Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 612e8156 by Tony CHEMIT at 2018-10-03T01:20:22Z improve navigation config design - - - - - 9a074550 by Tony CHEMIT at 2018-10-03T01:20:55Z comment some debug code - - - - - 595dfc21 by Tony CHEMIT at 2018-10-03T01:21:13Z fix ui prefix - - - - - 12a06934 by Tony CHEMIT at 2018-10-03T01:21:55Z add license header - - - - - 97c73e8c by Tony CHEMIT at 2018-10-03T01:22:11Z [V8] L'accès au formulaire Echantillons logbooks LL ne fonctionne pas - Closes #1109 - - - - - 18 changed files: - client/src/main/java/fr/ird/observe/client/ui/ObserveMainUIInitializer.java - + client/src/main/java/fr/ird/observe/client/ui/actions/content/tree/NavigationConfigUIActionSupport.java - + client/src/main/java/fr/ird/observe/client/ui/actions/content/tree/ToggleConfigureNavigationConfigUIAction.java - + client/src/main/java/fr/ird/observe/client/ui/actions/content/tree/ToggleShowEmptyNavigationConfigUIAction.java - + client/src/main/java/fr/ird/observe/client/ui/actions/content/tree/ToggleShowLonglineNavigationConfigUIAction.java - + client/src/main/java/fr/ird/observe/client/ui/actions/content/tree/ToggleShowReferentialNavigationConfigUIAction.java - + client/src/main/java/fr/ird/observe/client/ui/actions/content/tree/ToggleShowSeineNavigationConfigUIAction.java - client/src/main/java/fr/ird/observe/client/ui/content/api/ContentUIModel.java - client/src/main/java/fr/ird/observe/client/ui/content/api/data/table/action/ContentTableUIEntryActionSupport.java - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookSampleUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/SamplePartLogbookUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/TripLonglineLandingLogbookUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/TripLonglineSampleLogbookUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/TripLonglineSampleLogbookUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jcss - client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/util/UIHelper.java Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/ObserveMainUIInitializer.java ===================================== @@ -416,6 +416,7 @@ public class ObserveMainUIInitializer { ui.getNavigationView().addMouseListener(mouseAdapter); ui.getNavigationUI().getTree().addMouseListener(mouseAdapter); ui.getNavigationUI().addMouseListener(mouseAdapter); + ui.getNavigationUI().getHandler().init(actionMap); init(ui.getSplitpane()); init(ui.getSplitpane2()); ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/tree/NavigationConfigUIActionSupport.java ===================================== @@ -0,0 +1,48 @@ +package fr.ird.observe.client.ui.actions.content.tree; + +/*- + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2018 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.ui.ObserveMainUI; +import fr.ird.observe.client.ui.actions.main.menu.MenuActionSupport; + +import javax.swing.Icon; +import javax.swing.KeyStroke; +import java.awt.event.ActionEvent; + +/** + * Created by tchemit on 03/10/2018. + * + * @author Tony Chemit - dev@tchemit.fr + */ +public abstract class NavigationConfigUIActionSupport extends MenuActionSupport { + + NavigationConfigUIActionSupport(ObserveMainUI mainUI, String actionCommandKey, String label, String shortDescription, Icon actionIcon, KeyStroke acceleratorKey) { + super(mainUI, actionCommandKey, label, shortDescription, null, acceleratorKey); + putValue(SMALL_ICON, actionIcon); + } + + @Override + protected void doActionPerformed(ActionEvent e) { + getMainUI().getNavigationUI().getHandler().tryToUpdateNavigationTree(); + } +} ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/tree/ToggleConfigureNavigationConfigUIAction.java ===================================== @@ -0,0 +1,51 @@ +package fr.ird.observe.client.ui.actions.content.tree; + +/*- + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2018 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.ui.ObserveKeyStrokes; +import fr.ird.observe.client.ui.ObserveMainUI; +import fr.ird.observe.client.ui.actions.UIActionSupport; + +import java.awt.event.ActionEvent; + +import static org.nuiton.i18n.I18n.n; + +/** + * Created by tchemit on 03/10/2018. + * + * @author Tony Chemit - dev@tchemit.fr + */ +public class ToggleConfigureNavigationConfigUIAction extends UIActionSupport { + + public static final String ACTION_NAME = ToggleConfigureNavigationConfigUIAction.class.getName(); + + public ToggleConfigureNavigationConfigUIAction(ObserveMainUI mainUI) { + super(mainUI, ACTION_NAME, null, n("observe.tree.action.configure.tip"), "generate", ObserveKeyStrokes.KEY_STROKE_NAVIGATION_CONFIGURE); + } + + @Override + public void actionPerformed(ActionEvent e) { + getMainUI().getNavigationUI().getHandler().configure(); + } + +} ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/tree/ToggleShowEmptyNavigationConfigUIAction.java ===================================== @@ -0,0 +1,44 @@ +package fr.ird.observe.client.ui.actions.content.tree; + +/*- + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2018 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.ui.ObserveKeyStrokes; +import fr.ird.observe.client.ui.ObserveMainUI; +import fr.ird.observe.client.ui.util.UIHelper; + +import static org.nuiton.i18n.I18n.n; + +/** + * Created by tchemit on 03/10/2018. + * + * @author Tony Chemit - dev@tchemit.fr + */ +public class ToggleShowEmptyNavigationConfigUIAction extends NavigationConfigUIActionSupport { + + public static final String ACTION_NAME = ToggleShowEmptyNavigationConfigUIAction.class.getName(); + + public ToggleShowEmptyNavigationConfigUIAction(ObserveMainUI mainUI) { + super(mainUI, ACTION_NAME, n("observe.constant.ObserveModelType.EMPTY"), n("observe.constant.ObserveModelType.EMPTY.description"), UIHelper.getUIManagerIcon("navigation.data.seine.TripSeine-16"), ObserveKeyStrokes.KEY_STROKE_SHOW_EMPTY_PROGRAM); + } + +} ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/tree/ToggleShowLonglineNavigationConfigUIAction.java ===================================== @@ -0,0 +1,44 @@ +package fr.ird.observe.client.ui.actions.content.tree; + +/*- + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2018 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.ui.ObserveKeyStrokes; +import fr.ird.observe.client.ui.ObserveMainUI; +import fr.ird.observe.client.ui.util.UIHelper; + +import static org.nuiton.i18n.I18n.n; + +/** + * Created by tchemit on 03/10/2018. + * + * @author Tony Chemit - dev@tchemit.fr + */ +public class ToggleShowLonglineNavigationConfigUIAction extends NavigationConfigUIActionSupport { + + public static final String ACTION_NAME = ToggleShowLonglineNavigationConfigUIAction.class.getName(); + + public ToggleShowLonglineNavigationConfigUIAction(ObserveMainUI mainUI) { + super(mainUI, ACTION_NAME, n("observe.constant.ObserveModelType.LL"), n("observe.constant.ObserveModelType.LL.description"), UIHelper.getUIManagerIcon("navigation.referential.Program-16"), ObserveKeyStrokes.KEY_STROKE_SHOW_LONGLINE); + } + +} ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/tree/ToggleShowReferentialNavigationConfigUIAction.java ===================================== @@ -0,0 +1,44 @@ +package fr.ird.observe.client.ui.actions.content.tree; + +/*- + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2018 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.ui.ObserveKeyStrokes; +import fr.ird.observe.client.ui.ObserveMainUI; +import fr.ird.observe.client.ui.util.UIHelper; + +import static org.nuiton.i18n.I18n.n; + +/** + * Created by tchemit on 03/10/2018. + * + * @author Tony Chemit - dev@tchemit.fr + */ +public class ToggleShowReferentialNavigationConfigUIAction extends NavigationConfigUIActionSupport { + + public static final String ACTION_NAME = ToggleShowReferentialNavigationConfigUIAction.class.getName(); + + public ToggleShowReferentialNavigationConfigUIAction(ObserveMainUI mainUI) { + super(mainUI, ACTION_NAME, n("observe.constant.ObserveModelType.REF"), n("observe.constant.ObserveModelType.REF.description"), UIHelper.getUIManagerIcon("navigation.referentiel-16"), ObserveKeyStrokes.KEY_STROKE_SHOW_REFERENTIAL); + } + +} ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/tree/ToggleShowSeineNavigationConfigUIAction.java ===================================== @@ -0,0 +1,44 @@ +package fr.ird.observe.client.ui.actions.content.tree; + +/*- + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2018 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.ui.ObserveKeyStrokes; +import fr.ird.observe.client.ui.ObserveMainUI; +import fr.ird.observe.client.ui.util.UIHelper; + +import static org.nuiton.i18n.I18n.n; + +/** + * Created by tchemit on 03/10/2018. + * + * @author Tony Chemit - dev@tchemit.fr + */ +public class ToggleShowSeineNavigationConfigUIAction extends NavigationConfigUIActionSupport { + + public static final String ACTION_NAME = ToggleShowSeineNavigationConfigUIAction.class.getName(); + + public ToggleShowSeineNavigationConfigUIAction(ObserveMainUI mainUI) { + super(mainUI, ACTION_NAME, n("observe.constant.ObserveModelType.PS"), n("observe.constant.ObserveModelType.PS.description"), UIHelper.getUIManagerIcon("navigation.referential.Program-16"), ObserveKeyStrokes.KEY_STROKE_SHOW_SEINE); + } + +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/api/ContentUIModel.java ===================================== @@ -79,7 +79,7 @@ public abstract class ContentUIModel extends AbstractSerializableBean { private boolean addMessageOnOpen = true; protected ContentUIModel() { - prefix = "[" + getClass().getSimpleName() + "] "; + prefix = "[" + getClass().getSimpleName().replace("Model", "") + "] "; } static <U extends ContentUI> ContentUIModel newModel(U ui) { ===================================== client/src/main/java/fr/ird/observe/client/ui/content/api/data/table/action/ContentTableUIEntryActionSupport.java ===================================== @@ -1,5 +1,27 @@ package fr.ird.observe.client.ui.content.api.data.table.action; +/*- + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2018 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.ui.ObserveMainUI; import fr.ird.observe.client.ui.actions.UIActionSupport; import fr.ird.observe.client.ui.content.api.data.table.ContentTableModel; @@ -45,8 +67,10 @@ public abstract class ContentTableUIEntryActionSupport extends UIActionSupport { @Override public final void actionPerformed(ActionEvent e) { if (!isEnabled()) { + log.info(String.format("Reject action: %s :: %s", getActionCommandKey(), this)); return; } + log.info(String.format("Accept action: %s :: %s", getActionCommandKey(), this)); boolean focusOwner = ui.getTable().isFocusOwner(); log.debug("table has focus? " + focusOwner); if (focusOwner) { ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookSampleUIHandler.java ===================================== @@ -37,6 +37,8 @@ import org.nuiton.jaxx.runtime.spi.UIHandler; import java.awt.Component; import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.Insets; import java.util.Optional; /** @@ -66,7 +68,13 @@ public class ActivityLonglineLogbookSampleUIHandler extends ContentSimpleUIHandl ui.getSamplePartLogbookPanel().remove(subUI); ui.getSamplePartLogbookPanel().add(subUI.getBody()); ui.getSamplePartLogbookPanel().putClientProperty("contentUI", subUI); + ui.getTitleRightToolBar().add(subUI.getSelectToolbar(), 0); } + + ui.getActions().add(ui.getReset(), new GridBagConstraints(0, 0, 1, 1, 0.5, 0.0, 10, 1, new Insets(0, 0, 0, 0), 0, 0)); + ui.getActions().add(ui.getSave(), new GridBagConstraints(1, 0, 1, 1, 0.5, 0.0, 10, 1, new Insets(0, 0, 0, 0), 0, 0)); + ui.getActions().add(ui.getMove(), new GridBagConstraints(2, 0, 1, 1, 0.5, 0.0, 10, 1, new Insets(0, 0, 0, 0), 0, 0)); + } @Override ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/SamplePartLogbookUIHandler.java ===================================== @@ -62,6 +62,7 @@ public class SamplePartLogbookUIHandler extends ContentTableUIHandler<SampleLogb private static final Logger log = LogManager.getLogger(SamplePartLogbookUIHandler.class); private final PropertyChangeListener speciesChanged; + private boolean fromActivity; SamplePartLogbookUIHandler() { speciesChanged = evt -> onSpeciesChanged((SpeciesReference) evt.getNewValue()); @@ -70,7 +71,8 @@ public class SamplePartLogbookUIHandler extends ContentTableUIHandler<SampleLogb @Override public void beforeInit(SamplePartLogbookUI ui) { super.beforeInit(ui); - if (ui.getContextValue(Boolean.class, "fromActivity") != null) { + fromActivity = ui.getContextValue(Boolean.class, "fromActivity") != null; + if (fromActivity) { ui.removeContextValue(Boolean.class, "fromActivity"); ui.setContextValue(new SamplePartLogbookUIModel(ui, ObserveSwingApplicationContext.get().getNavigationSelect().getLongline().getActivityLogbook())); } else { @@ -171,12 +173,17 @@ public class SamplePartLogbookUIHandler extends ContentTableUIHandler<SampleLogb @Override public void afterInit(SamplePartLogbookUI ui) { addReferentialFilter(SamplePartLogbookDto.PROPERTY_SPECIES, incomingReferences -> { - String setId = ObserveSwingApplicationContext.get().getNavigationSelect().getLongline().getActivityLogbookSet().getId(); - if (setId == null) { - return new LinkedList<>(); + if (fromActivity) { +// FIXME We do not have the set selected here (since this is a brother of it) + String setId = ObserveSwingApplicationContext.get().getNavigationSelect().getLongline().getActivityLogbookSet().getId(); + if (setId == null) { + return incomingReferences; + } + ReferentialDtoReferenceSet<SpeciesReference> sampleSpecies = getSetLonglineLogbookCatchService().getSampleSpecies(setId); + return new LinkedList<>(sampleSpecies.toSet()); + } else { + return incomingReferences; } - ReferentialDtoReferenceSet<SpeciesReference> sampleSpecies = getSetLonglineLogbookCatchService().getSampleSpecies(setId); - return new LinkedList<>(sampleSpecies.toSet()); }); super.afterInit(ui); } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/TripLonglineLandingLogbookUIHandler.java ===================================== @@ -65,7 +65,12 @@ public class TripLonglineLandingLogbookUIHandler extends ContentOpenableUIHandle ui.getLandingPartPanel().remove(subUI); ui.getLandingPartPanel().add(subUI.getBody()); ui.getLandingPartPanel().putClientProperty("contentUI", subUI); + ui.getTitleRightToolBar().add(subUI.getSelectToolbar(), 0); + subUI.getSelectToolbar().setVisible(false); } + ui.getMainTabbedPane().addChangeListener( + l -> ui.getLandingPartLogbookUI().getSelectToolbar().setVisible(ui.getMainTabbedPane().getSelectedIndex() == 1) + ); } @Override ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/TripLonglineSampleLogbookUI.jaxx ===================================== @@ -112,6 +112,7 @@ <JButton id='reopen'/> <JButton id='close'/> <JButton id='create'/> + <JButton id='save'/> <!-- actions --> <Table id="extraActions" fill='both' weightx='1' insets='0'> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/TripLonglineSampleLogbookUIHandler.java ===================================== @@ -58,10 +58,17 @@ class TripLonglineSampleLogbookUIHandler extends ContentOpenableUIHandler<Sample { // init floatlinesComposition tab SamplePartLogbookUI subUI = ui.getSamplePartLogbookUI(); + subUI.getModel().setStandalone(false); ui.getSamplePartLogbookPanel().remove(subUI); ui.getSamplePartLogbookPanel().add(subUI.getBody()); ui.getSamplePartLogbookPanel().putClientProperty("contentUI", subUI); + + ui.getTitleRightToolBar().add(subUI.getSelectToolbar(), 0); + subUI.getSelectToolbar().setVisible(false); } + ui.getMainTabbedPane().addChangeListener( + l -> ui.getSamplePartLogbookUI().getSelectToolbar().setVisible(ui.getMainTabbedPane().getSelectedIndex() == 1) + ); getModel().addPropertyChangeListener(TripLonglineSampleLogbookUIModel.PROPERTY_MODE, evt -> showPartsTab(evt.getNewValue() != ContentMode.CREATE)); } ===================================== client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jaxx ===================================== @@ -23,6 +23,12 @@ <import> fr.ird.observe.client.configuration.NavigationTreeConfigBean + fr.ird.observe.client.ui.actions.content.tree.ToggleShowSeineNavigationConfigUIAction + fr.ird.observe.client.ui.actions.content.tree.ToggleShowLonglineNavigationConfigUIAction + fr.ird.observe.client.ui.actions.content.tree.ToggleShowReferentialNavigationConfigUIAction + fr.ird.observe.client.ui.actions.content.tree.ToggleShowEmptyNavigationConfigUIAction + fr.ird.observe.client.ui.actions.content.tree.ToggleConfigureNavigationConfigUIAction + static org.nuiton.i18n.I18n.t </import> <NavigationTree id='tree' /> @@ -30,16 +36,16 @@ <NavigationTreeConfigBean id='navigationConfig' javaBean='treeModel.getConfig()'/> <JPopupMenu id='configurePopup'> - <JCheckBoxMenuItem id='showSeineTrip' onActionPerformed="handler.tryToUpdateNavigationTree()"/> - <JCheckBoxMenuItem id='showLonglineTrip' onActionPerformed="handler.tryToUpdateNavigationTree()"/> - <JCheckBoxMenuItem id='showReferential' onActionPerformed="handler.tryToUpdateNavigationTree()"/> - <JCheckBoxMenuItem id='showEmptyProgram' onActionPerformed="handler.tryToUpdateNavigationTree()"/> + <JCheckBoxMenuItem id='showSeineTrip'/> + <JCheckBoxMenuItem id='showLonglineTrip'/> + <JCheckBoxMenuItem id='showReferential'/> + <JCheckBoxMenuItem id='showEmptyProgram'/> </JPopupMenu> <JToolBar id='toolbar'> <JButton id='colapseAll' onActionPerformed='handler.collapseAll()'/> <JButton id='expandAll' onActionPerformed='handler.expandAll()'/> - <JToggleButton id='configure' onActionPerformed='handler.configure()'/> + <JToggleButton id='configure'/> </JToolBar> </JScrollPane> ===================================== client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jcss ===================================== @@ -22,23 +22,27 @@ #showSeineTrip { selected: {navigationConfig.isShowSeineTrip()}; - text:"observe.constant.ObserveModelType.PS"; - toolTipText:"observe.constant.ObserveModelType.PS.description"; + _observeAction:{ToggleShowSeineNavigationConfigUIAction.ACTION_NAME}; + /*text:"observe.constant.ObserveModelType.PS"; + toolTipText:"observe.constant.ObserveModelType.PS.description";*/ } #showLonglineTrip { selected: {navigationConfig.isShowLonglineTrip()}; - text:"observe.constant.ObserveModelType.LL"; - toolTipText:"observe.constant.ObserveModelType.LL.description"; + _observeAction:{ToggleShowLonglineNavigationConfigUIAction.ACTION_NAME}; + /*text:"observe.constant.ObserveModelType.LL"; + toolTipText:"observe.constant.ObserveModelType.LL.description";*/ } #showReferential { selected: {navigationConfig.isShowReferential()}; - text:"observe.constant.ObserveModelType.REF"; - toolTipText:"observe.constant.ObserveModelType.REF.description"; + _observeAction:{ToggleShowReferentialNavigationConfigUIAction.ACTION_NAME}; + /*text:"observe.constant.ObserveModelType.REF"; + toolTipText:"observe.constant.ObserveModelType.REF.description";*/ } #showEmptyProgram { selected: {navigationConfig.isShowEmptyProgram()}; - text:"observe.constant.ObserveModelType.EMPTY"; - toolTipText:"observe.constant.ObserveModelType.EMPTY.description"; + _observeAction:{ToggleShowEmptyNavigationConfigUIAction.ACTION_NAME}; + /*text:"observe.constant.ObserveModelType.EMPTY"; + toolTipText:"observe.constant.ObserveModelType.EMPTY.description";*/ } JToggleButton { @@ -62,8 +66,9 @@ JButton { } #configure { - actionIcon:generate; - toolTipText:"observe.tree.action.configure.tip"; + _observeAction:{ToggleConfigureNavigationConfigUIAction.ACTION_NAME}; + /*actionIcon:generate; + toolTipText:"observe.tree.action.configure.tip";*/ } #tree { ===================================== client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUIHandler.java ===================================== @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.tree.navigation; * 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>. @@ -25,19 +25,17 @@ package fr.ird.observe.client.ui.tree.navigation; import fr.ird.observe.client.ObserveSwingApplicationContext; import fr.ird.observe.client.configuration.ClientConfig; import fr.ird.observe.client.configuration.NavigationTreeConfig; -import fr.ird.observe.client.ui.ObserveKeyStrokes; +import fr.ird.observe.client.ui.actions.UIActionSupport; +import fr.ird.observe.client.ui.content.api.spi.ObserveActionMap; import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; -import fr.ird.observe.client.ui.util.UIHelper; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jdesktop.swingx.decorator.ColorHighlighter; import org.jdesktop.swingx.search.Searchable; import org.jdesktop.swingx.search.TreeSearchable; import org.nuiton.jaxx.runtime.spi.UIHandler; -import javax.swing.AbstractAction; -import javax.swing.ActionMap; -import javax.swing.InputMap; +import javax.swing.AbstractButton; import javax.swing.JComponent; import javax.swing.JPopupMenu; import javax.swing.SwingUtilities; @@ -45,7 +43,9 @@ import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuListener; import java.awt.Color; import java.awt.Dimension; -import java.awt.event.ActionEvent; +import java.util.Objects; + +import static fr.ird.observe.client.ui.content.api.ContentUIInitializer.OBSERVE_ACTION; /** * Created by tchemit on 01/04/2018. @@ -54,7 +54,6 @@ import java.awt.event.ActionEvent; */ public class NavigationUIHandler implements UIHandler<NavigationUI> { - /** Logger */ private static final Logger log = LogManager.getLogger(NavigationUIHandler.class); private NavigationUI ui; @@ -72,80 +71,27 @@ public class NavigationUIHandler implements UIHandler<NavigationUI> { this.ui = ui; } + public void init(ObserveActionMap actionMap) { + init(actionMap, ui.getShowSeineTrip()); + init(actionMap, ui.getShowLonglineTrip()); + init(actionMap, ui.getShowReferential()); + init(actionMap, ui.getShowEmptyProgram()); + init(actionMap, ui.getConfigure()); + } + @Override public void afterInit(NavigationUI ui) { - ui.getShowSeineTrip().setIcon(UIHelper.getUIManagerIcon("navigation.referential.Program-16")); - ui.getShowLonglineTrip().setIcon(UIHelper.getUIManagerIcon("navigation.referential.Program-16")); - ui.getShowReferential().setIcon(UIHelper.getUIManagerIcon("navigation.referentiel-16")); - ui.getShowEmptyProgram().setIcon(UIHelper.getUIManagerIcon("navigation.data.seine.TripSeine-16")); - NavigationTree tree = ui.getTree(); TreeSearchable searchable = new TreeSearchable(tree); tree.setSearchable(searchable); searchable.setMatchHighlighter(new ColorHighlighter(Color.YELLOW, Color.BLACK)); - ObserveKeyStrokes.addKeyStroke(ui.getShowSeineTrip(), ObserveKeyStrokes.KEY_STROKE_SHOW_SEINE); - ObserveKeyStrokes.addKeyStroke(ui.getShowLonglineTrip(), ObserveKeyStrokes.KEY_STROKE_SHOW_LONGLINE); - ObserveKeyStrokes.addKeyStroke(ui.getShowReferential(), ObserveKeyStrokes.KEY_STROKE_SHOW_REFERENTIAL); - ObserveKeyStrokes.addKeyStroke(ui.getShowEmptyProgram(), ObserveKeyStrokes.KEY_STROKE_SHOW_EMPTY_PROGRAM); - ObserveKeyStrokes.addKeyStroke(ui.getConfigure(), ObserveKeyStrokes.KEY_STROKE_NAVIGATION_CONFIGURE); - //FIXME (no text, so no text after...) - ui.getConfigure().setText(null); +// ui.getConfigure().setText(null); ClientConfig config = ObserveSwingApplicationContext.get().getConfig(); NavigationTreeModel treeModel = (NavigationTreeModel) tree.getModel(); treeModel.load(config); - InputMap inputMap = ui.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); - ActionMap actionMap = ui.getActionMap(); - inputMap.put(ObserveKeyStrokes.KEY_STROKE_SHOW_SEINE, "showSeine"); - actionMap.put("showSeine", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - if (ui.getConfigurePopup().isVisible()) { - ui.getShowSeineTrip().doClick(); - } - ui.getConfigurePopup().setVisible(false); - } - }); - inputMap.put(ObserveKeyStrokes.KEY_STROKE_SHOW_LONGLINE, "showLongline"); - actionMap.put("showLongline", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - if (ui.getConfigurePopup().isVisible()) { - ui.getShowLonglineTrip().doClick(); - } - ui.getConfigurePopup().setVisible(false); - } - }); - inputMap.put(ObserveKeyStrokes.KEY_STROKE_SHOW_REFERENTIAL, "showReferential"); - actionMap.put("showReferential", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - if (ui.getConfigurePopup().isVisible()) { - ui.getShowReferential().doClick(); - } - ui.getConfigurePopup().setVisible(false); - } - }); - inputMap.put(ObserveKeyStrokes.KEY_STROKE_SHOW_EMPTY_PROGRAM, "showEmptyProgram"); - actionMap.put("showEmptyProgram", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - if (ui.getConfigurePopup().isVisible()) { - ui.getShowEmptyProgram().doClick(); - } - ui.getConfigurePopup().setVisible(false); - } - }); - inputMap.put(ObserveKeyStrokes.KEY_STROKE_NAVIGATION_CONFIGURE, "configure"); - actionMap.put("configure", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - ui.getConfigure().doClick(); - } - }); - ui.getConfigurePopup().addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { @@ -164,7 +110,8 @@ public class NavigationUIHandler implements UIHandler<NavigationUI> { }); } - void configure() { + public void configure() { + ui.getConfigure().setSelected(true); SwingUtilities.invokeLater(() -> { JComponent c = ui.getConfigure(); JPopupMenu p = ui.getConfigurePopup(); @@ -186,7 +133,26 @@ public class NavigationUIHandler implements UIHandler<NavigationUI> { } - void tryToUpdateNavigationTree() { + protected void init(ObserveActionMap actionMap, AbstractButton editor) { + String actionId = (String) editor.getClientProperty(OBSERVE_ACTION); + if (actionId == null) { + + return; + } + + // on a trouve une action commune + UIActionSupport action = (UIActionSupport) actionMap.get(actionId); + Objects.requireNonNull(action, "action [" + actionId + "] not found for ui " + ui.getClass().getName()); + + if (log.isDebugEnabled()) { + log.debug("init common action " + actionId); + } + + action.initForMainUi(editor); + + } + + public void tryToUpdateNavigationTree() { boolean canContinue = ObserveSwingApplicationContext.get().getContentUIManager().closeSelectedContentUI(); @@ -223,19 +189,14 @@ public class NavigationUIHandler implements UIHandler<NavigationUI> { } public void collapseAll() { - NavigationTree tree = getTree(); tree.clearSelection(); tree.collapseAll(); tree.setSelectionRow(0); - } public void expandAll() { - NavigationTree tree = getTree(); tree.expandAll(); - } - } ===================================== client/src/main/java/fr/ird/observe/client/ui/util/UIHelper.java ===================================== @@ -598,9 +598,10 @@ public class UIHelper extends SwingUtil { SwingUtilities.invokeLater(component::requestFocus); } else if (ObserveSwingApplicationContext.get().getMainUI().getModel().canAcquireFocus()) { SwingUtilities.invokeLater(() -> { - log.info("ask focus for component: " + component.getName()); - boolean b = component.requestFocusInWindow(); - log.info(String.format("Will request focus %s ? %s", component.getName(), b)); + log.debug("ask focus for component: " + component.getName()); + /*boolean b =*/ + component.requestFocusInWindow(); +// log.debug(String.format("Will request focus %s ? %s", component.getName(), b)); }); } } View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/2c61cea2e0b57bec3d0f72f4e63... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/2c61cea2e0b57bec3d0f72f4e63... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT