Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 51347b1d by Tony Chemit at 2021-01-23T15:34:32+01:00 Fix SampleDataServiceLocalSupport (call twice binder to entity) - - - - - 4067895f by Tony Chemit at 2021-01-23T15:34:47+01:00 Put config color in UIManager - - - - - 479c83f0 by Tony Chemit at 2021-01-23T15:34:59+01:00 Use now config color in bavigation tree - - - - - 0236db7e by Tony Chemit at 2021-01-23T15:36:20+01:00 remove unused code - - - - - 5 changed files: - client/configuration/src/main/java/fr/ird/observe/client/configuration/ClientConfig.java - client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUINavigationHandler.java - client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUINavigationInitializer.java - services/local-impl/src/main/java/fr/ird/observe/services/local/service/data/ContainerDataServiceLocalSupport.java - services/local-impl/src/main/java/fr/ird/observe/services/local/service/data/ps/observation/SampleDataServiceLocalSupport.java Changes: ===================================== client/configuration/src/main/java/fr/ird/observe/client/configuration/ClientConfig.java ===================================== @@ -814,8 +814,17 @@ public class ClientConfig extends GeneratedClientConfig implements TripMapConfig loadUIConfigFile(ObserveClientResourceManager.Resource.ui_navigation_common, dir); loadUIConfigFile(ObserveClientResourceManager.Resource.ui_navigation_ps, dir); loadUIConfigFile(ObserveClientResourceManager.Resource.ui_navigation_ll, dir); - UIManager.getDefaults().put("BlockingLayerUI.busyColor", getBusyStateColor()); - UIManager.getDefaults().put("BlockingLayerUI.blockColor", getBlockStateColor()); + UIDefaults defaults = UIManager.getDefaults(); + defaults.put("BlockingLayerUI.busyColor", getBusyStateColor()); + defaults.put("BlockingLayerUI.blockColor", getBlockStateColor()); + for (ClientConfigOption option : ClientConfigOption.values()) { + if (option.getType()==Color.class) { + String key = option.getKey(); + Color color = get().getOptionAsColor(key); + log.info(String.format("Register color: %s → %s", key,color)); + defaults.put(key, color); + } + } } ===================================== client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUINavigationHandler.java ===================================== @@ -25,6 +25,7 @@ package fr.ird.observe.client.datasource.editor.api.content.data.table; import fr.ird.observe.client.datasource.editor.api.content.ContentMode; import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationHandler; +import javax.swing.UIManager; import java.awt.Color; import java.util.Objects; @@ -38,6 +39,8 @@ public abstract class ContentTableUINavigationHandler<N extends ContentTableUINa private final N node; + private Color disabledColor; + private Color emptyColor; public ContentTableUINavigationHandler(N node) { this.node = Objects.requireNonNull(node); } @@ -48,7 +51,10 @@ public abstract class ContentTableUINavigationHandler<N extends ContentTableUINa @Override public Color getColor() { if (!getNode().getInitializer().isShowData()) { - return Color.GRAY; + return getDisabledColor(); + } + if (getNode().getInitializer().isEmpty()) { + return getEmptyColor(); } return super.getColor(); } @@ -75,4 +81,18 @@ public abstract class ContentTableUINavigationHandler<N extends ContentTableUINa } return node.getParent().getHandler().getContentMode(); } + + public Color getDisabledColor() { + if (disabledColor==null) { + disabledColor = UIManager.getColor("ui.tree.node.disabled.color"); + } + return disabledColor; + } + + public Color getEmptyColor() { + if (emptyColor==null) { + emptyColor = UIManager.getColor("ui.tree.node.empty.color"); + } + return emptyColor; + } } ===================================== client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUINavigationInitializer.java ===================================== @@ -44,6 +44,7 @@ public class ContentTableUINavigationInitializer extends NavigationInitializer<C private DtoReference parentReference; private SingletonSupplier<Boolean> showData; + private SingletonSupplier<Boolean> empty; public static <D extends IdDto> boolean isEnabled(D bean, Class<? extends IdDto> dtoType) { Stream<JavaBeanPropertyDefinition<?, ?>> properties = bean.javaBeanDefinition().readProperties(); @@ -56,6 +57,17 @@ public class ContentTableUINavigationInitializer extends NavigationInitializer<C return true; } + public static <D extends IdDto> boolean isEmpty(D bean, Class<? extends IdDto> dtoType) { + Stream<JavaBeanPropertyDefinition<?, ?>> properties = bean.javaBeanDefinition().readProperties(); + String propertyNameCandidate = Introspector.decapitalize(dtoType.getSimpleName()) + .replace("Dto", "Empty") + .replace("Reference", "Empty"); + if (properties.anyMatch(p -> propertyNameCandidate.equals(p.propertyName()))) { + return bean.get(propertyNameCandidate); + } + return false; + } + public ContentTableUINavigationInitializer(NavigationScope scope, DtoReference parentReference) { super(scope); this.parentReference = Objects.requireNonNull(parentReference); @@ -65,6 +77,7 @@ public class ContentTableUINavigationInitializer extends NavigationInitializer<C protected Object init(NavigationContext<ContentTableUINavigationContext> context) { context.initReference(parentReference); this.showData = SingletonSupplier.of(this::computeShowSata); + this.empty = SingletonSupplier.of(this::computeEmpty); return getScope().getMainType(); } @@ -72,6 +85,10 @@ public class ContentTableUINavigationInitializer extends NavigationInitializer<C return isEnabled(parentReference, getScope().getMainType()); } + protected boolean computeEmpty() { + return isEmpty(parentReference, getScope().getMainType()); + } + @Override protected void open(NavigationContext<ContentTableUINavigationContext> context) { showData.clear(); @@ -94,6 +111,10 @@ public class ContentTableUINavigationInitializer extends NavigationInitializer<C return showData.get(); } + public boolean isEmpty() { + return empty.get(); + } + @Override public String toString() { ===================================== services/local-impl/src/main/java/fr/ird/observe/services/local/service/data/ContainerDataServiceLocalSupport.java ===================================== @@ -76,10 +76,6 @@ public class ContainerDataServiceLocalSupport<PE extends DataEntity<?, ?>, D ext return saveEntity(parentSpi, spi, entity, saveCallback); } - protected E newEntity() { - return spi.newEntity(now()); - } - protected PE loadOrCreateEntityFromDto(M dto) { return mainSpi.loadOrCreateEntityFromDto(getApplicationLocale(), getTopiaPersistenceContext(), dto); } @@ -92,10 +88,6 @@ public class ContainerDataServiceLocalSupport<PE extends DataEntity<?, ?>, D ext return parentSpi.loadEntity(getApplicationLocale(), getTopiaPersistenceContext(), parenId); } -// protected E loadSimpleEntity(String id) { -// return spi.loadEntity(getApplicationLocale(), getTopiaPersistenceContext(), id); -// } - } ===================================== services/local-impl/src/main/java/fr/ird/observe/services/local/service/data/ps/observation/SampleDataServiceLocalSupport.java ===================================== @@ -61,8 +61,6 @@ public abstract class SampleDataServiceLocalSupport<C extends ContainerChildDto, public SaveResultDto save(M dto) { Set parent = getParent(dto); E entity = loadOrCreateEntityFromDto(parent, dto); - checkLastUpdateDate(entity, dto); - entity.fromDto(getReferentialLocale(), dto); return onSave(parent, entity, dto); } @@ -82,6 +80,7 @@ public abstract class SampleDataServiceLocalSupport<C extends ContainerChildDto, protected final E loadOrCreateEntityFromDto(Set parent, M dto) { dto.setId(null); E entity = loadFormEntity(parent); + checkLastUpdateDate(entity, dto); entity.fromDto(getReferentialLocale(), dto); dto.setId(entity.getTopiaId()); return entity; View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/5f427e5b57f6ba0f3e15da249... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/5f427e5b57f6ba0f3e15da249... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT