This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See http://git.codelutin.com/observe.git commit 2a8eeff60250666274b6c7a812ce4baa747d48e5 Author: Kevin Morin <morin@codelutin.com> Date: Wed Nov 18 14:53:31 2015 +0100 ajout du menu de déplacement d'un noeud d'activité longline --- .../tree/ObserveNavigationTreeShowPopupAction.java | 13 ++- .../actions/ChangeActivityTripActionListener.java | 101 +++++++++++++++++++++ .../ui/tree/menu/MoveActivityLonglineNodeData.java | 65 +++++++++++++ 3 files changed, 178 insertions(+), 1 deletion(-) 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 38ca04e..5578d04 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 @@ -29,6 +29,7 @@ import fr.ird.observe.db.DataContext; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.ui.content.ContentUI; import fr.ird.observe.ui.content.open.ContentOpenableUI; +import fr.ird.observe.ui.tree.menu.MoveActivityLonglineNodeData; import fr.ird.observe.ui.tree.menu.MoveActivitySeineNodeData; import fr.ird.observe.ui.tree.menu.MoveNodeData; import fr.ird.observe.ui.tree.menu.MoveRouteNodeData; @@ -70,11 +71,13 @@ public class ObserveNavigationTreeShowPopupAction { private static final String TRIP_MENU_ITEMS = "trip"; private static final String ROUTE_MENU_ITEMS = "route"; private static final String ACTIVITY_SEINE_MENU_ITEMS = "activitySeine"; + private static final String ACTIVITY_LONGLINE_MENU_ITEMS = "activityLongline"; static { n("observe.navigationMenu.move.trip"); n("observe.navigationMenu.move.route"); n("observe.navigationMenu.move.activitySeine"); + n("observe.navigationMenu.move.activityLongline"); } private final ObserveTreeHelper treeHelper; @@ -134,7 +137,8 @@ public class ObserveNavigationTreeShowPopupAction { moveNodeDataByNodeType = ImmutableMap.of(TRIP_MENU_ITEMS, new MoveTripNodeData(), ROUTE_MENU_ITEMS, new MoveRouteNodeData(), - ACTIVITY_SEINE_MENU_ITEMS, new MoveActivitySeineNodeData()); + ACTIVITY_SEINE_MENU_ITEMS, new MoveActivitySeineNodeData(), + ACTIVITY_LONGLINE_MENU_ITEMS, new MoveActivityLonglineNodeData()); KeyAdapter keyAdapter = new KeyAdapter() { @Override @@ -277,6 +281,13 @@ public class ObserveNavigationTreeShowPopupAction { openAction.setEnabled(!dataContext.isOpenActivitySeine()); closeAction.setEnabled(closeActionEnabled); + } else if (selectedNode.isActivityLonglineNode()) { + + beforeOpenMenu(selectedNode, ACTIVITY_LONGLINE_MENU_ITEMS); + + openAction.setEnabled(!dataContext.isOpenActivityLongline()); + closeAction.setEnabled(closeActionEnabled); + } else { popup.add(noAction); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/actions/ChangeActivityTripActionListener.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/actions/ChangeActivityTripActionListener.java new file mode 100644 index 0000000..7b5c97f --- /dev/null +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/actions/ChangeActivityTripActionListener.java @@ -0,0 +1,101 @@ +package fr.ird.observe.ui.tree.actions; + +/* + * #%L + * ObServe :: Swing + * %% + * Copyright (C) 2008 - 2015 IRD, Codelutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + + +import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.db.ObserveSwingDataSource; +import fr.ird.observe.services.dto.longline.TripLonglineDto; +import fr.ird.observe.services.service.longline.ActivityLonglineService; +import fr.ird.observe.ui.DecoratorService; +import fr.ird.observe.ui.tree.ObserveNode; +import fr.ird.observe.ui.tree.ObserveTreeHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Created on 1/9/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 3.11 + */ +public class ChangeActivityTripActionListener extends NodeChangeActionListener { + + /** Logger. */ + private static final Log log = LogFactory.getLog(ChangeActivityTripActionListener.class); + + public ChangeActivityTripActionListener(ObserveTreeHelper treeHelper, + ObserveSwingDataSource dataSource, + String activityId, + String tripLonglineId) { + super(treeHelper, dataSource, activityId, tripLonglineId); + } + + @Override + protected ObserveNode getParentNode(ObserveNode node) { + return node.getParent().getParent(); + } + + @Override + protected ObserveNode getNewParentNode(ObserveNode grandParentNode, String parentNodeId) { + ObserveNode tripLonglineNode = getTreeHelper().getChild(grandParentNode, parentNodeId); + String activitiesNodeId = DecoratorService.getPropertyLabel(ObserveTreeHelper.TREE_NODE_PREFIX, + TripLonglineDto.PROPERTY_ACTIVITY_LONGLINE); + ObserveNode activities = getTreeHelper().getChild(tripLonglineNode, activitiesNodeId); + return activities; + } + + @Override + protected void closeParent(String oldParentId) { + ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); + applicationContext.getOpenDataManager().closeTripLongline(oldParentId); + } + + @Override + protected int moveNodeToParent(String nodeId, String parentNodeId) { + int position; + + ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); + + ActivityLonglineService service = applicationContext.newService(ActivityLonglineService.class); + position = service.moveActivityLonglineToTripLongline(nodeId, parentNodeId); + + return position; + } + + @Override + protected void openParent(ObserveNode activitiesNode) { + + ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); + + ObserveNode tripLonglineNode = activitiesNode.getParent(); + String tripLonglineId = tripLonglineNode.getId(); + + ObserveNode programNode = tripLonglineNode.getParent(); + String programId = programNode.getId(); + + applicationContext.getOpenDataManager().openTripLongline(programId, tripLonglineId); + + getTreeHelper().reloadNode(tripLonglineNode, true); + } +} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveActivityLonglineNodeData.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveActivityLonglineNodeData.java new file mode 100644 index 0000000..ddf373a --- /dev/null +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveActivityLonglineNodeData.java @@ -0,0 +1,65 @@ +package fr.ird.observe.ui.tree.menu; + +import fr.ird.observe.db.ObserveSwingDataSource; +import fr.ird.observe.services.dto.IdDtos; +import fr.ird.observe.services.dto.ReferenceDto; +import fr.ird.observe.services.dto.longline.TripLonglineDto; +import fr.ird.observe.ui.DecoratorService; +import fr.ird.observe.ui.tree.DtoNodeSupport; +import fr.ird.observe.ui.tree.ObserveNode; +import fr.ird.observe.ui.tree.ObserveTreeHelper; +import fr.ird.observe.ui.tree.actions.ChangeActivityRouteActionListener; +import fr.ird.observe.ui.tree.actions.NodeChangeActionListener; +import org.nuiton.decorator.Decorator; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author Kevin Morin (Code Lutin) + * @since 5.0 + */ +public class MoveActivityLonglineNodeData extends MoveNodeData { + + @Override + public NodeChangeActionListener createChangeActionListener(ObserveTreeHelper treeHelper, + ObserveSwingDataSource dataSource, + String id, + String parentId) { + return new ChangeActivityRouteActionListener(treeHelper, dataSource, id, parentId); + } + + @Override + public Map<String, String> getPossibleParentNodes(ObserveNode activityLonglineNode, ObserveTreeHelper treeHelper) { + + // noeud de marée parent + ObserveNode parentNode = activityLonglineNode.getParent().getParent(); + + // noeud de route de la marée sans le parent actuel + Map<String, String> possibleParents = new LinkedHashMap<>(); + + // noeud du programme + ObserveNode programNode = parentNode.getParent(); + + DecoratorService decoratorService = treeHelper.getTreeCellRenderer().getDecoratorService(); + Decorator<ReferenceDto> tripDecorator = + decoratorService.getDecoratorByType(ReferenceDto.class, TripLonglineDto.class.getSimpleName()); + + for (int i = 0, n = programNode.getChildCount() ; i < n ; i++) { + + ObserveNode tripNode = programNode.getChildAt(i); + String tripId = tripNode.getId(); + + // si le noeud de marée n'est pas le même que le parent actuel + if (!parentNode.equals(tripNode) + // si le noeud est bien un noeud de marée longline + && IdDtos.isTripLonglineId(tripId)) { + + String decoratedTrip = tripDecorator.toString(((DtoNodeSupport) tripNode).getEntity()); + possibleParents.put(tripId, decoratedTrip); + } + } + + return possibleParents; + } +} -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.