mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +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>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -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<IDIYComponent<?>> components =
|
||||
(List<IDIYComponent<?>>) 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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user