Tilde to repeat last added component

This commit is contained in:
bancika
2017-04-26 16:30:02 +02:00
parent 3f4b0475bc
commit b2501ccba1
5 changed files with 42 additions and 9 deletions
@@ -737,6 +737,8 @@ 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;
@@ -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)) {
Binary file not shown.
@@ -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<String> recent =
(List<String>) ConfigurationManager.getInstance().readObject(IPlugInPort.RECENT_COMPONENTS_KEY, null);
if (recent != null && !recent.isEmpty()) {
String clazz = recent.get(0);
Map<String, List<ComponentType>> componentTypes = CanvasPanel.this.plugInPort.getComponentTypes();
for (Map.Entry<String, List<ComponentType>> 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")
@@ -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;
+4
View File
@@ -1762,6 +1762,10 @@
<changeType>NEW_FEATURE</changeType>
<description>Potentiometers can show an optional shaft, can have either solder lugs or PCB pins and rendering includes the wafer</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>'Tilde' key repeats the last added component</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>