fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / libjava / javax / swing / table / TableColumn.java
blobd228d8aae92dd79b674e1ed632a7dd97c05c1e8d
1 /* TableColumn.java --
2 Copyright (C) 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.swing.table;
41 import java.beans.PropertyChangeListener;
42 import java.io.Serializable;
43 import javax.swing.event.SwingPropertyChangeSupport;
45 /**
46 * TableColumn
47 * @author Andrew Selkirk
48 * @version 1.0
50 public class TableColumn implements Serializable
52 static final long serialVersionUID = -6113660025878112608L;
54 //-------------------------------------------------------------
55 // Variables --------------------------------------------------
56 //-------------------------------------------------------------
58 /**
59 * COLUMN_WIDTH_PROPERTY
61 public static final String COLUMN_WIDTH_PROPERTY = "columWidth";
63 /**
64 * HEADER_VALUE_PROPERTY
66 public static final String HEADER_VALUE_PROPERTY = "headerValue";
68 /**
69 * HEADER_RENDERER_PROPERTY
71 public static final String HEADER_RENDERER_PROPERTY = "headerRenderer";
73 /**
74 * CELL_RENDERER_PROPERTY
76 public static final String CELL_RENDERER_PROPERTY = "cellRenderer";
78 /**
79 * modelIndex
81 protected int modelIndex;
83 /**
84 * identifier
86 protected Object identifier;
88 /**
89 * width
91 protected int width;
93 /**
94 * minWidth
96 protected int minWidth = 15;
98 /**
99 * preferredWidth
101 private int preferredWidth;
104 * maxWidth
106 protected int maxWidth = Integer.MAX_VALUE;
109 * headerRenderer
111 protected TableCellRenderer headerRenderer;
114 * headerValue
116 protected Object headerValue;
119 * cellRenderer
121 protected TableCellRenderer cellRenderer;
124 * cellEditor
126 protected TableCellEditor cellEditor;
129 * isResizable
131 protected boolean isResizable = true;
134 * resizedPostingDisableCount
136 protected transient int resizedPostingDisableCount;
139 * changeSupport
141 private SwingPropertyChangeSupport changeSupport = new SwingPropertyChangeSupport(this);
144 //-------------------------------------------------------------
145 // Initialization ---------------------------------------------
146 //-------------------------------------------------------------
149 * Constructor TableColumn
151 public TableColumn() {
152 this(0, 75, null, null);
153 } // TableColumn()
156 * Constructor TableColumn
157 * @param modelIndex TODO
159 public TableColumn(int modelIndex) {
160 this(modelIndex, 75, null, null);
161 } // TableColumn()
164 * Constructor TableColumn
165 * @param modelIndex TODO
166 * @param width TODO
168 public TableColumn(int modelIndex, int width) {
169 this(modelIndex, width, null, null);
170 } // TableColumn()
173 * Constructor TableColumn
174 * @param modelIndex TODO
175 * @param width TODO
176 * @param cellRenderer TODO
177 * @param cellEditor TODO
179 public TableColumn(int modelIndex, int width,
180 TableCellRenderer cellRenderer, TableCellEditor cellEditor) {
181 this.modelIndex = modelIndex;
182 this.width = width;
183 this.preferredWidth = width;
184 this.cellRenderer = cellRenderer;
185 this.cellEditor = cellEditor;
186 this.headerValue = null;
187 this.identifier = null;
188 } // TableColumn()
191 //-------------------------------------------------------------
192 // Methods ----------------------------------------------------
193 //-------------------------------------------------------------
196 * firePropertyChange
197 * @param property TODO
198 * @param oldValue TODO
199 * @param newValue TODO
201 private void firePropertyChange(String property, Object oldValue, Object newValue) {
202 changeSupport.firePropertyChange(property, oldValue, newValue);
203 } // firePropertyChange()
206 * firePropertyChange
207 * @param property TODO
208 * @param oldValue TODO
209 * @param newValue TODO
211 private void firePropertyChange(String property, int oldValue, int newValue) {
212 firePropertyChange(property, new Integer(oldValue), new Integer(newValue));
213 } // firePropertyChange()
216 * firePropertyChange
217 * @param property TODO
218 * @param oldValue TODO
219 * @param newValue TODO
221 private void firePropertyChange(String property, boolean oldValue, boolean newValue) {
222 firePropertyChange(property, new Boolean(oldValue), new Boolean(newValue));
223 } // firePropertyChange()
226 * setModelIndex
227 * @param modelIndex TODO
229 public void setModelIndex(int modelIndex) {
230 this.modelIndex = modelIndex;
231 } // setModelIndex()
234 * getModelIndex
235 * @returns int
237 public int getModelIndex() {
238 return modelIndex;
239 } // getModelIndex()
242 * setIdentifier
243 * @param identifier TODO
245 public void setIdentifier(Object identifier) {
246 this.identifier = identifier;
247 } // setIdentifier()
250 * getIdentifier
251 * @returns Object
253 public Object getIdentifier() {
254 if (identifier == null) {
255 return getHeaderValue();
256 } // if
257 return identifier;
258 } // getIdentifier()
261 * setHeaderValue
262 * @param headerValue TODO
264 public void setHeaderValue(Object headerValue) {
266 // Variables
267 Object oldValue;
269 // Get Old Value
270 oldValue = this.headerValue;
272 // Set Propeprty
273 this.headerValue = headerValue;
275 // Notify Listeners of change
276 firePropertyChange(HEADER_VALUE_PROPERTY,
277 oldValue, headerValue);
279 } // setHeaderValue()
282 * getHeaderValue
283 * @returns Object
285 public Object getHeaderValue() {
286 return headerValue;
287 } // getHeaderValue()
290 * setHeaderRenderer
291 * @param headerRenderer TODO
293 public void setHeaderRenderer(TableCellRenderer headerRenderer) {
295 // Variables
296 TableCellRenderer oldRenderer;
298 // Get Old Renderer
299 oldRenderer = this.headerRenderer;
301 // Set Property
302 this.headerRenderer = headerRenderer;
304 // Notify Listeners of change
305 firePropertyChange(HEADER_RENDERER_PROPERTY,
306 oldRenderer, headerRenderer);
308 } // setHeaderRenderer()
311 * getHeaderRenderer
312 * @returns TableCellRenderer
314 public TableCellRenderer getHeaderRenderer() {
315 return headerRenderer;
316 } // getHeaderRenderer()
319 * setCellRenderer
320 * @param cellRenderer TODO
322 public void setCellRenderer(TableCellRenderer cellRenderer) {
324 // Variables
325 TableCellRenderer oldRenderer;
327 // Get Old Renderer
328 oldRenderer = this.cellRenderer;
330 // Set Property
331 this.cellRenderer = cellRenderer;
333 // Notify Listeners of change
334 firePropertyChange(CELL_RENDERER_PROPERTY,
335 oldRenderer, cellRenderer);
337 } // setCellRenderer()
340 * getCellRenderer
341 * @returns TableCellRenderer
343 public TableCellRenderer getCellRenderer() {
344 return cellRenderer;
345 } // getCellRenderer()
348 * setCellEditor
349 * @param cellEditor TODO
351 public void setCellEditor(TableCellEditor cellEditor) {
352 this.cellEditor = cellEditor;
353 } // setCellEditor()
356 * getCellEditor
357 * @returns TableCellEditor
359 public TableCellEditor getCellEditor() {
360 return cellEditor;
361 } // getCellEditor()
364 * setWidth
365 * @param width TODO
367 public void setWidth(int width) {
369 // Variables
370 int oldWidth;
372 // Get Old Width
373 oldWidth = this.width;
375 // Adjust Width within Limits
376 if (width < minWidth) {
377 this.width = minWidth;
378 } else if (width > maxWidth) {
379 this.width = maxWidth;
380 } else {
381 this.width = width;
382 } // if
384 // Fire Property Change
385 firePropertyChange(COLUMN_WIDTH_PROPERTY, oldWidth, this.width);
387 } // setWidth()
390 * getWidth
391 * @returns int
393 public int getWidth() {
394 return width;
395 } // getWidth()
398 * setPreferredWidth
399 * @param preferredWidth TODO
401 public void setPreferredWidth(int preferredWidth) {
402 if (preferredWidth < minWidth) {
403 this.preferredWidth = minWidth;
404 } else if (preferredWidth > maxWidth) {
405 this.preferredWidth = maxWidth;
406 } else {
407 this.preferredWidth = preferredWidth;
408 } // if
409 } // setPreferredWidth()
412 * getPreferredWidth
413 * @returns int
415 public int getPreferredWidth() {
416 return preferredWidth;
417 } // getPreferredWidth()
420 * setMinWidth
421 * @param minWidth TODO
423 public void setMinWidth(int minWidth) {
424 this.minWidth = minWidth;
425 setWidth(getWidth());
426 setPreferredWidth(getPreferredWidth());
427 } // setMinWidth()
430 * getMinWidth
431 * @returns int
433 public int getMinWidth() {
434 return minWidth;
435 } // getMinWidth()
438 * setMaxWidth
439 * @param maxWidth TODO
441 public void setMaxWidth(int maxWidth) {
442 this.maxWidth = maxWidth;
443 setWidth(getWidth());
444 setPreferredWidth(getPreferredWidth());
445 } // setMaxWidth()
448 * getMaxWidth
449 * @returns int
451 public int getMaxWidth() {
452 return maxWidth;
453 } // getMaxWidth()
456 * setResizable
457 * @param isResizable TODO
459 public void setResizable(boolean isResizable) {
460 this.isResizable = isResizable;
461 } // setResizable()
464 * getResizable
465 * @returns boolean
467 public boolean getResizable() {
468 return isResizable;
469 } // getResizable()
472 * sizeWidthToFit
474 public void sizeWidthToFit() {
475 // TODO
476 } // sizeWidthToFit()
479 * disableResizedPosting
481 public void disableResizedPosting() {
482 // Does nothing
483 } // disableResizedPosting()
486 * enableResizedPosting
488 public void enableResizedPosting() {
489 // Does nothing
490 } // enableResizedPosting()
493 * addPropertyChangeListener
494 * @param listener TODO
496 public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
497 changeSupport.addPropertyChangeListener(listener);
498 } // addPropertyChangeListener()
501 * removePropertyChangeListener
502 * @param listener TODO
504 public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
505 changeSupport.removePropertyChangeListener(listener);
506 } // removePropertyChangeListener()
509 * createDefaultHeaderRenderer
510 * @returns TableCellRenderer
512 protected TableCellRenderer createDefaultHeaderRenderer() {
513 return new DefaultTableCellRenderer();
514 } // createDefaultHeaderRenderer()
517 } // TableColumn