Refactory: remove unused classes, imports, fields and methods.
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / bookmark / GroupNode.java
index 1064faa..354edd3 100644 (file)
@@ -1,10 +1,7 @@
-/*
- * Created on 27/06/2003
- *
- */
 package com.quantum.view.bookmark;
 
 import java.sql.SQLException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -25,12 +22,17 @@ import com.quantum.model.SchemaHolder;
 public class GroupNode extends TreeNode implements Comparable, SchemaHolder {
        private String type = null;
     private Schema schema = null;
+    private boolean initialized = false;
 
        public GroupNode(TreeNode parent, Schema schema, String type) {
         super(parent);
         this.schema = schema;
                this.type = type;
        }
+       
+       protected boolean isInitialized() {
+               return this.initialized;
+       }
        public boolean hasChildren() {
                if (!isInitialized()) {
                        return true;
@@ -47,7 +49,6 @@ public class GroupNode extends TreeNode implements Comparable, SchemaHolder {
     protected void initializeChildren() {
         try {
             boolean firstTimeInitialization = !isInitialized();
-            boolean changed = false;
             Map temp = new HashMap();
             for (Iterator i = this.children.iterator(); i.hasNext();) {
                 TreeNode treeNode = (TreeNode) i.next();
@@ -66,14 +67,21 @@ public class GroupNode extends TreeNode implements Comparable, SchemaHolder {
                 EntityNode entityNode = (EntityNode) temp.remove(name);
                 if (entityNode == null) {
                     this.children.add(new EntityNode(this, entities[i]));
-                    changed = true;
                 } else {
+                       entityNode.setEntity(entities[i]);
                     this.children.add(entityNode);
                 }
             }
-            if (changed && !firstTimeInitialization) {
+            for (Iterator i = temp.values().iterator(); i.hasNext();) {
+                               ((TreeNode) i.next()).dispose();
+                       }
+            
+            Collections.sort(this.children);
+            if (!firstTimeInitialization) {
                 firePropertyChange("children", null, null);
             }
+            
+            this.initialized = true;
         } catch (SQLException e) {
         }
     }
@@ -89,4 +97,7 @@ public class GroupNode extends TreeNode implements Comparable, SchemaHolder {
     public Schema getSchema() {
         return schema;
     }
+       public String getType() {
+               return this.type;
+       }
 }