Browse Source

Added icons to project tree view.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268198 13f79535-47bb-0310-9956-ffa450edef68
master
metasim 24 years ago
parent
commit
a04027cae3
9 changed files with 58 additions and 3 deletions
  1. +19
    -2
      src/antidote/org/apache/tools/ant/gui/AntTreeCellRenderer.java
  2. +14
    -0
      src/antidote/org/apache/tools/ant/gui/ResourceManager.java
  3. +21
    -1
      src/antidote/org/apache/tools/ant/gui/acs/BaseBeanInfo.java
  4. +4
    -0
      src/antidote/org/apache/tools/ant/gui/resources/antidote.properties
  5. BIN
      src/antidote/org/apache/tools/ant/gui/resources/project.gif
  6. BIN
      src/antidote/org/apache/tools/ant/gui/resources/property.gif
  7. BIN
      src/antidote/org/apache/tools/ant/gui/resources/target.gif
  8. BIN
      src/antidote/org/apache/tools/ant/gui/resources/task.gif
  9. BIN
      src/antidote/org/apache/tools/ant/gui/resources/unknown.gif

+ 19
- 2
src/antidote/org/apache/tools/ant/gui/AntTreeCellRenderer.java View File

@@ -56,7 +56,10 @@ package org.apache.tools.ant.gui;
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.
@@ -75,9 +78,23 @@ public class AntTreeCellRenderer extends DefaultTreeCellRenderer {
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;
}
}

+ 14
- 0
src/antidote/org/apache/tools/ant/gui/ResourceManager.java View File

@@ -162,6 +162,18 @@ public class ResourceManager {
return MessageFormat.format(format, arguments);
}

/**
* 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 @@ public class ResourceManager {
* @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);


+ 21
- 1
src/antidote/org/apache/tools/ant/gui/acs/BaseBeanInfo.java View File

@@ -56,6 +56,8 @@ package org.apache.tools.ant.gui.acs;
import org.apache.tools.ant.gui.ResourceManager;
import org.apache.tools.ant.gui.customizer.DynamicCustomizer;
import java.beans.*;
import javax.swing.ImageIcon;
import java.awt.Image;

/**
* Abstract base class for ACS BeanInfo classes.
@@ -66,15 +68,22 @@ import java.beans.*;
abstract class BaseBeanInfo extends SimpleBeanInfo {
/** Property name for specifiying a sorting order. */
public static final String SORT_ORDER = DynamicCustomizer.SORT_ORDER;

/** Resource provider for bean info. */
private static ResourceManager _resources = new ResourceManager();

/** Icon for this. */
private Image _icon = null;

/**
* Default ctor.
*
*/
protected BaseBeanInfo() {
// Load the icon.
ImageIcon img = _resources.getImageIcon(getClass(), "icon");
if(img != null) {
_icon = img.getImage();
}
}

/**
@@ -95,6 +104,17 @@ abstract class BaseBeanInfo extends SimpleBeanInfo {
return new ACSBeanDescriptor(this);
}

/**
* Get the icon for displaying this bean.
*
* @param kind Kind of icon. XXX currently ignored
* @return Image for bean, or null if none.
*/
public Image getIcon(int kind) {
// XXX kind is currently ignored.
return _icon;
}

/**
* Set the sorting order property of the given objects based
* on the order that they appear in the array.


+ 4
- 0
src/antidote/org/apache/tools/ant/gui/resources/antidote.properties View File

@@ -77,6 +77,7 @@ org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.depends=Dependencies
org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.if=if Clause
org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.unless=unless Clause
org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.xmlString=XML Code
org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.icon=target.gif

org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.beanName=Project
org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.beanDescription=\
@@ -85,6 +86,7 @@ org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.name=Name
org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.description=Description
org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.basedir=Base Directory
org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.default=Default Target
org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.icon=project.gif

org.apache.tools.ant.gui.acs.ACSPropertyElementBeanInfo.beanName=Property
org.apache.tools.ant.gui.acs.ACSPropertyElementBeanInfo.beanDescription=\
@@ -92,12 +94,14 @@ org.apache.tools.ant.gui.acs.ACSPropertyElementBeanInfo.beanDescription=\
org.apache.tools.ant.gui.acs.ACSPropertyElementBeanInfo.name=Name
org.apache.tools.ant.gui.acs.ACSPropertyElementBeanInfo.value=Value
org.apache.tools.ant.gui.acs.ACSPropertyElementBeanInfo.file=File
org.apache.tools.ant.gui.acs.ACSPropertyElementBeanInfo.icon=property.gif

org.apache.tools.ant.gui.acs.ACSTaskElementBeanInfo.beanName=Task
org.apache.tools.ant.gui.acs.ACSTaskElementBeanInfo.beanDescription=\
A scoped property
org.apache.tools.ant.gui.acs.ACSTaskElementBeanInfo.taskType=Type
org.apache.tools.ant.gui.acs.ACSTaskElementBeanInfo.xmlString=XML Code
org.apache.tools.ant.gui.acs.ACSTaskElementBeanInfo.icon=task.gif




BIN
src/antidote/org/apache/tools/ant/gui/resources/project.gif View File

Before After
Width: 20  |  Height: 20  |  Size: 914 B

BIN
src/antidote/org/apache/tools/ant/gui/resources/property.gif View File

Before After
Width: 20  |  Height: 20  |  Size: 998 B

BIN
src/antidote/org/apache/tools/ant/gui/resources/target.gif View File

Before After
Width: 20  |  Height: 20  |  Size: 187 B

BIN
src/antidote/org/apache/tools/ant/gui/resources/task.gif View File

Before After
Width: 20  |  Height: 20  |  Size: 988 B

BIN
src/antidote/org/apache/tools/ant/gui/resources/unknown.gif View File

Before After
Width: 20  |  Height: 20  |  Size: 1.0 KiB

Loading…
Cancel
Save