Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 5a189e8b by Tony CHEMIT at 2018-04-06T08:07:07Z fix update node in navigation on save, create or delete - - - - - 3 changed files: - client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUIModel.java Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUI.jaxx ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUI.jaxx +++ b/client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUI.jaxx @@ -22,10 +22,10 @@ <fr.ird.observe.client.ui.content.ContentUI abstract='true' superGenericType='E, U' - genericType='E extends IdDto, U extends ContentOpenableUI<E, U>'> + genericType='E extends DataDto, U extends ContentOpenableUI<E, U>'> <import> - fr.ird.observe.dto.IdDto + fr.ird.observe.dto.data.DataDto fr.ird.observe.client.ui.actions.content.CloseAndCreateUIAction fr.ird.observe.client.ui.actions.content.CloseOpenUIAction ===================================== client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUIHandler.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUIHandler.java +++ b/client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUIHandler.java @@ -6,15 +6,15 @@ * %% * 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 + * 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 + * + * 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% @@ -24,40 +24,38 @@ package fr.ird.observe.client.ui.content.open; import fr.ird.observe.client.ObserveSwingApplicationContext; import fr.ird.observe.client.db.ObserveSwingDataSource; import fr.ird.observe.client.db.constants.DataContextType; -import fr.ird.observe.client.ui.util.UIHelper; import fr.ird.observe.client.ui.content.ContentMode; import fr.ird.observe.client.ui.content.ContentUIHandler; import fr.ird.observe.client.ui.tree.navigation.NavigationTree; import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; +import fr.ird.observe.client.ui.tree.navigation.nodes.ReferenceNavigationTreeNodeSupport; import fr.ird.observe.client.ui.tree.navigation.nodes.longline.ProgramLonglineNavigationTreeNode; import fr.ird.observe.client.ui.tree.navigation.nodes.seine.ProgramSeineNavigationTreeNode; +import fr.ird.observe.client.ui.util.UIHelper; import fr.ird.observe.client.validation.ClientValidationContext; -import fr.ird.observe.dto.IdDto; +import fr.ird.observe.dto.data.DataDto; import fr.ird.observe.dto.data.longline.TripLonglineDto; import fr.ird.observe.dto.data.seine.TripSeineDto; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.validator.NuitonValidatorScope; - import static org.nuiton.i18n.I18n.t; /** * @author Tony Chemit - dev@tchemit.fr * @since 1.0 */ -public abstract class ContentOpenableUIHandler<E extends IdDto, U extends ContentOpenableUI<E, U>> extends ContentUIHandler<E, U> { +public abstract class ContentOpenableUIHandler<E extends DataDto, U extends ContentOpenableUI<E, U>> extends ContentUIHandler<E, U> { - protected static final String POSITION_OPENABLE = "positionOpenable"; + private static final String POSITION_OPENABLE = "positionOpenable"; /** Logger */ static private final Log log = LogFactory.getLog(ContentOpenableUIHandler.class); - + private static final String UPDATE_TRIP_NODE = "updateTripNode"; protected final String closeMessage; - public ContentOpenableUIHandler(DataContextType parentType, - DataContextType type, - String closeMessage) { + public ContentOpenableUIHandler(DataContextType parentType, DataContextType type, String closeMessage) { super(parentType, type); this.closeMessage = closeMessage; } @@ -122,6 +120,18 @@ public abstract class ContentOpenableUIHandler<E extends IdDto, U extends Conten } } + @Override + protected void afterDelete() { + super.afterDelete(); + NavigationTree treeHelper = getNavigationTree(); + NavigationTreeNodeSupport parent = treeHelper.getSelectedNode().getParent(); + if (!(parent instanceof ReferenceNavigationTreeNodeSupport)) { + parent = parent.getParent(); + } + parent.reload(); + treeHelper.reloadNode(parent, false); + } + public abstract boolean doCloseData(); public final void afterCloseData() { @@ -138,7 +148,7 @@ public abstract class ContentOpenableUIHandler<E extends IdDto, U extends Conten removeAllMessages(ui); addMessage(ui, NuitonValidatorScope.INFO, - getTypeI18nKey(bean.getClass()), t(closeMessage)); + getTypeI18nKey(bean.getClass()), t(closeMessage)); NavigationTree treeHelper = getNavigationTree(); treeHelper.reloadSelectedNode(bean instanceof TripSeineDto || bean instanceof TripLonglineDto, true); @@ -159,6 +169,11 @@ public abstract class ContentOpenableUIHandler<E extends IdDto, U extends Conten NavigationTreeNodeSupport node = treeHelper.getSelectedNode(); NavigationTreeNodeSupport parentNode = node.getParent(); + NavigationTreeNodeSupport parentDataNode = parentNode; + if (!(parentNode instanceof ReferenceNavigationTreeNodeSupport)) { + parentDataNode = parentNode.getParent(); + } + boolean create = node.getId() == null; E bean = getBean(); @@ -181,6 +196,10 @@ public abstract class ContentOpenableUIHandler<E extends IdDto, U extends Conten // on crée le noeud final de la marée node = treeHelper.addOpenable(parentNode, bean); + if (parentNode != parentDataNode) { + parentDataNode.reload(); + treeHelper.reloadNode(parentDataNode, false); + } // arrêt de l'édition de l'écran courant stopEditUI(); @@ -202,6 +221,11 @@ public abstract class ContentOpenableUIHandler<E extends IdDto, U extends Conten treeHelper.selectNode(node); } + node.reload(); + if (parentNode != parentDataNode) { + parentDataNode.reload(); + treeHelper.reloadNode(parentDataNode, false); + } // on repaint le noeud et ses enfants treeHelper.reloadSelectedNode(false, true); } @@ -286,8 +310,6 @@ public abstract class ContentOpenableUIHandler<E extends IdDto, U extends Conten } } - private static final String UPDATE_TRIP_NODE = "updateTripNode"; - protected void repaintTripNode() { Boolean updateTripNode = getUi().getContextValue(Boolean.class, UPDATE_TRIP_NODE); ===================================== client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUIModel.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUIModel.java +++ b/client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUIModel.java @@ -23,6 +23,7 @@ package fr.ird.observe.client.ui.content.open; import fr.ird.observe.client.ui.content.ContentUIModel; import fr.ird.observe.dto.IdDto; +import fr.ird.observe.dto.data.DataDto; /** * Le modèle pour un écran d'édition avec des fils. @@ -30,7 +31,7 @@ import fr.ird.observe.dto.IdDto; * @author Tony Chemit - dev@tchemit.fr * @since 1.5 */ -public abstract class ContentOpenableUIModel<E extends IdDto> extends ContentUIModel<E> { +public abstract class ContentOpenableUIModel<E extends DataDto> extends ContentUIModel<E> { public static final String PROPERTY_CAN_REOPEN = "canReopen"; View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/5a189e8b6502dcbb9f8b8a93bf32... --- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/5a189e8b6502dcbb9f8b8a93bf32... You're receiving this email because of your account on gitlab.com.