Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
2e099e71
by Tony Chemit at 2022-03-19T16:49:35+01:00
-
52c61fc7
by Tony Chemit at 2022-03-19T16:49:35+01:00
15 changed files:
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/delete/DeleteExecutor.java
- + 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/delete/DeleteTreeAdapter.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/edit/actions/SaveContentEditUIAdapter.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/open/actions/SaveContentOpenableUIAdapter.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/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/ActivityUIHandler.java
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/observation/ActivityUIHandler.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/ActivityUIHandler.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/ActivityUIHandler.java
- client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/data/edit/GenerateContentEditUIDeleteTreeAdapter.java
- client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/data/openable/GenerateContentOpenableUIDeleteTreeAdapter.java
- client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/data/rlist/GenerateContentRootListUINavigationNode.java
- client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/data/ropen/GenerateContentRootOpenableUIDeleteTreeAdapter.java
Changes:
| ... | ... | @@ -24,6 +24,7 @@ package fr.ird.observe.client.datasource.editor.api.content.actions.delete; |
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.client.datasource.editor.api.DataSourceEditor;
|
| 26 | 26 | import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
| 27 | +import fr.ird.observe.client.datasource.editor.api.navigation.NavigationUI;
|
|
| 27 | 28 | import fr.ird.observe.client.util.ObserveSwingTechnicalException;
|
| 28 | 29 | import org.apache.logging.log4j.LogManager;
|
| 29 | 30 | import org.apache.logging.log4j.Logger;
|
| ... | ... | @@ -73,13 +74,14 @@ public class DeleteExecutor { |
| 73 | 74 | if (optionalRequest.isPresent()) {
|
| 74 | 75 | DeleteRequest request = optionalRequest.get();
|
| 75 | 76 | String label = t("observe.ui.choice.confirm.delete");
|
| 76 | - actionExecutor.addAction(label, () -> consume(request, dataSourceEditor.getNavigationUI().getTree()));
|
|
| 77 | + actionExecutor.addAction(label, () -> consume(request, dataSourceEditor.getNavigationUI()));
|
|
| 77 | 78 | return;
|
| 78 | 79 | }
|
| 79 | 80 | log.warn("User cancel action.");
|
| 80 | 81 | }
|
| 81 | 82 | |
| 82 | - protected void consume(DeleteRequest request, NavigationTree tree) {
|
|
| 83 | + protected void consume(DeleteRequest request, NavigationUI navigationUI) {
|
|
| 84 | + NavigationTree tree = navigationUI.getTree();
|
|
| 83 | 85 | Set<String> ids = request.getIds();
|
| 84 | 86 | log.info(String.format("Delete adapt tree [start] %s", ids));
|
| 85 | 87 | Consumer<String> idConsumer = consumer.apply(request);
|
| ... | ... | @@ -88,7 +90,7 @@ public class DeleteExecutor { |
| 88 | 90 | }
|
| 89 | 91 | DeleteTreeAdapter<?> treeAdapter = this.treeAdapter.apply(request);
|
| 90 | 92 | try {
|
| 91 | - SwingUtilities.invokeAndWait(() -> treeAdapter.adaptTree(request, tree));
|
|
| 93 | + SwingUtilities.invokeAndWait(() -> treeAdapter.adaptTree(request, navigationUI, tree));
|
|
| 92 | 94 | } catch (Exception e) {
|
| 93 | 95 | throw new ObserveSwingTechnicalException(e);
|
| 94 | 96 | }
|
| 1 | +package fr.ird.observe.client.datasource.editor.api.content.actions.delete;
|
|
| 2 | + |
|
| 3 | +/*-
|
|
| 4 | + * #%L
|
|
| 5 | + * ObServe Client :: DataSource :: Editor :: API
|
|
| 6 | + * %%
|
|
| 7 | + * Copyright (C) 2008 - 2022 IRD, Code Lutin, Ultreia.io
|
|
| 8 | + * %%
|
|
| 9 | + * This program is free software: you can redistribute it and/or modify
|
|
| 10 | + * it under the terms of the GNU General Public License as
|
|
| 11 | + * published by the Free Software Foundation, either version 3 of the
|
|
| 12 | + * License, or (at your option) any later version.
|
|
| 13 | + *
|
|
| 14 | + * This program is distributed in the hope that it will be useful,
|
|
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 | + * GNU General Public License for more details.
|
|
| 18 | + *
|
|
| 19 | + * You should have received a copy of the GNU General Public
|
|
| 20 | + * License along with this program. If not, see
|
|
| 21 | + * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 | + * #L%
|
|
| 23 | + */
|
|
| 24 | + |
|
| 25 | +import fr.ird.observe.client.datasource.editor.api.navigation.NavigationUI;
|
|
| 26 | +import fr.ird.observe.client.datasource.editor.api.navigation.NavigationUIHandler;
|
|
| 27 | +import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
|
| 28 | +import fr.ird.observe.client.datasource.editor.api.navigation.tree.root.RootNavigationInitializer;
|
|
| 29 | + |
|
| 30 | +import java.util.Set;
|
|
| 31 | +import java.util.function.Function;
|
|
| 32 | + |
|
| 33 | +/**
|
|
| 34 | + * Created on 19/03/2022.
|
|
| 35 | + *
|
|
| 36 | + * @author Tony Chemit - dev@tchemit.fr
|
|
| 37 | + * @since 9.0.0
|
|
| 38 | + */
|
|
| 39 | +public abstract class DeleteRootTreeAdapter<OldParent extends NavigationNode> extends DeleteTreeAdapter<OldParent> {
|
|
| 40 | + |
|
| 41 | + public DeleteRootTreeAdapter(NavigationNode incomingNode, Function<NavigationNode, OldParent> parentSupplier) {
|
|
| 42 | + super(incomingNode, parentSupplier);
|
|
| 43 | + }
|
|
| 44 | + |
|
| 45 | + @Override
|
|
| 46 | + public void removeChildren(NavigationUI navigationUI, OldParent parentNode, Set<String> ids) {
|
|
| 47 | + super.removeChildren(navigationUI, parentNode, ids);
|
|
| 48 | + RootNavigationInitializer initializer = (RootNavigationInitializer) parentNode.getRoot().getInitializer();
|
|
| 49 | + boolean removeGroupBy = parentNode.getChildCount() == 0 && !initializer.getRequest().isLoadEmptyGroupBy();
|
|
| 50 | + if (removeGroupBy) {
|
|
| 51 | + parentNode.removeFromParent();
|
|
| 52 | + }
|
|
| 53 | + NavigationUIHandler.updateStatistics(navigationUI, removeGroupBy ? -1 : 0, -ids.size());
|
|
| 54 | + }
|
|
| 55 | +} |
| ... | ... | @@ -23,6 +23,7 @@ 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.NavigationTree;
|
| 26 | +import fr.ird.observe.client.datasource.editor.api.navigation.NavigationUI;
|
|
| 26 | 27 | import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
| 27 | 28 | |
| 28 | 29 | import java.util.Objects;
|
| ... | ... | @@ -52,12 +53,14 @@ public abstract class DeleteTreeAdapter<OldParent extends NavigationNode> { |
| 52 | 53 | this.parentSupplier = Objects.requireNonNull(parentSupplier);
|
| 53 | 54 | }
|
| 54 | 55 | |
| 55 | - public abstract void removeChildren(OldParent parentNode, Set<String> ids);
|
|
| 56 | + public void removeChildren(NavigationUI navigationUI, OldParent parentNode, Set<String> ids) {
|
|
| 57 | + parentNode.removeChildren(ids);
|
|
| 58 | + }
|
|
| 56 | 59 | |
| 57 | - public final void adaptTree(DeleteRequest request, NavigationTree tree) {
|
|
| 60 | + public final void adaptTree(DeleteRequest request, NavigationUI navigationUI, NavigationTree tree) {
|
|
| 58 | 61 | OldParent parentNode = getOldParentNode(getIncomingNode());
|
| 59 | 62 | Set<String> ids = request.getIds();
|
| 60 | - adaptParentNode(parentNode, ids);
|
|
| 63 | + adaptParentNode(navigationUI, parentNode, ids);
|
|
| 61 | 64 | doFinalSelect(tree, parentNode);
|
| 62 | 65 | }
|
| 63 | 66 | |
| ... | ... | @@ -65,11 +68,11 @@ public abstract class DeleteTreeAdapter<OldParent extends NavigationNode> { |
| 65 | 68 | return parentSupplier.apply(incomingNode);
|
| 66 | 69 | }
|
| 67 | 70 | |
| 68 | - public final void adaptParentNode(OldParent parentNode, Set<String> ids) {
|
|
| 71 | + public final void adaptParentNode(NavigationUI navigationUI, OldParent parentNode, Set<String> ids) {
|
|
| 69 | 72 | // reload node data
|
| 70 | 73 | parentNode.reloadNodeData();
|
| 71 | 74 | // remove obsolete nodes
|
| 72 | - removeChildren(parentNode, ids);
|
|
| 75 | + removeChildren(navigationUI, parentNode, ids);
|
|
| 73 | 76 | }
|
| 74 | 77 | |
| 75 | 78 | public final void doFinalSelect(NavigationTree tree, OldParent parentNode) {
|
| ... | ... | @@ -53,5 +53,9 @@ public class SaveContentEditUIAdapter<D extends EditableDto, U extends ContentEd |
| 53 | 53 | // apply extra actions from previous opened content (go back to correct tab if any, ...)
|
| 54 | 54 | U newUi = dataSourceEditor.getModel().getTypedContent();
|
| 55 | 55 | newUi.resetFromPreviousUi(ui);
|
| 56 | + |
|
| 57 | + if (notPersisted) {
|
|
| 58 | + dataSourceEditor.getNavigationUI().getTree().expandPath(dataSourceEditor.getNavigationUI().getTree().getSelectionPath());
|
|
| 59 | + }
|
|
| 56 | 60 | }
|
| 57 | 61 | } |
| ... | ... | @@ -27,6 +27,7 @@ import fr.ird.observe.client.datasource.editor.api.content.actions.save.SaveUIAd |
| 27 | 27 | import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUI;
|
| 28 | 28 | import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUIModel;
|
| 29 | 29 | import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUINavigationNode;
|
| 30 | +import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
|
| 30 | 31 | import fr.ird.observe.dto.data.OpenableDto;
|
| 31 | 32 | |
| 32 | 33 | import javax.swing.AbstractButton;
|
| ... | ... | @@ -68,23 +69,28 @@ public class SaveContentOpenableUIAdapter<D extends OpenableDto, U extends Conte |
| 68 | 69 | // As I prefer to use a unique code (for persisted or not, keep it like this)
|
| 69 | 70 | node.updateReference(bean.getId());
|
| 70 | 71 | |
| 71 | - afterNodeUpdated(dataSourceEditor, ui, node, notPersisted, bean);
|
|
| 72 | + NavigationTree tree = dataSourceEditor.getNavigationUI().getTree();
|
|
| 73 | + afterNodeUpdated(dataSourceEditor, ui, tree, node, notPersisted, bean);
|
|
| 72 | 74 | }
|
| 73 | 75 | |
| 74 | - protected void afterNodeUpdated(DataSourceEditor dataSourceEditor, U ui, ContentOpenableUINavigationNode node, boolean notPersisted, D bean) {
|
|
| 76 | + protected void afterNodeUpdated(DataSourceEditor dataSourceEditor, U ui, NavigationTree tree, ContentOpenableUINavigationNode node, boolean notPersisted, D bean) {
|
|
| 75 | 77 | |
| 76 | 78 | //FIXME A startEdit should do the math?
|
| 77 | - dataSourceEditor.getNavigationUI().getTree().reSelectSafeNode(node);
|
|
| 79 | + tree.reSelectSafeNode(node);
|
|
| 78 | 80 | |
| 79 | 81 | U newUi = dataSourceEditor.getModel().getTypedContent();
|
| 80 | 82 | |
| 81 | 83 | if (notPersisted && predicate.test(bean)) {
|
| 82 | 84 | // reload ui and do click
|
| 83 | -// U content = dataSourceEditor.getModel().getTypedContent();
|
|
| 84 | 85 | SwingUtilities.invokeLater(() -> Objects.requireNonNull(buttonGetter).apply(newUi).doClick());
|
| 86 | + return;
|
|
| 85 | 87 | } else {
|
| 86 | 88 | // apply extra actions from previous opened content (go back to correct tab if any, ...)
|
| 87 | 89 | newUi.resetFromPreviousUi(ui);
|
| 88 | 90 | }
|
| 91 | + |
|
| 92 | + if (notPersisted) {
|
|
| 93 | + tree.expandPath(tree.getSelectionPath());
|
|
| 94 | + }
|
|
| 89 | 95 | }
|
| 90 | 96 | } |
| ... | ... | @@ -27,14 +27,10 @@ import fr.ird.observe.client.datasource.editor.api.content.actions.save.SaveUIAd |
| 27 | 27 | import fr.ird.observe.client.datasource.editor.api.content.data.ropen.ContentRootOpenableUI;
|
| 28 | 28 | import fr.ird.observe.client.datasource.editor.api.content.data.ropen.ContentRootOpenableUIModel;
|
| 29 | 29 | import fr.ird.observe.client.datasource.editor.api.content.data.ropen.ContentRootOpenableUINavigationNode;
|
| 30 | +import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
|
| 31 | +import fr.ird.observe.client.datasource.editor.api.navigation.NavigationUIHandler;
|
|
| 30 | 32 | import fr.ird.observe.dto.data.RootOpenableDto;
|
| 31 | 33 | |
| 32 | -import javax.swing.AbstractButton;
|
|
| 33 | -import javax.swing.SwingUtilities;
|
|
| 34 | -import java.util.Objects;
|
|
| 35 | -import java.util.function.Function;
|
|
| 36 | -import java.util.function.Predicate;
|
|
| 37 | - |
|
| 38 | 34 | /**
|
| 39 | 35 | * Created on 16/10/2020.
|
| 40 | 36 | *
|
| ... | ... | @@ -43,48 +39,28 @@ import java.util.function.Predicate; |
| 43 | 39 | */
|
| 44 | 40 | public class SaveContentRootOpenableUIAdapter<D extends RootOpenableDto, U extends ContentRootOpenableUI<D, U>> implements SaveUIAdapter<D, U> {
|
| 45 | 41 | |
| 46 | - private final Predicate<D> predicate;
|
|
| 47 | - private final Function<U, AbstractButton> buttonGetter;
|
|
| 48 | - |
|
| 49 | - public SaveContentRootOpenableUIAdapter() {
|
|
| 50 | - this.predicate = t -> false;
|
|
| 51 | - this.buttonGetter = null;
|
|
| 52 | - }
|
|
| 53 | - |
|
| 54 | - public SaveContentRootOpenableUIAdapter(Predicate<D> predicate, Function<U, AbstractButton> buttonGetter) {
|
|
| 55 | - this.predicate = Objects.requireNonNull(predicate);
|
|
| 56 | - this.buttonGetter = Objects.requireNonNull(buttonGetter);
|
|
| 57 | - }
|
|
| 58 | - |
|
| 59 | 42 | @Override
|
| 60 | 43 | public final void adaptUi(DataSourceEditor dataSourceEditor, U ui, boolean notPersisted, D bean) {
|
| 61 | 44 | |
| 62 | 45 | ContentRootOpenableUIModel<?> model = ui.getModel();
|
| 63 | 46 | ui.stopEdit();
|
| 64 | 47 | |
| 65 | - ContentRootOpenableUINavigationNode node = model.getSource(); //??? .upToReferenceNode(model.getSource().getScope().getMainReferenceType());
|
|
| 66 | -// IdDto bean = request.getBean();
|
|
| 48 | + ContentRootOpenableUINavigationNode node = model.getSource();
|
|
| 67 | 49 | // We need to inject ot node the new reference (it could does not know the id if not persisted)
|
| 68 | 50 | // As I prefer to use a unique code (for persisted or not, keep it like this)
|
| 69 | 51 | node.updateReference(bean.getId());
|
| 70 | 52 | |
| 71 | - afterNodeUpdated(dataSourceEditor, ui, node, notPersisted, bean);
|
|
| 72 | - }
|
|
| 73 | - |
|
| 74 | - protected void afterNodeUpdated(DataSourceEditor dataSourceEditor, U ui, ContentRootOpenableUINavigationNode node, boolean notPersisted, D bean) {
|
|
| 75 | - |
|
| 76 | - //FIXME A startEdit should do the math?
|
|
| 77 | - dataSourceEditor.getNavigationUI().getTree().reSelectSafeNode(node);
|
|
| 53 | + NavigationTree tree = dataSourceEditor.getNavigationUI().getTree();
|
|
| 54 | + tree.reSelectSafeNode(node);
|
|
| 78 | 55 | |
| 79 | 56 | U newUi = dataSourceEditor.getModel().getTypedContent();
|
| 80 | 57 | |
| 81 | - if (notPersisted && predicate.test(bean)) {
|
|
| 82 | - // reload ui and do click
|
|
| 83 | -// U content = dataSourceEditor.getModel().getTypedContent();
|
|
| 84 | - SwingUtilities.invokeLater(() -> Objects.requireNonNull(buttonGetter).apply(newUi).doClick());
|
|
| 85 | - } else {
|
|
| 86 | - // apply extra actions from previous opened content (go back to correct tab if any, ...)
|
|
| 87 | - newUi.resetFromPreviousUi(ui);
|
|
| 58 | + // apply extra actions from previous opened content (go back to correct tab if any, ...)
|
|
| 59 | + newUi.resetFromPreviousUi(ui);
|
|
| 60 | + |
|
| 61 | + if (notPersisted) {
|
|
| 62 | + tree.expandPath(tree.getSelectionPath());
|
|
| 88 | 63 | }
|
| 64 | + NavigationUIHandler.updateStatistics(dataSourceEditor.getNavigationUI(), 0, 1);
|
|
| 89 | 65 | }
|
| 90 | 66 | } |
| ... | ... | @@ -50,6 +50,18 @@ 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 | + |
|
| 53 | 65 | public static void updateStatistics(NavigationUI ui) {
|
| 54 | 66 | NavigationResult navigationResult = ui.getTree().getRootNode().getInitializer().getNavigationResult();
|
| 55 | 67 | TreeConfigUIHandler.updateStatistics(navigationResult.getRequest(),
|
| ... | ... | @@ -27,6 +27,7 @@ import fr.ird.observe.client.datasource.editor.api.content.actions.save.NodeChil |
| 27 | 27 | import fr.ird.observe.client.datasource.editor.api.content.actions.save.SaveAction;
|
| 28 | 28 | import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUINavigationNode;
|
| 29 | 29 | import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.SaveContentOpenableUIAdapter;
|
| 30 | +import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
|
| 30 | 31 | import fr.ird.observe.dto.data.ll.logbook.ActivityDto;
|
| 31 | 32 | |
| 32 | 33 | /**
|
| ... | ... | @@ -44,9 +45,9 @@ class ActivityUIHandler extends GeneratedActivityUIHandler { |
| 44 | 45 | .call((r, d) -> getOpenableService().save(r.getParentId(), d))
|
| 45 | 46 | .then(new SaveContentOpenableUIAdapter<>(ActivityDto::isSetEnabled, ActivityUI::getAddSet) {
|
| 46 | 47 | @Override
|
| 47 | - protected void afterNodeUpdated(DataSourceEditor dataSourceEditor, ActivityUI ui, ContentOpenableUINavigationNode node, boolean notPersisted, ActivityDto bean) {
|
|
| 48 | + protected void afterNodeUpdated(DataSourceEditor dataSourceEditor, ActivityUI ui, NavigationTree tree, ContentOpenableUINavigationNode node, boolean notPersisted, ActivityDto bean) {
|
|
| 48 | 49 | ActivityUINavigationCapability.fillBuilder(NodeChildrenUpdate.afterUpdate(node, bean)).update();
|
| 49 | - super.afterNodeUpdated(dataSourceEditor, ui, node, notPersisted, bean);
|
|
| 50 | + super.afterNodeUpdated(dataSourceEditor, ui, tree, node, notPersisted, bean);
|
|
| 50 | 51 | }
|
| 51 | 52 | })
|
| 52 | 53 | .install(ui.getSave());
|
| ... | ... | @@ -27,6 +27,7 @@ import fr.ird.observe.client.datasource.editor.api.content.actions.save.NodeChil |
| 27 | 27 | import fr.ird.observe.client.datasource.editor.api.content.actions.save.SaveAction;
|
| 28 | 28 | import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUINavigationNode;
|
| 29 | 29 | import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.SaveContentOpenableUIAdapter;
|
| 30 | +import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
|
| 30 | 31 | import fr.ird.observe.dto.data.ll.observation.ActivityDto;
|
| 31 | 32 | |
| 32 | 33 | /**
|
| ... | ... | @@ -45,9 +46,9 @@ class ActivityUIHandler extends GeneratedActivityUIHandler { |
| 45 | 46 | .call((r, d) -> getOpenableService().save(r.getParentId(), d))
|
| 46 | 47 | .then(new SaveContentOpenableUIAdapter<>(ActivityDto::isSetEnabled, ActivityUI::getAddSet) {
|
| 47 | 48 | @Override
|
| 48 | - protected void afterNodeUpdated(DataSourceEditor dataSourceEditor, ActivityUI ui, ContentOpenableUINavigationNode node, boolean notPersisted, ActivityDto bean) {
|
|
| 49 | + protected void afterNodeUpdated(DataSourceEditor dataSourceEditor, ActivityUI ui, NavigationTree tree, ContentOpenableUINavigationNode node, boolean notPersisted, ActivityDto bean) {
|
|
| 49 | 50 | ActivityUINavigationCapability.fillBuilder(NodeChildrenUpdate.afterUpdate(node, bean)).update();
|
| 50 | - super.afterNodeUpdated(dataSourceEditor, ui, node, notPersisted, bean);
|
|
| 51 | + super.afterNodeUpdated(dataSourceEditor, ui, tree, node, notPersisted, bean);
|
|
| 51 | 52 | }
|
| 52 | 53 | })
|
| 53 | 54 | .install(ui.getSave());
|
| ... | ... | @@ -26,6 +26,7 @@ import fr.ird.observe.client.datasource.editor.api.content.actions.save.NodeChil |
| 26 | 26 | import fr.ird.observe.client.datasource.editor.api.content.actions.save.SaveAction;
|
| 27 | 27 | import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUINavigationNode;
|
| 28 | 28 | import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.SaveContentOpenableUIAdapter;
|
| 29 | +import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
|
| 29 | 30 | import fr.ird.observe.dto.data.ps.logbook.ActivityDto;
|
| 30 | 31 | import fr.ird.observe.dto.referential.ps.common.VesselActivityReference;
|
| 31 | 32 | |
| ... | ... | @@ -52,9 +53,9 @@ class ActivityUIHandler extends GeneratedActivityUIHandler { |
| 52 | 53 | .then(new SaveContentOpenableUIAdapter<>(ActivityDto::isSetEnabled, ActivityUI::getAddSet) {
|
| 53 | 54 | |
| 54 | 55 | @Override
|
| 55 | - protected void afterNodeUpdated(DataSourceEditor dataSourceEditor, ActivityUI ui, ContentOpenableUINavigationNode node, boolean notPersisted, ActivityDto bean) {
|
|
| 56 | + protected void afterNodeUpdated(DataSourceEditor dataSourceEditor, ActivityUI ui, NavigationTree tree, ContentOpenableUINavigationNode node, boolean notPersisted, ActivityDto bean) {
|
|
| 56 | 57 | ActivityUINavigationCapability.fillBuilder(NodeChildrenUpdate.afterUpdate(node, bean)).update();
|
| 57 | - super.afterNodeUpdated(dataSourceEditor, ui, node, notPersisted, bean);
|
|
| 58 | + super.afterNodeUpdated(dataSourceEditor, ui, tree, node, notPersisted, bean);
|
|
| 58 | 59 | }
|
| 59 | 60 | })
|
| 60 | 61 | .install(ui.getSave());
|
| ... | ... | @@ -26,6 +26,7 @@ import fr.ird.observe.client.datasource.editor.api.content.actions.save.NodeChil |
| 26 | 26 | import fr.ird.observe.client.datasource.editor.api.content.actions.save.SaveAction;
|
| 27 | 27 | import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUINavigationNode;
|
| 28 | 28 | import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.SaveContentOpenableUIAdapter;
|
| 29 | +import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
|
| 29 | 30 | import fr.ird.observe.dto.ProtectedIdsPs;
|
| 30 | 31 | import fr.ird.observe.dto.data.ps.observation.ActivityDto;
|
| 31 | 32 | import fr.ird.observe.dto.referential.ps.common.VesselActivityReference;
|
| ... | ... | @@ -81,10 +82,9 @@ public class ActivityUIHandler extends GeneratedActivityUIHandler { |
| 81 | 82 | .call((r, d) -> getOpenableService().save(r.getParentId(), d))
|
| 82 | 83 | .then(new SaveContentOpenableUIAdapter<>(ActivityDto::isStrongSetOperation, ActivityUI::getAddSet) {
|
| 83 | 84 | @Override
|
| 84 | - protected void afterNodeUpdated(DataSourceEditor dataSourceEditor, ActivityUI ui, ContentOpenableUINavigationNode node, boolean notPersisted, ActivityDto bean) {
|
|
| 85 | - ActivityUINavigationCapability.fillBuilder(NodeChildrenUpdate.afterUpdate(node, bean))
|
|
| 86 | - .update();
|
|
| 87 | - super.afterNodeUpdated(dataSourceEditor, ui, node, notPersisted, bean);
|
|
| 85 | + protected void afterNodeUpdated(DataSourceEditor dataSourceEditor, ActivityUI ui, NavigationTree tree, ContentOpenableUINavigationNode node, boolean notPersisted, ActivityDto bean) {
|
|
| 86 | + ActivityUINavigationCapability.fillBuilder(NodeChildrenUpdate.afterUpdate(node, bean)).update();
|
|
| 87 | + super.afterNodeUpdated(dataSourceEditor, ui, tree, node, notPersisted, bean);
|
|
| 88 | 88 | }
|
| 89 | 89 | })
|
| 90 | 90 | .install(ui.getSave());
|
| ... | ... | @@ -47,10 +47,6 @@ public class GenerateContentEditUIDeleteTreeAdapter extends GenerateContentEditU |
| 47 | 47 | " public Generated%1$sUIDeleteTreeAdapter(%1$sUINavigationNode incomingNode) {\n" +
|
| 48 | 48 | " super(incomingNode, e -> incomingNode.getParent());\n" +
|
| 49 | 49 | " }\n\n" +
|
| 50 | - " @Override\n" +
|
|
| 51 | - " public void removeChildren(%2$sUINavigationNode oldParentNode, Set<String> ids) {\n" +
|
|
| 52 | - " oldParentNode.removeChildren(ids);\n" +
|
|
| 53 | - " }\n" +
|
|
| 54 | 50 | "}\n";
|
| 55 | 51 | public static final String CONTENT = "" +
|
| 56 | 52 | "public class %1$sUIDeleteTreeAdapter extends Generated%1$sUIDeleteTreeAdapter {\n\n" +
|
| ... | ... | @@ -62,10 +58,10 @@ public class GenerateContentEditUIDeleteTreeAdapter extends GenerateContentEditU |
| 62 | 58 | @Override
|
| 63 | 59 | protected String generateAbstractContent0(Path sourceDirectory, Path targetDirectory, Path path, String packageName, String namePrefix) {
|
| 64 | 60 | List<String> imports = new LinkedList<>();
|
| 65 | - imports.add(Set.class.getName());
|
|
| 66 | - imports.add(DeleteTreeAdapter.class.getName());
|
|
| 67 | 61 | imports.add(DeleteRequest.class.getName());
|
| 62 | + imports.add(DeleteTreeAdapter.class.getName());
|
|
| 68 | 63 | imports.add(Function.class.getName());
|
| 64 | + imports.add(Set.class.getName());
|
|
| 69 | 65 | imports.add(scopeBuilder.editNode.getType().getName());
|
| 70 | 66 | return generate(GENERATED_CONTENT, imports, dtoNamePrefix, scopeBuilder.editNode.getType().getSimpleName().replace("Dto", ""));
|
| 71 | 67 | }
|
| ... | ... | @@ -55,10 +55,6 @@ public class GenerateContentOpenableUIDeleteTreeAdapter extends GenerateContentO |
| 55 | 55 | " public Generated%1$sUIDeleteTreeAdapter(%1$sUINavigationNode incomingNode) {\n" +
|
| 56 | 56 | " super(incomingNode, e -> incomingNode.getParent());\n" +
|
| 57 | 57 | " }\n\n" +
|
| 58 | - " @Override\n" +
|
|
| 59 | - " public void removeChildren(%1$sListUINavigationNode oldParentNode, Set<String> ids) {\n" +
|
|
| 60 | - " oldParentNode.removeChildren(ids);\n" +
|
|
| 61 | - " }\n" +
|
|
| 62 | 58 | "}\n";
|
| 63 | 59 | public static final String CONTENT = "" +
|
| 64 | 60 | "public class %1$sUIDeleteTreeAdapter extends Generated%1$sUIDeleteTreeAdapter {\n\n" +
|
| ... | ... | @@ -73,10 +69,10 @@ public class GenerateContentOpenableUIDeleteTreeAdapter extends GenerateContentO |
| 73 | 69 | @Override
|
| 74 | 70 | protected String generateAbstractContent0(Path sourceDirectory, Path targetDirectory, Path path, String packageName, String namePrefix) {
|
| 75 | 71 | List<String> imports = new LinkedList<>();
|
| 76 | - imports.add(Set.class.getName());
|
|
| 77 | - imports.add(DeleteTreeAdapter.class.getName());
|
|
| 78 | 72 | imports.add(DeleteRequest.class.getName());
|
| 73 | + imports.add(DeleteTreeAdapter.class.getName());
|
|
| 79 | 74 | imports.add(Function.class.getName());
|
| 75 | + imports.add(Set.class.getName());
|
|
| 80 | 76 | String siblingMethod = "findParentSibling";
|
| 81 | 77 | if (scopeBuilder.selectNode.getParent()==null) {
|
| 82 | 78 | siblingMethod = "findSibling";
|
| ... | ... | @@ -40,17 +40,6 @@ import java.util.Set; |
| 40 | 40 | */
|
| 41 | 41 | public class GenerateContentRootListUINavigationNode extends GenerateContentRootListUISupport {
|
| 42 | 42 | |
| 43 | - public static final String REMOVE_CHILDREN = "" +
|
|
| 44 | - " @Override\n" +
|
|
| 45 | - " public void removeChildren(Set<String> ids) {\n" +
|
|
| 46 | - " if (getChildCount() == ids.size() && !getParent().getInitializer().getRequest().isLoadEmptyGroupBy()) {\n" +
|
|
| 47 | - " // limit case : node will be empty, must remove it\n" +
|
|
| 48 | - " removeFromParent();\n" +
|
|
| 49 | - " return;\n" +
|
|
| 50 | - " }\n" +
|
|
| 51 | - " super.removeChildren(ids);\n" +
|
|
| 52 | - " }\n\n";
|
|
| 53 | - |
|
| 54 | 43 | @Override
|
| 55 | 44 | protected String generateConcreteContent(Path path, String packageName, String namePrefix) {
|
| 56 | 45 | List<String> imports = new LinkedList<>();
|
| ... | ... | @@ -67,8 +56,6 @@ public class GenerateContentRootListUINavigationNode extends GenerateContentRoot |
| 67 | 56 | context += ContentUINavigationContextHelper.generateGetParentSibling(cleanClassName);
|
| 68 | 57 | imports.add(Set.class.getName());
|
| 69 | 58 | context += ContentUINavigationContextHelper.generateAddChildren(dtoNamePrefix);
|
| 70 | - context += REMOVE_CHILDREN;
|
|
| 71 | 59 | return uiNavigationNodeHelper.generateContent(imports, context);
|
| 72 | 60 | }
|
| 73 | - |
|
| 74 | 61 | } |
| ... | ... | @@ -23,7 +23,7 @@ package fr.ird.observe.client.datasource.editor.spi.content.data.ropen; |
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.client.datasource.editor.api.content.actions.delete.DeleteRequest;
|
| 26 | -import fr.ird.observe.client.datasource.editor.api.content.actions.delete.DeleteTreeAdapter;
|
|
| 26 | +import fr.ird.observe.client.datasource.editor.api.content.actions.delete.DeleteRootTreeAdapter;
|
|
| 27 | 27 | |
| 28 | 28 | import java.nio.file.Path;
|
| 29 | 29 | import java.util.LinkedList;
|
| ... | ... | @@ -40,7 +40,7 @@ import java.util.function.Function; |
| 40 | 40 | public class GenerateContentRootOpenableUIDeleteTreeAdapter extends GenerateContentRootOpenableUISupport {
|
| 41 | 41 | |
| 42 | 42 | public static final String GENERATED_CONTENT = "" +
|
| 43 | - "public abstract class Generated%1$sUIDeleteTreeAdapter extends DeleteTreeAdapter<%1$sListUINavigationNode> {\n" +
|
|
| 43 | + "public abstract class Generated%1$sUIDeleteTreeAdapter extends DeleteRootTreeAdapter<%1$sListUINavigationNode> {\n" +
|
|
| 44 | 44 | "\n" +
|
| 45 | 45 | " public static Function<DeleteRequest, %1$sUIDeleteTreeAdapter> create(%1$sListUI ui) {\n" +
|
| 46 | 46 | " return r -> new %1$sUIDeleteTreeAdapter(ui.getModel().getSource());\n" +
|
| ... | ... | @@ -55,10 +55,6 @@ public class GenerateContentRootOpenableUIDeleteTreeAdapter extends GenerateCont |
| 55 | 55 | " public Generated%1$sUIDeleteTreeAdapter(%1$sUINavigationNode incomingNode) {\n" +
|
| 56 | 56 | " super(incomingNode, e -> incomingNode.getParent());\n" +
|
| 57 | 57 | " }\n\n" +
|
| 58 | - " @Override\n" +
|
|
| 59 | - " public void removeChildren(%1$sListUINavigationNode oldParentNode, Set<String> ids) {\n" +
|
|
| 60 | - " oldParentNode.removeChildren(ids);\n" +
|
|
| 61 | - " }\n" +
|
|
| 62 | 58 | "}\n";
|
| 63 | 59 | public static final String CONTENT = "" +
|
| 64 | 60 | "public class %1$sUIDeleteTreeAdapter extends Generated%1$sUIDeleteTreeAdapter {\n\n" +
|
| ... | ... | @@ -73,10 +69,10 @@ public class GenerateContentRootOpenableUIDeleteTreeAdapter extends GenerateCont |
| 73 | 69 | @Override
|
| 74 | 70 | protected String generateAbstractContent0(Path sourceDirectory, Path targetDirectory, Path path, String packageName, String namePrefix) {
|
| 75 | 71 | List<String> imports = new LinkedList<>();
|
| 76 | - imports.add(Set.class.getName());
|
|
| 77 | - imports.add(DeleteTreeAdapter.class.getName());
|
|
| 78 | 72 | imports.add(DeleteRequest.class.getName());
|
| 73 | + imports.add(DeleteRootTreeAdapter.class.getName());
|
|
| 79 | 74 | imports.add(Function.class.getName());
|
| 75 | + imports.add(Set.class.getName());
|
|
| 80 | 76 | String siblingMethod = "findParentSibling";
|
| 81 | 77 | if (scopeBuilder.selectNode.getParent() == null) {
|
| 82 | 78 | siblingMethod = "findSibling";
|