Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
e5fe0fab
by Tony Chemit at 2021-01-07T14:51:31+01:00
-
3f58446c
by Tony Chemit at 2021-01-07T15:41:56+01:00
-
aceee7ee
by Tony Chemit at 2021-01-07T16:26:19+01:00
-
84ea6b17
by Tony Chemit at 2021-01-07T16:27:22+01:00
-
ee081a5d
by Tony Chemit at 2021-01-07T16:27:52+01:00
7 changed files:
- client/core/src/main/java/fr/ird/observe/client/util/init/UIInitHelper.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/ObserveKeyStrokesEditorApi.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ContentUIInitializer.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/open/ContentOpen.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUIInitializer.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ui/table/popup/AutoSelectRowAndShowPopupActionSupport.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/menu/actions/ReloadStorageAction.java
Changes:
| ... | ... | @@ -89,6 +89,16 @@ public class UIInitHelper { |
| 89 | 89 |
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0), "none");
|
| 90 | 90 |
}
|
| 91 | 91 |
|
| 92 |
+ public static void init(JTable editor) {
|
|
| 93 |
+ InputMap inputMap = editor.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
|
| 94 |
+ inputMap.put(KeyStroke.getKeyStroke("pressed UP"), "none");
|
|
| 95 |
+ inputMap.put(KeyStroke.getKeyStroke("pressed PAGE_UP"), "none");
|
|
| 96 |
+ inputMap.put(KeyStroke.getKeyStroke("pressed DOWN"), "none");
|
|
| 97 |
+ inputMap.put(KeyStroke.getKeyStroke("pressed PAGE_DOWN"), "none");
|
|
| 98 |
+ inputMap.put(KeyStroke.getKeyStroke("pressed LEFT"), "none");
|
|
| 99 |
+ inputMap.put(KeyStroke.getKeyStroke("pressed RIGHT"), "none");
|
|
| 100 |
+ }
|
|
| 101 |
+ |
|
| 92 | 102 |
public static void init(JTree editor) {
|
| 93 | 103 |
editor.getInputMap()
|
| 94 | 104 |
.put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "none");
|
| ... | ... | @@ -75,22 +75,23 @@ public class ObserveKeyStrokesEditorApi extends ObserveKeyStrokesSupport { |
| 75 | 75 |
public static final KeyStroke KEY_STROKE_TOGGLE_LOGBOOK_AVAILABILITY = KeyStroke.getKeyStroke("ctrl pressed F2");
|
| 76 | 76 |
public static final KeyStroke KEY_STROKE_COPY_TO_CLIPBOARD = KeyStroke.getKeyStroke("ctrl pressed C");
|
| 77 | 77 |
|
| 78 |
+ public static final KeyStroke KEY_STROKE_BACK_TO_REFERENTIAL_LIST = KeyStroke.getKeyStroke("alt pressed BACK_SPACE");
|
|
| 79 |
+ |
|
| 78 | 80 |
// Content Table
|
| 79 | 81 |
public static final KeyStroke KEY_STROKE_SAVE_TABLE_ENTRY = KeyStroke.getKeyStroke("ctrl pressed S");
|
| 80 | 82 |
public static final KeyStroke KEY_STROKE_SAVE_AND_NEW_TABLE_ENTRY = KeyStroke.getKeyStroke("ctrl pressed N");
|
| 81 | 83 |
public static final KeyStroke KEY_STROKE_DELETE_TABLE_ENTRY = KeyStroke.getKeyStroke("ctrl pressed E");
|
| 82 | 84 |
public static final KeyStroke KEY_STROKE_RESET_TABLE_ENTRY = KeyStroke.getKeyStroke("ctrl pressed R");
|
| 83 |
- public static final KeyStroke KEY_STROKE_BACK_TO_REFERENTIAL_LIST = KeyStroke.getKeyStroke("alt pressed BACK_SPACE");
|
|
| 84 | 85 |
|
| 85 |
- public static final KeyStroke KEY_STROKE_SELECT_FIRST_TABLE_ENTRY = KeyStroke.getKeyStroke("shift alt pressed UP");
|
|
| 86 |
+ public static final KeyStroke KEY_STROKE_SELECT_FIRST_TABLE_ENTRY = KeyStroke.getKeyStroke("alt pressed PAGE_UP");
|
|
| 86 | 87 |
public static final KeyStroke KEY_STROKE_SELECT_PREVIOUS_TABLE_ENTRY = KeyStroke.getKeyStroke("alt pressed UP");
|
| 87 | 88 |
public static final KeyStroke KEY_STROKE_SELECT_NEXT_TABLE_ENTRY = KeyStroke.getKeyStroke("alt pressed DOWN");
|
| 88 |
- public static final KeyStroke KEY_STROKE_SELECT_LAST_TABLE_ENTRY = KeyStroke.getKeyStroke("shift alt pressed DOWN");
|
|
| 89 |
+ public static final KeyStroke KEY_STROKE_SELECT_LAST_TABLE_ENTRY = KeyStroke.getKeyStroke("alt pressed PAGE_DOWN");
|
|
| 89 | 90 |
|
| 90 | 91 |
public static final KeyStroke KEY_STROKE_MOVE_DOWN_TABLE_ENTRY = KeyStroke.getKeyStroke("altGraph pressed DOWN");
|
| 91 |
- public static final KeyStroke KEY_STROKE_MOVE_BOTTOM_TABLE_ENTRY = KeyStroke.getKeyStroke("shift altGraph pressed DOWN");
|
|
| 92 |
+ public static final KeyStroke KEY_STROKE_MOVE_BOTTOM_TABLE_ENTRY = KeyStroke.getKeyStroke("altGraph pressed PAGE_DOWN");
|
|
| 92 | 93 |
public static final KeyStroke KEY_STROKE_MOVE_UP_TABLE_ENTRY = KeyStroke.getKeyStroke("altGraph pressed UP");
|
| 93 |
- public static final KeyStroke KEY_STROKE_MOVE_TOP_TABLE_ENTRY = KeyStroke.getKeyStroke("shift altGraph pressed UP");
|
|
| 94 |
+ public static final KeyStroke KEY_STROKE_MOVE_TOP_TABLE_ENTRY = KeyStroke.getKeyStroke("altGraph pressed PAGE_UP");
|
|
| 94 | 95 |
|
| 95 | 96 |
public static final KeyStroke KEY_STROKE_ADD_TABLE_ENTRY = KeyStroke.getKeyStroke("ctrl pressed INSERT");
|
| 96 | 97 |
public static final KeyStroke KEY_STROKE_DELETE_SELECTED_TABLE_ENTRY = KeyStroke.getKeyStroke("ctrl pressed DELETE");
|
| ... | ... | @@ -478,7 +478,7 @@ public class ContentUIInitializer<UI extends ContentUI> extends UIInitializerSup |
| 478 | 478 |
|
| 479 | 479 |
private void init(JTable editor) {
|
| 480 | 480 |
initializerContext.checkFirstPass();
|
| 481 |
-// UIInitHelper.init(editor);
|
|
| 481 |
+ UIInitHelper.init(editor);
|
|
| 482 | 482 |
}
|
| 483 | 483 |
|
| 484 | 484 |
@SuppressWarnings({"unchecked", "rawtypes"})
|
| ... | ... | @@ -114,6 +114,7 @@ public class ContentOpen<U extends ContentUI> { |
| 114 | 114 |
private List<JTable> tables;
|
| 115 | 115 |
private ActionMap newActionMap;
|
| 116 | 116 |
private InputMap newInputMap;
|
| 117 |
+ private List<JaxxComboBox> comboBoxs;
|
|
| 117 | 118 |
|
| 118 | 119 |
public ContentOpen(U ui, ContentOpenExecutor<U> contentOpenExecutor) {
|
| 119 | 120 |
this(ui, contentOpenExecutor, null);
|
| ... | ... | @@ -140,6 +141,7 @@ public class ContentOpen<U extends ContentUI> { |
| 140 | 141 |
public DefaultUIInitializerResult init(ContentUIInitializer<U> initializer) {
|
| 141 | 142 |
DefaultUIInitializerResult initializerResult = initializer.initUI();
|
| 142 | 143 |
tables = initializerResult.getComponentsList(JTable.class);
|
| 144 |
+ comboBoxs = initializerResult.getComponentsList(JaxxComboBox.class);
|
|
| 143 | 145 |
tabbedPaneValidator = initializerResult.getTabbedPaneValidator();
|
| 144 | 146 |
subTabbedPaneValidator = initializerResult.getSubTabbedPaneValidator();
|
| 145 | 147 |
coordinateEditors = initializerResult.getCoordinateEditors();
|
| ... | ... | @@ -153,14 +155,14 @@ public class ContentOpen<U extends ContentUI> { |
| 153 | 155 |
ui.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).setParent(null);
|
| 154 | 156 |
ui.getActionMap().setParent(null);
|
| 155 | 157 |
JComponent actionContainer = initializer.getActionContainer();
|
| 156 |
- initActions(actionContainer, initializerResult);
|
|
| 158 |
+ initActions(initializerResult);
|
|
| 157 | 159 |
ContentUIModel model = ui.getModel();
|
| 158 | 160 |
|
| 159 | 161 |
@SuppressWarnings("unchecked") ContentUIHandler<U> handler = (ContentUIHandler<U>) ui.getHandler();
|
| 160 | 162 |
model.init(ui, initializerResult);
|
| 161 | 163 |
handler.onInit(ui);
|
| 162 | 164 |
|
| 163 |
- postInstallActions(actionContainer, newInputMap, newActionMap, initializerResult);
|
|
| 165 |
+ postInstallActions(actionContainer, initializerResult);
|
|
| 164 | 166 |
|
| 165 | 167 |
model.getStates().addPropertyChangeListener(ContentUIModelStates.PROPERTY_MODE, evt -> {
|
| 166 | 168 |
ContentMode newValue = (ContentMode) evt.getNewValue();
|
| ... | ... | @@ -541,27 +543,31 @@ public class ContentOpen<U extends ContentUI> { |
| 541 | 543 |
return ui;
|
| 542 | 544 |
}
|
| 543 | 545 |
|
| 544 |
- public void initActions(JComponent actionContainer, DefaultUIInitializerResult initializerResult) {
|
|
| 546 |
+ public List<JaxxComboBox> getComboBoxs() {
|
|
| 547 |
+ return comboBoxs;
|
|
| 548 |
+ }
|
|
| 549 |
+ |
|
| 550 |
+ public void initActions(DefaultUIInitializerResult initializerResult) {
|
|
| 545 | 551 |
ContentUIHandler<?> handler = ui.getHandler();
|
| 546 | 552 |
handler.initActions();
|
| 547 | 553 |
handler.installChangeModeAction();
|
| 548 | 554 |
|
| 549 |
- InputMap inputMap = actionContainer.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
|
| 555 |
+ InputMap inputMap = ui.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
|
| 550 | 556 |
KeyStroke[] uiActionKeyStrokes = inputMap.allKeys();
|
| 551 | 557 |
log.info(String.format("%sFound %d actions to share", ui.getModel().getPrefix(), uiActionKeyStrokes.length));
|
| 552 |
- ActionMap actionMap = actionContainer.getActionMap();
|
|
| 558 |
+ ActionMap actionMap = ui.getActionMap();
|
|
| 553 | 559 |
newActionMap = new ActionMapUIResource();
|
| 554 | 560 |
newInputMap = new InputMapUIResource();
|
| 555 | 561 |
for (KeyStroke actionKeyStroke : uiActionKeyStrokes) {
|
| 556 | 562 |
Object actionMapKey = inputMap.get(actionKeyStroke);
|
| 557 |
- newInputMap.put(actionKeyStroke, actionMapKey);
|
|
| 558 | 563 |
Action action = actionMap.get(actionMapKey);
|
| 559 | 564 |
if (action instanceof MenuAction) {
|
| 560 | 565 |
log.info(String.format("Skip menu action %s → %s", actionKeyStroke, actionMapKey));
|
| 561 | 566 |
continue;
|
| 562 | 567 |
}
|
| 563 |
- newActionMap.put(actionMapKey, action);
|
|
| 564 | 568 |
log.info(String.format("Register action %s → %s", actionKeyStroke, actionMapKey));
|
| 569 |
+ newInputMap.put(actionKeyStroke, actionMapKey);
|
|
| 570 |
+ newActionMap.put(actionMapKey, action);
|
|
| 565 | 571 |
}
|
| 566 | 572 |
|
| 567 | 573 |
ContentUIModel model = ui.getModel();
|
| ... | ... | @@ -582,17 +588,42 @@ public class ContentOpen<U extends ContentUI> { |
| 582 | 588 |
handler.updateToggleInsertVisibility();
|
| 583 | 589 |
}
|
| 584 | 590 |
|
| 585 |
- protected void postInstallActions(JComponent actionContainer, InputMap newInputMap, ActionMap newActionMap, DefaultUIInitializerResult initializerResult) {
|
|
| 591 |
+ protected void postInstallActions(JComponent actionContainer, DefaultUIInitializerResult initializerResult) {
|
|
| 586 | 592 |
KeyStroke[] keyStrokes = newInputMap.allKeys();
|
| 587 |
- initializerResult.getComponents(JaxxComboBox.class).forEach(editor -> UIInitHelper.cleanInputMapAndSet(editor, keyStrokes, newInputMap, newActionMap));
|
|
| 593 |
+ initializerResult.getComponents(JaxxComboBox.class).forEach(editor -> UIInitHelper.cleanInputMapAndSet(editor.getCombobox(), keyStrokes, newInputMap, newActionMap));
|
|
| 588 | 594 |
initializerResult.getComponents(JTable.class).forEach(editor -> UIInitHelper.cleanInputMap(editor, keyStrokes));
|
| 589 | 595 |
for (Map.Entry<ContentTableUI<?, ?, ?>, JPanel> entry : subUiMap.entrySet()) {
|
| 590 | 596 |
ContentTableUI<?, ?, ?> subUi = entry.getKey();
|
| 591 |
- subUi.getHandler().getContentOpen().getTables().forEach(editor -> UIInitHelper.cleanInputMap(editor, keyStrokes));
|
|
| 597 |
+ InputMap newInputMapSubUi = subUi.getHandler().getContentOpen().getNewInputMap();
|
|
| 598 |
+ ActionMap newActionMapSubUi = subUi.getHandler().getContentOpen().getNewActionMap();
|
|
| 599 |
+ newInputMapSubUi.setParent(newInputMap);
|
|
| 600 |
+ newActionMapSubUi.setParent(newActionMap);
|
|
| 601 |
+ KeyStroke[] keyStrokesSubUi = newInputMapSubUi.allKeys();
|
|
| 602 |
+ for (KeyStroke keyStroke : keyStrokesSubUi) {
|
|
| 603 |
+ if (newInputMap.get(keyStroke)!=null) {
|
|
| 604 |
+ Object o = newInputMapSubUi.get(keyStroke);
|
|
| 605 |
+ if (o!=null) {
|
|
| 606 |
+ newActionMapSubUi.remove(o);
|
|
| 607 |
+ newInputMapSubUi.remove(keyStroke);
|
|
| 608 |
+ }
|
|
| 609 |
+ }
|
|
| 610 |
+ }
|
|
| 611 |
+ subUi.getBody().setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, newInputMapSubUi);
|
|
| 612 |
+ subUi.getBody().setActionMap(newActionMapSubUi);
|
|
| 613 |
+ subUi.getHandler().getContentOpen().getTables().forEach(editor -> UIInitHelper.cleanInputMap(editor, keyStrokesSubUi));
|
|
| 614 |
+ subUi.getHandler().getContentOpen().getComboBoxs().forEach(editor -> UIInitHelper.cleanInputMapAndSet(editor.getCombobox(), keyStrokesSubUi, newInputMapSubUi, newActionMapSubUi));
|
|
| 592 | 615 |
//FIXME:Actions We should define some scope only for subUi ?
|
| 593 | 616 |
}
|
| 594 | 617 |
}
|
| 595 | 618 |
|
| 619 |
+ public ActionMap getNewActionMap() {
|
|
| 620 |
+ return newActionMap;
|
|
| 621 |
+ }
|
|
| 622 |
+ |
|
| 623 |
+ public InputMap getNewInputMap() {
|
|
| 624 |
+ return newInputMap;
|
|
| 625 |
+ }
|
|
| 626 |
+ |
|
| 596 | 627 |
private void onToggleDateTimeEditorSliderChanged(boolean newValue) {
|
| 597 | 628 |
if (!toggleDateTimeEditorSliderIsChanging) {
|
| 598 | 629 |
toggleDateTimeEditorSliderIsChanging = true;
|
| ... | ... | @@ -93,11 +93,6 @@ public class ContentTableUIInitializer<D extends DataDto, C extends DataDto, U e |
| 93 | 93 |
ui.getSelectPreviousTableEntry().setEnabled(false);
|
| 94 | 94 |
ui.getSelectNextTableEntry().setEnabled(false);
|
| 95 | 95 |
ui.getSelectLastTableEntry().setEnabled(false);
|
| 96 |
- InputMap inputMap = ui.getTable().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
|
| 97 |
- inputMap.put(KeyStroke.getKeyStroke("pressed UP"), "none");
|
|
| 98 |
- inputMap.put(KeyStroke.getKeyStroke("pressed DOWN"), "none");
|
|
| 99 |
- inputMap.put(KeyStroke.getKeyStroke("pressed LEFT"), "none");
|
|
| 100 |
- inputMap.put(KeyStroke.getKeyStroke("pressed RIGHT"), "none");
|
|
| 101 | 96 |
|
| 102 | 97 |
ui.getTitleRightToolBar().add(ui.getSelectToolbar(), 0);
|
| 103 | 98 |
|
| ... | ... | @@ -113,20 +113,16 @@ public abstract class AutoSelectRowAndShowPopupActionSupport { |
| 113 | 113 |
log.debug("At point [" + p + "] found Row " + rowIndex + ", Column " + columnIndex);
|
| 114 | 114 |
|
| 115 | 115 |
boolean canContinue = stopEdit();
|
| 116 |
- if (canContinue) {
|
|
| 116 |
+ if (canContinue && rowIndex != -1 && columnIndex != -1) {
|
|
| 117 | 117 |
|
| 118 | 118 |
// select row (could empty selection)
|
| 119 |
- if (rowIndex == -1) {
|
|
| 120 |
- table.clearSelection();
|
|
| 121 |
- } else if (!ArrayUtils.contains(selectedRows, rowIndex)) {
|
|
| 119 |
+ if (!ArrayUtils.contains(selectedRows, rowIndex)) {
|
|
| 122 | 120 |
// set selection
|
| 123 | 121 |
table.setRowSelectionInterval(rowIndex, rowIndex);
|
| 124 | 122 |
}
|
| 125 | 123 |
|
| 126 | 124 |
// select column (could empty selection)
|
| 127 |
- if (columnIndex == -1) {
|
|
| 128 |
- table.clearSelection();
|
|
| 129 |
- } else if (!ArrayUtils.contains(selectedColumns, columnIndex)) {
|
|
| 125 |
+ if (!ArrayUtils.contains(selectedColumns, columnIndex)) {
|
|
| 130 | 126 |
table.setColumnSelectionInterval(columnIndex, columnIndex);
|
| 131 | 127 |
}
|
| 132 | 128 |
|
| ... | ... | @@ -46,13 +46,9 @@ public class ReloadStorageAction extends DataSourceEditorMenuActionSupport imple |
| 46 | 46 |
super(t("observe.ui.action.reload.storage"), t("observe.ui.action.reload.storage.tip"), "db-reload", 'R');
|
| 47 | 47 |
}
|
| 48 | 48 |
|
| 49 |
- public ReloadStorageAction(String actionName, char keyStroke) {
|
|
| 50 |
- super(actionName, t("observe.ui.action.reload.storage"), t("observe.ui.action.reload.storage.tip"), "db-reload", keyStroke);
|
|
| 51 |
- }
|
|
| 52 |
- |
|
| 53 | 49 |
@Override
|
| 54 | 50 |
protected void doActionPerformed(ActionEvent event, DataSourceEditorMenu ui) {
|
| 55 |
- run();
|
|
| 51 |
+ getClientUIContext().getActionExecutor().addAction(getText(), this);
|
|
| 56 | 52 |
}
|
| 57 | 53 |
|
| 58 | 54 |
@Override
|