diff --git a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
index cfd8f4e4..12c22134 100644
--- a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
+++ b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
@@ -617,9 +617,9 @@ public class Presenter implements IPlugInPort {
IDIYComponent> topComponent = components.get(0);
// If ctrl is pressed just toggle the component under mouse
// cursor.
- if (!Utils.isMac() && ctrlDown) {
+ if (ctrlDown) {
if (newSelection.contains(topComponent)) {
- newSelection.removeAll(findAllGroupedComponents(topComponent));
+ newSelection.removeAll(findAllGroupedComponents(topComponent));
} else {
newSelection.addAll(findAllGroupedComponents(topComponent));
}
diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar
index 5c31a81b..5d13643c 100644
Binary files a/diylc/diylc-library/lib/diylc-core.jar and b/diylc/diylc-library/lib/diylc-core.jar differ
diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar
index 5c31a81b..5d13643c 100644
Binary files a/diylc/diylc-swing/lib/diylc-core.jar and b/diylc/diylc-swing/lib/diylc-core.jar differ
diff --git a/diylc/diylc-swing/library/main.jar b/diylc/diylc-swing/library/main.jar
index 39a4e75f..06180036 100644
Binary files a/diylc/diylc-swing/library/main.jar and b/diylc/diylc-swing/library/main.jar differ
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java
index 382d7da3..bc5cb4d7 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java
@@ -47,7 +47,6 @@ import javax.swing.SwingUtilities;
import org.apache.log4j.Logger;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.appframework.miscutils.IConfigListener;
-import org.diylc.appframework.miscutils.Utils;
import org.diylc.common.BadPositionException;
import org.diylc.common.EventType;
import org.diylc.common.IComponentTransformer;
@@ -136,23 +135,31 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
if (canvasPanel == null) {
canvasPanel = new CanvasPanel(plugInPort);
canvasPanel.addMouseListener(new MouseAdapter() {
+
+ private MouseEvent pressedEvent;
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ plugInPort.mouseClicked(e.getPoint(), e.getButton(), e.isControlDown(), e.isShiftDown(), e.isAltDown(),
+ e.getClickCount());
+ }
@Override
public void mousePressed(MouseEvent e) {
+ LOG.info("Pressed: " + e.isPopupTrigger());
canvasPanel.requestFocus();
- mouseReleased(e);
+ pressedEvent = e;
}
@Override
public void mouseReleased(final MouseEvent e) {
-
// Invoke the rest of the code later so we get the chance to
// process selection messages.
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
- if (plugInPort.getNewComponentTypeSlot() == null && e.isPopupTrigger()) {
+ if (plugInPort.getNewComponentTypeSlot() == null && (e.isPopupTrigger() || pressedEvent.isPopupTrigger())) {
// Enable actions.
boolean enabled = !plugInPort.getSelectedComponents().isEmpty();
getCutAction().setEnabled(enabled);
@@ -192,8 +199,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
@Override
public void keyPressed(KeyEvent e) {
- if (plugInPort.keyPressed(e.getKeyCode(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(),
- e.isShiftDown(), e.isAltDown())) {
+ if (plugInPort.keyPressed(e.getKeyCode(), e.isControlDown(), e.isShiftDown(), e.isAltDown())) {
e.consume();
}
}
@@ -204,17 +210,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
@Override
public void mouseMoved(MouseEvent e) {
canvasPanel.setCursor(plugInPort.getCursorAt(e.getPoint()));
- plugInPort.mouseMoved(e.getPoint(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(), e.isShiftDown(),
- e.isAltDown());
- }
- });
-
- canvasPanel.addMouseListener(new MouseAdapter() {
-
- @Override
- public void mouseClicked(MouseEvent e) {
- plugInPort.mouseClicked(e.getPoint(), e.getButton(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(),
- e.isShiftDown(), e.isAltDown(), e.getClickCount());
+ plugInPort.mouseMoved(e.getPoint(), e.isControlDown(), e.isShiftDown(), e.isAltDown());
}
});
}
@@ -250,7 +246,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
boolean wheelZoom = ConfigurationManager.getInstance().readBoolean(IPlugInPort.WHEEL_ZOOM_KEY, false);
- if (wheelZoom || (Utils.isMac() ? e.isMetaDown() : e.isControlDown())) {
+ if (wheelZoom || e.isControlDown()) {
Point mousePos = getCanvasPanel().getMousePosition(true);
@@ -271,10 +267,10 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
}
plugInPort.setZoomLevel(newZoom = availableZoomLevels[i]);
}
-
+
Rectangle2D selectionBounds = plugInPort.getSelectionBounds(true);
Rectangle visibleRect = scrollPane.getVisibleRect();
-
+
JScrollBar horizontal = scrollPane.getHorizontalScrollBar();
JScrollBar vertical = scrollPane.getVerticalScrollBar();
@@ -283,8 +279,8 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
Point desiredPos =
new Point((int) (1d * mousePos.x / oldZoom * newZoom), (int) (1d * mousePos.y / oldZoom * newZoom));
int dx = desiredPos.x - mousePos.x;
- int dy = desiredPos.y - mousePos.y;
- horizontal.setValue(horizontal.getValue() + dx);
+ int dy = desiredPos.y - mousePos.y;
+ horizontal.setValue(horizontal.getValue() + dx);
vertical.setValue(vertical.getValue() + dy);
} else {
// center to selection
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentButtonFactory.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentButtonFactory.java
index f5406d60..ca0c5f21 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentButtonFactory.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentButtonFactory.java
@@ -1,184 +1,178 @@
/*
+ *
+ * DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
+ *
+ * This file is part of DIYLC.
+ *
+ * DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with DIYLC. If not, see
+ * .
+ */
+package org.diylc.swing.plugins.toolbox;
- DIY Layout Creator (DIYLC).
- Copyright (c) 2009-2018 held jointly by the individual authors.
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+import java.util.List;
- This file is part of DIYLC.
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
+import javax.swing.SwingUtilities;
+import javax.swing.border.Border;
+import javax.swing.border.EmptyBorder;
- DIYLC is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
+import org.diylc.common.ComponentType;
+import org.diylc.common.IPlugInPort;
+import org.diylc.core.IDIYComponent;
+import org.diylc.core.Template;
+import org.diylc.images.IconLoader;
+import org.diylc.swingframework.openide.DropDownButtonFactory;
- DIYLC is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+/**
+ * Factory that creates {@link JButton}s which display component type icons and instantiates the
+ * component when clicked.
+ *
+ * @author Branislav Stojkovic
+ */
+public class ComponentButtonFactory {
- You should have received a copy of the GNU General Public License
- along with DIYLC. If not, see .
+ public static int MARGIN = 3;
-*/
-package org.diylc.swing.plugins.toolbox;
-
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPopupMenu;
-import javax.swing.SwingUtilities;
-import javax.swing.border.Border;
-import javax.swing.border.EmptyBorder;
-
-import org.diylc.appframework.miscutils.Utils;
-import org.diylc.common.ComponentType;
-import org.diylc.common.IPlugInPort;
-import org.diylc.core.IDIYComponent;
-import org.diylc.core.Template;
-import org.diylc.images.IconLoader;
-import org.diylc.swingframework.openide.DropDownButtonFactory;
-
-/**
- * Factory that creates {@link JButton}s which display component type icons and instantiates the
- * component when clicked.
- *
- * @author Branislav Stojkovic
- */
-public class ComponentButtonFactory {
-
- public static int MARGIN = 3;
-
- public static JButton create(final IPlugInPort plugInPort, final ComponentType componentType, final JPopupMenu menu) {
- JButton button = DropDownButtonFactory.createDropDownButton(componentType.getIcon(), menu);
-
- button.setBorder(BorderFactory.createEmptyBorder(MARGIN + 1, MARGIN + 1, MARGIN, MARGIN));
-
- button.setToolTipText("" + componentType.getName() + "
" + componentType.getDescription()
- + "
Author: " + componentType.getAuthor() + "
Right click to select all components of this type"
- + "");
- button.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- plugInPort.setNewComponentTypeSlot(componentType, null);
- }
- });
-
- button.addMouseListener(new MouseAdapter() {
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (e.getButton() == MouseEvent.BUTTON3) {
- List> components = plugInPort.getCurrentProject().getComponents();
- List> newSelection = new ArrayList>();
- for (IDIYComponent> component : components) {
- if (componentType.getInstanceClass().equals(component.getClass())) {
- newSelection.add(component);
- }
- }
- // Ctrl appends selection
- if (Utils.isMac() ? e.isMetaDown() : e.isControlDown()) {
- newSelection.addAll(plugInPort.getSelectedComponents());
- }
- plugInPort.updateSelection(newSelection);
- plugInPort.setNewComponentTypeSlot(null, null);
- plugInPort.refresh();
- }
- }
- });
-
- button.addKeyListener(new KeyAdapter() {
-
- @Override
- public void keyPressed(KeyEvent e) {
- plugInPort.keyPressed(e.getKeyCode(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(), e.isShiftDown(),
- e.isAltDown());
- }
- });
- return button;
- }
-
- public static JMenuItem createTemplateItem(final IPlugInPort plugInPort, final Template template,
- final ComponentType componentType) {
- final JMenuItem item = new JMenuItem(template.getName()) {
-
- private static final long serialVersionUID = 1L;
-
- // Customize item size to fit the delete button
- public java.awt.Dimension getPreferredSize() {
- Dimension d = super.getPreferredSize();
- return new Dimension(d.width + 32, d.height);
- }
- };
- item.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- plugInPort.setNewComponentTypeSlot(componentType, template);
- }
- });
-
- JLabel label = new JLabel(template.isDefaultFlag() ? IconLoader.PinGreen.getIcon() : IconLoader.PinGrey.getIcon());
- label.setToolTipText(template.isDefaultFlag() ? "Remove default variant" : "Set default variant");
- label.addMouseListener(new MouseAdapter() {
-
- @Override
- public void mouseClicked(MouseEvent e) {
- // Hide the menu
- Container c = item.getParent();
- if (c != null && c instanceof JPopupMenu) {
- JPopupMenu m = (JPopupMenu) c;
- m.setVisible(false);
- }
- plugInPort.setTemplateDefault(componentType.getCategory(), componentType.getName(), template.getName(),
- !template.isDefaultFlag());
- e.consume();
- }
- });
- Border margin = new EmptyBorder(4, 0, 0, 0);
- label.setBorder(margin);
- item.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
- item.add(label);
-
- label = new JLabel(IconLoader.Garbage.getIcon());
- label.setToolTipText("Delete variant");
- label.addMouseListener(new MouseAdapter() {
-
- @Override
- public void mouseClicked(MouseEvent e) {
- // Hide the menu
- Container c = item.getParent();
- if (c != null && c instanceof JPopupMenu) {
- JPopupMenu m = (JPopupMenu) c;
- m.setVisible(false);
- }
- int result =
- JOptionPane.showConfirmDialog(SwingUtilities.getRoot(item), "Are you sure you want to delete variant \""
- + template.getName() + "\"", "Delete", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
- if (result != JOptionPane.YES_OPTION) {
- return;
- }
- plugInPort.deleteTemplate(componentType.getCategory(), componentType.getName(), template.getName());
- e.consume();
- }
- });
- margin = new EmptyBorder(4, 2, 0, 0);
- label.setBorder(margin);
- item.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
- item.add(label);
- return item;
- }
-}
+ public static JButton create(final IPlugInPort plugInPort, final ComponentType componentType, final JPopupMenu menu) {
+ JButton button = DropDownButtonFactory.createDropDownButton(componentType.getIcon(), menu);
+
+ button.setBorder(BorderFactory.createEmptyBorder(MARGIN + 1, MARGIN + 1, MARGIN, MARGIN));
+
+ button.setToolTipText("" + componentType.getName() + "
" + componentType.getDescription()
+ + "
Author: " + componentType.getAuthor() + "
Right click to select all components of this type"
+ + "");
+ button.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ plugInPort.setNewComponentTypeSlot(componentType, null);
+ }
+ });
+
+ button.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ if (e.getButton() == MouseEvent.BUTTON3) {
+ List> components = plugInPort.getCurrentProject().getComponents();
+ List> newSelection = new ArrayList>();
+ for (IDIYComponent> component : components) {
+ if (componentType.getInstanceClass().equals(component.getClass())) {
+ newSelection.add(component);
+ }
+ }
+ // Ctrl appends selection
+ if (e.isControlDown()) {
+ newSelection.addAll(plugInPort.getSelectedComponents());
+ }
+ plugInPort.updateSelection(newSelection);
+ plugInPort.setNewComponentTypeSlot(null, null);
+ plugInPort.refresh();
+ }
+ }
+ });
+
+ button.addKeyListener(new KeyAdapter() {
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ plugInPort.keyPressed(e.getKeyCode(), e.isControlDown(), e.isShiftDown(), e.isAltDown());
+ }
+ });
+ return button;
+ }
+
+ public static JMenuItem createTemplateItem(final IPlugInPort plugInPort, final Template template,
+ final ComponentType componentType) {
+ final JMenuItem item = new JMenuItem(template.getName()) {
+
+ private static final long serialVersionUID = 1L;
+
+ // Customize item size to fit the delete button
+ public java.awt.Dimension getPreferredSize() {
+ Dimension d = super.getPreferredSize();
+ return new Dimension(d.width + 32, d.height);
+ }
+ };
+ item.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ plugInPort.setNewComponentTypeSlot(componentType, template);
+ }
+ });
+
+ JLabel label = new JLabel(template.isDefaultFlag() ? IconLoader.PinGreen.getIcon() : IconLoader.PinGrey.getIcon());
+ label.setToolTipText(template.isDefaultFlag() ? "Remove default variant" : "Set default variant");
+ label.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ // Hide the menu
+ Container c = item.getParent();
+ if (c != null && c instanceof JPopupMenu) {
+ JPopupMenu m = (JPopupMenu) c;
+ m.setVisible(false);
+ }
+ plugInPort.setTemplateDefault(componentType.getCategory(), componentType.getName(), template.getName(),
+ !template.isDefaultFlag());
+ e.consume();
+ }
+ });
+ Border margin = new EmptyBorder(4, 0, 0, 0);
+ label.setBorder(margin);
+ item.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
+ item.add(label);
+
+ label = new JLabel(IconLoader.Garbage.getIcon());
+ label.setToolTipText("Delete variant");
+ label.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ // Hide the menu
+ Container c = item.getParent();
+ if (c != null && c instanceof JPopupMenu) {
+ JPopupMenu m = (JPopupMenu) c;
+ m.setVisible(false);
+ }
+ int result =
+ JOptionPane.showConfirmDialog(SwingUtilities.getRoot(item), "Are you sure you want to delete variant \""
+ + template.getName() + "\"", "Delete", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
+ if (result != JOptionPane.YES_OPTION) {
+ return;
+ }
+ plugInPort.deleteTemplate(componentType.getCategory(), componentType.getName(), template.getName());
+ e.consume();
+ }
+ });
+ margin = new EmptyBorder(4, 2, 0, 0);
+ label.setBorder(margin);
+ item.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
+ item.add(label);
+ return item;
+ }
+}
diff --git a/diylc/diylc-swing/update.xml b/diylc/diylc-swing/update.xml
index 3f3a8b10..8c5b52e2 100644
--- a/diylc/diylc-swing/update.xml
+++ b/diylc/diylc-swing/update.xml
@@ -2052,8 +2052,12 @@
BUG_FIX
- Clicking on a building block twice in a row inside the component tree would make the components go back to the top-left corner of the layout
-
+ Clicking on a building block in the component tree sometimes makes the components go back to the top-left corner of the layout
+
+
+ BUG_FIX
+ Ctrl + click doesn't add components to the selection in MacOS
+
https://github.com/bancika/diy-layout-creator/releases