Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
51347b1d
by Tony Chemit at 2021-01-23T15:34:32+01:00
-
4067895f
by Tony Chemit at 2021-01-23T15:34:47+01:00
-
479c83f0
by Tony Chemit at 2021-01-23T15:34:59+01:00
-
0236db7e
by Tony Chemit at 2021-01-23T15:36:20+01:00
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:
| ... | ... | @@ -814,8 +814,17 @@ public class ClientConfig extends GeneratedClientConfig implements TripMapConfig |
| 814 | 814 |
loadUIConfigFile(ObserveClientResourceManager.Resource.ui_navigation_common, dir);
|
| 815 | 815 |
loadUIConfigFile(ObserveClientResourceManager.Resource.ui_navigation_ps, dir);
|
| 816 | 816 |
loadUIConfigFile(ObserveClientResourceManager.Resource.ui_navigation_ll, dir);
|
| 817 |
- UIManager.getDefaults().put("BlockingLayerUI.busyColor", getBusyStateColor());
|
|
| 818 |
- UIManager.getDefaults().put("BlockingLayerUI.blockColor", getBlockStateColor());
|
|
| 817 |
+ UIDefaults defaults = UIManager.getDefaults();
|
|
| 818 |
+ defaults.put("BlockingLayerUI.busyColor", getBusyStateColor());
|
|
| 819 |
+ defaults.put("BlockingLayerUI.blockColor", getBlockStateColor());
|
|
| 820 |
+ for (ClientConfigOption option : ClientConfigOption.values()) {
|
|
| 821 |
+ if (option.getType()==Color.class) {
|
|
| 822 |
+ String key = option.getKey();
|
|
| 823 |
+ Color color = get().getOptionAsColor(key);
|
|
| 824 |
+ log.info(String.format("Register color: %s → %s", key,color));
|
|
| 825 |
+ defaults.put(key, color);
|
|
| 826 |
+ }
|
|
| 827 |
+ }
|
|
| 819 | 828 |
|
| 820 | 829 |
}
|
| 821 | 830 |
|
| ... | ... | @@ -25,6 +25,7 @@ package fr.ird.observe.client.datasource.editor.api.content.data.table; |
| 25 | 25 |
import fr.ird.observe.client.datasource.editor.api.content.ContentMode;
|
| 26 | 26 |
import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationHandler;
|
| 27 | 27 |
|
| 28 |
+import javax.swing.UIManager;
|
|
| 28 | 29 |
import java.awt.Color;
|
| 29 | 30 |
import java.util.Objects;
|
| 30 | 31 |
|
| ... | ... | @@ -38,6 +39,8 @@ public abstract class ContentTableUINavigationHandler<N extends ContentTableUINa |
| 38 | 39 |
|
| 39 | 40 |
private final N node;
|
| 40 | 41 |
|
| 42 |
+ private Color disabledColor;
|
|
| 43 |
+ private Color emptyColor;
|
|
| 41 | 44 |
public ContentTableUINavigationHandler(N node) {
|
| 42 | 45 |
this.node = Objects.requireNonNull(node);
|
| 43 | 46 |
}
|
| ... | ... | @@ -48,7 +51,10 @@ public abstract class ContentTableUINavigationHandler<N extends ContentTableUINa |
| 48 | 51 |
@Override
|
| 49 | 52 |
public Color getColor() {
|
| 50 | 53 |
if (!getNode().getInitializer().isShowData()) {
|
| 51 |
- return Color.GRAY;
|
|
| 54 |
+ return getDisabledColor();
|
|
| 55 |
+ }
|
|
| 56 |
+ if (getNode().getInitializer().isEmpty()) {
|
|
| 57 |
+ return getEmptyColor();
|
|
| 52 | 58 |
}
|
| 53 | 59 |
return super.getColor();
|
| 54 | 60 |
}
|
| ... | ... | @@ -75,4 +81,18 @@ public abstract class ContentTableUINavigationHandler<N extends ContentTableUINa |
| 75 | 81 |
}
|
| 76 | 82 |
return node.getParent().getHandler().getContentMode();
|
| 77 | 83 |
}
|
| 84 |
+ |
|
| 85 |
+ public Color getDisabledColor() {
|
|
| 86 |
+ if (disabledColor==null) {
|
|
| 87 |
+ disabledColor = UIManager.getColor("ui.tree.node.disabled.color");
|
|
| 88 |
+ }
|
|
| 89 |
+ return disabledColor;
|
|
| 90 |
+ }
|
|
| 91 |
+ |
|
| 92 |
+ public Color getEmptyColor() {
|
|
| 93 |
+ if (emptyColor==null) {
|
|
| 94 |
+ emptyColor = UIManager.getColor("ui.tree.node.empty.color");
|
|
| 95 |
+ }
|
|
| 96 |
+ return emptyColor;
|
|
| 97 |
+ }
|
|
| 78 | 98 |
}
|
| ... | ... | @@ -44,6 +44,7 @@ public class ContentTableUINavigationInitializer extends NavigationInitializer<C |
| 44 | 44 |
|
| 45 | 45 |
private DtoReference parentReference;
|
| 46 | 46 |
private SingletonSupplier<Boolean> showData;
|
| 47 |
+ private SingletonSupplier<Boolean> empty;
|
|
| 47 | 48 |
|
| 48 | 49 |
public static <D extends IdDto> boolean isEnabled(D bean, Class<? extends IdDto> dtoType) {
|
| 49 | 50 |
Stream<JavaBeanPropertyDefinition<?, ?>> properties = bean.javaBeanDefinition().readProperties();
|
| ... | ... | @@ -56,6 +57,17 @@ public class ContentTableUINavigationInitializer extends NavigationInitializer<C |
| 56 | 57 |
return true;
|
| 57 | 58 |
}
|
| 58 | 59 |
|
| 60 |
+ public static <D extends IdDto> boolean isEmpty(D bean, Class<? extends IdDto> dtoType) {
|
|
| 61 |
+ Stream<JavaBeanPropertyDefinition<?, ?>> properties = bean.javaBeanDefinition().readProperties();
|
|
| 62 |
+ String propertyNameCandidate = Introspector.decapitalize(dtoType.getSimpleName())
|
|
| 63 |
+ .replace("Dto", "Empty")
|
|
| 64 |
+ .replace("Reference", "Empty");
|
|
| 65 |
+ if (properties.anyMatch(p -> propertyNameCandidate.equals(p.propertyName()))) {
|
|
| 66 |
+ return bean.get(propertyNameCandidate);
|
|
| 67 |
+ }
|
|
| 68 |
+ return false;
|
|
| 69 |
+ }
|
|
| 70 |
+ |
|
| 59 | 71 |
public ContentTableUINavigationInitializer(NavigationScope scope, DtoReference parentReference) {
|
| 60 | 72 |
super(scope);
|
| 61 | 73 |
this.parentReference = Objects.requireNonNull(parentReference);
|
| ... | ... | @@ -65,6 +77,7 @@ public class ContentTableUINavigationInitializer extends NavigationInitializer<C |
| 65 | 77 |
protected Object init(NavigationContext<ContentTableUINavigationContext> context) {
|
| 66 | 78 |
context.initReference(parentReference);
|
| 67 | 79 |
this.showData = SingletonSupplier.of(this::computeShowSata);
|
| 80 |
+ this.empty = SingletonSupplier.of(this::computeEmpty);
|
|
| 68 | 81 |
return getScope().getMainType();
|
| 69 | 82 |
}
|
| 70 | 83 |
|
| ... | ... | @@ -72,6 +85,10 @@ public class ContentTableUINavigationInitializer extends NavigationInitializer<C |
| 72 | 85 |
return isEnabled(parentReference, getScope().getMainType());
|
| 73 | 86 |
}
|
| 74 | 87 |
|
| 88 |
+ protected boolean computeEmpty() {
|
|
| 89 |
+ return isEmpty(parentReference, getScope().getMainType());
|
|
| 90 |
+ }
|
|
| 91 |
+ |
|
| 75 | 92 |
@Override
|
| 76 | 93 |
protected void open(NavigationContext<ContentTableUINavigationContext> context) {
|
| 77 | 94 |
showData.clear();
|
| ... | ... | @@ -94,6 +111,10 @@ public class ContentTableUINavigationInitializer extends NavigationInitializer<C |
| 94 | 111 |
return showData.get();
|
| 95 | 112 |
}
|
| 96 | 113 |
|
| 114 |
+ public boolean isEmpty() {
|
|
| 115 |
+ return empty.get();
|
|
| 116 |
+ }
|
|
| 117 |
+ |
|
| 97 | 118 |
|
| 98 | 119 |
@Override
|
| 99 | 120 |
public String toString() {
|
| ... | ... | @@ -76,10 +76,6 @@ public class ContainerDataServiceLocalSupport<PE extends DataEntity<?, ?>, D ext |
| 76 | 76 |
return saveEntity(parentSpi, spi, entity, saveCallback);
|
| 77 | 77 |
}
|
| 78 | 78 |
|
| 79 |
- protected E newEntity() {
|
|
| 80 |
- return spi.newEntity(now());
|
|
| 81 |
- }
|
|
| 82 |
- |
|
| 83 | 79 |
protected PE loadOrCreateEntityFromDto(M dto) {
|
| 84 | 80 |
return mainSpi.loadOrCreateEntityFromDto(getApplicationLocale(), getTopiaPersistenceContext(), dto);
|
| 85 | 81 |
}
|
| ... | ... | @@ -92,10 +88,6 @@ public class ContainerDataServiceLocalSupport<PE extends DataEntity<?, ?>, D ext |
| 92 | 88 |
return parentSpi.loadEntity(getApplicationLocale(), getTopiaPersistenceContext(), parenId);
|
| 93 | 89 |
}
|
| 94 | 90 |
|
| 95 |
-// protected E loadSimpleEntity(String id) {
|
|
| 96 |
-// return spi.loadEntity(getApplicationLocale(), getTopiaPersistenceContext(), id);
|
|
| 97 |
-// }
|
|
| 98 |
- |
|
| 99 | 91 |
}
|
| 100 | 92 |
|
| 101 | 93 |
|
| ... | ... | @@ -61,8 +61,6 @@ public abstract class SampleDataServiceLocalSupport<C extends ContainerChildDto, |
| 61 | 61 |
public SaveResultDto save(M dto) {
|
| 62 | 62 |
Set parent = getParent(dto);
|
| 63 | 63 |
E entity = loadOrCreateEntityFromDto(parent, dto);
|
| 64 |
- checkLastUpdateDate(entity, dto);
|
|
| 65 |
- entity.fromDto(getReferentialLocale(), dto);
|
|
| 66 | 64 |
return onSave(parent, entity, dto);
|
| 67 | 65 |
}
|
| 68 | 66 |
|
| ... | ... | @@ -82,6 +80,7 @@ public abstract class SampleDataServiceLocalSupport<C extends ContainerChildDto, |
| 82 | 80 |
protected final E loadOrCreateEntityFromDto(Set parent, M dto) {
|
| 83 | 81 |
dto.setId(null);
|
| 84 | 82 |
E entity = loadFormEntity(parent);
|
| 83 |
+ checkLastUpdateDate(entity, dto);
|
|
| 85 | 84 |
entity.fromDto(getReferentialLocale(), dto);
|
| 86 | 85 |
dto.setId(entity.getTopiaId());
|
| 87 | 86 |
return entity;
|