KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > core > ColumnProperty


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.netbeans.modules.tasklist.core;
21
22 import org.openide.nodes.PropertySupport;
23
24 import java.beans.PropertyEditor JavaDoc;
25 import org.netbeans.modules.tasklist.core.filter.SuggestionProperty;
26
27 /**
28  * Class holding column properties.
29  * See debuggercore's TreeTableExplorerViewSupport.java
30  *
31  * @author Tor Norbye
32  */

33 public class ColumnProperty extends PropertySupport.ReadOnly {
34     /** Id of the column. Used such that with deserialization,
35      * we can tell exactly which column you're referring to,
36      * even if we've added and removed columns from the system.
37      * (Could also store the column property name, but that's
38      * more work and more data). */

39     public int uid; // Used to check equivalence in serialized data,
40
// so I don't have to store whole string names
41
public int width;
42
43     private Class JavaDoc propertyEditorClass;
44
45     public ColumnProperty(
46               int uid,
47               SuggestionProperty prop,
48               boolean sortable,
49               boolean defaultVisiblity,
50               int width
51               ) {
52       this(uid, prop.getID(), prop.getValueClass(), prop.getName(), prop.getHint(), sortable, defaultVisiblity, width);
53     }
54
55     public ColumnProperty(
56               int uid,
57               SuggestionProperty prop,
58               boolean sortable,
59               int width
60               ) {
61       this(uid, prop.getID(),prop.getName(), prop.getHint(), sortable, width);
62     }
63               
64
65
66     // Used for non-treetable columns
67
/** Construct a new property for a "table column" (e.g. not
68      * the leftmost tree column)
69      * @param uid UID of this column
70      * @param name Property name
71      * @param type Type of this property
72      * @param displayName Name shown in the display
73      * @param hint Tooltip for the property
74      * @param sortable Whether or not this column is valid as a sort key
75      * @param defaultVisibility Whether or not this column should be shown by
76      * @param width Default width for the column
77      * default */

78     public ColumnProperty(
79         int uid,
80         String JavaDoc name,
81         Class JavaDoc type,
82         String JavaDoc displayName,
83         String JavaDoc hint,
84         boolean sortable,
85         boolean defaultVisibility,
86         int width
87     ) {
88         super(name, type, displayName, hint);
89         this.uid = uid;
90         this.width = width;
91         setValue("suppressCustomEditor", Boolean.TRUE); // NOI18N
92
// setValue("canEditAsText", Boolean.FALSE); // NOI18N
93
setValue ("ColumnDescriptionTTV", hint); // NOI18N
94
if (sortable) {
95             setValue("ComparableColumnTTV", Boolean.TRUE);// NOI18N
96
}
97         if (!defaultVisibility) {
98             setValue("InvisibleInTreeTableView", Boolean.TRUE);// NOI18N
99
}
100     }
101
102     // Used for the Tree column (column 0)
103
/** Construct a column object for the treecolumn (leftmost
104      * column).
105      * @param uid UID of the column
106      * @param name Property name
107      * @param displayName Name shown in the display
108      * @param hint Tooltip for the property
109      * @param sortable Whether or not this column is sortable
110      * @param width Default width for the column
111      */

112     public ColumnProperty (
113         int uid,
114         String JavaDoc name,
115         String JavaDoc displayName,
116         String JavaDoc hint,
117         boolean sortable,
118         int width
119     ) {
120         super(name, String JavaDoc.class, displayName, hint);
121         this.uid = uid;
122         this.width = width;
123         setValue( "TreeColumnTTV", Boolean.TRUE );// NOI18N
124
setValue("suppressCustomEditor", Boolean.TRUE); // NOI18N
125
setValue("canEditAsText", Boolean.FALSE); // NOI18N
126
if (sortable) {
127             setValue ("ComparableColumnTTV", Boolean.TRUE);// NOI18N
128
}
129     }
130
131     public Object JavaDoc getValue() {
132         return null;
133     }
134
135     public int getWidth() {
136         return width;
137     }
138
139     public final void setPropertyEditorClass(Class JavaDoc peClass) {
140         propertyEditorClass = peClass;
141     }
142
143     public final PropertyEditor JavaDoc getPropertyEditor() {
144         if (propertyEditorClass != null)
145             try {
146                 return (PropertyEditor JavaDoc) propertyEditorClass.newInstance ();
147             } catch (InstantiationException JavaDoc ex) {
148             } catch (IllegalAccessException JavaDoc iex) {
149             }
150         return super.getPropertyEditor ();
151     }
152 }
153
Popular Tags