Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
901dabf4
by Tony Chemit at 2023-05-01T15:35:04+02:00
10 changed files:
- client/configuration/src/main/filtered-resources/observe-log4j2.xml
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/rlist/ContentRootListUINavigationCapability.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/referential/actions/SaveContentReferentialUIAdapter.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/NavigationTreeModel.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/tree/root/RootNavigationCapability.java
- toolkit/api-i18n/src/main/i18n/translations/toolkit-api-i18n_en_GB.properties
- toolkit/api-i18n/src/main/i18n/translations/toolkit-api-i18n_es_ES.properties
- toolkit/api-i18n/src/main/i18n/translations/toolkit-api-i18n_fr_FR.properties
- toolkit/api/src/main/i18n/getters/java.getter
- toolkit/api/src/main/java/fr/ird/observe/dto/I18nDecoratorHelper.java
Changes:
| ... | ... | @@ -103,6 +103,10 @@ |
| 103 | 103 | <AppenderRef ref="console"/>
|
| 104 | 104 | <AppenderRef ref="File"/>
|
| 105 | 105 | </Logger>
|
| 106 | + <Logger name="fr.ird.observe.client.datasource.editor.api.navigation.NavigationTreeModel" level="info" additivity="false">
|
|
| 107 | + <AppenderRef ref="console"/>
|
|
| 108 | + <AppenderRef ref="File"/>
|
|
| 109 | + </Logger>
|
|
| 106 | 110 | <Logger name="fr.ird.observe.client.datasource.editor.api.content.actions" level="warn" additivity="false">
|
| 107 | 111 | <AppenderRef ref="console"/>
|
| 108 | 112 | <AppenderRef ref="File"/>
|
| ... | ... | @@ -51,6 +51,7 @@ public abstract class ContentRootListUINavigationCapability<N extends ContentRoo |
| 51 | 51 | |
| 52 | 52 | @Override
|
| 53 | 53 | public void updateReference(DataGroupByDto<?> reference) {
|
| 54 | + getNode().getInitializer().setParentReference(reference);
|
|
| 54 | 55 | Enumeration<?> children = getNode().children();
|
| 55 | 56 | while (children.hasMoreElements()) {
|
| 56 | 57 | ContentRootOpenableUINavigationNode childrenNode = (ContentRootOpenableUINavigationNode) children.nextElement();
|
| ... | ... | @@ -64,24 +64,28 @@ public class SaveContentReferentialUIAdapter<D extends ReferentialDto, R extends |
| 64 | 64 | RootNavigationInitializer initializer = rootNode.getInitializer();
|
| 65 | 65 | ToolkitTreeFlatModelRootRequest request = initializer.getRequest();
|
| 66 | 66 | if (!request.isLoadData()) {
|
| 67 | - return;
|
|
| 68 | - }
|
|
| 69 | - if (!bean.isEnabled() && !request.isLoadDisabledGroupBy()) {
|
|
| 70 | - return;
|
|
| 71 | - }
|
|
| 72 | - if (notPersisted && !request.isLoadEmptyGroupBy()) {
|
|
| 67 | + // no data loading, no update to perform
|
|
| 73 | 68 | return;
|
| 74 | 69 | }
|
| 75 | 70 | Class<?> groupByType = initializer.getGroupBy().getPropertyType();
|
| 76 | 71 | if (!groupByType.equals(states.mainReferenceType())) {
|
| 72 | + // the groupBy type is not the navigation configuration one (no update to perform)
|
|
| 77 | 73 | return;
|
| 78 | 74 | }
|
| 79 | 75 | String groupById = bean.getId();
|
| 80 | 76 | if (notPersisted) {
|
| 81 | - // add the new empty node
|
|
| 77 | + if (!request.isLoadEmptyGroupBy()) {
|
|
| 78 | + // navigation configuration won't add this node
|
|
| 79 | + return;
|
|
| 80 | + }
|
|
| 81 | + if (!bean.isEnabled() && !request.isLoadDisabledGroupBy()) {
|
|
| 82 | + // navigation configuration won't add this node
|
|
| 83 | + return;
|
|
| 84 | + }
|
|
| 85 | + // add the new groupBy node
|
|
| 82 | 86 | rootNode.getCapability().createMissingNode(groupById);
|
| 83 | 87 | } else {
|
| 84 | - // get existing node
|
|
| 88 | + // update the (optional) groupBy node
|
|
| 85 | 89 | rootNode.getCapability().updateChildNode(groupById);
|
| 86 | 90 | }
|
| 87 | 91 | }
|
| ... | ... | @@ -27,11 +27,8 @@ import fr.ird.observe.client.datasource.api.ObserveSwingDataSource; |
| 27 | 27 | import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
| 28 | 28 | import fr.ird.observe.client.datasource.editor.api.navigation.tree.root.RootNavigationInitializer;
|
| 29 | 29 | import fr.ird.observe.client.datasource.editor.api.navigation.tree.root.RootNavigationNode;
|
| 30 | -import fr.ird.observe.client.datasource.editor.api.navigation.tree.select.SelectNodeStrategy;
|
|
| 31 | -import fr.ird.observe.client.datasource.editor.api.navigation.tree.select.SelectNodesByModel;
|
|
| 32 | -import fr.ird.observe.client.datasource.editor.api.navigation.tree.select.SelectNodesByModelNode;
|
|
| 33 | -import fr.ird.observe.client.datasource.editor.api.navigation.tree.select.SelectNodesByPath;
|
|
| 34 | -import fr.ird.observe.client.datasource.editor.api.navigation.tree.select.SelectNodesDefault;
|
|
| 30 | +import fr.ird.observe.client.datasource.editor.api.navigation.tree.select.*;
|
|
| 31 | +import fr.ird.observe.dto.I18nDecoratorHelper;
|
|
| 35 | 32 | import fr.ird.observe.navigation.id.IdNode;
|
| 36 | 33 | import fr.ird.observe.navigation.id.Project;
|
| 37 | 34 | import fr.ird.observe.navigation.tree.GroupByHelper;
|
| ... | ... | @@ -49,10 +46,7 @@ import javax.swing.tree.DefaultTreeModel; |
| 49 | 46 | import javax.swing.tree.TreeNode;
|
| 50 | 47 | import java.beans.PropertyChangeListener;
|
| 51 | 48 | import java.beans.PropertyChangeSupport;
|
| 52 | -import java.util.LinkedList;
|
|
| 53 | -import java.util.List;
|
|
| 54 | -import java.util.Objects;
|
|
| 55 | -import java.util.Optional;
|
|
| 49 | +import java.util.*;
|
|
| 56 | 50 | |
| 57 | 51 | /**
|
| 58 | 52 | * Created on 14/11/16.
|
| ... | ... | @@ -220,23 +214,23 @@ public class NavigationTreeModel extends DefaultTreeModel implements WithClientU |
| 220 | 214 | |
| 221 | 215 | protected NavigationResult createOrUpdateNavigationResult(NavigationResult navigationResult) {
|
| 222 | 216 | NavigationService navigationService = getDataSourcesManager().getMainDataSource().getNavigationService();
|
| 217 | + Locale locale = getDecoratorService().getReferentialLocale().getLocale();
|
|
| 218 | + ToolkitTreeFlatModelRootRequest request;
|
|
| 219 | + Date timestamp;
|
|
| 223 | 220 | NavigationResult newNavigationResult;
|
| 224 | 221 | if (navigationResult == null) {
|
| 225 | 222 | log.info("Ask for new navigation result (no previous result)");
|
| 226 | - ToolkitTreeFlatModelRootRequest request = getConfig().toRootRequest(groupByHelper);
|
|
| 227 | - newNavigationResult = navigationService.getNavigation(request, null);
|
|
| 228 | - log.info("Generated new navigation result at: " + newNavigationResult.getTimestamp());
|
|
| 223 | + timestamp = null;
|
|
| 224 | + request = getConfig().toRootRequest(groupByHelper);
|
|
| 229 | 225 | } else {
|
| 230 | - log.info("Ask for new navigation result from: " + navigationResult.getTimestamp());
|
|
| 231 | - newNavigationResult = navigationService.getNavigation(navigationResult.getRequest(), navigationResult.getTimestamp());
|
|
| 232 | - if (newNavigationResult == null) {
|
|
| 233 | - // reuse previous result
|
|
| 234 | - log.info("Reuse previous navigation result from: " + navigationResult.getTimestamp());
|
|
| 235 | - newNavigationResult = navigationResult;
|
|
| 236 | - } else {
|
|
| 237 | - log.info("Generated new navigation result at: " + newNavigationResult.getTimestamp());
|
|
| 238 | - }
|
|
| 226 | + log.info("Ask for new navigation result from: " + I18nDecoratorHelper.getTimestampWithSecondsLabel(locale, navigationResult.getTimestamp()));
|
|
| 227 | + // Only on local mode, can always trust the service timestamp
|
|
| 228 | + // otherwise always use a null time stamp to skip null result by service
|
|
| 229 | + timestamp = getDataSourcesManager().getMainDataSource().isLocal() ? navigationResult.getTimestamp() : null;
|
|
| 230 | + request = navigationResult.getRequest();
|
|
| 239 | 231 | }
|
| 232 | + newNavigationResult = navigationService.getNavigation(request, timestamp);
|
|
| 233 | + log.info("Generated new navigation result at: {}", I18nDecoratorHelper.getTimestampWithSecondsLabel(locale, newNavigationResult.getTimestamp()));
|
|
| 240 | 234 | return newNavigationResult;
|
| 241 | 235 | }
|
| 242 | 236 |
| ... | ... | @@ -44,7 +44,6 @@ import java.util.stream.Collectors; |
| 44 | 44 | * @since 8.0.1
|
| 45 | 45 | */
|
| 46 | 46 | public class RootNavigationCapability implements GroupByContainerCapability<RootNavigationNode> {
|
| 47 | - |
|
| 48 | 47 | private final RootNavigationNode node;
|
| 49 | 48 | |
| 50 | 49 | private final SingletonSupplier<List<Class<? extends NavigationNode>>> acceptedNodeTypes;
|
| ... | ... | @@ -90,20 +89,33 @@ public class RootNavigationCapability implements GroupByContainerCapability<Root |
| 90 | 89 | public void updateChildNode(String id) {
|
| 91 | 90 | // Update also navigation result, this method is asking it
|
| 92 | 91 | NavigationResult navigationResult = getNode().getInitializer().getTreeModel().updateNavigationResult();
|
| 92 | + |
|
| 93 | + ContentRootListUINavigationNode groupByNode = (ContentRootListUINavigationNode) getNode().findChildById(id);
|
|
| 94 | + |
|
| 93 | 95 | DataGroupByDto<?> reference = navigationResult.getGroupBy(id);
|
| 94 | - if (reference.decorator().isEmpty()) {
|
|
| 95 | - getNode().getContext().getDecoratorService().installDecorator(reference);
|
|
| 96 | + if (reference == null) {
|
|
| 97 | + // this case can happen if groupBy is not compliant with the navigation configuration
|
|
| 98 | + if (groupByNode != null) {
|
|
| 99 | + // this case can happen if groupBy was compliant with the navigation configuration, but not any longer
|
|
| 100 | + // just remove the obsolete groupBy node
|
|
| 101 | + groupByNode.removeFromParent();
|
|
| 102 | + }
|
|
| 103 | + return;
|
|
| 104 | + }
|
|
| 105 | + if (groupByNode == null) {
|
|
| 106 | + // this case can happen if group by was disabled, then enabled and navigation configuration does not accept disabled groupBy
|
|
| 107 | + // we need just then to insert the new groupBy node
|
|
| 108 | + insertChildNode(reference);
|
|
| 109 | + return;
|
|
| 96 | 110 | }
|
| 97 | - ContentRootListUINavigationNode groupByNode = (ContentRootListUINavigationNode) getNode().findChildById(id);
|
|
| 98 | - // Maybe position has changed ?
|
|
| 99 | 111 | int oldNodePosition = getNode().getIndex(groupByNode);
|
| 100 | 112 | int newNodePosition = getNodePosition(reference);
|
| 101 | - groupByNode.getInitializer().setParentReference(reference);
|
|
| 113 | + // Propagate reference as parentReference to in children and as reference to this node
|
|
| 114 | + groupByNode.getCapability().updateReference(reference);
|
|
| 102 | 115 | // need to update groupByNode
|
| 103 | 116 | groupByNode.nodeChanged();
|
| 104 | - // Propagate reference as parentReference to in children
|
|
| 105 | - groupByNode.getCapability().updateReference(reference);
|
|
| 106 | 117 | if (oldNodePosition != newNodePosition) {
|
| 118 | + // position has changed
|
|
| 107 | 119 | getNode().moveNode(groupByNode, newNodePosition);
|
| 108 | 120 | }
|
| 109 | 121 | }
|
| ... | ... | @@ -114,6 +126,7 @@ public class RootNavigationCapability implements GroupByContainerCapability<Root |
| 114 | 126 | NavigationResult navigationResult = getNode().getInitializer().getTreeModel().updateNavigationResult();
|
| 115 | 127 | DataGroupByDto<?> reference = navigationResult.getGroupBy(id);
|
| 116 | 128 | if (reference == null) {
|
| 129 | + //FIXME How the reference could not be found in navigation result?
|
|
| 117 | 130 | reference = getNode().getContext().computeGroupByDto(id);
|
| 118 | 131 | }
|
| 119 | 132 | return insertChildNode(reference);
|
| ... | ... | @@ -49,6 +49,7 @@ observe.Common.none=None |
| 49 | 49 | observe.Common.size=%d element(s)
|
| 50 | 50 | observe.Common.time.format=%1$tH\:%1$tM
|
| 51 | 51 | observe.Common.timestamp.format=%1$tY-%1$tm-%1$td %1$tH\:%1$tM
|
| 52 | +observe.Common.timestamp.seconds.format=%1$tY-%1$tm-%1$td %1$tH\:%1$tM\:%1$tS
|
|
| 52 | 53 | observe.Common.type.data=Data
|
| 53 | 54 | observe.Common.type.referential=Referential
|
| 54 | 55 | observe.Common.undefined=Undefined
|
| ... | ... | @@ -49,6 +49,7 @@ observe.Common.none=Ninguno |
| 49 | 49 | observe.Common.size=%d element(s) \#TODO
|
| 50 | 50 | observe.Common.time.format=%1$tH\:%1$tM
|
| 51 | 51 | observe.Common.timestamp.format=%1$tY-%1$tm-%1$td %1$tH\:%1$tM
|
| 52 | +observe.Common.timestamp.seconds.format=%1$tY-%1$tm-%1$td %1$tH\:%1$tM\:%1$tS
|
|
| 52 | 53 | observe.Common.type.data=Datos
|
| 53 | 54 | observe.Common.type.referential=Referential
|
| 54 | 55 | observe.Common.undefined=indeterminado
|
| ... | ... | @@ -49,6 +49,7 @@ observe.Common.none=Aucun |
| 49 | 49 | observe.Common.size=%d élément(s)
|
| 50 | 50 | observe.Common.time.format=%1$tH\:%1$tM
|
| 51 | 51 | observe.Common.timestamp.format=%1$td/%1$tm/%1$tY %1$tH\:%1$tM
|
| 52 | +observe.Common.timestamp.seconds.format=%1$td/%1$tm/%1$tY %1$tH\:%1$tM\:%1$tS
|
|
| 52 | 53 | observe.Common.type.data=Donnée
|
| 53 | 54 | observe.Common.type.referential=Référentiel
|
| 54 | 55 | observe.Common.undefined=Non défini
|
| ... | ... | @@ -25,6 +25,7 @@ observe.Common.no.coordinate |
| 25 | 25 | observe.Common.no.value
|
| 26 | 26 | observe.Common.time.format
|
| 27 | 27 | observe.Common.timestamp.format
|
| 28 | +observe.Common.timestamp.seconds.format
|
|
| 28 | 29 | observe.Common.type.data
|
| 29 | 30 | observe.Common.type.referential
|
| 30 | 31 | observe.Common.undefined
|
| ... | ... | @@ -156,23 +156,26 @@ public abstract class I18nDecoratorHelper extends BeanPropertyI18nKeyProducerPro |
| 156 | 156 | }
|
| 157 | 157 | |
| 158 | 158 | public static String getTimestampLabel(Locale locale, Date date) {
|
| 159 | - |
|
| 160 | 159 | return I18n.l(locale, "observe.Common.timestamp.format", date);
|
| 161 | 160 | }
|
| 162 | 161 | |
| 162 | + public static String getTimestampWithSecondsLabel(Locale locale, Date date) {
|
|
| 163 | + return I18n.l(locale, "observe.Common.timestamp.seconds.format", date);
|
|
| 164 | + }
|
|
| 165 | + |
|
| 163 | 166 | public static String getTimeLabel(Locale locale, Date date) {
|
| 164 | 167 | return I18n.l(locale, "observe.Common.time.format", date);
|
| 165 | 168 | }
|
| 166 | 169 | |
| 167 | 170 | public static String getSpeedRange(Locale locale, Integer minValue, Integer maxValue) {
|
| 168 | - String min = minValue == null ? "" : minValue + "";
|
|
| 169 | - String max = maxValue == null ? "" : maxValue + "";
|
|
| 171 | + String min = minValue == null ? "" : String.valueOf(minValue);
|
|
| 172 | + String max = maxValue == null ? "" : String.valueOf(maxValue);
|
|
| 170 | 173 | return I18n.l(locale, "observe.referential.common.Wind.speedRange") + String.format("[%-4s < %-4s]", min, max);
|
| 171 | 174 | }
|
| 172 | 175 | |
| 173 | 176 | public static String getSwellHeight(Locale locale, Float minValue, Float maxValue) {
|
| 174 | - String min = minValue == null ? "" : minValue + "";
|
|
| 175 | - String max = maxValue == null ? "" : maxValue + "";
|
|
| 177 | + String min = minValue == null ? "" : String.valueOf(minValue);
|
|
| 178 | + String max = maxValue == null ? "" : String.valueOf(maxValue);
|
|
| 176 | 179 | return I18n.l(locale, "observe.referential.common.Wind.swellHeight") + String.format("[%-4s < %-4s]", min, max);
|
| 177 | 180 | }
|
| 178 | 181 |