private void updateParentUserObject(DefaultMutableTreeNode parent) {
   String label = ((CheckBoxNode) parent.getUserObject()).label;
   int selectedCount = 0;
   int indeterminateCount = 0;
   Enumeration children = parent.children();
   while (children.hasMoreElements()) {
     DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement();
     CheckBoxNode check = (CheckBoxNode) node.getUserObject();
     if (check.status == Status.INDETERMINATE) {
       indeterminateCount++;
       break;
     }
     if (check.status == Status.SELECTED) {
       selectedCount++;
     }
   }
   onCheckboxStatusChanged(parent);
   if (indeterminateCount > 0) {
     parent.setUserObject(new CheckBoxNode(label));
   } else if (selectedCount == 0) {
     parent.setUserObject(new CheckBoxNode(label, Status.DESELECTED));
   } else if (selectedCount == parent.getChildCount()) {
     parent.setUserObject(new CheckBoxNode(label, Status.SELECTED));
   } else {
     parent.setUserObject(new CheckBoxNode(label));
   }
 }
示例#2
0
  /** set labels on the tree */
  protected void setTreeLabels() {
    switch (getTreeMode()) {
      case DEPENDENCY:
        indNode.setUserObject(app.getPlain("FreeObjects"));
        model.nodeChanged(indNode);

        depNode.setUserObject(app.getPlain("DependentObjects"));
        model.nodeChanged(depNode);

        auxiliaryNode.setUserObject(app.getPlain("AuxiliaryObjects"));
        model.nodeChanged(auxiliaryNode);
        break;
      case TYPE:
        DefaultMutableTreeNode node;
        for (String key : typeNodesMap.keySet()) {
          node = typeNodesMap.get(key);
          node.setUserObject(app.getPlain(key));
          model.nodeChanged(node);
        }
        break;
      case LAYER:
        for (Integer key : layerNodesMap.keySet()) {
          node = layerNodesMap.get(key);
          node.setUserObject(app.getPlain("LayerA", key.toString()) + "TODO" + key);
          model.nodeChanged(node);
        }
        break;
      case ORDER:
        model.nodeChanged(rootOrder);
        break;
    }
  }
  public int createTreeFromMenuBar(
      javax.swing.MenuElement subElements[],
      javax.swing.tree.DefaultMutableTreeNode treeNodes,
      javax.swing.tree.DefaultMutableTreeNode topReports,
      java.lang.String reportNodeTitle,
      java.lang.String utilitiesNodeTitle) {

    for (int i = 0; i < subElements.length; i++) {

      if (subElements[i].getClass().getName() != "javax.swing.JPopupMenu") {

        javax.swing.JMenuItem abstractButton = (javax.swing.JMenuItem) subElements[i];

        if (abstractButton.isEnabled()) {

          siblingNode = new javax.swing.tree.DefaultMutableTreeNode(abstractButton.getText());

          treeNodes.add(siblingNode);

          if (treeNodes.getUserObject() == "Reports") {

            treeNodes.setUserObject(reportNodeTitle);

            topReports.add(treeNodes);
          }

          if (treeNodes.getUserObject() == "Utility") {

            treeNodes.setUserObject(utilitiesNodeTitle);

            topReports.add(treeNodes);
          }
        }
      }

      if (subElements[i].getSubElements().length > 0) {

        createTreeFromMenuBar(
            subElements[i].getSubElements(),
            siblingNode,
            topReports,
            reportNodeTitle,
            utilitiesNodeTitle);

        if (treeNodes.isLeaf()) {

          javax.swing.tree.DefaultMutableTreeNode parentNode =
              (javax.swing.tree.DefaultMutableTreeNode) siblingNode.getParent();

          siblingNode.removeFromParent();
        }
      }

      treeCount++;
    }

    return treeCount;
  }
  protected boolean doSetIcon(
      DefaultMutableTreeNode node, @Nullable String path, Component component) {
    if (StringUtil.isNotEmpty(path) && !new File(path).isFile()) {
      Messages.showErrorDialog(
          component,
          IdeBundle.message("error.file.not.found.message", path),
          IdeBundle.message("title.choose.action.icon"));
      return false;
    }

    String actionId = getActionId(node);
    if (actionId == null) return false;

    final AnAction action = ActionManager.getInstance().getAction(actionId);
    if (action != null && action.getTemplatePresentation() != null) {
      if (StringUtil.isNotEmpty(path)) {
        Image image = null;
        try {
          image =
              ImageLoader.loadFromStream(
                  VfsUtil.convertToURL(VfsUtil.pathToUrl(path.replace(File.separatorChar, '/')))
                      .openStream());
        } catch (IOException e) {
          LOG.debug(e);
        }
        Icon icon = new File(path).exists() ? IconLoader.getIcon(image) : null;
        if (icon != null) {
          if (icon.getIconWidth() > EmptyIcon.ICON_18.getIconWidth()
              || icon.getIconHeight() > EmptyIcon.ICON_18.getIconHeight()) {
            Messages.showErrorDialog(
                component,
                IdeBundle.message("custom.icon.validation.message"),
                IdeBundle.message("title.choose.action.icon"));
            return false;
          }
          node.setUserObject(Pair.create(actionId, icon));
          mySelectedSchema.addIconCustomization(actionId, path);
        }
      } else {
        node.setUserObject(Pair.create(actionId, null));
        mySelectedSchema.removeIconCustomization(actionId);
        final DefaultMutableTreeNode nodeOnToolbar = findNodeOnToolbar(actionId);
        if (nodeOnToolbar != null) {
          editToolbarIcon(actionId, nodeOnToolbar);
          node.setUserObject(nodeOnToolbar.getUserObject());
        }
      }
      return true;
    }
    return false;
  }
  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);
    }
  }
示例#6
0
    public void actionPerformed(ActionEvent arg0) {
      DefaultMutableTreeNode curTreeNode =
          (DefaultMutableTreeNode) treWhere.getLastSelectedPathComponent();
      if (curTreeNode == null || !curTreeNode.isLeaf()) return;

      Caliber cal = (Caliber) curTreeNode.getUserObject();
      IStatisticCaliber myCaliber = cal.getACal();
      if (!(myCaliber instanceof ICustomStatisticCaliber)) {
        ICustomStatisticCaliber caliberTmp = new MySummaryStatisticCaliberImpl();
        caliberTmp.setAddSQL(myCaliber.getAddSQL());
        caliberTmp.setCompareType(myCaliber.getCompareType());
        caliberTmp.setJoinBefore(myCaliber.getJoinBefore());
        caliberTmp.setSourceColID(myCaliber.getSourceColID());
        caliberTmp.setSourceID(myCaliber.getSourceID());
        caliberTmp.setValue(myCaliber.getValue());
        caliberTmp.setCaliberID(DefinePub.getRandomUUID());
        cal.setACal(caliberTmp);
      }

      myCaliber = cal.getACal();
      if (((ICustomStatisticCaliber) myCaliber).getRParenthesis() != null) {
        ((ICustomStatisticCaliber) myCaliber)
            .setRParenthesis(((ICustomStatisticCaliber) cal.getACal()).getRParenthesis() + ")");
      } else {
        ((ICustomStatisticCaliber) myCaliber).setRParenthesis(")");
      }
      curTreeNode.setUserObject(cal);
      // 刷新节点中文名称
      refreshNodeChName(curTreeNode);
      // 刷新节点
      ((DefaultTreeModel) treWhere.getModel()).nodeChanged(curTreeNode);
    }
 @NotNull
 private DefaultMutableTreeNode addPackage(PsiPackage aPackage) {
   final String qualifiedPackageName = aPackage.getQualifiedName();
   final PsiPackage parentPackage = aPackage.getParentPackage();
   if (parentPackage == null) {
     final DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) myModel.getRoot();
     if (qualifiedPackageName.length() == 0) {
       rootNode.setUserObject(aPackage);
       return rootNode;
     } else {
       DefaultMutableTreeNode packageNode = findPackageNode(rootNode, qualifiedPackageName);
       if (packageNode != null) return packageNode;
       packageNode = new DefaultMutableTreeNode(aPackage);
       rootNode.add(packageNode);
       return packageNode;
     }
   } else {
     final DefaultMutableTreeNode parentNode = addPackage(parentPackage);
     DefaultMutableTreeNode packageNode = findPackageNode(parentNode, qualifiedPackageName);
     if (packageNode != null) {
       return packageNode;
     }
     packageNode = new DefaultMutableTreeNode(aPackage);
     parentNode.add(packageNode);
     return packageNode;
   }
 }
  private void addItemToNode(
      DefaultMutableTreeNode node, ArmylistWargearItem item, ArmylistWargearGroup group) {
    DefaultMutableTreeNode newNode = new DefaultMutableTreeNode();

    WargearTreeUserObjectContainer container =
        new WargearTreeUserObjectContainer(item, newNode, node);
    container.setItemGroup(group);
    newNode.setUserObject(container);

    node.add(newNode);

    /*Iterator subGroups = group.getSubGroups().iterator();
    while(subGroups.hasNext()){
        ArmylistWargearGroup subGroup = (ArmylistWargearGroup)subGroups.next();
        this.addGroupToNode(newNode, subGroup);
    }

    Iterator items = group.getItems().iterator();
    while(items.hasNext()){
        DefaultMutableTreeNode temp = new DefaultMutableTreeNode();
        ArmylistWargearItem item = (ArmylistWargearItem)items.next();
        WargearTreeUserObjectContainer container = new WargearTreeUserObjectContainer(item, temp, newNode);
        container.setItemGroup(group);
        temp.setUserObject(container);
        newNode.add(temp);
    }*/

  }
  /**
   * @param node
   * @return
   */
  @Pure
  @Nonnull
  @CheckReturnValue
  public static DefaultMutableTreeNode deepCloneNode(
      final DefaultMutableTreeNode node, final Function<Object, ?> cloneFunc) {
    Preconditions.checkNotNull(node);
    Preconditions.checkNotNull(cloneFunc);

    // shadow clone node
    final DefaultMutableTreeNode cloneNode = (DefaultMutableTreeNode) node.clone();

    // deep clone the user object
    final Object cloneObject = cloneFunc.apply(node.getUserObject());
    cloneNode.setUserObject(cloneObject);

    return cloneNode;

    //        //@throws IllegalArgumentException
    //        //   If the node's user object is not cloneable.
    //
    //        final Cloneable userObjectAsCloneable = CommonOP.As(node.getUserObject(),
    // Cloneable.class);
    //        if (userObjectAsCloneable != null) {
    //            // shadow clone node
    //            final DefaultMutableTreeNode cloneNode = (DefaultMutableTreeNode) node.clone();
    //
    //            //deep clone the user object
    //            final Object cloneObject = userObjectAsCloneable.clone();
    //            cloneNode.setUserObject(cloneObject);
    //
    //            return cloneNode;
    //        } else {
    //            throw new IllegalArgumentException("The node's user object is not cloneable.");
    //        }
  }
示例#10
0
    public void setLabels() {
      root.setUserObject(app.getPlain("Objects"));

      // iterate through all type nodes and update the labels
      for (String key : typeNodesMap.keySet()) {
        typeNodesMap.get(key).setUserObject(app.getPlain(key));
      }
    }
示例#11
0
 /** This gets called whenever one of the ConfigElements we are modeling has changed its name. */
 public void nameChanged(ConfigElementEvent evt) {
   ConfigElement src = (ConfigElement) evt.getSource();
   DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot();
   DefaultMutableTreeNode name_node = (DefaultMutableTreeNode) root.getChildAt(0);
   name_node.setUserObject(src.getName());
   fireTreeNodesChanged(
       this, new Object[] {getPathToRoot(root)}, new int[] {0}, new Object[] {name_node});
 }
  public JPanel createJCheckBoxTree() {
    /*		try {
    		    String lafName = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
    		    UIManager.setLookAndFeel(lafName);
    */
    JPanel checkBoxPane = new JPanel();
    checkBoxPane.setLayout(new BorderLayout());

    this.sortedChoices = new JComboBox();
    this.sortedChoices.addItem("Par Année");
    this.sortedChoices.addItem("Par Catégorie");

    this.sortedChoices.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            // TODO Auto-generated method stub
            if (((String) ComponentsChoicesView.this.sortedChoices.getSelectedItem())
                .equals("Par Année")) {
              if (!ComponentsChoicesView.this.dateDisplay) {
                ComponentsChoicesView.this.dateDisplay = true;
                ComponentsChoicesView.this.updateCheckBoxTree();
              }
            } else {
              if (ComponentsChoicesView.this.dateDisplay) {
                ComponentsChoicesView.this.dateDisplay = false;
                ComponentsChoicesView.this.updateCheckBoxTree();
              }
            }
          }
        });

    checkBoxPane.add(this.sortedChoices, BorderLayout.NORTH);

    this.checkboxTree = new CheckboxTree();
    this.checkboxTree.getCheckingModel().setCheckingMode(TreeCheckingModel.CheckingMode.PROPAGATE);
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) this.checkboxTree.getModel().getRoot();
    root.setUserObject("Les Logiciels");

    checkBoxPane.add(new JScrollPane(this.checkboxTree), BorderLayout.CENTER);

    return checkBoxPane;
    /*		} catch (ClassNotFoundException e) {
    		    e.printStackTrace();
    		} catch (InstantiationException e) {
    		    e.printStackTrace();
    		} catch (IllegalAccessException e) {
    		    e.printStackTrace();
    		} catch (UnsupportedLookAndFeelException e) {
    		    e.printStackTrace();
    		}


    		return null;
    */
  }
示例#13
0
 /** {@inheritDoc} */
 @Override
 public void setUserObject(Object aUserObject) {
   if ((aUserObject != ROOT_ID) && (aUserObject instanceof String)) {
     setText((String) aUserObject);
   } else if (aUserObject instanceof Boolean) {
     setVisible(((Boolean) aUserObject).booleanValue());
   } else if (aUserObject instanceof IUIElement) {
     super.setUserObject(aUserObject);
   }
 }
示例#14
0
  public void buildTree() {
    top.removeAllChildren();
    DefaultTreeModel model = (DefaultTreeModel) this.getModel();
    top.setUserObject(new NodeData(jsonElement, "data"));
    model.setRoot(top);

    prepareElement(top, jsonElement);
    repaint();
    setSelectionRow(0);
  }
  private DefaultMutableTreeNode newTreeNode(String text, String url, boolean isColl) {
    // create node
    DefaultMutableTreeNode node = new DefaultMutableTreeNode();
    UrlNodeUserObject nodeObject = new UrlNodeUserObject(node, isColl);
    nodeObject.setText(text);
    nodeObject.setUrl(url);

    node.setUserObject(nodeObject);
    return node;
  }
示例#16
0
 /**
  * gets the representation of this object as a defaultmutableTreeNode;
  *
  * @return
  */
 public DefaultMutableTreeNode getTreeNode() {
   DefaultMutableTreeNode root = new DefaultMutableTreeNode(textContent);
   root.setUserObject(this);
   for (int i = 0; i < tags.size(); i++) {
     AttributeTree attribute = new AttributeTree(tags.get(i), this);
     DefaultMutableTreeNode child = new DefaultMutableTreeNode(attribute);
     root.add(child);
   }
   return root;
 }
  /** Creates a new instance of VDCCollectionTree */
  public VDCCollectionTree() {

    // create root node with its children expanded
    DefaultMutableTreeNode rootTreeNode = new DefaultMutableTreeNode();
    IceUserObject rootObject = new IceUserObject(rootTreeNode);
    rootObject.setText("Root Node");
    rootObject.setExpanded(true);
    rootTreeNode.setUserObject(rootObject);

    tree = new DefaultTreeModel(rootTreeNode);
  }
 private void updateAllChildrenUserObject(DefaultMutableTreeNode root, Status status) {
   Enumeration breadth = root.breadthFirstEnumeration();
   while (breadth.hasMoreElements()) {
     DefaultMutableTreeNode node = (DefaultMutableTreeNode) breadth.nextElement();
     if (root == node) {
       continue;
     }
     CheckBoxNode check = (CheckBoxNode) node.getUserObject();
     node.setUserObject(new CheckBoxNode(check.label, status));
     onCheckboxStatusChanged(node);
   }
 }
 public void setRootElement(CompositePackagingElement<?> rootElement) {
   myContext
       .getOrCreateModifiableArtifactModel()
       .getOrCreateModifiableArtifact(myOriginalArtifact)
       .setRootElement(rootElement);
   myTreeStructure.updateRootElement();
   final DefaultMutableTreeNode node = myTree.getRootNode();
   node.setUserObject(myTreeStructure.getRootElement());
   myBuilder.updateNode(node);
   rebuildTree();
   myArtifactsEditor.getSourceItemsTree().rebuildTree();
 }
示例#20
0
  /**
   * Sets PROJECT_ID attribute to DEFAULT_PROJECT_ID and cleans tree and node to show Must be called
   * at participant logout
   */
  public DefaultMutableTreeNode getDefaultTree() {
    DefaultMutableTreeNode defaultTree = new DefaultMutableTreeNode();
    WilosObjectNode iceUserObject = new WilosObjectNode(defaultTree);

    ResourceBundle bundle =
        ResourceBundle.getBundle(
            "wilos.resources.messages",
            FacesContext.getCurrentInstance().getApplication().getDefaultLocale());
    iceUserObject.setText(bundle.getString("navigation.tree.defaulttreenodetext"));
    defaultTree.setUserObject(iceUserObject);
    return defaultTree;
  }
  // add table to list
  private void addConnectionToTree(Connection conn) {

    Log log = Utils.getLog();

    DefaultTreeModel defTreeModel = (DefaultTreeModel) getModel();

    DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) getModel().getRoot();

    //
    log.debug(conn.getName());

    DefaultMutableTreeNode nameNode = new DefaultMutableTreeNode(conn.getName(), true);

    DefaultMutableTreeNode tablesNode = new DefaultMutableTreeNode("Tables", true);

    nameNode.setUserObject(conn);
    nameNode.add(tablesNode);

    for (Table mtable : conn.getTableList()) {

      // log.info(mtable);

      DefaultMutableTreeNode tableNode = new DefaultMutableTreeNode(mtable.getName(), true);
      tablesNode.add(tableNode);
      tableNode.setUserObject(mtable);
    }

    DefaultMutableTreeNode confNode =
        new DefaultMutableTreeNode("Tables Count:" + tablesNode.getChildCount(), true);
    nameNode.add(confNode);

    rootNode.add(nameNode);

    defTreeModel.setRoot(rootNode);

    for (int i = 0; i < getRowCount(); i++) {
      expandRow(i);
    }
  }
 /**
  * returns a default mutable tree representation of a given working copy node
  *
  * @param svnTreeNode mode of an svn working copy model
  * @return root DefaultMutableTreeNode of the given model
  */
 public static DefaultMutableTreeNode buildTreeNode(SVNTreeNodeData svnTreeNode) {
   DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(svnTreeNode);
   for (Iterator iterator = svnTreeNode.getChildren().iterator(); iterator.hasNext(); ) {
     SVNTreeNodeData svnTreeNodeData = (SVNTreeNodeData) iterator.next();
     DefaultMutableTreeNode newNode = new DefaultMutableTreeNode();
     newNode.setUserObject(svnTreeNodeData);
     DefaultMutableTreeNode newChild = buildTreeNode(svnTreeNodeData);
     if (newChild != null) {
       rootNode.add(newChild);
     }
   }
   return rootNode;
 }
示例#23
0
  /**
   * Connect the manager to a remote repository.
   *
   * @param ior_url an url pointing to the IOR file of a remote repository.
   */
  public void connectTo(String ior_url) {
    try {
      m_admin = AdminHelper.narrow(m_orb.resolve_initial_references("ImplementationRepository"));
    } catch (org.omg.CORBA.ORBPackage.InvalidName in) {
      if (logger.isWarnEnabled()) logger.warn("Could not contact Impl. Repository!");
      return;
    }

    fetchImRInfo();

    m_top_node.setUserObject(m_imr_info);

    fetchServers();

    setRefreshInterval(m_current_refresh_interval);
  }
示例#24
0
    public void actionPerformed(ActionEvent arg0) {
      DefaultMutableTreeNode curTreeNode =
          (DefaultMutableTreeNode) treWhere.getLastSelectedPathComponent();
      if (curTreeNode == null || !curTreeNode.isLeaf()) return;

      // 检查信息是否填写完整
      if (!checkInputInfo()) return;

      String objDs = (String) dataSourceCbx.getValue();
      String objField = (String) cbxFieldName.getValue();
      String objValue = (String) cbxWhereValue.getValue();
      String objCompare = (String) cbxCompare.getValue();

      String[] arrField = objField.split(":");
      String fieldType = arrField[1];
      fieldType = DefinePub.getFieldTypeWithCh(fieldType);
      if (DefinePub.checkCharVal(fieldType)) {
        objValue = "'" + objValue + "'";
      } else {
        // 检查一下是不是数字
        try {
          Double.parseDouble(objValue);
        } catch (Exception e) {
          new MessageBox(calcColumnDialog, "值不是合法的数字!", MessageBox.MESSAGE, MessageBox.BUTTON_OK)
              .show();
          return;
        }
      }

      DefaultMutableTreeNode defaultMutableTreeNode =
          (DefaultMutableTreeNode) treWhere.getLastSelectedPathComponent();
      if (defaultMutableTreeNode == null) return;
      IStatisticCaliber asCal = ((Caliber) defaultMutableTreeNode.getUserObject()).getACal();

      asCal.setSourceID(objDs.toString());
      asCal.setSourceColID(arrField[0]);
      asCal.setCompareType(objCompare.toString());
      asCal.setValue(objValue.toString());
      asCal.setJoinBefore(frdoType.getValue().toString());

      defaultMutableTreeNode.setUserObject(new Caliber(asCal));
      // 刷新节点中文名称
      refreshNodeChName(defaultMutableTreeNode);
      // 刷新节点
      ((DefaultTreeModel) treWhere.getModel()).nodeChanged(defaultMutableTreeNode);
    }
示例#25
0
    public void actionPerformed(ActionEvent arg0) {

      DefaultMutableTreeNode curTreeNode =
          (DefaultMutableTreeNode) treWhere.getLastSelectedPathComponent();
      if (curTreeNode == null || !curTreeNode.isLeaf()) return;
      Caliber cal = (Caliber) curTreeNode.getUserObject();
      if (cal.getACal() instanceof ICustomStatisticCaliber) {
        ICustomStatisticCaliber myCal = (ICustomStatisticCaliber) cal.getACal();
        myCal.setLParenthesis("");
        myCal.setRParenthesis("");
        curTreeNode.setUserObject(cal);
        // 刷新节点中文名称
        refreshNodeChName(curTreeNode);
        // 刷新节点
        ((DefaultTreeModel) treWhere.getModel()).nodeChanged(curTreeNode);
      }
    }
示例#26
0
  /**
   * Build a tree node for a server, with all its dependend POAs.
   *
   * @param index the servers ServerInfo struct.
   */
  private void buildServerNode(int index) {
    DefaultMutableTreeNode _server_node;
    POAInfo[] _poa_array = m_servers[index].poas;
    Vector _poas;
    if (index < m_server_nodes.size()) {
      // a server node for that index exists
      _server_node = (DefaultMutableTreeNode) m_server_nodes.elementAt(index);
      _poas = (Vector) m_poa_nodes.elementAt(index);

    } else {
      // a new server node has to be created
      _server_node = new DefaultMutableTreeNode(m_servers[index]);
      m_server_nodes.addElement(_server_node);
      m_tree_model.insertNodeInto(_server_node, m_top_node, index);
      m_tree.scrollPathToVisible(new TreePath(_server_node.getPath()));

      _poas = new Vector();
      m_poa_nodes.addElement(_poas);
    }

    int _i;
    // update existing nodes
    for (_i = 0; _i < _poas.size(); _i++) {
      if (_i < _poa_array.length) {
        DefaultMutableTreeNode _poa = (DefaultMutableTreeNode) _poas.elementAt(_i);
        _poa.setUserObject(_poa_array[_i]);
      } else break;
    }
    if (_i >= _poa_array.length) {
      // remove surplus nodes
      for (int _j = _poas.size() - 1; _j >= _i; _j--) {
        DefaultMutableTreeNode _poa = (DefaultMutableTreeNode) _poas.elementAt(_j);
        _poas.removeElementAt(_j);
        m_tree_model.removeNodeFromParent(_poa);
      }
    } else {
      // build new nodes
      for (int _j = _i; _j < _poa_array.length; _j++) {
        DefaultMutableTreeNode _poa = new DefaultMutableTreeNode(_poa_array[_j]);
        _poas.addElement(_poa);
        m_tree_model.insertNodeInto(_poa, _server_node, _j);
      }
    }
  }
示例#27
0
  /** Build the tree by building all its server nodes. The root node stays always the same. */
  private void buildTree() {
    int _i;
    // update exisiting nodes
    for (_i = 0; _i < m_server_nodes.size(); _i++) {
      if (_i < m_servers.length) {
        DefaultMutableTreeNode _server = (DefaultMutableTreeNode) m_server_nodes.elementAt(_i);
        _server.setUserObject(m_servers[_i]);
        buildServerNode(_i);
      } else break;
    }

    if (_i >= m_servers.length) {
      // remove surplus nodes
      for (int _j = m_server_nodes.size() - 1; _j >= _i; _j--) removeServerNode(_j);
    } else {
      // add new nodes
      for (int _j = _i; _j < m_servers.length; _j++) buildServerNode(_j);
    }
  }
 private void editToolbarIcon(String actionId, DefaultMutableTreeNode node) {
   final AnAction anAction = ActionManager.getInstance().getAction(actionId);
   if (isToolbarAction(node)
       && anAction.getTemplatePresentation() != null
       && anAction.getTemplatePresentation().getIcon() == null) {
     final int exitCode =
         Messages.showOkCancelDialog(
             IdeBundle.message("error.adding.action.without.icon.to.toolbar"),
             IdeBundle.message("title.unable.to.add.action.without.icon.to.toolbar"),
             Messages.getInformationIcon());
     if (exitCode == Messages.OK) {
       mySelectedSchema.addIconCustomization(actionId, null);
       anAction.getTemplatePresentation().setIcon(AllIcons.Toolbar.Unknown);
       anAction.setDefaultIcon(false);
       node.setUserObject(Pair.create(actionId, AllIcons.Toolbar.Unknown));
       myActionsTree.repaint();
       setCustomizationSchemaForCurrentProjects();
     }
   }
 }
示例#29
0
 public DefaultMutableTreeNode buildTree(String ontName, String rootTerm) throws Exception {
   DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode();
   MessageLog.printInfo("OntologyTree.initTree(): caching tree for " + ontName);
   SearchCriteria sc = CaBIOUtils.newSearchCriteria(ontName);
   sc.putCriterion("name", Criterion.EQUAL_TO, rootTerm);
   Object[] results = sc.search().getResultSet();
   if (results.length == 1) {
     CMAPOntology root = (CMAPOntology) results[0];
     CMAPOntologyRelationship[] rels = (CMAPOntologyRelationship[]) root.getChildRelationships();
     CMAPOntology rootObj = rels[0].getChild();
     String id = CaBIOUtils.getProperty(rootObj, "id").toString();
     String name = rootTerm;
     treeRoot.setUserObject(
         new WebNode(id, name, "javascript:" + _eventHandler + "('" + id + "', '" + name + "')"));
     buildTree(treeRoot, rootObj);
   } else if (results.length > 1) {
     throw new Exception("Found more that one root for root term: " + rootTerm);
   } else {
     throw new Exception("Found not root for root term: " + rootTerm);
   }
   return treeRoot;
 }
示例#30
0
  /**
   * Agrega una nueva unidad al árbol, como hijo de un nodo padre
   *
   * @param padre Padre de la nueva unidad
   * @param nuevaUnidad Nueva unidad
   * @return El nodo con la unidad dentro, ya asignado al padre
   */
  public DefaultMutableTreeNode agregarNodo(DefaultMutableTreeNode padre, Unidad nuevaUnidad) {

    DefaultMutableTreeNode node = new DefaultMutableTreeNode();
    UnidadUserObject userObject = new UnidadUserObject(node);
    node.setUserObject(userObject);
    userObject.setUnidad(nuevaUnidad);

    node.setAllowsChildren(true);
    userObject.setText(nuevaUnidad.getNombre());
    userObject.setLeaf(false);

    if (nuevaUnidad.getTipo() == 0) {
      userObject.setExpanded(true);
    } else {
      userObject.setExpanded(false);
    }

    if (padre != null) {
      padre.add(node);
    }

    return node;
  }