Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
7ee7eb28
by Tony Chemit at 2020-07-10T11:01:52+02:00
-
ad4c3466
by Tony Chemit at 2020-07-10T12:44:31+02:00
7 changed files:
- client-core/src/main/java/fr/ird/observe/client/ObserveSwingApplicationContext.java
- client-core/src/main/java/fr/ird/observe/client/datasource/api/ObserveDataSourcesManager.java
- client-core/src/main/java/fr/ird/observe/client/datasource/api/ObserveSwingDataSource.java
- client-core/src/main/java/fr/ird/observe/client/main/ObserveMainUI.jaxx
- client-core/src/main/java/fr/ird/observe/client/main/actions/ReloadApplicationAction.java
- client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/wizard/StorageUIModel.java
- client-runner/src/main/java/fr/ird/observe/client/RunObserve.java
Changes:
| ... | ... | @@ -22,9 +22,9 @@ |
| 22 | 22 |
package fr.ird.observe.client;
|
| 23 | 23 |
|
| 24 | 24 |
import fr.ird.observe.client.configuration.ClientConfig;
|
| 25 |
-import fr.ird.observe.client.datasource.api.ObserveSwingDataSource;
|
|
| 26 | 25 |
import fr.ird.observe.services.ObserveServiceMainFactory;
|
| 27 | 26 |
import fr.ird.observe.services.ObserveServiceMainFactoryApplicationComponent;
|
| 27 |
+import fr.ird.observe.services.configuration.ObserveDataSourceConfiguration;
|
|
| 28 | 28 |
import fr.ird.observe.spi.DtoModelHelper;
|
| 29 | 29 |
import io.ultreia.java4all.application.context.ApplicationContext;
|
| 30 | 30 |
import org.apache.logging.log4j.LogManager;
|
| ... | ... | @@ -45,7 +45,7 @@ import static io.ultreia.java4all.i18n.I18n.n; |
| 45 | 45 |
public class ObserveSwingApplicationContext extends ApplicationContext {
|
| 46 | 46 |
|
| 47 | 47 |
private static final Logger log = LogManager.getLogger(ObserveSwingApplicationContext.class);
|
| 48 |
- private static ObserveSwingDataSource dataSourceToReload;
|
|
| 48 |
+ private static ObserveDataSourceConfiguration dataSourceConfigurationToReload;
|
|
| 49 | 49 |
|
| 50 | 50 |
public static ObserveSwingApplicationContext init(ClientConfig config) {
|
| 51 | 51 |
ClientConfigFinderInstance.config = config;
|
| ... | ... | @@ -94,11 +94,11 @@ public class ObserveSwingApplicationContext extends ApplicationContext { |
| 94 | 94 |
|
| 95 | 95 |
}
|
| 96 | 96 |
|
| 97 |
- public static void setDataSourceToReload(ObserveSwingDataSource dataSourceToReload) {
|
|
| 98 |
- ObserveSwingApplicationContext.dataSourceToReload = dataSourceToReload;
|
|
| 97 |
+ public static void setDataSourceToReload(ObserveDataSourceConfiguration dataSourceToReload) {
|
|
| 98 |
+ ObserveSwingApplicationContext.dataSourceConfigurationToReload = dataSourceToReload;
|
|
| 99 | 99 |
}
|
| 100 | 100 |
|
| 101 |
- public static Optional<ObserveSwingDataSource> getDataSourceToReload() {
|
|
| 102 |
- return Optional.ofNullable(dataSourceToReload);
|
|
| 101 |
+ public static Optional<ObserveDataSourceConfiguration> getDataSourceToReload() {
|
|
| 102 |
+ return Optional.ofNullable(dataSourceConfigurationToReload);
|
|
| 103 | 103 |
}
|
| 104 | 104 |
}
|
| ... | ... | @@ -25,7 +25,6 @@ package fr.ird.observe.client.datasource.api; |
| 25 | 25 |
import fr.ird.observe.client.configuration.ClientConfig;
|
| 26 | 26 |
import fr.ird.observe.client.datasource.api.event.ObserveSwingDataSourceEvent;
|
| 27 | 27 |
import fr.ird.observe.client.datasource.api.event.ObserveSwingDataSourceListenerAdapter;
|
| 28 |
-import fr.ird.observe.client.util.ProgressModel;
|
|
| 29 | 28 |
import fr.ird.observe.navigation.model.edit.ObserveEditModel;
|
| 30 | 29 |
import fr.ird.observe.navigation.model.select.ObserveSelectModel;
|
| 31 | 30 |
import fr.ird.observe.services.ObserveDataSourceConfigurationMainFactory;
|
| ... | ... | @@ -50,6 +49,7 @@ import java.io.File; |
| 50 | 49 |
import java.util.ArrayList;
|
| 51 | 50 |
import java.util.LinkedList;
|
| 52 | 51 |
import java.util.List;
|
| 52 |
+import java.util.Objects;
|
|
| 53 | 53 |
import java.util.Optional;
|
| 54 | 54 |
import java.util.UUID;
|
| 55 | 55 |
|
| ... | ... | @@ -205,6 +205,10 @@ public class ObserveDataSourcesManager implements Closeable { |
| 205 | 205 |
super.onClosed(event);
|
| 206 | 206 |
ObserveSwingDataSource dataSource = event.getSource();
|
| 207 | 207 |
dataSources.remove(dataSource);
|
| 208 |
+ if (Objects.equals(dataSource, getMainDataSource())) {
|
|
| 209 |
+ log.info(String.format("Remove main data source: %s", dataSource));
|
|
| 210 |
+ setMainDataSource(null);
|
|
| 211 |
+ }
|
|
| 208 | 212 |
log.info(String.format("Data source closed : %s (%d data sources open)", dataSource.getConfiguration(), dataSources.size()));
|
| 209 | 213 |
}
|
| 210 | 214 |
});
|
| ... | ... | @@ -215,10 +219,6 @@ public class ObserveDataSourcesManager implements Closeable { |
| 215 | 219 |
@Override
|
| 216 | 220 |
public void open() throws DatabaseConnexionNotAuthorizedException, DatabaseNotFoundException, BabModelVersionException, DatabaseOpenException {
|
| 217 | 221 |
try {
|
| 218 |
- //FIXME:BodyContent Review progress model, not linked to ui any more...
|
|
| 219 |
- if (getProgressModel() == null) {
|
|
| 220 |
- setProgressModel(new ProgressModel());
|
|
| 221 |
- }
|
|
| 222 | 222 |
create(createDto);
|
| 223 | 223 |
} catch (IncompatibleDataSourceCreateConfigurationException | DataSourceCreateWithNoReferentialImportException e) {
|
| 224 | 224 |
throw new DatabaseOpenException(e, configuration);
|
| ... | ... | @@ -134,6 +134,8 @@ public class ObserveSwingDataSource extends ObserveServicesProviderSupport imple |
| 134 | 134 |
this.servicesProvider = new ObserveDataSourceServicesProvider(this);
|
| 135 | 135 |
this.serviceFactory = serviceFactory;
|
| 136 | 136 |
this.expired = false;
|
| 137 |
+ setProgressModel(new ProgressModel());
|
|
| 138 |
+ |
|
| 137 | 139 |
if (isLocal()) {
|
| 138 | 140 |
icon = SwingUtil.getUIManagerActionIcon("db-local");
|
| 139 | 141 |
} else if (isRemote()) {
|
| ... | ... | @@ -97,7 +97,6 @@ public void destroy() { |
| 97 | 97 |
|
| 98 | 98 |
<JMenu id='menuFile'>
|
| 99 | 99 |
<JMenuItem id='reloadApplication'/>
|
| 100 |
- <JMenuItem id='openLastFeedBack'/>
|
|
| 101 | 100 |
<JMenuItem id='closeApplication'/>
|
| 102 | 101 |
</JMenu>
|
| 103 | 102 |
<JMenu id='menuConfiguration'>
|
| ... | ... | @@ -116,6 +115,7 @@ public void destroy() { |
| 116 | 115 |
<JMenu id='menuHelp'>
|
| 117 | 116 |
<JMenuItem id='gotoSite'/>
|
| 118 | 117 |
<JMenuItem id='showAbout'/>
|
| 118 |
+ <JMenuItem id='openLastFeedBack'/>
|
|
| 119 | 119 |
<JSeparator/>
|
| 120 | 120 |
<JMenuItem id='translate'/>
|
| 121 | 121 |
</JMenu>
|
| ... | ... | @@ -26,6 +26,7 @@ import fr.ird.observe.client.ObserveSwingApplicationContext; |
| 26 | 26 |
import fr.ird.observe.client.datasource.api.ObserveSwingDataSource;
|
| 27 | 27 |
import fr.ird.observe.client.main.body.NoBodyContentComponent;
|
| 28 | 28 |
import fr.ird.observe.client.util.UIHelper;
|
| 29 |
+import fr.ird.observe.services.configuration.ObserveDataSourceConfiguration;
|
|
| 29 | 30 |
import org.apache.logging.log4j.LogManager;
|
| 30 | 31 |
import org.apache.logging.log4j.Logger;
|
| 31 | 32 |
import org.nuiton.jaxx.runtime.swing.application.ApplicationRunner;
|
| ... | ... | @@ -57,15 +58,17 @@ public class ReloadApplicationAction extends CloseApplicationAction { |
| 57 | 58 |
|
| 58 | 59 |
ObserveSwingDataSource mainDataSource = getObserveDataSourcesManager().getMainDataSource();
|
| 59 | 60 |
if (mainDataSource != null) {
|
| 61 |
+ ObserveDataSourceConfiguration mainDataSourceConfiguration = mainDataSource.getConfiguration();
|
|
| 60 | 62 |
if (mainDataSource.isOpen()) {
|
| 61 | 63 |
try {
|
| 62 | 64 |
mainDataSource.close();
|
| 63 | 65 |
} catch (Exception e) {
|
| 64 | 66 |
UIHelper.handlingError("Can't close data source", e);
|
| 65 |
- mainDataSource = null;
|
|
| 67 |
+ // In this case, won't try to reopen it
|
|
| 68 |
+ mainDataSourceConfiguration = null;
|
|
| 66 | 69 |
}
|
| 67 | 70 |
}
|
| 68 |
- ObserveSwingApplicationContext.setDataSourceToReload(mainDataSource);
|
|
| 71 |
+ ObserveSwingApplicationContext.setDataSourceToReload(mainDataSourceConfiguration);
|
|
| 69 | 72 |
}
|
| 70 | 73 |
ApplicationRunner.getRunner().setReload(true);
|
| 71 | 74 |
|
| ... | ... | @@ -160,8 +160,6 @@ public class StorageUIModel extends WizardModel<StorageStep> implements WithClie |
| 160 | 160 |
* doBackup est active.
|
| 161 | 161 |
*/
|
| 162 | 162 |
protected File backupFile = new File("");
|
| 163 |
- /** un drapeau pour savoir s'il faut sauver la configuration à distante */
|
|
| 164 |
- protected boolean storeRemoteConfig;
|
|
| 165 | 163 |
/** le storage precedemment utilise */
|
| 166 | 164 |
protected ObserveDataSourceConfiguration previousDataSourceConfiguration;
|
| 167 | 165 |
protected ConnexionStatus connexionStatus;
|
| ... | ... | @@ -1217,10 +1215,6 @@ public class StorageUIModel extends WizardModel<StorageStep> implements WithClie |
| 1217 | 1215 |
validate();
|
| 1218 | 1216 |
}
|
| 1219 | 1217 |
|
| 1220 |
- public boolean isStoreRemoteConfig() {
|
|
| 1221 |
- return storeRemoteConfig;
|
|
| 1222 |
- }
|
|
| 1223 |
- |
|
| 1224 | 1218 |
public File getBackupFile() {
|
| 1225 | 1219 |
return backupFile;
|
| 1226 | 1220 |
}
|
| ... | ... | @@ -40,9 +40,9 @@ import fr.ird.observe.client.datasource.h2.backup.WithLocalDatabaseBackupTimer; |
| 40 | 40 |
import fr.ird.observe.client.main.ObserveMainUI;
|
| 41 | 41 |
import fr.ird.observe.client.util.FloatConverter;
|
| 42 | 42 |
import fr.ird.observe.client.util.ObserveSwingTechnicalException;
|
| 43 |
-import fr.ird.observe.client.util.ProgressModel;
|
|
| 44 | 43 |
import fr.ird.observe.client.util.UIHelper;
|
| 45 | 44 |
import fr.ird.observe.services.configuration.DataSourceCreateConfigurationDto;
|
| 45 |
+import fr.ird.observe.services.configuration.ObserveDataSourceConfiguration;
|
|
| 46 | 46 |
import fr.ird.observe.services.configuration.ObserveDataSourceInformation;
|
| 47 | 47 |
import fr.ird.observe.services.configuration.topia.ObserveDataSourceConfigurationTopiaH2;
|
| 48 | 48 |
import io.ultreia.java4all.application.context.ApplicationContext;
|
| ... | ... | @@ -272,7 +272,7 @@ public class RunObserve extends ApplicationRunner implements WithBackupsManager, |
| 272 | 272 |
//
|
| 273 | 273 |
// return;
|
| 274 | 274 |
// }
|
| 275 |
- Optional<ObserveSwingDataSource> dataSourceToReload = ObserveSwingApplicationContext.getDataSourceToReload();
|
|
| 275 |
+ Optional<ObserveDataSourceConfiguration> dataSourceToReload = ObserveSwingApplicationContext.getDataSourceToReload();
|
|
| 276 | 276 |
ObserveSwingApplicationContext.setDataSourceToReload(null);
|
| 277 | 277 |
if (!config.isLoadLocalStorage() && !dataSourceToReload.isPresent()) {
|
| 278 | 278 |
|
| ... | ... | @@ -368,19 +368,19 @@ public class RunObserve extends ApplicationRunner implements WithBackupsManager, |
| 368 | 368 |
//FIXME Need to have a unified API and only one
|
| 369 | 369 |
//FIXME first try to open specified ds (here local ds)
|
| 370 | 370 |
//FIXME if can not load local ds, then feedback it and propose to load automatic backup, or to create a new local ds
|
| 371 |
- private void initStorage(ClientConfig config, JFrame ui, ObserveSwingDataSource previousDataSource) {
|
|
| 371 |
+ private void initStorage(ClientConfig config, JFrame ui, ObserveDataSourceConfiguration previousDataSourceConfiguration) {
|
|
| 372 | 372 |
|
| 373 | 373 |
ObserveMainUI mainUI = (ObserveMainUI) ui;
|
| 374 | 374 |
ObserveDataSourcesManager dataSourcesManager = getObserveDataSourcesManager();
|
| 375 | 375 |
BackupsManager backupsManager = getBackupsManager();
|
| 376 | 376 |
|
| 377 |
- if (previousDataSource != null) {
|
|
| 377 |
+ if (previousDataSourceConfiguration != null) {
|
|
| 378 | 378 |
|
| 379 | 379 |
// reuse previous data source
|
| 380 |
- previousDataSource.setProgressModel(new ProgressModel());
|
|
| 380 |
+ ObserveSwingDataSource previousDataSource = dataSourcesManager.newDataSource(previousDataSourceConfiguration);
|
|
| 381 | 381 |
mainUI.getMainUIBodyContentManager().getBodyTyped(DataSourceEditor.class, DataSourceEditorBodyContent.class).loadStorage(mainUI, previousDataSource, true);
|
| 382 | 382 |
|
| 383 |
- } else if (config.isLoadLocalStorage()){
|
|
| 383 |
+ } else if (config.isLoadLocalStorage()) {
|
|
| 384 | 384 |
|
| 385 | 385 |
boolean askToCreate = true;
|
| 386 | 386 |
BackupStorage lastAutomaticBackup = backupsManager.getAutomaticBackups().stream().findFirst().orElse(null);
|
| ... | ... | @@ -390,7 +390,6 @@ public class RunObserve extends ApplicationRunner implements WithBackupsManager, |
| 390 | 390 |
// une base locale existe, on l'ouvre
|
| 391 | 391 |
|
| 392 | 392 |
ObserveSwingDataSource dataSource = dataSourcesManager.newLocalDataSource();
|
| 393 |
- dataSource.setProgressModel(new ProgressModel());
|
|
| 394 | 393 |
|
| 395 | 394 |
try {
|
| 396 | 395 |
|