mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
z-order of building blocks
This commit is contained in:
@@ -21,23 +21,23 @@
|
||||
*/
|
||||
package org.diylc.common;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public class BuildingBlockPackage {
|
||||
|
||||
private Map<String, Collection<IDIYComponent<?>>> block;
|
||||
private Map<String, List<IDIYComponent<?>>> block;
|
||||
private String owner;
|
||||
|
||||
public BuildingBlockPackage(Map<String, Collection<IDIYComponent<?>>> blocks, String owner) {
|
||||
public BuildingBlockPackage(Map<String, List<IDIYComponent<?>>> blocks, String owner) {
|
||||
super();
|
||||
this.block = blocks;
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Map<String, Collection<IDIYComponent<?>>> getBlocks() {
|
||||
public Map<String, List<IDIYComponent<?>>> getBlocks() {
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
@@ -2505,11 +2505,18 @@ public class Presenter implements IPlugInPort {
|
||||
@Override
|
||||
public void saveSelectionAsBlock(String blockName) {
|
||||
LOG.debug(String.format("saveSelectionAsBlock(%s)", blockName));
|
||||
Map<String, Collection<IDIYComponent<?>>> blocks =
|
||||
(Map<String, Collection<IDIYComponent<?>>>) ConfigurationManager.getInstance().readObject(BLOCKS_KEY, null);
|
||||
Map<String, List<IDIYComponent<?>>> blocks =
|
||||
(Map<String, List<IDIYComponent<?>>>) ConfigurationManager.getInstance().readObject(BLOCKS_KEY, null);
|
||||
if (blocks == null)
|
||||
blocks = new HashMap<String, Collection<IDIYComponent<?>>>();
|
||||
blocks.put(blockName, this.selectedComponents);
|
||||
blocks = new HashMap<String, List<IDIYComponent<?>>>();
|
||||
List<IDIYComponent<?>> blockComponents = new ArrayList<IDIYComponent<?>>(this.selectedComponents);
|
||||
Collections.sort(blockComponents, new Comparator<IDIYComponent<?>>() {
|
||||
|
||||
@Override
|
||||
public int compare(IDIYComponent<?> o1, IDIYComponent<?> o2) {
|
||||
return new Integer(currentProject.getComponents().indexOf(o1)).compareTo(currentProject.getComponents().indexOf(o2));
|
||||
}});
|
||||
blocks.put(blockName, blockComponents);
|
||||
ConfigurationManager.getInstance().writeValue(BLOCKS_KEY, blocks);
|
||||
}
|
||||
|
||||
@@ -2517,8 +2524,8 @@ public class Presenter implements IPlugInPort {
|
||||
@Override
|
||||
public void loadBlock(String blockName) throws InvalidBlockException {
|
||||
LOG.debug(String.format("loadBlock(%s)", blockName));
|
||||
Map<String, Collection<IDIYComponent<?>>> blocks =
|
||||
(Map<String, Collection<IDIYComponent<?>>>) ConfigurationManager.getInstance().readObject(BLOCKS_KEY, null);
|
||||
Map<String, List<IDIYComponent<?>>> blocks =
|
||||
(Map<String, List<IDIYComponent<?>>>) ConfigurationManager.getInstance().readObject(BLOCKS_KEY, null);
|
||||
if (blocks != null) {
|
||||
Collection<IDIYComponent<?>> components = blocks.get(blockName);
|
||||
if (components == null)
|
||||
@@ -2548,8 +2555,8 @@ public class Presenter implements IPlugInPort {
|
||||
@Override
|
||||
public void deleteBlock(String blockName) {
|
||||
LOG.debug(String.format("deleteBlock(%s)", blockName));
|
||||
Map<String, Collection<IDIYComponent<?>>> blocks =
|
||||
(Map<String, Collection<IDIYComponent<?>>>) ConfigurationManager.getInstance().readObject(BLOCKS_KEY, null);
|
||||
Map<String, List<IDIYComponent<?>>> blocks =
|
||||
(Map<String, List<IDIYComponent<?>>>) ConfigurationManager.getInstance().readObject(BLOCKS_KEY, null);
|
||||
if (blocks != null) {
|
||||
blocks.remove(blockName);
|
||||
ConfigurationManager.getInstance().writeValue(BLOCKS_KEY, blocks);
|
||||
@@ -2626,13 +2633,13 @@ public class Presenter implements IPlugInPort {
|
||||
if (pkg == null || pkg.getBlocks().isEmpty())
|
||||
return 0;
|
||||
|
||||
Map<String, Collection<IDIYComponent<?>>> blocks =
|
||||
(Map<String, Collection<IDIYComponent<?>>>) ConfigurationManager.getInstance().readObject(BLOCKS_KEY, null);
|
||||
Map<String, List<IDIYComponent<?>>> blocks =
|
||||
(Map<String, List<IDIYComponent<?>>>) ConfigurationManager.getInstance().readObject(BLOCKS_KEY, null);
|
||||
if (blocks == null) {
|
||||
blocks = new HashMap<String, Collection<IDIYComponent<?>>>();
|
||||
blocks = new HashMap<String, List<IDIYComponent<?>>>();
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Collection<IDIYComponent<?>>> entry : pkg.getBlocks().entrySet()) {
|
||||
for (Map.Entry<String, List<IDIYComponent<?>>> entry : pkg.getBlocks().entrySet()) {
|
||||
blocks.put(entry.getKey() + " [" + pkg.getOwner() + "]", entry.getValue());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user