diff --git a/diylc/diylc-core/src/org/diylc/common/IPlugInPort.java b/diylc/diylc-core/src/org/diylc/common/IPlugInPort.java index 2577ed93..83736bc2 100644 --- a/diylc/diylc-core/src/org/diylc/common/IPlugInPort.java +++ b/diylc/diylc-core/src/org/diylc/common/IPlugInPort.java @@ -77,6 +77,7 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP public static final String HARDWARE_ACCELERATION = "hardwareAcceleration"; public static final String EXTRA_SPACE_KEY = "extraSpace"; public static final String FAVORITES_KEY = "favorites"; + public static final String RENUMBER_ON_PASTE_KEY = "renumberOnPaste"; public static final String SNAP_TO_NONE = "None"; public static final String SNAP_TO_GRID = "Grid"; @@ -223,9 +224,10 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP * Adds a list of components to the project. * * @param components - * @param autoGroup + * @param autoGroup + * @param assignNewNames */ - void pasteComponents(Collection> components, boolean autoGroup); + void pasteComponents(Collection> components, boolean autoGroup, boolean assignNewNames); /** * Duplicates selected components and places them nearby. diff --git a/diylc/diylc-core/src/org/diylc/presenter/InstantiationManager.java b/diylc/diylc-core/src/org/diylc/presenter/InstantiationManager.java index 356946c0..3a72207e 100644 --- a/diylc/diylc-core/src/org/diylc/presenter/InstantiationManager.java +++ b/diylc/diylc-core/src/org/diylc/presenter/InstantiationManager.java @@ -143,7 +143,7 @@ public class InstantiationManager { @SuppressWarnings("unchecked") public void pasteComponents(Collection> components, Point scaledPoint, boolean snapToGrid, - Size gridSpacing, boolean autoGroup, Project currentProject) { + Size gridSpacing, boolean autoGroup, Project currentProject, boolean assignNewNames) { // Adjust location of components so they are centered under the mouse // cursor int minX = Integer.MAX_VALUE; @@ -159,7 +159,7 @@ public class InstantiationManager { for (IDIYComponent component : components) { // assign a new name if it already exists in the project - if (existingNames.contains(component.getName())) { + if (assignNewNames && existingNames.contains(component.getName())) { ComponentType componentType = ComponentProcessor.getInstance().extractComponentTypeFrom((Class>) component.getClass()); String newName = createUniqueName(componentType, allComponents); diff --git a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java index 7598a024..98229d4c 100644 --- a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java +++ b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java @@ -1556,10 +1556,10 @@ public class Presenter implements IPlugInPort { } @Override - public void pasteComponents(Collection> components, boolean autoGroup) { - LOG.info(String.format("pasteComponents(%s, %s)", components, autoGroup)); + public void pasteComponents(Collection> components, boolean autoGroup, boolean assignNewNames) { + LOG.info(String.format("pasteComponents(%s, %s, %s)", components, autoGroup, assignNewNames)); instantiationManager.pasteComponents(components, this.previousScaledPoint, isSnapToGrid(), - currentProject.getGridSpacing(), autoGroup, this.currentProject); + currentProject.getGridSpacing(), autoGroup, this.currentProject, assignNewNames); messageDispatcher.dispatchMessage(EventType.REPAINT); messageDispatcher.dispatchMessage(EventType.SLOT_CHANGED, instantiationManager.getComponentTypeSlot(), instantiationManager.getFirstControlPoint()); @@ -2579,7 +2579,7 @@ public class Presenter implements IPlugInPort { LOG.error("Could not clone component: " + c); } // paste them to the project - pasteComponents(clones, true); + pasteComponents(clones, true, true); } else throw new InvalidBlockException(); } diff --git a/diylc/diylc-core/src/org/diylc/presenter/update.xml b/diylc/diylc-core/src/org/diylc/presenter/update.xml index f38b370f..731e9a69 100644 --- a/diylc/diylc-core/src/org/diylc/presenter/update.xml +++ b/diylc/diylc-core/src/org/diylc/presenter/update.xml @@ -2726,6 +2726,10 @@ NEW_FEATURE Added ability to collapse and expand the component tree panel to the left edge of the screen + + NEW_FEATURE + Added "Renumber On Paste" option in the "Config" menu + IMPROVEMENT Upgraded to Java 8 diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar index 555958df..bd67c822 100644 Binary files a/diylc/diylc-library/lib/diylc-core.jar and b/diylc/diylc-library/lib/diylc-core.jar differ diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar index 555958df..bd67c822 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/ActionFactory.java b/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java index 829ff9e7..533bd6d2 100644 --- a/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java +++ b/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java @@ -411,7 +411,7 @@ public class ActionFactory { presenter.loadProjectFromFile(file.getAbsolutePath()); // Grab all components and paste them into the main // presenter - plugInPort.pasteComponents(presenter.getCurrentProject().getComponents(), false); + plugInPort.pasteComponents(presenter.getCurrentProject().getComponents(), false, false); // Cleanup components in the temp presenter, don't need // them anymore presenter.selectAll(0); @@ -1107,7 +1107,7 @@ public class ActionFactory { try { List> components = (List>) clipboard.getData(ComponentTransferable.listFlavor); - plugInPort.pasteComponents(cloneComponents(components), false); + plugInPort.pasteComponents(cloneComponents(components), false, ConfigurationManager.getInstance().readBoolean(Presenter.RENUMBER_ON_PASTE_KEY, true)); } catch (Exception ex) { LOG.error("Coule not paste.", ex); } diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/config/ConfigPlugin.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/config/ConfigPlugin.java index f1c48e5d..32933e8b 100644 --- a/diylc/diylc-swing/src/org/diylc/swing/plugins/config/ConfigPlugin.java +++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/config/ConfigPlugin.java @@ -94,6 +94,9 @@ public class ConfigPlugin implements IPlugIn { swingUI.injectMenuAction( ActionFactory.getInstance().createConfigAction(plugInPort, "Outline Mode", IPlugInPort.OUTLINE_KEY, false), CONFIG_MENU); + swingUI.injectMenuAction( + ActionFactory.getInstance().createConfigAction(plugInPort, "Renumber On Paste", IPlugInPort.RENUMBER_ON_PASTE_KEY, true), + CONFIG_MENU); swingUI.injectMenuAction( ActionFactory.getInstance().createConfigAction(plugInPort, "Show Rulers", IPlugInPort.SHOW_RULERS_KEY, true), CONFIG_MENU);