mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Duplicate selection option in Edit menu and popup menu (Ctrl+D)
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -39,7 +39,8 @@ public enum IconLoader {
|
||||
"messages.png"), SearchBox("search-box.png"), Screwdriver("screwdriver.png"), Hammer("hammer.png"), FlipHorizontal(
|
||||
"flip_horizontal.png"), FlipVertical("flip_vertical.png"), MagicWand("magic_wand.png"), PinGrey("pin_grey.png"), PinGreen(
|
||||
"pin_green.png"), CoffeebeanEdit("coffeebean_edit.png"), ApplicationEdit("application_edit.png"), ComponentAdd(
|
||||
"component_add.png"), History("history.png"), DocumentPlain("document_plain.png"), FitToSize("fit_to_size.png");
|
||||
"component_add.png"), History("history.png"), DocumentPlain("document_plain.png"), FitToSize("fit_to_size.png"), DocumentsGear(
|
||||
"documents_gear.png");
|
||||
|
||||
protected String name;
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 782 B |
@@ -114,6 +114,10 @@ public class ActionFactory {
|
||||
return new PasteAction(plugInPort, clipboard);
|
||||
}
|
||||
|
||||
public DuplicateAction createDuplicateAction(IPlugInPort plugInPort) {
|
||||
return new DuplicateAction(plugInPort);
|
||||
}
|
||||
|
||||
public SelectAllAction createSelectAllAction(IPlugInPort plugInPort) {
|
||||
return new SelectAllAction(plugInPort);
|
||||
}
|
||||
@@ -652,33 +656,6 @@ public class ActionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static class CopyAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
private Clipboard clipboard;
|
||||
private ClipboardOwner clipboardOwner;
|
||||
|
||||
public CopyAction(IPlugInPort plugInPort, Clipboard clipboard, ClipboardOwner clipboardOwner) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.clipboard = clipboard;
|
||||
this.clipboardOwner = clipboardOwner;
|
||||
putValue(AbstractAction.NAME, "Copy");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Copy.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Copy triggered");
|
||||
clipboard.setContents(new ComponentTransferable(cloneComponents(plugInPort.getSelectedComponents())),
|
||||
clipboardOwner);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PasteAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -710,6 +687,60 @@ public class ActionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static class CopyAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
private Clipboard clipboard;
|
||||
private ClipboardOwner clipboardOwner;
|
||||
|
||||
public CopyAction(IPlugInPort plugInPort, Clipboard clipboard, ClipboardOwner clipboardOwner) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.clipboard = clipboard;
|
||||
this.clipboardOwner = clipboardOwner;
|
||||
putValue(AbstractAction.NAME, "Copy");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Copy.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Copy triggered");
|
||||
clipboard.setContents(new ComponentTransferable(cloneComponents(plugInPort.getSelectedComponents())),
|
||||
clipboardOwner);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class DuplicateAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
|
||||
public DuplicateAction(IPlugInPort plugInPort) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Duplicate");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DocumentsGear.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Duplicate triggered");
|
||||
try {
|
||||
plugInPort.duplicateSelection();
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Coule not duplicate.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<IDIYComponent<?>> cloneComponents(Collection<IDIYComponent<?>> components) {
|
||||
List<IDIYComponent<?>> result = new ArrayList<IDIYComponent<?>>(components.size());
|
||||
for (IDIYComponent<?> component : components) {
|
||||
|
||||
@@ -64,6 +64,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
private ActionFactory.CutAction cutAction;
|
||||
private ActionFactory.CopyAction copyAction;
|
||||
private ActionFactory.PasteAction pasteAction;
|
||||
private ActionFactory.DuplicateAction duplicateAction;
|
||||
private ActionFactory.EditSelectionAction editSelectionAction;
|
||||
private ActionFactory.DeleteSelectionAction deleteSelectionAction;
|
||||
private ActionFactory.SaveAsTemplateAction saveAsTemplateAction;
|
||||
@@ -138,6 +139,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
boolean enabled = !plugInPort.getSelectedComponents().isEmpty();
|
||||
getCutAction().setEnabled(enabled);
|
||||
getCopyAction().setEnabled(enabled);
|
||||
getDuplicateAction().setEnabled(enabled);
|
||||
try {
|
||||
getPasteAction().setEnabled(clipboard.isDataFlavorAvailable(ComponentTransferable.listFlavor));
|
||||
} catch (Exception ex) {
|
||||
@@ -172,7 +174,8 @@ 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(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(),
|
||||
e.isShiftDown(), e.isAltDown())) {
|
||||
e.consume();
|
||||
}
|
||||
}
|
||||
@@ -183,7 +186,8 @@ 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());
|
||||
plugInPort.mouseMoved(e.getPoint(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(), e.isShiftDown(),
|
||||
e.isAltDown());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -191,8 +195,8 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
|
||||
@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.mouseClicked(e.getPoint(), e.getButton(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(),
|
||||
e.isShiftDown(), e.isAltDown(), e.getClickCount());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -279,6 +283,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
popupMenu.add(getCutAction());
|
||||
popupMenu.add(getCopyAction());
|
||||
popupMenu.add(getPasteAction());
|
||||
popupMenu.add(getDuplicateAction());
|
||||
popupMenu.addSeparator();
|
||||
popupMenu.add(getEditSelectionAction());
|
||||
popupMenu.add(getDeleteSelectionAction());
|
||||
@@ -411,6 +416,13 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
return pasteAction;
|
||||
}
|
||||
|
||||
public ActionFactory.DuplicateAction getDuplicateAction() {
|
||||
if (duplicateAction == null) {
|
||||
duplicateAction = ActionFactory.getInstance().createDuplicateAction(plugInPort);
|
||||
}
|
||||
return duplicateAction;
|
||||
}
|
||||
|
||||
public ActionFactory.EditSelectionAction getEditSelectionAction() {
|
||||
if (editSelectionAction == null) {
|
||||
editSelectionAction = ActionFactory.getInstance().createEditSelectionAction(plugInPort);
|
||||
|
||||
@@ -35,6 +35,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
private ActionFactory.CutAction cutAction;
|
||||
private ActionFactory.CopyAction copyAction;
|
||||
private ActionFactory.PasteAction pasteAction;
|
||||
private ActionFactory.DuplicateAction duplicateAction;
|
||||
private ActionFactory.EditSelectionAction editSelectionAction;
|
||||
private ActionFactory.DeleteSelectionAction deleteSelectionAction;
|
||||
private ActionFactory.GroupAction groupAction;
|
||||
@@ -104,6 +105,13 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
return pasteAction;
|
||||
}
|
||||
|
||||
public ActionFactory.DuplicateAction getDuplicateAction() {
|
||||
if (duplicateAction == null) {
|
||||
duplicateAction = ActionFactory.getInstance().createDuplicateAction(plugInPort);
|
||||
}
|
||||
return duplicateAction;
|
||||
}
|
||||
|
||||
public ActionFactory.EditSelectionAction getEditSelectionAction() {
|
||||
if (editSelectionAction == null) {
|
||||
editSelectionAction = ActionFactory.getInstance().createEditSelectionAction(plugInPort);
|
||||
@@ -145,7 +153,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
}
|
||||
return bringToFrontAction;
|
||||
}
|
||||
|
||||
|
||||
public ActionFactory.NudgeAction getNudgeAction() {
|
||||
if (nudgeAction == null) {
|
||||
nudgeAction = ActionFactory.getInstance().createNudgeAction(plugInPort);
|
||||
@@ -196,7 +204,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
}
|
||||
return saveAsTemplateAction;
|
||||
}
|
||||
|
||||
|
||||
public ActionFactory.SaveAsBlockAction getSaveAsBlockAction() {
|
||||
if (saveAsBlockAction == null) {
|
||||
saveAsBlockAction = ActionFactory.getInstance().createSaveAsBlockAction(plugInPort);
|
||||
@@ -217,7 +225,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
}
|
||||
return rotateCounterClockwiseAction;
|
||||
}
|
||||
|
||||
|
||||
public ActionFactory.MirrorSelectionAction getMirrorHorizontallyAction() {
|
||||
if (mirrorHorizontallyAction == null) {
|
||||
mirrorHorizontallyAction =
|
||||
@@ -246,6 +254,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
swingUI.injectMenuAction(getCutAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getCopyAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getPasteAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getDuplicateAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(null, EDIT_TITLE);
|
||||
swingUI.injectMenuAction(actionFactory.createSelectAllAction(plugInPort), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getEditSelectionAction(), EDIT_TITLE);
|
||||
@@ -265,7 +274,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
swingUI.injectMenuAction(getGroupAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(getUngroupAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(null, EDIT_TITLE);
|
||||
// swingUI.injectMenuAction(getSaveAsTemplateAction(), EDIT_TITLE);
|
||||
// swingUI.injectMenuAction(getSaveAsTemplateAction(), EDIT_TITLE);
|
||||
swingUI.injectSubmenu(RENUMBER_TITLE, IconLoader.Sort.getIcon(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getRenumberXAxisAction(), RENUMBER_TITLE);
|
||||
swingUI.injectMenuAction(getRenumberYAxisAction(), RENUMBER_TITLE);
|
||||
@@ -305,6 +314,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
boolean enabled = !plugInPort.getSelectedComponents().isEmpty();
|
||||
getCutAction().setEnabled(enabled);
|
||||
getCopyAction().setEnabled(enabled);
|
||||
getDuplicateAction().setEnabled(enabled);
|
||||
try {
|
||||
getPasteAction().setEnabled(clipboard.isDataFlavorAvailable(ComponentTransferable.listFlavor));
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -1774,6 +1774,10 @@
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Ability to change PCB board shape from rectangular to oval.</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Duplicate selection option in Edit menu and popup menu (Ctrl+D).</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added bitchin new splash screen</description>
|
||||
|
||||
Reference in New Issue
Block a user