From: <ju...@us...> - 2007-05-14 15:40:20
|
Revision: 4138 http://svn.sourceforge.net/smartfrog/?rev=4138&view=rev Author: julgui Date: 2007-05-14 08:40:18 -0700 (Mon, 14 May 2007) Log Message: ----------- Adding tag browsing to management console. SFOS-130 Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2007-05-14 15:10:27 UTC (rev 4137) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2007-05-14 15:40:18 UTC (rev 4138) @@ -345,14 +345,12 @@ *@return The attributes value */ public Object[][] getAttributes() { - String[][] empty = { - { "", "" } - }; + //Attribute,value,tag + String[][] empty = { { "", "","" } }; try { Context context = null; - if (entry instanceof Prim){ context = ((Prim) entry).sfContext(); } else if (entry instanceof ComponentDescription){ @@ -362,27 +360,33 @@ } String name = ""; Object value = null; + String tags =""; String solvedValue = null; - Object[][] data = new Object[this.sizeAttributes()][2]; + Object[][] data = new Object[this.sizeAttributes()][3]; int index = 0; for (Enumeration e = context.keys(); e.hasMoreElements();) { try { name = ""; value = null; + tags =""; name = e.nextElement().toString(); value = context.get(name); + tags = context.sfGetTags(name).toString(); if (!isChild(value)) { try { value = ContextImpl.getBasicValueFor(value); - } catch (Exception ex1) { /*ignore*/ } + } catch (Exception ex1) { if (sfLog().isIgnoreEnabled()) sfLog().ignore(ex1);/*ignore*/ } + try { data[index][0] = name; data[index][1] = value; + data[index][2] = tags; } catch (Exception ex) { if (sfLog().isErrorEnabled()) sfLog().error("sfManagementConsole.deployEntry.getAttributes: error reading "+name+" >"+ex.getMessage()); data[index][0] = name; data[index][1] = "Error:"+ex.toString(); + data[index][2] = tags; index++; throw ex; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java 2007-05-14 15:10:27 UTC (rev 4137) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployTreePanel.java 2007-05-14 15:40:18 UTC (rev 4138) @@ -36,8 +36,10 @@ import java.io.PrintWriter; import java.io.IOException; import java.util.Vector; +import java.util.Set; import org.smartfrog.sfcore.common.ContextImpl; +import org.smartfrog.sfcore.common.SmartFrogContextException; import org.smartfrog.sfcore.logging.LogSF; import org.smartfrog.sfcore.logging.LogFactory; import org.smartfrog.services.display.FontSize; @@ -248,7 +250,7 @@ if (treeNode instanceof DeployEntry) { //System.out.println("TreeNode: "+treeNode); Object[][] data = ((DeployEntry) treeNode).getAttributes(); - String[] title = { "Attribute", "Value" }; + String[] title = { "Attribute", "Value","Tag(s)" }; table.setModel(new DefaultTableModel(data, title)); this.completeName.setText (((DeployEntry) treeNode).getDN()); @@ -276,9 +278,9 @@ public void refresh() { this.jTextArea1.setText(""); this.completeName.setText(" "); - String[] title = { "Attribute", "Value" }; + String[] title = { "Attribute", "Value", "Tag(s)" }; Object[][] data = { - { " ", " " } + { " ", " ","" } }; this.table.setModel(new DefaultTableModel(data, title)); updateTable(); @@ -318,7 +320,7 @@ int[] rows = new int[selectedRows.size()]; int index = 0; for (int i = 0; i < selectedRows.size();) { - System.out.println("Selected: i " + i + " - " + ((Integer) selectedRows.elementAt(i)).intValue()); + //System.out.println("Selected: i " + i + " - " + ((Integer) selectedRows.elementAt(i)).intValue()); rows[index++] = ((Integer) selectedRows.elementAt(i)).intValue(); } systemViewTree.setSelectionRows(rows); @@ -393,10 +395,12 @@ */ void resolveAttrib(Object attribName) { Object value; + String tags=""; StringBuffer solvedValue = new StringBuffer(); try { Object node = getNode(); value = sfResolveHere(attribName, node); + tags = sfGetTags(attribName, node).toString(); String solvedValueClass = "class not found"; String stackTrace = null; try { @@ -426,6 +430,7 @@ String tempString = ""; StringBuffer text = new StringBuffer(); text.append("* Attribute: "+attribName); + text.append("\n * Tags: "+tags); text.append("\n * Value: "); tempString = value.toString(); try { @@ -528,6 +533,24 @@ } /** + * Get tags for an attribute + * @param attribName attribute name + * @param node Node + * @return Set Tags + * @throws SmartFrogContextException error in resolving + * @throws RemoteException in case of remote/network error + */ + private Set sfGetTags(Object attribName, Object node) throws SmartFrogContextException, RemoteException { + Set tags=null; + if (node instanceof Prim){ + tags = ((Prim)node).sfGetTags(attribName); + } else if (node instanceof ComponentDescription){ + tags = ((ComponentDescription)node).sfGetTags(attribName); + } + return tags; + } + + /** * Log for this class * @return */ Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java 2007-05-14 15:10:27 UTC (rev 4137) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/NewAttributeDialog.java 2007-05-14 15:40:18 UTC (rev 4138) @@ -31,6 +31,8 @@ import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.logging.LogSF; import org.smartfrog.sfcore.logging.LogFactory; +import org.smartfrog.sfcore.common.ContextImpl; + import javax.swing.*; import java.awt.*; import java.io.StringWriter; @@ -64,33 +66,9 @@ private GridBagLayout gridBagLayout1 = new GridBagLayout(); /** Set of attributes. */ private Object[] attribute = null; - /** Component types. */ - private String[] componentTypes = {"AnyValue"}; + JLabel jLabel1 = new JLabel(); - /** Integer value for string. */ - static final int STRING = 8; - /** Integer value for integer. */ - static final int INTEGER = 1; - /** Integer value for boolean. */ - static final int BOOLEAN = 2; - /** Integer value for component description. */ - static final int COMPONENT_DESCRIPTION = 3; - /** Integer value for reference. */ - static final int REFERENCE = 4; - /** Integer value for long. */ - static final int LONG = 5; - /** Integer value for float. */ - static final int FLOAT = 6; - /** Integer value for double. */ - static final int DOUBLE = 7; - /** Integer value for PRIMVALUE. */ - static final int ANYVALUE = 0; - - //final int VECTOR = 3; - private JComboBox TypejComboBox = new JComboBox(componentTypes); - JLabel jLabel1 = new JLabel(); - /** * Constructs NewAttributeDialog with frame, title , modal and set of * attributes. @@ -115,7 +93,7 @@ } if (attribute[1] != null) { - String value = attribute[1].toString(); + String value = ContextImpl.getBasicValueFor(attribute[1]); if (attribute[1] instanceof ComponentDescription) { StringWriter sw = new StringWriter(); try { @@ -134,9 +112,6 @@ } } - // public Object[] NewAttributeDialog() { - // this(null, "", false); - // } /** * Initializes the UI. * @throws Exception if there is any error during initialization @@ -206,9 +181,7 @@ if ((this.NamejTextField.getText() != null) && (!this.NamejTextField.getText().equals(""))) { attribute[0] = this.NamejTextField.getText(); - attribute[1] = this.createValueObject(this.TypejComboBox. - getSelectedIndex(),(String) this.ValuejTextArea. - getText()); + attribute[1] = parseValue(ValuejTextArea.getText(),"sf"); } else { attribute[0] = null; attribute[1] = null; @@ -218,74 +191,6 @@ } /** - * Creates object from type and string value. - * @param type of the object - * @param valueStr value in string - * @return the object created using type and value - */ - Object createValueObject(int type, String valueStr) { - try { - switch (type) { - case ANYVALUE: - return parseValue(valueStr,"sf"); - case STRING: - return new String(valueStr); - - case INTEGER: - return Integer.valueOf(valueStr); - - case BOOLEAN: - return Boolean.valueOf(valueStr); - - case COMPONENT_DESCRIPTION: - return parsePhase("raw", valueStr, "sf"); - - case REFERENCE: - try { - return Reference.fromString(valueStr); - } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error (ex); - return null; - } - - case LONG: - return Long.valueOf(valueStr); - - case FLOAT: - return Float.valueOf(valueStr); - case DOUBLE: - return Double.valueOf(valueStr); - } - } catch (Exception ex) { - if (sfLog().isErrorEnabled()) sfLog().error (ex); - } - - return null; - } - /** - * Selects the combo box - * @param value of object - */ - void selectComboIndex(Object value) { - if (value instanceof String) { - this.TypejComboBox.setSelectedIndex(STRING); - } else if ((value instanceof Integer)) { - this.TypejComboBox.setSelectedIndex(INTEGER); - } else if ((value instanceof Boolean)) { - this.TypejComboBox.setSelectedIndex(BOOLEAN); - } else if ((value instanceof ComponentDescription)) { - this.TypejComboBox.setSelectedIndex(COMPONENT_DESCRIPTION); - } else if ((value instanceof Reference)) { - this.TypejComboBox.setSelectedIndex(REFERENCE); - } else if ((value instanceof Long)) { - this.TypejComboBox.setSelectedIndex(LONG); - } else if ((value instanceof Float)) { - this.TypejComboBox.setSelectedIndex(FLOAT); - } else if ((value instanceof Double)) { - this.TypejComboBox.setSelectedIndex(DOUBLE); - } - } - /** * Parses the phases. * @param phase parsing phase * @param textToParse text to parse This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |