mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 09:42:08 +10:00
Preserve z-order of components when copy-pasting
This commit is contained in:
@@ -26,6 +26,7 @@ import java.util.Comparator;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
|
||||
public class ComparatorFactory {
|
||||
|
||||
@@ -128,4 +129,16 @@ public class ComparatorFactory {
|
||||
}
|
||||
return componentZOrderComparator;
|
||||
}
|
||||
|
||||
public Comparator<IDIYComponent<?>> getComponentProjectZOrderComparator(final Project project) {
|
||||
return new Comparator<IDIYComponent<?>>() {
|
||||
|
||||
@Override
|
||||
public int compare(IDIYComponent<?> o1, IDIYComponent<?> o2) {
|
||||
int index1 = project.getComponents().indexOf(o1);
|
||||
int index2 = project.getComponents().indexOf(o2);
|
||||
return new Integer(index1).compareTo(index2);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -831,7 +831,9 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
@Override
|
||||
public Collection<IDIYComponent<?>> getSelectedComponents() {
|
||||
return selectedComponents;
|
||||
List<IDIYComponent<?>> selection = new ArrayList<IDIYComponent<?>>(selectedComponents);
|
||||
Collections.sort(selection, ComparatorFactory.getInstance().getComponentProjectZOrderComparator(currentProject));
|
||||
return selection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1878,6 +1878,10 @@
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Holding "shift" key switches mouse wheel scrolling from vertical to horizontal</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Preserve z-order of components when copy-pasting</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>"Cut Line" component sometimes disappears</description>
|
||||
|
||||
Reference in New Issue
Block a user