void onEdit() {
    DefaultTreeModel model = (DefaultTreeModel) m_tree.getModel();
    TreePath path = m_tree.getSelectionPath();
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
    DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();
    Organization org = (Organization) node.getUserObject();
    OrganizationEditorDlg dlg = null;

    if (parent == model.getRoot())
      dlg =
          new OrganizationEditorDlg(
              pohaci.gumunda.cgui.GumundaMainFrame.getMainFrame(), m_conn, m_sessionid, null, org);
    else
      dlg =
          new OrganizationEditorDlg(
              pohaci.gumunda.cgui.GumundaMainFrame.getMainFrame(),
              m_conn,
              m_sessionid,
              (DefaultMutableTreeNode) node.getParent(),
              org);
    dlg.setVisible(true);

    if (dlg.getResponse() == JOptionPane.OK_OPTION) {
      node.setUserObject(dlg.getOrganization());
      model.nodeChanged(node);
    }
  }
  public void updateModel(
      List<? extends ChangeList> changeLists,
      Trinity<List<VirtualFile>, Integer, Integer> unversionedFiles,
      final List<LocallyDeletedChange> locallyDeletedFiles,
      List<VirtualFile> modifiedWithoutEditing,
      MultiMap<String, VirtualFile> switchedFiles,
      @Nullable Map<VirtualFile, String> switchedRoots,
      @Nullable List<VirtualFile> ignoredFiles,
      final List<VirtualFile> lockedFolders,
      @Nullable final Map<VirtualFile, LogicalLock> logicallyLockedFiles) {
    TreeModelBuilder builder = new TreeModelBuilder(myProject, isShowFlatten());
    final DefaultTreeModel model =
        builder.buildModel(
            changeLists,
            unversionedFiles,
            locallyDeletedFiles,
            modifiedWithoutEditing,
            switchedFiles,
            switchedRoots,
            ignoredFiles,
            lockedFolders,
            logicallyLockedFiles);

    storeState();
    DefaultTreeModel oldModel = getModel();
    setModel(model);
    setCellRenderer(new ChangesBrowserNodeRenderer(myProject, isShowFlatten(), true));
    ChangesBrowserNode root = (ChangesBrowserNode) model.getRoot();
    expandPath(new TreePath(root.getPath()));
    restoreState();
    expandDefaultChangeList(oldModel, root);
  }
 void deleteNode(DefaultMutableTreeNode node) throws Exception {
   DefaultTreeModel model = (DefaultTreeModel) m_tree.getModel();
   HRMBusinessLogic logic = new HRMBusinessLogic(m_conn);
   logic.orgLogic.deleteOrganization(
       logic, m_sessionid, IDBConstants.MODUL_MASTER_DATA, ((Organization) node.getUserObject()));
   model.removeNodeFromParent(node);
 }
  /**
   * Update the layouts tree.
   *
   * @param current The name of the current layout or <CODE>null</CODE> if none.
   */
  public void updateLayouts(Path current) throws PipelineException {
    DefaultMutableTreeNode root = null;
    {
      root = new DefaultMutableTreeNode(new TreeData(), true);

      {
        Path path = new Path(PackageInfo.getSettingsPath(), "layouts");
        rebuildTreeModel(path, new Path("/"), root);
      }

      DefaultTreeModel model = (DefaultTreeModel) pTree.getModel();
      model.setRoot(root);

      {
        Enumeration e = root.depthFirstEnumeration();
        if (e != null) {
          while (e.hasMoreElements()) {
            DefaultMutableTreeNode tnode = (DefaultMutableTreeNode) e.nextElement();
            pTree.expandPath(new TreePath(tnode.getPath()));
          }
        }
      }
    }

    pTree.clearSelection();
    if (current != null) {
      TreePath tpath = null;
      DefaultMutableTreeNode tnode = root;
      for (String comp : current.getComponents()) {
        DefaultMutableTreeNode next = null;
        Enumeration e = tnode.children();
        if (e != null) {
          while (e.hasMoreElements()) {
            DefaultMutableTreeNode child = (DefaultMutableTreeNode) e.nextElement();
            TreeData data = (TreeData) child.getUserObject();
            if (data.toString().equals(comp)) {
              tpath = new TreePath(child.getPath());
              next = child;
              break;
            }
          }
        }

        if (next == null) break;

        tnode = next;
      }

      if (tpath != null) {
        pTree.setSelectionPath(tpath);
        pTree.makeVisible(tpath);
      }
    }
  }
  // ===============================================================
  // ===============================================================
  private void moveLeaf(
      DefaultMutableTreeNode collec_node, DefaultMutableTreeNode leaf_node, int pos) {
    Object obj = collec_node.getUserObject();
    if (obj instanceof PollThread) {
      treeModel.removeNodeFromParent(leaf_node);
      if (pos < 0) treeModel.insertNodeInto(leaf_node, collec_node, collec_node.getChildCount());
      else treeModel.insertNodeInto(leaf_node, collec_node, pos);

      expandNode(leaf_node);
    }
  }
Exemple #6
0
 private void collapseTargets() {
   DefaultMutableTreeNode root = (DefaultMutableTreeNode) myTreeModel.getRoot();
   for (int i = 0; i < root.getChildCount(); i++) {
     DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(i);
     myTree.collapsePath(new TreePath(node.getPath()));
   }
 }
 public void update() {
   if (myFileSystemTree != null) {
     myFileSystemTree.updateTree();
     final DefaultTreeModel model = (DefaultTreeModel) myTree.getModel();
     final int visibleRowCount = myTree.getVisibleRowCount();
     for (int row = 0; row < visibleRowCount; row++) {
       final TreePath pathForRow = myTree.getPathForRow(row);
       if (pathForRow != null) {
         final TreeNode node = (TreeNode) pathForRow.getLastPathComponent();
         if (node != null) {
           model.nodeChanged(node);
         }
       }
     }
   }
 }
  // ===============================================================
  // ===============================================================
  DefaultMutableTreeNode addThreadNode() {

    PollThread new_thread = new PollThread(getNextThreadNum());
    DefaultMutableTreeNode node = new DefaultMutableTreeNode(new_thread);
    treeModel.insertNodeInto(node, root, root.getChildCount());
    return node;
  }
Exemple #9
0
  // {{{ removeSelectedNode() method
  private void removeSelectedNode() {
    TreePath path = resultTree.getSelectionPath();
    if (path == null) return;

    MutableTreeNode value = (MutableTreeNode) path.getLastPathComponent();

    if (path.getPathCount() > 1) {
      // Adjust selection so that repeating some removals
      // behave naturally.
      TreePath parentPath = path.getParentPath();
      MutableTreeNode parent = (MutableTreeNode) parentPath.getLastPathComponent();
      int removingIndex = parent.getIndex(value);
      int nextIndex = removingIndex + 1;
      if (nextIndex < parent.getChildCount()) {
        TreeNode next = parent.getChildAt(nextIndex);
        resultTree.setSelectionPath(parentPath.pathByAddingChild(next));
      } else {
        resultTree.setSelectionPath(parentPath);
      }

      resultTreeModel.removeNodeFromParent(value);
    }

    HyperSearchOperationNode.removeNodeFromCache(value);
    if (resultTreeRoot.getChildCount() == 0) {
      hideDockable();
    }
  } // }}}
Exemple #10
0
  public boolean restoreSelection(TreeSelection treeSelection) {
    if (treeSelection.isEmpty()) return false;

    DefaultMutableTreeNode root = (DefaultMutableTreeNode) myTreeModel.getRoot();
    for (int i = 0; i < root.getChildCount(); i++) {
      TreeNode node = root.getChildAt(i);
      if (node instanceof MessageNode) {
        MessageNode messageNode = (MessageNode) node;
        String[] text = messageNode.getText();
        if (text.length == 0) continue;
        if (Comparing.equal(treeSelection.mySelectedTarget, text[0])) {
          TreePath pathToSelect = new TreePath(messageNode.getPath());
          for (Enumeration enumeration = messageNode.children(); enumeration.hasMoreElements(); ) {
            Object o = enumeration.nextElement();
            if (o instanceof MessageNode) {
              messageNode = (MessageNode) o;
              if (Comparing.equal(treeSelection.mySelectedTask, text[0])) {
                pathToSelect = new TreePath(messageNode.getPath());
                break;
              }
            }
          }
          TreeUtil.selectPath(myTree, pathToSelect);
          myTree.expandPath(pathToSelect);
          return true;
        }
      }
    }

    return false;
  }
Exemple #11
0
 private static IndexTreePathState removeLastPathComponent(
     final DefaultTreeModel model, final TreePath pathToBeRemoved) {
   final IndexTreePathState selectionState = new IndexTreePathState(pathToBeRemoved);
   if (((MutableTreeNode) pathToBeRemoved.getLastPathComponent()).getParent() == null)
     return selectionState;
   model.removeNodeFromParent((MutableTreeNode) pathToBeRemoved.getLastPathComponent());
   return selectionState;
 }
Exemple #12
0
  private void addJavacMessageImpl(AntMessage message) {
    MutableTreeNode parentNode = (MutableTreeNode) myParentPath.getLastPathComponent();
    MessageNode messageNode = new MessageNode(message, myProject, false);

    myTreeModel.insertNodeInto(messageNode, parentNode, parentNode.getChildCount());
    myMessageItems.add(messageNode);

    handleExpansion();
  }
Exemple #13
0
  public Object addMessage(AntMessage message) {
    MessageNode messageNode = createMessageNode(message);

    MutableTreeNode parentNode = (MutableTreeNode) myParentPath.getLastPathComponent();
    myTreeModel.insertNodeInto(messageNode, parentNode, parentNode.getChildCount());
    myMessageItems.add(messageNode);

    handleExpansion();
    return messageNode;
  }
  /* Simple tree node factory method - set's parent and user object.
   */
  private DefaultMutableTreeNode makeNode(Object userObject, MutableTreeNode parent) {

    DefaultMutableTreeNode node = new DefaultMutableTreeNode(userObject);

    if (parent != null) {
      treeModel.insertNodeInto(node, parent, parent.getChildCount());
    }

    return node;
  }
    public void nodeAdded(String fqn) {
      MyNode n, p;

      n = root.add(fqn);
      if (n != null) {
        p = (MyNode) n.getParent();
        tree_model.reload(p);
        jtree.scrollPathToVisible(new TreePath(n.getPath()));
      }
    }
  protected void doSort() {
    Pair<ElementNode, List<ElementNode>> pair = storeSelection();

    Enumeration<ParentNode> children = getRootNodeChildren();
    while (children.hasMoreElements()) {
      ParentNode classNode = children.nextElement();
      sortNode(classNode, myComparator);
      myTreeModel.nodeStructureChanged(classNode);
    }

    restoreSelection(pair);
  }
    public void nodeRemoved(String fqn) {
      MyNode n;
      TreeNode par;

      n = root.findNode(fqn);
      if (n != null) {
        n.removeAllChildren();
        par = n.getParent();
        n.removeFromParent();
        tree_model.reload(par);
      }
    }
  /** Removes the current selected group. */
  final void removeSelectedGroup() {
    TreePath[] selectionPaths = this.tree.getSelectionPaths();
    if (selectionPaths == null) {
      return;
    }

    DefaultTreeModel model = (DefaultTreeModel) this.tree.getModel();
    ElementTreeNode rootNode = (ElementTreeNode) model.getRoot();

    for (TreePath selectionPath : selectionPaths) {
      ElementTreeNode treeNode = (ElementTreeNode) selectionPath.getLastPathComponent();
      if (treeNode.getUserObject() instanceof ElementGroup) {
        ElementGroup elementGroup = (ElementGroup) treeNode.getUserObject();

        this.model.removeGroup(elementGroup);

        model.nodesWereRemoved(
            rootNode, new int[] {rootNode.getIndex(treeNode)}, new Object[] {treeNode});
      }
    }
  }
    public void mouseReleased(MouseEvent e) {
      if (e.isPopupTrigger()) {
        DefaultTreeModel model = (DefaultTreeModel) m_tree.getModel();
        TreePath path = m_tree.getSelectionPath();
        if (path != null) {
          DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();

          if (node == model.getRoot()) {
            mi_add.setEnabled(true);
            mi_edit.setEnabled(false);
            mi_delete.setEnabled(false);
          } else {
            mi_add.setEnabled(true);
            mi_edit.setEnabled(true);
            mi_delete.setEnabled(true);
          }

          Rectangle rectangle = m_tree.getPathBounds(path);
          if (rectangle.contains(e.getPoint())) m_popupMenu.show(m_tree, e.getX(), e.getY());
        }
      }
    }
  protected void restoreTree() {
    Pair<ElementNode, List<ElementNode>> selection = storeSelection();

    DefaultMutableTreeNode root = getRootNode();
    if (!myShowClasses || myContainerNodes.isEmpty()) {
      List<ParentNode> otherObjects = new ArrayList<ParentNode>();
      Enumeration<ParentNode> children = getRootNodeChildren();
      ParentNode newRoot =
          new ParentNode(
              null, new MemberChooserObjectBase(getAllContainersNodeName()), new Ref<Integer>(0));
      while (children.hasMoreElements()) {
        final ParentNode nextElement = children.nextElement();
        if (nextElement instanceof ContainerNode) {
          final ContainerNode containerNode = (ContainerNode) nextElement;
          Enumeration<MemberNode> memberNodes = containerNode.children();
          List<MemberNode> memberNodesList = new ArrayList<MemberNode>();
          while (memberNodes.hasMoreElements()) {
            memberNodesList.add(memberNodes.nextElement());
          }
          for (MemberNode memberNode : memberNodesList) {
            newRoot.add(memberNode);
          }
        } else {
          otherObjects.add(nextElement);
        }
      }
      replaceChildren(root, otherObjects);
      sortNode(newRoot, myComparator);
      if (newRoot.children().hasMoreElements()) root.add(newRoot);
    } else {
      Enumeration<ParentNode> children = getRootNodeChildren();
      while (children.hasMoreElements()) {
        ParentNode allClassesNode = children.nextElement();
        Enumeration<MemberNode> memberNodes = allClassesNode.children();
        ArrayList<MemberNode> arrayList = new ArrayList<MemberNode>();
        while (memberNodes.hasMoreElements()) {
          arrayList.add(memberNodes.nextElement());
        }
        Collections.sort(arrayList, myComparator);
        for (MemberNode memberNode : arrayList) {
          myNodeToParentMap.get(memberNode).add(memberNode);
        }
      }
      replaceChildren(root, myContainerNodes);
    }
    myTreeModel.nodeStructureChanged(root);

    defaultExpandTree();

    restoreSelection(selection);
  }
Exemple #21
0
 public void addMessages(AntMessage[] messages) {
   DefaultMutableTreeNode parentNode =
       (DefaultMutableTreeNode) myParentPath.getLastPathComponent();
   int[] indices = new int[messages.length];
   for (int i = 0; i < messages.length; i++) {
     AntMessage message = messages[i];
     MessageNode messageNode = createMessageNode(message);
     indices[i] = parentNode.getChildCount();
     parentNode.insert(messageNode, indices[i]);
     myMessageItems.add(messageNode);
   }
   myTreeModel.nodesWereInserted(parentNode, indices);
   handleExpansion();
 }
  void onAdd() {
    DefaultTreeModel model = (DefaultTreeModel) m_tree.getModel();
    TreePath path = m_tree.getSelectionPath();
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
    OrganizationEditorDlg dlg = null;

    if (node == model.getRoot())
      dlg =
          new OrganizationEditorDlg(
              pohaci.gumunda.cgui.GumundaMainFrame.getMainFrame(), m_conn, m_sessionid, null);
    else
      dlg =
          new OrganizationEditorDlg(
              pohaci.gumunda.cgui.GumundaMainFrame.getMainFrame(), m_conn, m_sessionid, node);
    dlg.setVisible(true);

    if (dlg.getResponse() == JOptionPane.OK_OPTION) {
      Organization org = new Organization(dlg.getOrganization(), dlg.getOrganization().getCode());
      DefaultMutableTreeNode child = new DefaultMutableTreeNode(org);
      model.insertNodeInto(child, node, node.getChildCount());
      m_tree.scrollPathToVisible(new TreePath(model.getPathToRoot(child)));
    }
  }
  /** Adds a new group to our tree and element model. */
  final void addNewGroup() {
    DefaultTreeModel model = (DefaultTreeModel) this.tree.getModel();

    boolean groupSummaryVisibleByDefault = UIManager.getBoolean(GROUP_SUMMARY_VISIBLE_DEFAULT);
    boolean scopeVisibleByDefault = UIManager.getBoolean(ANALOG_SCOPE_VISIBLE_DEFAULT);

    int groupCount = this.model.getGroups().size();
    String name = String.format("Group %d", Integer.valueOf(groupCount + 1));

    // Create model structure...
    ElementGroup newGroup = this.model.addGroup(name);
    newGroup.setVisible(true);

    SignalElement groupSummaryElement = SignalElement.createGroupSummaryElement(newGroup);
    groupSummaryElement.setEnabled(groupSummaryVisibleByDefault);
    newGroup.addElement(groupSummaryElement);

    SignalElement analogScopeElement = SignalElement.createAnalogScopeElement(newGroup);
    analogScopeElement.setEnabled(scopeVisibleByDefault);
    newGroup.addElement(analogScopeElement);

    // Create tree structure...
    ElementTreeNode rootNode = (ElementTreeNode) model.getRoot();

    ElementTreeNode groupNode = new ElementTreeNode(newGroup);
    rootNode.add(groupNode);

    groupNode.add(new ElementTreeNode(groupSummaryElement));
    groupNode.add(new ElementTreeNode(analogScopeElement));

    int index = rootNode.getIndex(groupNode);

    model.nodesWereInserted(rootNode, new int[] {index});
    model.nodeStructureChanged(groupNode);

    this.tree.expandRow(index);
  }
Exemple #24
0
  public void addException(AntMessage exception, boolean showFullTrace) {
    MessageNode exceptionRootNode = null;

    StringTokenizer tokenizer = new StringTokenizer(exception.getText(), "\r\n");
    while (tokenizer.hasMoreElements()) {
      String line = (String) tokenizer.nextElement();
      if (exceptionRootNode == null) {
        AntMessage newMessage =
            new AntMessage(
                exception.getType(),
                exception.getPriority(),
                line,
                exception.getFile(),
                exception.getLine(),
                exception.getColumn());
        exceptionRootNode = new MessageNode(newMessage, myProject, true);
        myMessageItems.add(exceptionRootNode);
      } else if (showFullTrace) {
        if (StringUtil.startsWithChar(line, '\t')) {
          line = line.substring(1);
        }

        HyperlinkUtil.PlaceInfo info = HyperlinkUtil.parseStackLine(myProject, '\t' + line);
        VirtualFile file = info != null ? info.getFile() : null;
        int lineNumber = info != null ? info.getLine() : 0;
        int column = info != null ? info.getColumn() : 1;
        AntMessage newMessage =
            new AntMessage(
                exception.getType(), exception.getPriority(), line, file, lineNumber, column);
        MessageNode child = new MessageNode(newMessage, myProject, false);
        exceptionRootNode.add(child);
        myMessageItems.add(child);
      }
    }
    if (exceptionRootNode == null) return;

    MutableTreeNode parentNode = (MutableTreeNode) myParentPath.getLastPathComponent();
    myTreeModel.insertNodeInto(exceptionRootNode, parentNode, parentNode.getChildCount());

    handleExpansion();
  }
  private void expandDefaultChangeList(DefaultTreeModel oldModel, ChangesBrowserNode root) {
    if (((ChangesBrowserNode) oldModel.getRoot()).getCount() == 0
        && TreeUtil.collectExpandedPaths(this).size() == 1) {
      TreeNode toExpand = null;
      for (int i = 0; i < root.getChildCount(); i++) {
        TreeNode node = root.getChildAt(i);
        if (node instanceof ChangesBrowserChangeListNode && node.getChildCount() > 0) {
          ChangeList object = ((ChangesBrowserChangeListNode) node).getUserObject();
          if (object instanceof LocalChangeList) {
            if (((LocalChangeList) object).isDefault()) {
              toExpand = node;
              break;
            }
          }
        }
      }

      if (toExpand != null) {
        expandPath(new TreePath(new Object[] {root, toExpand}));
      }
    }
  }
  // ===============================================================
  // ===============================================================
  void removeThread() {
    DefaultMutableTreeNode node = getSelectedNode();

    if (node != null) {
      Object obj = node.getUserObject();
      if (obj instanceof PollThread) {
        //	Check if device(s) associated.
        if (node.getChildCount() == 0) {
          //	get future selected node
          DefaultMutableTreeNode next_node = getFutureSelectedNode(node);
          //	Remove selected one
          treeModel.removeNodeFromParent(node);
          PollThread pt = (PollThread) obj;
          threadsInfo.remove(pt);
          //	And select the found node
          TreeNode[] tree_node = next_node.getPath();
          TreePath path = new TreePath(tree_node);
          setSelectionPath(path);
          scrollPathToVisible(path);
        } else Utils.popupError(parent, "Cannot remove a not empty thread !");
      }
    }
  }
 protected DefaultMutableTreeNode getRootNode() {
   return (DefaultMutableTreeNode) myTreeModel.getRoot();
 }
Exemple #28
0
 public void setActionsEnabled(boolean actionsEnabled) {
   myActionsEnabled = actionsEnabled;
   if (actionsEnabled) {
     myTreeModel.reload();
   }
 }
Exemple #29
0
 public void finishBuild(String messageText) {
   collapseTargets();
   DefaultMutableTreeNode root = (DefaultMutableTreeNode) myTreeModel.getRoot();
   myStatusNode = new DefaultMutableTreeNode(messageText);
   myTreeModel.insertNodeInto(myStatusNode, root, root.getChildCount());
 }
Exemple #30
0
 public void scrollToFirstError() {
   TreePath path = getFirstErrorPath(new TreePath(myTreeModel.getRoot()));
   if (path != null) {
     TreeUtil.selectPath(myTree, path);
   }
 }