[Ejtools-cvs] CVS: applications/management/src/main/net/sourceforge/ejtools/management/model Node.ja
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-04-22 18:00:28
|
Update of /cvsroot/ejtools/applications/management/src/main/net/sourceforge/ejtools/management/model In directory usw-pr-cvs1:/tmp/cvs-serv29989/management/src/main/net/sourceforge/ejtools/management/model Added Files: Node.java Log Message: Initial Import --- NEW FILE: Node.java --- package net.sourceforge.ejtools.management.model; import java.awt.*; import java.beans.*; import java.beans.beancontext.*; import java.util.*; import javax.naming.*; import javax.swing.*; import net.sourceforge.ejtools.awt.GenericCustomizer; import net.sourceforge.ejtools.util.*; /** * Description of the Class * * @author letiembl * @created 13 décembre 2001 */ public abstract class Node extends BeanContextServicesSupport implements BeanContextChildComponentProxy { /** Description of the Field */ protected transient Customizer c = null; /** Description of the Field */ protected String name = "undefined"; /** Constructor for the Node object */ public Node() { super(); } /** * Gets the component attribute of the Node object * * @return The component value */ public Component getComponent() { if (c == null) { c = new GenericCustomizer(true, this); } return (Component) c; } /** * Gets the name attribute of the Node object * * @return The name value */ public String getName() { return this.name; } /** * Getter for the service attribute * * @param child Description of Parameter * @param requestor Description of Parameter * @param serviceClass Description of Parameter * @param serviceSelector Description of Parameter * @param bcsrl Description of Parameter * @return The value * @exception TooManyListenersException Description of Exception */ public Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException { Object service = super.getService(child, requestor, serviceClass, serviceSelector, bcsrl); // If the service requested is not provided by this BeanContext, try the parent if (service == null) { BeanContextServices bcs = null; try { bcs = (BeanContextServices) getBeanContext(); } catch (ClassCastException cce) { return null; } return bcs.getService(this, requestor, serviceClass, serviceSelector, bcsrl); } return service; } /** * Description of the Method * * @return Description of the Returned Value */ public Iterator iterator() { return Sort.sortByClassAndName(super.iterator()); } /** * Description of the Method * * @return Description of the Returned Value */ public String toString() { return (name == null || "".equals(name)) ? "Default" : name; } /** * Description of the Method * * @param collection Description of Parameter */ protected void createHierarchy(Collection collection) { Vector copy = new Vector(collection); // Create the hierachy for (int i = 0; i < copy.size(); i++) { Resource resource = (Resource) copy.elementAt(i); String search = resource.getJ2EEType() + "=" + resource.getName(); System.out.println("Filter with " + search + " over " + copy.size()); for (int j = 0; j < copy.size(); j++) { if (i != j) { Resource other = (Resource) copy.elementAt(j); String canonical = other.getCanonicalName(); if (canonical.indexOf(search) >= 0) { //copy.remove(other); collection.remove(other); resource.add(other); } } } } // Recurse through all children which have children Iterator iterator = collection.iterator(); while (iterator.hasNext()) { Resource resource = (Resource) iterator.next(); if (!resource.isEmpty()) { resource.createHierarchy(resource); } } } /** * Setter for the name attribute * * @param name The new value */ protected void setName(String name) { this.name = name; } } |