Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe
Commits:
-
0fba6fec
by Tony CHEMIT at 2018-07-05T08:57:48Z
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:
| ... | ... | @@ -37,7 +37,9 @@ import javax.swing.ActionMap; |
| 37 | 37 |
import javax.swing.Icon;
|
| 38 | 38 |
import javax.swing.InputMap;
|
| 39 | 39 |
import javax.swing.JComponent;
|
| 40 |
+import javax.swing.JTabbedPane;
|
|
| 40 | 41 |
import javax.swing.KeyStroke;
|
| 42 |
+import java.awt.Component;
|
|
| 41 | 43 |
import java.awt.event.ActionEvent;
|
| 42 | 44 |
import java.awt.event.InputEvent;
|
| 43 | 45 |
|
| ... | ... | @@ -183,4 +185,18 @@ public abstract class UIActionSupport extends AbstractAction { |
| 183 | 185 |
return ObserveSwingDataSource.MAIN;
|
| 184 | 186 |
}
|
| 185 | 187 |
|
| 188 |
+ protected ContentUI<?, ?> getContentUI(ContentUI<?, ?> contentUI) {
|
|
| 189 |
+ if (contentUI.getObjectById("mainTabbedPane") != null) {
|
|
| 190 |
+ Component selectedComponent = ((JTabbedPane) contentUI.getObjectById("mainTabbedPane")).getSelectedComponent();
|
|
| 191 |
+ if (selectedComponent instanceof JComponent) {
|
|
| 192 |
+ JComponent selectedComponent1 = (JComponent) selectedComponent;
|
|
| 193 |
+ Object contentUI1 = selectedComponent1.getClientProperty("contentUI");
|
|
| 194 |
+ if (contentUI1 instanceof ContentUI) {
|
|
| 195 |
+ return (ContentUI<?, ?>) contentUI1;
|
|
| 196 |
+ }
|
|
| 197 |
+ return null;
|
|
| 198 |
+ }
|
|
| 199 |
+ }
|
|
| 200 |
+ return contentUI;
|
|
| 201 |
+ }
|
|
| 186 | 202 |
}
|
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.actions.content; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| ... | ... | @@ -58,7 +58,20 @@ public abstract class AbstractContentUIAction extends UIActionSupport { |
| 58 | 58 |
}
|
| 59 | 59 |
this.e = e;
|
| 60 | 60 |
|
| 61 |
- ContentUI<?, ?> contentUI = getContentUI(e);
|
|
| 61 |
+ ContentUI<?, ?> contentUI = null;
|
|
| 62 |
+ if (getEditor() != null) {
|
|
| 63 |
+ Object ui = getEditor().getClientProperty("ui");
|
|
| 64 |
+ if (ui instanceof ContentUI) {
|
|
| 65 |
+ contentUI = (ContentUI<?, ?>) ui;
|
|
| 66 |
+ }
|
|
| 67 |
+ }
|
|
| 68 |
+ if (contentUI == null) {
|
|
| 69 |
+ contentUI = getContentUI(e);
|
|
| 70 |
+ ContentUI<?, ?> contentUI1 = getContentUI(contentUI);
|
|
| 71 |
+ if (contentUI1 != null) {
|
|
| 72 |
+ contentUI = contentUI1;
|
|
| 73 |
+ }
|
|
| 74 |
+ }
|
|
| 62 | 75 |
actionPerformed(contentUI);
|
| 63 | 76 |
}
|
| 64 | 77 |
|
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.actions.main.global; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| ... | ... | @@ -66,19 +66,7 @@ public class DeleteDataGlobalUIAction extends GlobalUIActionSupport { |
| 66 | 66 |
}
|
| 67 | 67 |
}
|
| 68 | 68 |
} else {
|
| 69 |
- if (contentUI instanceof ContentTableUI) {
|
|
| 70 |
- ContentTableUI ui = (ContentTableUI) contentUI;
|
|
| 71 |
- button = ui.getDeleteEntry();
|
|
| 72 |
- } else if (contentUI instanceof ContentReferenceUI) {
|
|
| 73 |
- ContentReferenceUI ui = (ContentReferenceUI) contentUI;
|
|
| 74 |
- if (ui.getModel().isEditing()) {
|
|
| 75 |
- button = ui.getDeleteFromDetail();
|
|
| 76 |
- } else {
|
|
| 77 |
- button = ui.getDeleteFromList();
|
|
| 78 |
- }
|
|
| 79 |
- } else {
|
|
| 80 |
- button = (JButton) contentUI.getObjectById("delete");
|
|
| 81 |
- }
|
|
| 69 |
+ button = getActionButton(contentUI);
|
|
| 82 | 70 |
}
|
| 83 | 71 |
Objects.requireNonNull(button);
|
| 84 | 72 |
UIActionSupport action = (UIActionSupport) button.getAction();
|
| ... | ... | @@ -87,4 +75,23 @@ public class DeleteDataGlobalUIAction extends GlobalUIActionSupport { |
| 87 | 75 |
return action;
|
| 88 | 76 |
}
|
| 89 | 77 |
|
| 78 |
+ protected JButton getActionButton(ContentUI<?, ?> contentUI) {
|
|
| 79 |
+ ContentUI<?, ?> contentUI2 = getContentUI(contentUI);
|
|
| 80 |
+ if (!Objects.equals(contentUI, contentUI2)) {
|
|
| 81 |
+ return getActionButton(contentUI2);
|
|
| 82 |
+ }
|
|
| 83 |
+ if (contentUI instanceof ContentTableUI) {
|
|
| 84 |
+ ContentTableUI ui = (ContentTableUI) contentUI;
|
|
| 85 |
+ return ui.getDeleteEntry();
|
|
| 86 |
+ }
|
|
| 87 |
+ if (contentUI instanceof ContentReferenceUI) {
|
|
| 88 |
+ ContentReferenceUI ui = (ContentReferenceUI) contentUI;
|
|
| 89 |
+ if (ui.getModel().isEditing()) {
|
|
| 90 |
+ return ui.getDeleteFromDetail();
|
|
| 91 |
+ }
|
|
| 92 |
+ return ui.getDeleteFromList();
|
|
| 93 |
+ }
|
|
| 94 |
+ return (JButton) contentUI.getObjectById("delete");
|
|
| 95 |
+ }
|
|
| 96 |
+ |
|
| 90 | 97 |
}
|
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.actions.main.global; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| ... | ... | @@ -34,6 +34,10 @@ import fr.ird.observe.client.ui.content.table.ContentTableUI; |
| 34 | 34 |
import fr.ird.observe.client.ui.storage.presets.RemotePresetsUI;
|
| 35 | 35 |
|
| 36 | 36 |
import javax.swing.JButton;
|
| 37 |
+import javax.swing.JComponent;
|
|
| 38 |
+import javax.swing.JTabbedPane;
|
|
| 39 |
+import java.awt.Component;
|
|
| 40 |
+import java.util.Objects;
|
|
| 37 | 41 |
|
| 38 | 42 |
/**
|
| 39 | 43 |
* Created on 11/11/16.
|
| ... | ... | @@ -59,22 +63,32 @@ public class NewNextDataGlobalUIAction extends GlobalUIActionSupport { |
| 59 | 63 |
button = presetsUI.getCreateAction();
|
| 60 | 64 |
}
|
| 61 | 65 |
} else {
|
| 62 |
- |
|
| 63 |
- if (contentUI instanceof ContentListUI) {
|
|
| 64 |
- ContentListUI ui = (ContentListUI) contentUI;
|
|
| 65 |
- button = ui.getCreate();
|
|
| 66 |
- } else if (contentUI instanceof ContentOpenableUI) {
|
|
| 67 |
- ContentOpenableUI ui = (ContentOpenableUI) contentUI;
|
|
| 68 |
- button = ui.getCloseAndCreate();
|
|
| 69 |
- } else if (contentUI instanceof ContentTableUI) {
|
|
| 70 |
- ContentTableUI ui = (ContentTableUI) contentUI;
|
|
| 71 |
- button = ui.getNewEntry();
|
|
| 72 |
- } else if (contentUI instanceof ContentReferenceUI) {
|
|
| 73 |
- ContentReferenceUI ui = (ContentReferenceUI) contentUI;
|
|
| 74 |
- button = ui.getCreate();
|
|
| 75 |
- }
|
|
| 66 |
+ button = getActionButton(contentUI);
|
|
| 76 | 67 |
}
|
| 77 | 68 |
return button == null ? null : (UIActionSupport) button.getAction();
|
| 78 | 69 |
}
|
| 79 | 70 |
|
| 71 |
+ |
|
| 72 |
+ |
|
| 73 |
+ protected JButton getActionButton(ContentUI<?, ?> contentUI) {
|
|
| 74 |
+ ContentUI<?, ?> contentUI2 = getContentUI(contentUI);
|
|
| 75 |
+ if (!Objects.equals(contentUI,contentUI2)) {
|
|
| 76 |
+ return getActionButton(contentUI2);
|
|
| 77 |
+ }
|
|
| 78 |
+ if (contentUI instanceof ContentListUI) {
|
|
| 79 |
+ ContentListUI ui = (ContentListUI) contentUI;
|
|
| 80 |
+ return ui.getCreate();
|
|
| 81 |
+ } else if (contentUI instanceof ContentOpenableUI) {
|
|
| 82 |
+ ContentOpenableUI ui = (ContentOpenableUI) contentUI;
|
|
| 83 |
+ return ui.getCloseAndCreate();
|
|
| 84 |
+ } else if (contentUI instanceof ContentTableUI) {
|
|
| 85 |
+ ContentTableUI ui = (ContentTableUI) contentUI;
|
|
| 86 |
+ return ui.getNewEntry();
|
|
| 87 |
+ } else if (contentUI instanceof ContentReferenceUI) {
|
|
| 88 |
+ ContentReferenceUI ui = (ContentReferenceUI) contentUI;
|
|
| 89 |
+ return ui.getCreate();
|
|
| 90 |
+ }
|
|
| 91 |
+ return null;
|
|
| 92 |
+ }
|
|
| 93 |
+ |
|
| 80 | 94 |
}
|
| ... | ... | @@ -95,6 +95,7 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong |
| 95 | 95 |
FloatlinesCompositionUI compositionUI = ui.getFloatlinesCompositionUI();
|
| 96 | 96 |
ui.getFloatlinesCompositionPanel().remove(compositionUI);
|
| 97 | 97 |
ui.getFloatlinesCompositionPanel().add(compositionUI.getBody());
|
| 98 |
+ ui.getFloatlinesCompositionPanel().putClientProperty("contentUI", compositionUI);
|
|
| 98 | 99 |
}
|
| 99 | 100 |
|
| 100 | 101 |
{
|
| ... | ... | @@ -102,6 +103,7 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong |
| 102 | 103 |
BranchlinesCompositionUI compositionUI = ui.getBranchlinesCompositionUI();
|
| 103 | 104 |
ui.getBranchlinesCompositionPanel().remove(compositionUI);
|
| 104 | 105 |
ui.getBranchlinesCompositionPanel().add(compositionUI.getBody());
|
| 106 |
+ ui.getBranchlinesCompositionPanel().putClientProperty("contentUI", compositionUI);
|
|
| 105 | 107 |
}
|
| 106 | 108 |
|
| 107 | 109 |
{
|
| ... | ... | @@ -109,6 +111,7 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong |
| 109 | 111 |
HooksCompositionUI compositionUI = ui.getHooksCompositionUI();
|
| 110 | 112 |
ui.getHooksCompositionPanel().remove(compositionUI);
|
| 111 | 113 |
ui.getHooksCompositionPanel().add(compositionUI.getBody());
|
| 114 |
+ ui.getHooksCompositionPanel().putClientProperty("contentUI", compositionUI);
|
|
| 112 | 115 |
}
|
| 113 | 116 |
|
| 114 | 117 |
{
|
| ... | ... | @@ -116,6 +119,7 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong |
| 116 | 119 |
BaitsCompositionUI compositionUI = ui.getBaitsCompositionUI();
|
| 117 | 120 |
ui.getBaitsCompositionPanel().remove(compositionUI);
|
| 118 | 121 |
ui.getBaitsCompositionPanel().add(compositionUI.getBody());
|
| 122 |
+ ui.getBaitsCompositionPanel().putClientProperty("contentUI", compositionUI);
|
|
| 119 | 123 |
}
|
| 120 | 124 |
}
|
| 121 | 125 |
|