[Ejtools-cvs] libraries/adwt/src/main/org/ejtools/adwt/util DefaultObjectIndexer.java,1.2,1.3 Defaul
Brought to you by:
letiemble
From: <let...@us...> - 2003-12-14 10:42:47
|
Update of /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/util In directory sc8-pr-cvs1:/tmp/cvs-serv19233/adwt/src/main/org/ejtools/adwt/util Modified Files: DefaultObjectIndexer.java DefaultObjectRenderer.java ObjectIndexer.java ObjectRenderer.java ObjectSearcher.java ObjectWrapper.java SearchableTreeModel.java Log Message: Add more javadocs. Add package.html files. Index: DefaultObjectIndexer.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/util/DefaultObjectIndexer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DefaultObjectIndexer.java 15 Sep 2003 22:37:14 -0000 1.2 --- DefaultObjectIndexer.java 13 Dec 2003 21:29:35 -0000 1.3 *************** *** 1,17 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! import java.util.Hashtable; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public class DefaultObjectIndexer extends Hashtable implements ObjectIndexer ! { ! } --- 1,17 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! import java.util.Hashtable; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public class DefaultObjectIndexer extends Hashtable implements ObjectIndexer ! { ! } Index: DefaultObjectRenderer.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/util/DefaultObjectRenderer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DefaultObjectRenderer.java 15 Sep 2003 22:37:14 -0000 1.2 --- DefaultObjectRenderer.java 13 Dec 2003 21:29:35 -0000 1.3 *************** *** 1,119 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! import java.awt.Image; ! import java.awt.Toolkit; ! import java.awt.image.ImageProducer; ! import java.io.IOException; ! import java.net.URL; ! import java.security.AccessController; ! import java.security.PrivilegedAction; ! import java.util.Hashtable; ! import java.util.Map; ! ! import javax.swing.Icon; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public class DefaultObjectRenderer implements ObjectRenderer ! { ! /** Description of the Field */ ! protected Map objects = new Hashtable(); ! ! ! /** ! * Gets the icon attribute of the DefaultObjectRenderer object ! * ! * @param o Description of the Parameter ! * @return The icon value ! */ ! public Icon getIcon(Object o) ! { ! return this.getObjectWrapper(o).getIcon(); ! } ! ! ! /** ! * Gets the label attribute of the DefaultObjectRenderer object ! * ! * @param o Description of the Parameter ! * @return The label value ! */ ! public String getLabel(Object o) ! { ! return this.getObjectWrapper(o).toString(); ! } ! ! ! /** ! * Gets the objectWrapper attribute of the DefaultObjectRenderer object ! * ! * @param o Description of the Parameter ! * @return The objectWrapper value ! */ ! protected ObjectWrapper getObjectWrapper(Object o) ! { ! ObjectWrapper wrapper = (ObjectWrapper) this.objects.get(o); ! if (wrapper == null) ! { ! wrapper = new ObjectWrapper(o); ! this.objects.put(o, wrapper); ! } ! return wrapper; ! } ! ! ! /** ! * Description of the Method ! * ! * @param resourceName Description of the Parameter ! * @return Description of the Return Value ! */ ! protected static Image loadImage(final String resourceName) ! { ! try ! { ! final Class c = DefaultObjectRenderer.class; ! ImageProducer ip = (ImageProducer) AccessController.doPrivileged( ! new PrivilegedAction() ! { ! public Object run() ! { ! URL url; ! if ((url = c.getResource(resourceName)) == null) ! { ! return null; ! } ! else ! { ! try ! { ! return url.getContent(); ! } ! catch (IOException ioe) ! { ! return null; ! } ! } ! } ! }); ! if (ip == null) ! { ! return null; ! } ! Toolkit tk = Toolkit.getDefaultToolkit(); ! return tk.createImage(ip); ! } ! catch (Exception ex) ! { ! return null; ! } ! } ! } --- 1,119 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! import java.awt.Image; ! import java.awt.Toolkit; ! import java.awt.image.ImageProducer; ! import java.io.IOException; ! import java.net.URL; ! import java.security.AccessController; ! import java.security.PrivilegedAction; ! import java.util.Hashtable; ! import java.util.Map; ! ! import javax.swing.Icon; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public class DefaultObjectRenderer implements ObjectRenderer ! { ! /** Description of the Field */ ! protected Map objects = new Hashtable(); ! ! ! /** ! * Gets the icon attribute of the DefaultObjectRenderer object ! * ! * @param o Description of the Parameter ! * @return The icon value ! */ ! public Icon getIcon(Object o) ! { ! return this.getObjectWrapper(o).getIcon(); ! } ! ! ! /** ! * Gets the label attribute of the DefaultObjectRenderer object ! * ! * @param o Description of the Parameter ! * @return The label value ! */ ! public String getLabel(Object o) ! { ! return this.getObjectWrapper(o).toString(); ! } ! ! ! /** ! * Gets the objectWrapper attribute of the DefaultObjectRenderer object ! * ! * @param o Description of the Parameter ! * @return The objectWrapper value ! */ ! protected ObjectWrapper getObjectWrapper(Object o) ! { ! ObjectWrapper wrapper = (ObjectWrapper) this.objects.get(o); ! if (wrapper == null) ! { ! wrapper = new ObjectWrapper(o); ! this.objects.put(o, wrapper); ! } ! return wrapper; ! } ! ! ! /** ! * Description of the Method ! * ! * @param resourceName Description of the Parameter ! * @return Description of the Return Value ! */ ! protected static Image loadImage(final String resourceName) ! { ! try ! { ! final Class c = DefaultObjectRenderer.class; ! ImageProducer ip = (ImageProducer) AccessController.doPrivileged( ! new PrivilegedAction() ! { ! public Object run() ! { ! URL url; ! if ((url = c.getResource(resourceName)) == null) ! { ! return null; ! } ! else ! { ! try ! { ! return url.getContent(); ! } ! catch (IOException ioe) ! { ! return null; ! } ! } ! } ! }); ! if (ip == null) ! { ! return null; ! } ! Toolkit tk = Toolkit.getDefaultToolkit(); ! return tk.createImage(ip); ! } ! catch (Exception ex) ! { ! return null; ! } ! } ! } Index: ObjectIndexer.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/util/ObjectIndexer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ObjectIndexer.java 15 Sep 2003 22:37:14 -0000 1.2 --- ObjectIndexer.java 13 Dec 2003 21:29:35 -0000 1.3 *************** *** 1,42 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface ObjectIndexer ! { ! /** ! * Description of the Method ! * ! * @param key Description of the Parameter ! * @param value Description of the Parameter ! * @return Description of the Return Value ! */ ! public Object put(Object key, Object value); ! ! ! /** ! * Description of the Method ! * ! * @param key Description of the Parameter ! * @return Description of the Return Value ! */ ! public Object remove(Object key); ! ! ! /** ! * Description of the Method ! * ! * @param key Description of the Parameter ! * @return Description of the Return Value ! */ ! public Object get(Object key); ! } --- 1,42 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface ObjectIndexer ! { ! /** ! * Description of the Method ! * ! * @param key Description of the Parameter ! * @param value Description of the Parameter ! * @return Description of the Return Value ! */ ! public Object put(Object key, Object value); ! ! ! /** ! * Description of the Method ! * ! * @param key Description of the Parameter ! * @return Description of the Return Value ! */ ! public Object remove(Object key); ! ! ! /** ! * Description of the Method ! * ! * @param key Description of the Parameter ! * @return Description of the Return Value ! */ ! public Object get(Object key); ! } Index: ObjectRenderer.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/util/ObjectRenderer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ObjectRenderer.java 15 Sep 2003 22:37:14 -0000 1.2 --- ObjectRenderer.java 13 Dec 2003 21:29:35 -0000 1.3 *************** *** 1,33 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! import javax.swing.Icon; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface ObjectRenderer ! { ! /** ! * Gets the icon attribute of the ObjectRenderer object ! * ! * @param o Description of the Parameter ! * @return The icon value ! */ ! public Icon getIcon(Object o); ! ! ! /** ! * Gets the label attribute of the ObjectRenderer object ! * ! * @param o Description of the Parameter ! * @return The label value ! */ ! public String getLabel(Object o); ! } --- 1,33 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! import javax.swing.Icon; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface ObjectRenderer ! { ! /** ! * Gets the icon attribute of the ObjectRenderer object ! * ! * @param o Description of the Parameter ! * @return The icon value ! */ ! public Icon getIcon(Object o); ! ! ! /** ! * Gets the label attribute of the ObjectRenderer object ! * ! * @param o Description of the Parameter ! * @return The label value ! */ ! public String getLabel(Object o); ! } Index: ObjectSearcher.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/util/ObjectSearcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ObjectSearcher.java 15 Sep 2003 22:37:14 -0000 1.1 --- ObjectSearcher.java 13 Dec 2003 21:29:35 -0000 1.2 *************** *** 1,31 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface ObjectSearcher ! { ! /** ! * Description of the Method ! * ! * @param o Description of the Parameter ! * @return Description of the Return Value ! */ ! public Object find(Object o); ! ! ! /** ! * Sets the indexer attribute of the ObjectSearcher object ! * ! * @param indexer The new indexer value ! */ ! public void setIndexer(ObjectIndexer indexer); ! } --- 1,31 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface ObjectSearcher ! { ! /** ! * Description of the Method ! * ! * @param o Description of the Parameter ! * @return Description of the Return Value ! */ ! public Object find(Object o); ! ! ! /** ! * Sets the indexer attribute of the ObjectSearcher object ! * ! * @param indexer The new indexer value ! */ ! public void setIndexer(ObjectIndexer indexer); ! } Index: ObjectWrapper.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/util/ObjectWrapper.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ObjectWrapper.java 15 Sep 2003 22:37:14 -0000 1.2 --- ObjectWrapper.java 13 Dec 2003 21:29:35 -0000 1.3 *************** *** 1,120 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! import java.awt.Component; ! import java.beans.BeanInfo; ! import java.beans.Introspector; ! import java.beans.beancontext.BeanContextChildComponentProxy; ! import java.beans.beancontext.BeanContextContainerProxy; ! import java.lang.reflect.Method; ! ! import javax.swing.Icon; ! import javax.swing.ImageIcon; ! import javax.swing.JLabel; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public class ObjectWrapper implements BeanContextChildComponentProxy ! { ! /** Description of the Field */ ! private Icon icon; ! /** Description of the Field */ ! private Object object; ! /** Description of the Field */ ! private String text; ! ! ! /** ! * Constructor for the ContextNode object ! * ! * @param object Description of the Parameter ! */ ! public ObjectWrapper(Object object) ! { ! this.object = object; ! try ! { ! BeanInfo beaninfo = Introspector.getBeanInfo(this.object.getClass()); ! if (beaninfo.getIcon(BeanInfo.ICON_COLOR_16x16) != null) ! { ! this.icon = new ImageIcon(beaninfo.getIcon(BeanInfo.ICON_COLOR_16x16)); ! } ! ! Method method = this.object.getClass().getMethod("toString", new Class[0]); ! if (method.getDeclaringClass().equals(Object.class)) ! { ! this.text = beaninfo.getBeanDescriptor().getDisplayName(); ! } ! } ! catch (Exception exception) ! { ! exception.printStackTrace(); ! } ! } ! ! ! /** ! * Gets the Component attribute of the ContextNode object ! * ! * @return The Component value ! */ ! public Component getComponent() ! { ! if (this.object instanceof Component) ! { ! return (Component) this.object; ! } ! if (this.object instanceof BeanContextContainerProxy) ! { ! return ((BeanContextContainerProxy) this.object).getContainer(); ! } ! if (this.object instanceof BeanContextChildComponentProxy) ! { ! return ((BeanContextChildComponentProxy) this.object).getComponent(); ! } ! else ! { ! return new JLabel("No GUI available for this service", 0); ! } ! } ! ! ! /** ! * Returns the icon. ! * ! * @return Icon ! */ ! public Icon getIcon() ! { ! return this.icon; ! } ! ! ! /** ! * Gets the UserObject attribute of the ContextNode object ! * ! * @return The UserObject value ! */ ! public Object getUserObject() ! { ! return this.object; ! } ! ! ! /** ! * Description of the Method ! * ! * @return Description of the Returned Value ! */ ! public String toString() ! { ! return this.text != null ? this.text : this.object.toString(); ! } ! } --- 1,120 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! import java.awt.Component; ! import java.beans.BeanInfo; ! import java.beans.Introspector; ! import java.beans.beancontext.BeanContextChildComponentProxy; ! import java.beans.beancontext.BeanContextContainerProxy; ! import java.lang.reflect.Method; ! ! import javax.swing.Icon; ! import javax.swing.ImageIcon; ! import javax.swing.JLabel; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public class ObjectWrapper implements BeanContextChildComponentProxy ! { ! /** Description of the Field */ ! private Icon icon; ! /** Description of the Field */ ! private Object object; ! /** Description of the Field */ ! private String text; ! ! ! /** ! * Constructor for the ContextNode object ! * ! * @param object Description of the Parameter ! */ ! public ObjectWrapper(Object object) ! { ! this.object = object; ! try ! { ! BeanInfo beaninfo = Introspector.getBeanInfo(this.object.getClass()); ! if (beaninfo.getIcon(BeanInfo.ICON_COLOR_16x16) != null) ! { ! this.icon = new ImageIcon(beaninfo.getIcon(BeanInfo.ICON_COLOR_16x16)); ! } ! ! Method method = this.object.getClass().getMethod("toString", new Class[0]); ! if (method.getDeclaringClass().equals(Object.class)) ! { ! this.text = beaninfo.getBeanDescriptor().getDisplayName(); ! } ! } ! catch (Exception exception) ! { ! exception.printStackTrace(); ! } ! } ! ! ! /** ! * Gets the Component attribute of the ContextNode object ! * ! * @return The Component value ! */ ! public Component getComponent() ! { ! if (this.object instanceof Component) ! { ! return (Component) this.object; ! } ! if (this.object instanceof BeanContextContainerProxy) ! { ! return ((BeanContextContainerProxy) this.object).getContainer(); ! } ! if (this.object instanceof BeanContextChildComponentProxy) ! { ! return ((BeanContextChildComponentProxy) this.object).getComponent(); ! } ! else ! { ! return new JLabel("No GUI available for this service", 0); ! } ! } ! ! ! /** ! * Returns the icon. ! * ! * @return Icon ! */ ! public Icon getIcon() ! { ! return this.icon; ! } ! ! ! /** ! * Gets the UserObject attribute of the ContextNode object ! * ! * @return The UserObject value ! */ ! public Object getUserObject() ! { ! return this.object; ! } ! ! ! /** ! * Description of the Method ! * ! * @return Description of the Returned Value ! */ ! public String toString() ! { ! return this.text != null ? this.text : this.object.toString(); ! } ! } Index: SearchableTreeModel.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/util/SearchableTreeModel.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SearchableTreeModel.java 15 Sep 2003 22:37:14 -0000 1.1 --- SearchableTreeModel.java 13 Dec 2003 21:29:35 -0000 1.2 *************** *** 1,19 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! import javax.swing.tree.TreeModel; ! ! /** ! * Description of the Interface ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface SearchableTreeModel extends TreeModel, ObjectSearcher ! { ! } --- 1,19 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.util; ! ! import javax.swing.tree.TreeModel; ! ! /** ! * Description of the Interface ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface SearchableTreeModel extends TreeModel, ObjectSearcher ! { ! } |