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 9e9a45b8864c37343acea6d10475e9a3a57d5597 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Aug 16 17:48:58 2016 +0200 Fix merge --- .../shared/MoveActivityLonglinesUIAction.java | 71 ++++++++++----------- .../actions/shared/MoveActivitySeinesUIAction.java | 72 ++++++++++------------ .../ui/actions/shared/MoveRoutesUIAction.java | 65 +++++++++---------- .../tree/ObserveNavigationTreeShowPopupAction.java | 8 +-- .../actions/ChangeTripProgramActionListener.java | 3 +- 5 files changed, 103 insertions(+), 116 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 4d06448..ec1a132 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 @@ -24,11 +24,12 @@ package fr.ird.observe.ui.actions.shared; import com.google.common.collect.Lists; import fr.ird.observe.ObserveOpenDataManager; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.application.swing.decoration.DecoratorService; +import fr.ird.observe.application.swing.decoration.decorators.DataReferenceDecorator; import fr.ird.observe.services.dto.DataReference; import fr.ird.observe.services.dto.longline.ActivityLonglineDto; import fr.ird.observe.services.dto.longline.TripLonglineDto; import fr.ird.observe.services.service.longline.ActivityLonglineService; -import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.content.ContentUI; import fr.ird.observe.ui.content.list.impl.longline.ActivityLonglinesUI; @@ -36,14 +37,12 @@ import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; import fr.ird.observe.ui.tree.TripLonglineNode; import fr.ird.observe.ui.util.DecoratedNodeEntity; -import fr.ird.observe.application.swing.decoration.decorators.DataReferenceDecorator; import org.apache.commons.logging.Log; 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; import java.util.Optional; @@ -80,45 +79,41 @@ public class MoveActivityLonglinesUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } - - if (!(ui instanceof ActivityLonglinesUI)) { - throw new IllegalStateException("Can not come here!"); - } - ActivityLonglinesUI activityLonglinesUI = (ActivityLonglinesUI) ui; + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); + } + if (!(ui instanceof ActivityLonglinesUI)) { + throw new IllegalStateException("Can not come here!"); + } + ActivityLonglinesUI activityLonglinesUI = (ActivityLonglinesUI) ui; - // get current triplongline id - ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); - ObserveNode oldActivitiesNode = treeHelper.getSelectedNode(); - ObserveNode oldTripLonglineNode = oldActivitiesNode.getParent(); - // choose the new tripLongline - String tripLonglineId = chooseNewTripLongline(ui, oldTripLonglineNode); + // get current triplongline id + ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); + ObserveNode oldActivitiesNode = treeHelper.getSelectedNode(); + ObserveNode oldTripLonglineNode = oldActivitiesNode.getParent(); - if (tripLonglineId != null) { - // change the tripLongline of the selected activities - List<DataReference<ActivityLonglineDto>> selectedDatas = activityLonglinesUI.getModel().getSelectedDatas(); - List<String> activityIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); - ActivityLonglineService service = ObserveSwingApplicationContext.get().newService(ActivityLonglineService.class); - List<Integer> positions = service.moveActivityLonglinesToTripLongline(activityIds, tripLonglineId); + // choose the new tripLongline + String tripLonglineId = chooseNewTripLongline(ui, oldTripLonglineNode); - // update the tree - updateTree(oldActivitiesNode, tripLonglineId, activityIds); - } + if (tripLonglineId != null) { + // change the tripLongline of the selected activities + List<DataReference<ActivityLonglineDto>> selectedDatas = activityLonglinesUI.getModel().getSelectedDatas(); + List<String> activityIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); + ActivityLonglineService service = ObserveSwingApplicationContext.get().getMainDataSourceServicesProvider().newActivityLonglineService(); + List<Integer> positions = service.moveActivityLonglinesToTripLongline(activityIds, tripLonglineId); + // update the tree + updateTree(oldActivitiesNode, tripLonglineId, activityIds); } + }); } @@ -173,9 +168,9 @@ public class MoveActivityLonglinesUIAction extends AbstractUIAction { // Let's check if we're moving an open activity Optional<String> openActivity = activityIds - .stream() - .filter(openDataManager::isOpenActivityLongline) - .findFirst(); + .stream() + .filter(openDataManager::isOpenActivityLongline) + .findFirst(); // If so, we close it to avoid ending up with an open activity into a closed trip. if (openActivity.isPresent()) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivitySeinesUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivitySeinesUIAction.java index 1853fc2..9d0d920 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivitySeinesUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivitySeinesUIAction.java @@ -24,11 +24,12 @@ package fr.ird.observe.ui.actions.shared; import com.google.common.collect.Lists; import fr.ird.observe.ObserveOpenDataManager; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.application.swing.decoration.DecoratorService; +import fr.ird.observe.application.swing.decoration.decorators.DataReferenceDecorator; import fr.ird.observe.services.dto.DataReference; import fr.ird.observe.services.dto.seine.ActivitySeineDto; import fr.ird.observe.services.dto.seine.RouteDto; import fr.ird.observe.services.service.seine.ActivitySeineService; -import fr.ird.observe.ui.DecoratorService; import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.content.ContentUI; import fr.ird.observe.ui.content.list.impl.seine.ActivitySeinesUI; @@ -37,16 +38,15 @@ import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; import fr.ird.observe.ui.tree.RouteSeineNode; import fr.ird.observe.ui.util.DecoratedNodeEntity; -import fr.ird.observe.ui.util.decorator.DataReferenceDecorator; import org.apache.commons.logging.Log; 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; +import java.util.Optional; import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; @@ -80,43 +80,39 @@ public class MoveActivitySeinesUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } - - if (!(ui instanceof ActivitySeinesUI)) { - throw new IllegalStateException("Can not come here!"); - } - - // get current route id - ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); - ObserveNode oldActivitiesNode = treeHelper.getSelectedNode(); - ObserveNode oldRouteNode = oldActivitiesNode.getParent(); - - // choose the new route - String routeId = chooseNewRoute(ui, oldRouteNode); - - if (routeId != null) { - // change the route of the selected activities - List<DataReference<ActivitySeineDto>> selectedDatas = ((ActivitySeinesUIModel) ui.getModel()).getSelectedDatas(); - List<String> activityIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); - ActivitySeineService service = ObserveSwingApplicationContext.get().newService(ActivitySeineService.class); - List<Integer> positions = service.moveActivitySeinesToRoute(activityIds, routeId); - - // update the tree - updateTree(oldActivitiesNode, routeId, activityIds); - } + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); + } + if (!(ui instanceof ActivitySeinesUI)) { + throw new IllegalStateException("Can not come here!"); } + + // get current route id + ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); + ObserveNode oldActivitiesNode = treeHelper.getSelectedNode(); + ObserveNode oldRouteNode = oldActivitiesNode.getParent(); + + // choose the new route + String routeId = chooseNewRoute(ui, oldRouteNode); + + if (routeId != null) { + // change the route of the selected activities + List<DataReference<ActivitySeineDto>> selectedDatas = ((ActivitySeinesUIModel) ui.getModel()).getSelectedDatas(); + List<String> activityIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); + ActivitySeineService service = ObserveSwingApplicationContext.get().getMainDataSourceServicesProvider().newActivitySeineService(); + List<Integer> positions = service.moveActivitySeinesToRoute(activityIds, routeId); + + // update the tree + updateTree(oldActivitiesNode, routeId, activityIds); + } + }); } 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 f71dd76..ebca90e 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 @@ -24,11 +24,12 @@ package fr.ird.observe.ui.actions.shared; import com.google.common.collect.Lists; import fr.ird.observe.ObserveOpenDataManager; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.application.swing.decoration.DecoratorService; +import fr.ird.observe.application.swing.decoration.decorators.DataReferenceDecorator; import fr.ird.observe.services.dto.DataReference; import fr.ird.observe.services.dto.seine.RouteDto; import fr.ird.observe.services.dto.seine.TripSeineDto; import fr.ird.observe.services.service.seine.RouteService; -import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.content.ContentUI; import fr.ird.observe.ui.content.list.impl.seine.RoutesUI; @@ -36,14 +37,12 @@ import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; import fr.ird.observe.ui.tree.TripSeineNode; import fr.ird.observe.ui.util.DecoratedNodeEntity; -import fr.ird.observe.application.swing.decoration.decorators.DataReferenceDecorator; import org.apache.commons.logging.Log; 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; import java.util.Optional; @@ -80,45 +79,41 @@ public class MoveRoutesUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } - - if (!(ui instanceof RoutesUI)) { - throw new IllegalStateException("Can not come here!"); - } + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); + } - RoutesUI theUi = (RoutesUI) ui; + if (!(ui instanceof RoutesUI)) { + throw new IllegalStateException("Can not come here!"); + } - // get current tripseine id - ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); - ObserveNode oldRoutesNode = treeHelper.getSelectedNode(); - ObserveNode oldTripSeineNode = oldRoutesNode.getParent(); + RoutesUI theUi = (RoutesUI) ui; - // choose the new tripseine - String tripSeineId = chooseNewTripSeine(theUi, oldTripSeineNode); + // get current tripseine id + ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); + ObserveNode oldRoutesNode = treeHelper.getSelectedNode(); + ObserveNode oldTripSeineNode = oldRoutesNode.getParent(); - if (tripSeineId != null) { - // change the tripseine of the selected routes - List<DataReference<RouteDto>> selectedDatas = theUi.getModel().getSelectedDatas(); - List<String> routeIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); - RouteService service = ObserveSwingApplicationContext.get().newService(RouteService.class); - List<Integer> positions = service.moveRoutesToTripSeine(routeIds, tripSeineId); + // choose the new tripseine + String tripSeineId = chooseNewTripSeine(theUi, oldTripSeineNode); - // update the tree - updateTree(oldRoutesNode, tripSeineId, routeIds); - } + if (tripSeineId != null) { + // change the tripseine of the selected routes + List<DataReference<RouteDto>> selectedDatas = theUi.getModel().getSelectedDatas(); + List<String> routeIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); + RouteService service = ObserveSwingApplicationContext.get().getMainDataSourceServicesProvider().newRouteService(); + List<Integer> positions = service.moveRoutesToTripSeine(routeIds, tripSeineId); + // update the tree + updateTree(oldRoutesNode, tripSeineId, routeIds); } + }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveNavigationTreeShowPopupAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveNavigationTreeShowPopupAction.java index 6e53ec0..c831984 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveNavigationTreeShowPopupAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveNavigationTreeShowPopupAction.java @@ -252,7 +252,7 @@ public class ObserveNavigationTreeShowPopupAction { ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); DataContext dataContext = applicationContext.getDataContext(); - ContentUI<?> selectedContentUI = applicationContext.getSelectedContentUI(); + ContentUI<?> selectedContentUI = applicationContext.getContentUIManager().getSelectedContentUI(); boolean closeActionEnabled = false; @@ -306,13 +306,13 @@ public class ObserveNavigationTreeShowPopupAction { if (selectedNode.isOpen()) { - closeAction.putClientProperty("ui", applicationContext.getSelectedContentUI()); + closeAction.putClientProperty("ui", applicationContext.getContentUIManager().getSelectedContentUI()); popup.add(closeAction); } else { - openAction.putClientProperty("ui", applicationContext.getSelectedContentUI()); + openAction.putClientProperty("ui", applicationContext.getContentUIManager().getSelectedContentUI()); popup.add(openAction); } @@ -347,7 +347,7 @@ public class ObserveNavigationTreeShowPopupAction { moveAction.add(item); } - deleteAction.putClientProperty("ui", applicationContext.getSelectedContentUI()); + deleteAction.putClientProperty("ui", applicationContext.getContentUIManager().getSelectedContentUI()); deleteAction.setEnabled(selectedNode.isOpen()); popup.add(deleteAction); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/actions/ChangeTripProgramActionListener.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/actions/ChangeTripProgramActionListener.java index 5f435ff..95686da 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/actions/ChangeTripProgramActionListener.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/actions/ChangeTripProgramActionListener.java @@ -72,7 +72,8 @@ public class ChangeTripProgramActionListener extends NodeChangeActionListener { protected int moveNodeToParent(String nodeId, String parentNodeId, String oldParentNodeId) { int position; - ObserveServicesProvider servicesProvider = ObserveSwingApplicationContext.get().getMainDataSourceServicesProvider(); + ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); + ObserveServicesProvider servicesProvider = applicationContext.getMainDataSourceServicesProvider(); if (IdDtos.isTripLonglineId(nodeId)) { TripLonglineService service = servicesProvider.newTripLonglineService(); position = service.moveTripLonglineToProgram(nodeId, parentNodeId); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.