mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Tilde to repeat last added component
This commit is contained in:
@@ -737,6 +737,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void mouseMoved(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown) {
|
public void mouseMoved(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown) {
|
||||||
|
if (point == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (shiftDown) {
|
if (shiftDown) {
|
||||||
dragAction = IPlugInPort.DND_TOGGLE_SNAP;
|
dragAction = IPlugInPort.DND_TOGGLE_SNAP;
|
||||||
@@ -1443,8 +1445,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
public void setDefaultPropertyValue(Class<?> clazz, String propertyName, Object value) {
|
public void setDefaultPropertyValue(Class<?> clazz, String propertyName, Object value) {
|
||||||
LOG.info(String.format("setProjectDefaultPropertyValue(%s, %s, %s)", clazz.getName(), propertyName, value));
|
LOG.info(String.format("setProjectDefaultPropertyValue(%s, %s, %s)", clazz.getName(), propertyName, value));
|
||||||
LOG.debug("Default property value set for " + Project.class.getName() + ":" + propertyName);
|
LOG.debug("Default property value set for " + Project.class.getName() + ":" + propertyName);
|
||||||
ConfigurationManager.getInstance().writeValue(DEFAULTS_KEY_PREFIX + clazz.getName() + ":" + propertyName,
|
ConfigurationManager.getInstance().writeValue(DEFAULTS_KEY_PREFIX + clazz.getName() + ":" + propertyName, value);
|
||||||
value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1910,8 +1911,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Could not apply properties", e);
|
LOG.error("Could not apply properties", e);
|
||||||
view.showMessage("Could not apply changes. Check the log for details.", "Error",
|
view.showMessage("Could not apply changes. Check the log for details.", "Error", IView.ERROR_MESSAGE);
|
||||||
IView.ERROR_MESSAGE);
|
|
||||||
} finally {
|
} finally {
|
||||||
// Notify the listeners.
|
// Notify the listeners.
|
||||||
if (!oldProject.equals(currentProject)) {
|
if (!oldProject.equals(currentProject)) {
|
||||||
|
|||||||
Binary file not shown.
@@ -21,6 +21,7 @@ import java.awt.image.VolatileImage;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -101,7 +102,10 @@ public class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializeActions() {
|
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");
|
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "clearSlot");
|
||||||
|
|
||||||
for (int i = 1; i <= 12; i++) {
|
for (int i = 1; i <= 12; i++) {
|
||||||
final int x = i;
|
final int x = i;
|
||||||
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F1 + i - 1, 0),
|
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);
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import java.awt.event.MouseEvent;
|
|||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.Format;
|
import java.text.Format;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|||||||
@@ -1762,6 +1762,10 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<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>
|
<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>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>'Tilde' key repeats the last added component</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||||
</org.diylc.appframework.update.Version>
|
</org.diylc.appframework.update.Version>
|
||||||
|
|||||||
Reference in New Issue
Block a user