Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
b30328dd
by Tony Chemit at 2021-11-04T17:13:47+01:00
-
491c31d7
by Tony Chemit at 2021-11-04T17:32:24+01:00
5 changed files:
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/referential/ContentReferentialUI.jcss
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/referential/ContentReferentialUIHandler.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/referential/ContentReferentialUINavigationHandler.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/referential/ReferentialHomeUINavigationHandler.java
- models/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripMapBuilder.java
Changes:
| ... | ... | @@ -102,3 +102,7 @@ |
| 102 | 102 |
enabled:{showTechnicalInformations.isEnabled()};
|
| 103 | 103 |
}
|
| 104 | 104 |
|
| 105 |
+#changeId {
|
|
| 106 |
+ enabled:false;
|
|
| 107 |
+}
|
|
| 108 |
+ |
| ... | ... | @@ -58,11 +58,13 @@ import javax.swing.Icon; |
| 58 | 58 |
import javax.swing.JList;
|
| 59 | 59 |
import javax.swing.KeyStroke;
|
| 60 | 60 |
import javax.swing.SwingUtilities;
|
| 61 |
+import java.awt.Component;
|
|
| 61 | 62 |
import java.awt.Container;
|
| 62 | 63 |
import java.awt.event.MouseAdapter;
|
| 63 | 64 |
import java.awt.event.MouseEvent;
|
| 64 | 65 |
import java.util.Collections;
|
| 65 | 66 |
import java.util.List;
|
| 67 |
+import java.util.Objects;
|
|
| 66 | 68 |
import java.util.Set;
|
| 67 | 69 |
|
| 68 | 70 |
/**
|
| ... | ... | @@ -87,6 +89,8 @@ public class ContentReferentialUIHandler<D extends ReferentialDto, R extends Ref |
| 87 | 89 |
return;
|
| 88 | 90 |
}
|
| 89 | 91 |
ui1.revalidate();
|
| 92 |
+ Component component = ui1.getHandler().computeFocusOwner();
|
|
| 93 |
+ component.requestFocusInWindow();
|
|
| 90 | 94 |
};
|
| 91 | 95 |
}
|
| 92 | 96 |
|
| ... | ... | @@ -134,6 +138,7 @@ public class ContentReferentialUIHandler<D extends ReferentialDto, R extends Ref |
| 134 | 138 |
public final ContentOpenWithValidator<U> getContentOpen() {
|
| 135 | 139 |
return (ContentOpenWithValidator<U>) super.getContentOpen();
|
| 136 | 140 |
}
|
| 141 |
+ |
|
| 137 | 142 |
@Override
|
| 138 | 143 |
protected final ContentUIInitializer<U> createContentUIInitializer(U ui) {
|
| 139 | 144 |
return new ContentReferentialUIInitializer<>(ui);
|
| ... | ... | @@ -154,6 +159,25 @@ public class ContentReferentialUIHandler<D extends ReferentialDto, R extends Ref |
| 154 | 159 |
installSaveAction();
|
| 155 | 160 |
}
|
| 156 | 161 |
|
| 162 |
+ @Override
|
|
| 163 |
+ protected Container computeFocusOwnerContainer() {
|
|
| 164 |
+ if (getModel().getSource().getHandler().getChildCount() == 0) {
|
|
| 165 |
+ return ui;
|
|
| 166 |
+ }
|
|
| 167 |
+ if (Objects.equals(ui.getViewLayout().getSelected(), ContentReferentialUI.LIST_VIEW)) {
|
|
| 168 |
+ return ui.getContentBody();
|
|
| 169 |
+ }
|
|
| 170 |
+ ContentMode mode = getModel().getStates().getMode();
|
|
| 171 |
+ if (mode == null || mode == ContentMode.READ || !getModel().getStates().isEditable()) {
|
|
| 172 |
+ if (Objects.equals(ui.getViewLayout().getSelected(), ContentReferentialUI.DETAIL_VIEW)) {
|
|
| 173 |
+ // can't give focus to form
|
|
| 174 |
+ return ui.getActions();
|
|
| 175 |
+ }
|
|
| 176 |
+ return ui.getContentBody();
|
|
| 177 |
+ }
|
|
| 178 |
+ return super.computeFocusOwnerContainer();
|
|
| 179 |
+ }
|
|
| 180 |
+ |
|
| 157 | 181 |
@Override
|
| 158 | 182 |
public void installChangeModeAction() {
|
| 159 | 183 |
ChangeModeRequest request = ChangeModeRequest.of(ui);
|
| ... | ... | @@ -25,7 +25,9 @@ package fr.ird.observe.client.datasource.editor.api.content.referential; |
| 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 java.awt.Color;
|
|
| 28 | 29 |
import java.util.Objects;
|
| 30 |
+import java.util.function.Supplier;
|
|
| 29 | 31 |
|
| 30 | 32 |
/**
|
| 31 | 33 |
* Created on 24/10/2020.
|
| ... | ... | @@ -53,7 +55,7 @@ public abstract class ContentReferentialUINavigationHandler<N extends ContentRef |
| 53 | 55 |
public final String getText() {
|
| 54 | 56 |
N node = getNode();
|
| 55 | 57 |
String text = node.getScope().getI18nTranslation("type");
|
| 56 |
- return String.format("%s (%s)", text, node.isLoaded() ? node.getReferences().size() : node.getInitializer().getInitialCount());
|
|
| 58 |
+ return text + getChildCountText();
|
|
| 57 | 59 |
}
|
| 58 | 60 |
|
| 59 | 61 |
@Override
|
| ... | ... | @@ -64,6 +66,25 @@ public abstract class ContentReferentialUINavigationHandler<N extends ContentRef |
| 64 | 66 |
|
| 65 | 67 |
@Override
|
| 66 | 68 |
public String getContentTitle() {
|
| 67 |
- return getNode().getScope().getI18nTranslation("type");
|
|
| 69 |
+ return getText();
|
|
| 70 |
+ }
|
|
| 71 |
+ |
|
| 72 |
+ @Override
|
|
| 73 |
+ protected Color getColor0(Supplier<Color> defaultValue) {
|
|
| 74 |
+ if (!getNode().getInitializer().isEditable()) {
|
|
| 75 |
+ return getDisabledColor();
|
|
| 76 |
+ }
|
|
| 77 |
+ if (getChildCount() == 0) {
|
|
| 78 |
+ return getEmptyColor();
|
|
| 79 |
+ }
|
|
| 80 |
+ return super.getColor0(defaultValue);
|
|
| 81 |
+ }
|
|
| 82 |
+ |
|
| 83 |
+ protected long getChildCount() {
|
|
| 84 |
+ return node.isLoaded() ? node.getReferences().size() : node.getInitializer().getInitialCount();
|
|
| 85 |
+ }
|
|
| 86 |
+ |
|
| 87 |
+ protected String getChildCountText() {
|
|
| 88 |
+ return String.format(" (%d)", getChildCount());
|
|
| 68 | 89 |
}
|
| 69 | 90 |
}
|
| ... | ... | @@ -25,7 +25,9 @@ package fr.ird.observe.client.datasource.editor.api.content.referential; |
| 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 java.awt.Color;
|
|
| 28 | 29 |
import java.util.Objects;
|
| 30 |
+import java.util.function.Supplier;
|
|
| 29 | 31 |
|
| 30 | 32 |
/**
|
| 31 | 33 |
* Created on 24/10/2020.
|
| ... | ... | @@ -69,4 +71,12 @@ public abstract class ReferentialHomeUINavigationHandler<N extends ReferentialHo |
| 69 | 71 |
// We can not perform any edit action
|
| 70 | 72 |
return ContentMode.READ;
|
| 71 | 73 |
}
|
| 74 |
+ |
|
| 75 |
+ @Override
|
|
| 76 |
+ protected Color getColor0(Supplier<Color> defaultValue) {
|
|
| 77 |
+ if (!getNode().getInitializer().isEditable()) {
|
|
| 78 |
+ return getDisabledColor();
|
|
| 79 |
+ }
|
|
| 80 |
+ return super.getColor0(defaultValue);
|
|
| 81 |
+ }
|
|
| 72 | 82 |
}
|
| ... | ... | @@ -98,7 +98,7 @@ public class TripMapBuilder { |
| 98 | 98 |
" FROM ps_logbook.route r" +
|
| 99 | 99 |
" INNER JOIN ps_logbook.activity a ON a.route = r.topiaId" +
|
| 100 | 100 |
" WHERE r.trip = ?" +
|
| 101 |
- " ORDER BY r.date, a.time");
|
|
| 101 |
+ " ORDER BY r.date, a.number");
|
|
| 102 | 102 |
}
|
| 103 | 103 |
|
| 104 | 104 |
@Override
|