mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Added "Renumber On Paste" option in the "Config" menu
This commit is contained in:
@@ -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<IDIYComponent<?>> components, boolean autoGroup);
|
||||
void pasteComponents(Collection<IDIYComponent<?>> components, boolean autoGroup, boolean assignNewNames);
|
||||
|
||||
/**
|
||||
* Duplicates selected components and places them nearby.
|
||||
|
||||
@@ -143,7 +143,7 @@ public class InstantiationManager {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void pasteComponents(Collection<IDIYComponent<?>> 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<? extends IDIYComponent<?>>) component.getClass());
|
||||
String newName = createUniqueName(componentType, allComponents);
|
||||
|
||||
@@ -1556,10 +1556,10 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pasteComponents(Collection<IDIYComponent<?>> components, boolean autoGroup) {
|
||||
LOG.info(String.format("pasteComponents(%s, %s)", components, autoGroup));
|
||||
public void pasteComponents(Collection<IDIYComponent<?>> 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();
|
||||
}
|
||||
|
||||
@@ -2726,6 +2726,10 @@
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added ability to collapse and expand the component tree panel to the left edge of the screen</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added "Renumber On Paste" option in the "Config" menu</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Upgraded to Java 8</description>
|
||||
|
||||
Reference in New Issue
Block a user