Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 0fba6fec by Tony CHEMIT at 2018-07-05T08:57:48Z [LL] Racourcis clavier non fonctionnents sur les onglets de définition de la composition globale de la palangre - See #1016 - - - - - 5 changed files: - client/src/main/java/fr/ird/observe/client/ui/actions/UIActionSupport.java - client/src/main/java/fr/ird/observe/client/ui/actions/content/AbstractContentUIAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/main/global/DeleteDataGlobalUIAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/main/global/NewNextDataGlobalUIAction.java - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/LonglineGlobalCompositionUIHandler.java Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/UIActionSupport.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/actions/UIActionSupport.java +++ b/client/src/main/java/fr/ird/observe/client/ui/actions/UIActionSupport.java @@ -37,7 +37,9 @@ import javax.swing.ActionMap; import javax.swing.Icon; import javax.swing.InputMap; import javax.swing.JComponent; +import javax.swing.JTabbedPane; import javax.swing.KeyStroke; +import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; @@ -183,4 +185,18 @@ public abstract class UIActionSupport extends AbstractAction { return ObserveSwingDataSource.MAIN; } + protected ContentUI<?, ?> getContentUI(ContentUI<?, ?> contentUI) { + if (contentUI.getObjectById("mainTabbedPane") != null) { + Component selectedComponent = ((JTabbedPane) contentUI.getObjectById("mainTabbedPane")).getSelectedComponent(); + if (selectedComponent instanceof JComponent) { + JComponent selectedComponent1 = (JComponent) selectedComponent; + Object contentUI1 = selectedComponent1.getClientProperty("contentUI"); + if (contentUI1 instanceof ContentUI) { + return (ContentUI<?, ?>) contentUI1; + } + return null; + } + } + return contentUI; + } } ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/AbstractContentUIAction.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/actions/content/AbstractContentUIAction.java +++ b/client/src/main/java/fr/ird/observe/client/ui/actions/content/AbstractContentUIAction.java @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.actions.content; * 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>. @@ -58,7 +58,20 @@ public abstract class AbstractContentUIAction extends UIActionSupport { } this.e = e; - ContentUI<?, ?> contentUI = getContentUI(e); + ContentUI<?, ?> contentUI = null; + if (getEditor() != null) { + Object ui = getEditor().getClientProperty("ui"); + if (ui instanceof ContentUI) { + contentUI = (ContentUI<?, ?>) ui; + } + } + if (contentUI == null) { + contentUI = getContentUI(e); + ContentUI<?, ?> contentUI1 = getContentUI(contentUI); + if (contentUI1 != null) { + contentUI = contentUI1; + } + } actionPerformed(contentUI); } ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/main/global/DeleteDataGlobalUIAction.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/actions/main/global/DeleteDataGlobalUIAction.java +++ b/client/src/main/java/fr/ird/observe/client/ui/actions/main/global/DeleteDataGlobalUIAction.java @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.actions.main.global; * 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>. @@ -66,19 +66,7 @@ public class DeleteDataGlobalUIAction extends GlobalUIActionSupport { } } } else { - if (contentUI instanceof ContentTableUI) { - ContentTableUI ui = (ContentTableUI) contentUI; - button = ui.getDeleteEntry(); - } else if (contentUI instanceof ContentReferenceUI) { - ContentReferenceUI ui = (ContentReferenceUI) contentUI; - if (ui.getModel().isEditing()) { - button = ui.getDeleteFromDetail(); - } else { - button = ui.getDeleteFromList(); - } - } else { - button = (JButton) contentUI.getObjectById("delete"); - } + button = getActionButton(contentUI); } Objects.requireNonNull(button); UIActionSupport action = (UIActionSupport) button.getAction(); @@ -87,4 +75,23 @@ public class DeleteDataGlobalUIAction extends GlobalUIActionSupport { return action; } + protected JButton getActionButton(ContentUI<?, ?> contentUI) { + ContentUI<?, ?> contentUI2 = getContentUI(contentUI); + if (!Objects.equals(contentUI, contentUI2)) { + return getActionButton(contentUI2); + } + if (contentUI instanceof ContentTableUI) { + ContentTableUI ui = (ContentTableUI) contentUI; + return ui.getDeleteEntry(); + } + if (contentUI instanceof ContentReferenceUI) { + ContentReferenceUI ui = (ContentReferenceUI) contentUI; + if (ui.getModel().isEditing()) { + return ui.getDeleteFromDetail(); + } + return ui.getDeleteFromList(); + } + return (JButton) contentUI.getObjectById("delete"); + } + } ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/main/global/NewNextDataGlobalUIAction.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/actions/main/global/NewNextDataGlobalUIAction.java +++ b/client/src/main/java/fr/ird/observe/client/ui/actions/main/global/NewNextDataGlobalUIAction.java @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.actions.main.global; * 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>. @@ -34,6 +34,10 @@ import fr.ird.observe.client.ui.content.table.ContentTableUI; import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI; import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JTabbedPane; +import java.awt.Component; +import java.util.Objects; /** * Created on 11/11/16. @@ -59,22 +63,32 @@ public class NewNextDataGlobalUIAction extends GlobalUIActionSupport { button = presetsUI.getCreateAction(); } } else { - - if (contentUI instanceof ContentListUI) { - ContentListUI ui = (ContentListUI) contentUI; - button = ui.getCreate(); - } else if (contentUI instanceof ContentOpenableUI) { - ContentOpenableUI ui = (ContentOpenableUI) contentUI; - button = ui.getCloseAndCreate(); - } else if (contentUI instanceof ContentTableUI) { - ContentTableUI ui = (ContentTableUI) contentUI; - button = ui.getNewEntry(); - } else if (contentUI instanceof ContentReferenceUI) { - ContentReferenceUI ui = (ContentReferenceUI) contentUI; - button = ui.getCreate(); - } + button = getActionButton(contentUI); } return button == null ? null : (UIActionSupport) button.getAction(); } + + + protected JButton getActionButton(ContentUI<?, ?> contentUI) { + ContentUI<?, ?> contentUI2 = getContentUI(contentUI); + if (!Objects.equals(contentUI,contentUI2)) { + return getActionButton(contentUI2); + } + if (contentUI instanceof ContentListUI) { + ContentListUI ui = (ContentListUI) contentUI; + return ui.getCreate(); + } else if (contentUI instanceof ContentOpenableUI) { + ContentOpenableUI ui = (ContentOpenableUI) contentUI; + return ui.getCloseAndCreate(); + } else if (contentUI instanceof ContentTableUI) { + ContentTableUI ui = (ContentTableUI) contentUI; + return ui.getNewEntry(); + } else if (contentUI instanceof ContentReferenceUI) { + ContentReferenceUI ui = (ContentReferenceUI) contentUI; + return ui.getCreate(); + } + return null; + } + } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/LonglineGlobalCompositionUIHandler.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/LonglineGlobalCompositionUIHandler.java +++ b/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/LonglineGlobalCompositionUIHandler.java @@ -95,6 +95,7 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong FloatlinesCompositionUI compositionUI = ui.getFloatlinesCompositionUI(); ui.getFloatlinesCompositionPanel().remove(compositionUI); ui.getFloatlinesCompositionPanel().add(compositionUI.getBody()); + ui.getFloatlinesCompositionPanel().putClientProperty("contentUI", compositionUI); } { @@ -102,6 +103,7 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong BranchlinesCompositionUI compositionUI = ui.getBranchlinesCompositionUI(); ui.getBranchlinesCompositionPanel().remove(compositionUI); ui.getBranchlinesCompositionPanel().add(compositionUI.getBody()); + ui.getBranchlinesCompositionPanel().putClientProperty("contentUI", compositionUI); } { @@ -109,6 +111,7 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong HooksCompositionUI compositionUI = ui.getHooksCompositionUI(); ui.getHooksCompositionPanel().remove(compositionUI); ui.getHooksCompositionPanel().add(compositionUI.getBody()); + ui.getHooksCompositionPanel().putClientProperty("contentUI", compositionUI); } { @@ -116,6 +119,7 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong BaitsCompositionUI compositionUI = ui.getBaitsCompositionUI(); ui.getBaitsCompositionPanel().remove(compositionUI); ui.getBaitsCompositionPanel().add(compositionUI.getBody()); + ui.getBaitsCompositionPanel().putClientProperty("contentUI", compositionUI); } } View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/0fba6fecc6000bba629c60d071db... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/0fba6fecc6000bba629c60d071db... You're receiving this email because of your account on gitlab.com.