Package org.nasutekds.guitools.controlpanel.ui.nodes

Examples of org.nasutekds.guitools.controlpanel.ui.nodes.BasicNode


        ColorAndFontConstants.progressFont));
  }

  private BasicNode findParentNode(DN dn, BasicNode root)
  {
    BasicNode parentNode = null;
    int nRootChildren = controller.getTreeModel().getChildCount(root);
    for (int i=0; i<nRootChildren; i++)
    {
      BasicNode node =
        (BasicNode)controller.getTreeModel().getChild(root, i);
      try
      {
        DN nodeDN = DN.decode(node.getDN());
        if (dn.isDescendantOf(nodeDN))
        {
          if (dn.getNumComponents() == nodeDN.getNumComponents() + 1)
          {
            parentNode = node;
View Full Code Here


  /**
   * The method that actually does the refresh.
   */
  @Override
  public void run() {
    final BasicNode node = getNode();

    try {
      boolean checkExpand = false;
      if (localEntry == null) {
        changeStateTo(State.READING_LOCAL_ENTRY);
        runReadLocalEntry();
      }
      if (controller.getFollowReferrals() && isReferralEntry(localEntry)) {
        changeStateTo(State.SOLVING_REFERRAL);
        runSolveReferral();
      }
      if (node.isLeaf()) {
        changeStateTo(State.DETECTING_CHILDREN);
        runDetectChildren();
      }
      if (controller.nodeIsExpanded(node) && recursive) {
        changeStateTo(State.SEARCHING_CHILDREN);
        runSearchChildren();
        /* If the node is not expanded, we have to refresh its children
          when we expand it */
      } else if (recursive  && (!node.isLeaf() || !isLeafNode)) {
        node.setRefreshNeededOnExpansion(true);
        checkExpand = true;
      }
      changeStateTo(State.FINISHED);
      if (checkExpand && mustAutomaticallyExpand(node))
      {
View Full Code Here

  /**
   * Read the local entry associated to the current node.
   */
  private void runReadLocalEntry() throws SearchAbandonException {
    BasicNode node = getNode();
    InitialLdapContext ctx = null;

    try {
      ctx = controller.findConnectionForLocalEntry(node);

      if (useCustomFilter())
      {
        // Check that the entry verifies the filter
        searchForCustomFilter(node, ctx);
      }

      SearchControls ctls = controller.getBasicSearchControls();
      ctls.setReturningAttributes(controller.getAttrsForRedSearch());
      ctls.setSearchScope(SearchControls.OBJECT_SCOPE);

      NamingEnumeration<SearchResult> s = ctx.search(new LdapName(node.getDN()),
                controller.getObjectSearchFilter(),
                ctls);
      try
      {
        while (s.hasMore())
        {
          localEntry = s.next();
          localEntry.setName(node.getDN());

        }
      }
      finally
      {
        s.close();
      }
      if (localEntry == null) {
        /* Not enough rights to read the entry or the entry simply does not
           exist */
        throw new NameNotFoundException("Can't find entry: "+node.getDN());
      }
      throwAbandonIfNeeded(null);
    }
    catch(NamingException x) {
      throwAbandonIfNeeded(x);
View Full Code Here

   * Detects whether the entry has children by performing a search using the
   * entry as base DN.
   * @throws SearchAbandonException if there is an error.
   */
  private void runDetectChildrenManually() throws SearchAbandonException {
    BasicNode parentNode = getNode();
    InitialLdapContext ctx = null;
    NamingEnumeration<SearchResult> searchResults = null;

    try {
      // We set the search constraints so that only one entry is returned.
View Full Code Here

   * Searchs for the children.
   * @throws SearchAbandonException if an error occurs.
   */
  private void runSearchChildren() throws SearchAbandonException {
    InitialLdapContext ctx = null;
    BasicNode parentNode = getNode();
    parentNode.setSizeLimitReached(false);

    try {
      // Send an LDAP search
      SearchControls ctls = controller.getBasicSearchControls();
      if (useCustomFilter())
      {
        ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
      }
      else
      {
        ctls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
      }
      ctls.setReturningAttributes(controller.getAttrsForRedSearch());
      ctx = controller.findConnectionForDisplayedEntry(parentNode);
      String parentDn = controller.findBaseDNForChildEntries(parentNode);
      int parentComponents;
      try
      {
        DN dn = DN.decode(parentDn);
        parentComponents = dn.getNumComponents();
      }
      catch (Throwable t)
      {
        throw new RuntimeException("Error decoding dn: "+parentDn+" . "+t,
            t);
      }
      NamingEnumeration<SearchResult> entries = ctx.search(
            new LdapName(parentDn),
                controller.getChildSearchFilter(),
                ctls);

      try
      {
        while (entries.hasMore())
        {
          SearchResult r = entries.next();
          String name;
          if (r.getName().length() == 0)
          {
            continue;
          }
          else
          {
            name = unquoteRelativeName(r.getName())+","+parentDn;
          }
          boolean add = false;
          if (useCustomFilter())
          {
            // Check that is an immediate child: use a faster method by just
            // comparing the number of components.
            DN dn = null;
            try
            {
              dn = DN.decode(name);
              add = dn.getNumComponents() == parentComponents + 1;
            }
            catch (Throwable t)
            {
              throw new RuntimeException("Error decoding dns: "+t, t);
            }

            if (!add)
            {
              // Is not a direct child.  Check if the parent has been added,
              // if it is the case, do not add the parent.  If is not the case,
              // search for the parent and add it.
              RDN[] rdns = new RDN[parentComponents + 1];
              int diff = dn.getNumComponents() - rdns.length;
              for (int i=0; i < rdns.length; i++)
              {
                rdns[i] = dn.getRDN(i + diff);
              }
              final DN parentToAddDN = new DN(rdns);
              boolean mustAddParent = true;
              for (SearchResult addedEntry : childEntries)
              {
                try
                {
                  DN addedDN = DN.decode(addedEntry.getName());
                  if (addedDN.equals(parentToAddDN))
                  {
                    mustAddParent = false;
                    break;
                  }
                }
                catch (Throwable t)
                {
                  throw new RuntimeException("Error decoding dn: "+
                      addedEntry.getName()+" . "+t, t);
                }
              }
              if (mustAddParent)
              {
                final boolean resultValue[] = {true};
                // Check the children added to the tree
                try
                {
                  SwingUtilities.invokeAndWait(new Runnable()
                  {
                    public void run()
                    {
                      for (int i=0; i<getNode().getChildCount(); i++)
                      {
                        BasicNode node = (BasicNode)getNode().getChildAt(i);
                        try
                        {
                          DN dn = DN.decode(node.getDN());
                          if (dn.equals(parentToAddDN))
                          {
                            resultValue[0] = false;
                            break;
                          }
                        }
                        catch (Throwable t)
                        {
                          throw new RuntimeException("Error decoding dn: "+
                              node.getDN()+" . "+t, t);
                        }
                      }
                    }
                  });
                }
View Full Code Here

      throw new IllegalArgumentException("Duplicate node dn " + nodeDn);
    }
    else {
      index = - (index + 1);
    }
    BasicNode newNode = new BasicNode(nodeDn);
    treeModel.insertNodeInto(newNode, parentNode, index);
    startRefreshNode(newNode, null, true);

    return new TreePath(treeModel.getPathToRoot(newNode));
  }
View Full Code Here

   * @param suffixDn the DN of the suffix to be removed.
   * @return the TreePath of the parent node of the removed node.
   */
  public TreePath removeSuffix(String suffixDn) {
    TreePath result = null;
    BasicNode node = findSuffixNode(suffixDn, rootNode);
    TreeNode parentNode = node.getParent();
    /* If the parent is null... the node is no longer in the tree */
    if (parentNode != null) {
      removeOneNode(node);
      result = new TreePath(treeModel.getPathToRoot(parentNode));
    }
View Full Code Here

   * the describing IBrowserNodeInfo.
   * @param path the TreePath associated with the node we are searching.
   * @return the BrowserNodeInfo associated to the TreePath.
   */
  public BrowserNodeInfo getNodeInfoFromPath(TreePath path) {
    BasicNode node = (BasicNode)path.getLastPathComponent();
    return new BrowserNodeInfoImpl(node);
  }
View Full Code Here

   * @param newEntryDn the dn of the entry to be added.
   * @return the tree path associated with the new entry.
   */
  public TreePath notifyEntryAdded(BrowserNodeInfo parentInfo,
      String newEntryDn) {
    BasicNode parentNode = parentInfo.getNode();
    BasicNode childNode = new BasicNode(newEntryDn);
    int childIndex;
    if (sorted) {
      childIndex = findChildNode(parentNode, newEntryDn);
      if (childIndex >= 0) {
        throw new IllegalArgumentException("Duplicate DN " + newEntryDn);
View Full Code Here

   * @param nodeInfo the node to be deleted.
   * @return the tree path associated with the parent of the deleted node.
   */
  public TreePath notifyEntryDeleted(BrowserNodeInfo nodeInfo) {
    TreePath result = null;
    BasicNode node = nodeInfo.getNode();
    if (node == rootNode) {
      throw new IllegalArgumentException("Root node cannot be removed");
    }
    TreeNode parentNode = node.getParent();

    /* If the parent is null... the node is no longer in the tree */
    if (parentNode != null) {
      removeOneNode(node);
      result = new TreePath(treeModel.getPathToRoot(parentNode));
View Full Code Here

TOP

Related Classes of org.nasutekds.guitools.controlpanel.ui.nodes.BasicNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.