summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornjames <njames@us.ibm.com>2015-02-17 09:53:12 -0600
committernjames <njames@us.ibm.com>2015-02-17 09:53:12 -0600
commit9f8811b63958d35d4566d6fb4feaf4d9a1bef5c1 (patch)
tree40cb3f3f5fe7606569498285c6ee7c77b98a88ec
parent34ad2d2b2dc559ba14fbf5971a4ccd37ef643fad (diff)
downloadserverwiz-9f8811b63958d35d4566d6fb4feaf4d9a1bef5c1.tar.gz
serverwiz-9f8811b63958d35d4566d6fb4feaf4d9a1bef5c1.zip
version 2.1
-rw-r--r--src/com/ibm/ServerWizard2/AttributeEditingSupport.java32
-rw-r--r--src/com/ibm/ServerWizard2/MainDialog.java51
-rw-r--r--src/com/ibm/ServerWizard2/SdrRecord.java16
-rw-r--r--src/com/ibm/ServerWizard2/ServerWizard2.java8
-rw-r--r--src/com/ibm/ServerWizard2/SystemModel.java28
5 files changed, 92 insertions, 43 deletions
diff --git a/src/com/ibm/ServerWizard2/AttributeEditingSupport.java b/src/com/ibm/ServerWizard2/AttributeEditingSupport.java
index 4a0d167..f15e101 100644
--- a/src/com/ibm/ServerWizard2/AttributeEditingSupport.java
+++ b/src/com/ibm/ServerWizard2/AttributeEditingSupport.java
@@ -2,10 +2,16 @@ package com.ibm.ServerWizard2;
import java.util.Vector;
+import javax.swing.InputVerifier;
+import javax.swing.event.CellEditorListener;
+import javax.swing.event.ChangeEvent;
+
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ComboBoxViewerCellEditor;
import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.ICellEditorListener;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.swt.SWT;
@@ -45,10 +51,34 @@ public class AttributeEditingSupport extends EditingSupport {
this.editor=e;
} else {
this.editor = new TextCellEditor(viewer.getTable());
+ AttributeValidator attrValidator = new AttributeValidator(f);
+ this.editor.setValidator(attrValidator);
+ this.editor.addListener(new ICellEditorListener() {
+
+ public void applyEditorValue() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void cancelEditor() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void editorValueChanged(boolean arg0, boolean arg1) {
+ // TODO Auto-generated method stub
+ if (!arg1) {
+ MessageDialog.openError(null, "Invalid format", editor.getErrorMessage());
+ }
+ System.out.println(arg0+":"+arg1);
+
+ }
+
+ });
}
return editor;
}
-
+
@Override
protected Object getValue(Object obj) {
Field f = (Field) obj;
diff --git a/src/com/ibm/ServerWizard2/MainDialog.java b/src/com/ibm/ServerWizard2/MainDialog.java
index af0299e..b83842f 100644
--- a/src/com/ibm/ServerWizard2/MainDialog.java
+++ b/src/com/ibm/ServerWizard2/MainDialog.java
@@ -102,7 +102,7 @@ public class MainDialog extends Dialog {
/**
* Create the dialog.
- *
+ *
* @param parentShell
*/
public MainDialog(Shell parentShell) {
@@ -121,7 +121,7 @@ public class MainDialog extends Dialog {
/**
* Create contents of the dialog.
- *
+ *
* @param parent
*/
@Override
@@ -217,7 +217,7 @@ public class MainDialog extends Dialog {
btnDeleteTarget.setText("Delete Instance");
new Label(compositeInstance, SWT.NONE);
new Label(compositeInstance, SWT.NONE);
-
+
btnCopyInstance = new Button(compositeInstance, SWT.NONE);
btnCopyInstance.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
btnCopyInstance.setText("Copy Node or Connector");
@@ -319,7 +319,7 @@ public class MainDialog extends Dialog {
/**
* Create contents of the button bar.
- *
+ *
* @param parent
*/
@Override
@@ -441,7 +441,7 @@ public class MainDialog extends Dialog {
btnImportSDR.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
btnImportSDR.setEnabled(true);
-
+
btnRunChecks = createButton(parent, IDialogConstants.NO_ID, "Run Checks", false);
btnRunChecks.addSelectionListener(new SelectionAdapter() {
@Override
@@ -536,7 +536,6 @@ public class MainDialog extends Dialog {
this.source = null;
this.dest = null;
this.selectedEndpoint = null;
- this.targetFound = false;
refreshInstanceTree();
refreshConnections();
this.updateView();
@@ -598,7 +597,7 @@ public class MainDialog extends Dialog {
btnCopyInstance.setEnabled(false);
}
}
-
+
public void updatePopupMenu(Target selectedTarget) {
if (selectedTarget == null || tree.getSelectionCount()==0) {
@@ -609,7 +608,7 @@ public class MainDialog extends Dialog {
}
popupMenu = new Menu(tree);
-
+
if (busMode) {
if (cmbBusses.getSelectionIndex() > 0) {
if (targetForConnections != null && selectedTarget.getAttribute("CLASS").equals("UNIT")) {
@@ -705,19 +704,22 @@ public class MainDialog extends Dialog {
public ConnectionEndpoint getEndpoint(TreeItem item, String stopCard) {
ConnectionEndpoint endpoint = new ConnectionEndpoint();
-
+
Target target = (Target) item.getData();
endpoint.setTargetName(target.getName());
+ Boolean done = false;
Boolean found = false;
TreeItem parentItem = item.getParentItem();
- while (!found) {
+
+ while (!done) {
if (parentItem==null) {
- found=true;
+ done=true;
} else {
Target parentTarget = (Target) parentItem.getData();
String parentName = parentTarget.getName();
if (parentName.equals(stopCard)) {
+ done = true;
found = true;
} else {
endpoint.setPath(parentName + "/" + endpoint.getPath());
@@ -725,15 +727,21 @@ public class MainDialog extends Dialog {
}
}
}
+
+ if (!found && stopCard != null) {
+ MessageDialog.openError(null, "Connection Error", "The connection must start and end on or below selected card.");
+ endpoint=null;
+ }
return endpoint;
}
public ConnectionEndpoint getEndpoint(boolean setBold) {
TreeItem item = tree.getSelection()[0];
- if (setBold) {
+ ConnectionEndpoint endpoint = getEndpoint(item,cmbCards.getText());
+ if (setBold && endpoint != null) {
setEndpointState(item);
}
- return getEndpoint(item,cmbCards.getText());
+ return endpoint;
}
public void setEndpointState(TreeItem item) {
@@ -785,12 +793,9 @@ public class MainDialog extends Dialog {
}
public void refreshInstanceTree() {
currentPath="";
- if (this.busMode && this.targetForConnections !=null) {
- this.updateInstanceTree(targetForConnections, null);
- } else {
- for (Target target : controller.getRootTargets()) {
- this.updateInstanceTree(target, null);
- }
+ targetFound = false;
+ for (Target target : controller.getRootTargets()) {
+ this.updateInstanceTree(target, null);
}
btnAddTarget.setEnabled(false);
}
@@ -813,7 +818,7 @@ public class MainDialog extends Dialog {
String name = target.getName();
String lastPath = currentPath;
currentPath=currentPath+"/"+name;
-
+
if (busMode) {
if (!target.isSystem() && !cmbBusses.getText().equals("NONE")) {
if (target.isBusHidden(cmbBusses.getText())) {
@@ -863,6 +868,7 @@ public class MainDialog extends Dialog {
treeitem = new TreeItem(parentItem, SWT.VIRTUAL | SWT.BORDER);
}
}
+
treeitem.setText(name);
treeitem.setData(target);
@@ -894,6 +900,8 @@ public class MainDialog extends Dialog {
}
public void refreshConnections() {
+ this.source=null;
+ this.dest=null;
listBusses.removeAll();
if (cmbBusses == null) {
return;
@@ -1054,14 +1062,12 @@ public class MainDialog extends Dialog {
public void widgetSelected(SelectionEvent e) {
Target t = (Target) cmbCards.getData(cmbCards.getText());
targetForConnections = t;
- targetFound = false;
refreshInstanceTree();
refreshConnections();
}
});
cmbBusses.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- targetFound = false;
refreshInstanceTree();
refreshConnections();
}
@@ -1084,7 +1090,6 @@ public class MainDialog extends Dialog {
btnHideBusses.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- targetFound = false;
refreshInstanceTree();
refreshConnections();
}
diff --git a/src/com/ibm/ServerWizard2/SdrRecord.java b/src/com/ibm/ServerWizard2/SdrRecord.java
index 3182cc9..fe6370e 100644
--- a/src/com/ibm/ServerWizard2/SdrRecord.java
+++ b/src/com/ibm/ServerWizard2/SdrRecord.java
@@ -11,7 +11,7 @@ public class SdrRecord {
private Integer sensorType = 0x00;
private Target target = null;
private String entityName = "";
-
+
public String getAttributeValue() {
return String.format("0x%02x%02x,0x%02x", sensorType,entityId,sensorId);
}
@@ -43,12 +43,16 @@ public class SdrRecord {
return this.entityName;
}
- public void readXML(Element t) {
+ public void readXML(Element t) throws Exception {
name = SystemModel.getElement(t, "name");
- sensorId = Integer.decode(SystemModel.getElement(t, "sensor_id"));
- entityId = Integer.decode(SystemModel.getElement(t, "entity_id"));
- sensorType = Integer.decode(SystemModel.getElement(t, "sensor_type"));
- entityInstance = Integer.decode(SystemModel.getElement(t, "entity_instance"));
+ try {
+ sensorId = Integer.decode(SystemModel.getElement(t, "sensor_id"));
+ entityId = Integer.decode(SystemModel.getElement(t, "entity_id"));
+ sensorType = Integer.decode(SystemModel.getElement(t, "sensor_type"));
+ entityInstance = Integer.decode(SystemModel.getElement(t, "entity_instance"));
+ } catch (Exception e) {
+ throw new Exception("Invalid SDR entry for: "+name);
+ }
}
public String toString() {
return String.format("%30s (%3d) Entity Id=%3d; Entity Inst=%3d; Sensor Type=%3d",name,sensorId,entityId,entityInstance,sensorType);
diff --git a/src/com/ibm/ServerWizard2/ServerWizard2.java b/src/com/ibm/ServerWizard2/ServerWizard2.java
index 1545dfd..136d3fc 100644
--- a/src/com/ibm/ServerWizard2/ServerWizard2.java
+++ b/src/com/ibm/ServerWizard2/ServerWizard2.java
@@ -9,10 +9,10 @@ public class ServerWizard2 {
/**
* @param args
*/
-
- public static final String VERSION = "2.0.0";
- public final static Logger LOGGER = Logger.getLogger(ServerWizard2.class.getName());
-
+
+ public static final String VERSION = "2.1.0";
+ public final static Logger LOGGER = Logger.getLogger(ServerWizard2.class.getName());
+
public static void main(String[] args) {
LOGGER.setLevel(Level.CONFIG);
LOGGER.setUseParentHandlers(false);
diff --git a/src/com/ibm/ServerWizard2/SystemModel.java b/src/com/ibm/ServerWizard2/SystemModel.java
index b74a7b1..46fba20 100644
--- a/src/com/ibm/ServerWizard2/SystemModel.java
+++ b/src/com/ibm/ServerWizard2/SystemModel.java
@@ -52,7 +52,7 @@ public class SystemModel {
private HashMap<String, HashMap<String, Field>> globalSettings = new HashMap<String, HashMap<String, Field>>();
public String logData;
-
+
public void addPropertyChangeListener(PropertyChangeListener l) {
changes.addPropertyChangeListener(l);
}
@@ -76,7 +76,7 @@ public class SystemModel {
public Collection<Target> getTargetInstances() {
return targetInstances.values();
}
- public void importSdr(Target target, HashMap<Integer, HashMap<Integer, Vector<SdrRecord>>> sdrLookup,HashMap<String,Boolean>instCheck,String path) throws Exception {
+ public void importSdr(Target target, HashMap<Integer, HashMap<Integer, Vector<SdrRecord>>> sdrLookup,HashMap<String,Boolean>instCheck,String path) throws Exception {
if (target==null) {
for (Target t : this.rootTargets) {
this.importSdr(t,sdrLookup,instCheck,"/");
@@ -88,7 +88,7 @@ public class SystemModel {
if (entityInst==-1) { entityInst=0; } //units have special position of -1 to maintain assigned name
String instPath = path+target.getName();
HashMap<String,Field> inst = this.globalSettings.get(instPath);
-
+
if (inst!=null) {
Field instStr=inst.get("IPMI_INSTANCE");
if (instStr!=null && instStr.value!=null) {
@@ -106,12 +106,13 @@ public class SystemModel {
instCheck.put(key,true);
}
String ids[] = strEntityId.split(",");
-
+
String ipmiAttr[] = new String[16];
for (int i=0;i<16;i++) {
ipmiAttr[i]="0xFFFF,0xFF";
}
- int i=0;
+ //int i=0;
+ String nameStr="";
for (String id : ids) {
Integer entityId = Integer.decode(id);
if (entityId>0) {
@@ -134,19 +135,27 @@ public class SystemModel {
}
String apssStr="";
String sep=",";
- for (i=0;i<16;i++) {
+ for (int i=0;i<16;i++) {
if (i==15) { sep=""; }
apssStr=apssStr+String.format("0x%02X", apss[i])+sep;
}
this.setGlobalSetting(instPath, "ADC_CHANNEL_SENSOR_NUMBERS",apssStr);
- } else {
+ } else {
Vector<SdrRecord> sdrs = sdrMap.get(entityInst);
if (sdrs!=null) {
+ int i=0;
for (SdrRecord sdr:sdrs ) {
String msg = "IMPORT MATCH: "+target.getName()+"; "+sdr.toString();
+ nameStr=nameStr+sdr.getName()+",";
ServerWizard2.LOGGER.info(msg);
this.logData=this.logData+msg+"\n";
+ if (i>15) {
+ msg="ERROR: There are more than 16 sensors defined for: "+target.getName()+":"+entityInst;
+ ServerWizard2.LOGGER.severe(msg);
+ throw new Exception(msg);
+ }
ipmiAttr[i]=sdr.getAttributeValue();
+ i++;
}
} else {
String msg = ">>IMPORT ERROR: "+target.getName()+"; Entity ID: "+entityId+"; Entity Inst: "+entityInst+" not found in SDR";
@@ -160,16 +169,17 @@ public class SystemModel {
this.logData=this.logData+msg+"\n";
}
}
- i++;
+ //i++;
}
String ipmiStr="";
String sep=",";
Arrays.sort(ipmiAttr);
- for (i=0;i<16;i++) {
+ for (int i=0;i<16;i++) {
if (i==15) { sep=""; }
ipmiStr=ipmiStr+ipmiAttr[i]+sep;
}
this.setGlobalSetting(instPath, "IPMI_SENSORS",ipmiStr);
+ this.setGlobalSetting(instPath, "IPMI_NAME",nameStr);
}
path=path+target.getName()+"/";
for (String child : target.getChildren()) {
OpenPOWER on IntegriCloud