Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
4e4b90da
by Tony Chemit at 2022-02-09T10:37:51+01:00
-
11b1732c
by Tony Chemit at 2022-02-09T10:58:24+01:00
-
0ac6cf2b
by Tony Chemit at 2022-02-09T10:58:54+01:00
4 changed files:
- client/core/src/main/java/fr/ird/observe/client/datasource/api/ObserveSwingDataSource.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/avdth/ImportDialogModel.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/NavigationUIInitializer.java
Changes:
| ... | ... | @@ -90,7 +90,6 @@ import java.nio.file.Files; |
| 90 | 90 | import java.nio.file.Path;
|
| 91 | 91 | import java.util.Collections;
|
| 92 | 92 | import java.util.Date;
|
| 93 | -import java.util.HashMap;
|
|
| 94 | 93 | import java.util.Iterator;
|
| 95 | 94 | import java.util.Map;
|
| 96 | 95 | import java.util.Objects;
|
| ... | ... | @@ -106,7 +105,7 @@ import static io.ultreia.java4all.i18n.I18n.t; |
| 106 | 105 | */
|
| 107 | 106 | @GenerateJavaBeanDefinition
|
| 108 | 107 | @GenerateTemplate(template = "ObserveSwingDataSource.ftl")
|
| 109 | -public class ObserveSwingDataSource extends AbstractJavaBean implements ObserveServicesProvider ,ObserveDataSourceConfigurationAndConnection, WithClientUIContextApi, WithPermission {
|
|
| 108 | +public class ObserveSwingDataSource extends AbstractJavaBean implements ObserveServicesProvider, ObserveDataSourceConfigurationAndConnection, WithClientUIContextApi, WithPermission {
|
|
| 110 | 109 | |
| 111 | 110 | private static final Logger log = LogManager.getLogger(ObserveSwingDataSource.class);
|
| 112 | 111 | |
| ... | ... | @@ -117,9 +116,9 @@ public class ObserveSwingDataSource extends AbstractJavaBean implements ObserveS |
| 117 | 116 | private final DataSourceReferenceProvider referenceProvider;
|
| 118 | 117 | private final DecoratorService decoratorService;
|
| 119 | 118 | private final Icon icon;
|
| 120 | - private final Map<Class<?>, ObserveService> cache;
|
|
| 119 | + private final ObserveServicesProviderImpl servicesProvider;
|
|
| 120 | + // private final Map<Class<?>, ObserveService> cache;
|
|
| 121 | 121 | private ProgressionModel progressModel;
|
| 122 | -private final ObserveServicesProviderImpl servicesProvider;
|
|
| 123 | 122 | // connexion expired, but data source not closed
|
| 124 | 123 | private boolean expired;
|
| 125 | 124 | // at least one commit was performed on this data source
|
| ... | ... | @@ -157,7 +156,7 @@ private final ObserveServicesProviderImpl servicesProvider; |
| 157 | 156 | this.expired = false;
|
| 158 | 157 | this.icon = configuration.getConnectMode().getIcon();
|
| 159 | 158 | //FIXME Not sure a cache here is good, any leak inside a service will stay here...
|
| 160 | - this.cache = new HashMap<>();
|
|
| 159 | +// this.cache = new HashMap<>();
|
|
| 161 | 160 | setProgressModel(new ProgressionModel());
|
| 162 | 161 | this.servicesProvider = new ObserveServicesProviderImpl(serviceFactory, this::createServiceInitializer);
|
| 163 | 162 | }
|
| ... | ... | @@ -184,12 +183,13 @@ private final ObserveServicesProviderImpl servicesProvider; |
| 184 | 183 | |
| 185 | 184 | @Override
|
| 186 | 185 | public <S extends ObserveService> S getService(Class<S> serviceType) {
|
| 187 | - @SuppressWarnings("unchecked") S result = (S) cache.get(serviceType);
|
|
| 188 | - if (result == null) {
|
|
| 189 | - result = servicesProvider.getService(serviceType);
|
|
| 190 | - cache.put(serviceType, result);
|
|
| 191 | - }
|
|
| 192 | - return result;
|
|
| 186 | +// @SuppressWarnings("unchecked") S result = (S) cache.get(serviceType);
|
|
| 187 | +// if (result == null) {
|
|
| 188 | +// result = servicesProvider.getService(serviceType);
|
|
| 189 | +// cache.put(serviceType, result);
|
|
| 190 | +// }
|
|
| 191 | +// return result;
|
|
| 192 | + return servicesProvider.getService(serviceType);
|
|
| 193 | 193 | }
|
| 194 | 194 | |
| 195 | 195 | protected ObserveServiceInitializer createServiceInitializer() {
|
| ... | ... | @@ -277,7 +277,7 @@ private final ObserveServicesProviderImpl servicesProvider; |
| 277 | 277 | dataSourceService.close();
|
| 278 | 278 | }
|
| 279 | 279 | } finally {
|
| 280 | - cache.clear();
|
|
| 280 | +// cache.clear();
|
|
| 281 | 281 | ObserveUtil.cleanMemory();
|
| 282 | 282 | setConnection(null);
|
| 283 | 283 | expired = false;
|
| ... | ... | @@ -216,7 +216,6 @@ public class DataSourceEditorBodyContent extends MainUIBodyContent<DataSourceEdi |
| 216 | 216 | } catch (Exception e) {
|
| 217 | 217 | mainUI.removeBodyContent();
|
| 218 | 218 | throw e;
|
| 219 | -// UIHelper.handlingError(e);
|
|
| 220 | 219 | }
|
| 221 | 220 | }
|
| 222 | 221 | |
| ... | ... | @@ -235,7 +234,6 @@ public class DataSourceEditorBodyContent extends MainUIBodyContent<DataSourceEdi |
| 235 | 234 | public void doImportAvdth() {
|
| 236 | 235 | if (isAlive()) {
|
| 237 | 236 | ImportAvdthFile action = (ImportAvdthFile) get().getNavigationUI().getImportAvdthFile().getAction();
|
| 238 | -// ImportAvdthFileAction action = (ImportAvdthFileAction) editorMenu.getImportAvdthFile().getAction();
|
|
| 239 | 237 | action.run();
|
| 240 | 238 | }
|
| 241 | 239 | }
|
| ... | ... | @@ -243,15 +241,13 @@ public class DataSourceEditorBodyContent extends MainUIBodyContent<DataSourceEdi |
| 243 | 241 | public void doCloseStorage() {
|
| 244 | 242 | if (isAlive()) {
|
| 245 | 243 | CloseStorage action = (CloseStorage) get().getNavigationUI().getCloseStorage().getAction();
|
| 246 | -// CloseStorageAction action = (CloseStorageAction) editorMenu.getCloseStorage().getAction();
|
|
| 247 | 244 | action.run();
|
| 248 | 245 | }
|
| 249 | 246 | }
|
| 250 | 247 | |
| 251 | 248 | public void doReloadStorage() {
|
| 252 | 249 | if (isAlive()) {
|
| 253 | - ReloadStorage action = (ReloadStorage) get().getNavigationUI().getCloseStorage().getAction();
|
|
| 254 | -// ReloadStorageAction action = (ReloadStorageAction) editorMenu.getReloadStorage().getAction();
|
|
| 250 | + ReloadStorage action = (ReloadStorage) get().getNavigationUI().getReloadStorage().getAction();
|
|
| 255 | 251 | action.run();
|
| 256 | 252 | }
|
| 257 | 253 | }
|
| ... | ... | @@ -45,6 +45,7 @@ import java.nio.file.Path; |
| 45 | 45 | import java.util.Date;
|
| 46 | 46 | import java.util.List;
|
| 47 | 47 | import java.util.Objects;
|
| 48 | +import java.util.stream.Collectors;
|
|
| 48 | 49 | |
| 49 | 50 | /**
|
| 50 | 51 | * Created on 12/06/2021.
|
| ... | ... | @@ -126,7 +127,8 @@ public class ImportDialogModel extends AbstractJavaBean { |
| 126 | 127 | |
| 127 | 128 | public static ImportDialogModel create(WithClientUIContextApi clientUIContext) {
|
| 128 | 129 | ObserveSwingDataSource dataSource = clientUIContext.getDataSourcesManager().getMainDataSource();
|
| 129 | - List<ProgramReference> programs = dataSource.getReferenceProvider().getReferentialReferences(ProgramReference.class).toList();
|
|
| 130 | + // get only program for logbook
|
|
| 131 | + List<ProgramReference> programs = dataSource.getReferenceProvider().getReferentialReferences(ProgramReference.class).stream().filter(ProgramReference::isLogbook).collect(Collectors.toList());
|
|
| 130 | 132 | List<OceanReference> oceans = dataSource.getReferenceProvider().getReferentialReferences(OceanReference.class).toArrayList();
|
| 131 | 133 | ClientConfig clientConfig = clientUIContext.getClientConfig();
|
| 132 | 134 | Path temporaryDirectory = clientConfig.getTemporaryDirectory().toPath();
|
| ... | ... | @@ -88,7 +88,6 @@ class NavigationUIInitializer extends UIInitializerSupport<NavigationUI, UIIniti |
| 88 | 88 | |
| 89 | 89 | protected void init(NavigationTree editor) {
|
| 90 | 90 | initializerContext.checkFirstPass();
|
| 91 | - UIInitHelper.init(editor);
|
|
| 92 | 91 | editor.setFont(editor.getFont().deriveFont(11f));
|
| 93 | 92 | editor.setCellRenderer(new NavigationTreeCellRenderer());
|
| 94 | 93 | NavigationUI ui = initializerContext.getUi();
|