This is an automated email from the git hooks/post-receive script. New commit to branch feature/7591_Correction_migration_entites_d_un_parent_a_un_autre in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 5b332e3bebe097edc789bf130891db7edcc293a8 Author: Samuel Maisonneuve <maisonneuve@codelutin.com> Date: Thu Jul 28 15:46:24 2016 +0200 Fix routes move action refs #7591 --- .../ui/actions/shared/MoveRoutesUIAction.java | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveRoutesUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveRoutesUIAction.java index ec2f97b..2f875c7 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveRoutesUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveRoutesUIAction.java @@ -43,6 +43,7 @@ import org.apache.commons.logging.LogFactory; import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; +import javax.swing.tree.TreePath; import java.awt.event.ActionEvent; import java.util.List; @@ -172,8 +173,6 @@ public class MoveRoutesUIAction extends AbstractUIAction { TripSeineDto.PROPERTY_ROUTE); ObserveNode newRoutesNode = treeHelper.getChild(newTripSeineNode, routesNodeId); - treeHelper.selectNode(newRoutesNode); - for (int i = 0, s = positions.size(); i < s; i++) { String routeId = routeIds.get(i); @@ -184,6 +183,7 @@ public class MoveRoutesUIAction extends AbstractUIAction { if (wasOpen) { openDataManager.closeTripSeine(oldTripSeineId); openDataManager.openTripSeine(programNode.getId(), tripSeineId); + openDataManager.openRoute(tripSeineId, routeNode.getId()); // Need to reopen the route since closing the trip also close the route } ObserveNode newRouteNode = treeHelper.getChild(newRoutesNode, routeId); @@ -198,6 +198,32 @@ public class MoveRoutesUIAction extends AbstractUIAction { } } + // We need to fully reload the newRoutesNode, + // triggering the child loadors to recreate the node's children from the database + // (since the change in the database has already been care of) + + // 1. Select the newRoutesNode : + // only a selected node can be reloaded (@see fr.ird.observe.ui.tree.ObserveTreeBridge.canLoadChild). + // (And also it's better for user experience because it puts the focus on the routes node which receive the routes) + // + // However, the node selection has to be done after that the trip has been opened : + // selecting the newRoutesNode opens a list layout which compute a rendering mode associated to the trip state. + // After the mode has been computed, it is injected in the list component which triggers listeners on associated components, such as buttons. + // + // That's why, if we do this before the trip is opened, + // we will end up with an incoherent list view (some buttons will be deactivated while they should be activated for instance) + treeHelper.selectNode(newRoutesNode); + + // 2. Let's fully reload newRoutesNode + treeHelper.clearAndPopulateNode(newRoutesNode); + + // 3. We ensure the path until the newRoutesNode is expanded + // so that the user can see the activities he moved + TreePath path = new TreePath(newRoutesNode.getPath()); + treeHelper.getUI().collapsePath(path); // FIXME : sometimes the path don't expand because its state seems to indicate that it's already expanded.. + treeHelper.expandPath(path); + + // Finally, let's refresh the nodes' label of the whole programme treeHelper.reloadNode(programNode, true); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.