コード例 #1
0
  // ===============================================================
  // ===============================================================
  void putPoolThreadInfo() {
    //  ToDo
    //	Get configuration from tree
    int nbThreads = root.getChildCount();
    ArrayList<String> lines = new ArrayList<String>();
    for (int i = 0; i < root.getChildCount(); i++) {
      DefaultMutableTreeNode threadNode = (DefaultMutableTreeNode) root.getChildAt(i);
      int deviceNumber = threadNode.getChildCount();
      if (deviceNumber > 0) {
        String s = "";
        for (int j = 0; j < deviceNumber; j++) {
          s += threadNode.getChildAt(j).toString();
          if (j < deviceNumber - 1) s += ",";
        }
        lines.add(s);
      }
    }
    //  Check for maximum length of lines
    lines = manageMaxLength(lines);

    //	Convert tree to device(admin) property.
    String[] config = new String[lines.size()];
    for (int i = 0; i < lines.size(); i++) config[i] = lines.get(i);

    //	And send it to database.
    try {
      DbDatum[] argin = new DbDatum[2];
      argin[0] = new DbDatum(propertyNames[NB_THREADS], nbThreads);
      argin[1] = new DbDatum(propertyNames[THREADS_CONFIG], config);
      server.put_property(argin);
    } catch (DevFailed e) {
      ErrorPane.showErrorMessage(parent, null, e);
    }
  }
コード例 #2
0
 // ===============================================================
 // ===============================================================
 private DefaultMutableTreeNode getFutureSelectedNode(DefaultMutableTreeNode node) {
   //	Get the future selectd node, after remove.
   DefaultMutableTreeNode parent_node = (DefaultMutableTreeNode) node.getParent();
   DefaultMutableTreeNode ret_node = parent_node;
   for (int i = 0; i < parent_node.getChildCount(); i++) {
     DefaultMutableTreeNode child_node = (DefaultMutableTreeNode) parent_node.getChildAt(i);
     if (child_node == node) {
       if (i == parent_node.getChildCount() - 1) {
         if (i > 0) ret_node = (DefaultMutableTreeNode) parent_node.getChildAt(i - 1);
       } else ret_node = (DefaultMutableTreeNode) parent_node.getChildAt(i + 1);
     }
   }
   return ret_node;
 }
コード例 #3
0
 private ArrayList<TreeNode> childrenToArray(DefaultMutableTreeNode node) {
   ArrayList<TreeNode> arrayList = new ArrayList<TreeNode>();
   for (int i = 0; i < node.getChildCount(); i++) {
     arrayList.add(node.getChildAt(i));
   }
   return arrayList;
 }
コード例 #4
0
ファイル: TreeView.java プロジェクト: jexp/idea2
 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()));
   }
 }
コード例 #5
0
ファイル: TreeView.java プロジェクト: jexp/idea2
  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;
  }
コード例 #6
0
 // ===============================================================
 // ===============================================================
 private int getNextThreadNum() {
   int num = 0;
   for (int i = 0; i < root.getChildCount(); i++) {
     DefaultMutableTreeNode th_node = (DefaultMutableTreeNode) root.getChildAt(i);
     num = ((PollThread) th_node.getUserObject()).num;
   }
   return ++num;
 }
コード例 #7
0
ファイル: TreeUtil.java プロジェクト: jexp/idea2
 public static void sort(final DefaultMutableTreeNode node, final Comparator comparator) {
   final List<TreeNode> children = childrenToArray(node);
   Collections.sort(children, comparator);
   node.removeAllChildren();
   addChildrenTo(node, children);
   for (int i = 0; i < node.getChildCount(); i++) {
     sort((DefaultMutableTreeNode) node.getChildAt(i), comparator);
   }
 }
コード例 #8
0
 private static DefaultMutableTreeNode findInChildren(
     DefaultMutableTreeNode currentTreeNode, AbstractTreeNode topPathElement) {
   for (int i = 0; i < currentTreeNode.getChildCount(); i++) {
     TreeNode child = currentTreeNode.getChildAt(i);
     if (((DefaultMutableTreeNode) child).getUserObject().equals(topPathElement)) {
       return (DefaultMutableTreeNode) child;
     }
   }
   return null;
 }
コード例 #9
0
 // ===============================================================
 // ===============================================================
 private void expandChildren(DefaultMutableTreeNode node) {
   boolean level_done = false;
   for (int i = 0; i < node.getChildCount(); i++) {
     DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(i);
     if (child.isLeaf()) {
       if (!level_done) {
         expandNode(child);
         level_done = true;
       }
     } else expandChildren(child);
   }
 }
コード例 #10
0
 private void restoreUsageExpandState(final Collection<UsageState> states) {
   // always expand the last level group
   final DefaultMutableTreeNode root = (DefaultMutableTreeNode) myTree.getModel().getRoot();
   for (int i = root.getChildCount() - 1; i >= 0; i--) {
     final DefaultMutableTreeNode child = (DefaultMutableTreeNode) root.getChildAt(i);
     if (child instanceof GroupNode) {
       final TreePath treePath = new TreePath(child.getPath());
       myTree.expandPath(treePath);
     }
   }
   myTree.getSelectionModel().clearSelection();
   for (final UsageState usageState : states) {
     usageState.restore();
   }
 }
コード例 #11
0
ファイル: TreeUtil.java プロジェクト: jexp/idea2
 @Nullable
 public static DefaultMutableTreeNode findNodeWithObject(
     final DefaultMutableTreeNode aRoot, final Object aObject) {
   if (Comparing.equal(aRoot.getUserObject(), aObject)) {
     return aRoot;
   } else {
     for (int i = 0; i < aRoot.getChildCount(); i++) {
       final DefaultMutableTreeNode candidate =
           findNodeWithObject((DefaultMutableTreeNode) aRoot.getChildAt(i), aObject);
       if (null != candidate) {
         return candidate;
       }
     }
     return null;
   }
 }
コード例 #12
0
 private void captureUsagesExpandState(TreePath pathFrom, final Collection<UsageState> states) {
   if (!myTree.isExpanded(pathFrom)) {
     return;
   }
   final DefaultMutableTreeNode node = (DefaultMutableTreeNode) pathFrom.getLastPathComponent();
   final int childCount = node.getChildCount();
   for (int idx = 0; idx < childCount; idx++) {
     final TreeNode child = node.getChildAt(idx);
     if (child instanceof UsageNode) {
       final Usage usage = ((UsageNode) child).getUsage();
       states.add(
           new UsageState(
               usage,
               myTree.getSelectionModel().isPathSelected(pathFrom.pathByAddingChild(child))));
     } else {
       captureUsagesExpandState(pathFrom.pathByAddingChild(child), states);
     }
   }
 }
コード例 #13
0
 private DefaultMutableTreeNode findIDorURL(DefaultMutableTreeNode node, ID id, URL url) {
   SearchTOCItem item = (SearchTOCItem) node.getUserObject();
   if (item != null) {
     ID testID = item.getID();
     if (testID != null && id != null && testID.equals(id)) {
       return node;
     } else {
       URL testURL = item.getURL();
       if (testURL != null && url != null && url.sameFile(testURL)) {
         return node;
       }
     }
   }
   int size = node.getChildCount();
   for (int i = 0; i < size; i++) {
     DefaultMutableTreeNode tmp = (DefaultMutableTreeNode) node.getChildAt(i);
     DefaultMutableTreeNode test = findIDorURL(tmp, id, url);
     if (test != null) {
       return test;
     }
   }
   return null;
 }