Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
cef03dd1
by Tony Chemit at 2021-10-25T21:30:21+02:00
4 changed files:
- 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/DataSourceEditorHandler.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/menu/actions/ReloadStorageAction.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/tree/root/RootNavigationNode.java
Changes:
| ... | ... | @@ -40,6 +40,7 @@ import fr.ird.observe.client.datasource.editor.api.menu.actions.CloseStorageActi |
| 40 | 40 |
import fr.ird.observe.client.datasource.editor.api.menu.actions.ImportAvdthFileAction;
|
| 41 | 41 |
import fr.ird.observe.client.datasource.editor.api.menu.actions.ReloadStorageAction;
|
| 42 | 42 |
import fr.ird.observe.client.datasource.editor.api.menu.actions.ShowDataSourcePresetsAction;
|
| 43 |
+import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
|
| 43 | 44 |
import fr.ird.observe.client.main.ObserveMainUI;
|
| 44 | 45 |
import fr.ird.observe.client.main.body.HideBodyContentNotAcceptedException;
|
| 45 | 46 |
import fr.ird.observe.client.main.body.MainUIBodyContent;
|
| ... | ... | @@ -79,6 +80,7 @@ public class DataSourceEditorBodyContent extends MainUIBodyContent<DataSourceEdi |
| 79 | 80 |
private DataSourceEditorMenu editorMenu;
|
| 80 | 81 |
private DataSourceEditorNavigationMenu navigationMenu;
|
| 81 | 82 |
private ObserveSwingDataSource dataSource;
|
| 83 |
+ private NavigationNode previousNode;
|
|
| 82 | 84 |
|
| 83 | 85 |
public DataSourceEditorBodyContent() {
|
| 84 | 86 |
super(1, DataSourceEditor.class);
|
| ... | ... | @@ -86,6 +88,10 @@ public class DataSourceEditorBodyContent extends MainUIBodyContent<DataSourceEdi |
| 86 | 88 |
this.reload = e -> reload();
|
| 87 | 89 |
}
|
| 88 | 90 |
|
| 91 |
+ public void setPreviousNode(NavigationNode previousNode) {
|
|
| 92 |
+ this.previousNode = previousNode;
|
|
| 93 |
+ }
|
|
| 94 |
+ |
|
| 89 | 95 |
private Supplier<DataSourceEditor> createSupplier() {
|
| 90 | 96 |
return () -> {
|
| 91 | 97 |
ObserveMainUI mainUI = getClientUIContext().getMainUI();
|
| ... | ... | @@ -193,7 +199,10 @@ public class DataSourceEditorBodyContent extends MainUIBodyContent<DataSourceEdi |
| 193 | 199 |
focusModel.addZone(new ContentZone(focusModel, dataSourceEditor));
|
| 194 | 200 |
|
| 195 | 201 |
navigationMenu.getUiModel().setConfig(dataSourceEditor.getNavigationUI().getTree().getModel().getConfig());
|
| 196 |
- dataSourceEditor.getHandler().loadNavigationUI(progressModel);
|
|
| 202 |
+ NavigationNode previousNode = this.previousNode;
|
|
| 203 |
+ // remove it right now
|
|
| 204 |
+ setPreviousNode(null);
|
|
| 205 |
+ dataSourceEditor.getHandler().loadNavigationUI(progressModel, previousNode);
|
|
| 197 | 206 |
progressModel.increments();
|
| 198 | 207 |
}
|
| 199 | 208 |
|
| ... | ... | @@ -30,6 +30,7 @@ import fr.ird.observe.client.datasource.editor.api.content.ContentUIManager; |
| 30 | 30 |
import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
| 31 | 31 |
import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTreeModel;
|
| 32 | 32 |
import fr.ird.observe.client.datasource.editor.api.navigation.NavigationUI;
|
| 33 |
+import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
|
| 33 | 34 |
import fr.ird.observe.client.util.ProgressModel;
|
| 34 | 35 |
import fr.ird.observe.client.util.init.UIInitHelper;
|
| 35 | 36 |
import fr.ird.observe.client.util.session.ObserveSwingSessionHelper;
|
| ... | ... | @@ -153,8 +154,9 @@ public class DataSourceEditorHandler implements UIHandler<DataSourceEditor>, Wit |
| 153 | 154 |
* <b>Note:</b> cette méthode doit être appelée après tout rechargement de modèle de navigation.
|
| 154 | 155 |
*
|
| 155 | 156 |
* @param progressModel the progress model to interact with ui
|
| 157 |
+ * @param previousNode
|
|
| 156 | 158 |
*/
|
| 157 |
- public void loadNavigationUI(ProgressModel progressModel) {
|
|
| 159 |
+ public void loadNavigationUI(ProgressModel progressModel, NavigationNode previousNode) {
|
|
| 158 | 160 |
boolean canReadData = getClientUIContext().getDataSourcesManager().getMainDataSource().canReadData();
|
| 159 | 161 |
NavigationUI navigationUI = ui.getNavigationUI();
|
| 160 | 162 |
NavigationTree tree = navigationUI.getTree();
|
| ... | ... | @@ -163,10 +165,20 @@ public class DataSourceEditorHandler implements UIHandler<DataSourceEditor>, Wit |
| 163 | 165 |
treeModel.populate(null);
|
| 164 | 166 |
progressModel.increments();
|
| 165 | 167 |
// select initial node
|
| 166 |
- try {
|
|
| 167 |
- tree.selectInitialNode();
|
|
| 168 |
- } catch (Exception e) {
|
|
| 169 |
- log.error("Could not load initial node", e);
|
|
| 168 |
+ if (previousNode != null) {
|
|
| 169 |
+ try {
|
|
| 170 |
+ tree.reselectInitialNode(previousNode);
|
|
| 171 |
+ } catch (Exception e) {
|
|
| 172 |
+ log.error("Could not load previous node", e);
|
|
| 173 |
+ previousNode = null;
|
|
| 174 |
+ }
|
|
| 175 |
+ }
|
|
| 176 |
+ if (previousNode == null) {
|
|
| 177 |
+ try {
|
|
| 178 |
+ tree.selectInitialNode();
|
|
| 179 |
+ } catch (Exception e) {
|
|
| 180 |
+ log.error("Could not load initial node", e);
|
|
| 181 |
+ }
|
|
| 170 | 182 |
}
|
| 171 | 183 |
progressModel.increments();
|
| 172 | 184 |
tree.setVisible(true);
|
| ... | ... | @@ -23,8 +23,9 @@ package fr.ird.observe.client.datasource.editor.api.menu.actions; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.datasource.api.ObserveSwingDataSource;
|
| 26 |
+import fr.ird.observe.client.datasource.editor.api.DataSourceEditorBodyContent;
|
|
| 26 | 27 |
import fr.ird.observe.client.datasource.editor.api.menu.DataSourceEditorMenu;
|
| 27 |
-import fr.ird.observe.client.main.ObserveMainUI;
|
|
| 28 |
+import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
|
| 28 | 29 |
import fr.ird.observe.client.util.ObserveSwingTechnicalException;
|
| 29 | 30 |
import org.apache.logging.log4j.LogManager;
|
| 30 | 31 |
import org.apache.logging.log4j.Logger;
|
| ... | ... | @@ -60,28 +61,24 @@ public class ReloadStorageAction extends DataSourceEditorMenuActionSupport imple |
| 60 | 61 |
|
| 61 | 62 |
log.info(String.format("Will close main data source: %s", dataSource));
|
| 62 | 63 |
|
| 63 |
- // Close
|
|
| 64 |
- getDataSourceEditorBodyContent().doCloseStorage();
|
|
| 64 |
+ DataSourceEditorBodyContent bodyContent = getDataSourceEditorBodyContent();
|
|
| 65 | 65 |
|
| 66 |
- ObserveMainUI mainUI = getClientUIContext().getMainUI();
|
|
| 66 |
+ // keep selected node to select it on new navigation tree
|
|
| 67 |
+ NavigationNode selectedNode = bodyContent.get().getNavigationUI().getTree().getSelectedNode();
|
|
| 68 |
+ bodyContent.setPreviousNode(selectedNode);
|
|
| 67 | 69 |
|
| 68 |
- //FIXME:BodyContent reload previous selected node
|
|
| 69 |
- getClientUIContext().getBusyModel().addTask("Reload storage");
|
|
| 70 |
- try {
|
|
| 71 |
- |
|
| 72 |
- //FIXME:Datasource See why we do this?
|
|
| 73 |
- dataSource.setCanMigrate(getClientConfig());
|
|
| 70 |
+ // Close storage
|
|
| 71 |
+ bodyContent.doCloseStorage();
|
|
| 74 | 72 |
|
| 75 |
- log.info(String.format("Will load main data source: %s", dataSource));
|
|
| 73 |
+ //FIXME:Datasource See why we do this?
|
|
| 74 |
+ dataSource.setCanMigrate(getClientConfig());
|
|
| 76 | 75 |
|
| 77 |
- try {
|
|
| 78 |
- getDataSourceEditorBodyContent().loadStorage(mainUI, dataSource);
|
|
| 79 |
- } catch (Exception e) {
|
|
| 80 |
- throw new ObserveSwingTechnicalException(e);
|
|
| 81 |
- }
|
|
| 76 |
+ log.info(String.format("Will load main data source: %s", dataSource));
|
|
| 82 | 77 |
|
| 83 |
- } finally {
|
|
| 84 |
- getClientUIContext().getBusyModel().popTask();
|
|
| 78 |
+ try {
|
|
| 79 |
+ bodyContent.loadStorage(getClientUIContext().getMainUI(), dataSource);
|
|
| 80 |
+ } catch (Exception e) {
|
|
| 81 |
+ throw new ObserveSwingTechnicalException(e);
|
|
| 85 | 82 |
}
|
| 86 | 83 |
|
| 87 | 84 |
}
|
| ... | ... | @@ -141,7 +141,7 @@ public class RootNavigationNode extends NavigationNode { |
| 141 | 141 |
return result;
|
| 142 | 142 |
}
|
| 143 | 143 |
|
| 144 |
- public <N extends NavigationNode> N findChildByType0(Class<N> childType, String id) {
|
|
| 144 |
+ public <N extends NavigationNode> N findChildByTypeWithNoCreate(Class<N> childType, String id) {
|
|
| 145 | 145 |
return super.findChildByType(childType, id);
|
| 146 | 146 |
}
|
| 147 | 147 |
|
| ... | ... | @@ -173,7 +173,10 @@ public class RootNavigationNode extends NavigationNode { |
| 173 | 173 |
NavigationNode next;
|
| 174 | 174 |
NavigationNode oldNode = (NavigationNode) treeNode;
|
| 175 | 175 |
if (oldNode.getLevel() == 0) {
|
| 176 |
- next = ((RootNavigationNode) result).findChildByType0(oldNode.getClass(), oldNode.getInitializer().getSelectNodeId());
|
|
| 176 |
+ next = result;
|
|
| 177 |
+ } else if (oldNode.getLevel() == 1) {
|
|
| 178 |
+ // use the method which will not create node
|
|
| 179 |
+ next = ((RootNavigationNode) result).findChildByTypeWithNoCreate(oldNode.getClass(), oldNode.getInitializer().getSelectNodeId());
|
|
| 177 | 180 |
} else if (oldNode.getScope().isSelectNode()) {
|
| 178 | 181 |
next = result.findChildByType(oldNode.getClass(), oldNode.getInitializer().getSelectNodeId());
|
| 179 | 182 |
} else {
|