Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe
Commits:
-
b24c2861
by Tony CHEMIT at 2018-09-22T11:54:43Z
23 changed files:
- client/src/main/java/fr/ird/observe/client/ui/actions/content/CloseAndCreateUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/content/CloseOpenUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveActivityLonglinesUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveActivitySeinesUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveRoutesUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveSingleDataUIActionSupport.java
- client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveTripsUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/content/ReOpenUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/content/ResetEditUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/content/SelectNodeUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/content/SelectOpenNodeUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/content/ContentUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/seine/SetSeineUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/ref/ReferenceHomeUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTree.java
Changes:
| ... | ... | @@ -88,7 +88,7 @@ public class CloseAndCreateUIAction extends AbstractContentUIAction { |
| 88 | 88 |
NavigationTreeNodeSupport selectedNode = tree.getSelectedNode();
|
| 89 | 89 |
selectedNode = tree.getActivitySeineNode(selectedNode, dataContext.getOpenActivitySeineId());
|
| 90 | 90 |
|
| 91 |
- tree.selectNode(selectedNode);
|
|
| 91 |
+ tree.selectSafeNode(selectedNode);
|
|
| 92 | 92 |
|
| 93 | 93 |
// on conserve le path de l'activité
|
| 94 | 94 |
TreePath path = tree.getSelectionPath();
|
| ... | ... | @@ -127,7 +127,7 @@ public class CloseAndCreateUIAction extends AbstractContentUIAction { |
| 127 | 127 |
// selection du noeud de l'activity ouverte
|
| 128 | 128 |
NavigationTreeNodeSupport selectedNode = tree.getSelectedNode();
|
| 129 | 129 |
selectedNode = tree.getActivityLonglineNode(selectedNode, dataContext.getOpenActivitySeineId());
|
| 130 |
- tree.selectNode(selectedNode);
|
|
| 130 |
+ tree.selectSafeNode(selectedNode);
|
|
| 131 | 131 |
|
| 132 | 132 |
// on conserve le path de l'activité
|
| 133 | 133 |
TreePath path = tree.getSelectionPath();
|
| ... | ... | @@ -107,7 +107,7 @@ public class CloseOpenUIAction extends AbstractContentUIAction { |
| 107 | 107 |
|
| 108 | 108 |
NavigationTreeNodeSupport node = tree.getChild(selectedNode, id);
|
| 109 | 109 |
|
| 110 |
- tree.selectNode(node);
|
|
| 110 |
+ tree.selectSafeNode(node);
|
|
| 111 | 111 |
|
| 112 | 112 |
ContentOpenableUI selectedUI = (ContentOpenableUI) applicationContext.getContentUIManager().getSelectedContentUI();
|
| 113 | 113 |
|
| ... | ... | @@ -117,7 +117,7 @@ public class CloseOpenUIAction extends AbstractContentUIAction { |
| 117 | 117 |
SwingUtilities.invokeLater(() -> {
|
| 118 | 118 |
|
| 119 | 119 |
// retour sur le noeud parent
|
| 120 |
- tree.selectNode(selectedNode);
|
|
| 120 |
+ tree.selectSafeNode(selectedNode);
|
|
| 121 | 121 |
|
| 122 | 122 |
});
|
| 123 | 123 |
|
| ... | ... | @@ -96,7 +96,7 @@ public class MoveActivityLonglinesUIAction extends MoveMultipleDataUIActionSuppo |
| 96 | 96 |
treeHelper.reloadNodeSubTree(newActivitiesNode);
|
| 97 | 97 |
|
| 98 | 98 |
// Let's put the focus on the activities node which received the activities
|
| 99 |
- treeHelper.selectNode(newActivitiesNode);
|
|
| 99 |
+ treeHelper.selectSafeNode(newActivitiesNode);
|
|
| 100 | 100 |
|
| 101 | 101 |
}
|
| 102 | 102 |
|
| ... | ... | @@ -96,7 +96,7 @@ public class MoveActivitySeinesUIAction extends MoveMultipleDataUIActionSupport< |
| 96 | 96 |
treeHelper.reloadNodeSubTree(newActivitiesNode);
|
| 97 | 97 |
|
| 98 | 98 |
// Let's put the focus on the activities node which received the activities
|
| 99 |
- treeHelper.selectNode(newActivitiesNode);
|
|
| 99 |
+ treeHelper.selectSafeNode(newActivitiesNode);
|
|
| 100 | 100 |
}
|
| 101 | 101 |
|
| 102 | 102 |
}
|
| ... | ... | @@ -104,7 +104,7 @@ public class MoveRoutesUIAction extends MoveMultipleDataUIActionSupport<RoutesUI |
| 104 | 104 |
//
|
| 105 | 105 |
// That's why, if we do this before the trip is opened,
|
| 106 | 106 |
// we will end up with an incoherent list view (some buttons will be deactivated while they should be activated for instance)
|
| 107 |
- treeHelper.selectNode(newRoutesNode);
|
|
| 107 |
+ treeHelper.selectSafeNode(newRoutesNode);
|
|
| 108 | 108 |
|
| 109 | 109 |
}
|
| 110 | 110 |
|
| ... | ... | @@ -73,7 +73,7 @@ public abstract class MoveSingleDataUIActionSupport extends UIActionSupport { |
| 73 | 73 |
|
| 74 | 74 |
int position = moveData(oldParentNode.getId(), newParentId, dataId);
|
| 75 | 75 |
|
| 76 |
- treeHelper.selectNode(newParentNode);
|
|
| 76 |
+ treeHelper.selectSafeNode(newParentNode);
|
|
| 77 | 77 |
|
| 78 | 78 |
treeHelper.removeNode(node);
|
| 79 | 79 |
|
| ... | ... | @@ -87,7 +87,7 @@ public abstract class MoveSingleDataUIActionSupport extends UIActionSupport { |
| 87 | 87 |
|
| 88 | 88 |
treeHelper.reloadNode(oldParentNode, false);
|
| 89 | 89 |
treeHelper.reloadNode(newParentNode, false);
|
| 90 |
- treeHelper.selectNode(newNode);
|
|
| 90 |
+ treeHelper.selectSafeNode(newNode);
|
|
| 91 | 91 |
|
| 92 | 92 |
}
|
| 93 | 93 |
|
| ... | ... | @@ -30,8 +30,8 @@ import fr.ird.observe.client.ui.content.list.ContentListUI; |
| 30 | 30 |
import fr.ird.observe.client.ui.tree.navigation.NavigationTree;
|
| 31 | 31 |
import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport;
|
| 32 | 32 |
import fr.ird.observe.dto.referential.GearType;
|
| 33 |
-import org.apache.logging.log4j.Logger;
|
|
| 34 | 33 |
import org.apache.logging.log4j.LogManager;
|
| 34 |
+import org.apache.logging.log4j.Logger;
|
|
| 35 | 35 |
|
| 36 | 36 |
import java.util.List;
|
| 37 | 37 |
import java.util.Optional;
|
| ... | ... | @@ -111,7 +111,7 @@ public abstract class MoveTripsUIAction<U extends ContentListUI<?, ?, ?, ?>> ext |
| 111 | 111 |
|
| 112 | 112 |
treeHelper.reloadNode(oldParentNode, true);
|
| 113 | 113 |
treeHelper.reloadNode(newProgramNode, true);
|
| 114 |
- treeHelper.selectNode(newProgramNode);
|
|
| 114 |
+ treeHelper.selectSafeNode(newProgramNode);
|
|
| 115 | 115 |
}
|
| 116 | 116 |
|
| 117 | 117 |
}
|
| ... | ... | @@ -73,7 +73,7 @@ public class ReOpenUIAction extends AbstractContentUIAction { |
| 73 | 73 |
NavigationTreeNodeSupport selectedNode = tree.getSelectedNode();
|
| 74 | 74 |
NavigationTreeNodeSupport node = tree.getChild(selectedNode, id);
|
| 75 | 75 |
|
| 76 |
- tree.selectNode(node);
|
|
| 76 |
+ tree.selectSafeNode(node);
|
|
| 77 | 77 |
|
| 78 | 78 |
openUI = (ContentOpenableUI<?, ?>)
|
| 79 | 79 |
ObserveSwingApplicationContext.get().getContentUIManager().getSelectedContentUI();
|
| ... | ... | @@ -59,7 +59,7 @@ public class ResetEditUIAction extends AbstractContentUIAction { |
| 59 | 59 |
NavigationTree tree = getMainUI().getNavigationUI().getTree();
|
| 60 | 60 |
NavigationTreeNodeSupport parentNode = tree.getSelectedNode().getParent();
|
| 61 | 61 |
tree.removeNode(tree.getSelectedNode());
|
| 62 |
- tree.selectNode(parentNode);
|
|
| 62 |
+ tree.selectSafeNode(parentNode);
|
|
| 63 | 63 |
} else {
|
| 64 | 64 |
ui.resetEdit();
|
| 65 | 65 |
}
|
| ... | ... | @@ -79,7 +79,7 @@ public class SelectNodeUIAction extends AbstractContentUIAction { |
| 79 | 79 |
NavigationTreeNodeSupport selectedNode = tree.getSelectedNode();
|
| 80 | 80 |
NavigationTreeNodeSupport nodeToSelect = tree.getChild(selectedNode, dataReference.getId());
|
| 81 | 81 |
|
| 82 |
- SwingUtilities.invokeLater(() -> tree.selectNode(nodeToSelect));
|
|
| 82 |
+ SwingUtilities.invokeLater(() -> tree.selectSafeNode(nodeToSelect));
|
|
| 83 | 83 |
return;
|
| 84 | 84 |
}
|
| 85 | 85 |
|
| ... | ... | @@ -92,6 +92,6 @@ public class SelectNodeUIAction extends AbstractContentUIAction { |
| 92 | 92 |
NavigationTreeNodeSupport node = (NavigationTreeNodeSupport) source.getClientProperty(NODE);
|
| 93 | 93 |
Objects.requireNonNull(node);
|
| 94 | 94 |
|
| 95 |
- SwingUtilities.invokeLater(() -> getMainUI().getNavigationUI().getTree().selectNode(node));
|
|
| 95 |
+ SwingUtilities.invokeLater(() -> getMainUI().getNavigationUI().getTree().selectSafeNode(node));
|
|
| 96 | 96 |
}
|
| 97 | 97 |
}
|
| ... | ... | @@ -58,7 +58,7 @@ public class SelectOpenNodeUIAction extends AbstractContentUIAction { |
| 58 | 58 |
|
| 59 | 59 |
NavigationTreeNodeSupport<?> node = contentListUI.getOpenNode();
|
| 60 | 60 |
NavigationTree tree = getNavigationTree();
|
| 61 |
- tree.selectNode(node);
|
|
| 61 |
+ tree.selectSafeNode(node);
|
|
| 62 | 62 |
|
| 63 | 63 |
}
|
| 64 | 64 |
|
| ... | ... | @@ -658,13 +658,11 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U |
| 658 | 658 |
String id = entity.getId();
|
| 659 | 659 |
NavigationTreeNodeSupport node = treeHelper.getChild(parentNode, id);
|
| 660 | 660 |
log.debug("will go to node " + node + " for " + id);
|
| 661 |
- treeHelper.selectNode(node);
|
|
| 661 |
+ treeHelper.selectSafeNode(node);
|
|
| 662 | 662 |
}
|
| 663 | 663 |
|
| 664 | 664 |
public void openLink(String url) {
|
| 665 |
- |
|
| 666 | 665 |
try {
|
| 667 |
- |
|
| 668 | 666 |
UIHelper.openLink(url);
|
| 669 | 667 |
} catch (Exception e) {
|
| 670 | 668 |
UIHelper.handlingError(e);
|
| ... | ... | @@ -683,13 +681,13 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U |
| 683 | 681 |
|
| 684 | 682 |
}
|
| 685 | 683 |
|
| 686 |
- public <F extends IdDto> void loadReferentialReferenceSetsInModel(FormDefinition<F> formDefinition) {
|
|
| 684 |
+ public <D extends IdDto> void loadReferentialReferenceSetsInModel(FormDefinition<D> formDefinition) {
|
|
| 687 | 685 |
loadReferentialReferenceSetsInModel(formDefinition, true);
|
| 688 | 686 |
}
|
| 689 | 687 |
|
| 690 |
- protected <F extends IdDto> void loadReferentialReferenceSetsInModel(FormDefinition<F> formDefinition, boolean clear) {
|
|
| 688 |
+ protected <D extends IdDto> void loadReferentialReferenceSetsInModel(FormDefinition<D> formDefinition, boolean clear) {
|
|
| 691 | 689 |
|
| 692 |
- Class<F> dtoType = formDefinition.getType();
|
|
| 690 |
+ Class<D> dtoType = formDefinition.getType();
|
|
| 693 | 691 |
|
| 694 | 692 |
ImmutableMap.Builder<String, ReferentialDtoReferenceSet<?>> modelReferentialReferenceSets = ImmutableMap.builder();
|
| 695 | 693 |
|
| ... | ... | @@ -808,7 +806,7 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U |
| 808 | 806 |
if (parentNode != null) {
|
| 809 | 807 |
// node still attached, so remove it
|
| 810 | 808 |
treehelper.removeNode(node);
|
| 811 |
- treehelper.selectNode(parentNode);
|
|
| 809 |
+ treehelper.selectSafeNode(parentNode);
|
|
| 812 | 810 |
}
|
| 813 | 811 |
}
|
| 814 | 812 |
|
| ... | ... | @@ -831,7 +829,7 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U |
| 831 | 829 |
NavigationTreeNodeSupport node = treeHelper.getSelectedNode();
|
| 832 | 830 |
NavigationTreeNodeSupport parentNode = node.getParent();
|
| 833 | 831 |
treeHelper.removeNode(node);
|
| 834 |
- treeHelper.selectNode(parentNode);
|
|
| 832 |
+ treeHelper.selectSafeNode(parentNode);
|
|
| 835 | 833 |
}
|
| 836 | 834 |
}
|
| 837 | 835 |
|
| ... | ... | @@ -29,6 +29,7 @@ import fr.ird.observe.client.ui.content.ContentMode; |
| 29 | 29 |
import fr.ird.observe.client.ui.content.ContentUIModel;
|
| 30 | 30 |
import fr.ird.observe.client.ui.content.ObserveLayoutFocusTraversalPolicy;
|
| 31 | 31 |
import fr.ird.observe.client.ui.content.open.ContentOpenableUIHandler;
|
| 32 |
+import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 32 | 33 |
import fr.ird.observe.client.validation.ClientValidationContext;
|
| 33 | 34 |
import fr.ird.observe.dto.data.longline.ActivityLonglineDto;
|
| 34 | 35 |
import fr.ird.observe.dto.data.longline.ActivityLonglineHelper;
|
| ... | ... | @@ -36,8 +37,8 @@ import fr.ird.observe.dto.data.longline.TripLonglineDto; |
| 36 | 37 |
import fr.ird.observe.dto.form.Form;
|
| 37 | 38 |
import fr.ird.observe.dto.reference.DataDtoReference;
|
| 38 | 39 |
import fr.ird.observe.dto.result.TripChildSaveResultDto;
|
| 39 |
-import org.apache.logging.log4j.Logger;
|
|
| 40 | 40 |
import org.apache.logging.log4j.LogManager;
|
| 41 |
+import org.apache.logging.log4j.Logger;
|
|
| 41 | 42 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 42 | 43 |
import org.nuiton.validator.NuitonValidatorScope;
|
| 43 | 44 |
|
| ... | ... | @@ -254,9 +255,7 @@ class ActivityLonglineUIHandler extends ContentOpenableUIHandler<ActivityLonglin |
| 254 | 255 |
}
|
| 255 | 256 |
|
| 256 | 257 |
@Override
|
| 257 |
- protected boolean doSave(ActivityLonglineDto bean) {
|
|
| 258 |
- |
|
| 259 |
- boolean notPersisted = bean.isNotPersisted();
|
|
| 258 |
+ protected boolean doSave(ActivityLonglineDto bean, boolean notPersisted) {
|
|
| 260 | 259 |
|
| 261 | 260 |
String tripId = getSelectedParentId();
|
| 262 | 261 |
|
| ... | ... | @@ -270,15 +269,23 @@ class ActivityLonglineUIHandler extends ContentOpenableUIHandler<ActivityLonglin |
| 270 | 269 |
if (notPersisted) {
|
| 271 | 270 |
// ouverture de l'activité après création
|
| 272 | 271 |
getOpenDataManager().openActivityLongline(getSelectedParentId(), bean.getId(), null);
|
| 272 |
+ }
|
|
| 273 |
+ |
|
| 274 |
+ return true;
|
|
| 275 |
+ }
|
|
| 276 |
+ |
|
| 277 |
+ @Override
|
|
| 278 |
+ protected void afterSave(ActivityLonglineDto bean, NavigationTreeNodeSupport node, boolean notPersisted) {
|
|
| 279 |
+ repaintTripNode();
|
|
| 280 |
+ if (notPersisted) {
|
|
| 273 | 281 |
|
| 274 | 282 |
if (ActivityLonglineHelper.FISHING_OPERATION_ID.equals(bean.getVesselActivityLongline().getId())) {
|
| 275 | 283 |
|
| 276 |
- // création de l'opération de pêche
|
|
| 277 |
- SwingUtilities.invokeLater(() -> getUi().getAddSet().doClick());
|
|
| 284 |
+ // création de l'opération de pêche (sur le nouvel écran car l'action n'est pas accessible sur l'ancien écran)
|
|
| 285 |
+ ActivityLonglineUI content = ObserveSwingApplicationContext.get().getContentUIManager().getContent();
|
|
| 286 |
+ SwingUtilities.invokeLater(() -> content.getAddSet().doClick());
|
|
| 278 | 287 |
}
|
| 279 | 288 |
}
|
| 280 |
- |
|
| 281 |
- return true;
|
|
| 282 | 289 |
}
|
| 283 | 290 |
|
| 284 | 291 |
@Override
|
| ... | ... | @@ -305,13 +312,6 @@ class ActivityLonglineUIHandler extends ContentOpenableUIHandler<ActivityLonglin |
| 305 | 312 |
|
| 306 | 313 |
setUpdateMareeNodeTag(wasTripEndDateUpdated);
|
| 307 | 314 |
return true;
|
| 308 |
- |
|
| 309 |
- }
|
|
| 310 |
- |
|
| 311 |
- @Override
|
|
| 312 |
- protected void afterSave(boolean refresh) {
|
|
| 313 |
- super.afterSave(refresh);
|
|
| 314 |
- repaintTripNode();
|
|
| 315 | 315 |
}
|
| 316 | 316 |
|
| 317 | 317 |
@Override
|
| ... | ... | @@ -40,8 +40,8 @@ import fr.ird.observe.dto.data.longline.SetLonglineReference; |
| 40 | 40 |
import fr.ird.observe.dto.form.Form;
|
| 41 | 41 |
import fr.ird.observe.dto.result.SaveResultDto;
|
| 42 | 42 |
import fr.ird.observe.spi.DtoModelHelper;
|
| 43 |
-import org.apache.logging.log4j.Logger;
|
|
| 44 | 43 |
import org.apache.logging.log4j.LogManager;
|
| 44 |
+import org.apache.logging.log4j.Logger;
|
|
| 45 | 45 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 46 | 46 |
import org.nuiton.jaxx.validator.swing.SwingValidatorMessage;
|
| 47 | 47 |
import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel;
|
| ... | ... | @@ -380,7 +380,7 @@ public class SetLonglineUIHandler extends ContentUIHandler<SetLonglineDto, SetLo |
| 380 | 380 |
node = treeHelper.addSetLongline(parentNode, reference);
|
| 381 | 381 |
|
| 382 | 382 |
stopEditUI();
|
| 383 |
- treeHelper.selectNode(node);
|
|
| 383 |
+ treeHelper.selectSafeNode(node);
|
|
| 384 | 384 |
|
| 385 | 385 |
} else {
|
| 386 | 386 |
|
| ... | ... | @@ -30,6 +30,7 @@ import fr.ird.observe.client.ui.content.ContentMode; |
| 30 | 30 |
import fr.ird.observe.client.ui.content.ObserveLayoutFocusTraversalPolicy;
|
| 31 | 31 |
import fr.ird.observe.client.ui.content.open.ContentOpenableUIHandler;
|
| 32 | 32 |
import fr.ird.observe.client.ui.content.open.ContentOpenableUIModel;
|
| 33 |
+import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 33 | 34 |
import fr.ird.observe.client.ui.util.tripMap.TripMapUI;
|
| 34 | 35 |
import fr.ird.observe.dto.data.TripMapDto;
|
| 35 | 36 |
import fr.ird.observe.dto.data.longline.TripLonglineDto;
|
| ... | ... | @@ -43,8 +44,8 @@ import fr.ird.observe.dto.referential.VesselDto; |
| 43 | 44 |
import fr.ird.observe.dto.referential.VesselHelper;
|
| 44 | 45 |
import fr.ird.observe.dto.referential.VesselReference;
|
| 45 | 46 |
import fr.ird.observe.dto.result.SaveResultDto;
|
| 46 |
-import org.apache.logging.log4j.Logger;
|
|
| 47 | 47 |
import org.apache.logging.log4j.LogManager;
|
| 48 |
+import org.apache.logging.log4j.Logger;
|
|
| 48 | 49 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 49 | 50 |
import org.nuiton.util.DateUtil;
|
| 50 | 51 |
|
| ... | ... | @@ -278,9 +279,7 @@ class TripLonglineUIHandler extends ContentOpenableUIHandler<TripLonglineDto, Tr |
| 278 | 279 |
}
|
| 279 | 280 |
|
| 280 | 281 |
@Override
|
| 281 |
- protected boolean doSave(TripLonglineDto bean) {
|
|
| 282 |
- |
|
| 283 |
- boolean notPersisted = bean.isNotPersisted();
|
|
| 282 |
+ protected boolean doSave(TripLonglineDto bean, boolean notPersisted) {
|
|
| 284 | 283 |
|
| 285 | 284 |
// on force toujours la date a etre sans heure, minute,...
|
| 286 | 285 |
Date startDate = DateUtil.getDay(bean.getStartDate());
|
| ... | ... | @@ -308,8 +307,11 @@ class TripLonglineUIHandler extends ContentOpenableUIHandler<TripLonglineDto, Tr |
| 308 | 307 |
}
|
| 309 | 308 |
|
| 310 | 309 |
@Override
|
| 311 |
- protected int getOpenablePosition(String parentId, TripLonglineDto bean) {
|
|
| 310 |
+ protected void afterSave(TripLonglineDto bean, NavigationTreeNodeSupport node, boolean notPersisted) {
|
|
| 311 |
+ }
|
|
| 312 | 312 |
|
| 313 |
+ @Override
|
|
| 314 |
+ protected int getOpenablePosition(String parentId, TripLonglineDto bean) {
|
|
| 313 | 315 |
return getTripLonglineService().getTripLonglinePositionInProgram(parentId, bean.getId());
|
| 314 | 316 |
}
|
| 315 | 317 |
|
| ... | ... | @@ -28,6 +28,7 @@ import fr.ird.observe.client.ui.content.ContentMode; |
| 28 | 28 |
import fr.ird.observe.client.ui.content.ContentUIModel;
|
| 29 | 29 |
import fr.ird.observe.client.ui.content.ObserveLayoutFocusTraversalPolicy;
|
| 30 | 30 |
import fr.ird.observe.client.ui.content.open.ContentOpenableUIHandler;
|
| 31 |
+import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 31 | 32 |
import fr.ird.observe.client.validation.ClientValidationContext;
|
| 32 | 33 |
import fr.ird.observe.dto.data.seine.ActivitySeineDto;
|
| 33 | 34 |
import fr.ird.observe.dto.data.seine.ActivitySeineHelper;
|
| ... | ... | @@ -38,8 +39,8 @@ import fr.ird.observe.dto.reference.DataDtoReference; |
| 38 | 39 |
import fr.ird.observe.dto.referential.seine.VesselActivitySeineHelper;
|
| 39 | 40 |
import fr.ird.observe.dto.referential.seine.VesselActivitySeineReference;
|
| 40 | 41 |
import fr.ird.observe.dto.result.SaveResultDto;
|
| 41 |
-import org.apache.logging.log4j.Logger;
|
|
| 42 | 42 |
import org.apache.logging.log4j.LogManager;
|
| 43 |
+import org.apache.logging.log4j.Logger;
|
|
| 43 | 44 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 44 | 45 |
import org.nuiton.jaxx.validator.swing.SwingValidatorMessage;
|
| 45 | 46 |
import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel;
|
| ... | ... | @@ -82,35 +83,6 @@ class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySeineDto, |
| 82 | 83 |
};
|
| 83 | 84 |
}
|
| 84 | 85 |
|
| 85 |
- @Override
|
|
| 86 |
- protected void prepareValidationContext() {
|
|
| 87 |
- super.prepareValidationContext();
|
|
| 88 |
- |
|
| 89 |
- ClientValidationContext validationContext = ObserveSwingApplicationContext.get().getValidationContext();
|
|
| 90 |
- validationContext.setCoordinatesEditor("coordinate", getUi().getCoordinatesEditor());
|
|
| 91 |
- |
|
| 92 |
- }
|
|
| 93 |
- |
|
| 94 |
- @Override
|
|
| 95 |
- protected boolean doOpenData() {
|
|
| 96 |
- boolean result = getOpenDataManager().canOpenActivitySeine(getSelectedParentId());
|
|
| 97 |
- if (result) {
|
|
| 98 |
- String setSeineId = Optional.ofNullable(getBean().getSetSeine()).map(DataDtoReference::getId).orElse(null);
|
|
| 99 |
- |
|
| 100 |
- getOpenDataManager().openActivitySeine(getSelectedParentId(), getSelectedId(), setSeineId);
|
|
| 101 |
- }
|
|
| 102 |
- return result;
|
|
| 103 |
- }
|
|
| 104 |
- |
|
| 105 |
- @Override
|
|
| 106 |
- public boolean doCloseData() {
|
|
| 107 |
- boolean result = getOpenDataManager().isOpenActivitySeine(getSelectedId());
|
|
| 108 |
- if (result) {
|
|
| 109 |
- getOpenDataManager().closeActivitySeine(getSelectedId());
|
|
| 110 |
- }
|
|
| 111 |
- return result;
|
|
| 112 |
- }
|
|
| 113 |
- |
|
| 114 | 86 |
@Override
|
| 115 | 87 |
protected ContentMode getContentMode(ClientDataContext dataContext) {
|
| 116 | 88 |
|
| ... | ... | @@ -163,38 +135,32 @@ class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySeineDto, |
| 163 | 135 |
}
|
| 164 | 136 |
|
| 165 | 137 |
@Override
|
| 166 |
- protected ObserveLayoutFocusTraversalPolicy<ActivitySeineUI> creatFocusTraversalPolicy() {
|
|
| 167 |
- return new ObserveLayoutFocusTraversalPolicy<ActivitySeineUI>() {
|
|
| 138 |
+ protected void prepareValidationContext() {
|
|
| 139 |
+ super.prepareValidationContext();
|
|
| 168 | 140 |
|
| 169 |
- @Override
|
|
| 170 |
- protected Component getFirstComponentForEdit(Container aContainer) {
|
|
| 171 |
- ActivitySeineUI ui = getUi();
|
|
| 172 |
- int selectedIndex = ui.getMainTabbedPane().getSelectedIndex();
|
|
| 173 |
- switch (selectedIndex) {
|
|
| 174 |
- case 0:
|
|
| 175 |
- JComponent editor = ui.getTime().getHourEditor().getEditor();
|
|
| 176 |
- return ((JSpinner.DateEditor) editor).getTextField();
|
|
| 177 |
- case 1:
|
|
| 178 |
- return ui.getVesselSpeed();
|
|
| 179 |
- case 2:
|
|
| 180 |
- return ui.getObservedSystem().getUniverseList();
|
|
| 181 |
- }
|
|
| 182 |
- return super.getFirstComponent(aContainer);
|
|
| 183 |
- }
|
|
| 141 |
+ ClientValidationContext validationContext = ObserveSwingApplicationContext.get().getValidationContext();
|
|
| 142 |
+ validationContext.setCoordinatesEditor("coordinate", getUi().getCoordinatesEditor());
|
|
| 184 | 143 |
|
| 185 |
- @Override
|
|
| 186 |
- protected Component getLastComponentForEdit(Container aContainer) {
|
|
| 187 |
- ActivitySeineUI ui = getUi();
|
|
| 188 |
- if (ui.getModel().isCreatingMode()) {
|
|
| 189 |
- if (ui.getSave().isEnabled()) {
|
|
| 190 |
- return ui.getSave();
|
|
| 191 |
- }
|
|
| 192 |
- return ui.getReset();
|
|
| 193 |
- } else
|
|
| 194 |
- return ui.getCloseAndCreate();
|
|
| 195 |
- }
|
|
| 144 |
+ }
|
|
| 196 | 145 |
|
| 197 |
- };
|
|
| 146 |
+ @Override
|
|
| 147 |
+ protected boolean doOpenData() {
|
|
| 148 |
+ boolean result = getOpenDataManager().canOpenActivitySeine(getSelectedParentId());
|
|
| 149 |
+ if (result) {
|
|
| 150 |
+ String setSeineId = Optional.ofNullable(getBean().getSetSeine()).map(DataDtoReference::getId).orElse(null);
|
|
| 151 |
+ |
|
| 152 |
+ getOpenDataManager().openActivitySeine(getSelectedParentId(), getSelectedId(), setSeineId);
|
|
| 153 |
+ }
|
|
| 154 |
+ return result;
|
|
| 155 |
+ }
|
|
| 156 |
+ |
|
| 157 |
+ @Override
|
|
| 158 |
+ public boolean doCloseData() {
|
|
| 159 |
+ boolean result = getOpenDataManager().isOpenActivitySeine(getSelectedId());
|
|
| 160 |
+ if (result) {
|
|
| 161 |
+ getOpenDataManager().closeActivitySeine(getSelectedId());
|
|
| 162 |
+ }
|
|
| 163 |
+ return result;
|
|
| 198 | 164 |
}
|
| 199 | 165 |
|
| 200 | 166 |
@Override
|
| ... | ... | @@ -319,9 +285,42 @@ class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySeineDto, |
| 319 | 285 |
}
|
| 320 | 286 |
|
| 321 | 287 |
@Override
|
| 322 |
- protected boolean doSave(ActivitySeineDto bean) {
|
|
| 288 |
+ protected ObserveLayoutFocusTraversalPolicy<ActivitySeineUI> creatFocusTraversalPolicy() {
|
|
| 289 |
+ return new ObserveLayoutFocusTraversalPolicy<ActivitySeineUI>() {
|
|
| 323 | 290 |
|
| 324 |
- boolean notPersisted = bean.isNotPersisted();
|
|
| 291 |
+ @Override
|
|
| 292 |
+ protected Component getFirstComponentForEdit(Container aContainer) {
|
|
| 293 |
+ ActivitySeineUI ui = getUi();
|
|
| 294 |
+ int selectedIndex = ui.getMainTabbedPane().getSelectedIndex();
|
|
| 295 |
+ switch (selectedIndex) {
|
|
| 296 |
+ case 0:
|
|
| 297 |
+ JComponent editor = ui.getTime().getHourEditor().getEditor();
|
|
| 298 |
+ return ((JSpinner.DateEditor) editor).getTextField();
|
|
| 299 |
+ case 1:
|
|
| 300 |
+ return ui.getVesselSpeed();
|
|
| 301 |
+ case 2:
|
|
| 302 |
+ return ui.getObservedSystem().getUniverseList();
|
|
| 303 |
+ }
|
|
| 304 |
+ return super.getFirstComponent(aContainer);
|
|
| 305 |
+ }
|
|
| 306 |
+ |
|
| 307 |
+ @Override
|
|
| 308 |
+ protected Component getLastComponentForEdit(Container aContainer) {
|
|
| 309 |
+ ActivitySeineUI ui = getUi();
|
|
| 310 |
+ if (ui.getModel().isCreatingMode()) {
|
|
| 311 |
+ if (ui.getSave().isEnabled()) {
|
|
| 312 |
+ return ui.getSave();
|
|
| 313 |
+ }
|
|
| 314 |
+ return ui.getReset();
|
|
| 315 |
+ } else
|
|
| 316 |
+ return ui.getCloseAndCreate();
|
|
| 317 |
+ }
|
|
| 318 |
+ |
|
| 319 |
+ };
|
|
| 320 |
+ }
|
|
| 321 |
+ |
|
| 322 |
+ @Override
|
|
| 323 |
+ protected boolean doSave(ActivitySeineDto bean, boolean notPersisted) {
|
|
| 325 | 324 |
|
| 326 | 325 |
String routeId = getSelectedParentId();
|
| 327 | 326 |
|
| ... | ... | @@ -335,17 +334,22 @@ class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySeineDto, |
| 335 | 334 |
if (notPersisted) {
|
| 336 | 335 |
// ouverture de l'activité après création
|
| 337 | 336 |
getOpenDataManager().openActivitySeine(getSelectedParentId(), bean.getId(), null);
|
| 338 |
- |
|
| 339 |
- if (bean.getReasonForNoFishing() == null) {
|
|
| 340 |
- // création de l'opération de pêche
|
|
| 341 |
- SwingUtilities.invokeLater(() -> getUi().getAddSet().doClick());
|
|
| 342 |
- }
|
|
| 343 |
- |
|
| 344 | 337 |
}
|
| 345 | 338 |
|
| 346 | 339 |
return true;
|
| 347 | 340 |
}
|
| 348 | 341 |
|
| 342 |
+ @Override
|
|
| 343 |
+ protected void afterSave(ActivitySeineDto bean, NavigationTreeNodeSupport node, boolean notPersisted) {
|
|
| 344 |
+ if (notPersisted) {
|
|
| 345 |
+ if (bean.isSetOperation() && bean.getReasonForNoFishing() == null) {
|
|
| 346 |
+ // create set
|
|
| 347 |
+ ActivitySeineUI content = ObserveSwingApplicationContext.get().getContentUIManager().getContent();
|
|
| 348 |
+ SwingUtilities.invokeLater(() -> content.getAddSet().doClick());
|
|
| 349 |
+ }
|
|
| 350 |
+ }
|
|
| 351 |
+ }
|
|
| 352 |
+ |
|
| 349 | 353 |
@Override
|
| 350 | 354 |
protected int getOpenablePosition(String parentId, ActivitySeineDto bean) {
|
| 351 | 355 |
return getActivitySeineService().getActivitySeinePositionInRoute(parentId, bean.getId());
|
| ... | ... | @@ -264,7 +264,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, |
| 264 | 264 |
node = treeHelper.addFloatingObject(parentNode, reference);
|
| 265 | 265 |
stopEditUI();
|
| 266 | 266 |
if (refresh) {
|
| 267 |
- treeHelper.selectNode(node);
|
|
| 267 |
+ treeHelper.selectSafeNode(node);
|
|
| 268 | 268 |
}
|
| 269 | 269 |
} else {
|
| 270 | 270 |
|
| ... | ... | @@ -38,8 +38,8 @@ import fr.ird.observe.dto.form.Form; |
| 38 | 38 |
import fr.ird.observe.dto.referential.seine.VesselActivitySeineHelper;
|
| 39 | 39 |
import fr.ird.observe.dto.referential.seine.VesselActivitySeineReference;
|
| 40 | 40 |
import fr.ird.observe.dto.result.TripChildSaveResultDto;
|
| 41 |
-import org.apache.logging.log4j.Logger;
|
|
| 42 | 41 |
import org.apache.logging.log4j.LogManager;
|
| 42 |
+import org.apache.logging.log4j.Logger;
|
|
| 43 | 43 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 44 | 44 |
import org.nuiton.util.DateUtil;
|
| 45 | 45 |
import org.nuiton.validator.NuitonValidatorScope;
|
| ... | ... | @@ -185,9 +185,7 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme |
| 185 | 185 |
}
|
| 186 | 186 |
|
| 187 | 187 |
@Override
|
| 188 |
- protected boolean doSave(RouteDto bean) {
|
|
| 189 |
- |
|
| 190 |
- boolean notPersisted = bean.isNotPersisted();
|
|
| 188 |
+ protected boolean doSave(RouteDto bean, boolean notPersisted) {
|
|
| 191 | 189 |
|
| 192 | 190 |
String tripId = getSelectedParentId();
|
| 193 | 191 |
|
| ... | ... | @@ -217,14 +215,13 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme |
| 217 | 215 |
}
|
| 218 | 216 |
|
| 219 | 217 |
@Override
|
| 220 |
- protected int getOpenablePosition(String parentId, RouteDto bean) {
|
|
| 221 |
- return getRouteService().getRoutePositionInTripSeine(parentId, bean.getId());
|
|
| 218 |
+ protected void afterSave(RouteDto bean, NavigationTreeNodeSupport node, boolean notPersisted) {
|
|
| 219 |
+ repaintTripNode();
|
|
| 222 | 220 |
}
|
| 223 | 221 |
|
| 224 | 222 |
@Override
|
| 225 |
- protected void afterSave(boolean refresh) {
|
|
| 226 |
- super.afterSave(refresh);
|
|
| 227 |
- repaintTripNode();
|
|
| 223 |
+ protected int getOpenablePosition(String parentId, RouteDto bean) {
|
|
| 224 |
+ return getRouteService().getRoutePositionInTripSeine(parentId, bean.getId());
|
|
| 228 | 225 |
}
|
| 229 | 226 |
|
| 230 | 227 |
@Override
|
| ... | ... | @@ -347,7 +344,7 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme |
| 347 | 344 |
log.debug("PARENT NODE = " + parentNode);
|
| 348 | 345 |
// select activities node before adding new node, otherwise, the new unsaved activity node may no more be selected
|
| 349 | 346 |
// at the end of addUnsavedNode method (reloading sub node will empty selection...)
|
| 350 |
- treeHelper.selectNode(parentNode);
|
|
| 347 |
+ treeHelper.selectSafeNode(parentNode);
|
|
| 351 | 348 |
treeHelper.addUnsavedNode(parentNode, ActivitySeineDto.class);
|
| 352 | 349 |
|
| 353 | 350 |
// on recupère l'écran d'édition
|
| ... | ... | @@ -40,8 +40,8 @@ import fr.ird.observe.dto.data.seine.SetSeineReference; |
| 40 | 40 |
import fr.ird.observe.dto.form.Form;
|
| 41 | 41 |
import fr.ird.observe.dto.result.SaveResultDto;
|
| 42 | 42 |
import fr.ird.observe.spi.DtoModelHelper;
|
| 43 |
-import org.apache.logging.log4j.Logger;
|
|
| 44 | 43 |
import org.apache.logging.log4j.LogManager;
|
| 44 |
+import org.apache.logging.log4j.Logger;
|
|
| 45 | 45 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 46 | 46 |
import org.nuiton.jaxx.validator.swing.SwingValidatorMessage;
|
| 47 | 47 |
import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel;
|
| ... | ... | @@ -275,7 +275,7 @@ public class SetSeineUIHandler extends ContentUIHandler<SetSeineDto, SetSeineUI> |
| 275 | 275 |
node = treeHelper.addSetSeine(parentNode, reference);
|
| 276 | 276 |
|
| 277 | 277 |
stopEditUI();
|
| 278 |
- treeHelper.selectNode(node);
|
|
| 278 |
+ treeHelper.selectSafeNode(node);
|
|
| 279 | 279 |
} else {
|
| 280 | 280 |
// select ancestor node
|
| 281 | 281 |
// treeHelper.refreshNode(node, false);
|
| ... | ... | @@ -29,6 +29,7 @@ import fr.ird.observe.client.ui.content.ContentMode; |
| 29 | 29 |
import fr.ird.observe.client.ui.content.ObserveLayoutFocusTraversalPolicy;
|
| 30 | 30 |
import fr.ird.observe.client.ui.content.open.ContentOpenableUIHandler;
|
| 31 | 31 |
import fr.ird.observe.client.ui.content.open.ContentOpenableUIModel;
|
| 32 |
+import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 32 | 33 |
import fr.ird.observe.client.ui.util.tripMap.TripMapUI;
|
| 33 | 34 |
import fr.ird.observe.dto.data.TripMapDto;
|
| 34 | 35 |
import fr.ird.observe.dto.data.seine.TripSeineDto;
|
| ... | ... | @@ -42,8 +43,8 @@ import fr.ird.observe.dto.referential.VesselDto; |
| 42 | 43 |
import fr.ird.observe.dto.referential.VesselHelper;
|
| 43 | 44 |
import fr.ird.observe.dto.referential.VesselReference;
|
| 44 | 45 |
import fr.ird.observe.dto.result.SaveResultDto;
|
| 45 |
-import org.apache.logging.log4j.Logger;
|
|
| 46 | 46 |
import org.apache.logging.log4j.LogManager;
|
| 47 |
+import org.apache.logging.log4j.Logger;
|
|
| 47 | 48 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 48 | 49 |
import org.nuiton.util.DateUtil;
|
| 49 | 50 |
|
| ... | ... | @@ -273,9 +274,7 @@ class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeineDto, TripSein |
| 273 | 274 |
}
|
| 274 | 275 |
|
| 275 | 276 |
@Override
|
| 276 |
- protected boolean doSave(TripSeineDto bean) {
|
|
| 277 |
- |
|
| 278 |
- boolean notPersisted = bean.isNotPersisted();
|
|
| 277 |
+ protected boolean doSave(TripSeineDto bean, boolean notPersisted) {
|
|
| 279 | 278 |
|
| 280 | 279 |
// on force toujours la date a etre sans heure, minute,...
|
| 281 | 280 |
Date startDate = DateUtil.getDay(bean.getStartDate());
|
| ... | ... | @@ -303,8 +302,12 @@ class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeineDto, TripSein |
| 303 | 302 |
return true;
|
| 304 | 303 |
}
|
| 305 | 304 |
|
| 306 |
- protected int getOpenablePosition(String parentId, TripSeineDto bean) {
|
|
| 305 |
+ @Override
|
|
| 306 |
+ protected void afterSave(TripSeineDto bean, NavigationTreeNodeSupport node, boolean notPersisted) {
|
|
| 307 |
+ |
|
| 308 |
+ }
|
|
| 307 | 309 |
|
| 310 |
+ protected int getOpenablePosition(String parentId, TripSeineDto bean) {
|
|
| 308 | 311 |
return getTripSeineService().getTripSeinePositionInProgram(parentId, bean.getId());
|
| 309 | 312 |
}
|
| 310 | 313 |
|
| ... | ... | @@ -8,12 +8,12 @@ |
| 8 | 8 |
* it under the terms of the GNU General Public License as
|
| 9 | 9 |
* published by the Free Software Foundation, either version 3 of the
|
| 10 | 10 |
* License, or (at your option) any later version.
|
| 11 |
- *
|
|
| 11 |
+ *
|
|
| 12 | 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 | 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 15 |
* GNU General Public License for more details.
|
| 16 |
- *
|
|
| 16 |
+ *
|
|
| 17 | 17 |
* You should have received a copy of the GNU General Public
|
| 18 | 18 |
* License along with this program. If not, see
|
| 19 | 19 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| ... | ... | @@ -50,10 +50,10 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont |
| 50 | 50 |
|
| 51 | 51 |
private static final String POSITION_OPENABLE = "positionOpenable";
|
| 52 | 52 |
|
| 53 |
- /** Logger */
|
|
| 54 | 53 |
static private final Logger log = LogManager.getLogger(ContentOpenableUIHandler.class);
|
| 55 | 54 |
private static final String UPDATE_TRIP_NODE = "updateTripNode";
|
| 56 | 55 |
protected final String closeMessage;
|
| 56 |
+ private boolean notPersisted;
|
|
| 57 | 57 |
|
| 58 | 58 |
public ContentOpenableUIHandler(DataContextType parentType, DataContextType type, String closeMessage) {
|
| 59 | 59 |
super(parentType, type);
|
| ... | ... | @@ -62,6 +62,16 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont |
| 62 | 62 |
|
| 63 | 63 |
protected abstract boolean obtainCanReopen(boolean create);
|
| 64 | 64 |
|
| 65 |
+ protected abstract boolean doOpenData();
|
|
| 66 |
+ |
|
| 67 |
+ public abstract boolean doCloseData();
|
|
| 68 |
+ |
|
| 69 |
+ protected abstract boolean doSave(E bean, boolean notPersisted);
|
|
| 70 |
+ |
|
| 71 |
+ protected abstract void afterSave(E bean, NavigationTreeNodeSupport node, boolean notPersisted);
|
|
| 72 |
+ |
|
| 73 |
+ protected abstract int getOpenablePosition(String parentId, E bean);
|
|
| 74 |
+ |
|
| 65 | 75 |
@Override
|
| 66 | 76 |
public ContentOpenableUIModel<E> getModel() {
|
| 67 | 77 |
return (ContentOpenableUIModel<E>) super.getModel();
|
| ... | ... | @@ -72,8 +82,6 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont |
| 72 | 82 |
return source.canWriteData();
|
| 73 | 83 |
}
|
| 74 | 84 |
|
| 75 |
- protected abstract boolean doOpenData();
|
|
| 76 |
- |
|
| 77 | 85 |
public final void openDataUI() {
|
| 78 | 86 |
boolean ok = false;
|
| 79 | 87 |
try {
|
| ... | ... | @@ -132,8 +140,6 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont |
| 132 | 140 |
treeHelper.reloadNode(parent, false);
|
| 133 | 141 |
}
|
| 134 | 142 |
|
| 135 |
- public abstract boolean doCloseData();
|
|
| 136 |
- |
|
| 137 | 143 |
public final void afterCloseData() {
|
| 138 | 144 |
|
| 139 | 145 |
U ui = getUi();
|
| ... | ... | @@ -148,7 +154,7 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont |
| 148 | 154 |
|
| 149 | 155 |
removeAllMessages(ui);
|
| 150 | 156 |
addMessage(ui, NuitonValidatorScope.INFO,
|
| 151 |
- getTypeI18nKey(bean.getClass()), t(closeMessage));
|
|
| 157 |
+ getTypeI18nKey(bean.getClass()), t(closeMessage));
|
|
| 152 | 158 |
|
| 153 | 159 |
NavigationTree treeHelper = getNavigationTree();
|
| 154 | 160 |
treeHelper.reloadSelectedNode(bean instanceof TripSeineDto || bean instanceof TripLonglineDto, true);
|
| ... | ... | @@ -157,8 +163,13 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont |
| 157 | 163 |
grabFocusOnForm();
|
| 158 | 164 |
}
|
| 159 | 165 |
|
| 166 |
+ protected final boolean doSave(E bean) {
|
|
| 167 |
+ notPersisted = bean.isNotPersisted();
|
|
| 168 |
+ return doSave(bean, notPersisted);
|
|
| 169 |
+ }
|
|
| 170 |
+ |
|
| 160 | 171 |
@Override
|
| 161 |
- protected void afterSave(boolean refresh) {
|
|
| 172 |
+ protected final void afterSave(boolean refresh) {
|
|
| 162 | 173 |
|
| 163 | 174 |
super.afterSave(refresh);
|
| 164 | 175 |
|
| ... | ... | @@ -210,7 +221,7 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont |
| 210 | 221 |
}
|
| 211 | 222 |
|
| 212 | 223 |
// on sélectionne le nouveau noeud
|
| 213 |
- treeHelper.selectNode(node);
|
|
| 224 |
+ treeHelper.selectSafeNode(node);
|
|
| 214 | 225 |
} else {
|
| 215 | 226 |
if (oldPosition != position) {
|
| 216 | 227 |
|
| ... | ... | @@ -218,7 +229,7 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont |
| 218 | 229 |
treeHelper.moveNode(parentNode, node, position);
|
| 219 | 230 |
|
| 220 | 231 |
// et le selectionner
|
| 221 |
- treeHelper.selectNode(node);
|
|
| 232 |
+ treeHelper.selectSafeNode(node);
|
|
| 222 | 233 |
}
|
| 223 | 234 |
|
| 224 | 235 |
node.reload();
|
| ... | ... | @@ -229,6 +240,7 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont |
| 229 | 240 |
// on repaint le noeud et ses enfants
|
| 230 | 241 |
treeHelper.reloadSelectedNode(false, true);
|
| 231 | 242 |
}
|
| 243 |
+ afterSave(bean, node, notPersisted);
|
|
| 232 | 244 |
}
|
| 233 | 245 |
|
| 234 | 246 |
/**
|
| ... | ... | @@ -271,8 +283,6 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont |
| 271 | 283 |
getUi().setContextValue(position, POSITION_OPENABLE);
|
| 272 | 284 |
}
|
| 273 | 285 |
|
| 274 |
- protected abstract int getOpenablePosition(String parentId, E bean);
|
|
| 275 |
- |
|
| 276 | 286 |
protected final void finalizeOpenUI(ContentMode mode, boolean create) {
|
| 277 | 287 |
|
| 278 | 288 |
boolean historicalData = false;
|
| ... | ... | @@ -37,7 +37,6 @@ import org.nuiton.jaxx.runtime.spi.UIHandler; |
| 37 | 37 |
|
| 38 | 38 |
import javax.swing.JButton;
|
| 39 | 39 |
import javax.swing.JPanel;
|
| 40 |
- |
|
| 41 | 40 |
import java.awt.Component;
|
| 42 | 41 |
import java.awt.Container;
|
| 43 | 42 |
|
| ... | ... | @@ -95,7 +94,7 @@ public class ReferenceHomeUIHandler extends ContentUIHandler<ProgramDto, Referen |
| 95 | 94 |
|
| 96 | 95 |
String text = t(ObserveI18nDecoratorHelper.getTypePluralI18nKey(type));
|
| 97 | 96 |
JButton button = new JButton(text);
|
| 98 |
- button.addActionListener(e -> navigation.selectNode(referentialNode.findChildByClass(type)));
|
|
| 97 |
+ button.addActionListener(e -> navigation.selectSafeNode(referentialNode.findChildByClass(type)));
|
|
| 99 | 98 |
panel.add(button);
|
| 100 | 99 |
|
| 101 | 100 |
}
|
| ... | ... | @@ -64,8 +64,8 @@ import fr.ird.observe.dto.referential.ProgramReference; |
| 64 | 64 |
import fr.ird.observe.dto.referential.ReferentialLocale;
|
| 65 | 65 |
import fr.ird.observe.spi.DtoModelHelper;
|
| 66 | 66 |
import org.apache.commons.collections4.CollectionUtils;
|
| 67 |
-import org.apache.logging.log4j.Logger;
|
|
| 68 | 67 |
import org.apache.logging.log4j.LogManager;
|
| 68 |
+import org.apache.logging.log4j.Logger;
|
|
| 69 | 69 |
import org.jdesktop.swingx.JXTree;
|
| 70 | 70 |
|
| 71 | 71 |
import javax.swing.SwingUtilities;
|
| ... | ... | @@ -98,7 +98,7 @@ public class NavigationTree extends JXTree { |
| 98 | 98 |
setSelectionModel(new DefaultTreeSelectionModel() {
|
| 99 | 99 |
@Override
|
| 100 | 100 |
public void setSelectionPath(TreePath path) {
|
| 101 |
- boolean canChange = !Objects.equals(path, getSelectionPath()) && ObserveSwingApplicationContext.get().getContentUIManager().closeSelectedContentUI();
|
|
| 101 |
+ boolean canChange = skipCheckPreviousContent || (!Objects.equals(path, getSelectionPath()) && ObserveSwingApplicationContext.get().getContentUIManager().closeSelectedContentUI());
|
|
| 102 | 102 |
if (!canChange) {
|
| 103 | 103 |
// cancel the change of node
|
| 104 | 104 |
return;
|
| ... | ... | @@ -176,6 +176,29 @@ public class NavigationTree extends JXTree { |
| 176 | 176 |
return isSelectionEmpty() ? null : (NavigationTreeNodeSupport) getSelectionPath().getLastPathComponent();
|
| 177 | 177 |
}
|
| 178 | 178 |
|
| 179 |
+ private boolean skipCheckPreviousContent;
|
|
| 180 |
+ |
|
| 181 |
+ /**
|
|
| 182 |
+ * Selects the given {@code node} in the tree without doing any check on previous content loaded.
|
|
| 183 |
+ * <p>
|
|
| 184 |
+ * This method should be used only programmatically.
|
|
| 185 |
+ *
|
|
| 186 |
+ * @param node the node to select
|
|
| 187 |
+ */
|
|
| 188 |
+ public void selectSafeNode(NavigationTreeNodeSupport node) {
|
|
| 189 |
+ if (log.isInfoEnabled()) {
|
|
| 190 |
+ log.info("try to select node [" + node + "]");
|
|
| 191 |
+ }
|
|
| 192 |
+ TreePath path = new TreePath(getTreeModel().getPathToRoot(node));
|
|
| 193 |
+ |
|
| 194 |
+ skipCheckPreviousContent = true;
|
|
| 195 |
+ try {
|
|
| 196 |
+ setSelectionPath(path);
|
|
| 197 |
+ } finally {
|
|
| 198 |
+ skipCheckPreviousContent = false;
|
|
| 199 |
+ }
|
|
| 200 |
+ SwingUtilities.invokeLater(() -> scrollPathToVisible(path));
|
|
| 201 |
+ }
|
|
| 179 | 202 |
/**
|
| 180 | 203 |
* Selects the given {@code node} in the registred tree.
|
| 181 | 204 |
*
|
| ... | ... | @@ -237,7 +260,7 @@ public class NavigationTree extends JXTree { |
| 237 | 260 |
|
| 238 | 261 |
try {
|
| 239 | 262 |
|
| 240 |
- selectNode(selectedNode);
|
|
| 263 |
+ selectSafeNode(selectedNode);
|
|
| 241 | 264 |
} finally {
|
| 242 | 265 |
|
| 243 | 266 |
// nettoyage du context
|
| ... | ... | @@ -332,7 +355,7 @@ public class NavigationTree extends JXTree { |
| 332 | 355 |
log.debug("will selected open node: " + selectedNode);
|
| 333 | 356 |
}
|
| 334 | 357 |
|
| 335 |
- selectNode(selectedNode);
|
|
| 358 |
+ selectSafeNode(selectedNode);
|
|
| 336 | 359 |
}
|
| 337 | 360 |
|
| 338 | 361 |
}
|
| ... | ... | @@ -434,7 +457,7 @@ public class NavigationTree extends JXTree { |
| 434 | 457 |
fireTreeExpanded(new TreePath(result.getPath()));
|
| 435 | 458 |
|
| 436 | 459 |
// Select new node
|
| 437 |
- selectNode(result);
|
|
| 460 |
+ selectSafeNode(result);
|
|
| 438 | 461 |
|
| 439 | 462 |
return result;
|
| 440 | 463 |
}
|