z-order of building blocks

This commit is contained in:
Branislav Stojkovic
2019-03-04 10:34:53 +01:00
parent 04418f8101
commit 2553ffbba7
9 changed files with 51 additions and 28 deletions
@@ -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());
}
Binary file not shown.
+1 -1
View File
@@ -7,7 +7,7 @@
<property name="jar.dir" value="${build.dir}/jar" />
<property name="report.dir" value="${build.dir}/junitreport" />
<property name="main.class" value="org.diylc.DIYLCStarter" />
<property name="diylc.version" value="3.55.0" />
<property name="diylc.version" value="3.55.1" />
<property name="classes.dir" value="${build.dir}/temp/${ant.project.name}/classes" />
<property name="test.classes.dir" value="${build.dir}/temp/${ant.project.name}/test.classes" />
Binary file not shown.
Binary file not shown.
@@ -893,11 +893,11 @@ public class ActionFactory {
public void actionPerformed(ActionEvent e) {
LOG.info("ExportBuildingBlocksAction triggered");
Map<String, Collection<IDIYComponent<?>>> selectedBlocks;
Map<String, List<IDIYComponent<?>>> selectedBlocks;
try {
Map<String, Collection<IDIYComponent<?>>> blocks =
(Map<String, Collection<IDIYComponent<?>>>) ConfigurationManager.getInstance().readObject(IPlugInPort.BLOCKS_KEY, null);
Map<String, List<IDIYComponent<?>>> blocks =
(Map<String, List<IDIYComponent<?>>>) ConfigurationManager.getInstance().readObject(IPlugInPort.BLOCKS_KEY, null);
if (blocks == null || blocks.isEmpty()) {
swingUI.showMessage("No building blocks found to export.", "Error", IView.ERROR_MESSAGE);
return;
@@ -926,7 +926,7 @@ public class ActionFactory {
return;
}
selectedBlocks = new HashMap<String, Collection<IDIYComponent<?>>>();
selectedBlocks = new HashMap<String, List<IDIYComponent<?>>>();
for (Object key : selected) {
selectedBlocks.put(key.toString(), blocks.get(key));
}
@@ -152,7 +152,7 @@ public class TreePanel extends JPanel {
@SuppressWarnings("unchecked")
@Override
public void valueChanged(String key, Object value) {
Map<String, Collection<IDIYComponent<?>>> newBlocks = (Map<String, Collection<IDIYComponent<?>>>) value;
Map<String, List<IDIYComponent<?>>> newBlocks = (Map<String, List<IDIYComponent<?>>>) value;
if (newBlocks != null) {
List<String> blockNames = new ArrayList<String>(newBlocks.keySet());
Collections.sort(blockNames);
@@ -216,8 +216,8 @@ public class TreePanel extends JPanel {
if (this.blocksNode == null) {
this.blocksNode = new DefaultMutableTreeNode(new Payload("(Building Blocks)", null), true);
@SuppressWarnings("unchecked")
Map<String, Collection<IDIYComponent<?>>> newBlocks =
(Map<String, Collection<IDIYComponent<?>>>) ConfigurationManager.getInstance().readObject(
Map<String, List<IDIYComponent<?>>> newBlocks =
(Map<String, List<IDIYComponent<?>>>) ConfigurationManager.getInstance().readObject(
IPlugInPort.BLOCKS_KEY, null);
if (newBlocks != null) {
List<String> blockNames = new ArrayList<String>(newBlocks.keySet());
+20 -4
View File
@@ -2516,7 +2516,7 @@
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Show wire diameter in mm and in next to AWG gauge</description>
<description>"Analyze Guitar Wiring" can figure out if wiring is hum-cancelling and in or out of phase for each position, split-coil wiring, series/parallel humbucking mode, volume and tone potentiometers</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
@@ -2525,11 +2525,11 @@
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added 4-position Tele switch type to the "Lever Switch" component</description>
</org.diylc.appframework.update.Change>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>"Analyze Guitar Wiring" can figure out if wiring is hum-cancelling and in or out of phase for each position, split-coil wiring, series/parallel humbucking mode, volume and tone potentiometers</description>
</org.diylc.appframework.update.Change>
<description>Show wire diameter in mm and in next to AWG gauge</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Increase the range of zoom slider for images to 500%</description>
@@ -2552,6 +2552,22 @@
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>3</major>
<minor>55</minor>
<build>1</build>
</versionNumber>
<releaseDate>2019-03-02 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Z-order of components is not retained in building blocks</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
</a>
</java.util.Arrays_-ArrayList>