Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
4fde4c23
by Tony Chemit at 2023-04-01T16:02:43+02:00
-
5930e9e5
by Tony Chemit at 2023-04-01T16:02:43+02:00
-
445e730f
by Tony Chemit at 2023-04-01T16:02:43+02:00
-
acb6bc6c
by Tony Chemit at 2023-04-01T16:02:44+02:00
10 changed files:
- client/core/src/main/resources/fr/ird/observe/client/ui/ObserveCommon.jcss
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/delete/DeleteRootTreeAdapter.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/move/MoveExecutor.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/move/MoveTreeAdapter.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/move/layout/MoveLayoutExecutor.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/move/layout/MoveLayoutTreeAdapter.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/ropen/actions/SaveContentRootOpenableUIAdapter.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/NavigationUIHandler.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/RouteListUI.jaxx
- toolkit/api-services/src/main/java/fr/ird/observe/services/service/data/MoveRequest.java
Changes:
| ... | ... | @@ -195,3 +195,7 @@ BlockingLayerUI { |
| 195 | 195 | .editableAndNotModified {
|
| 196 | 196 | enabled:{states.isEditable() && !states.isModified()};
|
| 197 | 197 | }
|
| 198 | + |
|
| 199 | +.editableAndShowDataAndNotEmpty {
|
|
| 200 | + enabled:{states.isEditable() && states.isShowData() && !states.isEmpty()};
|
|
| 201 | +} |
| ... | ... | @@ -23,7 +23,6 @@ package fr.ird.observe.client.datasource.editor.api.content.actions.delete; |
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.client.datasource.editor.api.navigation.NavigationUI;
|
| 26 | -import fr.ird.observe.client.datasource.editor.api.navigation.NavigationUIHandler;
|
|
| 27 | 26 | import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
| 28 | 27 | import fr.ird.observe.client.datasource.editor.api.navigation.tree.root.RootNavigationInitializer;
|
| 29 | 28 | |
| ... | ... | @@ -45,6 +44,8 @@ public abstract class DeleteRootTreeAdapter<OldParent extends NavigationNode> ex |
| 45 | 44 | @Override
|
| 46 | 45 | public void removeChildren(NavigationUI navigationUI, OldParent parentNode, Set<String> ids) {
|
| 47 | 46 | super.removeChildren(navigationUI, parentNode, ids);
|
| 47 | + // update navigation result
|
|
| 48 | + navigationUI.getTree().getModel().updateNavigationResult();
|
|
| 48 | 49 | NavigationNode rootNode = parentNode.getRoot();
|
| 49 | 50 | RootNavigationInitializer initializer = (RootNavigationInitializer) rootNode.getInitializer();
|
| 50 | 51 | boolean removeGroupBy = parentNode.getChildCount() == 0 && !initializer.getRequest().isLoadEmptyGroupBy();
|
| ... | ... | @@ -54,6 +55,5 @@ public abstract class DeleteRootTreeAdapter<OldParent extends NavigationNode> ex |
| 54 | 55 | navigationUI.getTree().selectFirstNode();
|
| 55 | 56 | }
|
| 56 | 57 | }
|
| 57 | - NavigationUIHandler.updateStatistics(navigationUI, removeGroupBy ? -1 : 0, -ids.size());
|
|
| 58 | 58 | }
|
| 59 | 59 | } |
| ... | ... | @@ -27,6 +27,7 @@ import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree; |
| 27 | 27 | import fr.ird.observe.client.util.ObserveSwingTechnicalException;
|
| 28 | 28 | import fr.ird.observe.datasource.security.ConcurrentModificationException;
|
| 29 | 29 | import fr.ird.observe.dto.ToolkitIdDtoBean;
|
| 30 | +import fr.ird.observe.navigation.tree.navigation.NavigationTreeConfig;
|
|
| 30 | 31 | import fr.ird.observe.services.service.data.MoveRequest;
|
| 31 | 32 | import org.apache.logging.log4j.LogManager;
|
| 32 | 33 | import org.apache.logging.log4j.Logger;
|
| ... | ... | @@ -90,7 +91,14 @@ public class MoveExecutor { |
| 90 | 91 | ToolkitIdDtoBean oldParentId = request.getOldParentId();
|
| 91 | 92 | Set<String> referenceId = request.getIds();
|
| 92 | 93 | log.info(String.format("Move adapt tree [start] %s from parent: %s to %s", referenceId, oldParentId, newParentId));
|
| 93 | - |
|
| 94 | + String oldGroupByValue;
|
|
| 95 | + if (request.isNewParentIsRootType()) {
|
|
| 96 | + // if new parent id is a Trip, then we need to keep back his groupBy value
|
|
| 97 | + NavigationTreeConfig config = tree.getModel().getConfig();
|
|
| 98 | + oldGroupByValue = tree.getModel().getDataSourcesManager().getMainDataSource().getRootOpenableService().getGroupByValue(config.getGroupByName(), config.getGroupByFlavor(), newParentId.getId());
|
|
| 99 | + } else {
|
|
| 100 | + oldGroupByValue = null;
|
|
| 101 | + }
|
|
| 94 | 102 | Set<String> newIds;
|
| 95 | 103 | try {
|
| 96 | 104 | newIds = requestConsumer.apply(request, newParentId, referenceId);
|
| ... | ... | @@ -100,7 +108,7 @@ public class MoveExecutor { |
| 100 | 108 | |
| 101 | 109 | MoveTreeAdapter<?, ?, ?> moveTreeAdapter = this.treeAdapter.apply(request);
|
| 102 | 110 | try {
|
| 103 | - SwingUtilities.invokeAndWait(() -> moveTreeAdapter.adaptTree(request, tree, newIds));
|
|
| 111 | + SwingUtilities.invokeAndWait(() -> moveTreeAdapter.adaptTree(request, tree, newIds, oldGroupByValue));
|
|
| 104 | 112 | } catch (InterruptedException | InvocationTargetException e) {
|
| 105 | 113 | throw new ObserveSwingTechnicalException(e.getCause());
|
| 106 | 114 | }
|
| ... | ... | @@ -22,8 +22,10 @@ package fr.ird.observe.client.datasource.editor.api.content.actions.move; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | +import fr.ird.observe.client.datasource.editor.api.content.data.rlist.ContentRootListUINavigationNode;
|
|
| 25 | 26 | import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
| 26 | 27 | import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
| 28 | +import fr.ird.observe.navigation.tree.navigation.NavigationTreeConfig;
|
|
| 27 | 29 | import fr.ird.observe.services.service.data.MoveRequest;
|
| 28 | 30 | |
| 29 | 31 | import java.util.Objects;
|
| ... | ... | @@ -50,24 +52,44 @@ public abstract class MoveTreeAdapter<OldParent extends NavigationNode, NewParen |
| 50 | 52 | |
| 51 | 53 | public abstract NewNode addMissingChildren(NewParent newParentNode, String newId);
|
| 52 | 54 | |
| 53 | - public final void adaptTree(MoveRequest request, NavigationTree tree, Set<String> newIds) {
|
|
| 55 | + public final void adaptTree(MoveRequest request, NavigationTree tree, Set<String> newIds, String oldGroupByValue) {
|
|
| 54 | 56 | Set<String> ids = request.getIds();
|
| 55 | 57 | boolean selectTarget = request.isSelectTarget();
|
| 56 | 58 | boolean multiple = !request.isSingle();
|
| 57 | 59 | OldParent oldParentNode = getOldParentNode(getIncomingNode());
|
| 58 | - NewParent newParentNode = getNewParentNode(oldParentNode, request.getNewParentId().getId());
|
|
| 59 | - NavigationNode nodeToSelect = adaptNewParentNode(newParentNode, multiple || !selectTarget ? null : newIds.iterator().next());
|
|
| 60 | + String newParentId = request.getNewParentId().getId();
|
|
| 61 | + if (request.isNewParentIsRootType()) {
|
|
| 62 | + NavigationTreeConfig config = tree.getModel().getConfig();
|
|
| 63 | + String groupByValue = oldParentNode.getContext().getServicesProvider().getRootOpenableService().getGroupByValue(config.getGroupByName(), config.getGroupByFlavor(), newParentId);
|
|
| 64 | + if (!Objects.equals(oldGroupByValue, groupByValue)) {
|
|
| 65 | + // the navigation must be updated, new parent groupBy value has changed
|
|
| 66 | + String[] previousPaths = oldParentNode.toPaths();
|
|
| 67 | + tree.getModel().updateNavigationResult();
|
|
| 68 | + // update the old parent parent node
|
|
| 69 | + ContentRootListUINavigationNode oldParentNodeParent = (ContentRootListUINavigationNode) oldParentNode.upToGroupByValue();
|
|
| 70 | + oldParentNodeParent.updateNode();
|
|
| 71 | + // get the new old parent node
|
|
| 72 | + oldParentNode = (OldParent) tree.getModel().getNodeFromPath(previousPaths, false);
|
|
| 73 | + // need also to update the new parent old parent node
|
|
| 74 | + ContentRootListUINavigationNode newParentOldParentNode = (ContentRootListUINavigationNode) tree.getModel().getNodeFromPath(new String[]{oldGroupByValue}, false);
|
|
| 75 | + if (newParentOldParentNode != null) {
|
|
| 76 | + // only update it if it still exist (the node may have been removed from navigation tree)
|
|
| 77 | + newParentOldParentNode.updateNode();
|
|
| 78 | + if (!config.isLoadEmptyGroupBy() && newParentOldParentNode.getChildCount() == 0) {
|
|
| 79 | + // the configuration requires that node to be removed
|
|
| 80 | + newParentOldParentNode.removeFromParent();
|
|
| 81 | + }
|
|
| 82 | + }
|
|
| 83 | + }
|
|
| 84 | + }
|
|
| 85 | + NewParent newParentNode = getNewParentNode(oldParentNode, newParentId);
|
|
| 86 | + |
|
| 87 | + // kep old node paths
|
|
| 88 | + String[] oldNodePaths = oldParentNode.toPaths();
|
|
| 89 | + NavigationNode nodeToSelect = adaptNewParentNode(tree, newParentNode, multiple || !selectTarget ? null : newIds.iterator().next());
|
|
| 60 | 90 | if (!selectTarget) {
|
| 61 | 91 | // stay on old parent node
|
| 62 | - nodeToSelect = oldParentNode;
|
|
| 63 | - } else {
|
|
| 64 | - if (multiple) {
|
|
| 65 | - // on multiple move select new parent node
|
|
| 66 | - nodeToSelect = newParentNode;
|
|
| 67 | - } else if (nodeToSelect == null) {
|
|
| 68 | - // this can happen if new parent node was not loaded before the service call
|
|
| 69 | - nodeToSelect = newParentNode;
|
|
| 70 | - }
|
|
| 92 | + nodeToSelect = tree.getModel().getNodeFromPath(oldNodePaths, false);
|
|
| 71 | 93 | }
|
| 72 | 94 | adaptOldParentNode(oldParentNode, ids);
|
| 73 | 95 | doFinalSelect(selectTarget, tree, nodeToSelect);
|
| ... | ... | @@ -82,18 +104,17 @@ public abstract class MoveTreeAdapter<OldParent extends NavigationNode, NewParen |
| 82 | 104 | oldParentNode.reloadNodeDataToRootAndChildren();
|
| 83 | 105 | }
|
| 84 | 106 | |
| 85 | - public final NewNode adaptNewParentNode(NewParent newParentNode, String newId) {
|
|
| 107 | + public final NavigationNode adaptNewParentNode(NavigationTree tree, NewParent newParentNode, String newId) {
|
|
| 86 | 108 | // reload node
|
| 87 | - newParentNode.reloadNodeDataToRootAndChildren();
|
|
| 88 | - // add new nodes
|
|
| 89 | - // refresh ui FIXME:Tree this should be done by addMissingChildren ?
|
|
| 90 | - newParentNode.nodeChanged();
|
|
| 91 | - NewNode newNode = addMissingChildren(newParentNode, newId);
|
|
| 92 | -// if (newNode!=null) {
|
|
| 93 | -// // and reload his parent
|
|
| 94 | -// newNode.getParent().reloadNodeData();
|
|
| 95 | -// }
|
|
| 96 | - return newNode;
|
|
| 109 | + String[] paths = newParentNode.toPaths();
|
|
| 110 | + ContentRootListUINavigationNode newParentOldParentNode = (ContentRootListUINavigationNode) newParentNode.upToGroupByValue();
|
|
| 111 | + newParentOldParentNode.updateNode();
|
|
| 112 | + newParentNode = (NewParent) tree.getModel().getNodeFromPath(paths, false);
|
|
| 113 | + if (newId == null) {
|
|
| 114 | + return newParentNode;
|
|
| 115 | + }
|
|
| 116 | + // get new node
|
|
| 117 | + return addMissingChildren(newParentNode, newId);
|
|
| 97 | 118 | }
|
| 98 | 119 | |
| 99 | 120 | public final void doFinalSelect(boolean selectTarget, NavigationTree tree, NavigationNode nodeToSelect) {
|
| ... | ... | @@ -25,6 +25,7 @@ package fr.ird.observe.client.datasource.editor.api.content.actions.move.layout; |
| 25 | 25 | import fr.ird.observe.client.datasource.editor.api.DataSourceEditor;
|
| 26 | 26 | import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
| 27 | 27 | import fr.ird.observe.client.util.ObserveSwingTechnicalException;
|
| 28 | +import fr.ird.observe.navigation.tree.navigation.NavigationTreeConfig;
|
|
| 28 | 29 | import fr.ird.observe.services.service.data.MoveLayoutRequest;
|
| 29 | 30 | import org.apache.logging.log4j.LogManager;
|
| 30 | 31 | import org.apache.logging.log4j.Logger;
|
| ... | ... | @@ -88,11 +89,14 @@ public class MoveLayoutExecutor { |
| 88 | 89 | String oldParentId = request.getOldParentId();
|
| 89 | 90 | log.info(String.format("Move adapt tree [start] from parent: %s to %s", oldParentId, newParentId));
|
| 90 | 91 | |
| 92 | + NavigationTreeConfig config = tree.getModel().getConfig();
|
|
| 93 | + String oldGroupByValue = tree.getModel().getDataSourcesManager().getMainDataSource().getRootOpenableService().getGroupByValue(config.getGroupByName(), config.getGroupByFlavor(), newParentId);
|
|
| 94 | + |
|
| 91 | 95 | requestConsumer.accept(request);
|
| 92 | 96 | |
| 93 | 97 | MoveLayoutTreeAdapter<?, ?> moveTreeAdapter = treeAdapter.apply(request);
|
| 94 | 98 | try {
|
| 95 | - SwingUtilities.invokeAndWait(() -> moveTreeAdapter.adaptTree(request, tree));
|
|
| 99 | + SwingUtilities.invokeAndWait(() -> moveTreeAdapter.adaptTree(request, tree, oldGroupByValue));
|
|
| 96 | 100 | } catch (InterruptedException | InvocationTargetException e) {
|
| 97 | 101 | throw new ObserveSwingTechnicalException(e.getCause());
|
| 98 | 102 | }
|
| ... | ... | @@ -22,6 +22,7 @@ package fr.ird.observe.client.datasource.editor.api.content.actions.move.layout; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | +import fr.ird.observe.client.datasource.editor.api.content.data.rlist.ContentRootListUINavigationNode;
|
|
| 25 | 26 | import fr.ird.observe.client.datasource.editor.api.content.data.ropen.ContentRootOpenableUINavigationNode;
|
| 26 | 27 | import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
| 27 | 28 | import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
| ... | ... | @@ -48,15 +49,36 @@ public abstract class MoveLayoutTreeAdapter<ParentNode extends ContentRootOpenab |
| 48 | 49 | |
| 49 | 50 | public abstract SourceNode getNodeToSelect(ParentNode parentNode);
|
| 50 | 51 | |
| 51 | - public final void adaptTree(MoveLayoutRequest request, NavigationTree tree) {
|
|
| 52 | + public final void adaptTree(MoveLayoutRequest request, NavigationTree tree, String oldGroupByValue) {
|
|
| 52 | 53 | boolean selectTarget = request.isSelectTarget();
|
| 53 | 54 | ParentNode oldParentNode = oldParentSupplier.get();
|
| 54 | 55 | NavigationTreeConfig config = tree.getModel().getConfig();
|
| 55 | 56 | String newParentId = request.getNewParentId();
|
| 56 | - //FIXME NPE See https://gitlab.com/ultreiaio/ird-observe/-/issues/2656
|
|
| 57 | 57 | String groupByValue = oldParentNode.getContext().getServicesProvider().getRootOpenableService().getGroupByValue(config.getGroupByName(), config.getGroupByFlavor(), newParentId);
|
| 58 | + if (!Objects.equals(oldGroupByValue, groupByValue)) {
|
|
| 59 | + // the navigation must be updated, new parent groupBy value has changed
|
|
| 60 | + tree.getModel().updateNavigationResult();
|
|
| 61 | + // update the old parent parent node
|
|
| 62 | + ContentRootListUINavigationNode oldParentNodeParent = oldParentNode.getParent();
|
|
| 63 | + oldParentNodeParent.updateNode();
|
|
| 64 | + // get the new old parent node
|
|
| 65 | + oldParentNode = (ParentNode) oldParentNodeParent.findChildById(request.getOldParentId());
|
|
| 66 | + |
|
| 67 | + // need also to update the new parent old parent node
|
|
| 68 | + ContentRootListUINavigationNode newParentOldParentNode = (ContentRootListUINavigationNode) tree.getModel().getNodeFromPath(new String[]{oldGroupByValue}, false);
|
|
| 69 | + if (newParentOldParentNode != null) {
|
|
| 70 | + // only update it if it still exist (the node may have been removed from navigation tree)
|
|
| 71 | + newParentOldParentNode.updateNode();
|
|
| 72 | + if (!config.isLoadEmptyGroupBy() && newParentOldParentNode.getChildCount() == 0) {
|
|
| 73 | + // the configuration requires that node to be removed
|
|
| 74 | + newParentOldParentNode.removeFromParent();
|
|
| 75 | + }
|
|
| 76 | + }
|
|
| 77 | + } else {
|
|
| 78 | + |
|
| 79 | + oldParentNode.updateNode();
|
|
| 80 | + }
|
|
| 58 | 81 | @SuppressWarnings("unchecked") ParentNode newParentNode = (ParentNode) tree.getModel().getNodeFromPath(new String[]{groupByValue, newParentId}, true);
|
| 59 | - oldParentNode.updateNode();
|
|
| 60 | 82 | newParentNode.updateNode();
|
| 61 | 83 | if (selectTarget) {
|
| 62 | 84 | NavigationNode nodeToSelect = getNodeToSelect(newParentNode);
|
| ... | ... | @@ -30,13 +30,12 @@ import fr.ird.observe.client.datasource.editor.api.content.data.ropen.ContentRoo |
| 30 | 30 | import fr.ird.observe.client.datasource.editor.api.content.data.ropen.ContentRootOpenableUINavigationNode;
|
| 31 | 31 | import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
| 32 | 32 | import fr.ird.observe.client.datasource.editor.api.navigation.NavigationUI;
|
| 33 | -import fr.ird.observe.client.datasource.editor.api.navigation.NavigationUIHandler;
|
|
| 34 | -import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
|
| 35 | 33 | import fr.ird.observe.client.datasource.editor.api.navigation.tree.capability.ReferenceContainerCapability;
|
| 36 | 34 | import fr.ird.observe.client.datasource.editor.api.navigation.tree.root.RootNavigationNode;
|
| 37 | 35 | import fr.ird.observe.dto.data.DataGroupByDto;
|
| 38 | 36 | import fr.ird.observe.dto.data.RootOpenableDto;
|
| 39 | 37 | import fr.ird.observe.dto.reference.DataDtoReference;
|
| 38 | +import fr.ird.observe.navigation.tree.NavigationResult;
|
|
| 40 | 39 | import org.apache.logging.log4j.LogManager;
|
| 41 | 40 | import org.apache.logging.log4j.Logger;
|
| 42 | 41 | |
| ... | ... | @@ -70,16 +69,13 @@ public class SaveContentRootOpenableUIAdapter<D extends RootOpenableDto, U exten |
| 70 | 69 | boolean groupByChanged = !Objects.equals(oldGroupByDto.getFilterValue(), newGroupByValue);
|
| 71 | 70 | // We need to inject ot node the new reference (it could does not know the id if not persisted)
|
| 72 | 71 | // As I prefer to use a unique code (for persisted or not, keep it like this)
|
| 73 | - node = updateReference(dataSourceEditor.getNavigationUI(), node, bean.getId(), oldGroupByDto, groupByChanged ? newGroupByValue : null);
|
|
| 72 | + node = updateReference(dataSourceEditor.getNavigationUI(), node, bean.getId(), oldGroupByDto, groupByChanged, newGroupByValue);
|
|
| 74 | 73 | |
| 75 | 74 | tree.reSelectSafeNodeThen(node, () -> {
|
| 76 | 75 | dataSourceEditor.getModel().resetFromPreviousUi(ui);
|
| 77 | 76 | if (notPersisted) {
|
| 78 | 77 | tree.expandPath(tree.getSelectionPath());
|
| 79 | 78 | }
|
| 80 | - if (!groupByChanged) {
|
|
| 81 | - NavigationUIHandler.updateStatistics(dataSourceEditor.getNavigationUI(), 0, 1);
|
|
| 82 | - }
|
|
| 83 | 79 | });
|
| 84 | 80 | }
|
| 85 | 81 | |
| ... | ... | @@ -87,11 +83,13 @@ public class SaveContentRootOpenableUIAdapter<D extends RootOpenableDto, U exten |
| 87 | 83 | ContentRootOpenableUINavigationNode node,
|
| 88 | 84 | String id,
|
| 89 | 85 | DataGroupByDto<D> oldGroupByDto,
|
| 86 | + boolean groupByChanged,
|
|
| 90 | 87 | String newGroupByValue) {
|
| 91 | 88 | boolean notPersisted = node.getInitializer().isNotPersisted();
|
| 92 | - NavigationNode parent = node.getParent();
|
|
| 93 | - boolean groupByChanged = newGroupByValue != null;
|
|
| 89 | + ContentRootListUINavigationNode parent = node.getParent();
|
|
| 94 | 90 | if (groupByChanged) {
|
| 91 | + // the navigation must be updated, new parent groupBy value has changed
|
|
| 92 | + NavigationResult navigationResult = navigationUI.getTree().getModel().updateNavigationResult();
|
|
| 95 | 93 | // groupBy has changed (remove node from parent)
|
| 96 | 94 | RootNavigationNode rootNode = (RootNavigationNode) node.getRoot();
|
| 97 | 95 | node.removeFromParent();
|
| ... | ... | @@ -99,19 +97,19 @@ public class SaveContentRootOpenableUIAdapter<D extends RootOpenableDto, U exten |
| 99 | 97 | boolean removeGroupBy = parent.getChildCount() == 0 && !rootNode.getInitializer().getRequest().isLoadEmptyGroupBy();
|
| 100 | 98 | if (removeGroupBy) {
|
| 101 | 99 | parent.removeFromParent();
|
| 102 | - NavigationUIHandler.updateStatistics(navigationUI, -1, 0);
|
|
| 103 | 100 | } else {
|
| 104 | 101 | // update old parent to root
|
| 105 | 102 | parent.reloadNodeDataToRoot();
|
| 106 | 103 | }
|
| 107 | 104 | // find parent
|
| 108 | - parent = rootNode.findChildById(newGroupByValue);
|
|
| 105 | + parent = (ContentRootListUINavigationNode) rootNode.findChildById(newGroupByValue);
|
|
| 109 | 106 | if (parent == null) {
|
| 110 | 107 | // must create it (will update navigation result)
|
| 111 | - parent = rootNode.getCapability().createMissingNode(newGroupByValue);
|
|
| 108 | + DataGroupByDto<?> reference = navigationResult.getGroupBy(newGroupByValue);
|
|
| 109 | + parent = rootNode.getCapability().insertChildNode(reference);
|
|
| 112 | 110 | } else {
|
| 113 | 111 | // update parent reference in node
|
| 114 | - DataGroupByDto<?> parentReference = ((ContentRootListUINavigationNode) parent).getInitializer().getParentReference();
|
|
| 112 | + DataGroupByDto<?> parentReference = parent.getInitializer().getParentReference();
|
|
| 115 | 113 | node.getInitializer().setParentReference(() -> parentReference);
|
| 116 | 114 | }
|
| 117 | 115 | }
|
| ... | ... | @@ -129,7 +127,7 @@ public class SaveContentRootOpenableUIAdapter<D extends RootOpenableDto, U exten |
| 129 | 127 | node.populateChildrenIfNotLoaded();
|
| 130 | 128 | }
|
| 131 | 129 | |
| 132 | - ReferenceContainerCapability<?> capability = (ReferenceContainerCapability<?>) parent.getCapability();
|
|
| 130 | + ReferenceContainerCapability<?> capability = parent.getCapability();
|
|
| 133 | 131 | if (groupByChanged) {
|
| 134 | 132 | if (parent.isNotLoaded()) {
|
| 135 | 133 | // will load all children even the updated one
|
| ... | ... | @@ -50,18 +50,6 @@ public class NavigationUIHandler implements UIHandler<NavigationUI>, WithClientU |
| 50 | 50 | private Set<ReloadAction> actionsToReload;
|
| 51 | 51 | private NavigationUIInitializer initializer;
|
| 52 | 52 | |
| 53 | - public static void updateStatistics(NavigationUI ui, int groupByCountDiff, int dataCountDiff) {
|
|
| 54 | - NavigationResult navigationResult = ui.getTree().getRootNode().getInitializer().getNavigationResult();
|
|
| 55 | - TreeConfigUIHandler.updateStatistics(navigationResult.getRequest(),
|
|
| 56 | - ui.getTree().getModel().getGroupByHelper(),
|
|
| 57 | - () -> navigationResult.getGroupByCount() + groupByCountDiff,
|
|
| 58 | - () -> navigationResult.getGroupByDataCount() + dataCountDiff,
|
|
| 59 | - () -> navigationResult.getDataCount() + dataCountDiff,
|
|
| 60 | - ui::setStatisticsText,
|
|
| 61 | - ui::setStatisticsTip,
|
|
| 62 | - ui.getStatisticsLabel()::setIcon);
|
|
| 63 | - }
|
|
| 64 | - |
|
| 65 | 53 | public static void updateStatistics(NavigationUI ui) {
|
| 66 | 54 | NavigationResult navigationResult = ui.getTree().getRootNode().getInitializer().getNavigationResult();
|
| 67 | 55 | TreeConfigUIHandler.updateStatistics(navigationResult.getRequest(),
|
| ... | ... | @@ -28,5 +28,5 @@ |
| 28 | 28 | <RouteListUIModel id='model' constructorParams='@override:getNavigationSource(this)'/>
|
| 29 | 29 | <RouteListUIModelStates id='states'/>
|
| 30 | 30 | <TripDto id='bean'/>
|
| 31 | - <JMenuItem id='moveAll' styleClass='editableAndNotModified'/>
|
|
| 31 | + <JMenuItem id='moveAll' styleClass='editableAndShowDataAndNotEmpty'/>
|
|
| 32 | 32 | </fr.ird.observe.client.datasource.editor.api.content.data.list.ContentListUI> |
| ... | ... | @@ -24,6 +24,7 @@ package fr.ird.observe.services.service.data; |
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.dto.BusinessDto;
|
| 26 | 26 | import fr.ird.observe.dto.ToolkitIdDtoBean;
|
| 27 | +import fr.ird.observe.dto.data.RootOpenableDto;
|
|
| 27 | 28 | |
| 28 | 29 | import java.util.Set;
|
| 29 | 30 | import java.util.StringJoiner;
|
| ... | ... | @@ -92,6 +93,10 @@ public class MoveRequest { |
| 92 | 93 | return ids.size() == 1;
|
| 93 | 94 | }
|
| 94 | 95 | |
| 96 | + public boolean isNewParentIsRootType() {
|
|
| 97 | + return RootOpenableDto.class.isAssignableFrom(getParentTargetDtoType());
|
|
| 98 | + }
|
|
| 99 | + |
|
| 95 | 100 | @Override
|
| 96 | 101 | public String toString() {
|
| 97 | 102 | return new StringJoiner(", ", MoveRequest.class.getSimpleName() + "[", "]")
|