Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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[] {});
      }
    }
  }
Ejemplo n.º 3
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);
     }
   }
 }