001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.spi.viewmodel;
043:
044: import java.beans.PropertyEditor;
045: import javax.swing.table.TableCellEditor;
046: import javax.swing.table.TableCellRenderer;
047:
048: /**
049: * Defines model for one table view column. Can be used together with
050: * {@link TreeModel} for tree table view representation.
051: *
052: * @author Jan Jancura
053: */
054: public abstract class ColumnModel implements Model {
055:
056: /**
057: * Returns unique ID of this column.
058: *
059: * @return unique ID of this column
060: */
061: public abstract String getID();
062:
063: /**
064: * Returns display name of this column.
065: *
066: * @return display name of this column
067: */
068: public abstract String getDisplayName();
069:
070: /**
071: * Returns the character, that indicates a mnemonic key
072: * for this column name. Can be <code>null</code>.
073: *
074: * @return the mnemonic key or <code>null</code>.
075: * @since 1.11
076: */
077: public Character getDisplayedMnemonic() {
078: return null;
079: }
080:
081: /**
082: * Returns type of column items.
083: *
084: * @return type of column items
085: */
086: public abstract Class getType();
087:
088: /**
089: * Returns ID of column this column should be installed before or
090: * <code>null</code>. Defines default order of columns only.
091: * This default order can be changed by user, and
092: * {@link #getCurrentOrderNumber} and {@link #setCurrentOrderNumber} are
093: * used for sorting after that.
094: *
095: * @return ID of column this column should be installed before or
096: * <code>null</code>
097: * @deprecated Not used. See {@link #getCurrentOrderNumber}.
098: */
099: public String getPreviuosColumnID() {
100: return null;
101: }
102:
103: /**
104: * Returns ID of column this column should be installed after or
105: * <code>null</code>. Defines default order of columns only.
106: * This default order can be changed by user, and
107: * {@link #getCurrentOrderNumber} and {@link #setCurrentOrderNumber} are
108: * used for sorting after that.
109: *
110: * @return ID of column next to this one or <code>null</code>
111: * @deprecated Not used. See {@link #getCurrentOrderNumber}.
112: */
113: public String getNextColumnID() {
114: return null;
115: }
116:
117: /**
118: * Returns tooltip for given column. Default implementation returns
119: * <code>null</code> - do not use tooltip.
120: *
121: * @return tooltip for given node or <code>null</code>
122: */
123: public String getShortDescription() {
124: return null;
125: }
126:
127: /**
128: * True if column can be sorted. Default implementation returns
129: * <code>true</code>.
130: *
131: * @return true if column can be sorted
132: */
133: public boolean isSortable() {
134: return true;
135: }
136:
137: /**
138: * True if column should be visible. Default implementation
139: * returns <code>true</code>.
140: *
141: * @return <code>true</code> if column should be visible
142: */
143: public boolean isVisible() {
144: return true;
145: }
146:
147: /**
148: * Set true if column is to be visible. Default implementation does nothing.
149: *
150: * @param visible set true if column is to be visible
151: */
152: public void setVisible(boolean visible) {
153: }
154:
155: /**
156: * True if column is sorted.
157: * Default implementation returns <code>false</code>.
158: *
159: * @return <code>true</code> if column is sorted.
160: */
161: public boolean isSorted() {
162: return false;
163: }
164:
165: /**
166: * Set true if column is to be sorted. Default implementation does nothing.
167: *
168: * @param sorted set true if column is to be sorted
169: */
170: public void setSorted(boolean sorted) {
171: }
172:
173: /**
174: * True if column should be sorted in descending order.
175: * Default implementation returns <code>false</code>.
176: *
177: * @return <code>true</code> if column should be sorted
178: * in descending order
179: */
180: public boolean isSortedDescending() {
181: return false;
182: }
183:
184: /**
185: * Set true if column is to be sorted in descending order.
186: * Default implementation does nothing.
187: *
188: * @param sortedDescending set true if column is to be sorted
189: * in descending order
190: */
191: public void setSortedDescending(boolean sortedDescending) {
192: }
193:
194: /**
195: * Should return current order number of this column. Default value is
196: * <code>-1</code>.
197: *
198: * @return current order number of this column or <code>-1</code>
199: */
200: public int getCurrentOrderNumber() {
201: return -1;
202: }
203:
204: /**
205: * Is called when current order number of this column is changed.
206: * Default implementation does nothing.
207: *
208: * @param newOrderNumber new order number
209: */
210: public void setCurrentOrderNumber(int newOrderNumber) {
211: }
212:
213: /**
214: * Return column width of this column.
215: *
216: * @return column width of this column
217: */
218: public int getColumnWidth() {
219: return 20;
220: }
221:
222: /**
223: * Is called when column width of this column is changed.
224: * Default implementation does nothing.
225: *
226: * @param newColumnWidth a new column width
227: */
228: public void setColumnWidth(int newColumnWidth) {
229: }
230:
231: /**
232: * Returns {@link java.beans.PropertyEditor} to be used for
233: * this column. Default implementation returns <code>null</code> -
234: * means use default PropertyEditor.
235: *
236: * @return {@link java.beans.PropertyEditor} to be used for
237: * this column
238: */
239: public PropertyEditor getPropertyEditor() {
240: return null;
241: }
242:
243: /**
244: * Rerturns {@link javax.swing.table.TableCellEditor} to be used for
245: * this column.
246: *
247: * @return {@link javax.swing.table.TableCellEditor} to be used for
248: * this column
249: */
250: // public TableCellEditor getTableCellEditor () {
251: // return null;
252: // }
253: /**
254: * Rerturns {@link javax.swing.table.TableCellRenderer} to be used for
255: * this column.
256: *
257: * @return {@link javax.swing.table.TableCellRenderer} to be used for
258: * this column
259: */
260: // public TableCellRenderer getTableCellRenderer () {
261: // return null;
262: // }
263: }
|