initial quantum version
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / bookmark / ColumnNode.java
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/ColumnNode.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/ColumnNode.java
new file mode 100644 (file)
index 0000000..2894c03
--- /dev/null
@@ -0,0 +1,64 @@
+package com.quantum.view.bookmark;
+
+import com.quantum.model.Column;
+
+/**
+ * @author BC
+ */
+public class ColumnNode extends TreeNode {
+    
+    private Column column;
+    
+    public ColumnNode(TreeNode parent, Column column) {
+        super(parent);
+        this.column = column;
+    }
+
+    public Object[] getChildren() {
+        return BookmarkListNode.EMPTY_ARRAY;
+    }
+
+    public boolean hasChildren() {
+        return false;
+    }
+
+    public String getName() {
+        return this.column.getName();
+    }
+
+    protected String getImageName() {
+        return this.column.isPrimaryKey() ? "keycolumn.gif" : "column.gif";
+    }
+
+    public String getLabelName() {
+        String label = getName() + " : " + this.column.getTypeName(); //$NON-NLS-1$
+        if (this.column.isNumeric()) {
+            if (this.column.getSize() > 0 || this.column.getNumberOfFractionalDigits() > 0) {
+                label += "(" + Integer.toString(this.column.getSize()); //$NON-NLS-1$
+                if (this.column.getNumberOfFractionalDigits() > 0) {
+                    label += "," + Integer.toString(this.column.getNumberOfFractionalDigits()); //$NON-NLS-1$
+                }
+                label += ")"; //$NON-NLS-1$
+            }
+        } else if (this.column.getSize() > 0) {
+            label += "(" + Integer.toString(this.column.getSize()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+        }
+        return label;
+    }
+    /* (non-Javadoc)
+     * @see com.quantum.view.bookmark.TreeNode#initializeChildren()
+     */
+    protected void initializeChildren() {
+    }
+    protected boolean isInitialized() {
+        return true;
+    }
+
+    /**
+     * @return
+     */
+    public Column getColumn() {
+        return column;
+    }
+
+}