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;
}
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) {
* @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";
}
/**