Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
71da0962
by Tony Chemit at 2021-02-13T17:29:06+01:00
27 changed files:
- client/core/src/main/java/fr/ird/observe/client/ObserveActionExecutor.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/edit/actions/MoveEdit.java → client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/move/MoveAction.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/MoveRequest.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/tree/MoveTreeAdapter.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/list/ContentListUINavigationInitializer.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/list/ContentListUINavigationNode.java
- − client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/list/actions/MoveMultiple.java
- − client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/open/actions/MoveOpenable.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/tree/NavigationNode.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/tree/capability/ReferenceContainerCapability.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/tree/root/RootNavigationNode.java
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/ActivitySampleUIHandler.java
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/SampleListUIHandler.java
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/SampleUIHandler.java
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/sample/ActivitySampleUIMoveTreeAdapter.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/move/tree/DefaultMultipleMoveTreeAdapter.java → client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/sample/ActivitySampleUIMoveTreeAdapterToTrip.java
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/sample/SampleUIHelper.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/move/tree/DefaultSingleMoveTreeAdapter.java → client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/sample/SampleUIMoveTreeAdapterToActivity.java
- client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/GenerateContentUISupport.java
- client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/data/list/GenerateContentListUINavigationNode.java
- client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/data/openable/ContentOpenableUIDescriptor.java
- + client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/data/openable/GenerateContentOpenableUIMoveTreeAdapter.java
- client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/data/openable/GenerateContentOpenableUINavigationNode.java
- client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/helper/ContentUIHandlerHelper.java
- client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/helper/ContentUINavigationContextHelper.java
Changes:
| ... | ... | @@ -46,9 +46,9 @@ public class ObserveActionExecutor extends ActionExecutor implements Closeable { |
| 46 | 46 |
|
| 47 | 47 |
@Override
|
| 48 | 48 |
protected void executeWorker(String actionLabel, ActionWorker<?, ?> worker) {
|
| 49 |
- log.info(String.format("Launch ObServe worker [%s] now...", actionLabel));
|
|
| 49 |
+ log.info(String.format("Launch ObServe worker [%s] register...", actionLabel));
|
|
| 50 | 50 |
executorService.execute(worker);
|
| 51 |
- log.info(String.format("Launch ObServe worker [%s] is on...", actionLabel));
|
|
| 51 |
+ log.info(String.format("Launch ObServe worker [%s] running....", actionLabel));
|
|
| 52 | 52 |
}
|
| 53 | 53 |
|
| 54 | 54 |
@Override
|
| 1 |
-package fr.ird.observe.client.datasource.editor.api.content.data.edit.actions;
|
|
| 1 |
+package fr.ird.observe.client.datasource.editor.api.content.actions.move;
|
|
| 2 | 2 |
|
| 3 | 3 |
/*-
|
| 4 | 4 |
* #%L
|
| ... | ... | @@ -24,14 +24,17 @@ package fr.ird.observe.client.datasource.editor.api.content.data.edit.actions; |
| 24 | 24 |
|
| 25 | 25 |
import com.google.common.collect.ImmutableSet;
|
| 26 | 26 |
import fr.ird.observe.client.datasource.editor.api.ObserveKeyStrokesEditorApi;
|
| 27 |
+import fr.ird.observe.client.datasource.editor.api.content.ContentUI;
|
|
| 27 | 28 |
import fr.ird.observe.client.datasource.editor.api.content.actions.ConfigureMenuAction;
|
| 28 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveExecutor;
|
|
| 29 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequest;
|
|
| 30 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequestBuilder;
|
|
| 31 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.tree.MoveTreeAdapter;
|
|
| 29 |
+import fr.ird.observe.client.datasource.editor.api.content.actions.ContentUIActionSupport;
|
|
| 32 | 30 |
import fr.ird.observe.client.datasource.editor.api.content.data.edit.ContentEditUI;
|
| 31 |
+import fr.ird.observe.client.datasource.editor.api.content.data.list.ContentListUI;
|
|
| 32 |
+import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUI;
|
|
| 33 | 33 |
import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUII18nHelper;
|
| 34 |
+import fr.ird.observe.dto.ObserveUtil;
|
|
| 35 |
+import fr.ird.observe.dto.data.DataDto;
|
|
| 34 | 36 |
import fr.ird.observe.dto.data.EditableDto;
|
| 37 |
+import fr.ird.observe.dto.data.OpenableDto;
|
|
| 35 | 38 |
|
| 36 | 39 |
import javax.swing.AbstractButton;
|
| 37 | 40 |
import java.awt.event.ActionEvent;
|
| ... | ... | @@ -41,31 +44,101 @@ import java.util.function.Function; |
| 41 | 44 |
import java.util.function.Supplier;
|
| 42 | 45 |
|
| 43 | 46 |
/**
|
| 44 |
- * Created on 12/10/2020.
|
|
| 47 |
+ * To move a data.
|
|
| 48 |
+ * <p>
|
|
| 49 |
+ * Created on 12/02/2021.
|
|
| 45 | 50 |
*
|
| 46 | 51 |
* @author Tony Chemit - dev@tchemit.fr
|
| 47 |
- * @since 8.0.1
|
|
| 52 |
+ * @since 8.0.6
|
|
| 48 | 53 |
*/
|
| 49 |
-public final class MoveEdit<D extends EditableDto, U extends ContentEditUI<D, U>> extends ContentEditUIActionSupport<D, U> implements ConfigureMenuAction<U> {
|
|
| 54 |
+public class MoveAction<D extends DataDto, U extends ContentUI> extends ContentUIActionSupport<U> implements ConfigureMenuAction<U> {
|
|
| 50 | 55 |
|
| 56 |
+ /**
|
|
| 57 |
+ * To execute the move action.
|
|
| 58 |
+ */
|
|
| 51 | 59 |
private final MoveExecutor executor;
|
| 52 | 60 |
|
| 53 |
- public static <D extends EditableDto, U extends ContentEditUI<D, U>> void installAction(U ui, Supplier<MoveRequestBuilder.StepBuild> requestBuilderSupplier, Function<MoveRequest, BiConsumer<String, ImmutableSet<String>>> requestConsumer, Function<MoveRequest, MoveTreeAdapter> treeAdapter) {
|
|
| 54 |
- MoveExecutor moveExecutor = new MoveExecutor(requestBuilderSupplier, requestConsumer, treeAdapter);
|
|
| 55 |
- MoveEdit<D, U> action = new MoveEdit<>(ui.getModel().getSource().getScope().getMainType(), moveExecutor);
|
|
| 56 |
- init(ui, (AbstractButton) Objects.requireNonNull(ui).getObjectById("move"), action);
|
|
| 61 |
+ public static class Builder<D extends DataDto, U extends ContentUI> implements AddOnStep<D, U>, AddSaveStep<D, U>, AddThenStep<D, U>, BuildStep<D, U> {
|
|
| 62 |
+ |
|
| 63 |
+ private final U ui;
|
|
| 64 |
+ private final Class<D> dtoType;
|
|
| 65 |
+ private Supplier<MoveRequestBuilder.StepBuild> requestBuilderSupplier;
|
|
| 66 |
+ private Function<MoveRequest, BiConsumer<String, ImmutableSet<String>>> requestConsumer;
|
|
| 67 |
+ private Function<MoveRequest, ? extends MoveTreeAdapter<?, ?, ?>> treeAdapter;
|
|
| 68 |
+ |
|
| 69 |
+ public Builder(U ui, Class<D> dtoType) {
|
|
| 70 |
+ this.ui = Objects.requireNonNull(ui);
|
|
| 71 |
+ this.dtoType = Objects.requireNonNull(dtoType);
|
|
| 72 |
+ }
|
|
| 73 |
+ |
|
| 74 |
+ @Override
|
|
| 75 |
+ public AddSaveStep<D, U> on(Supplier<MoveRequestBuilder.StepBuild> requestBuilderSupplier) {
|
|
| 76 |
+ this.requestBuilderSupplier = Objects.requireNonNull(requestBuilderSupplier);
|
|
| 77 |
+ return this;
|
|
| 78 |
+ }
|
|
| 79 |
+ |
|
| 80 |
+ @Override
|
|
| 81 |
+ public AddThenStep<D, U> move(Function<MoveRequest, BiConsumer<String, ImmutableSet<String>>> requestConsumer) {
|
|
| 82 |
+ this.requestConsumer = Objects.requireNonNull(requestConsumer);
|
|
| 83 |
+ return this;
|
|
| 84 |
+ }
|
|
| 85 |
+ |
|
| 86 |
+ @Override
|
|
| 87 |
+ public BuildStep<D, U> then(Function<U, Function<MoveRequest, ? extends MoveTreeAdapter<?, ?, ?>>> treeAdapter) {
|
|
| 88 |
+ this.treeAdapter = Objects.requireNonNull(treeAdapter).apply(ui);
|
|
| 89 |
+ return this;
|
|
| 90 |
+ }
|
|
| 91 |
+ |
|
| 92 |
+ @Override
|
|
| 93 |
+ public MoveAction<D, U> install(Supplier<? extends AbstractButton> editor) {
|
|
| 94 |
+ MoveExecutor moveExecutor = new MoveExecutor(requestBuilderSupplier, requestConsumer, treeAdapter);
|
|
| 95 |
+ MoveAction<D, U> action = new MoveAction<>(dtoType, moveExecutor);
|
|
| 96 |
+ init(ui, editor.get(), action);
|
|
| 97 |
+ return action;
|
|
| 98 |
+ }
|
|
| 57 | 99 |
}
|
| 58 | 100 |
|
| 59 |
- protected MoveEdit(Class<D> dataType, MoveExecutor executor) {
|
|
| 60 |
- super(dataType, null, null, "move", ObserveKeyStrokesEditorApi.KEY_STROKE_MOVE);
|
|
| 61 |
- this.executor = executor;
|
|
| 62 |
- setText(ContentOpenableUII18nHelper.getActionMove(getDataType()));
|
|
| 63 |
- setTooltipText(ContentOpenableUII18nHelper.getActionMove(getDataType()));
|
|
| 101 |
+ public static <D extends DataDto, U extends ContentUI> AddOnStep<D, U> create(U ui, Class<D> dtoType) {
|
|
| 102 |
+ return new Builder<>(ui, dtoType);
|
|
| 103 |
+ }
|
|
| 104 |
+ |
|
| 105 |
+ public static <D extends EditableDto, U extends ContentEditUI<D, U>> AddOnStep<D, U> create(U ui) {
|
|
| 106 |
+ return create(ui, ObserveUtil.getFirstType(ui));
|
|
| 107 |
+ }
|
|
| 108 |
+ |
|
| 109 |
+ public static <D extends OpenableDto, U extends ContentOpenableUI<D, U>> AddOnStep<D, U> create(U ui) {
|
|
| 110 |
+ return create(ui, ObserveUtil.getFirstType(ui));
|
|
| 111 |
+ }
|
|
| 112 |
+ |
|
| 113 |
+ public static <D extends OpenableDto, U extends ContentListUI<D, ?, U>> AddOnStep<D, U> create(U ui) {
|
|
| 114 |
+ return create(ui, ObserveUtil.getFirstType(ui));
|
|
| 115 |
+ }
|
|
| 116 |
+ |
|
| 117 |
+ protected MoveAction(Class<D> dataType, MoveExecutor executor) {
|
|
| 118 |
+ super(null, null, "move", ObserveKeyStrokesEditorApi.KEY_STROKE_MOVE);
|
|
| 119 |
+ this.executor = Objects.requireNonNull(executor);
|
|
| 120 |
+ setText(ContentOpenableUII18nHelper.getActionMove(dataType));
|
|
| 121 |
+ setTooltipText(ContentOpenableUII18nHelper.getActionMove(dataType));
|
|
| 64 | 122 |
}
|
| 65 | 123 |
|
| 66 | 124 |
@Override
|
| 67 |
- protected void doActionPerformed(ActionEvent e, U ui) {
|
|
| 125 |
+ protected final void doActionPerformed(ActionEvent e, U ui) {
|
|
| 68 | 126 |
executor.execute(getClientUIContext().getActionExecutor(), getDataSourceEditor(), null);
|
| 69 | 127 |
}
|
| 70 | 128 |
|
| 129 |
+ public interface AddOnStep<D extends DataDto, U extends ContentUI> {
|
|
| 130 |
+ AddSaveStep<D, U> on(Supplier<MoveRequestBuilder.StepBuild> requestBuilderSupplier);
|
|
| 131 |
+ }
|
|
| 132 |
+ |
|
| 133 |
+ public interface AddSaveStep<D extends DataDto, U extends ContentUI> {
|
|
| 134 |
+ AddThenStep<D, U> move(Function<MoveRequest, BiConsumer<String, ImmutableSet<String>>> requestConsumer);
|
|
| 135 |
+ }
|
|
| 136 |
+ |
|
| 137 |
+ public interface AddThenStep<D extends DataDto, U extends ContentUI> {
|
|
| 138 |
+ BuildStep<D, U> then(Function<U, Function<MoveRequest, ? extends MoveTreeAdapter<?, ?, ?>>> treeAdapter);
|
|
| 139 |
+ }
|
|
| 140 |
+ |
|
| 141 |
+ public interface BuildStep<D extends DataDto, U extends ContentUI> {
|
|
| 142 |
+ MoveAction<D, U> install(Supplier<? extends AbstractButton> editor);
|
|
| 143 |
+ }
|
|
| 71 | 144 |
}
|
| ... | ... | @@ -25,7 +25,6 @@ package fr.ird.observe.client.datasource.editor.api.content.actions.move; |
| 25 | 25 |
import com.google.common.collect.ImmutableSet;
|
| 26 | 26 |
import fr.ird.observe.client.datasource.editor.api.DataSourceEditor;
|
| 27 | 27 |
import fr.ird.observe.client.datasource.editor.api.content.actions.mode.ChangeMode;
|
| 28 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.tree.MoveTreeAdapter;
|
|
| 29 | 28 |
import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
| 30 | 29 |
import fr.ird.observe.toolkit.dto.navigation.edit.EditNode;
|
| 31 | 30 |
import fr.ird.observe.toolkit.dto.navigation.edit.close.CloseEditNodeVetoException;
|
| ... | ... | @@ -34,6 +33,7 @@ import org.apache.logging.log4j.Logger; |
| 34 | 33 |
import org.nuiton.jaxx.runtime.swing.application.ActionExecutor;
|
| 35 | 34 |
|
| 36 | 35 |
import javax.swing.SwingUtilities;
|
| 36 |
+import java.lang.reflect.InvocationTargetException;
|
|
| 37 | 37 |
import java.util.Objects;
|
| 38 | 38 |
import java.util.Optional;
|
| 39 | 39 |
import java.util.function.BiConsumer;
|
| ... | ... | @@ -60,9 +60,9 @@ public class MoveExecutor { |
| 60 | 60 |
/**
|
| 61 | 61 |
* To adapt tree.
|
| 62 | 62 |
*/
|
| 63 |
- private final Function<MoveRequest, MoveTreeAdapter> treeAdapter;
|
|
| 63 |
+ private final Function<MoveRequest, ? extends MoveTreeAdapter<?, ?, ?>> treeAdapter;
|
|
| 64 | 64 |
|
| 65 |
- public MoveExecutor(Supplier<MoveRequestBuilder.StepBuild> requestBuilderSupplier, Function<MoveRequest, BiConsumer<String, ImmutableSet<String>>> requestConsumer, Function<MoveRequest, MoveTreeAdapter> treeAdapter) {
|
|
| 65 |
+ public MoveExecutor(Supplier<MoveRequestBuilder.StepBuild> requestBuilderSupplier, Function<MoveRequest, BiConsumer<String, ImmutableSet<String>>> requestConsumer, Function<MoveRequest, ? extends MoveTreeAdapter<?, ?, ?>> treeAdapter) {
|
|
| 66 | 66 |
this.requestBuilderSupplier = Objects.requireNonNull(requestBuilderSupplier);
|
| 67 | 67 |
this.requestConsumer = Objects.requireNonNull(requestConsumer);
|
| 68 | 68 |
this.treeAdapter = Objects.requireNonNull(treeAdapter);
|
| ... | ... | @@ -74,7 +74,7 @@ public class MoveExecutor { |
| 74 | 74 |
if (optionalRequest.isPresent()) {
|
| 75 | 75 |
MoveRequest request = optionalRequest.get();
|
| 76 | 76 |
if (editNode == null || close(request, editNode, dataSourceEditor)) {
|
| 77 |
- actionExecutor.addAction("", () -> consume(request, dataSourceEditor.getNavigationUI().getTree()));
|
|
| 77 |
+ actionExecutor.addAction("Move " + request, () -> consume(request, dataSourceEditor.getNavigationUI().getTree()));
|
|
| 78 | 78 |
}
|
| 79 | 79 |
return;
|
| 80 | 80 |
}
|
| ... | ... | @@ -93,12 +93,17 @@ public class MoveExecutor { |
| 93 | 93 |
String newParentId = request.getNewParentId();
|
| 94 | 94 |
String oldParentId = request.getOldParentId();
|
| 95 | 95 |
ImmutableSet<String> referenceId = request.getIds();
|
| 96 |
- log.info(String.format("Move %s from parent: %s to %s", referenceId, oldParentId, newParentId));
|
|
| 96 |
+ log.info(String.format("Move adapt tree [start] %s from parent: %s to %s", referenceId, oldParentId, newParentId));
|
|
| 97 | 97 |
|
| 98 | 98 |
BiConsumer<String, ImmutableSet<String>> consumer = getRequestConsumer(request);
|
| 99 | 99 |
consumer.accept(newParentId, referenceId);
|
| 100 |
- |
|
| 101 |
- SwingUtilities.invokeLater(() -> treeAdapter.apply(request).adaptTree(request, tree));
|
|
| 100 |
+ MoveTreeAdapter<?, ?, ?> moveTreeAdapter = this.treeAdapter.apply(request);
|
|
| 101 |
+ try {
|
|
| 102 |
+ SwingUtilities.invokeAndWait(() -> moveTreeAdapter.adaptTree(request, tree));
|
|
| 103 |
+ } catch (InterruptedException | InvocationTargetException e) {
|
|
| 104 |
+ log.error(e);
|
|
| 105 |
+ }
|
|
| 106 |
+ log.info(String.format("Move adapt tree [end..] %s from parent: %s to %s", referenceId, oldParentId, newParentId));
|
|
| 102 | 107 |
}
|
| 103 | 108 |
|
| 104 | 109 |
protected boolean close(MoveRequest request, EditNode<?> editNode, DataSourceEditor dataSourceEditor) {
|
| ... | ... | @@ -26,6 +26,8 @@ import com.google.common.collect.ImmutableSet; |
| 26 | 26 |
import fr.ird.observe.dto.reference.DataDtoReference;
|
| 27 | 27 |
import fr.ird.observe.dto.reference.DtoReference;
|
| 28 | 28 |
|
| 29 |
+import java.util.StringJoiner;
|
|
| 30 |
+ |
|
| 29 | 31 |
/**
|
| 30 | 32 |
* Created on 13/10/2020.
|
| 31 | 33 |
*
|
| ... | ... | @@ -108,4 +110,17 @@ public class MoveRequest { |
| 108 | 110 |
public boolean isSingle() {
|
| 109 | 111 |
return ids.size() == 1;
|
| 110 | 112 |
}
|
| 113 |
+ |
|
| 114 |
+ @Override
|
|
| 115 |
+ public String toString() {
|
|
| 116 |
+ return new StringJoiner(", ", MoveRequest.class.getSimpleName() + "[", "]")
|
|
| 117 |
+// .add("referenceType=" + referenceType)
|
|
| 118 |
+// .add("parentReferenceType=" + parentReferenceType)
|
|
| 119 |
+// .add("parentTargetReferenceType=" + parentTargetReferenceType)
|
|
| 120 |
+// .add("oldParentId='" + oldParentId + "'")
|
|
| 121 |
+ .add("ids=" + ids)
|
|
| 122 |
+ .add("newParentId='" + newParentId + "'")
|
|
| 123 |
+// .add("selectTarget=" + selectTarget)
|
|
| 124 |
+ .toString();
|
|
| 125 |
+ }
|
|
| 111 | 126 |
}
|
| 1 |
+package fr.ird.observe.client.datasource.editor.api.content.actions.move;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe Client :: DataSource :: Editor :: API
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2021 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 com.google.common.collect.ImmutableSet;
|
|
| 26 |
+import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
|
| 27 |
+import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
|
| 28 |
+ |
|
| 29 |
+import java.util.Objects;
|
|
| 30 |
+import java.util.Set;
|
|
| 31 |
+import java.util.function.Function;
|
|
| 32 |
+ |
|
| 33 |
+/**
|
|
| 34 |
+ * FIXME:Tree Create a template to generate implementations
|
|
| 35 |
+ * <p>
|
|
| 36 |
+ * Created on 12/02/2021.
|
|
| 37 |
+ *
|
|
| 38 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 39 |
+ * @since 8.0.6
|
|
| 40 |
+ */
|
|
| 41 |
+public abstract class MoveTreeAdapter<OldParent extends NavigationNode, NewParent extends NavigationNode, NewNode extends NavigationNode> {
|
|
| 42 |
+ |
|
| 43 |
+ private final NavigationNode incomingNode;
|
|
| 44 |
+ private final Function<NavigationNode, OldParent> oldParentSupplier;
|
|
| 45 |
+ |
|
| 46 |
+ protected MoveTreeAdapter(NavigationNode incomingNode, Function<NavigationNode, OldParent> oldParentSupplier) {
|
|
| 47 |
+ this.incomingNode = Objects.requireNonNull(incomingNode);
|
|
| 48 |
+ this.oldParentSupplier = Objects.requireNonNull(oldParentSupplier);
|
|
| 49 |
+ }
|
|
| 50 |
+ |
|
| 51 |
+ public abstract NewParent getNewParentNode(OldParent oldParentNode, String newParentId);
|
|
| 52 |
+ |
|
| 53 |
+ public abstract NewNode addMissingChildren(NewParent newParentNode);
|
|
| 54 |
+ |
|
| 55 |
+ public abstract void removeChildren(OldParent oldParentNode, Set<String> ids);
|
|
| 56 |
+ |
|
| 57 |
+ public final void adaptTree(MoveRequest request, NavigationTree tree) {
|
|
| 58 |
+ ImmutableSet<String> ids = request.getIds();
|
|
| 59 |
+ boolean selectTarget = request.isSelectTarget();
|
|
| 60 |
+ boolean multiple = !request.isSingle();
|
|
| 61 |
+ OldParent oldParentNode = getOldParentNode(getIncomingNode());
|
|
| 62 |
+ NewParent newParentNode = getNewParentNode(oldParentNode, request.getNewParentId());
|
|
| 63 |
+ NavigationNode nodeToSelect = adaptNewParentNode(newParentNode, ids);
|
|
| 64 |
+ if (!selectTarget) {
|
|
| 65 |
+ // stay on old parent node
|
|
| 66 |
+ nodeToSelect = oldParentNode;
|
|
| 67 |
+ } else {
|
|
| 68 |
+ if (multiple) {
|
|
| 69 |
+ // on multiple move select new parent node
|
|
| 70 |
+ nodeToSelect = newParentNode;
|
|
| 71 |
+ }
|
|
| 72 |
+ }
|
|
| 73 |
+ adaptOldParentNode(oldParentNode, ids);
|
|
| 74 |
+ doFinalSelect(selectTarget, tree, nodeToSelect);
|
|
| 75 |
+ }
|
|
| 76 |
+ |
|
| 77 |
+ public final OldParent getOldParentNode(NavigationNode incomingNode) {
|
|
| 78 |
+ return oldParentSupplier.apply(incomingNode);
|
|
| 79 |
+ }
|
|
| 80 |
+ |
|
| 81 |
+ public final void adaptOldParentNode(OldParent oldParentNode, ImmutableSet<String> ids) {
|
|
| 82 |
+ // reload node
|
|
| 83 |
+ oldParentNode.reloadNodeData();
|
|
| 84 |
+ // remove obsolete nodes
|
|
| 85 |
+ removeChildren(oldParentNode, ids);
|
|
| 86 |
+ }
|
|
| 87 |
+ |
|
| 88 |
+ public final NewNode adaptNewParentNode(NewParent newParentNode, ImmutableSet<String> ids) {
|
|
| 89 |
+ // reload node
|
|
| 90 |
+ newParentNode.reloadNodeData();
|
|
| 91 |
+ // add new nodes
|
|
| 92 |
+ NewNode newNode = addMissingChildren(newParentNode);
|
|
| 93 |
+ if (ids.size() == 1) {
|
|
| 94 |
+ //FIXME:Tree Make sure this is required, should be done by node
|
|
| 95 |
+ newNode.getParent().refreshToRoot();
|
|
| 96 |
+ }
|
|
| 97 |
+ return newNode;
|
|
| 98 |
+ }
|
|
| 99 |
+ |
|
| 100 |
+ public final void doFinalSelect(boolean selectTarget, NavigationTree tree, NavigationNode nodeToSelect) {
|
|
| 101 |
+ if (selectTarget) {
|
|
| 102 |
+ // select new node
|
|
| 103 |
+ tree.selectSafeNode(nodeToSelect);
|
|
| 104 |
+ } else {
|
|
| 105 |
+ if (nodeToSelect.getParent() == null) {
|
|
| 106 |
+ // limit case: node to select is old parent node and was removed
|
|
| 107 |
+ tree.selectFirstNode();
|
|
| 108 |
+ } else {
|
|
| 109 |
+ // re-select the node (to update associated form)
|
|
| 110 |
+ tree.reSelectSafeNode(nodeToSelect);
|
|
| 111 |
+ }
|
|
| 112 |
+ }
|
|
| 113 |
+ }
|
|
| 114 |
+ |
|
| 115 |
+ public NavigationNode getIncomingNode() {
|
|
| 116 |
+ return incomingNode;
|
|
| 117 |
+ }
|
|
| 118 |
+ |
|
| 119 |
+}
|
| 1 |
-package fr.ird.observe.client.datasource.editor.api.content.actions.move.tree;
|
|
| 2 |
- |
|
| 3 |
-/*-
|
|
| 4 |
- * #%L
|
|
| 5 |
- * ObServe Client :: DataSource :: Editor :: API
|
|
| 6 |
- * %%
|
|
| 7 |
- * Copyright (C) 2008 - 2021 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 com.google.common.collect.ImmutableSet;
|
|
| 26 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequest;
|
|
| 27 |
-import fr.ird.observe.client.datasource.editor.api.content.data.list.ContentListUINavigationNode;
|
|
| 28 |
-import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
|
| 29 |
-import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
|
| 30 |
-import fr.ird.observe.client.datasource.editor.api.navigation.tree.root.RootNavigationNode;
|
|
| 31 |
-import fr.ird.observe.dto.referential.common.ProgramReference;
|
|
| 32 |
- |
|
| 33 |
-/**
|
|
| 34 |
- * To adapt navigation tree after the move operation.
|
|
| 35 |
- * <p>
|
|
| 36 |
- * Created on 15/10/2020.
|
|
| 37 |
- *
|
|
| 38 |
- * @author Tony Chemit - dev@tchemit.fr
|
|
| 39 |
- * @since 8.0.1
|
|
| 40 |
- */
|
|
| 41 |
-public interface MoveTreeAdapter {
|
|
| 42 |
- |
|
| 43 |
- void adaptTree(MoveRequest request, NavigationTree tree);
|
|
| 44 |
- |
|
| 45 |
- static void cleanOldParentNode(NavigationTree tree, ImmutableSet<String> ids, ContentListUINavigationNode oldParentNode) {
|
|
| 46 |
- if (oldParentNode.getChildCount() == ids.size() && oldParentNode.getParent().isRoot()) {
|
|
| 47 |
- RootNavigationNode root = (RootNavigationNode) oldParentNode.getParent();
|
|
| 48 |
- if (!root.getInitializer().getConfig().isLoadEmptyProgram()) {
|
|
| 49 |
- // limit case : node will be empty, must remove it
|
|
| 50 |
- root.remove(oldParentNode);
|
|
| 51 |
- return;
|
|
| 52 |
- }
|
|
| 53 |
- }
|
|
| 54 |
- // clean it
|
|
| 55 |
- oldParentNode.removeChildren(ids);
|
|
| 56 |
- |
|
| 57 |
- // reload node
|
|
| 58 |
- oldParentNode.reloadNodeData();
|
|
| 59 |
- |
|
| 60 |
- // re-select the node (to update associated form)
|
|
| 61 |
- tree.reSelectSafeNode(oldParentNode);
|
|
| 62 |
- }
|
|
| 63 |
- |
|
| 64 |
- static ContentListUINavigationNode getNewParentNode(MoveRequest request, NavigationNode oldParentContainerNode) {
|
|
| 65 |
- String newParentId = request.getNewParentId();
|
|
| 66 |
- if (oldParentContainerNode.isRoot()) {
|
|
| 67 |
- RootNavigationNode root = (RootNavigationNode) oldParentContainerNode;
|
|
| 68 |
- boolean loadEmptyProgram = root.getInitializer().getConfig().isLoadEmptyProgram();
|
|
| 69 |
- if (!loadEmptyProgram) {
|
|
| 70 |
- NavigationNode result = root.findChildById(newParentId);
|
|
| 71 |
- if (result == null) {
|
|
| 72 |
- // limit case : node does not exist (was empty previously), need to create it
|
|
| 73 |
- ProgramReference reference = root.getInitializer().getNavigationResult().getProgram(newParentId);
|
|
| 74 |
- result = root.getCapability().createChildNode(reference);
|
|
| 75 |
- int position = root.getCapability().getNodePosition(reference);
|
|
| 76 |
- root.insert(result, position);
|
|
| 77 |
- }
|
|
| 78 |
- return (ContentListUINavigationNode) result;
|
|
| 79 |
- }
|
|
| 80 |
- }
|
|
| 81 |
- return (ContentListUINavigationNode) oldParentContainerNode.downToReferenceNode(request.getParentTargetReferenceType(), newParentId);
|
|
| 82 |
- }
|
|
| 83 |
- |
|
| 84 |
- static void doFinalSelect(MoveRequest request, NavigationTree tree,NavigationNode oldParentNode, NavigationNode newParentNode ) {
|
|
| 85 |
- if (request.isSelectTarget()) {
|
|
| 86 |
- // select new parent node
|
|
| 87 |
- tree.selectSafeNode(newParentNode);
|
|
| 88 |
- } else {
|
|
| 89 |
- if (oldParentNode.getParent() == null) {
|
|
| 90 |
- // limit case: select first node in tree (previous old parent node was removed)
|
|
| 91 |
- tree.selectFirstNode();
|
|
| 92 |
- }
|
|
| 93 |
- }
|
|
| 94 |
- }
|
|
| 95 |
-}
|
| ... | ... | @@ -34,6 +34,8 @@ import java.util.Comparator; |
| 34 | 34 |
import java.util.List;
|
| 35 | 35 |
import java.util.Objects;
|
| 36 | 36 |
import java.util.Optional;
|
| 37 |
+import java.util.Set;
|
|
| 38 |
+import java.util.stream.Collectors;
|
|
| 37 | 39 |
|
| 38 | 40 |
/**
|
| 39 | 41 |
* Created on 25/10/2020.
|
| ... | ... | @@ -90,6 +92,11 @@ public class ContentListUINavigationInitializer extends NavigationInitializer<Co |
| 90 | 92 |
return references.get().toArrayList();
|
| 91 | 93 |
}
|
| 92 | 94 |
|
| 95 |
+ public List<? extends DataDtoReference> getReferencesWithout(Set<String> idsToExclude) {
|
|
| 96 |
+ //FIXME Add this in framework (.without(idsToExclude)
|
|
| 97 |
+ return references.get().stream().filter(r -> !idsToExclude.contains(r.getId())).collect(Collectors.toList());
|
|
| 98 |
+ }
|
|
| 99 |
+ |
|
| 93 | 100 |
public final boolean isOpen() {
|
| 94 | 101 |
return Objects.equals(getSelectedParentId(), getParentEditNodeId());
|
| 95 | 102 |
}
|
| ... | ... | @@ -22,8 +22,8 @@ package fr.ird.observe.client.datasource.editor.api.content.data.list; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import com.google.common.collect.ImmutableSet;
|
|
| 26 | 25 |
import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
| 26 |
+import fr.ird.observe.dto.IdDto;
|
|
| 27 | 27 |
import fr.ird.observe.dto.reference.DataDtoReference;
|
| 28 | 28 |
import fr.ird.observe.dto.reference.DtoReference;
|
| 29 | 29 |
import fr.ird.observe.dto.reference.LazyDataDtoReferenceSet;
|
| ... | ... | @@ -31,6 +31,7 @@ import io.ultreia.java4all.lang.Objects2; |
| 31 | 31 |
|
| 32 | 32 |
import java.util.List;
|
| 33 | 33 |
import java.util.Set;
|
| 34 |
+import java.util.stream.Collectors;
|
|
| 34 | 35 |
|
| 35 | 36 |
/**
|
| 36 | 37 |
* Created on 07/10/2020.
|
| ... | ... | @@ -51,8 +52,6 @@ public abstract class ContentListUINavigationNode extends NavigationNode { |
| 51 | 52 |
return node;
|
| 52 | 53 |
}
|
| 53 | 54 |
|
| 54 |
-// public abstract OpenableDtoServiceContext<?, ?, ?> getSpi();
|
|
| 55 |
- |
|
| 56 | 55 |
@Override
|
| 57 | 56 |
public ContentListUINavigationInitializer getInitializer() {
|
| 58 | 57 |
return (ContentListUINavigationInitializer) super.getInitializer();
|
| ... | ... | @@ -81,45 +80,21 @@ public abstract class ContentListUINavigationNode extends NavigationNode { |
| 81 | 80 |
return getInitializer().getParentReference();
|
| 82 | 81 |
}
|
| 83 | 82 |
|
| 84 |
- public void removeChildren(ImmutableSet<String> ids) {
|
|
| 83 |
+ public void removeChildren(Set<String> ids) {
|
|
| 85 | 84 |
for (String id : ids) {
|
| 86 | 85 |
NavigationNode childNode = findChildById(id);
|
| 87 | 86 |
childNode.removeFromParent();
|
| 88 | 87 |
}
|
| 89 | 88 |
}
|
| 90 | 89 |
|
| 91 |
- public void addChildren(Set<String> ids) {
|
|
| 90 |
+ public NavigationNode addMissingChildren() {
|
|
| 92 | 91 |
ContentListUINavigationInitializer initializer = getInitializer();
|
| 93 |
- boolean notLoaded = isNotLoaded();
|
|
| 94 |
- reloadNodeData();
|
|
| 95 |
- List<? extends DataDtoReference> references = initializer.getReferences();
|
|
| 92 |
+ Set<String> existingIds = getChildrenReferences(getScope().getMainReferenceType()).stream().map(IdDto::getId).collect(Collectors.toSet());
|
|
| 93 |
+ List<? extends DataDtoReference> references = initializer.getReferencesWithout(existingIds);
|
|
| 96 | 94 |
ContentListUINavigationCapability<?> capability = getCapability();
|
| 95 |
+ NavigationNode result = null;
|
|
| 97 | 96 |
for (DataDtoReference reference : references) {
|
| 98 |
- if (notLoaded || ids.contains(reference.getId())) {
|
|
| 99 |
- NavigationNode childNode = capability.createChildNode(reference);
|
|
| 100 |
- int nodePosition = capability.getNodePosition(reference);
|
|
| 101 |
- insert(childNode, nodePosition);
|
|
| 102 |
- }
|
|
| 103 |
- }
|
|
| 104 |
- }
|
|
| 105 |
- public NavigationNode addChildren(String id) {
|
|
| 106 |
- NavigationNode result=null;
|
|
| 107 |
- ContentListUINavigationInitializer initializer = getInitializer();
|
|
| 108 |
- boolean notLoaded = isNotLoaded();
|
|
| 109 |
- reloadNodeData();
|
|
| 110 |
- List<? extends DataDtoReference> references = initializer.getReferences();
|
|
| 111 |
- ContentListUINavigationCapability<?> capability = getCapability();
|
|
| 112 |
- for (DataDtoReference reference : references) {
|
|
| 113 |
- boolean idEquals = id.equals(reference.getId());
|
|
| 114 |
- if (notLoaded || idEquals) {
|
|
| 115 |
- |
|
| 116 |
- NavigationNode childNode = capability.createChildNode(reference);
|
|
| 117 |
- int nodePosition = capability.getNodePosition(reference);
|
|
| 118 |
- insert(childNode, nodePosition);
|
|
| 119 |
- if (idEquals) {
|
|
| 120 |
- result = childNode;
|
|
| 121 |
- }
|
|
| 122 |
- }
|
|
| 97 |
+ result = capability.insertChildNode(reference);
|
|
| 123 | 98 |
}
|
| 124 | 99 |
return result;
|
| 125 | 100 |
}
|
| 1 |
-package fr.ird.observe.client.datasource.editor.api.content.data.list.actions;
|
|
| 2 |
- |
|
| 3 |
-/*-
|
|
| 4 |
- * #%L
|
|
| 5 |
- * ObServe Client :: DataSource :: Editor :: API
|
|
| 6 |
- * %%
|
|
| 7 |
- * Copyright (C) 2008 - 2021 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 com.google.common.collect.ImmutableSet;
|
|
| 26 |
-import fr.ird.observe.client.datasource.editor.api.ObserveKeyStrokesEditorApi;
|
|
| 27 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.ConfigureMenuAction;
|
|
| 28 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveExecutor;
|
|
| 29 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequest;
|
|
| 30 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequestBuilder;
|
|
| 31 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.tree.DefaultMultipleMoveTreeAdapter;
|
|
| 32 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.tree.MoveTreeAdapter;
|
|
| 33 |
-import fr.ird.observe.client.datasource.editor.api.content.data.list.ContentListUI;
|
|
| 34 |
-import fr.ird.observe.client.datasource.editor.api.content.data.list.ContentListUII18nHelper;
|
|
| 35 |
-import fr.ird.observe.dto.data.DataDto;
|
|
| 36 |
-import fr.ird.observe.dto.reference.DataDtoReference;
|
|
| 37 |
-import fr.ird.observe.dto.reference.DtoReferenceCollection;
|
|
| 38 |
- |
|
| 39 |
-import java.awt.event.ActionEvent;
|
|
| 40 |
-import java.util.Objects;
|
|
| 41 |
-import java.util.function.BiConsumer;
|
|
| 42 |
-import java.util.function.Function;
|
|
| 43 |
-import java.util.function.Supplier;
|
|
| 44 |
- |
|
| 45 |
-/**
|
|
| 46 |
- * Created by tchemit on 12/06/17.
|
|
| 47 |
- *
|
|
| 48 |
- * @author Tony Chemit - dev@tchemit.fr
|
|
| 49 |
- */
|
|
| 50 |
-public final class MoveMultiple<D extends DataDto, R extends DataDtoReference, U extends ContentListUI<D, R, U>> extends ContentListUIActionSupport<D, R, U> implements ConfigureMenuAction<U> {
|
|
| 51 |
- |
|
| 52 |
- private final MoveExecutor executor;
|
|
| 53 |
- |
|
| 54 |
- public static <D extends DataDto, R extends DataDtoReference, U extends ContentListUI<D, R, U>> void installMoveAction(U ui, Function<String, DtoReferenceCollection<?>> parentCandidates, Function<MoveRequest, BiConsumer<String, ImmutableSet<String>>> consumer) {
|
|
| 55 |
- Supplier<MoveRequestBuilder.StepBuild> requestBuilderSupplier = () -> MoveRequestBuilder.create(ui.getModel()).setParentCandidates(parentCandidates);
|
|
| 56 |
- installMoveAction(ui, requestBuilderSupplier, consumer, r -> new DefaultMultipleMoveTreeAdapter());
|
|
| 57 |
- }
|
|
| 58 |
- |
|
| 59 |
- public static <D extends DataDto, R extends DataDtoReference, U extends ContentListUI<D, R, U>> void installMoveAction(U ui, Supplier<MoveRequestBuilder.StepBuild> requestBuilderSupplier, Function<MoveRequest, BiConsumer<String, ImmutableSet<String>>> requestConsumer, Function<MoveRequest, MoveTreeAdapter> treeAdapter) {
|
|
| 60 |
- MoveExecutor moveExecutor = new MoveExecutor(requestBuilderSupplier, requestConsumer, treeAdapter);
|
|
| 61 |
- MoveMultiple<D, R, U> action = new MoveMultiple<>(ui.getModel().getSource().getScope().getMainType(), moveExecutor);
|
|
| 62 |
- init(ui, Objects.requireNonNull(ui).getMove(), action);
|
|
| 63 |
- }
|
|
| 64 |
- |
|
| 65 |
- protected MoveMultiple(Class<D> dataType, MoveExecutor executor) {
|
|
| 66 |
- super(dataType, null, null, "move", ObserveKeyStrokesEditorApi.KEY_STROKE_MOVE);
|
|
| 67 |
- this.executor = executor;
|
|
| 68 |
- setText(ContentListUII18nHelper.getActionMove(getDataType()));
|
|
| 69 |
- setTooltipText(ContentListUII18nHelper.getActionMoveTip(getDataType()));
|
|
| 70 |
- }
|
|
| 71 |
- |
|
| 72 |
- @Override
|
|
| 73 |
- protected void doActionPerformed(ActionEvent e, U ui) {
|
|
| 74 |
- executor.execute(getClientUIContext().getActionExecutor(), getDataSourceEditor(), ui.getModel().getSource().getInitializer().getEditNode());
|
|
| 75 |
- }
|
|
| 76 |
- |
|
| 77 |
-}
|
| 1 |
-package fr.ird.observe.client.datasource.editor.api.content.data.open.actions;
|
|
| 2 |
- |
|
| 3 |
-/*-
|
|
| 4 |
- * #%L
|
|
| 5 |
- * ObServe Client :: DataSource :: Editor :: API
|
|
| 6 |
- * %%
|
|
| 7 |
- * Copyright (C) 2008 - 2021 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 com.google.common.collect.ImmutableSet;
|
|
| 26 |
-import fr.ird.observe.client.datasource.editor.api.ObserveKeyStrokesEditorApi;
|
|
| 27 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.ConfigureMenuAction;
|
|
| 28 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveExecutor;
|
|
| 29 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequest;
|
|
| 30 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequestBuilder;
|
|
| 31 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.tree.DefaultSingleMoveTreeAdapter;
|
|
| 32 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.tree.MoveTreeAdapter;
|
|
| 33 |
-import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUI;
|
|
| 34 |
-import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUII18nHelper;
|
|
| 35 |
-import fr.ird.observe.dto.data.OpenableDto;
|
|
| 36 |
-import fr.ird.observe.dto.reference.DtoReferenceCollection;
|
|
| 37 |
- |
|
| 38 |
-import java.awt.event.ActionEvent;
|
|
| 39 |
-import java.util.Objects;
|
|
| 40 |
-import java.util.function.BiConsumer;
|
|
| 41 |
-import java.util.function.Function;
|
|
| 42 |
-import java.util.function.Supplier;
|
|
| 43 |
- |
|
| 44 |
-/**
|
|
| 45 |
- * Created by tchemit on 12/06/17.
|
|
| 46 |
- *
|
|
| 47 |
- * @author Tony Chemit - dev@tchemit.fr
|
|
| 48 |
- */
|
|
| 49 |
-public final class MoveOpenable<D extends OpenableDto, U extends ContentOpenableUI<D, U>> extends ContentOpenableUIActionSupport<D, U> implements ConfigureMenuAction<U> {
|
|
| 50 |
- |
|
| 51 |
- private final MoveExecutor executor;
|
|
| 52 |
- |
|
| 53 |
- public static <D extends OpenableDto, U extends ContentOpenableUI<D, U>> void installAction(U ui, Function<String, DtoReferenceCollection<?>> parentCandidates, Function<MoveRequest, BiConsumer<String, ImmutableSet<String>>> consumer) {
|
|
| 54 |
- Supplier<MoveRequestBuilder.StepBuild> requestBuilderSupplier = () -> ui.getModel().toMoveRequest().setParentCandidates(parentCandidates);
|
|
| 55 |
- MoveExecutor moveExecutor = new MoveExecutor(requestBuilderSupplier, consumer, r -> new DefaultSingleMoveTreeAdapter());
|
|
| 56 |
- MoveOpenable<D, U> action = new MoveOpenable<>(ui.getModel().getSource().getScope().getMainType(), moveExecutor);
|
|
| 57 |
- init(ui, Objects.requireNonNull(ui).getMove(), action);
|
|
| 58 |
- }
|
|
| 59 |
- |
|
| 60 |
- public static <D extends OpenableDto, U extends ContentOpenableUI<D, U>> void installAction(U ui, Supplier<MoveRequestBuilder.StepBuild> requestBuilderSupplier, Function<MoveRequest, BiConsumer<String, ImmutableSet<String>>> requestConsumer, Function<MoveRequest, MoveTreeAdapter> treeAdapter) {
|
|
| 61 |
- MoveExecutor moveExecutor = new MoveExecutor(requestBuilderSupplier, requestConsumer, treeAdapter);
|
|
| 62 |
- MoveOpenable<D, U> action = new MoveOpenable<>(ui.getModel().getSource().getScope().getMainType(), moveExecutor);
|
|
| 63 |
- init(ui, Objects.requireNonNull(ui).getMove(), action);
|
|
| 64 |
- }
|
|
| 65 |
- |
|
| 66 |
- protected MoveOpenable(Class<D> dataType, MoveExecutor executor) {
|
|
| 67 |
- super(dataType, null, null, "move", ObserveKeyStrokesEditorApi.KEY_STROKE_MOVE);
|
|
| 68 |
- this.executor = executor;
|
|
| 69 |
- setText(ContentOpenableUII18nHelper.getActionMove(getDataType()));
|
|
| 70 |
- setTooltipText(ContentOpenableUII18nHelper.getActionMove(getDataType()));
|
|
| 71 |
- }
|
|
| 72 |
- |
|
| 73 |
- @Override
|
|
| 74 |
- protected void doActionPerformed(ActionEvent e, U ui) {
|
|
| 75 |
- executor.execute(getClientUIContext().getActionExecutor(), getDataSourceEditor(), ui.getModel().getSource().getInitializer().getEditNode());
|
|
| 76 |
- }
|
|
| 77 |
- |
|
| 78 |
-}
|
| ... | ... | @@ -271,6 +271,25 @@ public abstract class NavigationNode extends DefaultMutableTreeNode implements W |
| 271 | 271 |
return result;
|
| 272 | 272 |
}
|
| 273 | 273 |
|
| 274 |
+ public final <R extends DtoReference> List<R> getChildrenReferences(Class<R> referenceType) {
|
|
| 275 |
+ Enumeration<?> children = children();
|
|
| 276 |
+ List<R> result = new LinkedList<>();
|
|
| 277 |
+ while (children.hasMoreElements()) {
|
|
| 278 |
+ NavigationNode o = (NavigationNode) children.nextElement();
|
|
| 279 |
+ if (o.isReference()) {
|
|
| 280 |
+ ReferenceCapability<?> capability = (ReferenceCapability<?>) o.getCapability();
|
|
| 281 |
+ DtoReference nodeReference = capability.getReference();
|
|
| 282 |
+ if (nodeReference.isNotPersisted()) {
|
|
| 283 |
+ continue;
|
|
| 284 |
+ }
|
|
| 285 |
+ if (referenceType.isAssignableFrom(nodeReference.getReferenceType())) {
|
|
| 286 |
+ result.add(referenceType.cast(nodeReference));
|
|
| 287 |
+ }
|
|
| 288 |
+ }
|
|
| 289 |
+ }
|
|
| 290 |
+ return result;
|
|
| 291 |
+ }
|
|
| 292 |
+ |
|
| 274 | 293 |
//--------------------------------------------------------------------------------------------
|
| 275 | 294 |
// Update methods
|
| 276 | 295 |
//--------------------------------------------------------------------------------------------
|
| ... | ... | @@ -625,6 +644,24 @@ public abstract class NavigationNode extends DefaultMutableTreeNode implements W |
| 625 | 644 |
return null;
|
| 626 | 645 |
}
|
| 627 | 646 |
|
| 647 |
+ /**
|
|
| 648 |
+ * @param siblingId id to seek
|
|
| 649 |
+ * @return sibling node with the given id
|
|
| 650 |
+ */
|
|
| 651 |
+ public NavigationNode findSibling(String siblingId) {
|
|
| 652 |
+ NavigationNode parent = getParent();
|
|
| 653 |
+ return parent.findChildByType(getClass(), siblingId);
|
|
| 654 |
+ }
|
|
| 655 |
+ |
|
| 656 |
+ /**
|
|
| 657 |
+ * @param siblingId id to seek
|
|
| 658 |
+ * @return sibling node with the given id (using parent sibling on given id)
|
|
| 659 |
+ */
|
|
| 660 |
+ public NavigationNode findParentSibling(String siblingId) {
|
|
| 661 |
+ NavigationNode sibling = getParent().findSibling(siblingId);
|
|
| 662 |
+ return sibling.findChildByType(getClass());
|
|
| 663 |
+ }
|
|
| 664 |
+ |
|
| 628 | 665 |
/**
|
| 629 | 666 |
* @return next sibling with exact node type matching
|
| 630 | 667 |
*/
|
| ... | ... | @@ -723,20 +760,6 @@ public abstract class NavigationNode extends DefaultMutableTreeNode implements W |
| 723 | 760 |
throw new IllegalStateException(String.format("Can't go down reference node of type: %s from node: %s", referenceType.getName(), this));
|
| 724 | 761 |
}
|
| 725 | 762 |
|
| 726 |
- public NavigationNode downToReferenceContainerNode(Class<? extends DtoReference> referenceType) {
|
|
| 727 |
- if (acceptReferenceContainerNode(referenceType)) {
|
|
| 728 |
- return this;
|
|
| 729 |
- }
|
|
| 730 |
- Enumeration<?> children = children();
|
|
| 731 |
- while (children.hasMoreElements()) {
|
|
| 732 |
- NavigationNode childrenNode = (NavigationNode) children.nextElement();
|
|
| 733 |
- if (childrenNode.acceptReferenceContainerNode(referenceType)) {
|
|
| 734 |
- return childrenNode;
|
|
| 735 |
- }
|
|
| 736 |
- }
|
|
| 737 |
- throw new IllegalStateException(String.format("Can't go down to reference container node of type: %s from node: %s", referenceType.getName(), this));
|
|
| 738 |
- }
|
|
| 739 |
- |
|
| 740 | 763 |
//--------------------------------------------------------------------------------------------
|
| 741 | 764 |
// TreeNode override methods
|
| 742 | 765 |
//--------------------------------------------------------------------------------------------
|
| ... | ... | @@ -40,6 +40,13 @@ public interface ReferenceContainerCapability<N extends NavigationNode> extends |
| 40 | 40 |
|
| 41 | 41 |
int getNodePosition(DtoReference reference);
|
| 42 | 42 |
|
| 43 |
+ default NavigationNode insertChildNode(DtoReference reference) {
|
|
| 44 |
+ NavigationNode result = createChildNode(reference);
|
|
| 45 |
+ int nodePosition = getNodePosition(reference);
|
|
| 46 |
+ getNode().insert(result, nodePosition);
|
|
| 47 |
+ return result;
|
|
| 48 |
+ }
|
|
| 49 |
+ |
|
| 43 | 50 |
default boolean acceptChildReferenceType(Class<? extends DtoReference> dtoReferenceType) {
|
| 44 | 51 |
return getAcceptedTypes().contains(dtoReferenceType);
|
| 45 | 52 |
}
|
| ... | ... | @@ -46,10 +46,6 @@ public class RootNavigationNode extends NavigationNode { |
| 46 | 46 |
|
| 47 | 47 |
public static int nodeCount;
|
| 48 | 48 |
|
| 49 |
- public RootNavigationNode() {
|
|
| 50 |
- nodeCount = 0;
|
|
| 51 |
- }
|
|
| 52 |
- |
|
| 53 | 49 |
public static int incrementsAndGetNodeCount() {
|
| 54 | 50 |
return ++nodeCount;
|
| 55 | 51 |
}
|
| ... | ... | @@ -84,6 +80,10 @@ public class RootNavigationNode extends NavigationNode { |
| 84 | 80 |
return node;
|
| 85 | 81 |
}
|
| 86 | 82 |
|
| 83 |
+ public RootNavigationNode() {
|
|
| 84 |
+ nodeCount = 0;
|
|
| 85 |
+ }
|
|
| 86 |
+ |
|
| 87 | 87 |
@Override
|
| 88 | 88 |
public RootNavigationInitializer getInitializer() {
|
| 89 | 89 |
return (RootNavigationInitializer) super.getInitializer();
|
| ... | ... | @@ -119,6 +119,46 @@ public class RootNavigationNode extends NavigationNode { |
| 119 | 119 |
return (RootNavigationCapability) super.getCapability();
|
| 120 | 120 |
}
|
| 121 | 121 |
|
| 122 |
+ @Override
|
|
| 123 |
+ public NavigationNode findChildById(String id) {
|
|
| 124 |
+ NavigationNode result = super.findChildById(id);
|
|
| 125 |
+ if (result == null) {
|
|
| 126 |
+ result = createMissingProgramNode(id);
|
|
| 127 |
+ }
|
|
| 128 |
+ return result;
|
|
| 129 |
+ }
|
|
| 130 |
+ |
|
| 131 |
+ @SuppressWarnings("unchecked")
|
|
| 132 |
+ @Override
|
|
| 133 |
+ public <N extends NavigationNode> N findChildByType(Class<N> childType, String id) {
|
|
| 134 |
+ N result = super.findChildByType(childType, id);
|
|
| 135 |
+ if (result == null) {
|
|
| 136 |
+ result = (N) createMissingProgramNode(id);
|
|
| 137 |
+ }
|
|
| 138 |
+ return result;
|
|
| 139 |
+ }
|
|
| 140 |
+ |
|
| 141 |
+ @Override
|
|
| 142 |
+ public NavigationNode findChildByModelNode(NavigationModelNode<?> node) {
|
|
| 143 |
+ NavigationNode result = super.findChildByModelNode(node);
|
|
| 144 |
+ if (result == null && node.isRoot()) {
|
|
| 145 |
+ result = createMissingProgramNode(node.getId());
|
|
| 146 |
+ }
|
|
| 147 |
+ return result;
|
|
| 148 |
+ }
|
|
| 149 |
+ |
|
| 150 |
+ protected NavigationNode createMissingProgramNode(String id) {
|
|
| 151 |
+ // limit case : node does not exist (was empty previously), need to create it
|
|
| 152 |
+ ProgramReference reference = getInitializer().getNavigationResult().getProgram(id);
|
|
| 153 |
+ if (reference == null) {
|
|
| 154 |
+ throw new IllegalStateException(String.format("Could not find program: %s", id));
|
|
| 155 |
+ }
|
|
| 156 |
+ NavigationNode result = getCapability().createChildNode(reference);
|
|
| 157 |
+ int position = getCapability().getNodePosition(reference);
|
|
| 158 |
+ insert(result, position);
|
|
| 159 |
+ return result;
|
|
| 160 |
+ }
|
|
| 161 |
+ |
|
| 122 | 162 |
public NavigationNode findNodeFromPreviousSelectedNode(NavigationNode oldSelectedNode) {
|
| 123 | 163 |
NavigationNode result = this;
|
| 124 | 164 |
TreeNode[] pathToRoot = oldSelectedNode.getPath();
|
| ... | ... | @@ -138,7 +178,6 @@ public class RootNavigationNode extends NavigationNode { |
| 138 | 178 |
return result;
|
| 139 | 179 |
}
|
| 140 | 180 |
|
| 141 |
- |
|
| 142 | 181 |
public NavigationNode findNode(NavigationModelNode<?> editNode) {
|
| 143 | 182 |
NavigationNode result = this;
|
| 144 | 183 |
ImmutableList<NavigationModelNode<?>> nodesFromRoot = editNode.getNodesFromRoot();
|
| ... | ... | @@ -23,13 +23,9 @@ package fr.ird.observe.client.datasource.editor.ll.data.logbook; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.datasource.editor.api.content.ContentUIInitializer;
|
| 26 |
+import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveAction;
|
|
| 26 | 27 |
import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequestBuilder;
|
| 27 |
-import fr.ird.observe.client.datasource.editor.api.content.data.edit.actions.MoveEdit;
|
|
| 28 |
-import fr.ird.observe.client.datasource.editor.ll.data.logbook.sample.ActivitySampleUIMoveTreeAdapter;
|
|
| 29 | 28 |
import fr.ird.observe.client.datasource.editor.ll.data.logbook.sample.SampleUIHelper;
|
| 30 |
-import fr.ird.observe.dto.data.ll.common.TripReference;
|
|
| 31 |
-import fr.ird.observe.dto.data.ll.logbook.ActivityReference;
|
|
| 32 |
-import io.ultreia.java4all.i18n.I18n;
|
|
| 33 | 29 |
|
| 34 | 30 |
/**
|
| 35 | 31 |
* Created on 12/5/14.
|
| ... | ... | @@ -54,28 +50,11 @@ public class ActivitySampleUIHandler extends GeneratedActivitySampleUIHandler { |
| 54 | 50 |
@Override
|
| 55 | 51 |
protected void installSaveAction() {
|
| 56 | 52 |
super.installSaveAction();
|
| 57 |
- MoveEdit.installAction(ui,
|
|
| 58 |
- () -> {
|
|
| 59 |
- Boolean moveToTrip = SampleUIHelper.movetoTrip();
|
|
| 60 |
- if (moveToTrip == null) {
|
|
| 61 |
- return null;
|
|
| 62 |
- }
|
|
| 63 |
- MoveRequestBuilder.StepSetParentCandidates requestBuilder = MoveRequestBuilder
|
|
| 64 |
- .create(getModel());
|
|
| 65 |
- if (moveToTrip) {
|
|
| 66 |
- return requestBuilder
|
|
| 67 |
- .setParentTargetReferenceType(TripReference.class)
|
|
| 68 |
- .setParentCandidates(this.getLlLogbookActivitySampleService()::getParents);
|
|
| 69 |
- }
|
|
| 70 |
- // move to activity
|
|
| 71 |
- return requestBuilder
|
|
| 72 |
- .setParentTargetReferenceType(ActivityReference.class)
|
|
| 73 |
- .setAskNewParentTitle(I18n.t("observe.data.ll.logbook.Sample.action.move.choose.parent.activity.title"))
|
|
| 74 |
- .setAskNewParentMessage(I18n.t("observe.data.ll.logbook.Sample.action.move.choose.parent.activity.message"))
|
|
| 75 |
- .setParentCandidates(this.getLlLogbookActivityService()::getBrothers);
|
|
| 76 |
- },
|
|
| 77 |
- r -> getLlLogbookActivitySampleService()::move,
|
|
| 78 |
- r -> new ActivitySampleUIMoveTreeAdapter());
|
|
| 53 |
+ MoveAction.create(ui)
|
|
| 54 |
+ .on(SampleUIHelper.newSupplier(this, () -> MoveRequestBuilder.create(ui.getModel())))
|
|
| 55 |
+ .move(r -> getLlLogbookActivitySampleService()::move)
|
|
| 56 |
+ .then(SampleUIHelper::create)
|
|
| 57 |
+ .install(ui::getMove);
|
|
| 79 | 58 |
}
|
| 80 | 59 |
|
| 81 | 60 |
}
|
| ... | ... | @@ -22,9 +22,7 @@ package fr.ird.observe.client.datasource.editor.ll.data.logbook; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.tree.DefaultMultipleMoveTreeAdapter;
|
|
| 26 |
-import fr.ird.observe.client.datasource.editor.api.content.data.list.actions.MoveMultiple;
|
|
| 27 |
-import fr.ird.observe.client.datasource.editor.ll.data.logbook.sample.ActivitySampleUIMoveTreeAdapter;
|
|
| 25 |
+import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveAction;
|
|
| 28 | 26 |
import fr.ird.observe.client.datasource.editor.ll.data.logbook.sample.SampleUIHelper;
|
| 29 | 27 |
|
| 30 | 28 |
/**
|
| ... | ... | @@ -37,9 +35,10 @@ class SampleListUIHandler extends GeneratedSampleListUIHandler { |
| 37 | 35 |
|
| 38 | 36 |
@Override
|
| 39 | 37 |
protected void installMoveAction() {
|
| 40 |
- MoveMultiple.installMoveAction(ui,
|
|
| 41 |
- SampleUIHelper.newSupplier(this, getModel()::toMoveRequest),
|
|
| 42 |
- r -> getLlLogbookSampleService()::move,
|
|
| 43 |
- r -> SampleUIHelper.toTrip(r) ? new DefaultMultipleMoveTreeAdapter() : new ActivitySampleUIMoveTreeAdapter());
|
|
| 38 |
+ MoveAction.create(ui)
|
|
| 39 |
+ .on(SampleUIHelper.newSupplier(this, getModel()::toMoveRequest))
|
|
| 40 |
+ .move(r -> getLlLogbookSampleService()::move)
|
|
| 41 |
+ .then(SampleUIHelper::create)
|
|
| 42 |
+ .install(ui::getMove);
|
|
| 44 | 43 |
}
|
| 45 | 44 |
}
|
| ... | ... | @@ -24,9 +24,7 @@ package fr.ird.observe.client.datasource.editor.ll.data.logbook; |
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.datasource.editor.api.content.ContentMode;
|
| 26 | 26 |
import fr.ird.observe.client.datasource.editor.api.content.ContentUIInitializer;
|
| 27 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.tree.DefaultSingleMoveTreeAdapter;
|
|
| 28 |
-import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.MoveOpenable;
|
|
| 29 |
-import fr.ird.observe.client.datasource.editor.ll.data.logbook.sample.ActivitySampleUIMoveTreeAdapter;
|
|
| 27 |
+import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveAction;
|
|
| 30 | 28 |
import fr.ird.observe.client.datasource.editor.ll.data.logbook.sample.SampleUIHelper;
|
| 31 | 29 |
|
| 32 | 30 |
/**
|
| ... | ... | @@ -66,9 +64,10 @@ class SampleUIHandler extends GeneratedSampleUIHandler { |
| 66 | 64 |
|
| 67 | 65 |
@Override
|
| 68 | 66 |
protected void installMoveAction() {
|
| 69 |
- MoveOpenable.installAction(ui,
|
|
| 70 |
- SampleUIHelper.newSupplier(this, getModel()::toMoveRequest),
|
|
| 71 |
- r -> getLlLogbookSampleService()::move,
|
|
| 72 |
- r -> SampleUIHelper.toTrip(r) ? new DefaultSingleMoveTreeAdapter() : new ActivitySampleUIMoveTreeAdapter());
|
|
| 67 |
+ MoveAction.create(ui)
|
|
| 68 |
+ .on(SampleUIHelper.newSupplier(this, getModel()::toMoveRequest))
|
|
| 69 |
+ .move(r -> getLlLogbookSampleService()::move)
|
|
| 70 |
+ .then(SampleUIHelper::create)
|
|
| 71 |
+ .install(ui::getMove);
|
|
| 73 | 72 |
}
|
| 74 | 73 |
}
|
| ... | ... | @@ -22,74 +22,39 @@ package fr.ird.observe.client.datasource.editor.ll.data.logbook.sample; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequest;
|
|
| 26 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.tree.DefaultSingleMoveTreeAdapter;
|
|
| 27 |
-import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
|
| 28 |
-import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
|
| 25 |
+import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveTreeAdapter;
|
|
| 29 | 26 |
import fr.ird.observe.client.datasource.editor.ll.data.logbook.ActivitySampleUINavigationNode;
|
| 30 | 27 |
import fr.ird.observe.client.datasource.editor.ll.data.logbook.ActivityUINavigationNode;
|
| 31 |
-import fr.ird.observe.client.datasource.editor.ll.data.logbook.SampleListUINavigationNode;
|
|
| 32 |
-import fr.ird.observe.client.datasource.editor.ll.data.logbook.SampleUINavigationNode;
|
|
| 28 |
+import fr.ird.observe.dto.data.ll.logbook.ActivitySampleReference;
|
|
| 29 |
+ |
|
| 30 |
+import java.util.Set;
|
|
| 33 | 31 |
|
| 34 | 32 |
/**
|
| 35 |
- * Created on 15/10/2020.
|
|
| 33 |
+ * FIXME:Tree Generate me
|
|
| 34 |
+ * Created on 12/02/2021.
|
|
| 36 | 35 |
*
|
| 37 | 36 |
* @author Tony Chemit - dev@tchemit.fr
|
| 38 |
- * @since 8.0.1
|
|
| 37 |
+ * @since 8.0.6
|
|
| 39 | 38 |
*/
|
| 40 |
-public class ActivitySampleUIMoveTreeAdapter extends DefaultSingleMoveTreeAdapter {
|
|
| 41 |
- |
|
| 42 |
- public static void moveFromActivityToActivity(NavigationTree tree, ActivitySampleUINavigationNode referenceNode, String activityId) {
|
|
| 43 |
- ActivityUINavigationNode newContainerNode = referenceNode.getParent().getParent()
|
|
| 44 |
- .getActivityUINavigationNode(activityId);
|
|
| 45 |
- newContainerNode.updateNode();
|
|
| 46 |
- ActivitySampleUINavigationNode node = newContainerNode.getActivitySampleUINavigationNode();
|
|
| 47 |
- tree.selectSafeNode(node);
|
|
| 48 |
- }
|
|
| 39 |
+public class ActivitySampleUIMoveTreeAdapter extends MoveTreeAdapter<ActivityUINavigationNode, ActivityUINavigationNode, ActivitySampleUINavigationNode> {
|
|
| 49 | 40 |
|
| 50 |
- public static void moveFromTripToActivity(NavigationTree tree, SampleUINavigationNode referenceNode, String activityId) {
|
|
| 51 |
- ActivityUINavigationNode newContainerNode = referenceNode.getParent().getParent()
|
|
| 52 |
- .getLogbookActivityListUINavigationNode().getActivityUINavigationNode(activityId);
|
|
| 53 |
- newContainerNode.updateNode();
|
|
| 54 |
- ActivitySampleUINavigationNode node = newContainerNode.getActivitySampleUINavigationNode();
|
|
| 55 |
- tree.selectSafeNode(node);
|
|
| 41 |
+ public ActivitySampleUIMoveTreeAdapter(ActivitySampleUINavigationNode incomingNode) {
|
|
| 42 |
+ super(incomingNode, e -> incomingNode.getParent());
|
|
| 56 | 43 |
}
|
| 57 | 44 |
|
| 58 |
- public static void moveFromTripToTrip(NavigationTree tree, SampleUINavigationNode referenceNode, String tripId, String sampleId) {
|
|
| 59 |
- SampleListUINavigationNode newContainerNode = referenceNode.getParent().getParent().getParent()
|
|
| 60 |
- .getTripUINavigationNode(tripId).getSampleListUINavigationNode();
|
|
| 61 |
- newContainerNode.reloadNodeDataToRoot();
|
|
| 62 |
- NavigationNode node = newContainerNode.getSampleUINavigationNode(sampleId);
|
|
| 63 |
- tree.selectSafeNode(node);
|
|
| 45 |
+ @Override
|
|
| 46 |
+ public ActivityUINavigationNode getNewParentNode(ActivityUINavigationNode oldParentNode, String newParentId) {
|
|
| 47 |
+ return oldParentNode.findParentSibling(newParentId);
|
|
| 64 | 48 |
}
|
| 65 | 49 |
|
| 66 |
- public static void moveFromActivityToTrip(NavigationTree tree, ActivitySampleUINavigationNode referenceNode, String tripId, String sampleId) {
|
|
| 67 |
- SampleListUINavigationNode newContainerNode = referenceNode.getParent().getParent().getParent().getParent()
|
|
| 68 |
- .getTripUINavigationNode(tripId).getSampleListUINavigationNode();
|
|
| 69 |
- newContainerNode.reloadNodeDataToRoot();
|
|
| 70 |
- NavigationNode node = newContainerNode.getSampleUINavigationNode(sampleId);
|
|
| 71 |
- tree.selectSafeNode(node);
|
|
| 50 |
+ @Override
|
|
| 51 |
+ public ActivitySampleUINavigationNode addMissingChildren(ActivityUINavigationNode newParentNode) {
|
|
| 52 |
+ ActivitySampleReference reference = newParentNode.getReference().getActivitySample();
|
|
| 53 |
+ return newParentNode.addActivitySampleUINavigationNode(reference);
|
|
| 72 | 54 |
}
|
| 73 | 55 |
|
| 74 | 56 |
@Override
|
| 75 |
- public void adaptTree(MoveRequest request, NavigationTree tree) {
|
|
| 76 |
- NavigationNode referenceNode = tree.getSelectedNode();
|
|
| 77 |
- boolean fromTrip = SampleUIHelper.fromTrip(request);
|
|
| 78 |
- if (SampleUIHelper.toTrip(request)) {
|
|
| 79 |
- if (fromTrip) {
|
|
| 80 |
- moveFromTripToTrip(tree, (SampleUINavigationNode) referenceNode, request.getNewParentId(), request.getId());
|
|
| 81 |
- } else {
|
|
| 82 |
- moveFromActivityToTrip(tree, (ActivitySampleUINavigationNode) referenceNode, request.getNewParentId(), request.getId());
|
|
| 83 |
- }
|
|
| 84 |
- } else {
|
|
| 85 |
- // move to activity
|
|
| 86 |
- if (fromTrip) {
|
|
| 87 |
- moveFromTripToActivity(tree, (SampleUINavigationNode) referenceNode, request.getNewParentId());
|
|
| 88 |
- } else {
|
|
| 89 |
- moveFromActivityToActivity(tree, (ActivitySampleUINavigationNode) referenceNode, request.getNewParentId());
|
|
| 90 |
- }
|
|
| 91 |
- }
|
|
| 92 |
- //FIXME Not sure we still need to do this.
|
|
| 93 |
- referenceNode.removeFromParent();
|
|
| 57 |
+ public void removeChildren(ActivityUINavigationNode oldParentNode, Set<String> ids) {
|
|
| 58 |
+ oldParentNode.getActivitySampleUINavigationNode().removeFromParent();
|
|
| 94 | 59 |
}
|
| 95 | 60 |
}
|
| 1 |
-package fr.ird.observe.client.datasource.editor.api.content.actions.move.tree;
|
|
| 1 |
+package fr.ird.observe.client.datasource.editor.ll.data.logbook.sample;
|
|
| 2 | 2 |
|
| 3 | 3 |
/*-
|
| 4 | 4 |
* #%L
|
| 5 |
- * ObServe Client :: DataSource :: Editor :: API
|
|
| 5 |
+ * ObServe Client :: DataSource :: Editor :: LL
|
|
| 6 | 6 |
* %%
|
| 7 | 7 |
* Copyright (C) 2008 - 2021 IRD, Code Lutin, Ultreia.io
|
| 8 | 8 |
* %%
|
| ... | ... | @@ -22,41 +22,40 @@ package fr.ird.observe.client.datasource.editor.api.content.actions.move.tree; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import com.google.common.collect.ImmutableSet;
|
|
| 26 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequest;
|
|
| 27 |
-import fr.ird.observe.client.datasource.editor.api.content.data.list.ContentListUINavigationNode;
|
|
| 28 |
-import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
|
| 29 |
-import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
|
| 25 |
+import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveTreeAdapter;
|
|
| 26 |
+import fr.ird.observe.client.datasource.editor.ll.data.logbook.ActivitySampleUINavigationNode;
|
|
| 27 |
+import fr.ird.observe.client.datasource.editor.ll.data.logbook.ActivityUINavigationNode;
|
|
| 28 |
+import fr.ird.observe.client.datasource.editor.ll.data.logbook.SampleListUINavigationNode;
|
|
| 29 |
+import fr.ird.observe.client.datasource.editor.ll.data.logbook.SampleUINavigationNode;
|
|
| 30 |
+ |
|
| 31 |
+import java.util.Set;
|
|
| 30 | 32 |
|
| 31 | 33 |
/**
|
| 32 |
- * Created on 15/10/2020.
|
|
| 34 |
+ * Created on 12/02/2021.
|
|
| 33 | 35 |
*
|
| 34 | 36 |
* @author Tony Chemit - dev@tchemit.fr
|
| 35 |
- * @since 8.0.1
|
|
| 37 |
+ * @since 8.0.6
|
|
| 36 | 38 |
*/
|
| 37 |
-public class DefaultMultipleMoveTreeAdapter implements MoveTreeAdapter {
|
|
| 38 |
- |
|
| 39 |
- @Override
|
|
| 40 |
- public void adaptTree(MoveRequest request, NavigationTree tree) {
|
|
| 41 |
- ImmutableSet<String> ids = request.getIds();
|
|
| 39 |
+public class ActivitySampleUIMoveTreeAdapterToTrip extends MoveTreeAdapter<ActivityUINavigationNode, SampleListUINavigationNode, SampleUINavigationNode> {
|
|
| 42 | 40 |
|
| 43 |
- // get old parent node
|
|
| 44 |
- ContentListUINavigationNode oldParentNode = (ContentListUINavigationNode) tree.getSelectedNode().upToReferenceContainerNode(request.getReferenceType());
|
|
| 45 |
- |
|
| 46 |
- // get shared ancestor of two parents
|
|
| 47 |
- NavigationNode parentContainerNode = oldParentNode.upToReferenceContainerNode(request.getParentReferenceType());
|
|
| 48 |
- |
|
| 49 |
- // get new parent node
|
|
| 50 |
- ContentListUINavigationNode newParentNode = MoveTreeAdapter.getNewParentNode(request, parentContainerNode);
|
|
| 41 |
+ public ActivitySampleUIMoveTreeAdapterToTrip(ActivitySampleUINavigationNode incomingNode) {
|
|
| 42 |
+ super(incomingNode, e -> incomingNode.getParent());
|
|
| 43 |
+ }
|
|
| 51 | 44 |
|
| 52 |
- // update it
|
|
| 53 |
- newParentNode.addChildren(ids);
|
|
| 54 | 45 |
|
| 55 |
- // clean old paren node
|
|
| 56 |
- MoveTreeAdapter.cleanOldParentNode(tree, ids, oldParentNode);
|
|
| 46 |
+ @Override
|
|
| 47 |
+ public SampleListUINavigationNode getNewParentNode(ActivityUINavigationNode oldParentNode, String newParentId) {
|
|
| 48 |
+ return oldParentNode.getParent().getParent().getSampleListUINavigationNode();
|
|
| 49 |
+ }
|
|
| 57 | 50 |
|
| 58 |
- MoveTreeAdapter.doFinalSelect(request, tree, oldParentNode, newParentNode);
|
|
| 51 |
+ @Override
|
|
| 52 |
+ public SampleUINavigationNode addMissingChildren(SampleListUINavigationNode newParentNode) {
|
|
| 53 |
+ return newParentNode.addMissingChildren();
|
|
| 59 | 54 |
}
|
| 60 | 55 |
|
| 56 |
+ @Override
|
|
| 57 |
+ public void removeChildren(ActivityUINavigationNode oldParentNode, Set<String> ids) {
|
|
| 58 |
+ oldParentNode.getActivitySampleUINavigationNode().removeFromParent();
|
|
| 59 |
+ }
|
|
| 61 | 60 |
|
| 62 |
-}
|
|
| \ No newline at end of file | ||
| 61 |
+}
|
| ... | ... | @@ -25,6 +25,11 @@ package fr.ird.observe.client.datasource.editor.ll.data.logbook.sample; |
| 25 | 25 |
import fr.ird.observe.client.ClientUIContext;
|
| 26 | 26 |
import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequest;
|
| 27 | 27 |
import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequestBuilder;
|
| 28 |
+import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveTreeAdapter;
|
|
| 29 |
+import fr.ird.observe.client.datasource.editor.ll.data.logbook.ActivitySampleUI;
|
|
| 30 |
+import fr.ird.observe.client.datasource.editor.ll.data.logbook.SampleListUI;
|
|
| 31 |
+import fr.ird.observe.client.datasource.editor.ll.data.logbook.SampleUI;
|
|
| 32 |
+import fr.ird.observe.client.datasource.editor.ll.data.logbook.SampleUIMoveTreeAdapter;
|
|
| 28 | 33 |
import fr.ird.observe.dto.data.TripAware;
|
| 29 | 34 |
import fr.ird.observe.dto.data.ll.common.TripReference;
|
| 30 | 35 |
import fr.ird.observe.dto.data.ll.logbook.ActivityReference;
|
| ... | ... | @@ -32,6 +37,7 @@ import fr.ird.observe.services.ObserveServicesProvider; |
| 32 | 37 |
import io.ultreia.java4all.i18n.I18n;
|
| 33 | 38 |
|
| 34 | 39 |
import javax.swing.JOptionPane;
|
| 40 |
+import java.util.function.Function;
|
|
| 35 | 41 |
import java.util.function.Supplier;
|
| 36 | 42 |
|
| 37 | 43 |
/**
|
| ... | ... | @@ -46,10 +52,6 @@ public class SampleUIHelper { |
| 46 | 52 |
return TripAware.class.isAssignableFrom(request.getParentTargetReferenceType());
|
| 47 | 53 |
}
|
| 48 | 54 |
|
| 49 |
- public static boolean fromTrip(MoveRequest request) {
|
|
| 50 |
- return TripAware.class.isAssignableFrom(request.getParentReferenceType());
|
|
| 51 |
- }
|
|
| 52 |
- |
|
| 53 | 55 |
public static Boolean movetoTrip() {
|
| 54 | 56 |
int response = ClientUIContext.askUser(
|
| 55 | 57 |
I18n.t("observe.data.ll.logbook.Sample.action.move.choose.parent.target.title"),
|
| ... | ... | @@ -88,4 +90,22 @@ public class SampleUIHelper { |
| 88 | 90 |
.setParentCandidates(servicesProvider.getLlLogbookActivityService()::getChildren);
|
| 89 | 91 |
};
|
| 90 | 92 |
}
|
| 93 |
+ |
|
| 94 |
+ public static Function<MoveRequest, ? extends MoveTreeAdapter<?, ?, ?>> create(ActivitySampleUI ui) {
|
|
| 95 |
+ return r -> toTrip(r)
|
|
| 96 |
+ ? new ActivitySampleUIMoveTreeAdapterToTrip(ui.getModel().getSource())
|
|
| 97 |
+ : new ActivitySampleUIMoveTreeAdapter(ui.getModel().getSource());
|
|
| 98 |
+ }
|
|
| 99 |
+ |
|
| 100 |
+ public static Function<MoveRequest, ? extends MoveTreeAdapter<?, ?, ?>> create(SampleListUI ui) {
|
|
| 101 |
+ return r -> toTrip(r)
|
|
| 102 |
+ ? new SampleUIMoveTreeAdapter(ui.getModel().getSource())
|
|
| 103 |
+ : new SampleUIMoveTreeAdapterToActivity(ui.getModel().getSource());
|
|
| 104 |
+ }
|
|
| 105 |
+ |
|
| 106 |
+ public static Function<MoveRequest, ? extends MoveTreeAdapter<?, ?, ?>> create(SampleUI ui) {
|
|
| 107 |
+ return r -> toTrip(r)
|
|
| 108 |
+ ? new SampleUIMoveTreeAdapter(ui.getModel().getSource())
|
|
| 109 |
+ : new SampleUIMoveTreeAdapterToActivity(ui.getModel().getSource());
|
|
| 110 |
+ }
|
|
| 91 | 111 |
}
|
| 1 |
-package fr.ird.observe.client.datasource.editor.api.content.actions.move.tree;
|
|
| 1 |
+package fr.ird.observe.client.datasource.editor.ll.data.logbook.sample;
|
|
| 2 | 2 |
|
| 3 | 3 |
/*-
|
| 4 | 4 |
* #%L
|
| 5 |
- * ObServe Client :: DataSource :: Editor :: API
|
|
| 5 |
+ * ObServe Client :: DataSource :: Editor :: LL
|
|
| 6 | 6 |
* %%
|
| 7 | 7 |
* Copyright (C) 2008 - 2021 IRD, Code Lutin, Ultreia.io
|
| 8 | 8 |
* %%
|
| ... | ... | @@ -22,48 +22,44 @@ package fr.ird.observe.client.datasource.editor.api.content.actions.move.tree; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequest;
|
|
| 26 |
-import fr.ird.observe.client.datasource.editor.api.content.data.list.ContentListUINavigationNode;
|
|
| 27 |
-import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
|
| 28 |
-import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
|
| 29 |
-import fr.ird.observe.dto.reference.DtoReference;
|
|
| 25 |
+import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveTreeAdapter;
|
|
| 26 |
+import fr.ird.observe.client.datasource.editor.ll.data.logbook.ActivitySampleUINavigationNode;
|
|
| 27 |
+import fr.ird.observe.client.datasource.editor.ll.data.logbook.ActivityUINavigationNode;
|
|
| 28 |
+import fr.ird.observe.client.datasource.editor.ll.data.logbook.SampleListUINavigationNode;
|
|
| 29 |
+import fr.ird.observe.client.datasource.editor.ll.data.logbook.SampleUINavigationNode;
|
|
| 30 |
+import fr.ird.observe.dto.data.ll.logbook.ActivitySampleReference;
|
|
| 31 |
+ |
|
| 32 |
+import java.util.Set;
|
|
| 30 | 33 |
|
| 31 | 34 |
/**
|
| 32 |
- * Created on 15/10/2020.
|
|
| 35 |
+ * Created on 12/02/2021.
|
|
| 33 | 36 |
*
|
| 34 | 37 |
* @author Tony Chemit - dev@tchemit.fr
|
| 35 |
- * @since 8.0.1
|
|
| 38 |
+ * @since 8.0.6
|
|
| 36 | 39 |
*/
|
| 37 |
-public class DefaultSingleMoveTreeAdapter implements MoveTreeAdapter {
|
|
| 38 |
- |
|
| 39 |
- @Override
|
|
| 40 |
- public void adaptTree(MoveRequest request, NavigationTree tree) {
|
|
| 41 |
- String id = request.getId();
|
|
| 42 |
- |
|
| 43 |
- Class<? extends DtoReference> parentReferenceType = request.getParentTargetReferenceType();
|
|
| 44 |
- |
|
| 45 |
- Class<? extends DtoReference> referenceType = request.getReferenceType();
|
|
| 46 |
- |
|
| 47 |
- // get old parent node
|
|
| 48 |
- ContentListUINavigationNode oldParentNode = (ContentListUINavigationNode) tree.getSelectedNode().upToReferenceContainerNode(referenceType);
|
|
| 49 |
- |
|
| 50 |
- // get shared ancestor of two parents
|
|
| 51 |
- NavigationNode parentContainerNode = oldParentNode.upToReferenceContainerNode(parentReferenceType);
|
|
| 52 |
- |
|
| 53 |
- // dow to new parent node
|
|
| 54 |
- ContentListUINavigationNode newParentNode = MoveTreeAdapter.getNewParentNode(request, parentContainerNode);
|
|
| 40 |
+public class SampleUIMoveTreeAdapterToActivity extends MoveTreeAdapter<SampleListUINavigationNode, ActivityUINavigationNode, ActivitySampleUINavigationNode> {
|
|
| 55 | 41 |
|
| 56 |
- // down to new child container node
|
|
| 57 |
- ContentListUINavigationNode newChildContainerNode = (ContentListUINavigationNode) newParentNode.downToReferenceContainerNode(referenceType);
|
|
| 42 |
+ public SampleUIMoveTreeAdapterToActivity(SampleListUINavigationNode incomingNode) {
|
|
| 43 |
+ super(incomingNode, e -> incomingNode);
|
|
| 44 |
+ }
|
|
| 58 | 45 |
|
| 59 |
- // update it
|
|
| 60 |
- NavigationNode node = newChildContainerNode.addChildren(id);
|
|
| 46 |
+ public SampleUIMoveTreeAdapterToActivity(SampleUINavigationNode incomingNode) {
|
|
| 47 |
+ super(incomingNode, e -> incomingNode.getParent());
|
|
| 48 |
+ }
|
|
| 61 | 49 |
|
| 62 |
- // clean old paren node
|
|
| 63 |
- MoveTreeAdapter.cleanOldParentNode(tree, request.getIds(), oldParentNode);
|
|
| 50 |
+ @Override
|
|
| 51 |
+ public ActivityUINavigationNode getNewParentNode(SampleListUINavigationNode oldParentNode, String newParentId) {
|
|
| 52 |
+ return oldParentNode.getParent().getLogbookActivityListUINavigationNode().getActivityUINavigationNode(newParentId);
|
|
| 53 |
+ }
|
|
| 64 | 54 |
|
| 65 |
- node.getParent().refreshToRoot();
|
|
| 55 |
+ @Override
|
|
| 56 |
+ public ActivitySampleUINavigationNode addMissingChildren(ActivityUINavigationNode newParentNode) {
|
|
| 57 |
+ ActivitySampleReference reference = newParentNode.getReference().getActivitySample();
|
|
| 58 |
+ return newParentNode.addActivitySampleUINavigationNode(reference);
|
|
| 59 |
+ }
|
|
| 66 | 60 |
|
| 67 |
- MoveTreeAdapter.doFinalSelect(request, tree, oldParentNode, node);
|
|
| 61 |
+ @Override
|
|
| 62 |
+ public void removeChildren(SampleListUINavigationNode oldParentNode, Set<String> ids) {
|
|
| 63 |
+ oldParentNode.removeChildren(ids);
|
|
| 68 | 64 |
}
|
| 69 | 65 |
}
|
| ... | ... | @@ -149,20 +149,21 @@ public abstract class GenerateContentUISupport extends GenerateJavaFileSupport { |
| 149 | 149 |
protected final boolean alwaysGenerateConcreteFile() {
|
| 150 | 150 |
return !getClass().getSimpleName().endsWith("ContentEditUIModel")
|
| 151 | 151 |
&& !getClass().getSimpleName().endsWith("EditUIHandler")
|
| 152 |
+ && !getClass().getSimpleName().endsWith("EditUIModelStates")
|
|
| 152 | 153 |
&& !getClass().getSimpleName().endsWith("OpenableUIHandler")
|
| 154 |
+ && !getClass().getSimpleName().endsWith("OpenableUIMoveTreeAdapter")
|
|
| 155 |
+ && !getClass().getSimpleName().endsWith("OpenableUIModelStates")
|
|
| 153 | 156 |
&& !getClass().getSimpleName().endsWith("ListUIHandler")
|
| 157 |
+ && !getClass().getSimpleName().endsWith("ListUINavigationCapability")
|
|
| 158 |
+// && !getClass().getSimpleName().endsWith("ListUINavigationHandler")
|
|
| 154 | 159 |
&& !getClass().getSimpleName().endsWith("SimpleUIHandler")
|
| 155 |
- && !getClass().getSimpleName().endsWith("TableUIHandler")
|
|
| 160 |
+ && !getClass().getSimpleName().endsWith("SimpleUIModelStates")
|
|
| 156 | 161 |
&& !getClass().getSimpleName().endsWith("NavigationScope")
|
| 157 | 162 |
&& !getClass().getSimpleName().endsWith("NavigationHandler")
|
| 158 |
-// && !getClass().getSimpleName().endsWith("ListUINavigationHandler")
|
|
| 159 |
- && !getClass().getSimpleName().endsWith("ListUINavigationCapability")
|
|
| 160 | 163 |
// && !getClass().getSimpleName().endsWith("TableUINavigationContext")
|
| 164 |
+ && !getClass().getSimpleName().endsWith("TableUIHandler")
|
|
| 161 | 165 |
&& !getClass().getSimpleName().endsWith("TableUITableModel")
|
| 162 | 166 |
&& !getClass().getSimpleName().endsWith("TableUIModelStates")
|
| 163 |
- && !getClass().getSimpleName().endsWith("EditUIModelStates")
|
|
| 164 |
- && !getClass().getSimpleName().endsWith("OpenableUIModelStates")
|
|
| 165 |
- && !getClass().getSimpleName().endsWith("SimpleUIModelStates")
|
|
| 166 | 167 |
;
|
| 167 | 168 |
}
|
| 168 | 169 |
|
| ... | ... | @@ -29,6 +29,7 @@ import fr.ird.observe.client.datasource.editor.spi.content.helper.ContentUINavig |
| 29 | 29 |
import java.nio.file.Path;
|
| 30 | 30 |
import java.util.LinkedList;
|
| 31 | 31 |
import java.util.List;
|
| 32 |
+import java.util.Set;
|
|
| 32 | 33 |
|
| 33 | 34 |
/**
|
| 34 | 35 |
* Created on 06/11/2020.
|
| ... | ... | @@ -38,6 +39,17 @@ import java.util.List; |
| 38 | 39 |
*/
|
| 39 | 40 |
public class GenerateContentListUINavigationNode extends GenerateContentListUISupport {
|
| 40 | 41 |
|
| 42 |
+ public static final String REMOVE_CHILDREN = "" +
|
|
| 43 |
+ " @Override\n" +
|
|
| 44 |
+ " public void removeChildren(Set<String> ids) {\n" +
|
|
| 45 |
+ " if (getChildCount() == ids.size() && !getParent().getInitializer().getConfig().isLoadEmptyProgram()) {\n" +
|
|
| 46 |
+ " // limit case : node will be empty, must remove it\n" +
|
|
| 47 |
+ " removeFromParent();\n" +
|
|
| 48 |
+ " return;\n" +
|
|
| 49 |
+ " }\n" +
|
|
| 50 |
+ " super.removeChildren(ids);\n" +
|
|
| 51 |
+ " }\n\n";
|
|
| 52 |
+ |
|
| 41 | 53 |
@Override
|
| 42 | 54 |
protected String generateConcreteContent(Path path, String packageName, String namePrefix) {
|
| 43 | 55 |
List<String> imports = new LinkedList<>();
|
| ... | ... | @@ -51,6 +63,13 @@ public class GenerateContentListUINavigationNode extends GenerateContentListUISu |
| 51 | 63 |
context += ContentUINavigationContextHelper.generateGetReferences(imports, referenceType);
|
| 52 | 64 |
context += ContentUINavigationContextHelper.generateGetParentReference(imports, parentReferenceType);
|
| 53 | 65 |
context += ContentUINavigationContextHelper.generateGetOpenableServiceSpi(imports, dtoType, referenceType, serviceType);
|
| 66 |
+ context += ContentUINavigationContextHelper.generateGetSibling(imports, cleanClassName);
|
|
| 67 |
+ context += ContentUINavigationContextHelper.generateGetParentSibling(imports, cleanClassName);
|
|
| 68 |
+ imports.add(Set.class.getName());
|
|
| 69 |
+ context += ContentUINavigationContextHelper.generateAddChildren(imports, dtoNamePrefix);
|
|
| 70 |
+ if (scopeBuilder.editNode.getParent().isRoot()) {
|
|
| 71 |
+ context += REMOVE_CHILDREN;
|
|
| 72 |
+ }
|
|
| 54 | 73 |
return uiNavigationNodeHelper.generateContent(imports, context);
|
| 55 | 74 |
}
|
| 56 | 75 |
|
| ... | ... | @@ -75,6 +75,7 @@ public class ContentOpenableUIDescriptor implements ContentUIDescriptor { |
| 75 | 75 |
GenerateContentOpenableUINavigationNode.class,
|
| 76 | 76 |
GenerateContentOpenableUINavigationScope.class,
|
| 77 | 77 |
GenerateContentOpenableUIHandler.class,
|
| 78 |
+ GenerateContentOpenableUIMoveTreeAdapter.class,
|
|
| 78 | 79 |
GenerateContentOpenableUIModelStates.class
|
| 79 | 80 |
);
|
| 80 | 81 |
}
|
| 1 |
+package fr.ird.observe.client.datasource.editor.spi.content.data.openable;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe Client :: DataSource :: Editor :: SPI
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2021 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.content.actions.move.MoveRequest;
|
|
| 26 |
+import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveTreeAdapter;
|
|
| 27 |
+ |
|
| 28 |
+import java.nio.file.Path;
|
|
| 29 |
+import java.util.LinkedList;
|
|
| 30 |
+import java.util.List;
|
|
| 31 |
+import java.util.Set;
|
|
| 32 |
+import java.util.function.Function;
|
|
| 33 |
+ |
|
| 34 |
+/**
|
|
| 35 |
+ * Created on 13/02/2021.
|
|
| 36 |
+ *
|
|
| 37 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 38 |
+ * @since 8.0.6
|
|
| 39 |
+ */
|
|
| 40 |
+public class GenerateContentOpenableUIMoveTreeAdapter extends GenerateContentOpenableUISupport {
|
|
| 41 |
+ |
|
| 42 |
+ public static final String GENERATED_CONTENT = "" +
|
|
| 43 |
+ "public abstract class Generated%1$sUIMoveTreeAdapter extends MoveTreeAdapter<%1$sListUINavigationNode, %1$sListUINavigationNode, %1$sUINavigationNode> {\n" +
|
|
| 44 |
+ "\n" +
|
|
| 45 |
+ " public static Function<MoveRequest, %1$sUIMoveTreeAdapter> create(%1$sListUI ui) {\n" +
|
|
| 46 |
+ " return r -> new %1$sUIMoveTreeAdapter(ui.getModel().getSource());\n" +
|
|
| 47 |
+ " }\n" +
|
|
| 48 |
+ "\n" +
|
|
| 49 |
+ " public static Function<MoveRequest, %1$sUIMoveTreeAdapter> create(%1$sUI ui) {\n" +
|
|
| 50 |
+ " return r -> new %1$sUIMoveTreeAdapter(ui.getModel().getSource());\n" +
|
|
| 51 |
+ " }\n\n" +
|
|
| 52 |
+ " public Generated%1$sUIMoveTreeAdapter(%1$sListUINavigationNode incomingNode) {\n" +
|
|
| 53 |
+ " super(incomingNode, e -> incomingNode);\n" +
|
|
| 54 |
+ " }\n\n" +
|
|
| 55 |
+ " public Generated%1$sUIMoveTreeAdapter(%1$sUINavigationNode incomingNode) {\n" +
|
|
| 56 |
+ " super(incomingNode, e -> incomingNode.getParent());\n" +
|
|
| 57 |
+ " }\n\n" +
|
|
| 58 |
+ " @Override\n" +
|
|
| 59 |
+ " public %1$sListUINavigationNode getNewParentNode(%1$sListUINavigationNode oldParentNode, String newParentId) {\n" +
|
|
| 60 |
+ " return oldParentNode.%2$s(newParentId);\n" +
|
|
| 61 |
+ " }\n" +
|
|
| 62 |
+ "\n" +
|
|
| 63 |
+ " @Override\n" +
|
|
| 64 |
+ " public %1$sUINavigationNode addMissingChildren(%1$sListUINavigationNode newParentNode) {\n" +
|
|
| 65 |
+ " return newParentNode.addMissingChildren();\n" +
|
|
| 66 |
+ " }\n" +
|
|
| 67 |
+ "\n" +
|
|
| 68 |
+ " @Override\n" +
|
|
| 69 |
+ " public void removeChildren(%1$sListUINavigationNode oldParentNode, Set<String> ids) {\n" +
|
|
| 70 |
+ " oldParentNode.removeChildren(ids);\n" +
|
|
| 71 |
+ " }\n" +
|
|
| 72 |
+ "}\n";
|
|
| 73 |
+ public static final String CONTENT = "" +
|
|
| 74 |
+ "public class %1$sUIMoveTreeAdapter extends Generated%1$sUIMoveTreeAdapter {\n\n" +
|
|
| 75 |
+ " public %1$sUIMoveTreeAdapter(%1$sListUINavigationNode incomingNode) {\n" +
|
|
| 76 |
+ " super(incomingNode);\n" +
|
|
| 77 |
+ " }\n\n" +
|
|
| 78 |
+ " public %1$sUIMoveTreeAdapter(%1$sUINavigationNode incomingNode) {\n" +
|
|
| 79 |
+ " super(incomingNode);\n" +
|
|
| 80 |
+ " }\n\n" +
|
|
| 81 |
+ "}\n";
|
|
| 82 |
+ |
|
| 83 |
+ @Override
|
|
| 84 |
+ protected String generateAbstractContent0(Path sourceDirectory, Path targetDirectory, Path path, String packageName, String namePrefix) {
|
|
| 85 |
+ List<String> imports = new LinkedList<>();
|
|
| 86 |
+ imports.add(Set.class.getName());
|
|
| 87 |
+ imports.add(MoveTreeAdapter.class.getName());
|
|
| 88 |
+ imports.add(MoveRequest.class.getName());
|
|
| 89 |
+ imports.add(Function.class.getName());
|
|
| 90 |
+ String siblingMethod = "findParentSibling";
|
|
| 91 |
+ if (scopeBuilder.selectNode.getParent().isRoot()) {
|
|
| 92 |
+ siblingMethod = "findSibling";
|
|
| 93 |
+ }
|
|
| 94 |
+ return generate(GENERATED_CONTENT, imports, dtoNamePrefix, siblingMethod);
|
|
| 95 |
+ }
|
|
| 96 |
+ |
|
| 97 |
+ @Override
|
|
| 98 |
+ protected String generateConcreteContent(Path path, String packageName, String namePrefix) {
|
|
| 99 |
+ List<String> imports = new LinkedList<>();
|
|
| 100 |
+ return generate(CONTENT, imports, dtoNamePrefix);
|
|
| 101 |
+ }
|
|
| 102 |
+}
|
| ... | ... | @@ -51,6 +51,8 @@ public class GenerateContentOpenableUINavigationNode extends GenerateContentOpen |
| 51 | 51 |
context += ContentUINavigationContextHelper.generateGetReference(imports, referenceType);
|
| 52 | 52 |
context += ContentUINavigationContextHelper.generateGetParentReference(imports, parentReferenceType);
|
| 53 | 53 |
context += ContentUINavigationContextHelper.generateGetOpenableServiceSpi(imports, dtoType, referenceType, serviceType);
|
| 54 |
+ context += ContentUINavigationContextHelper.generateGetSibling(imports, cleanClassName);
|
|
| 55 |
+ context += ContentUINavigationContextHelper.generateGetParentSibling(imports, cleanClassName);
|
|
| 54 | 56 |
return uiNavigationNodeHelper.generateContent(imports, context);
|
| 55 | 57 |
}
|
| 56 | 58 |
|
| ... | ... | @@ -23,13 +23,13 @@ package fr.ird.observe.client.datasource.editor.spi.content.helper; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.datasource.editor.api.content.actions.create.CreateNewOpenableUI;
|
| 26 |
+import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveAction;
|
|
| 27 |
+import fr.ird.observe.client.datasource.editor.api.content.actions.move.MoveRequestBuilder;
|
|
| 26 | 28 |
import fr.ird.observe.client.datasource.editor.api.content.actions.save.SaveAction;
|
| 27 | 29 |
import fr.ird.observe.client.datasource.editor.api.content.data.edit.actions.DeleteEdit;
|
| 28 | 30 |
import fr.ird.observe.client.datasource.editor.api.content.data.edit.actions.SaveContentEditUIAdapter;
|
| 29 | 31 |
import fr.ird.observe.client.datasource.editor.api.content.data.list.actions.DeleteMultiple;
|
| 30 |
-import fr.ird.observe.client.datasource.editor.api.content.data.list.actions.MoveMultiple;
|
|
| 31 | 32 |
import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.DeleteOpenable;
|
| 32 |
-import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.MoveOpenable;
|
|
| 33 | 33 |
import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.SaveContentOpenableUIAdapter;
|
| 34 | 34 |
import fr.ird.observe.client.datasource.editor.api.content.data.simple.actions.SaveContentSimpleUIAdapter;
|
| 35 | 35 |
import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.SaveContentTableUIAdapter;
|
| ... | ... | @@ -72,7 +72,12 @@ public class ContentUIHandlerHelper extends ContentUIHelperSupport { |
| 72 | 72 |
public static final String INSTALL_MOVE_SIMPLE_ACTION = "" +
|
| 73 | 73 |
" @Override\n" +
|
| 74 | 74 |
" protected void installMoveAction() {\n" +
|
| 75 |
- " MoveOpenable.installAction(ui, %1$s()::%2$s, r -> %3$s()::move);\n" +
|
|
| 75 |
+ " MoveAction\n" +
|
|
| 76 |
+ " .create(ui)\n" +
|
|
| 77 |
+ " .on(() -> MoveRequestBuilder.create(ui.getModel()).setParentCandidates(%1$s()::%2$s))\n" +
|
|
| 78 |
+ " .move(r -> %3$s()::move)\n" +
|
|
| 79 |
+ " .then(%4$sMoveTreeAdapter::create)\n" +
|
|
| 80 |
+ " .install(ui::getMove);\n" +
|
|
| 76 | 81 |
" }\n\n";
|
| 77 | 82 |
public static final String INSTALL_DELETE_SIMPLE_ACTION = "" +
|
| 78 | 83 |
" @Override\n" +
|
| ... | ... | @@ -82,7 +87,12 @@ public class ContentUIHandlerHelper extends ContentUIHelperSupport { |
| 82 | 87 |
public static final String INSTALL_MOVE_ACTION = "" +
|
| 83 | 88 |
" @Override\n" +
|
| 84 | 89 |
" protected void installMoveAction() {\n" +
|
| 85 |
- " MoveMultiple.installMoveAction(ui, %1$s()::%2$s, r -> %3$s()::move);\n" +
|
|
| 90 |
+ " MoveAction\n" +
|
|
| 91 |
+ " .create(ui)\n" +
|
|
| 92 |
+ " .on(() -> MoveRequestBuilder.create(ui.getModel()).setParentCandidates(%1$s()::%2$s))\n" +
|
|
| 93 |
+ " .move(r -> %3$s()::move)\n" +
|
|
| 94 |
+ " .then(%4$sMoveTreeAdapter::create)\n" +
|
|
| 95 |
+ " .install(ui::getMove);\n" +
|
|
| 86 | 96 |
" }\n\n";
|
| 87 | 97 |
public static final String INSTALL_DELETE_ACTION = "" +
|
| 88 | 98 |
" @Override\n" +
|
| ... | ... | @@ -97,7 +107,8 @@ public class ContentUIHandlerHelper extends ContentUIHelperSupport { |
| 97 | 107 |
public static final String INSTALL_SAVE_ACTION_METHOD = "" +
|
| 98 | 108 |
" @Override\n" +
|
| 99 | 109 |
" protected void installSaveAction() {\n" +
|
| 100 |
- " SaveAction.create(ui, %1$s.class)\n" +
|
|
| 110 |
+ " SaveAction\n" +
|
|
| 111 |
+ " .create(ui, %1$s.class)\n" +
|
|
| 101 | 112 |
" .on(ui.getModel().getStates()::toSaveRequest)\n" +
|
| 102 | 113 |
" .save((r, d) -> %2$s)\n" +
|
| 103 | 114 |
" .then(new %3$s<>())\n" +
|
| ... | ... | @@ -169,8 +180,6 @@ public class ContentUIHandlerHelper extends ContentUIHelperSupport { |
| 169 | 180 |
adapterType = SaveContentEditUIAdapter.class;
|
| 170 | 181 |
serviceCall += "().save(r.getParentId(), d)";
|
| 171 | 182 |
break;
|
| 172 |
- case REFERENTIAL:
|
|
| 173 |
- return "";
|
|
| 174 | 183 |
case OPEN:
|
| 175 | 184 |
dtoType = generator.scopeBuilder.dtoType;
|
| 176 | 185 |
adapterType = SaveContentOpenableUIAdapter.class;
|
| ... | ... | @@ -240,14 +249,15 @@ public class ContentUIHandlerHelper extends ContentUIHelperSupport { |
| 240 | 249 |
}
|
| 241 | 250 |
if (extraType == null) {
|
| 242 | 251 |
if (editNode != null && selectNode != null && selectNode.getType().equals(editNode.getType())) {
|
| 243 |
- imports.add(MoveOpenable.class.getName());
|
|
| 252 |
+ imports.add(MoveAction.class.getName());
|
|
| 253 |
+ imports.add(MoveRequestBuilder.class.getName());
|
|
| 244 | 254 |
String methodName = "getBrothers";
|
| 245 | 255 |
if (editNode.getLevel() == 1) {
|
| 246 | 256 |
methodName = "getParentBrothers";
|
| 247 | 257 |
}
|
| 248 | 258 |
imports.add(CreateNewOpenableUI.class.getName());
|
| 249 | 259 |
|
| 250 |
- extraMethods += String.format(INSTALL_MOVE_SIMPLE_ACTION, serviceParentMethod, methodName, serviceMethod);
|
|
| 260 |
+ extraMethods += String.format(INSTALL_MOVE_SIMPLE_ACTION, serviceParentMethod, methodName, serviceMethod, generator.cleanClassName);
|
|
| 251 | 261 |
}
|
| 252 | 262 |
Class<?> deleteActionType = null;
|
| 253 | 263 |
switch (generator.getDescriptor().getContentNodeType()) {
|
| ... | ... | @@ -275,7 +285,8 @@ public class ContentUIHandlerHelper extends ContentUIHelperSupport { |
| 275 | 285 |
String helperName = StringUtils.capitalize(editNode.getModule().getName().toLowerCase()) + "TripActionHelper";
|
| 276 | 286 |
imports.add(generator.packageName.substring(0, generator.packageName.lastIndexOf(".") + 1) + helperName);
|
| 277 | 287 |
imports.add(DeleteMultiple.class.getName());
|
| 278 |
- imports.add(MoveMultiple.class.getName());
|
|
| 288 |
+ imports.add(MoveAction.class.getName());
|
|
| 289 |
+ imports.add(MoveRequestBuilder.class.getName());
|
|
| 279 | 290 |
imports.add(CreateNewOpenableUI.class.getName());
|
| 280 | 291 |
if (editNode.getLevel() == 1) {
|
| 281 | 292 |
extraMethods += String.format(ON_END_OPEN_UI, helperName);
|
| ... | ... | @@ -283,7 +294,7 @@ public class ContentUIHandlerHelper extends ContentUIHelperSupport { |
| 283 | 294 |
|
| 284 | 295 |
}
|
| 285 | 296 |
extraMethods += generateListCreateNewAction(imports, generator);
|
| 286 |
- extraMethods += String.format(INSTALL_MOVE_ACTION, serviceParentMethod, methodName, serviceMethod);
|
|
| 297 |
+ extraMethods += String.format(INSTALL_MOVE_ACTION, serviceParentMethod, methodName, serviceMethod, generator.cleanClassName.replace("List", ""));
|
|
| 287 | 298 |
extraMethods += String.format(INSTALL_DELETE_ACTION, serviceMethod);
|
| 288 | 299 |
return generate(ContentUIHandlerHelper.UI_HANDLER_GENERATED2, imports, generator.cleanClassName, uiHandler, dtoType, extraType, extraMethods);
|
| 289 | 300 |
}
|
| ... | ... | @@ -82,6 +82,21 @@ public class ContentUINavigationContextHelper extends ContentUIHelperSupport { |
| 82 | 82 |
" public final %1$s get%2$s() {\n" +
|
| 83 | 83 |
" return (%1$s) super.get%2$s();\n" +
|
| 84 | 84 |
" }\n\n";
|
| 85 |
+ public static final String GET_SIBLING = "" +
|
|
| 86 |
+ " @Override\n" +
|
|
| 87 |
+ " public %1$sNavigationNode findSibling(String siblingId) {\n" +
|
|
| 88 |
+ " return (%1$sNavigationNode) super.findSibling(siblingId);\n" +
|
|
| 89 |
+ " }\n\n";
|
|
| 90 |
+ public static final String GET_PARENT_SIBLING = "" +
|
|
| 91 |
+ " @Override\n" +
|
|
| 92 |
+ " public %1$sNavigationNode findParentSibling(String siblingId) {\n" +
|
|
| 93 |
+ " return (%1$sNavigationNode) super.findParentSibling(siblingId);\n" +
|
|
| 94 |
+ " }\n\n";
|
|
| 95 |
+ public static final String ADD_CHILDREN = "" +
|
|
| 96 |
+ " @Override\n" +
|
|
| 97 |
+ " public %1$sUINavigationNode addMissingChildren() {\n" +
|
|
| 98 |
+ " return (%1$sUINavigationNode) super.addMissingChildren();\n" +
|
|
| 99 |
+ " }\n\n";
|
|
| 85 | 100 |
|
| 86 | 101 |
public static String generateGetReference(List<String> imports, Class<?> referenceType) {
|
| 87 | 102 |
imports.add(referenceType.getName());
|
| ... | ... | @@ -99,6 +114,21 @@ public class ContentUINavigationContextHelper extends ContentUIHelperSupport { |
| 99 | 114 |
return String.format(GET_REFERENCE, referenceType.getSimpleName(), "ParentReference");
|
| 100 | 115 |
}
|
| 101 | 116 |
|
| 117 |
+ public static String generateAddChildren(List<String> imports, String name) {
|
|
| 118 |
+ imports.add(OpenableDtoServiceContext.class.getName());
|
|
| 119 |
+ return String.format(ADD_CHILDREN, name);
|
|
| 120 |
+ }
|
|
| 121 |
+ |
|
| 122 |
+ public static String generateGetSibling(List<String> imports, String name) {
|
|
| 123 |
+ imports.add(OpenableDtoServiceContext.class.getName());
|
|
| 124 |
+ return String.format(GET_SIBLING, name);
|
|
| 125 |
+ }
|
|
| 126 |
+ |
|
| 127 |
+ public static String generateGetParentSibling(List<String> imports, String name) {
|
|
| 128 |
+ imports.add(OpenableDtoServiceContext.class.getName());
|
|
| 129 |
+ return String.format(GET_PARENT_SIBLING, name);
|
|
| 130 |
+ }
|
|
| 131 |
+ |
|
| 102 | 132 |
public static String generateGetOpenableServiceSpi(List<String> imports, Class<?> dtoType, Class<?> referenceType, Class<?> serviceType) {
|
| 103 | 133 |
imports.add(dtoType.getName());
|
| 104 | 134 |
imports.add(referenceType.getName());
|