Ejemplo n.º 1
0
 // ////////////////////////////////////
 // DbRefreshListener SUPPORT
 //
 // Overridden
 public void refreshAfterDbUpdate(DbUpdateEvent evt) throws DbException {
   if (evt.metaField == DbObject.fComponents) { // add, remove, or move to
     // another parent
     if (evt.neighbor instanceof DbGraphicalObjectI) // optimization:
       // discard
       // immediately the
       // graphical objects
       return;
     if (evt.op == Db.REMOVE_FROM_RELN) {
       // DbObject removed or with a new parent: remove the node from
       // its old parent if loaded.
       DynamicNode node = getDynamicNode(evt.neighbor, Db.OLD_VALUE, false);
       if (node != null) removeNode(node);
     } else if (evt.op == Db.ADD_TO_RELN) {
       // DbObject added or with a new parent: if its new parent has
       // its chidren loaded,
       // add a node for the new child.
       getDynamicNode(evt.neighbor, false);
     } else { // Db.REINSERT_IN_RELN
       DynamicNode node = getDynamicNode(evt.neighbor, false);
       if ((node != null && !childrenAreSorted(evt.dbo))
           || (node != null && !node.getGroupParams().sorted)) {
         DynamicNode parentNode = (DynamicNode) node.getParent();
         updateInsertIndexInChildrenOfNode(parentNode);
         removeNodeFromParent(node);
         int index = getInsertionIndex(evt.dbo, evt.neighbor, parentNode, node);
         insertNodeInto(node, parentNode, index);
       }
     }
   }
   // name refresh
   else if (evt.metaField == DbSemanticalObject.fName || tooltipsFields.contains(evt.metaField)) {
     updateNode(evt.dbo);
   }
 }
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
 // Remove the group node if this node is the last of its group.
 protected final void removeNode(DynamicNode node) {
   DynamicNode parentNode = (DynamicNode) node.getParent();
   if (parentNode.getUserObject() instanceof GroupParams && getChildCount(parentNode) == 1)
     removeNodeFromParent(parentNode);
   else removeNodeFromParent(node);
 }