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-2007 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: package org.netbeans.modules.visualweb.propertyeditors;
042:
043: import javax.swing.event.TableModelListener;
044: import javax.swing.table.TableModel;
045:
046: /**
047: * A model that defines methods for manipulating a tabular property value. A
048: * tabular property is typically a matrix of primitive types (e.g. a list of
049: * lists of strings, or a list of objects with any number of properties).
050: *
051: * @author gjmurphy
052: */
053: public interface TabularPropertyModel extends TableModel {
054:
055: /**
056: * Return the value of the table contents, as an object of type suitable
057: * for the property being edited.
058: */
059: public Object getValue();
060:
061: /**
062: * Set the initial value of the table contents.
063: */
064: public void setValue(Object value);
065:
066: /**
067: * Adds a listener to the model, which is notified each time a change to the
068: * model occurs.
069: */
070: public void addTableModelListener(TableModelListener listener);
071:
072: /**
073: * Removes the listener specified.
074: */
075: public void removeTableModelListener(TableModelListener listener);
076:
077: /**
078: * Returns the number of columns in the model. This number must not
079: * change over the lifetime of the editor.
080: *
081: * @return The number of columns in the model.
082: */
083: public int getColumnCount();
084:
085: /**
086: * Returns the display name of the column with the index specified.
087: *
088: * @param columnIndex
089: * @return The display name of the column with the index specified.
090: */
091: public String getColumnName(int columnIndex);
092:
093: /**
094: * Returns the type of the column with the index specified.
095: *
096: * @param columnIndex
097: * @return The type of the column with the index specified.
098: */
099: public Class getColumnClass(int columnIndex);
100:
101: /**
102: * Returns the current number of rows. The number may change over the
103: * lifetime of the editor.
104: *
105: * @return The current number of rows.
106: */
107: public int getRowCount();
108:
109: /**
110: * Returns the value of the cell at the row and column specified.
111: *
112: * @param rowIndex
113: * @param columnIndex
114: * @return The value of the cell at the row and column specified.
115: */
116: public Object getValueAt(int rowIndex, int columnIndex);
117:
118: /**
119: * Returns <code>true</code> if the cell specified is editable.
120: *
121: * @param rowIndex
122: * @param columnIndex
123: * @return <code>true</code> if the cell specified is editable.
124: */
125: public boolean isCellEditable(int rowIndex, int columnIndex);
126:
127: /**
128: * Change the value of the cell specified.
129: *
130: * @param newValue
131: * @param rowIndex
132: * @param columnIndex
133: * @return <code>true</code> if the cell specified was modified.
134: */
135: public void setValueAt(Object newValue, int rowIndex,
136: int columnIndex);
137:
138: /**
139: * Returns true if rows may be added to this table model.
140: *
141: * @return <code>true</code> if rows may be added to this table model.
142: */
143: public boolean canAddRow();
144:
145: /**
146: * Add a row to this model.
147: *
148: * @return <code>true</code> if a row was added to this table model.
149: */
150: public boolean addRow();
151:
152: /**
153: * Returns <code>true</code> if the row specified may be moved to the
154: * new location specified. Rows should be shift down one to make room
155: * for the new row.
156: */
157: public boolean canMoveRow(int indexFrom, int indexTo);
158:
159: public boolean moveRow(int indexFrom, int indexTo);
160:
161: /**
162: * Returns <code>true</code> if the row specified may be removed. Remaining
163: * rows should be shifted up one.
164: */
165: public boolean canRemoveRow(int index);
166:
167: public boolean removeRow(int index);
168:
169: public boolean removeAllRows();
170: }
|