From a04027cae372928a9f757764f38c28f61e128412 Mon Sep 17 00:00:00 2001 From: metasim Date: Thu, 16 Nov 2000 21:46:33 +0000 Subject: [PATCH] Added icons to project tree view. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268198 13f79535-47bb-0310-9956-ffa450edef68 --- .../tools/ant/gui/AntTreeCellRenderer.java | 21 +++++++++++++++-- .../apache/tools/ant/gui/ResourceManager.java | 14 +++++++++++ .../tools/ant/gui/acs/BaseBeanInfo.java | 22 +++++++++++++++++- .../ant/gui/resources/antidote.properties | 4 ++++ .../tools/ant/gui/resources/project.gif | Bin 0 -> 914 bytes .../tools/ant/gui/resources/property.gif | Bin 0 -> 998 bytes .../apache/tools/ant/gui/resources/target.gif | Bin 0 -> 187 bytes .../apache/tools/ant/gui/resources/task.gif | Bin 0 -> 988 bytes .../tools/ant/gui/resources/unknown.gif | Bin 0 -> 1043 bytes 9 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 src/antidote/org/apache/tools/ant/gui/resources/project.gif create mode 100644 src/antidote/org/apache/tools/ant/gui/resources/property.gif create mode 100644 src/antidote/org/apache/tools/ant/gui/resources/target.gif create mode 100644 src/antidote/org/apache/tools/ant/gui/resources/task.gif create mode 100644 src/antidote/org/apache/tools/ant/gui/resources/unknown.gif diff --git a/src/antidote/org/apache/tools/ant/gui/AntTreeCellRenderer.java b/src/antidote/org/apache/tools/ant/gui/AntTreeCellRenderer.java index 360d1d3a4..f954915de 100644 --- a/src/antidote/org/apache/tools/ant/gui/AntTreeCellRenderer.java +++ b/src/antidote/org/apache/tools/ant/gui/AntTreeCellRenderer.java @@ -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; } } diff --git a/src/antidote/org/apache/tools/ant/gui/ResourceManager.java b/src/antidote/org/apache/tools/ant/gui/ResourceManager.java index a066487af..9c5ea88bb 100644 --- a/src/antidote/org/apache/tools/ant/gui/ResourceManager.java +++ b/src/antidote/org/apache/tools/ant/gui/ResourceManager.java @@ -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); diff --git a/src/antidote/org/apache/tools/ant/gui/acs/BaseBeanInfo.java b/src/antidote/org/apache/tools/ant/gui/acs/BaseBeanInfo.java index 10954ec95..2051fb81f 100644 --- a/src/antidote/org/apache/tools/ant/gui/acs/BaseBeanInfo.java +++ b/src/antidote/org/apache/tools/ant/gui/acs/BaseBeanInfo.java @@ -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. diff --git a/src/antidote/org/apache/tools/ant/gui/resources/antidote.properties b/src/antidote/org/apache/tools/ant/gui/resources/antidote.properties index 4d08defc8..7240af0d1 100644 --- a/src/antidote/org/apache/tools/ant/gui/resources/antidote.properties +++ b/src/antidote/org/apache/tools/ant/gui/resources/antidote.properties @@ -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 diff --git a/src/antidote/org/apache/tools/ant/gui/resources/project.gif b/src/antidote/org/apache/tools/ant/gui/resources/project.gif new file mode 100644 index 0000000000000000000000000000000000000000..3a2bed667773056a07257cec705f84b94537bece GIT binary patch literal 914 zcmbW0v1`*&5Xa9}N{U1fvKVy`q-0Q+Bhn&*5Qqu|gAPg|LZKXL1Q&0i*dgyX&Y-sk(hUrwAVk55eJC`Z5O z-(eylQX(UALd8rh#7b<$9+$!-LZT!_;_+6QR7jQ7NIhDO$%IVFjLe}#&g4R_jsuq(T7F5 z;(&iZz#*t1253;?DL60~+K`5pM{;qE8pl*Uf`mVeMP;Vu$Q5=$flGB$M~+Au0e}n7 z5j5N)O5_1dbR!Nh!7vrt=4L_dcEFgG@8w3tJP|^+nr9Q+wJyxy?(zx7!1&R+Rge$o1jluO7X-{q4Ze%8{p!*Y51wHj^74%y*lG z)AJweFP^L~96opNYi4<)sGDP7p5HqA{lmhsOMkBHzIM^>PTbsi=hUYLN78%7sA@F(YIVb_@9se;SY!3`OY~I-e0lv zWFGSHi}0n-mp*U0-|6~@FL&h8TaTW@ltss2LgTQ^xWqWz80;v_2!sMP1Wr0kS{yXk zrcuajkXQ#d47&m83C9t&Osv)Iij^ z2-~PK5fqSA1n79QQZyWD3ChEi;zZm<%tq8iL_kpyqC;AwL29H-N=zf|!nI+WFa?AP zbulc);6`CbU@8zHsEc7S47Un)5T*nXfSQ5jU+6-z#juF5iz*vI6OuqcT?~texro|` zm{0^lY6cdOPQ!I!+b~TC0o9-JET#-P8WS>y=hDgu%;BWPq`^UrZ8C+#24n>0(6MM4 zG&E{5WraOmO~>!ZJ2U=KCu6>z>L5$urM<-Gc`3e zK0ZD+Ha0psIy5vCkH@>Zx?-_dOG`^M8f|WFjzl8$_4SIPR99DrLZOn9lET8m+}vEw zdfnZo=YfF zItxC2-isTdGtT84{mr$N%l~e@(BB)b*|5E7N8^$9qWwq>EVyH2c literal 0 HcmV?d00001 diff --git a/src/antidote/org/apache/tools/ant/gui/resources/target.gif b/src/antidote/org/apache/tools/ant/gui/resources/target.gif new file mode 100644 index 0000000000000000000000000000000000000000..3488dd3fe15449f95045ca070579bcc904f88c08 GIT binary patch literal 187 zcmZ?wbhEHb6k!ly*v!DN@zMWn+qQY^_|Guu&j0LwhG~WjI~ndUcur$5Y+ztWN=jlV zR%Kvd0J0%K@h1x>2LmsI4u}gfgMlSu!%5H8YaL(8=7subXvwiky*M;sX^B|tscp}b z*00s>tDM}Z?W#VVb6wlgMFE{#3{?HqJv=&pnH_wlufg&zjrTnViw1vzut1`(0TWA; haYU_!!kuQDD0hb+z1G!0yWwjzQI)&NX;JyQSx literal 0 HcmV?d00001 diff --git a/src/antidote/org/apache/tools/ant/gui/resources/task.gif b/src/antidote/org/apache/tools/ant/gui/resources/task.gif new file mode 100644 index 0000000000000000000000000000000000000000..8c091865b9911c86e17344270065e02508845077 GIT binary patch literal 988 zcmZvbTSyd99L7J>(7+^62<@SZj3wRJEhrQvDsy%vn*!ZHx-C6KLqZ+PmjW z9`f*$@T4u4wrHByY1*(SclhD^1QQM?Ejl_!RSw9ENsPfYU`JqvA%al+;FQBLi+wty zDuv9D#2UB(*kv$%5E7Jp&~a#4)OD&VWtozc1YE!dOh5n%yqPIlW7PYoMkxzQA)>}b zz($z~pMazwpH70-Bz1@CDCGf4F(T%|un{p476>Zv(;+QVCsk4=B_@${;o7iGm;yq9 zvK$r-xDnW4m_Z0Xl;yA(fLjLJ2UCK`hmwNjUFcG><*;_!DNB@6urNhuj8-4@C{;l@M5$&e77}zOX*twKsSZ$%Ee7^K7MK!P3Kr()=VxbU z$H&Lx@%YHdNPmBSEEenR>@*CcrKKejiPYEEhr{98+S*_+SYBT4_xp>AiV6w}a&mI` zC(+f_t7+Q8W2blAf_d&Oo;Lo~5K4I({5nR~LKq;X|#Pwv~NXAU$W z*_Qq_-d%BZ&6js~GOeD98`JTQx{uYp?;5szI6CxJ--Pz>JNEzGd~u@W-gLvO>vQ$p z`HS^#l)(e->R-1DKxe=J$Z2OZt=|@ zZ?aBLmt0PaKe}I+rwuk7&MeAC+li{^m5%1Kt&Qi=c=FWm-LBE`^49Uy&n{)#PftIN U&dhYQ?l?Kr-nn*Hb{0zi0qi&Jm;e9( literal 0 HcmV?d00001 diff --git a/src/antidote/org/apache/tools/ant/gui/resources/unknown.gif b/src/antidote/org/apache/tools/ant/gui/resources/unknown.gif new file mode 100644 index 0000000000000000000000000000000000000000..cd94e5f689d484e81ba4e711a43afdb61a26863a GIT binary patch literal 1043 zcmZ|OTSyd990u?&47x~Lgb*tQMvYLJ;YO&{8WGg&N;NOKB}BDUR6|-EBipAX%A#U~ zt>&c~q@rl-!aSsoMU=>jmwbq+hiwpB%k4t47(^26*XCQTeQ-D&_`m%4&VO5AYenV$ z0u&&HKZ#DA=+qU>zM|0=*|;z6_NSS4n6&6C6h2+#B4-#gav{Md~`^Q)JT<-Nr@R`T(~xD9lC%} zpiIYN3~mH=7 zB!-5Dy1TpE+uKdkGz=pai#0blM`ucDmB|lOEaGB`wtu}I(4M+aM8BFb_Gi(XU@p}MwDdNBD*66!0cggPC?W7;;xh55)Ze8 zj<;?(^L3;zuc+bH#-^`B{^dVC(WmFe2A4F>8o9akd}_V9DzxK9^@)-<*EUYBk)kJ8 z@BLEJQGe)_v1*TTB~@xX6Qu)vgH4{{r#DiUjb(xP_bbHsi1%v8_{YkN$>(Rz**k_e z<5T0pdHMSuR5X^q>sx#8`^TQ9+Q@`97GkL