Quantum version 2.4.2
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / bookmark / ColumnNode.java
1 package com.quantum.view.bookmark;
2
3 import com.quantum.model.Column;
4
5 /**
6  * @author BC
7  */
8 public class ColumnNode extends TreeNode {
9     
10     private Column column;
11     
12     public ColumnNode(TreeNode parent, Column column) {
13         super(parent);
14         this.column = column;
15     }
16
17     public Object[] getChildren() {
18         return BookmarkListNode.EMPTY_ARRAY;
19     }
20
21     public boolean hasChildren() {
22         return false;
23     }
24
25     public String getName() {
26         return this.column.getName();
27     }
28
29     protected String getImageName() {
30         return this.column.isPrimaryKey() ? "keycolumn.gif" : "column.gif";
31     }
32
33     public String getLabelName() {
34         String label = getName() + " : " + this.column.getTypeName(); //$NON-NLS-1$
35         if (this.column.isNumeric()) {
36             if (this.column.getSize() > 0 || this.column.getNumberOfFractionalDigits() > 0) {
37                 label += "(" + Integer.toString(this.column.getSize()); //$NON-NLS-1$
38                 if (this.column.getNumberOfFractionalDigits() > 0) {
39                     label += "," + Integer.toString(this.column.getNumberOfFractionalDigits()); //$NON-NLS-1$
40                 }
41                 label += ")"; //$NON-NLS-1$
42             }
43         } else if (this.column.getSize() > 0) {
44             label += "(" + Integer.toString(this.column.getSize()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
45         }
46         return label;
47     }
48     /* (non-Javadoc)
49      * @see com.quantum.view.bookmark.TreeNode#initializeChildren()
50      */
51     protected void initializeChildren() {
52     }
53     protected boolean isInitialized() {
54         return true;
55     }
56
57     /**
58      * @return
59      */
60     public Column getColumn() {
61         return column;
62     }
63
64     void setColumn(Column column) {
65         if (this.column == null || !this.column.equals(column)) {
66                 Column original = column;
67                 this.column = column;
68                 firePropertyChange("column", original, column);
69         }
70     }
71 }