diff --git a/src/com/ibm/ServerWizard2/ServerWizard2.java b/src/com/ibm/ServerWizard2/ServerWizard2.java index e469616..130b533 100644 --- a/src/com/ibm/ServerWizard2/ServerWizard2.java +++ b/src/com/ibm/ServerWizard2/ServerWizard2.java @@ -23,7 +23,7 @@ public class ServerWizard2 { */ public final static Logger LOGGER = Logger.getLogger(ServerWizard2.class.getName()); public final static int VERSION_MAJOR = 2; - public final static int VERSION_MINOR = 2; + public final static int VERSION_MINOR = 10; public final static String PROPERTIES_FILE = "serverwiz.preferences"; public static String GIT_LOCATION = ""; diff --git a/src/com/ibm/ServerWizard2/controller/TargetWizardController.java b/src/com/ibm/ServerWizard2/controller/TargetWizardController.java index ad033d0..dc22f74 100644 --- a/src/com/ibm/ServerWizard2/controller/TargetWizardController.java +++ b/src/com/ibm/ServerWizard2/controller/TargetWizardController.java @@ -6,6 +6,7 @@ import java.io.StringWriter; import java.nio.file.Files; import java.nio.file.StandardCopyOption; +import java.util.TreeMap; import java.util.Vector; import org.apache.logging.log4j.Level; @@ -41,6 +42,10 @@ public Boolean getModelCreationMode() { return this.modelCreationMode; } + public TreeMap getAttributeFilters() { + return model.getAttributeFilters(); + } + public void init() { try { String libraryLocation = ServerWizard2.GIT_LOCATION + File.separator + this.LIBRARY_NAME; @@ -81,8 +86,8 @@ public void setModel(SystemModel model) { public void deleteTarget(Target target) { model.deleteTarget(target); } - public Vector getAttributesAndGlobals(Target targetInstance, String path) { - return model.getAttributesAndGlobals(targetInstance, path, !this.modelCreationMode); + public Vector getAttributesAndGlobals(Target targetInstance, String path, String filter) { + return model.getAttributesAndGlobals(targetInstance, path, !this.modelCreationMode, filter); } public void addTargetInstance(Target targetModel, Target parentTarget, diff --git a/src/com/ibm/ServerWizard2/model/Attribute.java b/src/com/ibm/ServerWizard2/model/Attribute.java index 17b346c..b0eaecb 100644 --- a/src/com/ibm/ServerWizard2/model/Attribute.java +++ b/src/com/ibm/ServerWizard2/model/Attribute.java @@ -7,6 +7,7 @@ public class Attribute implements java.io.Serializable { private static final long serialVersionUID = 1L; + public String show = ""; public String name = ""; public String group = ""; public AttributeValue value; @@ -31,6 +32,7 @@ public Attribute() { public Attribute(Attribute a) { this.name = a.name; + this.show = a.show; this.desc = a.desc; this.group = a.group; this.persistency = a.persistency; @@ -123,12 +125,11 @@ public void readModelXML(Element attribute) { if (SystemModel.isElementDefined(attribute,"writeable")) { writeable=true; } - if (SystemModel.isElementDefined(attribute,"serverwizHide") || - name.equals("MODEL") || name.equals("TYPE") || name.equals("CLASS")) { + if (name.equals("MODEL") || name.equals("TYPE") || name.equals("CLASS")) { hide=true; } - if (SystemModel.isElementDefined(attribute,"serverwizReadonly")) { - readonly=true; + if (SystemModel.isElementDefined(attribute,"serverwizShow")) { + show = SystemModel.getElement(attribute, "serverwizShow"); } Node simpleType = attribute.getElementsByTagName("simpleType").item(0); if (simpleType!=null) { diff --git a/src/com/ibm/ServerWizard2/model/SystemModel.java b/src/com/ibm/ServerWizard2/model/SystemModel.java index 9038239..2c160ec 100644 --- a/src/com/ibm/ServerWizard2/model/SystemModel.java +++ b/src/com/ibm/ServerWizard2/model/SystemModel.java @@ -48,6 +48,7 @@ public class SystemModel { private HashMap attributes = new HashMap(); private TreeMap> attributeGroups = new TreeMap>(); private TreeMap errata = new TreeMap(); + private TreeMap attributeFilters = new TreeMap(); // List of targets in current system private Vector targetList = new Vector(); @@ -68,7 +69,11 @@ public class SystemModel { public Vector getBusTypes() { return busTypes; } + public TreeMap getAttributeFilters() { + return this.attributeFilters; + } + public Target getTarget(String t) { return targetLookup.get(t); } @@ -525,11 +530,11 @@ private void readErrata(Element setting) { * Returns a vector of attributes located in the target and global settings * associated with a particular target instance */ - public Vector getAttributesAndGlobals(Target targetInstance, String path, Boolean showGlobalSettings) { + public Vector getAttributesAndGlobals(Target targetInstance, String path, Boolean showGlobalSettings, String filter) { Vector attributes = new Vector(); for (Map.Entry entry : targetInstance.getAttributes().entrySet()) { Attribute attribute = entry.getValue(); - if (!attribute.isHidden()) { + if (attribute.show.equals(filter) || filter.isEmpty()) { if (attribute.isGlobal() && showGlobalSettings) { if (!path.isEmpty()) { Field field = getGlobalSetting(path, attribute.name); @@ -666,10 +671,12 @@ public void loadAttributes(String fileName) throws SAXException, } grp.add(a.name); } - if (a.getValue().getType().equals("enumeration")) { a.getValue().setEnumerator(enumerations.get(a.value.getFields().get(0).name)); } + if (!a.show.isEmpty()) { + this.attributeFilters.put(a.show,true); + } } } @@ -841,13 +848,16 @@ public void deleteTarget(Target deleteTarget) { ///////////////////////////////////////////////////////////////// // Utility static methods public static String getElement(Element a, String e) { - Node n = a.getElementsByTagName(e).item(0); - if (n != null) { - Node cn = n.getChildNodes().item(0); - if (cn == null) { - return ""; + NodeList nl = a.getChildNodes(); + for (int i=0;i attrMap) { parentType.add(e.getChildNodes().item(0).getNodeValue()); } NodeList attributeList = target.getElementsByTagName("attribute"); + boolean aerror = false; for (int i = 0; i < attributeList.getLength(); ++i) { String attrId = SystemModel.getElement((Element) attributeList.item(i), "id"); Attribute attributeLookup = attrMap.get(attrId); if (attributeLookup == null) { - throw new NullPointerException("Invalid attribute id: " + attrId + "(" + type + ")"); - } - Attribute a = new Attribute(attributeLookup); - if (a.value==null) { - throw new NullPointerException("Unknown attribute value type: " + attrId + "(" + type + ")"); + aerror = true; + System.out.println("Invalid attribute id: " + attrId + "(" + type + ")"); + } else { + Attribute a = new Attribute(attributeLookup); + if (a.value==null) { + aerror = true; + System.out.println("Unknown attribute value type: " + attrId + "(" + type + ")"); + } else { + attributes.put(a.name, a); + a.value.readInstanceXML((Element) attributeList.item(i)); + } } - attributes.put(a.name, a); - a.value.readInstanceXML((Element) attributeList.item(i)); + } + if (aerror == true) { + throw new NullPointerException("Attribute import error"); } } diff --git a/src/com/ibm/ServerWizard2/view/MainDialog.java b/src/com/ibm/ServerWizard2/view/MainDialog.java index 9e277e9..17a076a 100644 --- a/src/com/ibm/ServerWizard2/view/MainDialog.java +++ b/src/com/ibm/ServerWizard2/view/MainDialog.java @@ -114,10 +114,12 @@ public class MainDialog extends Dialog { private Composite compositeDir; private Button btnHideBusses; private Button btnShowHidden; + private Combo showFilter; private AttributeEditingSupport attributeEditor; private Label label; private Label label_1; + private Composite composite_1; /** * Create the dialog. * @@ -206,13 +208,23 @@ protected Control createDialogArea(Composite parent) { + "Select and Instance type. You can optionally enter a custom name. Then click 'Add Instance' button."); columnName.setResizable(true); + + composite_1 = new Composite(sashForm_1, SWT.NONE); + + showFilter = new Combo(composite_1, SWT.READ_ONLY); + showFilter.setFont(SWTResourceManager.getFont("Arial", 9, SWT.READ_ONLY)); + showFilter.setBounds(118, 0, 336, 23); + + Label lblAttributeFilter = new Label(composite_1, SWT.NONE); + lblAttributeFilter.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL)); + lblAttributeFilter.setBounds(15, 3, 97, 15); + lblAttributeFilter.setText("Attribute Filter:"); // Create attribute table viewer = new TableViewer(sashForm_1, SWT.VIRTUAL | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); this.createAttributeTable(); - sashForm_1.setWeights(new int[] { 1, 1 }); // ////////////////////////////////////////////////////////// // Tab folders @@ -374,6 +386,14 @@ protected Control createDialogArea(Composite parent) { this.initInstanceMode(); sashForm.setWeights(new int[] { 1, 1 }); columnName.pack(); + sashForm_1.setWeights(new int[] {302, 37, 171}); + + showFilter.removeAll(); + showFilter.add(""); + for (String a : controller.getAttributeFilters().keySet()) { + showFilter.add(a); + } + return container; } @@ -693,7 +713,12 @@ private void updateView() { //A target is selected so show the associated attributes TreeItem item = tree.getSelection()[0]; ConnectionEndpoint ep = this.getEndpoint(item, null); - attributes = controller.getAttributesAndGlobals(targetInstance, "/"+ep.getName()); + int s = showFilter.getSelectionIndex(); + String show = ""; + if (s>-1) { + show = showFilter.getItem(s); + } + attributes = controller.getAttributesAndGlobals(targetInstance, "/"+ep.getName(),show); viewer.setInput(attributes); viewer.refresh(); @@ -1077,6 +1102,12 @@ public void setFilename(String filename) { } private void addEvents() { + showFilter.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent arg0) { + updateView(); + } + }); btnShowHidden.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { @@ -1212,7 +1243,7 @@ public void widgetSelected(SelectionEvent arg0) { public void widgetSelected(SelectionEvent arg0) { if (listBusses.getSelectionCount() > 0) { Connection conn = (Connection) listBusses.getData(listBusses.getSelection()[0]); - attributes = controller.getAttributesAndGlobals(conn.busTarget, ""); + attributes = controller.getAttributesAndGlobals(conn.busTarget, "",""); viewer.setInput(attributes); viewer.refresh(); }