From 34b4c3f70d0086750b915b1c638a8080ce07f5c8 Mon Sep 17 00:00:00 2001 From: Igor Maznitsa Date: Sat, 28 Dec 2019 14:40:21 +0200 Subject: [PATCH] fix of group selection --- .../mindmap/plugins/api/VisualAttributePlugin.java | 10 ++++++---- .../emoticon/EmoticonVisualAttributePlugin.java | 2 +- .../attributes/images/ImageVisualAttributePlugin.java | 9 ++++++--- .../igormaznitsa/mindmap/swing/panel/MindMapPanel.java | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/plugins/api/VisualAttributePlugin.java b/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/plugins/api/VisualAttributePlugin.java index bcf54f6b5..cb01835ae 100644 --- a/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/plugins/api/VisualAttributePlugin.java +++ b/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/plugins/api/VisualAttributePlugin.java @@ -41,12 +41,14 @@ public interface VisualAttributePlugin extends AttributePlugin { /** * Process click on image represents the attribute, * - * @param context the plugin context - * @param topic the topic - * @param clickCount detected number of mouse clicks + * @param context the plugin context + * @param topic the topic + * @param activeGroupModifier true if any modifier to work with topic group (like SHIFT or CTRL) is active + * @param clickCount detected number of mouse clicks * @return true if the map was changed for the operation, false otherwise + * @since 1.4.7 */ - boolean onClick(@Nonnull PluginContext context, @Nonnull Topic topic, int clickCount); + boolean onClick(@Nonnull PluginContext context, @Nonnull Topic topic, boolean activeGroupModifier, int clickCount); /** * Get tool-tip for image represents the attribute. diff --git a/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/plugins/attributes/emoticon/EmoticonVisualAttributePlugin.java b/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/plugins/attributes/emoticon/EmoticonVisualAttributePlugin.java index dfb1a60d6..a3b9ea371 100644 --- a/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/plugins/attributes/emoticon/EmoticonVisualAttributePlugin.java +++ b/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/plugins/attributes/emoticon/EmoticonVisualAttributePlugin.java @@ -54,7 +54,7 @@ public Renderable getScaledImage(@Nonnull final MindMapPanelConfig config, @Nonn } @Override - public boolean onClick(@Nonnull PluginContext context, @Nonnull final Topic topic, int clickCount) { + public boolean onClick(final @Nonnull PluginContext context, final @Nonnull Topic topic, final boolean activeGroupModifier, final int clickCount) { return false; } diff --git a/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/plugins/attributes/images/ImageVisualAttributePlugin.java b/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/plugins/attributes/images/ImageVisualAttributePlugin.java index a3c7df0ff..e1ae15e8e 100644 --- a/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/plugins/attributes/images/ImageVisualAttributePlugin.java +++ b/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/plugins/attributes/images/ImageVisualAttributePlugin.java @@ -73,9 +73,9 @@ private Image extractImage(@Nonnull final Topic topic) { } @Override - public boolean onClick(@Nonnull PluginContext context, @Nonnull final Topic activeTopic, final int clickCount) { + public boolean onClick(@Nonnull final PluginContext context, @Nonnull final Topic topic, final boolean activeGroupModifier, final int clickCount) { if (clickCount > 1) { - final String imageFilePathUri = activeTopic.getAttribute(ATTR_IMAGE_URI_KEY); + final String imageFilePathUri = topic.getAttribute(ATTR_IMAGE_URI_KEY); if (imageFilePathUri != null) { try { context.openFile(new MMapURI(imageFilePathUri).asFile(context.getProjectFolder()), false); @@ -84,7 +84,10 @@ public boolean onClick(@Nonnull PluginContext context, @Nonnull final Topic acti } } } else { - context.getPanel().select(activeTopic, false); + if (!activeGroupModifier) { + context.getPanel().removeAllSelection(); + } + context.getPanel().select(topic, false); } return false; } diff --git a/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java b/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java index 9ef8963ca..2cafcc84c 100644 --- a/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java +++ b/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java @@ -730,7 +730,7 @@ public void mouseClicked(@Nonnull final MouseEvent e) { if (plugin.isClickable(context, element.getModel())) { processedByPlugin = true; try { - if (plugin.onClick(context, element.getModel(), e.getClickCount())) { + if (plugin.onClick(context, element.getModel(), e.isShiftDown() || e.isControlDown(), e.getClickCount())) { doLayout(); revalidate(); repaint();