Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 4ddcd796 by Tony Chemit at 2020-09-09T17:55:50+02:00 stash 3 - - - - - 23 changed files: - client-core/src/main/java/fr/ird/observe/client/util/DtoIconHelper.java - client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/content/data/open/actions/Create.java - client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/TripActionHelper.java - client-datasource-editor-ps/src/main/i18n/getters/java.getter - client-datasource-editor-ps/src/main/i18n/getters/jaxx.getter - client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/ObservePsKeyStrokes.java - + client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/LocalmarketUI.jaxx - + client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/LocalmarketUIHandler.java - + client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/LocalmarketUIModel.java - client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/SurveyPartUI.jaxx - + client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/actions/LocalmarketUIActionSupport.java - + client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/actions/LocalmarketUIAddBatch.java - + client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/actions/LocalmarketUIAddSample.java - + client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/actions/LocalmarketUIAddSurvey.java - client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/tree/navigation/nodes/data/ps/localmarket/LocalmarketNavigationTreeNode.java - client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/tree/navigation/nodes/data/ps/localmarket/SampleNavigationTreeNode.java - client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/tree/navigation/nodes/data/ps/localmarket/SurveyNavigationTreeNode.java - observe-i18n/src/main/i18n/translations/observe_en_GB.properties - observe-i18n/src/main/i18n/translations/observe_es_ES.properties - observe-i18n/src/main/i18n/translations/observe_fr_FR.properties - test/src/main/resources/db/8.1/dataForTestLongline.sql.gz - test/src/main/resources/db/8.1/dataForTestSeine.sql.gz - test/src/main/resources/db/8.1/referentiel.sql.gz Changes: ===================================== client-core/src/main/java/fr/ird/observe/client/util/DtoIconHelper.java ===================================== @@ -72,7 +72,10 @@ public class DtoIconHelper { } public static String getIconPath(String iconPathPrefix, boolean small) { - String iconPath = "navigation." + iconPathPrefix; + String iconPath = iconPathPrefix; + if (!iconPath.startsWith("navigation.")) { + iconPath = "navigation."+iconPath; + } if (small) { iconPath += "-small"; } ===================================== client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/content/data/open/actions/Create.java ===================================== @@ -26,6 +26,7 @@ import fr.ird.observe.client.datasource.editor.DataSourceEditor; import fr.ird.observe.client.datasource.editor.content.actions.ContentUIActionSupport; import fr.ird.observe.client.datasource.editor.content.data.edit.ContentEditUIModel; import fr.ird.observe.client.datasource.editor.content.data.open.ContentOpenableUI; +import fr.ird.observe.client.datasource.editor.content.data.simple.ContentSimpleUIModel; import fr.ird.observe.client.datasource.editor.tree.navigation.NavigationTree; import fr.ird.observe.client.util.ObserveKeyStrokesSupport; import fr.ird.observe.navigation.model.edit.CloseEditNodeVetoException; @@ -49,7 +50,7 @@ public class Create extends ContentUIActionSupport<ContentOpenableUI> { super(null, null, "add", ObserveKeyStrokesSupport.KEY_STROKE_NEW_NEXT_DATA); } - public static void closeAndCreate(DataSourceEditor dataSourceEditor, MultipleReferenceContainerNode<?, ?> parentNode, NavigationTree tree, ContentEditUIModel<?, ?> model) { + public static void closeAndCreate(DataSourceEditor dataSourceEditor, MultipleReferenceContainerNode<?, ?> parentNode, NavigationTree tree, ContentSimpleUIModel model) { try { Close.closeData(dataSourceEditor, model.getEditNode()); tree.addUnsavedNode(parentNode); ===================================== client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/TripActionHelper.java ===================================== @@ -22,11 +22,14 @@ package fr.ird.observe.client.datasource.editor.content.data; * #L% */ +import fr.ird.observe.client.datasource.editor.content.ContentUI; import fr.ird.observe.client.datasource.editor.content.data.list.ContentListUI; import fr.ird.observe.client.datasource.editor.tree.navigation.NavigationTree; import fr.ird.observe.client.main.ObserveMainUI; import fr.ird.observe.client.util.UIHelper; import fr.ird.observe.dto.data.TripAware; +import fr.ird.observe.dto.data.ps.common.TripReference; +import fr.ird.observe.navigation.tree.ReferenceNode; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -43,6 +46,15 @@ import static io.ultreia.java4all.i18n.I18n.t; public class TripActionHelper { private static final Logger log = LogManager.getLogger(TripActionHelper.class); + public static boolean gotoTripLogbookTab(ObserveMainUI mainui, ContentUI ui, String tripId, Function<String, TripAware> servicesProvider, String message) { + TripAware tripDto = servicesProvider.apply(tripId); + boolean canExecuteAction = tripDto.isLogbookAvailability(); + if (!canExecuteAction) { + askAndGotoTripMetaDataTab(mainui, ui, message, TripAware.PROPERTY_LOGBOOK_AVAILABILITY, 3); + } + return canExecuteAction; + } + public static boolean gotoTripLogbookTab(ObserveMainUI mainui, ContentListUI<?, ?, ?, ?> ui, Function<String, TripAware> servicesProvider, String message) { String tripId = ui.getModel().getSelectedParentId(); TripAware tripDto = servicesProvider.apply(tripId); @@ -63,7 +75,7 @@ public class TripActionHelper { return canExecuteAction; } - private static void askAndGotoTripMetaDataTab(ObserveMainUI mainui, ContentListUI<?, ?, ?, ?> ui, String message, String availabilityPropertyName, int tabIndex) { + private static void askAndGotoTripMetaDataTab(ObserveMainUI mainui, ContentUI ui, String message, String availabilityPropertyName, int tabIndex) { // Let's ask user to fill them int response = UIHelper.askUser( mainui, @@ -81,7 +93,7 @@ public class TripActionHelper { // go to trip form NavigationTree tree = ui.getDataSourceEditor().getNavigationUI().getTree(); - TreeNode tripNode = ui.getModel().upToParentReferenceNode(tree); + TreeNode tripNode = ReferenceNode.upToReferenceNode(TripReference.class, tree.getSelectedNode()); tree.selectSafeNode(tripNode); TripUI tripUI = (TripUI) ui.getDataSourceEditor().getContentUIManager().getSelectedContentUI(); // set availability flag to true ===================================== client-datasource-editor-ps/src/main/i18n/getters/java.getter ===================================== @@ -40,6 +40,8 @@ observe.data.ps.landing.Landing.table.weight observe.data.ps.landing.Landing.table.weight.tip observe.data.ps.landing.Landing.table.weightCategory observe.data.ps.landing.Landing.table.weightCategory.tip +observe.data.ps.localmarket.Batch.action.create +observe.data.ps.localmarket.Batch.action.create.tip observe.data.ps.localmarket.Batch.table.count observe.data.ps.localmarket.Batch.table.count.tip observe.data.ps.localmarket.Batch.table.packaging ===================================== client-datasource-editor-ps/src/main/i18n/getters/jaxx.getter ===================================== @@ -121,6 +121,7 @@ observe.data.ps.localmarket.SurveyPart.action.create observe.data.ps.localmarket.SurveyPart.action.create.tip observe.data.ps.localmarket.SurveyPart.proportion observe.data.ps.localmarket.SurveyPart.title +observe.data.ps.localmarket.title observe.data.ps.logbook.Activity.action.close.tip observe.data.ps.logbook.Activity.action.create observe.data.ps.logbook.Activity.action.create.tip ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/ObservePsKeyStrokes.java ===================================== @@ -40,4 +40,7 @@ public class ObservePsKeyStrokes extends ObserveKeyStrokesSupport { public static final KeyStroke KEY_STROKE_COPY_FLOATING_OBJECT_PART_TO_LEFT = KeyStroke.getKeyStroke("ctrl L"); public static final KeyStroke KEY_STROKE_ADD_SET_SEINE = KeyStroke.getKeyStroke("ctrl pressed L"); public static final KeyStroke KEY_STROKE_ADD_SAMPLE = KeyStroke.getKeyStroke("ctrl pressed S"); + public static final KeyStroke KEY_STROKE_LOCALMARKET_ADD_BATCH = KeyStroke.getKeyStroke("ctrl pressed F1"); + public static final KeyStroke KEY_STROKE_LOCALMARKET_ADD_SURVEY = KeyStroke.getKeyStroke("ctrl pressed F2"); + public static final KeyStroke KEY_STROKE_LOCALMARKET_ADD_SAMPLE = KeyStroke.getKeyStroke("ctrl pressed F3"); } ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/LocalmarketUI.jaxx ===================================== @@ -0,0 +1,45 @@ +<!-- + #%L + ObServe :: Client DataSource Editor PS + %% + Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io + %% + 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% + --> +<fr.ird.observe.client.datasource.editor.content.data.simple.ContentSimpleUI beanScope="bean" + i18n="fr.ird.observe.dto.data.ps.common.TripDto" + superGenericType='TripDto, LocalmarketUI' + contentTitle='{n("observe.data.ps.localmarket.title")}'> + <import> + fr.ird.observe.dto.data.ps.common.TripDto + static io.ultreia.java4all.i18n.I18n.n + </import> + + <LocalmarketUIModel id='model' constructorParams='@override'/> + <TripDto id='bean'/> + <BeanValidator id='validator' context='update' errorTableModel='{getErrorTableModel()}' + beanClass='fr.ird.observe.dto.data.ps.common.TripDto'> + <field name="localMarketBatch" component="addBatch"/> + <field name="localMarketSurvey" component="addSurvey"/> + <field name="localMarketSample" component="addSample"/> + </BeanValidator> + + <JPanel id="body" layout="{new GridLayout(0,1)}"> + <JButton id='addBatch'/> + <JButton id='addSurvey'/> + <JButton id='addSample'/> + </JPanel> +</fr.ird.observe.client.datasource.editor.content.data.simple.ContentSimpleUI> ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/LocalmarketUIHandler.java ===================================== @@ -0,0 +1,74 @@ +package fr.ird.observe.client.datasource.editor.content.data.ps.localmarket; + +/*- + * #%L + * ObServe :: Client DataSource Editor PS + * %% + * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io + * %% + * 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.client.datasource.editor.content.data.simple.ContentSimpleUIHandler; +import fr.ird.observe.client.datasource.editor.content.ui.ObserveLayoutFocusTraversalPolicy; +import fr.ird.observe.dto.data.ps.common.TripDto; +import fr.ird.observe.dto.form.Form; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.nuiton.jaxx.runtime.spi.UIHandler; + +import java.awt.Component; +import java.awt.Container; + +/** + * Created on 09/09/2020. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 8.1.0 + */ +class LocalmarketUIHandler extends ContentSimpleUIHandler<TripDto, LocalmarketUI> implements UIHandler<LocalmarketUI> { + private static final Logger log = LogManager.getLogger(LocalmarketUIHandler.class); + + @Override + protected ObserveLayoutFocusTraversalPolicy<LocalmarketUI> createFocusTraversalPolicy() { + return new ObserveLayoutFocusTraversalPolicy<LocalmarketUI>() { + @Override + protected Component getFirstComponentForEdit(Container aContainer) { + return ui.getAddBatch(); + } + + @Override + protected Component getLastComponentForEdit(Container aContainer) { + return ui.getAddBatch(); + } + }; + } + + @Override + public LocalmarketUIModel getModel() { + return (LocalmarketUIModel) super.getModel(); + } + + @Override + protected void onOpenModel() { + super.onOpenModel(); + LocalmarketUIModel model = getModel(); + String tripId = model.getSelectedId(); + log.info(prefix + "tripId = " + tripId); + Form<TripDto> form = getPsCommonTripService().loadForm(tripId); + model.openForm(form); + } +} ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/LocalmarketUIModel.java ===================================== @@ -0,0 +1,53 @@ +package fr.ird.observe.client.datasource.editor.content.data.ps.localmarket; + +/*- + * #%L + * ObServe :: Client DataSource Editor PS + * %% + * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io + * %% + * 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.client.datasource.editor.content.ContentMode; +import fr.ird.observe.client.datasource.editor.content.data.simple.ContentSimpleUIModel; +import fr.ird.observe.dto.data.ps.common.TripDto; +import fr.ird.observe.dto.form.Form; +import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition; + +/** + * Created on 09/09/2020. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 8.1.0 + */ +@GenerateJavaBeanDefinition +public class LocalmarketUIModel extends ContentSimpleUIModel<TripDto> { + + public LocalmarketUIModel() { + super(TripDto.class); + } + + @Override + protected ContentMode computeMode(boolean canWrite) { + return canWrite ? getContentModeFromSelf() : ContentMode.READ; + } + + @Override + public void openForm(Form<TripDto> form) { + super.openForm(form); + } +} ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/SurveyPartUI.jaxx ===================================== @@ -67,7 +67,7 @@ public SwingValidatorMessageTableModel getErrorTableModel() { ]]> </script> - <Table id='editorPanel' fill='both' insets='1'> + <Table id='editorPanel' fill='both' insets='1' beanScope="tableEditBean"> <!-- species --> <row> ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/actions/LocalmarketUIActionSupport.java ===================================== @@ -0,0 +1,60 @@ +package fr.ird.observe.client.datasource.editor.content.data.ps.localmarket.actions; + +/*- + * #%L + * ObServe :: Client DataSource Editor PS + * %% + * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io + * %% + * 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.client.datasource.editor.content.actions.ContentUIActionSupport; +import fr.ird.observe.client.datasource.editor.content.data.TripActionHelper; +import fr.ird.observe.client.datasource.editor.content.data.ps.localmarket.LocalmarketUI; +import fr.ird.observe.client.datasource.editor.content.data.ps.localmarket.LocalmarketUIModel; +import fr.ird.observe.client.util.DtoIconHelper; + +import javax.swing.KeyStroke; +import java.awt.event.ActionEvent; + +import static io.ultreia.java4all.i18n.I18n.t; + +/** + * Created on 09/09/2020. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 8.1.0 + */ +public abstract class LocalmarketUIActionSupport extends ContentUIActionSupport<LocalmarketUI> { + + protected LocalmarketUIActionSupport(String label, String shortDescription, String actionIcon, KeyStroke acceleratorKey) { + super(label, shortDescription, actionIcon, acceleratorKey); + setIcon(DtoIconHelper.getIcon(actionIcon)); + } + + + @Override + protected boolean canExecuteAction(ActionEvent e) { + boolean canExecuteAction = super.canExecuteAction(e); + //FIXME Finshi this + if (canExecuteAction) { + LocalmarketUIModel model = ui.getModel(); + canExecuteAction = TripActionHelper.gotoTripLogbookTab(getMainUI(), ui, model.getBean().getId(), getServicesProvider().getPsCommonTripService()::loadDto, t("observe.data.ps.common.Trip.message.missing.observation.metadata")); + } + return canExecuteAction; + } +} ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/actions/LocalmarketUIAddBatch.java ===================================== @@ -0,0 +1,75 @@ +package fr.ird.observe.client.datasource.editor.content.data.ps.localmarket.actions; + +/*- + * #%L + * ObServe :: Client DataSource Editor PS + * %% + * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io + * %% + * 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.client.datasource.editor.content.ObservePsKeyStrokes; +import fr.ird.observe.client.datasource.editor.content.data.ps.localmarket.BatchUI; +import fr.ird.observe.client.datasource.editor.content.data.ps.localmarket.LocalmarketUI; +import fr.ird.observe.client.datasource.editor.tree.navigation.NavigationTree; +import fr.ird.observe.client.datasource.editor.tree.navigation.nodes.NavigationTreeNodeSupport; +import fr.ird.observe.client.datasource.editor.tree.navigation.nodes.data.ps.localmarket.BatchNavigationTreeNode; +import fr.ird.observe.client.datasource.editor.tree.navigation.nodes.data.ps.localmarket.LocalmarketNavigationTreeNode; +import fr.ird.observe.client.util.DtoIconHelper; +import fr.ird.observe.dto.data.ps.localmarket.BatchDto; + +import javax.swing.SwingUtilities; +import java.awt.event.ActionEvent; +import java.awt.event.KeyListener; + +import static io.ultreia.java4all.i18n.I18n.t; + +/** + * Created on 09/09/2020. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 8.1.0 + */ +public class LocalmarketUIAddBatch extends LocalmarketUIActionSupport { + + public LocalmarketUIAddBatch() { + super(t("observe.data.ps.localmarket.Batch.action.create"), t("observe.data.ps.localmarket.Batch.action.create.tip"), DtoIconHelper.getIconPath(BatchDto.class), ObservePsKeyStrokes.KEY_STROKE_LOCALMARKET_ADD_BATCH); + } + + @Override + public void init() { + super.init(); + //FIXME Make this in UIHelper at least for any + for (KeyListener keyListener : editor.getKeyListeners()) { + if (keyListener.getClass().getName().contains("javax.swing.ToolTipManager$AccessibilityKeyListener")) { + editor.removeKeyListener(keyListener); + break; + } + } + } + + @Override + protected void doActionPerformed(ActionEvent e, LocalmarketUI ui) { + NavigationTree tree = getDataSourceEditor().getNavigationUI().getTree(); + LocalmarketNavigationTreeNode parentNode = (LocalmarketNavigationTreeNode) tree.getSelectedNode(); + NavigationTreeNodeSupport<?> nodeToSelect = parentNode.findChildByType(BatchNavigationTreeNode.class); + tree.selectSafeNode(nodeToSelect); + BatchUI content = getDataSourceEditor().getContentUIManager().getContent(); + SwingUtilities.invokeLater(() -> content.getNewEntry().doClick()); + + } +} ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/actions/LocalmarketUIAddSample.java ===================================== @@ -0,0 +1,62 @@ +package fr.ird.observe.client.datasource.editor.content.data.ps.localmarket.actions; + +/*- + * #%L + * ObServe :: Client DataSource Editor PS + * %% + * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io + * %% + * 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.client.datasource.editor.content.ObservePsKeyStrokes; +import fr.ird.observe.client.datasource.editor.content.data.ps.localmarket.LocalmarketUI; +import fr.ird.observe.client.datasource.editor.content.data.ps.localmarket.SampleListUI; +import fr.ird.observe.client.datasource.editor.tree.navigation.NavigationTree; +import fr.ird.observe.client.datasource.editor.tree.navigation.nodes.data.ps.localmarket.LocalmarketNavigationTreeNode; +import fr.ird.observe.client.datasource.editor.tree.navigation.nodes.data.ps.localmarket.SampleListNavigationTreeNode; +import fr.ird.observe.client.util.DtoIconHelper; +import fr.ird.observe.dto.data.ps.localmarket.SampleDto; + +import javax.swing.SwingUtilities; +import java.awt.event.ActionEvent; + +import static io.ultreia.java4all.i18n.I18n.t; + +/** + * Created on 09/09/2020. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 8.1.0 + */ +public class LocalmarketUIAddSample extends LocalmarketUIActionSupport { + + public LocalmarketUIAddSample() { + super(t("observe.data.ps.localmarket.Sample.action.create"), t("observe.data.ps.localmarket.Sample.action.create.tip"), DtoIconHelper.getIconPath(SampleDto.class), ObservePsKeyStrokes.KEY_STROKE_LOCALMARKET_ADD_SAMPLE); + } + + + @Override + protected void doActionPerformed(ActionEvent e, LocalmarketUI ui) { + NavigationTree tree = getDataSourceEditor().getNavigationUI().getTree(); + LocalmarketNavigationTreeNode parentNode = (LocalmarketNavigationTreeNode) tree.getSelectedNode(); + SampleListNavigationTreeNode nodeToSelect = (SampleListNavigationTreeNode) parentNode.findChildByType(SampleListNavigationTreeNode.class); + tree.selectSafeNode(nodeToSelect); + SampleListUI content = getDataSourceEditor().getContentUIManager().getContent(); + SwingUtilities.invokeLater(() -> content.getCreate().doClick()); + + } +} ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/localmarket/actions/LocalmarketUIAddSurvey.java ===================================== @@ -0,0 +1,61 @@ +package fr.ird.observe.client.datasource.editor.content.data.ps.localmarket.actions; + +/*- + * #%L + * ObServe :: Client DataSource Editor PS + * %% + * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io + * %% + * 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.client.datasource.editor.content.ObservePsKeyStrokes; +import fr.ird.observe.client.datasource.editor.content.data.ps.localmarket.LocalmarketUI; +import fr.ird.observe.client.datasource.editor.content.data.ps.localmarket.SurveyListUI; +import fr.ird.observe.client.datasource.editor.tree.navigation.NavigationTree; +import fr.ird.observe.client.datasource.editor.tree.navigation.nodes.data.ps.localmarket.LocalmarketNavigationTreeNode; +import fr.ird.observe.client.datasource.editor.tree.navigation.nodes.data.ps.localmarket.SurveyListNavigationTreeNode; +import fr.ird.observe.client.util.DtoIconHelper; +import fr.ird.observe.dto.data.ps.localmarket.SurveyDto; + +import javax.swing.SwingUtilities; +import java.awt.event.ActionEvent; + +import static io.ultreia.java4all.i18n.I18n.t; + +/** + * Created on 09/09/2020. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 8.1.0 + */ +public class LocalmarketUIAddSurvey extends LocalmarketUIActionSupport { + + public LocalmarketUIAddSurvey() { + super(t("observe.data.ps.localmarket.Survey.action.create"), t("observe.data.ps.localmarket.Survey.action.create.tip"), DtoIconHelper.getIconPath(SurveyDto.class), ObservePsKeyStrokes.KEY_STROKE_LOCALMARKET_ADD_SURVEY); + } + + @Override + protected void doActionPerformed(ActionEvent e, LocalmarketUI ui) { + NavigationTree tree = getDataSourceEditor().getNavigationUI().getTree(); + LocalmarketNavigationTreeNode parentNode = (LocalmarketNavigationTreeNode) tree.getSelectedNode(); + SurveyListNavigationTreeNode nodeToSelect = (SurveyListNavigationTreeNode) parentNode.findChildByType(SurveyListNavigationTreeNode.class); + tree.selectSafeNode(nodeToSelect); + SurveyListUI content = getDataSourceEditor().getContentUIManager().getContent(); + SwingUtilities.invokeLater(() -> content.getCreate().doClick()); + + } +} ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/tree/navigation/nodes/data/ps/localmarket/LocalmarketNavigationTreeNode.java ===================================== @@ -22,8 +22,10 @@ package fr.ird.observe.client.datasource.editor.tree.navigation.nodes.data.ps.lo * #L% */ +import fr.ird.observe.client.datasource.editor.content.data.ps.localmarket.LocalmarketUI; import fr.ird.observe.client.datasource.editor.tree.navigation.nodes.StringNavigationTreeNodeSupport; import fr.ird.observe.client.util.DtoIconHelper; +import fr.ird.observe.navigation.model.ObserveNavigationNode; import javax.swing.Icon; @@ -44,6 +46,21 @@ public class LocalmarketNavigationTreeNode extends StringNavigationTreeNodeSuppo add(new SampleListNavigationTreeNode()); } + @Override + public ObserveNavigationNode<?> getEditNode() { + return getEditNodeOrParentEditNode(); + } + + @Override + public Class<LocalmarketUI> getContentClass() { + return LocalmarketUI.class; + } + + @Override + public boolean isOpen() { + return super.isOpen(); + } + @Override public final Icon getIcon(boolean small) { return DtoIconHelper.getIcon("data.ps.localmarket", small); ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/tree/navigation/nodes/data/ps/localmarket/SampleNavigationTreeNode.java ===================================== @@ -27,6 +27,7 @@ import fr.ird.observe.client.datasource.editor.tree.navigation.nodes.ReferenceNa import fr.ird.observe.dto.data.ps.localmarket.SampleDto; import fr.ird.observe.dto.data.ps.localmarket.SampleReference; import fr.ird.observe.navigation.model.edit.seine.node.ObserveSeineLocalmarketSampleEditNode; +import fr.ird.observe.navigation.model.select.seine.node.ObserveSeineLocalmarketSampleSelectNode; import static io.ultreia.java4all.i18n.I18n.t; @@ -34,15 +35,12 @@ import static io.ultreia.java4all.i18n.I18n.t; * Created on 06/09/2020. * * @author Tony Chemit - dev@tchemit.fr - * @since + * @since 8.1.0 */ public class SampleNavigationTreeNode extends ReferenceNavigationTreeNodeSupport<SampleDto, SampleReference> { public SampleNavigationTreeNode(SampleReference data) { - super(data, ObserveSeineLocalmarketSampleEditNode.class, ObserveSeineLocalmarketSampleEditNode.class, true); - if (isPersisted()) { -// add(new ActivityListNavigationTreeNode()); - } + super(data, ObserveSeineLocalmarketSampleSelectNode.class, ObserveSeineLocalmarketSampleEditNode.class, false); } @Override @@ -53,7 +51,7 @@ public class SampleNavigationTreeNode extends ReferenceNavigationTreeNodeSupport @Override public boolean isLeaf() { - return !isPersisted(); + return true; } @Override ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/tree/navigation/nodes/data/ps/localmarket/SurveyNavigationTreeNode.java ===================================== @@ -27,6 +27,7 @@ import fr.ird.observe.client.datasource.editor.tree.navigation.nodes.ReferenceNa import fr.ird.observe.dto.data.ps.localmarket.SurveyDto; import fr.ird.observe.dto.data.ps.localmarket.SurveyReference; import fr.ird.observe.navigation.model.edit.seine.node.ObserveSeineLocalmarketSurveyEditNode; +import fr.ird.observe.navigation.model.select.seine.node.ObserveSeineLocalmarketSurveySelectNode; import static io.ultreia.java4all.i18n.I18n.t; @@ -39,10 +40,7 @@ import static io.ultreia.java4all.i18n.I18n.t; public class SurveyNavigationTreeNode extends ReferenceNavigationTreeNodeSupport<SurveyDto, SurveyReference> { public SurveyNavigationTreeNode(SurveyReference data) { - super(data, ObserveSeineLocalmarketSurveyEditNode.class, ObserveSeineLocalmarketSurveyEditNode.class, true); - if (isPersisted()) { -// add(new ActivityListNavigationTreeNode()); - } + super(data, ObserveSeineLocalmarketSurveySelectNode.class, ObserveSeineLocalmarketSurveyEditNode.class, false); } @Override @@ -53,7 +51,7 @@ public class SurveyNavigationTreeNode extends ReferenceNavigationTreeNodeSupport @Override public boolean isLeaf() { - return !isPersisted(); + return true; } @Override ===================================== observe-i18n/src/main/i18n/translations/observe_en_GB.properties ===================================== @@ -1380,6 +1380,7 @@ observe.data.ps.landing.Landing.title=Landing observe.data.ps.landing.Landing.type=Landing observe.data.ps.landing.Landing.weight=Weight (t) observe.data.ps.landing.Landing.weightCategory=Weight category +observe.data.ps.localmarket.Batch.action.create=Add a new batch observe.data.ps.localmarket.Batch.action.create.tip=Insert this batch observe.data.ps.localmarket.Batch.action.create.tip.tip=Insert this batch observe.data.ps.localmarket.Batch.count=Count @@ -1455,6 +1456,7 @@ observe.data.ps.localmarket.SurveyPart.table.species=Species observe.data.ps.localmarket.SurveyPart.table.species.tip=Species observe.data.ps.localmarket.SurveyPart.title=Survey part observe.data.ps.localmarket.SurveyPart.type=Survey part +observe.data.ps.localmarket.title=Local market observe.data.ps.logbook.Activity.action.addFloatingObject=Add FAD observe.data.ps.logbook.Activity.action.addFloatingObject.tip=Add a FAD to the activity observe.data.ps.logbook.Activity.action.addSet=Add a Set ===================================== observe-i18n/src/main/i18n/translations/observe_es_ES.properties ===================================== @@ -1380,6 +1380,7 @@ observe.data.ps.landing.Landing.title=Landing \#TODO observe.data.ps.landing.Landing.type=Landing \#TODO observe.data.ps.landing.Landing.weight=Weight (t) \#TODO observe.data.ps.landing.Landing.weightCategory=Weight category \#TODO +observe.data.ps.localmarket.Batch.action.create=Add a new batch \#TODO observe.data.ps.localmarket.Batch.action.create.tip=Insert this batch observe.data.ps.localmarket.Batch.action.create.tip.tip=Insert this batch observe.data.ps.localmarket.Batch.count=Count @@ -1455,6 +1456,7 @@ observe.data.ps.localmarket.SurveyPart.table.species=Species observe.data.ps.localmarket.SurveyPart.table.species.tip=Species observe.data.ps.localmarket.SurveyPart.title=Survey part observe.data.ps.localmarket.SurveyPart.type=Survey part +observe.data.ps.localmarket.title=Local market \#TODO observe.data.ps.logbook.Activity.action.addFloatingObject=Añadir un FOB observe.data.ps.logbook.Activity.action.addFloatingObject.tip=Añadir un objeto flotante a la actividad observe.data.ps.logbook.Activity.action.addSet=Añadir un lance ===================================== observe-i18n/src/main/i18n/translations/observe_fr_FR.properties ===================================== @@ -1380,6 +1380,7 @@ observe.data.ps.landing.Landing.title=Débarquements observe.data.ps.landing.Landing.type=Débarquements observe.data.ps.landing.Landing.weight=Poids (en t) observe.data.ps.landing.Landing.weightCategory=Catégorie de poids +observe.data.ps.localmarket.Batch.action.create=Ajouter un lot observe.data.ps.localmarket.Batch.action.create.tip=Insérer ce lot observe.data.ps.localmarket.Batch.action.create.tip.tip=Insérer ce lot observe.data.ps.localmarket.Batch.count=Nombre @@ -1455,6 +1456,7 @@ observe.data.ps.localmarket.SurveyPart.table.species=Espèce observe.data.ps.localmarket.SurveyPart.table.species.tip=Espèce observe.data.ps.localmarket.SurveyPart.title=Données de sondage observe.data.ps.localmarket.SurveyPart.type=Données de sondage +observe.data.ps.localmarket.title=Marché local observe.data.ps.logbook.Activity.action.addFloatingObject=Ajouter un DCP observe.data.ps.logbook.Activity.action.addFloatingObject.tip=Ajouter un objet flottant à l'activité observe.data.ps.logbook.Activity.action.addSet=Ajouter la calée ===================================== test/src/main/resources/db/8.1/dataForTestLongline.sql.gz ===================================== Binary files a/test/src/main/resources/db/8.1/dataForTestLongline.sql.gz and b/test/src/main/resources/db/8.1/dataForTestLongline.sql.gz differ ===================================== test/src/main/resources/db/8.1/dataForTestSeine.sql.gz ===================================== Binary files a/test/src/main/resources/db/8.1/dataForTestSeine.sql.gz and b/test/src/main/resources/db/8.1/dataForTestSeine.sql.gz differ ===================================== test/src/main/resources/db/8.1/referentiel.sql.gz ===================================== Binary files a/test/src/main/resources/db/8.1/referentiel.sql.gz and b/test/src/main/resources/db/8.1/referentiel.sql.gz differ View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/4ddcd7967fe72221aeeb6dbbd7... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/4ddcd7967fe72221aeeb6dbbd7... You're receiving this email because of your account on gitlab.com.