diff --git a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java index 0f952dbd..cc5d6a10 100644 --- a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java +++ b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java @@ -737,7 +737,9 @@ public class Presenter implements IPlugInPort { @SuppressWarnings("unchecked") @Override public void mouseMoved(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown) { - + if (point == null) + return; + if (shiftDown) { dragAction = IPlugInPort.DND_TOGGLE_SNAP; } else { @@ -859,7 +861,7 @@ public class Presenter implements IPlugInPort { public void nudgeSelection(Size xOffset, Size yOffset, boolean includeStuckComponents) { if (selectedComponents == null || selectedComponents.isEmpty()) return; - + LOG.debug(String.format("nudgeSelection(%s, %s, %s)", xOffset, yOffset, includeStuckComponents)); Map, Set> controlPointMap = new HashMap, Set>(); // If there aren't any control points, try to add all the selected @@ -877,10 +879,10 @@ public class Presenter implements IPlugInPort { if (controlPointMap.isEmpty()) { return; } - + if (includeStuckComponents) { includeStuckComponents(controlPointMap); - } + } int dx = (int) xOffset.convertToPixels(); int dy = (int) yOffset.convertToPixels(); @@ -1443,8 +1445,7 @@ public class Presenter implements IPlugInPort { public void setDefaultPropertyValue(Class clazz, String propertyName, Object value) { LOG.info(String.format("setProjectDefaultPropertyValue(%s, %s, %s)", clazz.getName(), propertyName, value)); LOG.debug("Default property value set for " + Project.class.getName() + ":" + propertyName); - ConfigurationManager.getInstance().writeValue(DEFAULTS_KEY_PREFIX + clazz.getName() + ":" + propertyName, - value); + ConfigurationManager.getInstance().writeValue(DEFAULTS_KEY_PREFIX + clazz.getName() + ":" + propertyName, value); } @Override @@ -1910,8 +1911,7 @@ public class Presenter implements IPlugInPort { } } catch (Exception e) { LOG.error("Could not apply properties", e); - view.showMessage("Could not apply changes. Check the log for details.", "Error", - IView.ERROR_MESSAGE); + view.showMessage("Could not apply changes. Check the log for details.", "Error", IView.ERROR_MESSAGE); } finally { // Notify the listeners. if (!oldProject.equals(currentProject)) { diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar index 8bcba159..6f27e1b3 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/src/org/diylc/swing/plugins/canvas/CanvasPanel.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPanel.java index 1d0629d4..367083c5 100644 --- a/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPanel.java +++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPanel.java @@ -21,6 +21,7 @@ import java.awt.image.VolatileImage; import java.util.EnumSet; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -101,7 +102,10 @@ public class CanvasPanel extends JComponent implements Autoscroll { } private void initializeActions() { + getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_QUOTE, 0), "repeatLast"); + getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "clearSlot"); + for (int i = 1; i <= 12; i++) { final int x = i; getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F1 + i - 1, 0), @@ -126,6 +130,32 @@ public class CanvasPanel extends JComponent implements Autoscroll { CanvasPanel.this.plugInPort.setNewComponentTypeSlot(null, null); } }); + + getActionMap().put("repeatLast", new AbstractAction() { + + private static final long serialVersionUID = 1L; + + @SuppressWarnings("unchecked") + @Override + public void actionPerformed(ActionEvent e) { + List recent = + (List) ConfigurationManager.getInstance().readObject(IPlugInPort.RECENT_COMPONENTS_KEY, null); + if (recent != null && !recent.isEmpty()) { + String clazz = recent.get(0); + Map> componentTypes = CanvasPanel.this.plugInPort.getComponentTypes(); + for (Map.Entry> entry : componentTypes.entrySet()) { + for (ComponentType type : entry.getValue()) { + if (type.getInstanceClass().getCanonicalName().equals(clazz)) { + CanvasPanel.this.plugInPort.setNewComponentTypeSlot(type, null); + // hack: fake mouse movement to repaint + CanvasPanel.this.plugInPort.mouseMoved(getMousePosition(), false, false, false); + return; + } + } + } + } + } + }); } @SuppressWarnings("unchecked") diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/statusbar/StatusBar.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/statusbar/StatusBar.java index e1a5b3b4..c7ef3b6e 100644 --- a/diylc/diylc-swing/src/org/diylc/swing/plugins/statusbar/StatusBar.java +++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/statusbar/StatusBar.java @@ -13,7 +13,6 @@ import java.awt.event.MouseEvent; import java.awt.geom.Point2D; import java.text.DecimalFormat; import java.text.Format; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; diff --git a/diylc/diylc-swing/update.xml b/diylc/diylc-swing/update.xml index 10fc4627..bf5509d3 100644 --- a/diylc/diylc-swing/update.xml +++ b/diylc/diylc-swing/update.xml @@ -1761,6 +1761,10 @@ NEW_FEATURE Potentiometers can show an optional shaft, can have either solder lugs or PCB pins and rendering includes the wafer + + + NEW_FEATURE + 'Tilde' key repeats the last added component https://github.com/bancika/diy-layout-creator/releases