예제 #1
0
 /**
  * If CS application, create a root node with 2 subnodes: RAM and repository; the RAM subnode
  * contains the list of RAM projects as subnodes. If RAM application, create a root node with the
  * list of projects as subnodes.
  */
 private DynamicNode createRootNode() {
   DynamicNode rootNode = null;
   DynamicNode RAMNode = null;
   try {
     RAMNode = new DynamicNode(DB_RAM);
     RAMNode.setDisplayText(DbRAM.DISPLAY_NAME);
     RAMNode.setIcon(kLocalIcon);
     loadChildren(RAMNode);
     Db[] dbs = Db.getDbs();
     for (int i = 0; i < dbs.length; i++) {
       if (dbs[i] instanceof DbRAM) continue;
       if (rootNode == null) {
         rootNode = new DynamicNode(ROOT);
         rootNode.setHasLoaded();
         rootNode.add(RAMNode);
       }
       DynamicNode dbNode = new DynamicNode(dbs[i]);
       dbNode.setDisplayText(dbs[i].getDBMSName());
       dbNode.setIcon(kRepositoryIcon);
       rootNode.add(dbNode);
       loadChildren(dbNode);
     }
   } catch (DbException ex) {
     org.modelsphere.jack.util.ExceptionHandler.processUncatchedException(
         ApplicationContext.getDefaultMainFrame(), ex);
   }
   return (rootNode != null ? rootNode : RAMNode);
 }
예제 #2
0
 private DynamicNode createGroupNode(GroupParams group) {
   DynamicNode groupNode = new DynamicNode(group);
   groupNode.setDisplayText(group.name);
   groupNode.setIcon(group.icon);
   groupNode.setGroupParams(group);
   groupNode.setHasLoaded();
   return groupNode;
 }
예제 #3
0
 // Overridden
 protected DynamicNode createPrimaryNode(DbObject dbParent, DbObject dbo) throws DbException {
   DynamicNode node = new DynamicNode(dbo, getSequence(dbParent, dbo));
   String displayText = getDisplayText(dbParent, dbo);
   String editText = getEditText(dbParent, dbo);
   String tooltips = getToolTipsText(dbParent, dbo);
   node.setDisplayText(displayText, editText);
   node.setToolTips(tooltips);
   node.setIcon(getIcon(dbo));
   node.setGroupParams(getGroupParams(dbParent, dbo));
   node.setIsLeaf(isLeaf(dbParent, dbo));
   node.setDefaultAction(getDefaultAction(dbo));
   return node;
 }
예제 #4
0
  // This method refreshes the display text of a node.
  protected final void updateNode(DbObject dbo) throws DbException {
    DynamicNode node = getDynamicNode(dbo, false);
    if (node == null) return;

    // backup selection and restore later
    Object focusObject = ApplicationContext.getFocusManager().getFocusObject();
    TreePath[] selPaths = null;
    if (focusObject instanceof ExplorerView) {
      selPaths = ((ExplorerView) focusObject).getSelectionPaths();
    }

    String displayText = getDisplayText(null, dbo);
    String editText = getEditText(null, dbo);
    String toolTipText = getToolTipsText(null, dbo);
    Icon icon = getIcon(dbo);

    node.setDisplayText(displayText, editText);
    node.setToolTips(toolTipText);
    node.setIcon(icon);
    nodeChanged(node);
    DynamicNode parentNode = (DynamicNode) node.getParent();
    Object parent = parentNode.getUserObject();
    if (!(parent instanceof DbObject) || childrenAreSorted((DbObject) parent)) {
      removeNodeFromParent(node);
      int index = getSortedIndex(parentNode, node);
      insertNodeInto(node, parentNode, index);
    }

    // Restore selection
    if (focusObject instanceof ExplorerView && selPaths != null) {
      ExplorerView explorerView = (ExplorerView) focusObject;
      try { // Should not occurs
        explorerView.setSelectionPaths(selPaths);
      } catch (Exception e) {
        explorerView.setSelectionPaths(new TreePath[] {});
      }
    }
  }
예제 #5
0
 private void refreshNode(DynamicNode srcNode, DynamicNode parentNode, int index)
     throws DbException {
   DynamicNode dstNode = getDynamicNode(parentNode, srcNode.getUserObject(), index);
   if (dstNode == null) {
     insertNodeInto(srcNode, parentNode, index);
   } else {
     if (dstNode != getChild(parentNode, index)) {
       removeNodeFromParent(dstNode);
       insertNodeInto(dstNode, parentNode, index);
     }
     if (dstNode.getUserObject() instanceof DynamicNode) {
       nodeChanged(dstNode); // in case text of primary node has
       // changed
     } else if (!dstNode.toString().equals(srcNode.toString())
         || dstNode.getIcon() != srcNode.getIcon()
         || (dstNode.getToolTips() != null
             && !dstNode.getToolTips().equals(srcNode.getToolTips()))) {
       dstNode.setDisplayText(srcNode.toString(), srcNode.getEditText());
       dstNode.setIcon(srcNode.getIcon());
       dstNode.setToolTips(srcNode.getToolTips());
       nodeChanged(dstNode);
     }
   }
 }