mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
improve paste
This commit is contained in:
+1
-1
@@ -273,7 +273,7 @@ public interface IPlugInPort {
|
|||||||
*
|
*
|
||||||
* @param components
|
* @param components
|
||||||
*/
|
*/
|
||||||
void addComponents(List<IDIYComponent<?>> components);
|
void pasteComponents(List<IDIYComponent<?>> components);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all the selected components from the project.
|
* Deletes all the selected components from the project.
|
||||||
|
|||||||
+1
-1
@@ -175,7 +175,7 @@ public class ClipboardManager implements IPlugIn, ClipboardOwner {
|
|||||||
try {
|
try {
|
||||||
List<IDIYComponent<?>> components = (List<IDIYComponent<?>>) clipboard
|
List<IDIYComponent<?>> components = (List<IDIYComponent<?>>) clipboard
|
||||||
.getData(ComponentSelection.listFlavor);
|
.getData(ComponentSelection.listFlavor);
|
||||||
plugInPort.addComponents(cloner.deepClone(components));
|
plugInPort.pasteComponents(cloner.deepClone(components));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOG.error("Coule not paste.", ex);
|
LOG.error("Coule not paste.", ex);
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-1
@@ -796,16 +796,24 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addComponents(List<IDIYComponent<?>> components) {
|
public void pasteComponents(List<IDIYComponent<?>> components) {
|
||||||
LOG.info(String.format("addComponents(%s)", components));
|
LOG.info(String.format("addComponents(%s)", components));
|
||||||
Project oldProject = cloner.deepClone(currentProject);
|
Project oldProject = cloner.deepClone(currentProject);
|
||||||
for (IDIYComponent<?> component : components) {
|
for (IDIYComponent<?> component : components) {
|
||||||
|
for (int i = 0; i < component.getControlPointCount(); i++) {
|
||||||
|
Point point = component.getControlPoint(i);
|
||||||
|
point.translate(currentProject.getGridSpacing().convertToPixels(), currentProject
|
||||||
|
.getGridSpacing().convertToPixels());
|
||||||
|
}
|
||||||
addComponent(component, componentTypeMap.get(component.getClass().getName()));
|
addComponent(component, componentTypeMap.get(component.getClass().getName()));
|
||||||
}
|
}
|
||||||
|
selectedComponents.clear();
|
||||||
|
selectedComponents.addAll(components);
|
||||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
||||||
.deepClone(currentProject), "Add");
|
.deepClone(currentProject), "Add");
|
||||||
this.modified = true;
|
this.modified = true;
|
||||||
fireFileStatusChanged();
|
fireFileStatusChanged();
|
||||||
|
fireSelectionChanged();
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user