KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > module > loader > AntProjectDataLoaderBeanInfo


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.apache.tools.ant.module.loader;
21
22 import java.awt.Image JavaDoc;
23 import java.beans.BeanInfo JavaDoc;
24 import java.beans.IntrospectionException JavaDoc;
25 import java.beans.Introspector JavaDoc;
26 import java.beans.PropertyDescriptor JavaDoc;
27 import java.beans.SimpleBeanInfo JavaDoc;
28 import org.apache.tools.ant.module.AntModule;
29 import org.openide.loaders.DataLoader;
30 import org.openide.util.NbBundle;
31
32 public class AntProjectDataLoaderBeanInfo extends SimpleBeanInfo JavaDoc {
33
34     @Override JavaDoc
35     public BeanInfo JavaDoc[] getAdditionalBeanInfo () {
36         try {
37             return new BeanInfo JavaDoc[] { Introspector.getBeanInfo (DataLoader.class) };
38         } catch (IntrospectionException JavaDoc ie) {
39             AntModule.err.notify(ie);
40             return null;
41         }
42     }
43     
44     @Override JavaDoc
45     public PropertyDescriptor JavaDoc[] getPropertyDescriptors() {
46         // Make extensions into a r/o property.
47
// It will only contain the Ant MIME type.
48
// Customizations should be done on the resolver object, not on the extension list.
49
// Does not work to just use additional bean info from UniFileLoader and return one extensions
50
// property with no setter--Introspector cleverly (!&#$@&) keeps your display name
51
// and everything and adds back in the setter from the superclass.
52
// So bypass UniFileLoader in the beaninfo search.
53
try {
54             PropertyDescriptor JavaDoc extensions = new PropertyDescriptor JavaDoc("extensions", AntProjectDataLoader.class, "getExtensions", null); // NOI18N
55
extensions.setDisplayName(NbBundle.getMessage(AntProjectDataLoaderBeanInfo.class, "PROP_extensions"));
56             extensions.setShortDescription(NbBundle.getMessage(AntProjectDataLoaderBeanInfo.class, "HINT_extensions"));
57             extensions.setExpert(true);
58             return new PropertyDescriptor JavaDoc[] {extensions};
59         } catch (IntrospectionException JavaDoc ie) {
60             AntModule.err.notify(ie);
61             return null;
62         }
63     }
64
65     @Override JavaDoc
66     public Image JavaDoc getIcon (int type) {
67         if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) {
68             return org.openide.util.Utilities.loadImage ("org/apache/tools/ant/module/resources/AntIcon.gif");
69         } else {
70             return null;
71         }
72     }
73
74 }
75
Popular Tags