X-Git-Url: http://git.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/SchemaNode.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/SchemaNode.java index 6b44cda..5181d2e 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/SchemaNode.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/SchemaNode.java @@ -1,6 +1,9 @@ package com.quantum.view.bookmark; import java.sql.SQLException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; import com.quantum.model.Bookmark; import com.quantum.model.NotConnectedException; @@ -37,14 +40,35 @@ public class SchemaNode extends TreeNode implements SchemaHolder { } protected void initializeChildren() { + boolean firstTimeInitialization = this.children.isEmpty(); + boolean changed = false; + Map temp = new HashMap(); + for (Iterator i = this.children.iterator(); i.hasNext();) { + GroupNode element = (GroupNode) i.next(); + temp.put(element.getType(), element); + } this.children.clear(); + Bookmark bookmark = getBookmark(); try { String[] types = bookmark.getDatabase().getEntityTypes(); for (int i = 0, length = (types == null) ? 0 : types.length; i < length; i++) { - this.children.add(new GroupNode(this, this.schema, types[i])); + GroupNode node = (GroupNode) temp.remove(types[i]); + if (node == null) { + this.children.add(new GroupNode(this, this.schema, types[i])); + changed = true; + } else { + this.children.add(node); + } + } + for (Iterator i = temp.values().iterator(); i.hasNext();) { + ((GroupNode) i.next()).dispose(); + changed = true; + } + if (!firstTimeInitialization && changed) { + firePropertyChange("children", null, null); } } catch (NotConnectedException e) { } catch (SQLException e) { @@ -69,7 +93,9 @@ public class SchemaNode extends TreeNode implements SchemaHolder { * @see com.quantum.view.bookmark.TreeNode#getImageName() */ protected String getImageName() { - return this.schema.isDefault() ? "user.gif" : "schema.gif"; + return this.schema.exists() + ? "schema.gif" + : "missingschema.gif"; } /**