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 01f382489d5d92f66aefbe817757e18a72694edc Author: Samuel Maisonneuve <maisonneuve@codelutin.com> Date: Thu Jul 28 17:19:51 2016 +0200 Fix activity lonline trip move action refs #7591 --- .../shared/MoveActivityLonglinesUIAction.java | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivityLonglinesUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivityLonglinesUIAction.java index ab3614e..8bf426b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivityLonglinesUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivityLonglinesUIAction.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 MoveActivityLonglinesUIAction extends AbstractUIAction { TripLonglineDto.PROPERTY_ACTIVITY_LONGLINE); ObserveNode newActivitiesNode = treeHelper.getChild(newTripLonglineNode, activitiesNodeId); - treeHelper.selectNode(newActivitiesNode); - for (int i = 0, s = positions.size(); i < s; i++) { String activityId = activityIds.get(i); @@ -184,6 +183,7 @@ public class MoveActivityLonglinesUIAction extends AbstractUIAction { if (wasOpen) { openDataManager.closeTripLongline(oldTripLonglineId); openDataManager.openTripLongline(programNode.getId(), tripLonglineId); + openDataManager.openActivityLongline(tripLonglineId, activityId); // We need to reopen the activity since closing the trip also close the activity } ObserveNode newRouteNode = treeHelper.getChild(newActivitiesNode, activityId); @@ -198,6 +198,32 @@ public class MoveActivityLonglinesUIAction extends AbstractUIAction { } } + // We need to fully reload the newActivitiesNode, + // 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 newActivitiesNode : + // 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 activities node which receive the activities) + // + // However, the node selection has to be done after that the trip has been opened : + // selecting the newAtivitiesNode 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(newActivitiesNode); + + // 2. Let's fully reload newActivitiesNode + treeHelper.clearAndPopulateNode(newActivitiesNode); + + // 3. We ensure the path until the newActivitiesNode is expanded + // so that the user can see the activities he moved + TreePath path = new TreePath(newActivitiesNode.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 program treeHelper.reloadNode(programNode, true); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.