Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: bea39d78 by Tony Chemit at 2023-07-26T16:56:52+02:00 Fix migration - See #2762 - - - - - ab18e1d6 by Tony Chemit at 2023-07-28T16:05:34+02:00 On ne voit pas les toolTip dans les arbres des assistants de synchronisation - Closes #2768 - - - - - 984a29d2 by Tony Chemit at 2023-07-28T16:05:34+02:00 Add a new classifier «action» on enumeration I18n constants (will be used by new actions based on enumration) - - - - - f1602cd3 by Tony Chemit at 2023-07-28T16:05:34+02:00 Open API in ToolkitTreeModelSupport to be able to build first the flatModel and then build the root node from it (will be used when we want to keep the flatModel and do some filter on it to produce root node without having to make a service call, since the flatModel won't have changed) - - - - - 5f94b023 by Tony Chemit at 2023-07-28T16:05:34+02:00 Review method SelectionTreeModelSupport.allDataIds to be able to use it outside of the model scope - - - - - acd770bf by Tony Chemit at 2023-07-28T16:05:34+02:00 Improve SelectionTreeNodeRendererContext API to be able to extend it - - - - - 22e5721c by Tony Chemit at 2023-07-28T16:05:34+02:00 Ne plus afficher le label L'opération requière des corrections sur les interfaces de certains assistants - Closes #2767 - - - - - 15 changed files: - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/AdminTabUI.jaxx - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/AdminTabUIHandler.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/pairing/ActivityPairingUIHandler.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportUIHandler.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/data/DataSynchroUIHandler.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/data/tree/DataSelectionTreePaneHandler.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/ReferentialSynchroUIHandler.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/tree/ReferentialSelectionTreeCellRenderer.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/validate/ValidateUIHandler.java - core/persistence/migration/src/main/resources/db/migration/v9/9.2/07_issue-2762-PG.sql - toolkit/api/src/main/java/fr/ird/observe/dto/I18nDecoratorHelper.java - toolkit/api/src/main/java/fr/ird/observe/navigation/tree/ToolkitTreeModelSupport.java - toolkit/api/src/main/java/fr/ird/observe/navigation/tree/selection/SelectionTreeCellRenderer.java - toolkit/api/src/main/java/fr/ird/observe/navigation/tree/selection/SelectionTreeModelSupport.java - toolkit/api/src/main/java/fr/ird/observe/navigation/tree/selection/SelectionTreeNodeRendererContext.java Changes: ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/AdminTabUI.jaxx ===================================== @@ -64,6 +64,7 @@ protected AdminTabUI(AdminUI parentContext) { } public void destroy() { + getHandler().destroy(); description.setText(""); leftSourceModel = null; rightSourceModel = null; ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/AdminTabUIHandler.java ===================================== @@ -28,6 +28,8 @@ import org.nuiton.jaxx.runtime.swing.wizard.ext.WizardState; import javax.swing.JButton; import javax.swing.JTextArea; import javax.swing.SwingUtilities; +import java.awt.GridBagConstraints; +import java.awt.Insets; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Objects; @@ -169,4 +171,15 @@ public class AdminTabUIHandler<U extends AdminTabUI> implements WithClientUICont progression.append(text + "\n"); progression.setCaretPosition(progression.getDocument().getLength()); } + + protected void hideFixedPanelLabel(AdminTabUI ui) { + // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2767 + // FIXME Maybe we should use a simple JPanel instead? + ui.getNEED_FIX_panel().removeAll(); + ui.getNEED_FIX_panel().add(ui.getNEED_FIX_content(), new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0)); + } + + public void destroy() { + + } } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/pairing/ActivityPairingUIHandler.java ===================================== @@ -36,5 +36,6 @@ public class ActivityPairingUIHandler extends AdminTabUIHandler<ActivityPairingU public void afterInit(ActivityPairingUI ui) { super.afterInit(ui); setAutoStart(ui.getPrepare()); + hideFixedPanelLabel(ui); } } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportUIHandler.java ===================================== @@ -122,6 +122,7 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa } } + @Override public void destroy() { ObserveSwingDataSource dataSource = ui.getModel().getConfigModel().getLeftSourceModel().getSafeSource(false); if (dataSource.isOpen()) { ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/data/DataSynchroUIHandler.java ===================================== @@ -32,6 +32,7 @@ import fr.ird.observe.client.util.init.UIInitHelper; import org.nuiton.jaxx.runtime.spi.UIHandler; import javax.swing.JScrollPane; +import javax.swing.ToolTipManager; import static io.ultreia.java4all.i18n.I18n.t; @@ -54,6 +55,8 @@ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> imple SelectUnselectWithOpposite.init(ui.getLeftTreePane().getTree(), null, new SelectUnselectWithOpposite(ui.getRightTreePane().getTree())); JScrollPane descriptionPane = ui.getDescriptionPane(); descriptionPane.getParent().remove(descriptionPane); + + hideFixedPanelLabel(ui); } @Override @@ -64,4 +67,9 @@ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> imple configModel.addPropertyChangeListener(StorageUIModel.VALID_PROPERTY_NAME, evt -> getModel().validate()); } + @Override + public void destroy() { + ToolTipManager.sharedInstance().unregisterComponent(ui.getLeftTreePane().getTree().getTree()); + ToolTipManager.sharedInstance().unregisterComponent(ui.getRightTreePane().getTree().getTree()); + } } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/data/tree/DataSelectionTreePaneHandler.java ===================================== @@ -45,6 +45,7 @@ import javax.swing.JLabel; import javax.swing.JPopupMenu; import javax.swing.JSeparator; import javax.swing.SwingUtilities; +import javax.swing.ToolTipManager; import javax.swing.tree.TreePath; import java.awt.Color; import java.awt.event.MouseAdapter; @@ -123,7 +124,7 @@ public class DataSelectionTreePaneHandler implements UIHandler<DataSelectionTree Consumer<TreeConfigUI> consumer = TreeConfigUIHandler::hideOptions; Consumer<TreeConfigUI> apply = u -> initPanel(parent, ui); SelectionTreePaneHandler.init(treePane, consumer, apply); - + ToolTipManager.sharedInstance().registerComponent(tree); if (isLeft) { stepModel.setLeftSelectionDataModel(treeModel); } else { ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/ReferentialSynchroUIHandler.java ===================================== @@ -32,6 +32,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.nuiton.jaxx.runtime.spi.UIHandler; +import javax.swing.ToolTipManager; import java.util.EnumSet; import static io.ultreia.java4all.i18n.I18n.t; @@ -59,6 +60,9 @@ public class ReferentialSynchroUIHandler extends AdminTabUIHandler<ReferentialSy parentUI.getTabs().setTitleAt(1, t("observe.ui.datasource.editor.actions.synchro.referential.withMode", newValue.getLabel())); } }); + hideFixedPanelLabel(ui); + ToolTipManager.sharedInstance().registerComponent(ui.getLeftTreePane().getTree()); + ToolTipManager.sharedInstance().registerComponent(ui.getRightTreePane().getTree()); } @Override ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/tree/ReferentialSelectionTreeCellRenderer.java ===================================== @@ -75,7 +75,7 @@ public class ReferentialSelectionTreeCellRenderer extends DefaultXTreeCellRender super.getTreeCellRendererComponent(tree, text, sel, expanded, leaf, row, hasFocus); setIcon(icon); - setToolTipText(text); + panel.setToolTipText(text); boolean selectedState; Icon selectedIcon = unselectedIcon; if (node.isLeaf()) { ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/validate/ValidateUIHandler.java ===================================== @@ -127,6 +127,7 @@ public class ValidateUIHandler extends AdminTabUIHandler<ValidateUI> implements Set<ValidatorDto> validators = getValidatorsManager().getValidators(); ValidateModel stepModel = model.getValidateModel(); stepModel.setAllValidators(validators); + hideFixedPanelLabel(ui); } @Override ===================================== core/persistence/migration/src/main/resources/db/migration/v9/9.2/07_issue-2762-PG.sql ===================================== @@ -19,8 +19,8 @@ -- <http://www.gnu.org/licenses/gpl-3.0.html>. -- #L% --- -ALTER TABLE ps_common.ObservedSystem RENAME allwObservation TO observation; -ALTER TABLE ps_common.ObservedSystem RENAME allwLogbook TO logbook; -ALTER TABLE ps_common.WeightCategory RENAME allwLanding TO landing; -ALTER TABLE ps_common.WeightCategory RENAME allwLogbook TO logbook; -ALTER TABLE ps_common.WeightCategory RENAME allwWellPlan TO wellPlan; +ALTER TABLE ps_common.ObservedSystem RENAME allowObservation TO observation; +ALTER TABLE ps_common.ObservedSystem RENAME allowLogbook TO logbook; +ALTER TABLE ps_common.WeightCategory RENAME allowLanding TO landing; +ALTER TABLE ps_common.WeightCategory RENAME allowLogbook TO logbook; +ALTER TABLE ps_common.WeightCategory RENAME allowWellPlan TO wellPlan; ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/I18nDecoratorHelper.java ===================================== @@ -49,6 +49,8 @@ public abstract class I18nDecoratorHelper extends BeanPropertyI18nKeyProducerPro public static final String I18N_CONSTANT_LABEL = "label"; public static final String I18N_CONSTANT_LABEL_PATTERN = "observe.constant.@CLASS_SIMPLE_NAME@.@NAME@"; public static final String I18N_CONSTANT_DESCRIPTION_PATTERN = "observe.constant.@CLASS_SIMPLE_NAME@.@NAME@.description"; + public static final String I18N_CONSTANT_ACTION = "action"; + public static final String I18N_CONSTANT_ACTION_PATTERN = "observe.constant.@CLASS_SIMPLE_NAME@.@NAME@.action"; public static final String I18N_CONSTANT_STORAGE_LABEL_PATTERN = "observe.constant.storage.@CLASS_SIMPLE_NAME@.@NAME@"; public static final String I18N_CONSTANT_NAVIGATION_LABEL_PATTERN = "observe.Common.navigation.config.@CLASS_SIMPLE_NAME@.@NAME@"; public static final String I18N_CONSTANT_NAVIGATION_DESCRIPTION_PATTERN = "observe.Common.navigation.config.@CLASS_SIMPLE_NAME@.@NAME@.description"; ===================================== toolkit/api/src/main/java/fr/ird/observe/navigation/tree/ToolkitTreeModelSupport.java ===================================== @@ -38,6 +38,7 @@ import java.beans.PropertyChangeSupport; import java.util.Enumeration; import java.util.List; import java.util.Objects; +import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; @@ -87,16 +88,32 @@ public abstract class ToolkitTreeModelSupport<R extends ToolkitTreeNode> extends this.editIds = editIds; } - public final void populate(Function<ToolkitTreeFlatModelRootRequest, ToolkitTreeFlatModel> service) { + public final ToolkitTreeFlatModel buildFlatModel(Function<ToolkitTreeFlatModelRootRequest, ToolkitTreeFlatModel> service) { request = toRequest(); ToolkitTreeFlatModel flatModel = service.apply(request); dataCount = flatModel.getDataCount(); augmentsModel(flatModel); + return flatModel; + } + + public final void populate(ToolkitTreeFlatModel flatModel, Consumer<R> rootConsumer) { R rootNode = new ToolkitTreeNodeBuilder().load(rootSupplier.get(), flatModel.getMapping()); augmentsRoot(rootNode); + if (rootConsumer != null) { + rootConsumer.accept(rootNode); + } setRoot(rootNode); } + public final void populate(Function<ToolkitTreeFlatModelRootRequest, ToolkitTreeFlatModel> service) { + populate(service, null); + } + + public final void populate(Function<ToolkitTreeFlatModelRootRequest, ToolkitTreeFlatModel> service, Consumer<R> rootConsumer) { + ToolkitTreeFlatModel flatModel = buildFlatModel(service); + populate(flatModel, rootConsumer); + } + public final ToolkitTreeFlatModelRootRequest getRequest() { return request; } ===================================== toolkit/api/src/main/java/fr/ird/observe/navigation/tree/selection/SelectionTreeCellRenderer.java ===================================== @@ -75,7 +75,7 @@ public class SelectionTreeCellRenderer extends DefaultXTreeCellRenderer { this.selected.setIcon(context.selectionState.getIcon()); setForeground(context.color); setIcon(context.icon); - setToolTipText(context.tip); + panel.setToolTipText(context.tip); if (context.open) { setFont(getFont().deriveFont(Font.BOLD)); } else { ===================================== toolkit/api/src/main/java/fr/ird/observe/navigation/tree/selection/SelectionTreeModelSupport.java ===================================== @@ -65,6 +65,20 @@ public class SelectionTreeModelSupport<R extends SelectionTreeNode> extends Tool */ private int selectedCount = -1; + public static List<String> allDataIds(TreeNode root) { + Enumeration<?> children = root.children(); + List<String> result = new LinkedList<>(); + while (children.hasMoreElements()) { + SelectionTreeNode topNode = (SelectionTreeNode) children.nextElement(); + Enumeration<TreeNode> dataEnum = topNode.children(); + while (dataEnum.hasMoreElements()) { + SelectionTreeNode treeNode = (SelectionTreeNode) dataEnum.nextElement(); + result.add(treeNode.getUserObject().getId()); + } + } + return result; + } + public SelectionTreeModelSupport(BusinessProject businessProject, SelectionTreeConfig config, Supplier<R> rootSupplier) { super(businessProject, config, rootSupplier); selectedData = new LinkedList<>(); @@ -163,20 +177,6 @@ public class SelectionTreeModelSupport<R extends SelectionTreeNode> extends Tool recomputeSelectedCount(); } - public List<String> allDataIds() { - Enumeration<?> children = getRoot().children(); - List<String> result = new LinkedList<>(); - while (children.hasMoreElements()) { - SelectionTreeNode topNode = (SelectionTreeNode) children.nextElement(); - Enumeration<TreeNode> dataEnum = topNode.children(); - while (dataEnum.hasMoreElements()) { - SelectionTreeNode treeNode = (SelectionTreeNode) dataEnum.nextElement(); - result.add(treeNode.getUserObject().getId()); - } - } - return result; - } - public long allDataCount() { Enumeration<?> children = getRoot().children(); long result = 0; @@ -287,7 +287,7 @@ public class SelectionTreeModelSupport<R extends SelectionTreeNode> extends Tool public void augmentsExistIds(List<String> otherSideIds) { if (otherSideIds != null) { - List<String> thisSideIds = allDataIds(); + List<String> thisSideIds = allDataIds(getRoot()); // optimization: only deal with this ids that are also on this side otherSideIds.removeIf(id -> !thisSideIds.contains(id)); // augments exist state ===================================== toolkit/api/src/main/java/fr/ird/observe/navigation/tree/selection/SelectionTreeNodeRendererContext.java ===================================== @@ -53,16 +53,30 @@ public class SelectionTreeNodeRendererContext { } else { this.count = node.getChildCount(); } - this.icon = node.getIcon(); + this.icon = buildIcon(node); + this.text = buildText(node); + this.tip = buildTip(node, text); + this.color = enabled && (!node.getUserObject().isReferentialType() || count > 0) ? Color.BLACK : Color.GRAY; + this.selectionState = node.getSelectionState(); + } + + protected Icon buildIcon(SelectionTreeNode node) { + return node.getIcon(); + } + + protected String buildText(SelectionTreeNode node) { String text = node.getUserObject().getText(); - String tip = text; if (exist) { text = t("observe.common.exist.on.remote", text); - tip = t("observe.ui.message.warning.will.be.delete", text); } - this.text = text; - this.tip = tip; - this.color = enabled && (!node.getUserObject().isReferentialType() || count > 0) ? Color.BLACK : Color.GRAY; - this.selectionState = node.getSelectionState(); + return text; + } + + protected String buildTip(SelectionTreeNode node, String text) { + String tip = text; + if (exist) { + tip += t("observe.ui.message.warning.will.be.delete", text); + } + return tip; } } View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/8703f6994cf71bbe0fa14ab21... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/8703f6994cf71bbe0fa14ab21... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT (@tchemit)