mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
Tilde to repeat last added component
This commit is contained in:
@@ -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<IDIYComponent<?>, Set<Integer>> controlPointMap = new HashMap<IDIYComponent<?>, Set<Integer>>();
|
||||
// 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)) {
|
||||
|
||||
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;
|
||||
|
||||
@@ -1761,6 +1761,10 @@
|
||||
<org.diylc.appframework.update.Change>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user