Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
bdcb5034
by Tony CHEMIT at 2017-08-04T20:53:41+02:00
8 changed files:
- client/src/main/java/fr/ird/observe/client/db/ObserveDataSourcesManager.java
- client/src/main/java/fr/ird/observe/client/db/ObserveMainDataSourceServicesProvider.java
- client/src/main/java/fr/ird/observe/client/ui/content/impl/seine/FloatingObjectUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/impl/seine/FloatingObjectUIModel.java
- client/src/main/resources/i18n/client_en_GB.properties
- client/src/main/resources/i18n/client_es_ES.properties
- client/src/main/resources/i18n/client_fr_FR.properties
- pom.xml
Changes:
| ... | ... | @@ -287,6 +287,7 @@ public class ObserveDataSourcesManager implements Closeable { |
| 287 | 287 |
// une base locale existe, on l'ouvre
|
| 288 | 288 |
|
| 289 | 289 |
ObserveSwingDataSource dataSource = newLocalDatasource(config);
|
| 290 |
+ dataSource.setProgressModel(new ProgressModel());
|
|
| 290 | 291 |
|
| 291 | 292 |
try {
|
| 292 | 293 |
|
| ... | ... | @@ -566,7 +567,7 @@ public class ObserveDataSourcesManager implements Closeable { |
| 566 | 567 |
}
|
| 567 | 568 |
|
| 568 | 569 |
if (source.canWriteData()) {
|
| 569 |
- applicationContext.getFloatingObjectReferencesManager().sanitize(progressModel,source);
|
|
| 570 |
+ applicationContext.getFloatingObjectReferencesManager().sanitize(progressModel, source);
|
|
| 570 | 571 |
}
|
| 571 | 572 |
|
| 572 | 573 |
dataContext.populateOpens(openIds);
|
| ... | ... | @@ -25,7 +25,6 @@ package fr.ird.observe.client.db; |
| 25 | 25 |
import fr.ird.observe.client.ObserveSwingApplicationContext;
|
| 26 | 26 |
import fr.ird.observe.services.ObserveServicesProviderSupport;
|
| 27 | 27 |
import fr.ird.observe.services.service.ObserveService;
|
| 28 |
-import java.util.function.Supplier;
|
|
| 29 | 28 |
|
| 30 | 29 |
/**
|
| 31 | 30 |
* Created by tchemit on 03/08/17.
|
| ... | ... | @@ -34,19 +33,13 @@ import java.util.function.Supplier; |
| 34 | 33 |
*/
|
| 35 | 34 |
public class ObserveMainDataSourceServicesProvider extends ObserveServicesProviderSupport {
|
| 36 | 35 |
|
| 37 |
- private final Supplier<ObserveSwingDataSource> dataSourceSupplier;
|
|
| 38 |
- |
|
| 39 |
- ObserveMainDataSourceServicesProvider() {
|
|
| 40 |
- this.dataSourceSupplier = ObserveSwingApplicationContext.get().getDataSourcesManager()::getMainDataSource;
|
|
| 41 |
- }
|
|
| 42 |
- |
|
| 43 | 36 |
@Override
|
| 44 | 37 |
public void close() {
|
| 45 | 38 |
}
|
| 46 | 39 |
|
| 47 | 40 |
@Override
|
| 48 | 41 |
public <S extends ObserveService> S getService(Class<S> serviceType) {
|
| 49 |
- return dataSourceSupplier.get().getService(serviceType);
|
|
| 42 |
+ return ObserveSwingApplicationContext.get().getDataSourcesManager().getMainDataSource().getService(serviceType);
|
|
| 50 | 43 |
}
|
| 51 | 44 |
|
| 52 | 45 |
}
|
| ... | ... | @@ -50,11 +50,13 @@ import java.util.EventObject; |
| 50 | 50 |
import java.util.HashSet;
|
| 51 | 51 |
import java.util.List;
|
| 52 | 52 |
import java.util.Map;
|
| 53 |
+import java.util.Objects;
|
|
| 53 | 54 |
import java.util.Optional;
|
| 54 | 55 |
import java.util.Set;
|
| 55 | 56 |
import java.util.TreeMap;
|
| 56 | 57 |
import javax.swing.Icon;
|
| 57 | 58 |
import javax.swing.JTable;
|
| 59 |
+import javax.swing.JTree;
|
|
| 58 | 60 |
import javax.swing.SwingUtilities;
|
| 59 | 61 |
import javax.swing.event.CellEditorListener;
|
| 60 | 62 |
import javax.swing.event.TableModelListener;
|
| ... | ... | @@ -64,13 +66,19 @@ import javax.swing.table.TableCellRenderer; |
| 64 | 66 |
import org.apache.commons.logging.Log;
|
| 65 | 67 |
import org.apache.commons.logging.LogFactory;
|
| 66 | 68 |
import org.apache.log4j.lf5.viewer.categoryexplorer.TreeModelAdapter;
|
| 69 |
+import org.jdesktop.swingx.JXTable;
|
|
| 67 | 70 |
import org.jdesktop.swingx.JXTreeTable;
|
| 71 |
+import org.jdesktop.swingx.table.ColumnFactory;
|
|
| 72 |
+import org.jdesktop.swingx.table.TableColumnExt;
|
|
| 73 |
+import org.jdesktop.swingx.tree.DefaultXTreeCellRenderer;
|
|
| 68 | 74 |
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
|
| 69 | 75 |
import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
|
| 76 |
+import org.nuiton.decorator.Decorator;
|
|
| 70 | 77 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 71 | 78 |
import org.nuiton.jaxx.runtime.swing.SwingUtil;
|
| 72 | 79 |
import org.nuiton.jaxx.validator.swing.SwingValidatorMessage;
|
| 73 | 80 |
import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel;
|
| 81 |
+import org.nuiton.jaxx.validator.swing.SwingValidatorUtil;
|
|
| 74 | 82 |
import org.nuiton.validator.NuitonValidatorScope;
|
| 75 | 83 |
|
| 76 | 84 |
|
| ... | ... | @@ -345,6 +353,8 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, |
| 345 | 353 |
}
|
| 346 | 354 |
});
|
| 347 | 355 |
|
| 356 |
+ getModel().addPropertyChangeListener(FloatingObjectUIModel.PROPERTY_PARTS_MODIFIED, e -> getModel().recomputeComputedValues());
|
|
| 357 |
+ |
|
| 348 | 358 |
getBean().addPropertyChangeListener(FloatingObjectDto.PROPERTY_OBJECT_OPERATION, e -> updateMaterials((ReferentialReference) e.getNewValue()));
|
| 349 | 359 |
|
| 350 | 360 |
}
|
| ... | ... | @@ -362,10 +372,18 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, |
| 362 | 372 |
private static final Icon ICON_NOT_A_REFERENCE = SwingUtil.createImageIcon("star-empty.png");
|
| 363 | 373 |
private static final Icon ICON_IS_A_REFERENCE = SwingUtil.createImageIcon("star.png");
|
| 364 | 374 |
|
| 365 |
- private void initTable(List<ObjectMaterialHierarchyDto> dtos, JXTreeTable table) {
|
|
| 375 |
+ private void initTable(List<ObjectMaterialHierarchyDto> materials, JXTreeTable table) {
|
|
| 376 |
+ |
|
| 377 |
+ DefaultMutableTreeTableNode root = getModel().createRoot(getDecoratorService().getDecoratorByType(ObjectMaterialDto.class), materials);
|
|
| 378 |
+ DefaultTreeTableModel treeModel = new DefaultTreeTableModel(root, Arrays.asList(
|
|
| 379 |
+ t("observe.content.floatingObject.table.type"),
|
|
| 380 |
+ t("observe.common.whenArriving"),
|
|
| 381 |
+ t("observe.common.whenLeaving"))) {
|
|
| 366 | 382 |
|
| 367 |
- DefaultMutableTreeTableNode root = getModel().createRoot(getDecoratorService().getDecoratorByType(ObjectMaterialDto.class), dtos);
|
|
| 368 |
- DefaultTreeTableModel treeModel = new DefaultTreeTableModel(root, Arrays.asList("Type", "À l'arrivée", "Au départ")) {
|
|
| 383 |
+ @Override
|
|
| 384 |
+ public int getColumnCount() {
|
|
| 385 |
+ return 3;
|
|
| 386 |
+ }
|
|
| 369 | 387 |
|
| 370 | 388 |
@Override
|
| 371 | 389 |
public Class<?> getColumnClass(int column) {
|
| ... | ... | @@ -379,20 +397,61 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, |
| 379 | 397 |
}
|
| 380 | 398 |
throw new IllegalStateException();
|
| 381 | 399 |
}
|
| 400 |
+ |
|
| 401 |
+ @Override
|
|
| 402 |
+ public boolean isCellEditable(Object node, int column) {
|
|
| 403 |
+ if (node instanceof FloatingObjectPartsTreeNode) {
|
|
| 404 |
+ boolean rowEnabled = ((FloatingObjectPartsTreeNode) node).getUserObject().isEnabled();
|
|
| 405 |
+ if (!rowEnabled) {
|
|
| 406 |
+ return false;
|
|
| 407 |
+ }
|
|
| 408 |
+ }
|
|
| 409 |
+ return super.isCellEditable(node, column);
|
|
| 410 |
+ }
|
|
| 382 | 411 |
};
|
| 383 | 412 |
table.setTreeTableModel(treeModel);
|
| 384 | 413 |
|
| 385 |
- table.setLeafIcon(null);
|
|
| 386 |
- table.setOpenIcon(null);
|
|
| 387 |
- table.setClosedIcon(null);
|
|
| 388 |
- table.setCollapsedIcon(null);
|
|
| 414 |
+ table.setColumnFactory(new ColumnFactory() {
|
|
| 415 |
+ |
|
| 416 |
+ @Override
|
|
| 417 |
+ public void configureColumnWidths(JXTable table, TableColumnExt columnExt) {
|
|
| 418 |
+ if (table.getColumn(0).equals(columnExt)) {
|
|
| 419 |
+ columnExt.setPreferredWidth(getUi().getPreferredSize().width - 200);
|
|
| 420 |
+ columnExt.setMinWidth(columnExt.getPreferredWidth());
|
|
| 421 |
+ return;
|
|
| 422 |
+ }
|
|
| 423 |
+ super.configureColumnWidths(table, columnExt);
|
|
| 424 |
+ columnExt.setMinWidth(columnExt.getPreferredWidth());
|
|
| 425 |
+ }
|
|
| 426 |
+ });
|
|
| 389 | 427 |
treeModel.addTreeModelListener(new TreeModelAdapter() {
|
| 390 | 428 |
@Override
|
| 391 | 429 |
public void treeNodesChanged(TreeModelEvent e) {
|
| 392 | 430 |
getModel().setModified(true);
|
| 431 |
+ getModel().setPartsModified();
|
|
| 393 | 432 |
}
|
| 394 | 433 |
|
| 395 | 434 |
});
|
| 435 |
+ DefaultXTreeCellRenderer cellRenderer = new DefaultXTreeCellRenderer() {
|
|
| 436 |
+ |
|
| 437 |
+ Decorator<ObjectMaterialDto> decorator = getDecoratorService().getDecoratorByType(ObjectMaterialDto.class);
|
|
| 438 |
+ |
|
| 439 |
+ @Override
|
|
| 440 |
+ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
|
|
| 441 |
+ if (!(value instanceof FloatingObjectPartsTreeNode)) {
|
|
| 442 |
+ return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
|
|
| 443 |
+ }
|
|
| 444 |
+ FloatingObjectPartsTreeNode node = (FloatingObjectPartsTreeNode) value;
|
|
| 445 |
+ Component result = super.getTreeCellRendererComponent(tree, decorator.toString(node.getUserObject()), sel, expanded, leaf, row, hasFocus);
|
|
| 446 |
+ result.setEnabled(node.getUserObject().isEnabled());
|
|
| 447 |
+ return result;
|
|
| 448 |
+ }
|
|
| 449 |
+ };
|
|
| 450 |
+ |
|
| 451 |
+ cellRenderer.setLeafIcon(null);
|
|
| 452 |
+ cellRenderer.setOpenIcon(null);
|
|
| 453 |
+ cellRenderer.setClosedIcon(null);
|
|
| 454 |
+ table.setTreeCellRenderer(cellRenderer);
|
|
| 396 | 455 |
TableCellRenderer defaultRenderer = new MyRenderer(table.getDefaultRenderer(Boolean.class), table.getDefaultRenderer(String.class));
|
| 397 | 456 |
table.setDefaultRenderer(Object.class, defaultRenderer);
|
| 398 | 457 |
table.setDefaultEditor(Object.class, new MyTableCellEditor(table.getDefaultEditor(Boolean.class), table.getDefaultEditor(String.class)));
|
| ... | ... | @@ -441,17 +500,25 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, |
| 441 | 500 |
|
| 442 | 501 |
@Override
|
| 443 | 502 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
| 444 |
- if (table.isCellEditable(row, column)) {
|
|
| 445 |
- FloatingObjectPartsTreeNode node = (FloatingObjectPartsTreeNode) ((JXTreeTable) table).getPathForRow(row).getLastPathComponent();
|
|
| 503 |
+ FloatingObjectPartsTreeNode node = (FloatingObjectPartsTreeNode) ((JXTreeTable) table).getPathForRow(row).getLastPathComponent();
|
|
| 504 |
+ Objects.requireNonNull(node);
|
|
| 505 |
+ TableCellRenderer renderer = notEditableRenderer;
|
|
| 506 |
+ Object newValue = value;
|
|
| 507 |
+ boolean enabled = true;
|
|
| 508 |
+ if (node.getUserObject().getObjectMaterialType() != null && (!node.getUserObject().isEnabled() || table.isCellEditable(row, column))) {
|
|
| 446 | 509 |
String objectMaterialType = node.getUserObject().getObjectMaterialType().getId();
|
| 447 | 510 |
if ("fr.ird.observe.entities.referentiel.seine.ObjectMaterialType#0#0".equals(objectMaterialType)) {
|
| 448 |
- value = value == null ? null : Boolean.valueOf(String.valueOf(value));
|
|
| 449 |
- return editableRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
|
| 450 |
- } else
|
|
| 451 |
- return notEditableRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
|
| 511 |
+ newValue = value == null ? null : Boolean.valueOf(String.valueOf(value));
|
|
| 512 |
+ renderer = editableRenderer;
|
|
| 513 |
+ }
|
|
| 514 |
+ enabled = node.getUserObject().isEnabled();
|
|
| 452 | 515 |
} else {
|
| 453 |
- return notEditableRenderer.getTableCellRendererComponent(table, "", isSelected, hasFocus, row, column);
|
|
| 516 |
+ newValue = "";
|
|
| 454 | 517 |
}
|
| 518 |
+ |
|
| 519 |
+ Component component = renderer.getTableCellRendererComponent(table, newValue, isSelected, hasFocus, row, column);
|
|
| 520 |
+ component.setEnabled(enabled);
|
|
| 521 |
+ return component;
|
|
| 455 | 522 |
}
|
| 456 | 523 |
}
|
| 457 | 524 |
|
| ... | ... | @@ -487,7 +554,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, |
| 487 | 554 |
editor = stringEditor;
|
| 488 | 555 |
break;
|
| 489 | 556 |
default:
|
| 490 |
- throw new IllegalStateException("Cant manage with type: " + objectMaterialType);
|
|
| 557 |
+ throw new IllegalStateException("Can't manage type: " + objectMaterialType);
|
|
| 491 | 558 |
|
| 492 | 559 |
}
|
| 493 | 560 |
return editor.getTableCellEditorComponent(table, value, isSelected, row, column);
|
| ... | ... | @@ -57,6 +57,8 @@ import static org.nuiton.i18n.I18n.t; |
| 57 | 57 |
public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> {
|
| 58 | 58 |
|
| 59 | 59 |
private static final long serialVersionUID = 1L;
|
| 60 |
+ static final String PROPERTY_PARTS_MODIFIED = "partsModified";
|
|
| 61 |
+ |
|
| 60 | 62 |
private final ReferenceBinderEngine referenceBinderEngine;
|
| 61 | 63 |
private final ReferentialLocale referentialLocale;
|
| 62 | 64 |
|
| ... | ... | @@ -132,9 +134,17 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> { |
| 132 | 134 |
return result.build();
|
| 133 | 135 |
}
|
| 134 | 136 |
|
| 137 |
+ void setPartsModified() {
|
|
| 138 |
+ firePropertyChange(PROPERTY_PARTS_MODIFIED, true);
|
|
| 139 |
+ }
|
|
| 140 |
+ |
|
| 135 | 141 |
public void reset() {
|
| 136 | 142 |
whenArriving.clear();
|
| 137 | 143 |
whenLeaving.clear();
|
| 144 |
+ fireComputedValuesChanged();
|
|
| 145 |
+ }
|
|
| 146 |
+ |
|
| 147 |
+ private void fireComputedValuesChanged() {
|
|
| 138 | 148 |
firePropertyChange("computedWhenArrivingBiodegradableValue", getComputedWhenArrivingBiodegradableValue());
|
| 139 | 149 |
firePropertyChange("computedWhenArrivingNonEntanglingValue", getComputedWhenArrivingNonEntanglingValue());
|
| 140 | 150 |
firePropertyChange("computedWhenArrivingSimplifiedObjectTypeValue", getComputedWhenArrivingSimplifiedObjectTypeValue());
|
| ... | ... | @@ -161,7 +171,7 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> { |
| 161 | 171 |
this.referentialMap = referentialMap;
|
| 162 | 172 |
}
|
| 163 | 173 |
|
| 164 |
- public void setWhenArriving(String id, String value) {
|
|
| 174 |
+ void setWhenArriving(String id, String value) {
|
|
| 165 | 175 |
ObjectMaterialDto dto = referentialMap.get(id);
|
| 166 | 176 |
if (dto == null) {
|
| 167 | 177 |
return;
|
| ... | ... | @@ -169,7 +179,7 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> { |
| 169 | 179 |
whenArriving.put(dto, value);
|
| 170 | 180 |
}
|
| 171 | 181 |
|
| 172 |
- public void setWhenLeaving(String id, String value) {
|
|
| 182 |
+ void setWhenLeaving(String id, String value) {
|
|
| 173 | 183 |
ObjectMaterialDto dto = referentialMap.get(id);
|
| 174 | 184 |
if (dto == null) {
|
| 175 | 185 |
return;
|
| ... | ... | @@ -250,4 +260,17 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> { |
| 250 | 260 |
log.debug("setLeaving: " + leaving);
|
| 251 | 261 |
firePropertyChange(PROPERTY_LEAVING, leaving);
|
| 252 | 262 |
}
|
| 263 |
+ |
|
| 264 |
+ void recomputeComputedValues() {
|
|
| 265 |
+ FloatingObjectDto bean = getBean();
|
|
| 266 |
+ |
|
| 267 |
+ log.info("Computed values need to be recomputed.");
|
|
| 268 |
+ bean.setComputedWhenArrivingBiodegradable(null);
|
|
| 269 |
+ bean.setComputedWhenArrivingNonEntangling(null);
|
|
| 270 |
+ bean.setComputedWhenArrivingSimplifiedObjectType(null);
|
|
| 271 |
+ bean.setComputedWhenLeavingBiodegradable(null);
|
|
| 272 |
+ bean.setComputedWhenLeavingNonEntangling(null);
|
|
| 273 |
+ bean.setComputedWhenLeavingSimplifiedObjectType(null);
|
|
| 274 |
+ fireComputedValuesChanged();
|
|
| 275 |
+ }
|
|
| 253 | 276 |
}
|
| ... | ... | @@ -762,6 +762,7 @@ observe.content.floatingObject.message.updating=updating a floating object |
| 762 | 762 |
observe.content.floatingObject.not.a.reference=Floating object is not a reference.
|
| 763 | 763 |
observe.content.floatingObject.tab.general=General caracteristics
|
| 764 | 764 |
observe.content.floatingObject.tab.materials=Materials
|
| 765 |
+observe.content.floatingObject.table.type=Type
|
|
| 765 | 766 |
observe.content.floatingObject.title=DCP
|
| 766 | 767 |
observe.content.floatingObjectTransmittingBuoyOperation.title=Transmitting buoy operations
|
| 767 | 768 |
observe.content.floatlinesComposition.action.create=Insert this floatline
|
| ... | ... | @@ -762,6 +762,7 @@ observe.content.floatingObject.message.updating=Se está modificando el objeto f |
| 762 | 762 |
observe.content.floatingObject.not.a.reference=L'objet flottant n'est pas une référence. \#TODO
|
| 763 | 763 |
observe.content.floatingObject.tab.general=Características generales
|
| 764 | 764 |
observe.content.floatingObject.tab.materials=Materials \#TODO
|
| 765 |
+observe.content.floatingObject.table.type=Typo
|
|
| 765 | 766 |
observe.content.floatingObject.title=Objeto flotante
|
| 766 | 767 |
observe.content.floatingObjectTransmittingBuoyOperation.title=Operación sur balises
|
| 767 | 768 |
observe.content.floatlinesComposition.action.create=Insertar este orinque
|
| ... | ... | @@ -762,6 +762,7 @@ observe.content.floatingObject.message.updating=L'objet flottant est en cours de |
| 762 | 762 |
observe.content.floatingObject.not.a.reference=L'objet flottant n'est pas une référence.
|
| 763 | 763 |
observe.content.floatingObject.tab.general=Caractéristiques générales
|
| 764 | 764 |
observe.content.floatingObject.tab.materials=Matériaux
|
| 765 |
+observe.content.floatingObject.table.type=Type
|
|
| 765 | 766 |
observe.content.floatingObject.title=Objet flottant
|
| 766 | 767 |
observe.content.floatingObjectTransmittingBuoyOperation.title=Opération sur balises
|
| 767 | 768 |
observe.content.floatlinesComposition.action.create=Insérer cet orin
|
| ... | ... | @@ -171,7 +171,7 @@ |
| 171 | 171 |
<eugenePluginVersion>3.0-alpha-11</eugenePluginVersion>
|
| 172 | 172 |
<processorPluginVersion>1.3</processorPluginVersion>
|
| 173 | 173 |
|
| 174 |
- <jaxxVersion>3.0-alpha-9</jaxxVersion>
|
|
| 174 |
+ <jaxxVersion>3.0-alpha-10</jaxxVersion>
|
|
| 175 | 175 |
<nuitonI18nVersion>4.0-alpha-3</nuitonI18nVersion>
|
| 176 | 176 |
<nuitonConfigVersion>3.2</nuitonConfigVersion>
|
| 177 | 177 |
<topiaVersion>3.2.1</topiaVersion>
|