ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meta...@locus.apache.org
Subject cvs commit: jakarta-ant/src/antidote/org/apache/tools/ant/gui AntTreeCellRenderer.java ResourceManager.java
Date Thu, 16 Nov 2000 21:46:29 GMT
metasim     00/11/16 13:46:29

  Modified:    src/antidote/org/apache/tools/ant/gui
                        AntTreeCellRenderer.java ResourceManager.java
  Log:
  Added icons to project tree view.
  
  Revision  Changes    Path
  1.2       +20 -3     jakarta-ant/src/antidote/org/apache/tools/ant/gui/AntTreeCellRenderer.java
  
  Index: AntTreeCellRenderer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/AntTreeCellRenderer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AntTreeCellRenderer.java	2000/11/09 23:14:10	1.1
  +++ AntTreeCellRenderer.java	2000/11/16 21:46:29	1.2
  @@ -56,12 +56,15 @@
   import org.apache.tools.ant.gui.acs.ACSElement;
   import javax.swing.tree.DefaultTreeCellRenderer;
   import javax.swing.JTree;
  +import javax.swing.ImageIcon;
   import java.awt.Component;
  +import java.awt.Image;
  +import java.beans.*;
   
   /**
    * Cell renderer for displaying the Ant XML file in a JTree.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   public class AntTreeCellRenderer extends DefaultTreeCellRenderer {
  @@ -75,9 +78,23 @@
                                                     boolean hasFocus) {
           super.getTreeCellRendererComponent(tree, value, sel, expanded,
                                              leaf, row, hasFocus);
  -        if(value instanceof ACSElement) {
  -            setText(((ACSElement)value).getDisplayName());
  +
  +        try {
  +            BeanInfo info = Introspector.getBeanInfo(value.getClass());
  +            Image icon = info.getIcon(BeanInfo.ICON_COLOR_16x16);
  +            setIcon(new ImageIcon(icon));
  +            if(value instanceof ACSElement) {
  +                setText(((ACSElement)value).getDisplayName());
  +            }
  +            else {
  +               setText(info.getBeanDescriptor().getDisplayName());
  +            }
  +        }
  +        catch(IntrospectionException ex) {
  +            // XXX log me.
  +            ex.printStackTrace();
           }
  +
           return this;
       }
   }
  
  
  
  1.4       +15 -1     jakarta-ant/src/antidote/org/apache/tools/ant/gui/ResourceManager.java
  
  Index: ResourceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/ResourceManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ResourceManager.java	2000/11/10 20:41:09	1.3
  +++ ResourceManager.java	2000/11/16 21:46:29	1.4
  @@ -63,7 +63,7 @@
    * Singleton class for accessing various resources by the application.
    * Relies on the resource bundles for resource values.
    *
  - * @version $Revision: 1.3 $ 
  + * @version $Revision: 1.4 $ 
    * @author Simeon H.K. Fitch 
    */
   public class ResourceManager {
  @@ -163,6 +163,18 @@
       }
   
   	/** 
  +	 * Get the image as an ImageIcon assigned to the given class with the
  +     * given key.
  +	 * 
  +     * @param clazz The class to load icon for.
  +     * @param key The key for looking up the icon.
  +	 * @return Image as an ImageIcon, or null if not found.
  +	 */
  +    public ImageIcon getImageIcon(Class clazz, String key) {
  +        return getImageIcon(getString(clazz, key));
  +    }
  +
  +	/** 
   	 * Get the image as an ImageIcon with the given file name. 
        * For example "open.gif". The image is loaded from the resources package.
   	 * 
  @@ -170,6 +182,8 @@
   	 * @return Image as an ImageIcon, or null if not found.
   	 */
       public ImageIcon getImageIcon(String fileName) {
  +        if(fileName == null) return null;
  +
           ImageIcon icon = null;
   
           URL location = getClass().getResource("resources/" + fileName);
  
  
  

Mime
View raw message