Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
6dd42c94
by Tony Chemit at 2020-12-22T15:48:45+01:00
-
fdc62d8b
by Tony Chemit at 2020-12-22T15:51:41+01:00
-
bdf480bd
by Tony Chemit at 2020-12-22T15:52:00+01:00
-
cedaee45
by Tony Chemit at 2020-12-22T16:13:31+01:00
9 changed files:
- client/core/src/main/java/fr/ird/observe/client/datasource/api/ObserveSwingDataSource.java
- client/core/src/main/java/fr/ird/observe/client/main/body/MainUIBodyContent.java
- client/core/src/main/java/fr/ird/observe/client/main/body/MainUIBodyContentManager.java
- client/core/src/main/java/fr/ird/observe/client/main/callback/ReloadUiCallback.java
- client/core/src/main/java/fr/ird/observe/client/util/init/DefaultUIInitializer.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/DataSourceEditorBodyContent.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ContentUIHandler.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ContentUIInitializer.java
- pom.xml
Changes:
| ... | ... | @@ -443,7 +443,7 @@ public class ObserveSwingDataSource extends ObserveServicesProviderSupport imple |
| 443 | 443 |
listenerList.remove(ObserveSwingDataSourceListener.class, listener);
|
| 444 | 444 |
}
|
| 445 | 445 |
|
| 446 |
- private ObserveSwingDataSourceListener[] getObserveSwingDataSourceListener() {
|
|
| 446 |
+ public ObserveSwingDataSourceListener[] getObserveSwingDataSourceListener() {
|
|
| 447 | 447 |
return listenerList.getListeners(ObserveSwingDataSourceListener.class);
|
| 448 | 448 |
}
|
| 449 | 449 |
|
| ... | ... | @@ -22,6 +22,7 @@ package fr.ird.observe.client.main.body; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import fr.ird.observe.client.ClientUIContext;
|
|
| 25 | 26 |
import fr.ird.observe.client.main.ObserveMainUI;
|
| 26 | 27 |
import io.ultreia.java4all.util.SingletonSupplier;
|
| 27 | 28 |
|
| ... | ... | @@ -120,6 +121,15 @@ public abstract class MainUIBodyContent<B extends JComponent> implements Supplie |
| 120 | 121 |
supplier.clear();
|
| 121 | 122 |
}
|
| 122 | 123 |
|
| 124 |
+ /**
|
|
| 125 |
+ * when ui was recreated, make what you can to reload this content.
|
|
| 126 |
+ * @param clientUIContext new client context
|
|
| 127 |
+ * @param mainUI new main ui
|
|
| 128 |
+ */
|
|
| 129 |
+ public void reloadContent(ClientUIContext clientUIContext, ObserveMainUI mainUI) {
|
|
| 130 |
+ |
|
| 131 |
+ }
|
|
| 132 |
+ |
|
| 123 | 133 |
public void setSupplier(SingletonSupplier<B> supplier) {
|
| 124 | 134 |
this.supplier = Objects.requireNonNull(supplier);
|
| 125 | 135 |
}
|
| ... | ... | @@ -195,4 +195,8 @@ public class MainUIBodyContentManager extends AbstractJavaBean { |
| 195 | 195 |
changeCurrentBody(previousBody);
|
| 196 | 196 |
}
|
| 197 | 197 |
}
|
| 198 |
+ |
|
| 199 |
+ public MainUIBodyContent<?> getPreviousBody() {
|
|
| 200 |
+ return previousBody;
|
|
| 201 |
+ }
|
|
| 198 | 202 |
}
|
| ... | ... | @@ -26,15 +26,19 @@ import com.google.auto.service.AutoService; |
| 26 | 26 |
import fr.ird.observe.client.ClientUIContext;
|
| 27 | 27 |
import fr.ird.observe.client.configuration.ClientConfig;
|
| 28 | 28 |
import fr.ird.observe.client.configuration.WithClientConfig;
|
| 29 |
+import fr.ird.observe.client.datasource.api.ObserveSwingDataSource;
|
|
| 29 | 30 |
import fr.ird.observe.client.main.ObserveMainUI;
|
| 30 | 31 |
import fr.ird.observe.client.main.body.ClientConfigUI;
|
| 32 |
+import fr.ird.observe.client.main.body.MainUIBodyContent;
|
|
| 31 | 33 |
import fr.ird.observe.client.main.body.NoBodyContentComponent;
|
| 34 |
+import fr.ird.observe.client.util.UIHelper;
|
|
| 32 | 35 |
import io.ultreia.java4all.application.context.ApplicationContext;
|
| 33 | 36 |
import org.nuiton.jaxx.runtime.swing.SwingUtil;
|
| 34 | 37 |
|
| 35 | 38 |
import javax.swing.Icon;
|
| 36 | 39 |
import javax.swing.JComponent;
|
| 37 | 40 |
import java.util.Objects;
|
| 41 |
+import java.util.Optional;
|
|
| 38 | 42 |
|
| 39 | 43 |
import static io.ultreia.java4all.i18n.I18n.n;
|
| 40 | 44 |
|
| ... | ... | @@ -74,21 +78,33 @@ public class ReloadUiCallback implements ObserveUICallback, WithClientConfig { |
| 74 | 78 |
|
| 75 | 79 |
//FIXME:BodyContent, cela doit être délégué au body content concerné
|
| 76 | 80 |
Class<? extends JComponent> bodyContent = NoBodyContentComponent.class;
|
| 81 |
+ MainUIBodyContent<?> previousBody = null;
|
|
| 77 | 82 |
if (ui != null) {
|
| 78 | 83 |
// Keep a reference on ui instance since it will be reset in close method
|
| 79 | 84 |
// FIXME Should use a closing state in application to improve this
|
| 80 | 85 |
ObserveMainUI ui = this.ui;
|
| 81 |
- bodyContent = ui.getMainUIBodyContentManager().getCurrentBodyType();
|
|
| 82 |
- if (ClientConfigUI.class.equals(bodyContent)) {
|
|
| 83 |
- bodyContent = NoBodyContentComponent.class;
|
|
| 86 |
+ previousBody = ui.getMainUIBodyContentManager().getPreviousBody();
|
|
| 87 |
+ Optional<ObserveSwingDataSource> mainDataSource = clientUIContext.getDataSourcesManager().getOptionalMainDataSource();
|
|
| 88 |
+ if (mainDataSource.isPresent() && previousBody != null) {
|
|
| 89 |
+ bodyContent = previousBody.type();
|
|
| 90 |
+ } else {
|
|
| 91 |
+ previousBody = null;
|
|
| 92 |
+ bodyContent = ui.getMainUIBodyContentManager().getCurrentBodyType();
|
|
| 93 |
+ if (ClientConfigUI.class.equals(bodyContent)) {
|
|
| 94 |
+ bodyContent = NoBodyContentComponent.class;
|
|
| 95 |
+ }
|
|
| 84 | 96 |
}
|
| 85 | 97 |
ui.dispose();
|
| 86 | 98 |
System.runFinalization();
|
| 87 | 99 |
}
|
| 88 | 100 |
|
| 89 | 101 |
ui = clientUIContext.initUI(rootContext, config);
|
| 90 |
- |
|
| 91 |
- ui.changeBodyContent(bodyContent);
|
|
| 102 |
+ if (previousBody != null) {
|
|
| 103 |
+ MainUIBodyContent<? extends JComponent> body = ui.getMainUIBodyContentManager().getBody(bodyContent);
|
|
| 104 |
+ body.reloadContent(clientUIContext, ui);
|
|
| 105 |
+ } else {
|
|
| 106 |
+ ui.changeBodyContent(bodyContent);
|
|
| 107 |
+ }
|
|
| 92 | 108 |
|
| 93 | 109 |
// show ui
|
| 94 | 110 |
clientUIContext.setMainUIVisible(ui, true);
|
| ... | ... | @@ -166,6 +166,7 @@ public class DefaultUIInitializer<UI extends JComponent & JAXXObject> extends UI |
| 166 | 166 |
initializerContext.checkFirstPass();
|
| 167 | 167 |
editor.getCombobox().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), "none");
|
| 168 | 168 |
editor.setI18nPrefix("observe.common.");
|
| 169 |
+ editor.setAutoSelectContent(true);
|
|
| 169 | 170 |
editor.setMinimumSize(new Dimension(0, 24));
|
| 170 | 171 |
if (StringUtils.isEmpty(editor.getConfig().getProperty())) {
|
| 171 | 172 |
editor.setProperty(editor.getName());
|
| ... | ... | @@ -23,11 +23,13 @@ package fr.ird.observe.client.datasource.editor.api; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import com.google.auto.service.AutoService;
|
| 26 |
+import fr.ird.observe.client.ClientUIContext;
|
|
| 26 | 27 |
import fr.ird.observe.client.WithClientUIContext;
|
| 27 | 28 |
import fr.ird.observe.client.configuration.ClientConfig;
|
| 28 | 29 |
import fr.ird.observe.client.configuration.WithClientConfig;
|
| 29 | 30 |
import fr.ird.observe.client.constants.DbMode;
|
| 30 | 31 |
import fr.ird.observe.client.datasource.api.ObserveSwingDataSource;
|
| 32 |
+import fr.ird.observe.client.datasource.api.event.ObserveSwingDataSourceListener;
|
|
| 31 | 33 |
import fr.ird.observe.client.datasource.editor.api.menu.DataSourceEditorMenu;
|
| 32 | 34 |
import fr.ird.observe.client.datasource.editor.api.menu.DataSourceEditorNavigationMenu;
|
| 33 | 35 |
import fr.ird.observe.client.datasource.editor.api.menu.actions.ChangeStorageAction;
|
| ... | ... | @@ -177,6 +179,28 @@ public class DataSourceEditorBodyContent extends MainUIBodyContent<DataSourceEdi |
| 177 | 179 |
}
|
| 178 | 180 |
}
|
| 179 | 181 |
|
| 182 |
+ @Override
|
|
| 183 |
+ public void reloadContent(ClientUIContext clientUIContext, ObserveMainUI mainUI) {
|
|
| 184 |
+ ObserveSwingDataSource mainDataSource = clientUIContext.getDataSourcesManager().getMainDataSource();
|
|
| 185 |
+ if (mainDataSource.isOpen()) {
|
|
| 186 |
+ // need to remove any old listeners
|
|
| 187 |
+ for (ObserveSwingDataSourceListener listener : mainDataSource.getObserveSwingDataSourceListener()) {
|
|
| 188 |
+ if (listener instanceof MainDataSourceListener) {
|
|
| 189 |
+ log.info("Remove obsolete listener: "+listener);
|
|
| 190 |
+ mainDataSource.removeObserveSwingDataSourceListener(listener);
|
|
| 191 |
+ }
|
|
| 192 |
+ }
|
|
| 193 |
+ }
|
|
| 194 |
+ prepareMainStorage(mainDataSource);
|
|
| 195 |
+ try {
|
|
| 196 |
+ setDataSource(mainDataSource);
|
|
| 197 |
+ mainUI.changeBodyContent(DataSourceEditor.class);
|
|
| 198 |
+ } catch (Exception e) {
|
|
| 199 |
+ UIHelper.handlingError(e);
|
|
| 200 |
+ mainUI.removeBodyContent();
|
|
| 201 |
+ }
|
|
| 202 |
+ }
|
|
| 203 |
+ |
|
| 180 | 204 |
public void doChangeStorage(Set<DbMode> dbModes, String title) {
|
| 181 | 205 |
ChangeStorageAction action = new ChangeStorageAction(dbModes, title);
|
| 182 | 206 |
action.run();
|
| ... | ... | @@ -48,7 +48,6 @@ import fr.ird.observe.dto.form.Form; |
| 48 | 48 |
import fr.ird.observe.dto.reference.ReferentialDtoReference;
|
| 49 | 49 |
import fr.ird.observe.services.ObserveServicesProvider;
|
| 50 | 50 |
import fr.ird.observe.services.service.ObserveService;
|
| 51 |
-import io.ultreia.java4all.jaxx.widgets.combobox.JaxxComboBox;
|
|
| 52 | 51 |
import io.ultreia.java4all.util.SingletonSupplier;
|
| 53 | 52 |
import org.apache.logging.log4j.LogManager;
|
| 54 | 53 |
import org.apache.logging.log4j.Logger;
|
| ... | ... | @@ -61,10 +60,8 @@ import javax.swing.Icon; |
| 61 | 60 |
import javax.swing.JButton;
|
| 62 | 61 |
import javax.swing.JComponent;
|
| 63 | 62 |
import javax.swing.JMenuItem;
|
| 64 |
-import javax.swing.JTextField;
|
|
| 65 | 63 |
import javax.swing.SwingUtilities;
|
| 66 | 64 |
import java.awt.Component;
|
| 67 |
-import java.awt.Container;
|
|
| 68 | 65 |
import java.awt.FocusTraversalPolicy;
|
| 69 | 66 |
import java.awt.KeyboardFocusManager;
|
| 70 | 67 |
import java.beans.PropertyChangeListener;
|
| ... | ... | @@ -445,30 +442,14 @@ public abstract class ContentUIHandler<U extends ContentUI> implements ObserveSe |
| 445 | 442 |
focusAdjusting = true;
|
| 446 | 443 |
try {
|
| 447 | 444 |
getModel().setFormFocusOwner(newValue);
|
| 448 |
- //FIXME on contentTable should also check we are in entry form
|
|
| 449 | 445 |
if (getDataSourceEditor().getModel().isFocusOnNavigation()) {
|
| 450 |
- return;
|
|
| 451 |
- }
|
|
| 452 |
- if ("ComboBox.textField".equals(newValue.getName())) {
|
|
| 453 |
- if (!getModel().getStates().isReadingMode()) {
|
|
| 454 |
- // we are on jaxx combo box, let's open popup
|
|
| 455 |
- Container parent = newValue.getParent();
|
|
| 456 |
- if (parent!=null) {
|
|
| 457 |
- parent = parent.getParent();
|
|
| 458 |
- if (parent!=null) {
|
|
| 459 |
- JaxxComboBox<?> combo = (JaxxComboBox<?>) parent;
|
|
| 460 |
- log.debug(String.format("On a JaxxComboBox: %s on edit mode, will open popup", combo.getName()));
|
|
| 461 |
- ((JTextField)newValue).setCaretPosition(0);
|
|
| 462 |
- combo.getCombobox().setPopupVisible(true);
|
|
| 463 |
- }
|
|
| 464 |
- }
|
|
| 465 |
- }
|
|
| 446 |
+ //FIXME on contentTable should also check we are in entry form
|
|
| 466 | 447 |
}
|
| 467 | 448 |
} finally {
|
| 468 | 449 |
focusAdjusting = false;
|
| 469 | 450 |
}
|
| 470 | 451 |
} else {
|
| 471 |
- log.debug(String.format("%sCan't set focus owner: %s", prefix,newValue));
|
|
| 452 |
+ log.debug(String.format("%sCan't set focus owner: %s", prefix, newValue));
|
|
| 472 | 453 |
}
|
| 473 | 454 |
}
|
| 474 | 455 |
|
| ... | ... | @@ -309,6 +309,7 @@ public class ContentUIInitializer<UI extends ContentUI> extends UIInitializerSup |
| 309 | 309 |
editor.getCombobox().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), "none");
|
| 310 | 310 |
@SuppressWarnings({"RawTypeCanBeGeneric", "rawtypes"}) Class referenceType = editor.getBeanType();
|
| 311 | 311 |
editor.setI18nPrefix("observe.common.");
|
| 312 |
+ editor.setAutoSelectContent(true);
|
|
| 312 | 313 |
editor.setMinimumSize(new Dimension(0, 24));
|
| 313 | 314 |
editor.setShowReset(true);
|
| 314 | 315 |
if (StringUtils.isEmpty(editor.getConfig().getProperty())) {
|
| ... | ... | @@ -155,7 +155,7 @@ |
| 155 | 155 |
|
| 156 | 156 |
<!-- <lib.version.java4all.topia>1.35</lib.version.java4all.topia>-->
|
| 157 | 157 |
<!-- <lib.version.java4all.eugene>3.0-alpha-38</lib.version.java4all.eugene>-->
|
| 158 |
-<!-- <lib.version.java4all.jaxx>3.0-alpha-85</lib.version.java4all.jaxx>-->
|
|
| 158 |
+ <lib.version.java4all.jaxx>3.0-alpha-86</lib.version.java4all.jaxx>
|
|
| 159 | 159 |
<!--<lib.version.java4all.application-context>1.0.3-SNAPSHOT</lib.version.java4all.application-context>-->
|
| 160 | 160 |
<!--<lib.version.java4all.application-template>1.0.2-SNAPSHOT</lib.version.java4all.application-template>-->
|
| 161 | 161 |
<!--<lib.version.java4all.i18n>4.0-beta-3-SNAPSHOT</lib.version.java4all.i18n>-->
|