Skip to content

Commit

Permalink
Changed HashMaps to TreeMaps so saved XML will be sorted by key
Browse files Browse the repository at this point in the history
therefore making diffs and merges easier
  • Loading branch information
nkskjames committed Oct 24, 2015
1 parent 25a9857 commit 2595b33
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
10 changes: 5 additions & 5 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<property name="one-jar.dist.dir" value="c:/one-jar"/>
<property name="plugin.dir" value="C:\Program Files (x86)\eclipse.luna\eclipse\plugins"/>
<property name="one-jar.dist.dir" value="c:/one-jar-ant"/>
<property name="plugin.dir" value="C:\eclipse\plugins"/>
<import file="${one-jar.dist.dir}/one-jar-ant-task.xml" optional="true" />
<path id="classpath">
<fileset dir="lib" includes="**/*.jar"/>
<fileset dir="C:\Program Files (x86)\eclipse.luna\eclipse\plugins" includes="**/*.jar"/>
<fileset dir="C:\eclipse\plugins" includes="**/*.jar"/>
</path>
<target name="clean">
<delete dir="build"/>
Expand Down Expand Up @@ -35,7 +35,7 @@
<lib>
<fileset file="lib/swt_win64.jar"/>
<fileset file="lib/json-simple-1.1.1.jar"/>
<fileset file="${plugin.dir}/org.eclipse.jface_3.10.1.v20140813-1009.jar"/>
<fileset file="${plugin.dir}/org.eclipse.jface_3.10.2.v20141021-1035.jar"/>
<fileset file="${plugin.dir}/org.eclipse.core.runtime_3.10.0.v20140318-2214.jar"/>
<fileset file="${plugin.dir}/org.eclipse.core.commands_3.6.100.v20140528-1422.jar"/>
<fileset file="${plugin.dir}/org.eclipse.equinox.common_3.6.200.v20130402-1505.jar"/>
Expand All @@ -48,7 +48,7 @@
<lib>
<fileset file="lib/swt_linux64.jar"/>
<fileset file="lib/json-simple-1.1.1.jar"/>
<fileset file="${plugin.dir}/org.eclipse.jface_3.10.1.v20140813-1009.jar"/>
<fileset file="${plugin.dir}/org.eclipse.jface_3.10.2.v20141021-1035.jar"/>
<fileset file="${plugin.dir}/org.eclipse.core.runtime_3.10.0.v20140318-2214.jar"/>
<fileset file="${plugin.dir}/org.eclipse.core.commands_3.6.100.v20140528-1422.jar"/>
<fileset file="${plugin.dir}/org.eclipse.equinox.common_3.6.200.v20130402-1505.jar"/>
Expand Down
3 changes: 2 additions & 1 deletion src/com/ibm/ServerWizard2/MainDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.Vector;

import org.eclipse.jface.dialogs.Dialog;
Expand Down Expand Up @@ -752,7 +753,7 @@ private void refreshAttributes(Target targetInstance,ConnectionEndpoint ep) {
if (attribute.isGlobal()) {
if (ep !=null) {
String path="/"+ep.getName();
HashMap<String,Field> settings = controller.getGlobalSettings(path);
TreeMap<String,Field> settings = controller.getGlobalSettings(path);
if (settings == null) {
controller.setGlobalSetting(path, attribute.name, "");
controller.setGlobalSetting(path, "INSTANCE_ID", ep.getTargetName());
Expand Down
18 changes: 9 additions & 9 deletions src/com/ibm/ServerWizard2/SystemModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class SystemModel {
public HashMap<String, Vector<Target>> childTargetTypes = new HashMap<String, Vector<Target>>();

// From attribute types
public HashMap<String, Enumerator> enumerations = new HashMap<String, Enumerator>();
public TreeMap<String, Enumerator> enumerations = new TreeMap<String, Enumerator>();
public HashMap<String, Attribute> attributes = new HashMap<String, Attribute>();

// List of targets in current system
Expand All @@ -48,7 +48,7 @@ public class SystemModel {
private Vector<Target> busTypes = new Vector<Target>();
private PropertyChangeSupport changes = new PropertyChangeSupport(this);

private HashMap<String, HashMap<String, Field>> globalSettings = new HashMap<String, HashMap<String, Field>>();
private TreeMap<String, TreeMap<String, Field>> globalSettings = new TreeMap<String, TreeMap<String, Field>>();

public String logData;

Expand Down Expand Up @@ -358,9 +358,9 @@ public void writeEnumeration(Writer out) throws Exception {
}

public Field setGlobalSetting(String path, String attribute, String value) {
HashMap<String, Field> s = globalSettings.get(path);
TreeMap<String, Field> s = globalSettings.get(path);
if (s == null) {
s = new HashMap<String, Field>();
s = new TreeMap<String, Field>();
globalSettings.put(path, s);
}
Field f = s.get(attribute);
Expand All @@ -374,7 +374,7 @@ public Field setGlobalSetting(String path, String attribute, String value) {
}

public Boolean isGlobalSetting(String path, String attribute) {
HashMap<String, Field> s = globalSettings.get(path);
TreeMap<String, Field> s = globalSettings.get(path);
if (s == null) {
return false;
}
Expand All @@ -386,7 +386,7 @@ public Boolean isGlobalSetting(String path, String attribute) {
}

public Field getGlobalSetting(String path, String attribute) {
HashMap<String, Field> s = globalSettings.get(path);
TreeMap<String, Field> s = globalSettings.get(path);
if (s == null) {
Field f=this.setGlobalSetting(path, attribute, "");
return f;
Expand All @@ -398,13 +398,13 @@ public Field getGlobalSetting(String path, String attribute) {
return f;
}

public HashMap<String, Field> getGlobalSettings(String path) {
HashMap<String, Field> s = globalSettings.get(path);
public TreeMap<String, Field> getGlobalSettings(String path) {
TreeMap<String, Field> s = globalSettings.get(path);
return s;
}

public void writeGlobalSettings(Writer out) throws Exception {
for (Map.Entry<String, HashMap<String, Field>> entry : this.globalSettings.entrySet()) {
for (Map.Entry<String, TreeMap<String, Field>> entry : this.globalSettings.entrySet()) {
out.write("<globalSetting>\n");
out.write("\t<id>" + entry.getKey() + "</id>\n");
for (Map.Entry<String, Field> setting : entry.getValue().entrySet()) {
Expand Down
3 changes: 2 additions & 1 deletion src/com/ibm/ServerWizard2/TargetWizardController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.Vector;

import javax.xml.parsers.DocumentBuilder;
Expand Down Expand Up @@ -214,7 +215,7 @@ public void setGlobalSetting(String path,String attribute,String value) {
public Field getGlobalSetting(String path,String attribute) {
return model.getGlobalSetting(path, attribute);
}
public HashMap<String,Field> getGlobalSettings(String path) {
public TreeMap<String,Field> getGlobalSettings(String path) {
return model.getGlobalSettings(path);
}
public Vector<Target> getChildTargets(Target target) {
Expand Down

0 comments on commit 2595b33

Please sign in to comment.