From: <ju...@us...> - 2007-06-08 17:40:22
|
Revision: 4276 http://svn.sourceforge.net/smartfrog/?rev=4276&view=rev Author: julgui Date: 2007-06-08 10:40:19 -0700 (Fri, 08 Jun 2007) Log Message: ----------- SFOS-155 Modified console to edit tags in tree nodes. Modified Tags api to allow modification of tags in container using NULL values (not final). Also, reverting changes in Reference.java Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTags.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Tags.java trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/Reference.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/DeployEntry.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -558,7 +558,7 @@ */ public String toString() { Object tags = getEntryTags(); - if ((tags!=null)&&(!tags.toString().equals(""))){ + if ((tags!=null)&&(!tags.toString().equals(""))&&(!tags.toString().equals("[]"))){ return getRDN()+" "+getEntryTags(); } return getRDN(); Modified: trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/services/management/PopUpTree.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -34,6 +34,7 @@ import java.rmi.RemoteException; import java.util.ArrayList; +import java.util.Set; import org.smartfrog.sfcore.componentdescription.ComponentDescription; @@ -46,6 +47,7 @@ import org.smartfrog.sfcore.common.*; import org.smartfrog.sfcore.processcompound.SFProcess; import org.smartfrog.sfcore.processcompound.ProcessCompound; +import org.smartfrog.sfcore.parser.SFParser; /** @@ -88,6 +90,9 @@ /** Item for Tree popup menu - add ScriptingPanel. */ JMenuItem menuItemAddScriptingPanel = new JMenuItem(); + /** Item for Tree popup menu - edit Tags. */ + JMenuItem menuItemEditTags = new JMenuItem(); + /** * Constructs PopUpTree object */ @@ -112,6 +117,7 @@ menuItemParentageChanged.setText("sfParentageChanged()"); menuItemAddScriptingPanel.setText("Add Scripting Panel"); menuItemIntrospector.setText("Instrospector"); + menuItemEditTags.setText("Edit Tags"); // Tree: options // popupTree.add(menuItemAddAttribute); @@ -127,6 +133,7 @@ popupTree.add(menuItemParentageChanged); popupTree.add(menuItemAddScriptingPanel); popupTree.add(menuItemIntrospector); + popupTree.add(menuItemEditTags); // Add action listeners for tree popup menuItemAddAttribute.addActionListener(this); @@ -143,6 +150,7 @@ menuItemParentageChanged.addActionListener(this); menuItemAddScriptingPanel.addActionListener(this); menuItemIntrospector.addActionListener(this); + menuItemEditTags.addActionListener(this); } /** @@ -176,8 +184,9 @@ menuItemParentageChanged.setVisible(true); menuItemAddScriptingPanel.setVisible(true); menuItemIntrospector.setVisible(true); + menuItemEditTags.setVisible(true); }else if (getNode()instanceof ComponentDescription){ - menuItemRemoveAttribute.setVisible(true); + menuItemRemoveAttribute.setVisible(true); menuItemDetach.setVisible(false); menuItemTerminateNormal.setVisible(false); menuItemTerminateAbnormal.setVisible(false); @@ -186,6 +195,7 @@ menuItemParentageChanged.setVisible(false); menuItemAddScriptingPanel.setVisible(true); menuItemIntrospector.setVisible(true); + menuItemEditTags.setVisible(true); } popupTree.show(comp, x, y); this.parent = parent; @@ -227,6 +237,9 @@ } else if (source == menuItemDetach) { detach(node); // Entry selected in the tree + } else if (source == menuItemEditTags) { + editTags(node); + // Entry selected in the tree } else if (source == menuItemParentageChanged) { if (node instanceof Prim){ try { @@ -513,7 +526,7 @@ org.smartfrog.services.management.DeployMgnt.detach((Prim) obj); parent.refresh(); } catch (Exception ex){ - String msg = "Problem when trying to Detach and Terminate '"+name; + String msg = "Problem when trying to Detach and Terminate "+name; if (sfLog().isErrorEnabled()) sfLog().error (msg); WindowUtilities.showError(this, msg +"'. \n"+ex.toString()); } @@ -522,8 +535,49 @@ } } + void editTags (Object obj) { + //System.out.println("Detatching: "+obj.toString()); + if (obj instanceof Prim) { + String name =""; + try { + name = ((Prim)obj).sfCompleteName().toString(); + Object tags = ((Prim)obj).sfGetTags(null); + tags = JOptionPane.showInputDialog(this,"Edit Tags",tags); + Set newTags = (Set)parseTags(tags.toString(),"sf"); + ((Prim)obj).sfSetTags(null, newTags); + } catch (Exception ex){ + String msg = "Problem when trying to edit tags on "+name; + if (sfLog().isErrorEnabled()) sfLog().error (msg); + WindowUtilities.showError(this, msg +"'. \n"+ex.toString()); + } + // Refresh Console. + // To do: automatic Refresh ;-) + } else if (obj instanceof ComponentDescription){ + } else { + WindowUtilities.showError(this, "Error when editing tags on object: "+obj.toString()+"\n "+obj.getClass().getName()); + } + } + + + /** + * Parse + * @param textToParse text to be parsed + * @param language language + * @return Object + */ + public Object parseTags(String textToParse, String language) { + try { + SFParser parser = new SFParser(language); + return parser.sfParseTags( textToParse); + } catch (Throwable ex) { + if (sfLog().isErrorEnabled()) sfLog().error (ex); + } + return null; + } + + /** * Prepares option dialog box * *@param title title displayed on the dialog box Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTags.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTags.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/RemoteTags.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -16,7 +16,7 @@ * Set the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tags a set of tags * * @throws SmartFrogException the attribute does not exist; @@ -27,7 +27,7 @@ * Get the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @return the set of tags * * @throws SmartFrogException the attribute does not exist; @@ -37,7 +37,7 @@ /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tag a tag to add to the set * * @throws SmartFrogException the attribute does not exist; @@ -47,7 +47,7 @@ /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tag a tag to remove from the set * * @throws SmartFrogException the attribute does not exist; @@ -58,7 +58,7 @@ /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tags a set of tags to add to the set * @throws SmartFrogException * the attribute does not exist; @@ -68,7 +68,7 @@ /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tags a set of tags to remove from the set * @throws SmartFrogException * the attribute does not exist; @@ -78,7 +78,7 @@ /** * Return whether or not a tag is in the list of tags for an attribute * - * @param name the name of the attribute + * @param name the name of the attribute. Use "NULL" to refer to container's tags * @param tag the tag to chack * * @return whether or not the attribute has that tag Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Tags.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Tags.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Tags.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -14,7 +14,7 @@ * Set the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tags a set of tags * * @throws SmartFrogException the attribute does not exist; @@ -25,7 +25,7 @@ * Get the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @return the set of tags * * @throws SmartFrogException the attribute does not exist; @@ -35,7 +35,7 @@ /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tag a tag to add to the set * * @throws SmartFrogContextException the attribute does not exist; @@ -45,7 +45,7 @@ /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tag a tag to remove from the set * * @throws SmartFrogException the attribute does not exist; @@ -56,7 +56,7 @@ /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tags a set of tags to add to the set * @throws SmartFrogException * the attribute does not exist; @@ -66,7 +66,7 @@ /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to container's tags * @param tags a set of tags to remove from the set * @throws SmartFrogException * the attribute does not exist; @@ -76,7 +76,7 @@ /** * Return an iterator over the tags for an attribute * - * @param name the name of the attribute + * @param name the name of the attribute. Throws exception if name is NULL * @return an iterator over the tags * * @throws SmartFrogException the attribute does not exist; @@ -86,7 +86,7 @@ /** * Return whether or not a tag is in the list of tags for an attribute * - * @param name the name of the attribute + * @param name the name of the attribute. Use "NULL" to refer to container's tags * @param tag the tag to chack * * @return whether or not the attribute has that tag Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -1264,99 +1264,190 @@ * Set the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tags * @param tags a set of tags * @throws SmartFrogException * the attribute does not exist; */ public void sfSetTags(Object name, Set tags) throws SmartFrogContextException { - sfContext.sfSetTags(name, tags); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfSetTags(key,tags); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfSetTags(key,tags); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + sfContext.sfSetTags(name, tags); } /** * Get the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tags * @return the set of tags * @throws SmartFrogException * the attribute does not exist; */ public Set sfGetTags(Object name) throws SmartFrogContextException { - return sfContext.sfGetTags(name); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + return parent.sfGetTags(key); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + return primParent.sfGetTags(key); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + return sfContext.sfGetTags(name); } /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tag * @param tag a tag to add to the set * @throws SmartFrogException * the attribute does not exist; */ public void sfAddTag(Object name, String tag) throws SmartFrogContextException { - sfContext.sfAddTag(name, tag); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfAddTag(key,tag); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfAddTag(key,tag); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + sfContext.sfAddTag(name, tag); } /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tag * @param tag a tag to remove from the set * @throws SmartFrogException * the attribute does not exist; */ public void sfRemoveTag(Object name, String tag) throws SmartFrogContextException { - sfContext.sfRemoveTag(name, tag); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfRemoveTag(key,tag); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfRemoveTag(key,tag); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + sfContext.sfRemoveTag(name, tag); } /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tags * @param tags a set of tags to add to the set * @throws SmartFrogException * the attribute does not exist; */ public void sfAddTags(Object name, Set tags) throws SmartFrogContextException { - sfContext.sfAddTags(name, tags); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfAddTags(key,tags); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfAddTags(key,tags); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + sfContext.sfAddTags(name, tags); } /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tag * @param tags a set of tags to remove from the set * @throws SmartFrogException * the attribute does not exist; */ public void sfRemoveTags(Object name, Set tags) throws SmartFrogContextException { - sfContext.sfRemoveTags(name, tags); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + parent.sfRemoveTags(key,tags); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + primParent.sfRemoveTags(key,tags); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + sfContext.sfRemoveTags(name, tags); } /** * Return an iterator over the tags for an attribute * - * @param name the name of the attribute + * @param name the name of the attribute. Null throws an exception * @return an iterator over the tags * @throws SmartFrogException * the attribute does not exist; */ public Iterator sfTags(Object name) throws SmartFrogContextException { - return sfContext.sfTags(name); + return sfContext.sfTags(name); } /** * Return whether or not a tag is in the list of tags for an attribute * - * @param name the name of the attribute + * @param name the name of the attribute. Use "NULL" to refer to this object's tag * @param tag the tag to chack * @return whether or not the attribute has that tag * @throws SmartFrogException * the attribute does not exist */ public boolean sfContainsTag(Object name, String tag) throws SmartFrogContextException { - return sfContext.sfContainsTag(name, tag); + if (name==null){ + if (parent!=null) { + Object key = parent.sfAttributeKeyFor(this); + return parent.sfContainsTag(key, tag); + }else { + try { + Object key = primParent.sfAttributeKeyFor(this); + return primParent.sfContainsTag(key, tag); + } catch (RemoteException e) { + throw (SmartFrogContextException)SmartFrogContextException.forward(e); + } + } + } else + return sfContext.sfContainsTag(name, tag); } /** Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -1707,16 +1707,22 @@ // implementation of the RemoteTags interface + + /** * Set the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tags. * @param tags a set of tags * * @throws SmartFrogException the attribute does not exist; */ public void sfSetTags(Object name, Set tags) throws SmartFrogContextException, RemoteException { + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfSetTags(key,tags); + } else sfContext.sfSetTags(name, tags); } @@ -1724,87 +1730,111 @@ * Get the TAGS for an attribute. TAGS are simply uninterpreted strings associated * with each attribute. * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tags * @return the set of tags * * @throws SmartFrogException the attribute does not exist; */ public Set sfGetTags(Object name) throws SmartFrogContextException, RemoteException { - return sfContext.sfGetTags(name); + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + return sfParent.sfGetTags(key); + } else + return sfContext.sfGetTags(name); } /** * add a tag to the tag set of an attribute * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tag * @param tag a tag to add to the set * * @throws SmartFrogException the attribute does not exist; */ public void sfAddTag(Object name, String tag) throws SmartFrogContextException, RemoteException { - sfContext.sfAddTag(name,tag); + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfAddTag(key,tag); + } else + sfContext.sfAddTag(name,tag); } /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tag * @param tag a tag to remove from the set * * @throws SmartFrogException the attribute does not exist; * */ public void sfRemoveTag(Object name, String tag) throws SmartFrogContextException, RemoteException { - sfContext.sfRemoveTag(name, tag); + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfRemoveTag(key,tag); + } else + sfContext.sfRemoveTag(name, tag); } /** * add a tag to the tag set of an attribute * * @param name attribute key for tags - * @param tags a set of tags to add to the set + * @param tags a set of tags to add to the set. Use "NULL" to refer to this object's tags * @throws SmartFrogException * the attribute does not exist; */ public void sfAddTags(Object name, Set tags) throws SmartFrogContextException, RemoteException { - sfContext.sfAddTags(name, tags); + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfAddTags(key,tags); + } else + sfContext.sfAddTags(name, tags); } /** * remove a tag from the tag set of an attribute if it exists * - * @param name attribute key for tags + * @param name attribute key for tags. Use "NULL" to refer to this object's tags * @param tags a set of tags to remove from the set * @throws SmartFrogException * the attribute does not exist; */ public void sfRemoveTags(Object name, Set tags) throws SmartFrogContextException, RemoteException { - sfContext.sfRemoveTags(name, tags); + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + sfParent.sfRemoveTags(key,tags); + } else + sfContext.sfRemoveTags(name, tags); } /** * Return an iterator over the tags for an attribute - not part of RemoteTags, but is part of Tags * - * @param name the name of the attribute + * @param name the name of the attribute. If name is null then it throws exception * @return an iterator over the tags * * @throws SmartFrogException the attribute does not exist; */ public Iterator sfTags(Object name) throws SmartFrogException { - return sfContext.sfTags(name); + return sfContext.sfTags(name); } /** * Return whether or not a tag is in the list of tags for an attribute * - * @param name the name of the attribute + * @param name the name of the attribute. Use "NULL" to refer to this object's tags * @param tag the tag to chack * * @return whether or not the attribute has that tag * @throws SmartFrogException the attribute does not exist */ public boolean sfContainsTag(Object name, String tag) throws SmartFrogContextException, RemoteException { - return sfContext.sfContainsTag(name, tag); + if (name==null){ + Object key = sfParent.sfAttributeKeyFor(this); + return sfParent.sfContainsTag(key,tag); + } else + return sfContext.sfContainsTag(name, tag); } } Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/Reference.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/Reference.java 2007-06-08 16:59:33 UTC (rev 4275) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/reference/Reference.java 2007-06-08 17:40:19 UTC (rev 4276) @@ -79,16 +79,16 @@ /** - * Constructs a reference with a single attrib reference part from a String. + * Constructs a reference with a single reference part from a String. * - * @param attributeName part to be put in reference + * @param referencePart part to be put in reference */ - public Reference(Object attributeName) { - this(ReferencePart.attrib(attributeName)); + public Reference(Object referencePart) { + this(ReferencePart.here(referencePart)); } /** - * Constructs a reference with a single attrib reference part from a String + * Constructs a reference with a single reference part from a String * or from a string in cannonical form using the parser. * * @param refString to be put/used in reference @@ -97,12 +97,11 @@ */ public Reference(String refString, boolean parse) throws SmartFrogResolutionException{ if (!parse) { - ref.addElement(ReferencePart.attrib(refString)); + ref.addElement(ReferencePart.here(refString)); } else { ref = fromString(refString).ref; } } - /** * Constructs a reference with a single reference part. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |