Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
baec96e5
by Tony CHEMIT at 2017-12-21T20:48:04+01:00
25 changed files:
- client/src/main/java/fr/ird/observe/client/ds/editor/form/MoveDataHelper.java
- client/src/main/java/fr/ird/observe/client/ds/editor/form/open/longline/ActivityLonglineObsUIModel.java
- client/src/main/java/fr/ird/observe/client/ds/editor/form/open/longline/TripLonglineUIModel.java
- client/src/main/java/fr/ird/observe/client/ds/editor/form/open/seine/ActivitySeineUIModel.java
- client/src/main/java/fr/ird/observe/client/ds/editor/form/open/seine/RouteUIModel.java
- client/src/main/java/fr/ird/observe/client/ds/editor/form/open/seine/TripSeineUIModel.java
- − client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/CommonOpenDataListFormUI.jcss
- − client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/OpenDataListFormUIMoveMultipleTripActionSupport.java
- client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/longline/ActivityLonglineObsListUI.jaxx
- client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/longline/ActivityLonglineObsListUIModel.java
- client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/longline/TripLonglineListUI.jaxx
- client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/longline/TripLonglineListUIModel.java
- − client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/longline/actions/OpenDataListFormUICreateActivityLonglineObs.java
- − client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/longline/actions/OpenDataListFormUIMoveMultipleActivityLonglineObs.java
- − client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/longline/actions/OpenDataListFormUIMoveMultipleTripLongline.java
- client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/seine/ActivitySeineListUI.jaxx
- client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/seine/ActivitySeineListUIModel.java
- client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/seine/RouteListUI.jaxx
- client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/seine/RouteListUIModel.java
- client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/seine/TripSeineListUI.jaxx
- client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/seine/TripSeineListUIModel.java
- − client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/seine/actions/OpenDataListFormUICreateActivitySeine.java
- − client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/seine/actions/OpenDataListFormUIMoveMultipleActivitySeine.java
- − client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/seine/actions/OpenDataListFormUIMoveMultipleRoute.java
- − client/src/main/java/fr/ird/observe/client/ds/editor/form/openlist/seine/actions/OpenDataListFormUIMoveMultipleTripSeine.java
Changes:
| ... | ... | @@ -22,6 +22,7 @@ package fr.ird.observe.client.ds.editor.form; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import fr.ird.observe.client.ClientApplicationContext;
|
|
| 25 | 26 |
import fr.ird.observe.client.ObserveClientApplicationContext;
|
| 26 | 27 |
import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
| 27 | 28 |
import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
| ... | ... | @@ -30,7 +31,6 @@ import fr.ird.observe.client.ds.editor.tree.navigation.nodes.longline.TripLongli |
| 30 | 31 |
import fr.ird.observe.client.ds.editor.tree.navigation.nodes.seine.RouteSeineNavigationTreeNode;
|
| 31 | 32 |
import fr.ird.observe.client.ds.editor.tree.navigation.nodes.seine.TripSeineListNavigationTreeNode;
|
| 32 | 33 |
import fr.ird.observe.client.ds.editor.tree.navigation.nodes.seine.TripSeineNavigationTreeNode;
|
| 33 |
-import fr.ird.observe.client.main.MainUI;
|
|
| 34 | 34 |
import fr.ird.observe.client.util.DecoratedNodeEntity;
|
| 35 | 35 |
import fr.ird.observe.dto.IdHelper;
|
| 36 | 36 |
import fr.ird.observe.dto.data.longline.TripLonglineReference;
|
| ... | ... | @@ -38,15 +38,14 @@ import fr.ird.observe.dto.data.seine.RouteReference; |
| 38 | 38 |
import fr.ird.observe.dto.data.seine.TripSeineReference;
|
| 39 | 39 |
import fr.ird.observe.dto.decoration.decorators.DataReferenceDecorator;
|
| 40 | 40 |
import fr.ird.observe.dto.decoration.decorators.ReferentialReferenceDecorator;
|
| 41 |
-import fr.ird.observe.dto.referential.GearType;
|
|
| 41 |
+import fr.ird.observe.dto.referential.ProgramDto;
|
|
| 42 | 42 |
import fr.ird.observe.dto.referential.ProgramReference;
|
| 43 |
+import fr.ird.observe.spi.application.ObserveApplicationDataContext;
|
|
| 43 | 44 |
|
| 44 |
-import javax.swing.JOptionPane;
|
|
| 45 | 45 |
import java.util.ArrayList;
|
| 46 |
+import java.util.Iterator;
|
|
| 46 | 47 |
import java.util.List;
|
| 47 |
-import java.util.Optional;
|
|
| 48 |
- |
|
| 49 |
-import static org.nuiton.i18n.I18n.t;
|
|
| 48 |
+import java.util.Set;
|
|
| 50 | 49 |
|
| 51 | 50 |
/**
|
| 52 | 51 |
* Created by tchemit on 26/11/17.
|
| ... | ... | @@ -55,135 +54,101 @@ import static org.nuiton.i18n.I18n.t; |
| 55 | 54 |
*/
|
| 56 | 55 |
public class MoveDataHelper {
|
| 57 | 56 |
|
| 58 |
- public static Optional<String> chooseNewTripLongline(MainUI ui, NavigationTreeNodeSupport oldParentNode) {
|
|
| 59 |
- |
|
| 60 |
- NavigationTreeNodeSupport programNode = oldParentNode.getParent();
|
|
| 61 |
- String oldTripLonglineId = oldParentNode.getId();
|
|
| 62 |
- int tripLonglineNb = programNode.getChildCount();
|
|
| 57 |
+ public static void moveTrips(NavigationTree treeHelper, String newParentId, Set<String> dataIds, List<Integer> positions, NavigationTreeNodeSupport oldParentNode) {
|
|
| 63 | 58 |
|
| 64 | 59 |
ObserveClientApplicationContext applicationContext = ObserveClientApplicationContext.get();
|
| 65 |
- DataReferenceDecorator<TripLonglineReference> decorator = applicationContext.getDataReferenceDecorator(TripLonglineReference.class, null);
|
|
| 60 |
+ ObserveApplicationDataContext openDataManager = applicationContext.getApplicationDataContext();
|
|
| 66 | 61 |
|
| 67 |
- //on crée un tableau avec une marée en moins car on ne propose pas la marée actuelle
|
|
| 68 |
- DecoratedNodeEntity[] decoratedTripLonglines = new DecoratedNodeEntity[tripLonglineNb - 1];
|
|
| 62 |
+ NavigationTreeNodeSupport rootNode = treeHelper.getRootNode();
|
|
| 63 |
+ NavigationTreeNodeSupport newProgramNode = treeHelper.getChild(rootNode, newParentId);
|
|
| 69 | 64 |
|
| 70 |
- int j = 0;
|
|
| 71 |
- for (int i = 0; i < tripLonglineNb; i++) {
|
|
| 65 |
+ Iterator<String> iterator = dataIds.iterator();
|
|
| 66 |
+ for (Integer position : positions) {
|
|
| 72 | 67 |
|
| 73 |
- TripLonglineNavigationTreeNode tripLonglineNode = (TripLonglineNavigationTreeNode) programNode.getChildAt(i);
|
|
| 68 |
+ String tripId = iterator.next();
|
|
| 69 |
+ NavigationTreeNodeSupport tripNode = treeHelper.getChild(oldParentNode, tripId);
|
|
| 70 |
+ boolean wasOpen = tripNode.isOpen();
|
|
| 71 |
+ treeHelper.removeNode(tripNode);
|
|
| 74 | 72 |
|
| 75 |
- String tripLonglineId = tripLonglineNode.getId();
|
|
| 73 |
+ if (wasOpen) {
|
|
| 74 |
+ openDataManager.close(ProgramDto.class);
|
|
| 75 |
+ openDataManager.open(ProgramDto.class, newParentId);
|
|
| 76 |
+ }
|
|
| 77 |
+ |
|
| 78 |
+ NavigationTreeNodeSupport newTripNode = treeHelper.getChild(newProgramNode, tripId);
|
|
| 79 |
+ |
|
| 80 |
+ if (newTripNode == null) {
|
|
| 76 | 81 |
|
| 77 |
- if (!oldTripLonglineId.equals(tripLonglineId)) {
|
|
| 78 |
- decoratedTripLonglines[j++] = DecoratedNodeEntity.newDecoratedNodeEntity(tripLonglineNode, decorator);
|
|
| 82 |
+ // create it
|
|
| 83 |
+ treeHelper.insertNode(newProgramNode, tripNode, position);
|
|
| 79 | 84 |
}
|
| 80 | 85 |
}
|
| 81 | 86 |
|
| 82 |
- Object decoratedTripLongline = JOptionPane.showInputDialog(ui,
|
|
| 83 |
- t("observe.action.choose.tripLongline.message"),
|
|
| 84 |
- t("observe.action.choose.tripLongline.title"),
|
|
| 85 |
- JOptionPane.QUESTION_MESSAGE,
|
|
| 86 |
- null,
|
|
| 87 |
- decoratedTripLonglines,
|
|
| 88 |
- null);
|
|
| 89 |
- return Optional.ofNullable(decoratedTripLongline != null ? ((DecoratedNodeEntity) decoratedTripLongline).getId() : null);
|
|
| 87 |
+ treeHelper.reloadNode(oldParentNode, true);
|
|
| 88 |
+ treeHelper.reloadNode(newProgramNode, true);
|
|
| 89 |
+ treeHelper.selectNode(newProgramNode);
|
|
| 90 |
+ |
|
| 90 | 91 |
}
|
| 91 | 92 |
|
| 92 |
- public static Optional<String> chooseNewRoute(MainUI ui, NavigationTreeNodeSupport oldParentNode) {
|
|
| 93 |
+ public static DecoratedNodeEntity[] getTripLonglineParentCandidates(FormUI ui, String parentId) {
|
|
| 93 | 94 |
|
| 94 |
- NavigationTreeNodeSupport routesNode = oldParentNode.getParent();
|
|
| 95 |
- String oldRouteId = oldParentNode.getId();
|
|
| 96 |
- int routeNb = routesNode.getChildCount();
|
|
| 95 |
+ NavigationTree treeHelper = ui.getDataSourceUI().getTree();
|
|
| 97 | 96 |
|
| 98 |
- ObserveClientApplicationContext applicationContext = ObserveClientApplicationContext.get();
|
|
| 99 |
- DataReferenceDecorator<RouteReference> decorator = applicationContext.getDecoratorService().getDataReferenceDecorator(RouteReference.class);
|
|
| 97 |
+ NavigationTreeNodeSupport rootNode = treeHelper.getRootNode();
|
|
| 100 | 98 |
|
| 101 |
- //on crée un tableau avec une route en moins car on ne propose pas la route actuel
|
|
| 102 |
- DecoratedNodeEntity[] decoratedRoutes = new DecoratedNodeEntity[routeNb - 1];
|
|
| 99 |
+ List<DecoratedNodeEntity> result = new ArrayList<>();
|
|
| 103 | 100 |
|
| 104 |
- int j = 0;
|
|
| 105 |
- for (int i = 0; i < routeNb; i++) {
|
|
| 101 |
+ ReferentialReferenceDecorator<ProgramReference> programDecorator = ui.getMainUI().getApplicationContext().getDecoratorService().getReferentialReferenceDecorator(ProgramReference.class);
|
|
| 106 | 102 |
|
| 107 |
- RouteSeineNavigationTreeNode routeNode = (RouteSeineNavigationTreeNode) routesNode.getChildAt(i);
|
|
| 103 |
+ for (int i = 0, n = rootNode.getChildCount(); i < n; i++) {
|
|
| 108 | 104 |
|
| 109 |
- String routeId = routeNode.getId();
|
|
| 105 |
+ NavigationTreeNodeSupport programNode = (NavigationTreeNodeSupport) rootNode.getChildAt(i);
|
|
| 106 |
+ String programId = programNode.getId();
|
|
| 110 | 107 |
|
| 111 |
- if (!oldRouteId.equals(routeId)) {
|
|
| 112 |
- decoratedRoutes[j++] = DecoratedNodeEntity.newDecoratedNodeEntity(routeNode, decorator);
|
|
| 108 |
+ if (programId != null && IdHelper.isProgramId(programId) && !parentId.equals(programId)) {
|
|
| 109 |
+ if (programNode instanceof TripLonglineListNavigationTreeNode) {
|
|
| 110 |
+ TripLonglineListNavigationTreeNode node = (TripLonglineListNavigationTreeNode) programNode;
|
|
| 111 |
+ result.add(DecoratedNodeEntity.newDecoratedNodeEntity(node, programDecorator));
|
|
| 112 |
+ }
|
|
| 113 | 113 |
}
|
| 114 | 114 |
}
|
| 115 |
- |
|
| 116 |
- Object decoratedRoute = JOptionPane.showInputDialog(ui,
|
|
| 117 |
- t("observe.action.choose.route.message"),
|
|
| 118 |
- t("observe.action.choose.route.title"),
|
|
| 119 |
- JOptionPane.QUESTION_MESSAGE,
|
|
| 120 |
- null,
|
|
| 121 |
- decoratedRoutes,
|
|
| 122 |
- null);
|
|
| 123 |
- |
|
| 124 |
- return Optional.ofNullable(decoratedRoute != null ? ((DecoratedNodeEntity) decoratedRoute).getId() : null);
|
|
| 115 |
+ return result.toArray(new DecoratedNodeEntity[result.size()]);
|
|
| 125 | 116 |
}
|
| 126 | 117 |
|
| 127 |
- public static Optional<String> chooseNewProgram(MainUI mainUI, GearType gearType, String oldProgramId) {
|
|
| 118 |
+ public static DecoratedNodeEntity[] getTripSeineParentCandidates(FormUI ui, String parentId) {
|
|
| 128 | 119 |
|
| 129 |
- NavigationTree treeHelper = mainUI.getDataSourceEditor().getTree();
|
|
| 120 |
+ NavigationTree treeHelper = ui.getDataSourceUI().getTree();
|
|
| 130 | 121 |
|
| 131 |
- // racine
|
|
| 132 | 122 |
NavigationTreeNodeSupport rootNode = treeHelper.getRootNode();
|
| 133 | 123 |
|
| 134 |
- //on crée un tableau avec un programme en moins car on ne propose pas le programme actuel
|
|
| 135 |
- List<DecoratedNodeEntity> decoratedProgramList = new ArrayList<>();
|
|
| 124 |
+ List<DecoratedNodeEntity> result = new ArrayList<>();
|
|
| 136 | 125 |
|
| 137 |
- ReferentialReferenceDecorator<ProgramReference> programDecorator = ObserveClientApplicationContext.get().getDecoratorService().getReferentialReferenceDecorator(ProgramReference.class);
|
|
| 126 |
+ ReferentialReferenceDecorator<ProgramReference> programDecorator = ui.getMainUI().getApplicationContext().getDecoratorService().getReferentialReferenceDecorator(ProgramReference.class);
|
|
| 138 | 127 |
|
| 139 | 128 |
for (int i = 0, n = rootNode.getChildCount(); i < n; i++) {
|
| 140 | 129 |
|
| 141 | 130 |
NavigationTreeNodeSupport programNode = (NavigationTreeNodeSupport) rootNode.getChildAt(i);
|
| 142 | 131 |
String programId = programNode.getId();
|
| 143 | 132 |
|
| 144 |
- // si le noeud programme n'est pas le même que le parent actuel
|
|
| 145 |
- // si le noeud est bien un noeud de programme
|
|
| 146 |
- if (programId != null && IdHelper.isProgramId(programId) && !oldProgramId.equals(programId)) {
|
|
| 147 |
- |
|
| 148 |
- if (programNode instanceof TripSeineListNavigationTreeNode && GearType.seine == gearType) {
|
|
| 149 |
- |
|
| 133 |
+ if (programId != null && IdHelper.isProgramId(programId) && !parentId.equals(programId)) {
|
|
| 134 |
+ if (programNode instanceof TripSeineListNavigationTreeNode) {
|
|
| 150 | 135 |
TripSeineListNavigationTreeNode node = (TripSeineListNavigationTreeNode) programNode;
|
| 151 |
- decoratedProgramList.add(DecoratedNodeEntity.newDecoratedNodeEntity(node, programDecorator));
|
|
| 152 |
- |
|
| 153 |
- } else if (programNode instanceof TripLonglineListNavigationTreeNode && GearType.longline == gearType) {
|
|
| 154 |
- |
|
| 155 |
- TripLonglineListNavigationTreeNode node = (TripLonglineListNavigationTreeNode) programNode;
|
|
| 156 |
- decoratedProgramList.add(DecoratedNodeEntity.newDecoratedNodeEntity(node, programDecorator));
|
|
| 157 |
- |
|
| 136 |
+ result.add(DecoratedNodeEntity.newDecoratedNodeEntity(node, programDecorator));
|
|
| 158 | 137 |
}
|
| 159 |
- |
|
| 160 | 138 |
}
|
| 161 | 139 |
}
|
| 162 |
- |
|
| 163 |
- DecoratedNodeEntity[] decoratedPrograms =
|
|
| 164 |
- decoratedProgramList.toArray(new DecoratedNodeEntity[decoratedProgramList.size()]);
|
|
| 165 |
- |
|
| 166 |
- DecoratedNodeEntity decoratedProgram = (DecoratedNodeEntity) JOptionPane.showInputDialog(mainUI,
|
|
| 167 |
- t("observe.action.choose.program.message"),
|
|
| 168 |
- t("observe.action.choose.program.title"),
|
|
| 169 |
- JOptionPane.QUESTION_MESSAGE,
|
|
| 170 |
- null,
|
|
| 171 |
- decoratedPrograms,
|
|
| 172 |
- null);
|
|
| 173 |
- |
|
| 174 |
- return Optional.ofNullable(decoratedProgram == null ? null : decoratedProgram.getId());
|
|
| 140 |
+ return result.toArray(new DecoratedNodeEntity[result.size()]);
|
|
| 175 | 141 |
}
|
| 176 | 142 |
|
| 177 |
- public static Optional<String> chooseNewTripSeine(MainUI mainUI, NavigationTreeNodeSupport oldTripSeineNode) {
|
|
| 178 |
- NavigationTreeNodeSupport programNode = oldTripSeineNode.getParent();
|
|
| 179 |
- String oldTripSeineId = oldTripSeineNode.getId();
|
|
| 143 |
+ public static DecoratedNodeEntity[] getRouteParentCandidates(String parentId, NavigationTreeNodeSupport oldParentNode) {
|
|
| 144 |
+ |
|
| 145 |
+ NavigationTreeNodeSupport programNode = oldParentNode.getParent();
|
|
| 180 | 146 |
int tripSeineNb = programNode.getChildCount();
|
| 181 | 147 |
|
| 182 |
- ObserveClientApplicationContext applicationContext = ObserveClientApplicationContext.get();
|
|
| 183 |
- DataReferenceDecorator<TripSeineReference> decorator = applicationContext.getDecoratorService().getDataReferenceDecorator(TripSeineReference.class);
|
|
| 148 |
+ ClientApplicationContext applicationContext = ClientApplicationContext.get();
|
|
| 149 |
+ DataReferenceDecorator decorator = applicationContext.getDecoratorService().getDataReferenceDecorator(TripSeineReference.class);
|
|
| 184 | 150 |
|
| 185 |
- //on crée un tableau avec une marée en moins car on ne propose pas la marée actuel
|
|
| 186 |
- DecoratedNodeEntity[] decoratedTripSeines = new DecoratedNodeEntity[tripSeineNb - 1];
|
|
| 151 |
+ DecoratedNodeEntity[] result = new DecoratedNodeEntity[tripSeineNb - 1];
|
|
| 187 | 152 |
|
| 188 | 153 |
int j = 0;
|
| 189 | 154 |
for (int i = 0; i < tripSeineNb; i++) {
|
| ... | ... | @@ -192,18 +157,52 @@ public class MoveDataHelper { |
| 192 | 157 |
|
| 193 | 158 |
String tripSeineId = tripSeineNode.getId();
|
| 194 | 159 |
|
| 195 |
- if (!oldTripSeineId.equals(tripSeineId)) {
|
|
| 196 |
- decoratedTripSeines[j++] = DecoratedNodeEntity.newDecoratedNodeEntity(tripSeineNode, decorator);
|
|
| 160 |
+ if (!parentId.equals(tripSeineId)) {
|
|
| 161 |
+ result[j++] = DecoratedNodeEntity.newDecoratedNodeEntity(tripSeineNode, decorator);
|
|
| 197 | 162 |
}
|
| 198 | 163 |
}
|
| 164 |
+ return result;
|
|
| 165 |
+ }
|
|
| 166 |
+ |
|
| 199 | 167 |
|
| 200 |
- Object decoratedTripSeine = JOptionPane.showInputDialog(mainUI,
|
|
| 201 |
- t("observe.action.choose.tripSeine.message"),
|
|
| 202 |
- t("observe.action.choose.tripSeine.title"),
|
|
| 203 |
- JOptionPane.QUESTION_MESSAGE,
|
|
| 204 |
- null,
|
|
| 205 |
- decoratedTripSeines,
|
|
| 206 |
- null);
|
|
| 207 |
- return Optional.ofNullable(decoratedTripSeine != null ? ((DecoratedNodeEntity) decoratedTripSeine).getId() : null);
|
|
| 168 |
+ public static DecoratedNodeEntity[] getActivitySeineParentCandidates(String parentId, NavigationTreeNodeSupport oldParentNode) {
|
|
| 169 |
+ NavigationTreeNodeSupport routesNode = oldParentNode.getParent();
|
|
| 170 |
+ int routeNb = routesNode.getChildCount();
|
|
| 171 |
+ |
|
| 172 |
+ ObserveClientApplicationContext applicationContext = ObserveClientApplicationContext.get();
|
|
| 173 |
+ DataReferenceDecorator<RouteReference> decorator = applicationContext.getDecoratorService().getDataReferenceDecorator(RouteReference.class);
|
|
| 174 |
+ |
|
| 175 |
+ DecoratedNodeEntity[] result = new DecoratedNodeEntity[routeNb - 1];
|
|
| 176 |
+ |
|
| 177 |
+ int j = 0;
|
|
| 178 |
+ for (int i = 0; i < routeNb; i++) {
|
|
| 179 |
+ RouteSeineNavigationTreeNode routeNode = (RouteSeineNavigationTreeNode) routesNode.getChildAt(i);
|
|
| 180 |
+ String routeId = routeNode.getId();
|
|
| 181 |
+ if (!parentId.equals(routeId)) {
|
|
| 182 |
+ result[j++] = DecoratedNodeEntity.newDecoratedNodeEntity(routeNode, decorator);
|
|
| 183 |
+ }
|
|
| 184 |
+ }
|
|
| 185 |
+ return result;
|
|
| 186 |
+ }
|
|
| 187 |
+ |
|
| 188 |
+ public static DecoratedNodeEntity[] getActivityLonglineParentCandidates(String parentId, NavigationTreeNodeSupport oldParentNode) {
|
|
| 189 |
+ NavigationTreeNodeSupport programNode = oldParentNode.getParent();
|
|
| 190 |
+ int tripLonglineNb = programNode.getChildCount();
|
|
| 191 |
+ |
|
| 192 |
+ ObserveClientApplicationContext applicationContext = ObserveClientApplicationContext.get();
|
|
| 193 |
+ DataReferenceDecorator<TripLonglineReference> decorator = applicationContext.getDataReferenceDecorator(TripLonglineReference.class, null);
|
|
| 194 |
+ |
|
| 195 |
+ DecoratedNodeEntity[] result = new DecoratedNodeEntity[tripLonglineNb - 1];
|
|
| 196 |
+ |
|
| 197 |
+ int j = 0;
|
|
| 198 |
+ for (int i = 0; i < tripLonglineNb; i++) {
|
|
| 199 |
+ TripLonglineNavigationTreeNode tripLonglineNode = (TripLonglineNavigationTreeNode) programNode.getChildAt(i);
|
|
| 200 |
+ String tripLonglineId = tripLonglineNode.getId();
|
|
| 201 |
+ if (!parentId.equals(tripLonglineId)) {
|
|
| 202 |
+ result[j++] = DecoratedNodeEntity.newDecoratedNodeEntity(tripLonglineNode, decorator);
|
|
| 203 |
+ }
|
|
| 204 |
+ }
|
|
| 205 |
+ return result;
|
|
| 208 | 206 |
}
|
| 207 |
+ |
|
| 209 | 208 |
}
|
| ... | ... | @@ -24,6 +24,7 @@ package fr.ird.observe.client.ds.editor.form.open.longline; |
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.ObserveClientApplicationContext;
|
| 26 | 26 |
import fr.ird.observe.client.ds.editor.form.FormUILayoutFocusTraversalPolicy;
|
| 27 |
+import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 27 | 28 |
import fr.ird.observe.client.ds.editor.form.ObserveFormHelper;
|
| 28 | 29 |
import fr.ird.observe.client.ds.editor.form.open.OpenDataFormUI;
|
| 29 | 30 |
import fr.ird.observe.client.ds.editor.form.open.OpenDataFormUILayoutFocusTraversalPolicy;
|
| ... | ... | @@ -31,15 +32,12 @@ import fr.ird.observe.client.ds.editor.form.open.OpenDataFormUIModel; |
| 31 | 32 |
import fr.ird.observe.client.ds.editor.form.spi.FormUIValidationMessageManager;
|
| 32 | 33 |
import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
| 33 | 34 |
import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
| 34 |
-import fr.ird.observe.client.ds.editor.tree.navigation.nodes.longline.TripLonglineNavigationTreeNode;
|
|
| 35 | 35 |
import fr.ird.observe.client.util.DecoratedNodeEntity;
|
| 36 | 36 |
import fr.ird.observe.dto.data.longline.ActivityLonglineObsDto;
|
| 37 | 37 |
import fr.ird.observe.dto.data.longline.ActivityLonglineObsHelper;
|
| 38 | 38 |
import fr.ird.observe.dto.data.longline.ActivityLonglineObsReference;
|
| 39 | 39 |
import fr.ird.observe.dto.data.longline.TripLonglineDto;
|
| 40 |
-import fr.ird.observe.dto.data.longline.TripLonglineReference;
|
|
| 41 | 40 |
import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
|
| 42 |
-import fr.ird.observe.dto.decoration.decorators.DataReferenceDecorator;
|
|
| 43 | 41 |
import fr.ird.observe.dto.reference.DataDtoReference;
|
| 44 | 42 |
import fr.ird.observe.dto.referential.longline.VesselActivityLonglineHelper;
|
| 45 | 43 |
import fr.ird.observe.dto.referential.longline.VesselActivityLonglineReference;
|
| ... | ... | @@ -181,26 +179,7 @@ public class ActivityLonglineObsUIModel extends OpenDataFormUIModel<ActivityLong |
| 181 | 179 |
|
| 182 | 180 |
@Override
|
| 183 | 181 |
public DecoratedNodeEntity[] getParentCandidates(OpenDataFormUI<ActivityLonglineObsDto, ActivityLonglineObsReference> ui) {
|
| 184 |
- NavigationTreeNodeSupport oldParentNode = getOldParentNode(ui);
|
|
| 185 |
- NavigationTreeNodeSupport programNode = oldParentNode.getParent();
|
|
| 186 |
- String oldTripLonglineId = oldParentNode.getId();
|
|
| 187 |
- int tripLonglineNb = programNode.getChildCount();
|
|
| 188 |
- |
|
| 189 |
- ObserveClientApplicationContext applicationContext = ObserveClientApplicationContext.get();
|
|
| 190 |
- DataReferenceDecorator<TripLonglineReference> decorator = applicationContext.getDataReferenceDecorator(TripLonglineReference.class, null);
|
|
| 191 |
- |
|
| 192 |
- //on crée un tableau avec une marée en moins car on ne propose pas la marée actuelle
|
|
| 193 |
- DecoratedNodeEntity[] decoratedTripLonglines = new DecoratedNodeEntity[tripLonglineNb - 1];
|
|
| 194 |
- |
|
| 195 |
- int j = 0;
|
|
| 196 |
- for (int i = 0; i < tripLonglineNb; i++) {
|
|
| 197 |
- TripLonglineNavigationTreeNode tripLonglineNode = (TripLonglineNavigationTreeNode) programNode.getChildAt(i);
|
|
| 198 |
- String tripLonglineId = tripLonglineNode.getId();
|
|
| 199 |
- if (!oldTripLonglineId.equals(tripLonglineId)) {
|
|
| 200 |
- decoratedTripLonglines[j++] = DecoratedNodeEntity.newDecoratedNodeEntity(tripLonglineNode, decorator);
|
|
| 201 |
- }
|
|
| 202 |
- }
|
|
| 203 |
- return decoratedTripLonglines;
|
|
| 182 |
+ return MoveDataHelper.getActivityLonglineParentCandidates(getParentId(), getOldParentNode(ui));
|
|
| 204 | 183 |
}
|
| 205 | 184 |
|
| 206 | 185 |
@Override
|
| ... | ... | @@ -27,6 +27,7 @@ import com.google.common.collect.ImmutableSet; |
| 27 | 27 |
import fr.ird.observe.client.ObserveClientApplicationContext;
|
| 28 | 28 |
import fr.ird.observe.client.configuration.ClientConfig;
|
| 29 | 29 |
import fr.ird.observe.client.ds.editor.form.FormUILayoutFocusTraversalPolicy;
|
| 30 |
+import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 30 | 31 |
import fr.ird.observe.client.ds.editor.form.ObserveFormHelper;
|
| 31 | 32 |
import fr.ird.observe.client.ds.editor.form.open.OpenDataFormUI;
|
| 32 | 33 |
import fr.ird.observe.client.ds.editor.form.open.OpenDataFormUILayoutFocusTraversalPolicy;
|
| ... | ... | @@ -35,24 +36,19 @@ import fr.ird.observe.client.ds.editor.form.spi.FormUIValidationMessageManager; |
| 35 | 36 |
import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
| 36 | 37 |
import fr.ird.observe.client.ds.editor.tree.navigation.ObserveNavigationTree;
|
| 37 | 38 |
import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
| 38 |
-import fr.ird.observe.client.ds.editor.tree.navigation.nodes.longline.TripLonglineListNavigationTreeNode;
|
|
| 39 | 39 |
import fr.ird.observe.client.util.DecoratedNodeEntity;
|
| 40 |
-import fr.ird.observe.dto.IdHelper;
|
|
| 41 | 40 |
import fr.ird.observe.dto.data.longline.TripLonglineDto;
|
| 42 | 41 |
import fr.ird.observe.dto.data.longline.TripLonglineReference;
|
| 43 |
-import fr.ird.observe.dto.decoration.decorators.ReferentialReferenceDecorator;
|
|
| 44 | 42 |
import fr.ird.observe.dto.reference.DtoReferenceCollection;
|
| 45 | 43 |
import fr.ird.observe.dto.reference.ReferentialReferencesFilter;
|
| 46 | 44 |
import fr.ird.observe.dto.referential.PersonHelper;
|
| 47 | 45 |
import fr.ird.observe.dto.referential.PersonReference;
|
| 48 |
-import fr.ird.observe.dto.referential.ProgramReference;
|
|
| 49 | 46 |
import fr.ird.observe.dto.referential.VesselHelper;
|
| 50 | 47 |
import fr.ird.observe.dto.referential.VesselReference;
|
| 51 | 48 |
import fr.ird.observe.services.service.data.longline.TripLonglineService;
|
| 52 | 49 |
|
| 53 | 50 |
import java.awt.Component;
|
| 54 | 51 |
import java.awt.Container;
|
| 55 |
-import java.util.ArrayList;
|
|
| 56 | 52 |
import java.util.List;
|
| 57 | 53 |
import java.util.Set;
|
| 58 | 54 |
|
| ... | ... | @@ -181,36 +177,9 @@ public class TripLonglineUIModel extends OpenDataFormUIModel<TripLonglineDto, Tr |
| 181 | 177 |
|
| 182 | 178 |
@Override
|
| 183 | 179 |
public DecoratedNodeEntity[] getParentCandidates(OpenDataFormUI<TripLonglineDto, TripLonglineReference> ui) {
|
| 184 |
- |
|
| 185 |
- NavigationTree treeHelper = ui.getDataSourceUI().getTree();
|
|
| 186 |
- |
|
| 187 |
- // racine
|
|
| 188 |
- NavigationTreeNodeSupport rootNode = treeHelper.getRootNode();
|
|
| 189 |
- |
|
| 190 |
- //on crée un tableau avec un programme en moins car on ne propose pas le programme actuel
|
|
| 191 |
- List<DecoratedNodeEntity> decoratedProgramList = new ArrayList<>();
|
|
| 192 |
- |
|
| 193 |
- ReferentialReferenceDecorator<ProgramReference> programDecorator = ui.getMainUI().getApplicationContext().getDecoratorService().getReferentialReferenceDecorator(ProgramReference.class);
|
|
| 194 |
- |
|
| 195 |
- String parentId = getParentId();
|
|
| 196 |
- for (int i = 0, n = rootNode.getChildCount(); i < n; i++) {
|
|
| 197 |
- |
|
| 198 |
- NavigationTreeNodeSupport programNode = (NavigationTreeNodeSupport) rootNode.getChildAt(i);
|
|
| 199 |
- String programId = programNode.getId();
|
|
| 200 |
- |
|
| 201 |
- // si le noeud programme n'est pas le même que le parent actuel
|
|
| 202 |
- // si le noeud est bien un noeud de programme
|
|
| 203 |
- if (programId != null && IdHelper.isProgramId(programId) && !parentId.equals(programId)) {
|
|
| 204 |
- if (programNode instanceof TripLonglineListNavigationTreeNode) {
|
|
| 205 |
- TripLonglineListNavigationTreeNode node = (TripLonglineListNavigationTreeNode) programNode;
|
|
| 206 |
- decoratedProgramList.add(DecoratedNodeEntity.newDecoratedNodeEntity(node, programDecorator));
|
|
| 207 |
- }
|
|
| 208 |
- }
|
|
| 209 |
- }
|
|
| 210 |
- return decoratedProgramList.toArray(new DecoratedNodeEntity[decoratedProgramList.size()]);
|
|
| 180 |
+ return MoveDataHelper.getTripLonglineParentCandidates(ui, getParentId());
|
|
| 211 | 181 |
}
|
| 212 | 182 |
|
| 213 |
- |
|
| 214 | 183 |
@Override
|
| 215 | 184 |
public String getMoveTitle() {
|
| 216 | 185 |
return t("observe.action.choose.program.title");
|
| ... | ... | @@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableSet; |
| 26 | 26 |
import fr.ird.observe.client.ClientApplicationContext;
|
| 27 | 27 |
import fr.ird.observe.client.ObserveClientApplicationContext;
|
| 28 | 28 |
import fr.ird.observe.client.ds.editor.form.FormUILayoutFocusTraversalPolicy;
|
| 29 |
+import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 29 | 30 |
import fr.ird.observe.client.ds.editor.form.ObserveFormHelper;
|
| 30 | 31 |
import fr.ird.observe.client.ds.editor.form.open.OpenDataFormUI;
|
| 31 | 32 |
import fr.ird.observe.client.ds.editor.form.open.OpenDataFormUILayoutFocusTraversalPolicy;
|
| ... | ... | @@ -33,15 +34,12 @@ import fr.ird.observe.client.ds.editor.form.open.OpenDataFormUIModel; |
| 33 | 34 |
import fr.ird.observe.client.ds.editor.form.spi.FormUIValidationMessageManager;
|
| 34 | 35 |
import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
| 35 | 36 |
import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
| 36 |
-import fr.ird.observe.client.ds.editor.tree.navigation.nodes.seine.RouteSeineNavigationTreeNode;
|
|
| 37 | 37 |
import fr.ird.observe.client.util.DecoratedNodeEntity;
|
| 38 | 38 |
import fr.ird.observe.dto.data.seine.ActivitySeineDto;
|
| 39 | 39 |
import fr.ird.observe.dto.data.seine.ActivitySeineReference;
|
| 40 | 40 |
import fr.ird.observe.dto.data.seine.RouteDto;
|
| 41 |
-import fr.ird.observe.dto.data.seine.RouteReference;
|
|
| 42 | 41 |
import fr.ird.observe.dto.data.seine.TripSeineDto;
|
| 43 | 42 |
import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
|
| 44 |
-import fr.ird.observe.dto.decoration.decorators.DataReferenceDecorator;
|
|
| 45 | 43 |
import fr.ird.observe.dto.reference.DataDtoReference;
|
| 46 | 44 |
import fr.ird.observe.dto.referential.seine.VesselActivitySeineHelper;
|
| 47 | 45 |
import fr.ird.observe.dto.referential.seine.VesselActivitySeineReference;
|
| ... | ... | @@ -246,25 +244,7 @@ public class ActivitySeineUIModel extends OpenDataFormUIModel<ActivitySeineDto, |
| 246 | 244 |
@Override
|
| 247 | 245 |
public DecoratedNodeEntity[] getParentCandidates(OpenDataFormUI<ActivitySeineDto, ActivitySeineReference> ui) {
|
| 248 | 246 |
NavigationTreeNodeSupport oldParentNode = getOldParentNode(ui);
|
| 249 |
- NavigationTreeNodeSupport routesNode = oldParentNode.getParent();
|
|
| 250 |
- String oldRouteId = oldParentNode.getId();
|
|
| 251 |
- int routeNb = routesNode.getChildCount();
|
|
| 252 |
- |
|
| 253 |
- ObserveClientApplicationContext applicationContext = ObserveClientApplicationContext.get();
|
|
| 254 |
- DataReferenceDecorator<RouteReference> decorator = applicationContext.getDecoratorService().getDataReferenceDecorator(RouteReference.class);
|
|
| 255 |
- |
|
| 256 |
- //on crée un tableau avec une route en moins car on ne propose pas la route actuel
|
|
| 257 |
- DecoratedNodeEntity[] decoratedRoutes = new DecoratedNodeEntity[routeNb - 1];
|
|
| 258 |
- |
|
| 259 |
- int j = 0;
|
|
| 260 |
- for (int i = 0; i < routeNb; i++) {
|
|
| 261 |
- RouteSeineNavigationTreeNode routeNode = (RouteSeineNavigationTreeNode) routesNode.getChildAt(i);
|
|
| 262 |
- String routeId = routeNode.getId();
|
|
| 263 |
- if (!oldRouteId.equals(routeId)) {
|
|
| 264 |
- decoratedRoutes[j++] = DecoratedNodeEntity.newDecoratedNodeEntity(routeNode, decorator);
|
|
| 265 |
- }
|
|
| 266 |
- }
|
|
| 267 |
- return decoratedRoutes;
|
|
| 247 |
+ return MoveDataHelper.getActivitySeineParentCandidates(getParentId(), oldParentNode);
|
|
| 268 | 248 |
}
|
| 269 | 249 |
|
| 270 | 250 |
|
| ... | ... | @@ -25,6 +25,7 @@ package fr.ird.observe.client.ds.editor.form.open.seine; |
| 25 | 25 |
import fr.ird.observe.client.ClientApplicationContext;
|
| 26 | 26 |
import fr.ird.observe.client.ds.editor.DataSourceUI;
|
| 27 | 27 |
import fr.ird.observe.client.ds.editor.form.FormUILayoutFocusTraversalPolicy;
|
| 28 |
+import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 28 | 29 |
import fr.ird.observe.client.ds.editor.form.ObserveFormHelper;
|
| 29 | 30 |
import fr.ird.observe.client.ds.editor.form.open.OpenDataFormUI;
|
| 30 | 31 |
import fr.ird.observe.client.ds.editor.form.open.OpenDataFormUILayoutFocusTraversalPolicy;
|
| ... | ... | @@ -33,15 +34,12 @@ import fr.ird.observe.client.ds.editor.form.spi.FormUIValidationMessageManager; |
| 33 | 34 |
import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
| 34 | 35 |
import fr.ird.observe.client.ds.editor.tree.navigation.ObserveNavigationTree;
|
| 35 | 36 |
import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
| 36 |
-import fr.ird.observe.client.ds.editor.tree.navigation.nodes.seine.TripSeineNavigationTreeNode;
|
|
| 37 | 37 |
import fr.ird.observe.client.util.DecoratedNodeEntity;
|
| 38 | 38 |
import fr.ird.observe.dto.data.seine.ActivitySeineDto;
|
| 39 | 39 |
import fr.ird.observe.dto.data.seine.RouteDto;
|
| 40 | 40 |
import fr.ird.observe.dto.data.seine.RouteReference;
|
| 41 | 41 |
import fr.ird.observe.dto.data.seine.TripSeineDto;
|
| 42 |
-import fr.ird.observe.dto.data.seine.TripSeineReference;
|
|
| 43 | 42 |
import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
|
| 44 |
-import fr.ird.observe.dto.decoration.decorators.DataReferenceDecorator;
|
|
| 45 | 43 |
import fr.ird.observe.dto.referential.seine.VesselActivitySeineHelper;
|
| 46 | 44 |
import fr.ird.observe.dto.referential.seine.VesselActivitySeineReference;
|
| 47 | 45 |
import fr.ird.observe.services.service.data.seine.RouteService;
|
| ... | ... | @@ -248,31 +246,7 @@ public class RouteUIModel extends OpenDataFormUIModel<RouteDto, RouteReference, |
| 248 | 246 |
|
| 249 | 247 |
@Override
|
| 250 | 248 |
public DecoratedNodeEntity[] getParentCandidates(OpenDataFormUI<RouteDto, RouteReference> ui) {
|
| 251 |
- |
|
| 252 |
- NavigationTreeNodeSupport oldTripSeineNode = getOldParentNode(ui);
|
|
| 253 |
- |
|
| 254 |
- NavigationTreeNodeSupport programNode = oldTripSeineNode.getParent();
|
|
| 255 |
- String oldTripSeineId = oldTripSeineNode.getId();
|
|
| 256 |
- int tripSeineNb = programNode.getChildCount();
|
|
| 257 |
- |
|
| 258 |
- ClientApplicationContext applicationContext = ClientApplicationContext.get();
|
|
| 259 |
- DataReferenceDecorator decorator = applicationContext.getDecoratorService().getDataReferenceDecorator(TripSeineReference.class);
|
|
| 260 |
- |
|
| 261 |
- //on crée un tableau avec une marée en moins car on ne propose pas la marée actuel
|
|
| 262 |
- DecoratedNodeEntity[] decoratedTripSeines = new DecoratedNodeEntity[tripSeineNb - 1];
|
|
| 263 |
- |
|
| 264 |
- int j = 0;
|
|
| 265 |
- for (int i = 0; i < tripSeineNb; i++) {
|
|
| 266 |
- |
|
| 267 |
- TripSeineNavigationTreeNode tripSeineNode = (TripSeineNavigationTreeNode) programNode.getChildAt(i);
|
|
| 268 |
- |
|
| 269 |
- String tripSeineId = tripSeineNode.getId();
|
|
| 270 |
- |
|
| 271 |
- if (!oldTripSeineId.equals(tripSeineId)) {
|
|
| 272 |
- decoratedTripSeines[j++] = DecoratedNodeEntity.newDecoratedNodeEntity(tripSeineNode, decorator);
|
|
| 273 |
- }
|
|
| 274 |
- }
|
|
| 275 |
- return decoratedTripSeines;
|
|
| 249 |
+ return MoveDataHelper.getRouteParentCandidates(getParentId(), getOldParentNode(ui));
|
|
| 276 | 250 |
}
|
| 277 | 251 |
|
| 278 | 252 |
|
| ... | ... | @@ -27,6 +27,7 @@ import com.google.common.collect.ImmutableSet; |
| 27 | 27 |
import fr.ird.observe.client.ObserveClientApplicationContext;
|
| 28 | 28 |
import fr.ird.observe.client.configuration.ClientConfig;
|
| 29 | 29 |
import fr.ird.observe.client.ds.editor.form.FormUILayoutFocusTraversalPolicy;
|
| 30 |
+import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 30 | 31 |
import fr.ird.observe.client.ds.editor.form.ObserveFormHelper;
|
| 31 | 32 |
import fr.ird.observe.client.ds.editor.form.open.OpenDataFormUI;
|
| 32 | 33 |
import fr.ird.observe.client.ds.editor.form.open.OpenDataFormUILayoutFocusTraversalPolicy;
|
| ... | ... | @@ -35,24 +36,19 @@ import fr.ird.observe.client.ds.editor.form.spi.FormUIValidationMessageManager; |
| 35 | 36 |
import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
| 36 | 37 |
import fr.ird.observe.client.ds.editor.tree.navigation.ObserveNavigationTree;
|
| 37 | 38 |
import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
| 38 |
-import fr.ird.observe.client.ds.editor.tree.navigation.nodes.seine.TripSeineListNavigationTreeNode;
|
|
| 39 | 39 |
import fr.ird.observe.client.util.DecoratedNodeEntity;
|
| 40 |
-import fr.ird.observe.dto.IdHelper;
|
|
| 41 | 40 |
import fr.ird.observe.dto.data.seine.TripSeineDto;
|
| 42 | 41 |
import fr.ird.observe.dto.data.seine.TripSeineReference;
|
| 43 |
-import fr.ird.observe.dto.decoration.decorators.ReferentialReferenceDecorator;
|
|
| 44 | 42 |
import fr.ird.observe.dto.reference.DtoReferenceCollection;
|
| 45 | 43 |
import fr.ird.observe.dto.reference.ReferentialReferencesFilter;
|
| 46 | 44 |
import fr.ird.observe.dto.referential.PersonHelper;
|
| 47 | 45 |
import fr.ird.observe.dto.referential.PersonReference;
|
| 48 |
-import fr.ird.observe.dto.referential.ProgramReference;
|
|
| 49 | 46 |
import fr.ird.observe.dto.referential.VesselHelper;
|
| 50 | 47 |
import fr.ird.observe.dto.referential.VesselReference;
|
| 51 | 48 |
import fr.ird.observe.services.service.data.seine.TripSeineService;
|
| 52 | 49 |
|
| 53 | 50 |
import java.awt.Component;
|
| 54 | 51 |
import java.awt.Container;
|
| 55 |
-import java.util.ArrayList;
|
|
| 56 | 52 |
import java.util.List;
|
| 57 | 53 |
import java.util.Set;
|
| 58 | 54 |
|
| ... | ... | @@ -188,33 +184,7 @@ public class TripSeineUIModel extends OpenDataFormUIModel<TripSeineDto, TripSein |
| 188 | 184 |
|
| 189 | 185 |
@Override
|
| 190 | 186 |
public DecoratedNodeEntity[] getParentCandidates(OpenDataFormUI<TripSeineDto, TripSeineReference> ui) {
|
| 191 |
- |
|
| 192 |
- NavigationTree treeHelper = ui.getDataSourceUI().getTree();
|
|
| 193 |
- |
|
| 194 |
- // racine
|
|
| 195 |
- NavigationTreeNodeSupport rootNode = treeHelper.getRootNode();
|
|
| 196 |
- |
|
| 197 |
- //on crée un tableau avec un programme en moins car on ne propose pas le programme actuel
|
|
| 198 |
- List<DecoratedNodeEntity> decoratedProgramList = new ArrayList<>();
|
|
| 199 |
- |
|
| 200 |
- ReferentialReferenceDecorator<ProgramReference> programDecorator = ui.getMainUI().getApplicationContext().getDecoratorService().getReferentialReferenceDecorator(ProgramReference.class);
|
|
| 201 |
- |
|
| 202 |
- String parentId = getParentId();
|
|
| 203 |
- for (int i = 0, n = rootNode.getChildCount(); i < n; i++) {
|
|
| 204 |
- |
|
| 205 |
- NavigationTreeNodeSupport programNode = (NavigationTreeNodeSupport) rootNode.getChildAt(i);
|
|
| 206 |
- String programId = programNode.getId();
|
|
| 207 |
- |
|
| 208 |
- // si le noeud programme n'est pas le même que le parent actuel
|
|
| 209 |
- // si le noeud est bien un noeud de programme
|
|
| 210 |
- if (programId != null && IdHelper.isProgramId(programId) && !parentId.equals(programId)) {
|
|
| 211 |
- if (programNode instanceof TripSeineListNavigationTreeNode) {
|
|
| 212 |
- TripSeineListNavigationTreeNode node = (TripSeineListNavigationTreeNode) programNode;
|
|
| 213 |
- decoratedProgramList.add(DecoratedNodeEntity.newDecoratedNodeEntity(node, programDecorator));
|
|
| 214 |
- }
|
|
| 215 |
- }
|
|
| 216 |
- }
|
|
| 217 |
- return decoratedProgramList.toArray(new DecoratedNodeEntity[decoratedProgramList.size()]);
|
|
| 187 |
+ return MoveDataHelper.getTripSeineParentCandidates(ui, getParentId());
|
|
| 218 | 188 |
}
|
| 219 | 189 |
|
| 220 | 190 |
@Override
|
| 1 |
-/*
|
|
| 2 |
- * #%L
|
|
| 3 |
- * ObServe :: Client
|
|
| 4 |
- * %%
|
|
| 5 |
- * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
|
|
| 6 |
- * %%
|
|
| 7 |
- * This program is free software: you can redistribute it and/or modify
|
|
| 8 |
- * it under the terms of the GNU General Public License as
|
|
| 9 |
- * published by the Free Software Foundation, either version 3 of the
|
|
| 10 |
- * License, or (at your option) any later version.
|
|
| 11 |
- *
|
|
| 12 |
- * This program is distributed in the hope that it will be useful,
|
|
| 13 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 |
- * GNU General Public License for more details.
|
|
| 16 |
- *
|
|
| 17 |
- * You should have received a copy of the GNU General Public
|
|
| 18 |
- * License along with this program. If not, see
|
|
| 19 |
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 |
- * #L%
|
|
| 21 |
- */
|
|
| 22 |
- |
| 1 |
-/*
|
|
| 2 |
- * #%L
|
|
| 3 |
- * ObServe :: Client
|
|
| 4 |
- * %%
|
|
| 5 |
- * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
|
|
| 6 |
- * %%
|
|
| 7 |
- * This program is free software: you can redistribute it and/or modify
|
|
| 8 |
- * it under the terms of the GNU General Public License as
|
|
| 9 |
- * published by the Free Software Foundation, either version 3 of the
|
|
| 10 |
- * License, or (at your option) any later version.
|
|
| 11 |
- *
|
|
| 12 |
- * This program is distributed in the hope that it will be useful,
|
|
| 13 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 |
- * GNU General Public License for more details.
|
|
| 16 |
- *
|
|
| 17 |
- * You should have received a copy of the GNU General Public
|
|
| 18 |
- * License along with this program. If not, see
|
|
| 19 |
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 |
- * #L%
|
|
| 21 |
- */
|
|
| 22 |
-package fr.ird.observe.client.ds.editor.form.openlist;
|
|
| 23 |
- |
|
| 24 |
-import fr.ird.observe.client.ObserveClientApplicationContext;
|
|
| 25 |
-import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 26 |
-import fr.ird.observe.client.ds.editor.form.openlist.actions.OpenDataListFormUIMoveMultipleDataActionSupport;
|
|
| 27 |
-import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
|
| 28 |
-import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 29 |
-import fr.ird.observe.dto.referential.GearType;
|
|
| 30 |
-import fr.ird.observe.dto.referential.ProgramDto;
|
|
| 31 |
-import fr.ird.observe.spi.application.ObserveApplicationDataContext;
|
|
| 32 |
-import org.apache.commons.logging.Log;
|
|
| 33 |
-import org.apache.commons.logging.LogFactory;
|
|
| 34 |
- |
|
| 35 |
-import java.util.Iterator;
|
|
| 36 |
-import java.util.List;
|
|
| 37 |
-import java.util.Optional;
|
|
| 38 |
-import java.util.Set;
|
|
| 39 |
- |
|
| 40 |
-import static org.nuiton.i18n.I18n.n;
|
|
| 41 |
- |
|
| 42 |
-/**
|
|
| 43 |
- * Action pour changer le programme d'une ou plusieurs marée dans la liste.
|
|
| 44 |
- *
|
|
| 45 |
- * @author Kevin Morin (Code Lutin)
|
|
| 46 |
- * @since 5.0
|
|
| 47 |
- */
|
|
| 48 |
-public abstract class OpenDataListFormUIMoveMultipleTripActionSupport extends OpenDataListFormUIMoveMultipleDataActionSupport {
|
|
| 49 |
- |
|
| 50 |
- private static final Log log = LogFactory.getLog(OpenDataListFormUIMoveMultipleTripActionSupport.class);
|
|
| 51 |
- |
|
| 52 |
- private final GearType gearType;
|
|
| 53 |
- |
|
| 54 |
- protected OpenDataListFormUIMoveMultipleTripActionSupport(GearType gearType) {
|
|
| 55 |
- super(n("observe.common.TripDto.action.moves"),
|
|
| 56 |
- n("observe.common.TripDto.action.moves.tip"),
|
|
| 57 |
- "move-trips");
|
|
| 58 |
- this.gearType = gearType;
|
|
| 59 |
- }
|
|
| 60 |
- |
|
| 61 |
- @Override
|
|
| 62 |
- public Optional<String> getNewParentId() {
|
|
| 63 |
- return MoveDataHelper.chooseNewProgram(getMainUI(), gearType, getOldParentNode().getId());
|
|
| 64 |
- }
|
|
| 65 |
- |
|
| 66 |
- @Override
|
|
| 67 |
- public void updateUI(String newParentId, Set<String> dataIds, List<Integer> positions) {
|
|
| 68 |
- |
|
| 69 |
- NavigationTreeNodeSupport oldParentNode = getOldParentNode();
|
|
| 70 |
- |
|
| 71 |
- ObserveClientApplicationContext applicationContext = ObserveClientApplicationContext.get();
|
|
| 72 |
- ObserveApplicationDataContext openDataManager = applicationContext.getApplicationDataContext();
|
|
| 73 |
- NavigationTree treeHelper = getDataSourceEditor().getTree();
|
|
| 74 |
- |
|
| 75 |
- NavigationTreeNodeSupport rootNode = treeHelper.getRootNode();
|
|
| 76 |
- NavigationTreeNodeSupport newProgramNode = treeHelper.getChild(rootNode, newParentId);
|
|
| 77 |
- |
|
| 78 |
- Iterator<String> iterator = dataIds.iterator();
|
|
| 79 |
- for (Integer position : positions) {
|
|
| 80 |
- |
|
| 81 |
- String tripId = iterator.next();
|
|
| 82 |
- NavigationTreeNodeSupport tripNode = treeHelper.getChild(oldParentNode, tripId);
|
|
| 83 |
- boolean wasOpen = tripNode.isOpen();
|
|
| 84 |
- treeHelper.removeNode(tripNode);
|
|
| 85 |
- |
|
| 86 |
- if (wasOpen) {
|
|
| 87 |
- openDataManager.close(ProgramDto.class);
|
|
| 88 |
- openDataManager.open(ProgramDto.class, newParentId);
|
|
| 89 |
- }
|
|
| 90 |
- |
|
| 91 |
- NavigationTreeNodeSupport newTripNode = treeHelper.getChild(newProgramNode, tripId);
|
|
| 92 |
- |
|
| 93 |
- if (newTripNode == null) {
|
|
| 94 |
- |
|
| 95 |
- // create it
|
|
| 96 |
- if (log.isInfoEnabled()) {
|
|
| 97 |
- log.info("Insert trip node: ");
|
|
| 98 |
- }
|
|
| 99 |
- treeHelper.insertNode(newProgramNode, tripNode, position);
|
|
| 100 |
- }
|
|
| 101 |
- }
|
|
| 102 |
- |
|
| 103 |
- treeHelper.reloadNode(oldParentNode, true);
|
|
| 104 |
- treeHelper.reloadNode(newProgramNode, true);
|
|
| 105 |
- treeHelper.selectNode(newProgramNode);
|
|
| 106 |
- }
|
|
| 107 |
- |
|
| 108 |
-}
|
| ... | ... | @@ -28,9 +28,7 @@ |
| 28 | 28 |
org.nuiton.jaxx.widgets.select.BeanListHeader
|
| 29 | 29 |
</import>
|
| 30 | 30 |
|
| 31 |
- <style source="../CommonOpenDataListFormUI.jcss"/>
|
|
| 32 |
- |
|
| 33 |
- <ActivityLonglineObsListUIModel id='model' title='observe.common.ActivityLonglineObsDto.types'/>
|
|
| 31 |
+ <ActivityLonglineObsListUIModel id='model'/>
|
|
| 34 | 32 |
<JLabel id="emptyLabel" text='observe.common.ActivityLonglineObsDto.message.nonForTrip'/>
|
| 35 | 33 |
<BeanListHeader id='listHeader' labelText='observe.common.ActivityDto.list'/>
|
| 36 | 34 |
|
| ... | ... | @@ -22,13 +22,26 @@ package fr.ird.observe.client.ds.editor.form.openlist.longline; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import com.google.common.collect.ImmutableSet;
|
|
| 26 |
+import fr.ird.observe.client.ObserveClientApplicationContext;
|
|
| 27 |
+import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 28 |
+import fr.ird.observe.client.ds.editor.form.openlist.OpenDataListFormUI;
|
|
| 25 | 29 |
import fr.ird.observe.client.ds.editor.form.openlist.OpenDataListFormUIModel;
|
| 26 | 30 |
import fr.ird.observe.client.ds.editor.form.spi.FormUIValidationMessageManager;
|
| 31 |
+import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
|
| 32 |
+import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 33 |
+import fr.ird.observe.client.util.DecoratedNodeEntity;
|
|
| 27 | 34 |
import fr.ird.observe.dto.data.longline.ActivityLonglineObsDto;
|
| 28 | 35 |
import fr.ird.observe.dto.data.longline.ActivityLonglineObsReference;
|
| 36 |
+import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
|
|
| 29 | 37 |
import fr.ird.observe.services.service.data.longline.ActivityLonglineObsService;
|
| 38 |
+import fr.ird.observe.spi.application.ObserveApplicationDataContext;
|
|
| 39 |
+ |
|
| 40 |
+import java.util.List;
|
|
| 41 |
+import java.util.Optional;
|
|
| 30 | 42 |
|
| 31 | 43 |
import static org.nuiton.i18n.I18n.n;
|
| 44 |
+import static org.nuiton.i18n.I18n.t;
|
|
| 32 | 45 |
|
| 33 | 46 |
/**
|
| 34 | 47 |
* Created on 9/26/14.
|
| ... | ... | @@ -38,6 +51,10 @@ import static org.nuiton.i18n.I18n.n; |
| 38 | 51 |
*/
|
| 39 | 52 |
public class ActivityLonglineObsListUIModel extends OpenDataListFormUIModel<ActivityLonglineObsDto, ActivityLonglineObsReference, ActivityLonglineObsService> {
|
| 40 | 53 |
|
| 54 |
+ public ActivityLonglineObsListUIModel() {
|
|
| 55 |
+ setTitle(t("observe.common.ActivityLonglineObsDto.types"));
|
|
| 56 |
+ }
|
|
| 57 |
+ |
|
| 41 | 58 |
@Override
|
| 42 | 59 |
public void computeReadMessages(FormUIValidationMessageManager validationManager) {
|
| 43 | 60 |
if (isAnotherParentOpen()) {
|
| ... | ... | @@ -61,4 +78,92 @@ public class ActivityLonglineObsListUIModel extends OpenDataListFormUIModel<Acti |
| 61 | 78 |
validationManager.addInfoMessage(n("observe.common.ActivityLonglineObsDto.message.active.found"));
|
| 62 | 79 |
}
|
| 63 | 80 |
|
| 81 |
+ @Override
|
|
| 82 |
+ public DecoratedNodeEntity[] getParentCandidates(OpenDataListFormUI<ActivityLonglineObsDto, ActivityLonglineObsReference> ui) {
|
|
| 83 |
+ return MoveDataHelper.getActivityLonglineParentCandidates(getParentId(), getOldParentNode(ui));
|
|
| 84 |
+ }
|
|
| 85 |
+ |
|
| 86 |
+ @Override
|
|
| 87 |
+ public String getMoveTitle() {
|
|
| 88 |
+ return t("observe.action.choose.tripLongline.title");
|
|
| 89 |
+ }
|
|
| 90 |
+ |
|
| 91 |
+ @Override
|
|
| 92 |
+ public String getMoveMessage() {
|
|
| 93 |
+ return t("observe.action.choose.tripLongline.message");
|
|
| 94 |
+ }
|
|
| 95 |
+ |
|
| 96 |
+ @Override
|
|
| 97 |
+ public void afterMoveData(ImmutableSet<String> dataIds, String newParentId, List<Integer> positions, OpenDataListFormUI<ActivityLonglineObsDto, ActivityLonglineObsReference> ui) {
|
|
| 98 |
+ super.afterMoveData(dataIds, newParentId, positions, ui);
|
|
| 99 |
+ |
|
| 100 |
+ NavigationTreeNodeSupport oldParentNode = getOldParentNode(ui);
|
|
| 101 |
+ |
|
| 102 |
+ ObserveClientApplicationContext applicationContext = ObserveClientApplicationContext.get();
|
|
| 103 |
+ ObserveApplicationDataContext openDataManager = applicationContext.getApplicationDataContext();
|
|
| 104 |
+ NavigationTree tree = ui.getDataSourceUI().getTree();
|
|
| 105 |
+ |
|
| 106 |
+ NavigationTreeNodeSupport oldTripLonglineNode = oldParentNode.getParent();
|
|
| 107 |
+ NavigationTreeNodeSupport programNode = oldTripLonglineNode.getParent();
|
|
| 108 |
+ NavigationTreeNodeSupport newTripLonglineNode = tree.getChild(programNode, newParentId);
|
|
| 109 |
+ String activitiesNodeId = ObserveI18nDecoratorHelper.getTypePluralI18nKey(ActivityLonglineObsDto.class);
|
|
| 110 |
+ NavigationTreeNodeSupport newActivitiesNode = tree.getChild(newTripLonglineNode, activitiesNodeId);
|
|
| 111 |
+ |
|
| 112 |
+ // Let's check if we're moving an open activity
|
|
| 113 |
+ String openId = openDataManager.getOpenId(ActivityLonglineObsDto.class);
|
|
| 114 |
+ Optional<String> openActivity = openId != null && dataIds.contains(openId) ? Optional.of(openId) : Optional.empty();
|
|
| 115 |
+ |
|
| 116 |
+ // If so, we closeData it to avoid ending up with an open activity into a closed trip.
|
|
| 117 |
+ if (openActivity.isPresent()) {
|
|
| 118 |
+ openDataManager.close(ActivityLonglineObsDto.class);
|
|
| 119 |
+ }
|
|
| 120 |
+ |
|
| 121 |
+ // Let's reload the sub tree of each activities node.
|
|
| 122 |
+ // As the change have already be oldParentNode in database, we just call the child loaders to regenerate the activities nodes sub trees
|
|
| 123 |
+ tree.reloadNodeSubTree(oldParentNode);
|
|
| 124 |
+ tree.reloadNodeSubTree(newActivitiesNode);
|
|
| 125 |
+ |
|
| 126 |
+ // Let's put the focus on the activities node which received the activities
|
|
| 127 |
+ tree.selectNode(newActivitiesNode);
|
|
| 128 |
+ }
|
|
| 129 |
+ |
|
| 130 |
+ /*
|
|
| 131 |
+ |
|
| 132 |
+ //FIXME!!! Voir si c'est vraiment nécessaire, je comprends pas pourquoi le comportement change des autres types
|
|
| 133 |
+ @Override
|
|
| 134 |
+ protected void doActionPerformed(ActionEvent e, OpenDataListFormUI ui) {
|
|
| 135 |
+ |
|
| 136 |
+ String openId = ObserveClientApplicationContext.applicationDataContext().getOpenActivityLonglineObsId();
|
|
| 137 |
+ |
|
| 138 |
+ NavigationTree tree = getDataSourceUI().getTree();
|
|
| 139 |
+ |
|
| 140 |
+ boolean wasCollapsed = ObserveFormHelper.isOpenActivityNodeCollapsed(tree, openId);
|
|
| 141 |
+ |
|
| 142 |
+ // selection du noeud de l'activity ouverte
|
|
| 143 |
+ NavigationTreeNodeSupport selectedNode = tree.getSelectedNode();
|
|
| 144 |
+ selectedNode = tree.getActivityLonglineNode(selectedNode, openId);
|
|
| 145 |
+ tree.selectNode(selectedNode);
|
|
| 146 |
+ |
|
| 147 |
+ // on conserve le path de l'activité
|
|
| 148 |
+ TreePath path = tree.getSelectionPath();
|
|
| 149 |
+ |
|
| 150 |
+ // recuperation de l'écran associé
|
|
| 151 |
+ ActivityLonglineObsUI selectedUI = (ActivityLonglineObsUI) getDataSourceUI().getSelectedContentUI();
|
|
| 152 |
+ |
|
| 153 |
+ if (openId != null) {
|
|
| 154 |
+ // fermeture de l'activité et création d'une nouvelle
|
|
| 155 |
+ selectedUI.getCloseData().doClick();
|
|
| 156 |
+ }
|
|
| 157 |
+ |
|
| 158 |
+ selectedUI.getCreate().doClick();
|
|
| 159 |
+ |
|
| 160 |
+ if (wasCollapsed) {
|
|
| 161 |
+ |
|
| 162 |
+ // on ferme le noeud de l'activité (qui a ete ouverte lors de la selection de celle-ci)
|
|
| 163 |
+ tree.collapsePath(path);
|
|
| 164 |
+ }
|
|
| 165 |
+ |
|
| 166 |
+ }
|
|
| 167 |
+ |
|
| 168 |
+ */
|
|
| 64 | 169 |
}
|
| ... | ... | @@ -28,9 +28,7 @@ |
| 28 | 28 |
org.nuiton.jaxx.widgets.select.BeanListHeader
|
| 29 | 29 |
</import>
|
| 30 | 30 |
|
| 31 |
- <style source="../CommonOpenDataListFormUI.jcss"/>
|
|
| 32 |
- |
|
| 33 |
- <TripLonglineListUIModel id='model' title='observe.common.TripLonglineDto.types'/>
|
|
| 31 |
+ <TripLonglineListUIModel id='model'/>
|
|
| 34 | 32 |
<JLabel id="emptyLabel" text='observe.common.TripDto.message.noneForTrip'/>
|
| 35 | 33 |
<BeanListHeader id='listHeader' labelText='observe.common.TripDto.list'/>
|
| 36 | 34 |
|
| ... | ... | @@ -22,16 +22,24 @@ package fr.ird.observe.client.ds.editor.form.openlist.longline; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import com.google.common.collect.ImmutableSet;
|
|
| 25 | 26 |
import fr.ird.observe.client.ClientApplicationContext;
|
| 27 |
+import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 28 |
+import fr.ird.observe.client.ds.editor.form.openlist.OpenDataListFormUI;
|
|
| 26 | 29 |
import fr.ird.observe.client.ds.editor.form.openlist.OpenDataListFormUIModel;
|
| 27 | 30 |
import fr.ird.observe.client.ds.editor.form.spi.FormUIValidationMessageManager;
|
| 31 |
+import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 32 |
+import fr.ird.observe.client.util.DecoratedNodeEntity;
|
|
| 28 | 33 |
import fr.ird.observe.dto.data.longline.TripLonglineDto;
|
| 29 | 34 |
import fr.ird.observe.dto.data.longline.TripLonglineReference;
|
| 30 | 35 |
import fr.ird.observe.dto.reference.DtoReference;
|
| 31 | 36 |
import fr.ird.observe.dto.referential.ProgramReference;
|
| 32 | 37 |
import fr.ird.observe.services.service.data.longline.TripLonglineService;
|
| 33 | 38 |
|
| 39 |
+import java.util.List;
|
|
| 40 |
+ |
|
| 34 | 41 |
import static org.nuiton.i18n.I18n.n;
|
| 42 |
+import static org.nuiton.i18n.I18n.t;
|
|
| 35 | 43 |
|
| 36 | 44 |
/**
|
| 37 | 45 |
* Created on 9/26/14.
|
| ... | ... | @@ -41,6 +49,10 @@ import static org.nuiton.i18n.I18n.n; |
| 41 | 49 |
*/
|
| 42 | 50 |
public class TripLonglineListUIModel extends OpenDataListFormUIModel<TripLonglineDto, TripLonglineReference, TripLonglineService> {
|
| 43 | 51 |
|
| 52 |
+ public TripLonglineListUIModel() {
|
|
| 53 |
+ setTitle(t("observe.common.TripLonglineDto.types"));
|
|
| 54 |
+ }
|
|
| 55 |
+ |
|
| 44 | 56 |
@Override
|
| 45 | 57 |
public void computeReadMessages(FormUIValidationMessageManager validationManager) {
|
| 46 | 58 |
validationManager.addInfoMessage(n("observe.common.TripLonglineDto.message.active.found.for.other.program"));
|
| ... | ... | @@ -63,4 +75,26 @@ public class TripLonglineListUIModel extends OpenDataListFormUIModel<TripLonglin |
| 63 | 75 |
setTitle(title);
|
| 64 | 76 |
super.openUI();
|
| 65 | 77 |
}
|
| 78 |
+ |
|
| 79 |
+ @Override
|
|
| 80 |
+ public String getMoveTitle() {
|
|
| 81 |
+ return t("observe.action.choose.program.title");
|
|
| 82 |
+ }
|
|
| 83 |
+ |
|
| 84 |
+ @Override
|
|
| 85 |
+ public String getMoveMessage() {
|
|
| 86 |
+ return t("observe.action.choose.program.message");
|
|
| 87 |
+ }
|
|
| 88 |
+ |
|
| 89 |
+ @Override
|
|
| 90 |
+ public DecoratedNodeEntity[] getParentCandidates(OpenDataListFormUI<TripLonglineDto, TripLonglineReference> ui) {
|
|
| 91 |
+ return MoveDataHelper.getTripLonglineParentCandidates(ui, getParentId());
|
|
| 92 |
+ }
|
|
| 93 |
+ |
|
| 94 |
+ @Override
|
|
| 95 |
+ public void afterMoveData(ImmutableSet<String> dataIds, String newParentId, List<Integer> positions, OpenDataListFormUI<TripLonglineDto, TripLonglineReference> ui) {
|
|
| 96 |
+ super.afterMoveData(dataIds, newParentId, positions, ui);
|
|
| 97 |
+ NavigationTreeNodeSupport oldParentNode = getOldParentNode(ui);
|
|
| 98 |
+ MoveDataHelper.moveTrips(ui.getDataSourceUI().getTree(), newParentId, dataIds, positions, oldParentNode);
|
|
| 99 |
+ }
|
|
| 66 | 100 |
}
|
| 1 |
-/*
|
|
| 2 |
- * #%L
|
|
| 3 |
- * ObServe :: Client
|
|
| 4 |
- * %%
|
|
| 5 |
- * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
|
|
| 6 |
- * %%
|
|
| 7 |
- * This program is free software: you can redistribute it and/or modify
|
|
| 8 |
- * it under the terms of the GNU General Public License as
|
|
| 9 |
- * published by the Free Software Foundation, either version 3 of the
|
|
| 10 |
- * License, or (at your option) any later version.
|
|
| 11 |
- *
|
|
| 12 |
- * This program is distributed in the hope that it will be useful,
|
|
| 13 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 |
- * GNU General Public License for more details.
|
|
| 16 |
- *
|
|
| 17 |
- * You should have received a copy of the GNU General Public
|
|
| 18 |
- * License along with this program. If not, see
|
|
| 19 |
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 |
- * #L%
|
|
| 21 |
- */
|
|
| 22 |
-package fr.ird.observe.client.ds.editor.form.openlist.longline.actions;
|
|
| 23 |
- |
|
| 24 |
-import fr.ird.observe.client.ObserveClientApplicationContext;
|
|
| 25 |
-import fr.ird.observe.client.ds.editor.form.ObserveFormHelper;
|
|
| 26 |
-import fr.ird.observe.client.ds.editor.form.open.longline.ActivityLonglineObsUI;
|
|
| 27 |
-import fr.ird.observe.client.ds.editor.form.openlist.OpenDataListFormUI;
|
|
| 28 |
-import fr.ird.observe.client.ds.editor.form.openlist.actions.OpenDataListFormUICreateData;
|
|
| 29 |
-import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
|
| 30 |
-import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 31 |
- |
|
| 32 |
-import javax.swing.tree.TreePath;
|
|
| 33 |
-import java.awt.event.ActionEvent;
|
|
| 34 |
- |
|
| 35 |
-/**
|
|
| 36 |
- * FIXME!!! N'est plus utilisé mais on garde pour voir si ce n'est pas encore nécessaire
|
|
| 37 |
- * Action pour fermer l'objet sous-jacent à l'écran et en créer un nouveau.
|
|
| 38 |
- *
|
|
| 39 |
- * @author Tony Chemit - dev@tchemit.fr
|
|
| 40 |
- * @since 1.5
|
|
| 41 |
- */
|
|
| 42 |
-public class OpenDataListFormUICreateActivityLonglineObs extends OpenDataListFormUICreateData {
|
|
| 43 |
- |
|
| 44 |
- public OpenDataListFormUICreateActivityLonglineObs() {
|
|
| 45 |
-// super(n("observe.common.ActivityDto.action.closeAndCreate"),
|
|
| 46 |
-// n("observe.common.ActivityDto.action.closeAndCreate.tip"));
|
|
| 47 |
- }
|
|
| 48 |
- |
|
| 49 |
- @Override
|
|
| 50 |
- protected void doActionPerformed(ActionEvent e, OpenDataListFormUI ui) {
|
|
| 51 |
- |
|
| 52 |
- //FIXME!!! Voir si c'est vraiment nécessaire, je comprends pas pourquoi le comportement change des autres types
|
|
| 53 |
- String openId = ObserveClientApplicationContext.applicationDataContext().getOpenActivityLonglineObsId();
|
|
| 54 |
- |
|
| 55 |
- NavigationTree tree = getDataSourceEditor().getTree();
|
|
| 56 |
- |
|
| 57 |
- boolean wasCollapsed = ObserveFormHelper.isOpenActivityNodeCollapsed(tree, openId);
|
|
| 58 |
- |
|
| 59 |
- // selection du noeud de l'activity ouverte
|
|
| 60 |
- NavigationTreeNodeSupport selectedNode = tree.getSelectedNode();
|
|
| 61 |
- selectedNode = tree.getActivityLonglineNode(selectedNode, openId);
|
|
| 62 |
- tree.selectNode(selectedNode);
|
|
| 63 |
- |
|
| 64 |
- // on conserve le path de l'activité
|
|
| 65 |
- TreePath path = tree.getSelectionPath();
|
|
| 66 |
- |
|
| 67 |
- // recuperation de l'écran associé
|
|
| 68 |
- ActivityLonglineObsUI selectedUI = (ActivityLonglineObsUI) getDataSourceEditor().getSelectedContentUI();
|
|
| 69 |
- |
|
| 70 |
- if (openId != null) {
|
|
| 71 |
- // fermeture de l'activité et création d'une nouvelle
|
|
| 72 |
- selectedUI.getCloseData().doClick();
|
|
| 73 |
- }
|
|
| 74 |
- |
|
| 75 |
- selectedUI.getCreate().doClick();
|
|
| 76 |
- |
|
| 77 |
- if (wasCollapsed) {
|
|
| 78 |
- |
|
| 79 |
- // on ferme le noeud de l'activité (qui a ete ouverte lors de la selection de celle-ci)
|
|
| 80 |
- tree.collapsePath(path);
|
|
| 81 |
- }
|
|
| 82 |
- |
|
| 83 |
- }
|
|
| 84 |
- |
|
| 85 |
-}
|
| 1 |
-/*
|
|
| 2 |
- * #%L
|
|
| 3 |
- * ObServe :: Client
|
|
| 4 |
- * %%
|
|
| 5 |
- * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
|
|
| 6 |
- * %%
|
|
| 7 |
- * This program is free software: you can redistribute it and/or modify
|
|
| 8 |
- * it under the terms of the GNU General Public License as
|
|
| 9 |
- * published by the Free Software Foundation, either version 3 of the
|
|
| 10 |
- * License, or (at your option) any later version.
|
|
| 11 |
- *
|
|
| 12 |
- * This program is distributed in the hope that it will be useful,
|
|
| 13 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 |
- * GNU General Public License for more details.
|
|
| 16 |
- *
|
|
| 17 |
- * You should have received a copy of the GNU General Public
|
|
| 18 |
- * License along with this program. If not, see
|
|
| 19 |
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 |
- * #L%
|
|
| 21 |
- */
|
|
| 22 |
-package fr.ird.observe.client.ds.editor.form.openlist.longline.actions;
|
|
| 23 |
- |
|
| 24 |
-import fr.ird.observe.client.ObserveClientApplicationContext;
|
|
| 25 |
-import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 26 |
-import fr.ird.observe.client.ds.editor.form.openlist.actions.OpenDataListFormUIMoveMultipleDataActionSupport;
|
|
| 27 |
-import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
|
| 28 |
-import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 29 |
-import fr.ird.observe.dto.data.longline.ActivityLonglineObsDto;
|
|
| 30 |
-import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
|
|
| 31 |
-import fr.ird.observe.spi.application.ObserveApplicationDataContext;
|
|
| 32 |
- |
|
| 33 |
-import java.util.List;
|
|
| 34 |
-import java.util.Optional;
|
|
| 35 |
-import java.util.Set;
|
|
| 36 |
- |
|
| 37 |
-import static org.nuiton.i18n.I18n.n;
|
|
| 38 |
- |
|
| 39 |
-/**
|
|
| 40 |
- * Action pour changer le programme d'une ou plusieurs marée dans la liste.
|
|
| 41 |
- *
|
|
| 42 |
- * @author Kevin Morin (Code Lutin)
|
|
| 43 |
- * @since 5.0
|
|
| 44 |
- */
|
|
| 45 |
-public class OpenDataListFormUIMoveMultipleActivityLonglineObs extends OpenDataListFormUIMoveMultipleDataActionSupport {
|
|
| 46 |
- |
|
| 47 |
- public OpenDataListFormUIMoveMultipleActivityLonglineObs() {
|
|
| 48 |
- super(n("observe.common.ActivityLonglineObsDto.action.moves"),
|
|
| 49 |
- n("observe.common.ActivityLonglineObsDto.action.moves.tip"),
|
|
| 50 |
- "move-activities");
|
|
| 51 |
- }
|
|
| 52 |
- |
|
| 53 |
- @Override
|
|
| 54 |
- public Optional<String> getNewParentId() {
|
|
| 55 |
- return MoveDataHelper.chooseNewTripLongline(getMainUI(), getOldParentNode());
|
|
| 56 |
- }
|
|
| 57 |
- |
|
| 58 |
- @Override
|
|
| 59 |
- public void updateUI(String tripLonglineId, Set<String> dataIds, List<Integer> positions) {
|
|
| 60 |
- |
|
| 61 |
- NavigationTreeNodeSupport oldParentNode = getOldParentNode();
|
|
| 62 |
- |
|
| 63 |
- ObserveClientApplicationContext applicationContext = ObserveClientApplicationContext.get();
|
|
| 64 |
- ObserveApplicationDataContext openDataManager = applicationContext.getApplicationDataContext();
|
|
| 65 |
- NavigationTree treeHelper = getDataSourceEditor().getTree();
|
|
| 66 |
- |
|
| 67 |
- NavigationTreeNodeSupport oldTripLonglineNode = oldParentNode.getParent();
|
|
| 68 |
- NavigationTreeNodeSupport programNode = oldTripLonglineNode.getParent();
|
|
| 69 |
- NavigationTreeNodeSupport newTripLonglineNode = treeHelper.getChild(programNode, tripLonglineId);
|
|
| 70 |
- String activitiesNodeId = ObserveI18nDecoratorHelper.getTypePluralI18nKey(ActivityLonglineObsDto.class);
|
|
| 71 |
- NavigationTreeNodeSupport newActivitiesNode = treeHelper.getChild(newTripLonglineNode, activitiesNodeId);
|
|
| 72 |
- |
|
| 73 |
- // Let's check if we're moving an open activity
|
|
| 74 |
- String openId = openDataManager.getOpenId(ActivityLonglineObsDto.class);
|
|
| 75 |
- Optional<String> openActivity = openId != null && dataIds.contains(openId) ? Optional.of(openId) : Optional.empty();
|
|
| 76 |
- |
|
| 77 |
- // If so, we closeData it to avoid ending up with an open activity into a closed trip.
|
|
| 78 |
- if (openActivity.isPresent()) {
|
|
| 79 |
- openDataManager.close(ActivityLonglineObsDto.class);
|
|
| 80 |
- }
|
|
| 81 |
- |
|
| 82 |
- // Let's reload the sub tree of each activities node.
|
|
| 83 |
- // As the change have already be oldParentNode in database, we just call the child loaders to regenerate the activities nodes sub trees
|
|
| 84 |
- treeHelper.reloadNodeSubTree(oldParentNode);
|
|
| 85 |
- treeHelper.reloadNodeSubTree(newActivitiesNode);
|
|
| 86 |
- |
|
| 87 |
- // Let's put the focus on the activities node which received the activities
|
|
| 88 |
- treeHelper.selectNode(newActivitiesNode);
|
|
| 89 |
- }
|
|
| 90 |
- |
|
| 91 |
-}
|
| 1 |
-package fr.ird.observe.client.ds.editor.form.openlist.longline.actions;
|
|
| 2 |
- |
|
| 3 |
-/*-
|
|
| 4 |
- * #%L
|
|
| 5 |
- * ObServe :: Client
|
|
| 6 |
- * %%
|
|
| 7 |
- * Copyright (C) 2008 - 2017 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.ds.editor.form.openlist.OpenDataListFormUIMoveMultipleTripActionSupport;
|
|
| 26 |
-import fr.ird.observe.dto.referential.GearType;
|
|
| 27 |
- |
|
| 28 |
-/**
|
|
| 29 |
- * @author Kevin Morin (Code Lutin)
|
|
| 30 |
- * @since 5.0
|
|
| 31 |
- */
|
|
| 32 |
-public class OpenDataListFormUIMoveMultipleTripLongline extends OpenDataListFormUIMoveMultipleTripActionSupport {
|
|
| 33 |
- |
|
| 34 |
- public OpenDataListFormUIMoveMultipleTripLongline() {
|
|
| 35 |
- super(GearType.longline);
|
|
| 36 |
- }
|
|
| 37 |
-}
|
| ... | ... | @@ -28,9 +28,7 @@ |
| 28 | 28 |
org.nuiton.jaxx.widgets.select.BeanListHeader
|
| 29 | 29 |
</import>
|
| 30 | 30 |
|
| 31 |
- <style source="../CommonOpenDataListFormUI.jcss"/>
|
|
| 32 |
- |
|
| 33 |
- <ActivitySeineListUIModel id='model' title='observe.common.ActivitySeineDto.types'/>
|
|
| 31 |
+ <ActivitySeineListUIModel id='model'/>
|
|
| 34 | 32 |
<JLabel id="emptyLabel" text='observe.common.ActivitySeineDto.message.noneForRoute'/>
|
| 35 | 33 |
<BeanListHeader id='listHeader' labelText='observe.common.ActivityDto.list'/>
|
| 36 | 34 |
<JButton id='showSelectedData'/>
|
| ... | ... | @@ -22,14 +22,26 @@ package fr.ird.observe.client.ds.editor.form.openlist.seine; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import com.google.common.collect.ImmutableSet;
|
|
| 25 | 26 |
import fr.ird.observe.client.ObserveClientApplicationContext;
|
| 27 |
+import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 28 |
+import fr.ird.observe.client.ds.editor.form.openlist.OpenDataListFormUI;
|
|
| 26 | 29 |
import fr.ird.observe.client.ds.editor.form.openlist.OpenDataListFormUIModel;
|
| 27 | 30 |
import fr.ird.observe.client.ds.editor.form.spi.FormUIValidationMessageManager;
|
| 31 |
+import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
|
| 32 |
+import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 33 |
+import fr.ird.observe.client.util.DecoratedNodeEntity;
|
|
| 28 | 34 |
import fr.ird.observe.dto.data.seine.ActivitySeineDto;
|
| 29 | 35 |
import fr.ird.observe.dto.data.seine.ActivitySeineReference;
|
| 36 |
+import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
|
|
| 30 | 37 |
import fr.ird.observe.services.service.data.seine.ActivitySeineService;
|
| 38 |
+import fr.ird.observe.spi.application.ObserveApplicationDataContext;
|
|
| 39 |
+ |
|
| 40 |
+import java.util.List;
|
|
| 41 |
+import java.util.Optional;
|
|
| 31 | 42 |
|
| 32 | 43 |
import static org.nuiton.i18n.I18n.n;
|
| 44 |
+import static org.nuiton.i18n.I18n.t;
|
|
| 33 | 45 |
|
| 34 | 46 |
/**
|
| 35 | 47 |
* Created on 9/26/14.
|
| ... | ... | @@ -39,6 +51,10 @@ import static org.nuiton.i18n.I18n.n; |
| 39 | 51 |
*/
|
| 40 | 52 |
public class ActivitySeineListUIModel extends OpenDataListFormUIModel<ActivitySeineDto, ActivitySeineReference, ActivitySeineService> {
|
| 41 | 53 |
|
| 54 |
+ public ActivitySeineListUIModel() {
|
|
| 55 |
+ setTitle(t("observe.common.ActivitySeineDto.types"));
|
|
| 56 |
+ }
|
|
| 57 |
+ |
|
| 42 | 58 |
@Override
|
| 43 | 59 |
public void computeReadMessages(FormUIValidationMessageManager validationManager) {
|
| 44 | 60 |
if (!ObserveClientApplicationContext.applicationDataContext().isOpenRoute()) {
|
| ... | ... | @@ -62,4 +78,95 @@ public class ActivitySeineListUIModel extends OpenDataListFormUIModel<ActivitySe |
| 62 | 78 |
validationManager.addInfoMessage(n("observe.common.ActivitySeineDto.message.active.found"));
|
| 63 | 79 |
}
|
| 64 | 80 |
|
| 81 |
+ |
|
| 82 |
+ @Override
|
|
| 83 |
+ public String getMoveTitle() {
|
|
| 84 |
+ return t("observe.action.choose.route.title");
|
|
| 85 |
+ }
|
|
| 86 |
+ |
|
| 87 |
+ @Override
|
|
| 88 |
+ public String getMoveMessage() {
|
|
| 89 |
+ return t("observe.action.choose.route.message");
|
|
| 90 |
+ }
|
|
| 91 |
+ |
|
| 92 |
+ @Override
|
|
| 93 |
+ public DecoratedNodeEntity[] getParentCandidates(OpenDataListFormUI<ActivitySeineDto, ActivitySeineReference> ui) {
|
|
| 94 |
+ return MoveDataHelper.getActivitySeineParentCandidates(getParentId(), getOldParentNode(ui));
|
|
| 95 |
+ }
|
|
| 96 |
+ |
|
| 97 |
+ @Override
|
|
| 98 |
+ public void afterMoveData(ImmutableSet<String> dataIds, String newParentId, List<Integer> positions, OpenDataListFormUI<ActivitySeineDto, ActivitySeineReference> ui) {
|
|
| 99 |
+ super.afterMoveData(dataIds, newParentId, positions, ui);
|
|
| 100 |
+ |
|
| 101 |
+ NavigationTreeNodeSupport oldParentNode = getOldParentNode(ui);
|
|
| 102 |
+ |
|
| 103 |
+ ObserveApplicationDataContext openDataManager = ObserveClientApplicationContext.applicationDataContext();
|
|
| 104 |
+ NavigationTree treeHelper = ui.getDataSourceUI().getTree();
|
|
| 105 |
+ |
|
| 106 |
+ NavigationTreeNodeSupport oldRouteNode = oldParentNode.getParent();
|
|
| 107 |
+ NavigationTreeNodeSupport routesNode = oldRouteNode.getParent();
|
|
| 108 |
+ NavigationTreeNodeSupport newRouteNode = treeHelper.getChild(routesNode, newParentId);
|
|
| 109 |
+ String activitiesNodeId = ObserveI18nDecoratorHelper.getTypePluralI18nKey(ActivitySeineDto.class);
|
|
| 110 |
+ NavigationTreeNodeSupport newActivitiesNode = treeHelper.getChild(newRouteNode, activitiesNodeId);
|
|
| 111 |
+ |
|
| 112 |
+ // Let's check if we're moving an open activity
|
|
| 113 |
+ String openId = openDataManager.getOpenActivityLonglineObsId();
|
|
| 114 |
+ Optional<String> openActivity = openId != null && dataIds.contains(openId) ? Optional.of(openId) : Optional.empty();
|
|
| 115 |
+ |
|
| 116 |
+ // If so, we closeData it to avoid ending up with an open activity into a closed route.
|
|
| 117 |
+ if (openActivity.isPresent()) {
|
|
| 118 |
+ openDataManager.close(ActivitySeineDto.class);
|
|
| 119 |
+ }
|
|
| 120 |
+ |
|
| 121 |
+ // Let's reload the sub tree of each activities node.
|
|
| 122 |
+ // As the change have already be done in database, we just call the child loaders to regenerate the activities nodes sub trees
|
|
| 123 |
+ treeHelper.reloadNodeSubTree(oldParentNode);
|
|
| 124 |
+ treeHelper.reloadNodeSubTree(newActivitiesNode);
|
|
| 125 |
+ |
|
| 126 |
+ // Let's put the focus on the activities node which received the activities
|
|
| 127 |
+ treeHelper.selectNode(newActivitiesNode);
|
|
| 128 |
+ }
|
|
| 129 |
+ |
|
| 130 |
+ /*
|
|
| 131 |
+ //FIXME!!! Voir si c'est vraiment nécessaire, je comprends pas pourquoi le comportement change des autres types
|
|
| 132 |
+ @Override
|
|
| 133 |
+ protected void doActionPerformed(ActionEvent e, OpenDataListFormUI ui) {
|
|
| 134 |
+ |
|
| 135 |
+ String openId = ObserveClientApplicationContext.applicationDataContext().getOpenActivitySeineId();
|
|
| 136 |
+ |
|
| 137 |
+ NavigationTree tree = getDataSourceUI().getTree();
|
|
| 138 |
+ |
|
| 139 |
+ boolean wasCollapsed = ObserveFormHelper.isOpenActivityNodeCollapsed(tree, openId);
|
|
| 140 |
+ |
|
| 141 |
+ //FIXME!!! Voir si ça fonctionne bien
|
|
| 142 |
+ // selection du noeud de l'activité ouverte
|
|
| 143 |
+ ui.getActionMap().get(MainUIMenuNavigationGoToOpenActivity.class).actionPerformed(null);
|
|
| 144 |
+ |
|
| 145 |
+ NavigationTreeNodeSupport selectedNode = tree.getSelectedNode();
|
|
| 146 |
+ selectedNode = tree.getActivitySeineNode(selectedNode, openId);
|
|
| 147 |
+ |
|
| 148 |
+ tree.selectNode(selectedNode);
|
|
| 149 |
+ |
|
| 150 |
+ // on conserve le path de l'activité
|
|
| 151 |
+ TreePath path = tree.getSelectionPath();
|
|
| 152 |
+ |
|
| 153 |
+ // recuperation de l'écran associé
|
|
| 154 |
+ ActivitySeineUI selectedUI = (ActivitySeineUI) getDataSourceUI().getSelectedContentUI();
|
|
| 155 |
+ |
|
| 156 |
+ if (openId != null) {
|
|
| 157 |
+ // fermeture de l'activité et création d'une nouvelle
|
|
| 158 |
+ selectedUI.getCloseData().doClick();
|
|
| 159 |
+ }
|
|
| 160 |
+ |
|
| 161 |
+ selectedUI.getCreate().doClick();
|
|
| 162 |
+ |
|
| 163 |
+ if (wasCollapsed) {
|
|
| 164 |
+ |
|
| 165 |
+ // on ferme le noeud de l'activity (qui a ete ouvert
|
|
| 166 |
+ // lors de la selection de celle-ci)
|
|
| 167 |
+ tree.collapsePath(path);
|
|
| 168 |
+ }
|
|
| 169 |
+ |
|
| 170 |
+ }
|
|
| 171 |
+ */
|
|
| 65 | 172 |
}
|
| ... | ... | @@ -28,9 +28,7 @@ |
| 28 | 28 |
org.nuiton.jaxx.widgets.select.BeanListHeader
|
| 29 | 29 |
</import>
|
| 30 | 30 |
|
| 31 |
- <style source="../CommonOpenDataListFormUI.jcss"/>
|
|
| 32 |
- |
|
| 33 |
- <RouteListUIModel id='model' title='observe.common.RouteDto.types'/>
|
|
| 31 |
+ <RouteListUIModel id='model'/>
|
|
| 34 | 32 |
<JLabel id="emptyLabel" text='observe.common.RouteDto.noneForTrip'/>
|
| 35 | 33 |
<BeanListHeader id='listHeader' labelText='observe.common.RouteDto.list'/>
|
| 36 | 34 |
<JButton id='showSelectedData'/>
|
| ... | ... | @@ -22,13 +22,26 @@ package fr.ird.observe.client.ds.editor.form.openlist.seine; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import com.google.common.collect.ImmutableSet;
|
|
| 26 |
+import fr.ird.observe.client.ObserveClientApplicationContext;
|
|
| 27 |
+import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 28 |
+import fr.ird.observe.client.ds.editor.form.openlist.OpenDataListFormUI;
|
|
| 25 | 29 |
import fr.ird.observe.client.ds.editor.form.openlist.OpenDataListFormUIModel;
|
| 26 | 30 |
import fr.ird.observe.client.ds.editor.form.spi.FormUIValidationMessageManager;
|
| 31 |
+import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
|
| 32 |
+import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 33 |
+import fr.ird.observe.client.util.DecoratedNodeEntity;
|
|
| 27 | 34 |
import fr.ird.observe.dto.data.seine.RouteDto;
|
| 28 | 35 |
import fr.ird.observe.dto.data.seine.RouteReference;
|
| 36 |
+import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
|
|
| 29 | 37 |
import fr.ird.observe.services.service.data.seine.RouteService;
|
| 38 |
+import fr.ird.observe.spi.application.ObserveApplicationDataContext;
|
|
| 39 |
+ |
|
| 40 |
+import java.util.List;
|
|
| 41 |
+import java.util.Optional;
|
|
| 30 | 42 |
|
| 31 | 43 |
import static org.nuiton.i18n.I18n.n;
|
| 44 |
+import static org.nuiton.i18n.I18n.t;
|
|
| 32 | 45 |
|
| 33 | 46 |
/**
|
| 34 | 47 |
* Created on 9/26/14.
|
| ... | ... | @@ -38,6 +51,10 @@ import static org.nuiton.i18n.I18n.n; |
| 38 | 51 |
*/
|
| 39 | 52 |
public class RouteListUIModel extends OpenDataListFormUIModel<RouteDto, RouteReference, RouteService> {
|
| 40 | 53 |
|
| 54 |
+ public RouteListUIModel() {
|
|
| 55 |
+ setTitle(t("observe.common.RouteDto.types"));
|
|
| 56 |
+ }
|
|
| 57 |
+ |
|
| 41 | 58 |
@Override
|
| 42 | 59 |
public void computeReadMessages(FormUIValidationMessageManager validationManager) {
|
| 43 | 60 |
if (isAnotherParentOpen()) {
|
| ... | ... | @@ -61,4 +78,62 @@ public class RouteListUIModel extends OpenDataListFormUIModel<RouteDto, RouteRef |
| 61 | 78 |
validationManager.addInfoMessage(n("observe.common.RouteDto.message.active.found"));
|
| 62 | 79 |
}
|
| 63 | 80 |
|
| 81 |
+ @Override
|
|
| 82 |
+ public String getMoveTitle() {
|
|
| 83 |
+ return t("observe.action.choose.tripSeine.title");
|
|
| 84 |
+ }
|
|
| 85 |
+ |
|
| 86 |
+ @Override
|
|
| 87 |
+ public String getMoveMessage() {
|
|
| 88 |
+ return t("observe.action.choose.tripSeine.message");
|
|
| 89 |
+ }
|
|
| 90 |
+ |
|
| 91 |
+ @Override
|
|
| 92 |
+ public DecoratedNodeEntity[] getParentCandidates(OpenDataListFormUI<RouteDto, RouteReference> ui) {
|
|
| 93 |
+ return MoveDataHelper.getRouteParentCandidates(getParentId(), getOldParentNode(ui));
|
|
| 94 |
+ }
|
|
| 95 |
+ |
|
| 96 |
+ @Override
|
|
| 97 |
+ public void afterMoveData(ImmutableSet<String> dataIds, String newParentId, List<Integer> positions, OpenDataListFormUI<RouteDto, RouteReference> ui) {
|
|
| 98 |
+ super.afterMoveData(dataIds, newParentId, positions, ui);
|
|
| 99 |
+ |
|
| 100 |
+ |
|
| 101 |
+ NavigationTreeNodeSupport oldParentNode = getOldParentNode(ui);
|
|
| 102 |
+ |
|
| 103 |
+ ObserveApplicationDataContext openDataManager = ObserveClientApplicationContext.applicationDataContext();
|
|
| 104 |
+ NavigationTree treeHelper = ui.getDataSourceUI().getTree();
|
|
| 105 |
+ |
|
| 106 |
+ NavigationTreeNodeSupport oldTripSeineNode = oldParentNode.getParent();
|
|
| 107 |
+ NavigationTreeNodeSupport programNode = oldTripSeineNode.getParent();
|
|
| 108 |
+ NavigationTreeNodeSupport newTripSeineNode = treeHelper.getChild(programNode, newParentId);
|
|
| 109 |
+ String routesNodeId = ObserveI18nDecoratorHelper.getTypePluralI18nKey(RouteDto.class);
|
|
| 110 |
+ NavigationTreeNodeSupport newRoutesNode = treeHelper.getChild(newTripSeineNode, routesNodeId);
|
|
| 111 |
+ |
|
| 112 |
+ // Let's check if we're moving an open route
|
|
| 113 |
+ String openId = openDataManager.getOpenRouteId();
|
|
| 114 |
+ Optional<String> openRoute = openId != null && dataIds.contains(openId) ? Optional.of(openId) : Optional.empty();
|
|
| 115 |
+ |
|
| 116 |
+ // If so, we closeData it to avoid ending up with an open route into a closed trip.
|
|
| 117 |
+ if (openRoute.isPresent()) {
|
|
| 118 |
+ openDataManager.close(RouteDto.class);
|
|
| 119 |
+ }
|
|
| 120 |
+ |
|
| 121 |
+ // Let's reload the sub tree of each routes node.
|
|
| 122 |
+ // As the change have already be done in database, we just call the child loaders to regenerate the routes nodes sub trees
|
|
| 123 |
+ treeHelper.reloadNodeSubTree(oldParentNode);
|
|
| 124 |
+ treeHelper.reloadNodeSubTree(newRoutesNode);
|
|
| 125 |
+ |
|
| 126 |
+ // 1. Select the newRoutesNode :
|
|
| 127 |
+ // only a selected node can be reloaded (@see fr.ird.observe.client.ui.tree.ObserveTreeBridge.canLoadChild).
|
|
| 128 |
+ // (And also it's better for user experience because it puts the focus on the routes node which receive the routes)
|
|
| 129 |
+ //
|
|
| 130 |
+ // However, the node selection has to be done after that the trip has been opened :
|
|
| 131 |
+ // selecting the newRoutesNode opens a list layout which compute a rendering mode associated to the trip state.
|
|
| 132 |
+ // After the mode has been computed, it is injected in the list component which triggers listeners on associated components, such as buttons.
|
|
| 133 |
+ //
|
|
| 134 |
+ // That's why, if we do this before the trip is opened,
|
|
| 135 |
+ // we will end up with an incoherent list view (some buttons will be deactivated while they should be activated for instance)
|
|
| 136 |
+ treeHelper.selectNode(newRoutesNode);
|
|
| 137 |
+ |
|
| 138 |
+ }
|
|
| 64 | 139 |
}
|
| ... | ... | @@ -27,9 +27,7 @@ |
| 27 | 27 |
org.nuiton.jaxx.widgets.select.BeanListHeader
|
| 28 | 28 |
</import>
|
| 29 | 29 |
|
| 30 |
- <style source="../CommonOpenDataListFormUI.jcss"/>
|
|
| 31 |
- |
|
| 32 |
- <TripSeineListUIModel id='model' title='observe.common.TripSeineDto.types'/>
|
|
| 30 |
+ <TripSeineListUIModel id='model'/>
|
|
| 33 | 31 |
<JLabel id="emptyLabel" text='observe.common.TripDto.message.noneForTrip'/>
|
| 34 | 32 |
<BeanListHeader id='listHeader' labelText='observe.common.TripDto.list'/>
|
| 35 | 33 |
<JButton id='showSelectedData'/>
|
| ... | ... | @@ -22,16 +22,24 @@ package fr.ird.observe.client.ds.editor.form.openlist.seine; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import com.google.common.collect.ImmutableSet;
|
|
| 25 | 26 |
import fr.ird.observe.client.ClientApplicationContext;
|
| 27 |
+import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 28 |
+import fr.ird.observe.client.ds.editor.form.openlist.OpenDataListFormUI;
|
|
| 26 | 29 |
import fr.ird.observe.client.ds.editor.form.openlist.OpenDataListFormUIModel;
|
| 27 | 30 |
import fr.ird.observe.client.ds.editor.form.spi.FormUIValidationMessageManager;
|
| 31 |
+import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 32 |
+import fr.ird.observe.client.util.DecoratedNodeEntity;
|
|
| 28 | 33 |
import fr.ird.observe.dto.data.seine.TripSeineDto;
|
| 29 | 34 |
import fr.ird.observe.dto.data.seine.TripSeineReference;
|
| 30 | 35 |
import fr.ird.observe.dto.reference.DtoReference;
|
| 31 | 36 |
import fr.ird.observe.dto.referential.ProgramReference;
|
| 32 | 37 |
import fr.ird.observe.services.service.data.seine.TripSeineService;
|
| 33 | 38 |
|
| 39 |
+import java.util.List;
|
|
| 40 |
+ |
|
| 34 | 41 |
import static org.nuiton.i18n.I18n.n;
|
| 42 |
+import static org.nuiton.i18n.I18n.t;
|
|
| 35 | 43 |
|
| 36 | 44 |
/**
|
| 37 | 45 |
* Created on 9/26/14.
|
| ... | ... | @@ -41,6 +49,10 @@ import static org.nuiton.i18n.I18n.n; |
| 41 | 49 |
*/
|
| 42 | 50 |
public class TripSeineListUIModel extends OpenDataListFormUIModel<TripSeineDto, TripSeineReference, TripSeineService> {
|
| 43 | 51 |
|
| 52 |
+ public TripSeineListUIModel() {
|
|
| 53 |
+ setTitle(t("observe.common.TripSeineDto.types"));
|
|
| 54 |
+ }
|
|
| 55 |
+ |
|
| 44 | 56 |
@Override
|
| 45 | 57 |
public void computeReadMessages(FormUIValidationMessageManager validationManager) {
|
| 46 | 58 |
validationManager.addInfoMessage(n("observe.common.TripSeineDto.message.active.found.for.other.program"));
|
| ... | ... | @@ -63,4 +75,26 @@ public class TripSeineListUIModel extends OpenDataListFormUIModel<TripSeineDto, |
| 63 | 75 |
setTitle(title);
|
| 64 | 76 |
super.openUI();
|
| 65 | 77 |
}
|
| 78 |
+ |
|
| 79 |
+ @Override
|
|
| 80 |
+ public String getMoveTitle() {
|
|
| 81 |
+ return t("observe.action.choose.program.title");
|
|
| 82 |
+ }
|
|
| 83 |
+ |
|
| 84 |
+ @Override
|
|
| 85 |
+ public String getMoveMessage() {
|
|
| 86 |
+ return t("observe.action.choose.program.message");
|
|
| 87 |
+ }
|
|
| 88 |
+ |
|
| 89 |
+ @Override
|
|
| 90 |
+ public DecoratedNodeEntity[] getParentCandidates(OpenDataListFormUI<TripSeineDto, TripSeineReference> ui) {
|
|
| 91 |
+ return MoveDataHelper.getTripSeineParentCandidates(ui, getParentId());
|
|
| 92 |
+ }
|
|
| 93 |
+ |
|
| 94 |
+ @Override
|
|
| 95 |
+ public void afterMoveData(ImmutableSet<String> dataIds, String newParentId, List<Integer> positions, OpenDataListFormUI<TripSeineDto, TripSeineReference> ui) {
|
|
| 96 |
+ super.afterMoveData(dataIds, newParentId, positions, ui);
|
|
| 97 |
+ NavigationTreeNodeSupport oldParentNode = getOldParentNode(ui);
|
|
| 98 |
+ MoveDataHelper.moveTrips(ui.getDataSourceUI().getTree(), newParentId, dataIds, positions, oldParentNode);
|
|
| 99 |
+ }
|
|
| 66 | 100 |
}
|
| 1 |
-/*
|
|
| 2 |
- * #%L
|
|
| 3 |
- * ObServe :: Client
|
|
| 4 |
- * %%
|
|
| 5 |
- * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
|
|
| 6 |
- * %%
|
|
| 7 |
- * This program is free software: you can redistribute it and/or modify
|
|
| 8 |
- * it under the terms of the GNU General Public License as
|
|
| 9 |
- * published by the Free Software Foundation, either version 3 of the
|
|
| 10 |
- * License, or (at your option) any later version.
|
|
| 11 |
- *
|
|
| 12 |
- * This program is distributed in the hope that it will be useful,
|
|
| 13 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 |
- * GNU General Public License for more details.
|
|
| 16 |
- *
|
|
| 17 |
- * You should have received a copy of the GNU General Public
|
|
| 18 |
- * License along with this program. If not, see
|
|
| 19 |
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 |
- * #L%
|
|
| 21 |
- */
|
|
| 22 |
-package fr.ird.observe.client.ds.editor.form.openlist.seine.actions;
|
|
| 23 |
- |
|
| 24 |
-import fr.ird.observe.client.ObserveClientApplicationContext;
|
|
| 25 |
-import fr.ird.observe.client.ds.editor.form.ObserveFormHelper;
|
|
| 26 |
-import fr.ird.observe.client.ds.editor.form.open.seine.ActivitySeineUI;
|
|
| 27 |
-import fr.ird.observe.client.ds.editor.form.openlist.OpenDataListFormUI;
|
|
| 28 |
-import fr.ird.observe.client.ds.editor.form.openlist.actions.OpenDataListFormUICreateData;
|
|
| 29 |
-import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
|
| 30 |
-import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 31 |
-import fr.ird.observe.client.main.actions.MainUIMenuNavigationGoToOpenActivity;
|
|
| 32 |
- |
|
| 33 |
-import javax.swing.tree.TreePath;
|
|
| 34 |
-import java.awt.event.ActionEvent;
|
|
| 35 |
- |
|
| 36 |
-/**
|
|
| 37 |
- * FIXME!!! N'est plus utilisé mais on garde pour voir si ce n'est pas encore nécessaire
|
|
| 38 |
- * Action pour fermer l'objet sous-jacent à l'écran et en créer un nouveau.
|
|
| 39 |
- *
|
|
| 40 |
- * @author Tony Chemit - dev@tchemit.fr
|
|
| 41 |
- * @since 1.5
|
|
| 42 |
- */
|
|
| 43 |
-public class OpenDataListFormUICreateActivitySeine extends OpenDataListFormUICreateData {
|
|
| 44 |
- |
|
| 45 |
- public OpenDataListFormUICreateActivitySeine() {
|
|
| 46 |
-// super(n("observe.common.ActivityDto.action.closeAndCreate"),
|
|
| 47 |
-// n("observe.common.ActivityDto.action.closeAndCreate.tip"));
|
|
| 48 |
- }
|
|
| 49 |
- |
|
| 50 |
- @Override
|
|
| 51 |
- protected void doActionPerformed(ActionEvent e, OpenDataListFormUI ui) {
|
|
| 52 |
- |
|
| 53 |
- //FIXME!!! Voir si c'est vraiment nécessaire, je comprends pas pourquoi le comportement change des autres types
|
|
| 54 |
- String openId = ObserveClientApplicationContext.applicationDataContext().getOpenActivitySeineId();
|
|
| 55 |
- |
|
| 56 |
- NavigationTree tree = getDataSourceEditor().getTree();
|
|
| 57 |
- |
|
| 58 |
- boolean wasCollapsed = ObserveFormHelper.isOpenActivityNodeCollapsed(tree, openId);
|
|
| 59 |
- |
|
| 60 |
- //FIXME!!! Voir si ça fonctionne bien
|
|
| 61 |
- // selection du noeud de l'activité ouverte
|
|
| 62 |
- getUi().getActionMap().get(MainUIMenuNavigationGoToOpenActivity.class).actionPerformed(null);
|
|
| 63 |
- |
|
| 64 |
- NavigationTreeNodeSupport selectedNode = tree.getSelectedNode();
|
|
| 65 |
- selectedNode = tree.getActivitySeineNode(selectedNode, openId);
|
|
| 66 |
- |
|
| 67 |
- tree.selectNode(selectedNode);
|
|
| 68 |
- |
|
| 69 |
- // on conserve le path de l'activité
|
|
| 70 |
- TreePath path = tree.getSelectionPath();
|
|
| 71 |
- |
|
| 72 |
- // recuperation de l'écran associé
|
|
| 73 |
- ActivitySeineUI selectedUI = (ActivitySeineUI) getDataSourceEditor().getSelectedContentUI();
|
|
| 74 |
- |
|
| 75 |
- if (openId != null) {
|
|
| 76 |
- // fermeture de l'activité et création d'une nouvelle
|
|
| 77 |
- selectedUI.getCloseData().doClick();
|
|
| 78 |
- }
|
|
| 79 |
- |
|
| 80 |
- selectedUI.getCreate().doClick();
|
|
| 81 |
- |
|
| 82 |
- if (wasCollapsed) {
|
|
| 83 |
- |
|
| 84 |
- // on ferme le noeud de l'activity (qui a ete ouvert
|
|
| 85 |
- // lors de la selection de celle-ci)
|
|
| 86 |
- tree.collapsePath(path);
|
|
| 87 |
- }
|
|
| 88 |
- |
|
| 89 |
- }
|
|
| 90 |
- |
|
| 91 |
-}
|
| 1 |
-/*
|
|
| 2 |
- * #%L
|
|
| 3 |
- * ObServe :: Client
|
|
| 4 |
- * %%
|
|
| 5 |
- * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
|
|
| 6 |
- * %%
|
|
| 7 |
- * This program is free software: you can redistribute it and/or modify
|
|
| 8 |
- * it under the terms of the GNU General Public License as
|
|
| 9 |
- * published by the Free Software Foundation, either version 3 of the
|
|
| 10 |
- * License, or (at your option) any later version.
|
|
| 11 |
- *
|
|
| 12 |
- * This program is distributed in the hope that it will be useful,
|
|
| 13 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 |
- * GNU General Public License for more details.
|
|
| 16 |
- *
|
|
| 17 |
- * You should have received a copy of the GNU General Public
|
|
| 18 |
- * License along with this program. If not, see
|
|
| 19 |
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 |
- * #L%
|
|
| 21 |
- */
|
|
| 22 |
-package fr.ird.observe.client.ds.editor.form.openlist.seine.actions;
|
|
| 23 |
- |
|
| 24 |
-import fr.ird.observe.client.ObserveClientApplicationContext;
|
|
| 25 |
-import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 26 |
-import fr.ird.observe.client.ds.editor.form.openlist.actions.OpenDataListFormUIMoveMultipleDataActionSupport;
|
|
| 27 |
-import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
|
| 28 |
-import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 29 |
-import fr.ird.observe.dto.data.seine.ActivitySeineDto;
|
|
| 30 |
-import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
|
|
| 31 |
-import fr.ird.observe.spi.application.ObserveApplicationDataContext;
|
|
| 32 |
- |
|
| 33 |
-import java.util.List;
|
|
| 34 |
-import java.util.Optional;
|
|
| 35 |
-import java.util.Set;
|
|
| 36 |
- |
|
| 37 |
-import static org.nuiton.i18n.I18n.n;
|
|
| 38 |
- |
|
| 39 |
-/**
|
|
| 40 |
- * Action pour changer le programme d'une ou plusieurs marée dans la liste.
|
|
| 41 |
- *
|
|
| 42 |
- * @author Kevin Morin (Code Lutin)
|
|
| 43 |
- * @since 5.0
|
|
| 44 |
- */
|
|
| 45 |
-public class OpenDataListFormUIMoveMultipleActivitySeine extends OpenDataListFormUIMoveMultipleDataActionSupport {
|
|
| 46 |
- |
|
| 47 |
- public OpenDataListFormUIMoveMultipleActivitySeine() {
|
|
| 48 |
- super(n("observe.common.ActivitySeineDto.action.moves"),
|
|
| 49 |
- n("observe.common.ActivitySeineDto.action.moves.tip"),
|
|
| 50 |
- "moveData-activities");
|
|
| 51 |
- }
|
|
| 52 |
- |
|
| 53 |
- @Override
|
|
| 54 |
- public Optional<String> getNewParentId() {
|
|
| 55 |
- return MoveDataHelper.chooseNewRoute(getMainUI(), getOldParentNode());
|
|
| 56 |
- }
|
|
| 57 |
- |
|
| 58 |
- @Override
|
|
| 59 |
- public void updateUI(String newParentId, Set<String> dataIds, List<Integer> positions) {
|
|
| 60 |
- |
|
| 61 |
- NavigationTreeNodeSupport oldParentNode = getOldParentNode();
|
|
| 62 |
- |
|
| 63 |
- ObserveApplicationDataContext openDataManager = ObserveClientApplicationContext.applicationDataContext();
|
|
| 64 |
- NavigationTree treeHelper = getDataSourceEditor().getTree();
|
|
| 65 |
- |
|
| 66 |
- NavigationTreeNodeSupport oldRouteNode = oldParentNode.getParent();
|
|
| 67 |
- NavigationTreeNodeSupport routesNode = oldRouteNode.getParent();
|
|
| 68 |
- NavigationTreeNodeSupport newRouteNode = treeHelper.getChild(routesNode, newParentId);
|
|
| 69 |
- String activitiesNodeId = ObserveI18nDecoratorHelper.getTypePluralI18nKey(ActivitySeineDto.class);
|
|
| 70 |
- NavigationTreeNodeSupport newActivitiesNode = treeHelper.getChild(newRouteNode, activitiesNodeId);
|
|
| 71 |
- |
|
| 72 |
- // Let's check if we're moving an open activity
|
|
| 73 |
- String openId = openDataManager.getOpenActivityLonglineObsId();
|
|
| 74 |
- Optional<String> openActivity = openId != null && dataIds.contains(openId) ? Optional.of(openId) : Optional.empty();
|
|
| 75 |
- |
|
| 76 |
- // If so, we closeData it to avoid ending up with an open activity into a closed route.
|
|
| 77 |
- if (openActivity.isPresent()) {
|
|
| 78 |
- openDataManager.close(ActivitySeineDto.class);
|
|
| 79 |
- }
|
|
| 80 |
- |
|
| 81 |
- // Let's reload the sub tree of each activities node.
|
|
| 82 |
- // As the change have already be done in database, we just call the child loaders to regenerate the activities nodes sub trees
|
|
| 83 |
- treeHelper.reloadNodeSubTree(oldParentNode);
|
|
| 84 |
- treeHelper.reloadNodeSubTree(newActivitiesNode);
|
|
| 85 |
- |
|
| 86 |
- // Let's put the focus on the activities node which received the activities
|
|
| 87 |
- treeHelper.selectNode(newActivitiesNode);
|
|
| 88 |
- }
|
|
| 89 |
- |
|
| 90 |
-}
|
| 1 |
-/*
|
|
| 2 |
- * #%L
|
|
| 3 |
- * ObServe :: Client
|
|
| 4 |
- * %%
|
|
| 5 |
- * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
|
|
| 6 |
- * %%
|
|
| 7 |
- * This program is free software: you can redistribute it and/or modify
|
|
| 8 |
- * it under the terms of the GNU General Public License as
|
|
| 9 |
- * published by the Free Software Foundation, either version 3 of the
|
|
| 10 |
- * License, or (at your option) any later version.
|
|
| 11 |
- *
|
|
| 12 |
- * This program is distributed in the hope that it will be useful,
|
|
| 13 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 |
- * GNU General Public License for more details.
|
|
| 16 |
- *
|
|
| 17 |
- * You should have received a copy of the GNU General Public
|
|
| 18 |
- * License along with this program. If not, see
|
|
| 19 |
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 |
- * #L%
|
|
| 21 |
- */
|
|
| 22 |
-package fr.ird.observe.client.ds.editor.form.openlist.seine.actions;
|
|
| 23 |
- |
|
| 24 |
-import fr.ird.observe.client.ObserveClientApplicationContext;
|
|
| 25 |
-import fr.ird.observe.client.ds.editor.form.MoveDataHelper;
|
|
| 26 |
-import fr.ird.observe.client.ds.editor.form.openlist.actions.OpenDataListFormUIMoveMultipleDataActionSupport;
|
|
| 27 |
-import fr.ird.observe.client.ds.editor.tree.navigation.NavigationTree;
|
|
| 28 |
-import fr.ird.observe.client.ds.editor.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 29 |
-import fr.ird.observe.dto.data.seine.RouteDto;
|
|
| 30 |
-import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
|
|
| 31 |
-import fr.ird.observe.spi.application.ObserveApplicationDataContext;
|
|
| 32 |
- |
|
| 33 |
-import java.util.List;
|
|
| 34 |
-import java.util.Optional;
|
|
| 35 |
-import java.util.Set;
|
|
| 36 |
- |
|
| 37 |
-import static org.nuiton.i18n.I18n.n;
|
|
| 38 |
- |
|
| 39 |
-/**
|
|
| 40 |
- * Action pour changer le programme d'une ou plusieurs marée dans la liste.
|
|
| 41 |
- *
|
|
| 42 |
- * @author Kevin Morin (Code Lutin)
|
|
| 43 |
- * @since 5.0
|
|
| 44 |
- */
|
|
| 45 |
-public class OpenDataListFormUIMoveMultipleRoute extends OpenDataListFormUIMoveMultipleDataActionSupport {
|
|
| 46 |
- |
|
| 47 |
- public OpenDataListFormUIMoveMultipleRoute() {
|
|
| 48 |
- super(n("observe.common.RouteDto.action.moves"),
|
|
| 49 |
- n("observe.common.RouteDto.action.moves.tip"),
|
|
| 50 |
- "moveData-routes");
|
|
| 51 |
- }
|
|
| 52 |
- |
|
| 53 |
- @Override
|
|
| 54 |
- public Optional<String> getNewParentId() {
|
|
| 55 |
- return MoveDataHelper.chooseNewTripSeine(getMainUI(), getOldParentNode());
|
|
| 56 |
- }
|
|
| 57 |
- |
|
| 58 |
- |
|
| 59 |
- @Override
|
|
| 60 |
- public void updateUI(String tripSeineId, Set<String> dataIds, List<Integer> positions) {
|
|
| 61 |
- |
|
| 62 |
- NavigationTreeNodeSupport oldParentNode = getOldParentNode();
|
|
| 63 |
- |
|
| 64 |
- ObserveApplicationDataContext openDataManager = ObserveClientApplicationContext.applicationDataContext();
|
|
| 65 |
- NavigationTree treeHelper = getDataSourceEditor().getTree();
|
|
| 66 |
- |
|
| 67 |
- NavigationTreeNodeSupport oldTripSeineNode = oldParentNode.getParent();
|
|
| 68 |
- NavigationTreeNodeSupport programNode = oldTripSeineNode.getParent();
|
|
| 69 |
- NavigationTreeNodeSupport newTripSeineNode = treeHelper.getChild(programNode, tripSeineId);
|
|
| 70 |
- String routesNodeId = ObserveI18nDecoratorHelper.getTypePluralI18nKey(RouteDto.class);
|
|
| 71 |
- NavigationTreeNodeSupport newRoutesNode = treeHelper.getChild(newTripSeineNode, routesNodeId);
|
|
| 72 |
- |
|
| 73 |
- // Let's check if we're moving an open route
|
|
| 74 |
- String openId = openDataManager.getOpenRouteId();
|
|
| 75 |
- Optional<String> openRoute = openId != null && dataIds.contains(openId) ? Optional.of(openId) : Optional.empty();
|
|
| 76 |
- |
|
| 77 |
- // If so, we closeData it to avoid ending up with an open route into a closed trip.
|
|
| 78 |
- if (openRoute.isPresent()) {
|
|
| 79 |
- openDataManager.close(RouteDto.class);
|
|
| 80 |
- }
|
|
| 81 |
- |
|
| 82 |
- // Let's reload the sub tree of each routes node.
|
|
| 83 |
- // As the change have already be done in database, we just call the child loaders to regenerate the routes nodes sub trees
|
|
| 84 |
- treeHelper.reloadNodeSubTree(oldParentNode);
|
|
| 85 |
- treeHelper.reloadNodeSubTree(newRoutesNode);
|
|
| 86 |
- |
|
| 87 |
- // 1. Select the newRoutesNode :
|
|
| 88 |
- // only a selected node can be reloaded (@see fr.ird.observe.client.ui.tree.ObserveTreeBridge.canLoadChild).
|
|
| 89 |
- // (And also it's better for user experience because it puts the focus on the routes node which receive the routes)
|
|
| 90 |
- //
|
|
| 91 |
- // However, the node selection has to be done after that the trip has been opened :
|
|
| 92 |
- // selecting the newRoutesNode opens a list layout which compute a rendering mode associated to the trip state.
|
|
| 93 |
- // After the mode has been computed, it is injected in the list component which triggers listeners on associated components, such as buttons.
|
|
| 94 |
- //
|
|
| 95 |
- // That's why, if we do this before the trip is opened,
|
|
| 96 |
- // we will end up with an incoherent list view (some buttons will be deactivated while they should be activated for instance)
|
|
| 97 |
- treeHelper.selectNode(newRoutesNode);
|
|
| 98 |
- |
|
| 99 |
- }
|
|
| 100 |
- |
|
| 101 |
-}
|
| 1 |
-package fr.ird.observe.client.ds.editor.form.openlist.seine.actions;
|
|
| 2 |
- |
|
| 3 |
-/*-
|
|
| 4 |
- * #%L
|
|
| 5 |
- * ObServe :: Client
|
|
| 6 |
- * %%
|
|
| 7 |
- * Copyright (C) 2008 - 2017 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.ds.editor.form.openlist.OpenDataListFormUIMoveMultipleTripActionSupport;
|
|
| 26 |
-import fr.ird.observe.dto.referential.GearType;
|
|
| 27 |
- |
|
| 28 |
-/**
|
|
| 29 |
- * @author Kevin Morin (Code Lutin)
|
|
| 30 |
- * @since 5.0
|
|
| 31 |
- */
|
|
| 32 |
-public class OpenDataListFormUIMoveMultipleTripSeine extends OpenDataListFormUIMoveMultipleTripActionSupport {
|
|
| 33 |
- |
|
| 34 |
- public OpenDataListFormUIMoveMultipleTripSeine() {
|
|
| 35 |
- super(GearType.seine);
|
|
| 36 |
- }
|
|
| 37 |
- |
|
| 38 |
-}
|