Package com.projity.grouping.core

Examples of com.projity.grouping.core.Node


        fireNodesInserted(this,addDescendants(children/*trees*/));
      }
    }

    public void paste(Node parent,List children,int position,NodeModel model,int actionType){
      Node p=(parent==null)?root:parent;

      Project project=null;
      ResourcePool resourcePool=null;
      if (model.getDataFactory() instanceof Project)
          project=(Project)model.getDataFactory();
      else if(model.getDataFactory() instanceof ResourcePool)
          resourcePool=(ResourcePool)model.getDataFactory();

      int subprojectLevel=getChildrenSubprojectLevel(parent);


//      ArrayList trees=new ArrayList();
//      HierarchyUtils.extractParents(children,trees);

      int childCount=p.getChildCount();
      if (position>childCount){
        NodeFactory nodeFactory=NodeFactory.getInstance();
        Node node=nodeFactory.createVoidNode();
        for (int i=childCount;i<position;i++){
          setSubprojectLevel(node,subprojectLevel);
          p.add(node);
        }
      }



      int j=position;
         for (Iterator i=/*trees*/children.iterator();i.hasNext();){
           Node node=(Node)i.next();
           if ((project!=null && node.getImpl() instanceof Task)||
               (resourcePool!=null && node.getImpl() instanceof Resource)||
               node.isVoid()){
            //if (node.getImpl() instanceof Task) System.out.println("PASTE parent="+parent+":"+(parent==null?"X":parent.isInSubproject())+", node="+node+":"+node.isInSubproject());
          setSubprojectLevel(node,subprojectLevel);
        //if (node.getImpl() instanceof Task) System.out.println("PASTE node in sub="+node.isInSubproject());
          if (position==-1) p.add(node);
      else p.insert(node,j++);
           }
         }
         Node[] descendants=addDescendants(/*trees*/children);


         ArrayList<Dependency> dependencies=new ArrayList<Dependency>();

      boolean doTransaction = model.getDocument() != null && descendants.length > 0;
      int transactionId = 0;
      if (doTransaction)
        transactionId = model.getDocument().fireMultipleTransaction(0,true);


      ArrayList<Node> insertedNodes=new ArrayList<Node>(descendants.length);

      if (project!=null){
        HashMap<Long,Resource> resourceMap=new HashMap<Long,Resource>();
        for (Resource r: (Collection<Resource>)project.getResourcePool().getResourceList())
          resourceMap.put(r.getUniqueId(),r);

        HashMap<Long,Task> taskMap=null;
        if (Environment.isKeepExternalLinks()){
          taskMap=new HashMap<Long,Task>();
          for (Task t: (Collection<Task>)project.getTasks()) //use model instead?
            taskMap.put(t.getUniqueId(),t);
        }

        Project owningProject;
        if (parent!=null && parent.getImpl() instanceof Task){
          Task task=(Task)parent.getImpl();
          if (task.isSubproject()) owningProject=((SubProj)task).getSubproject();
          else owningProject=task.getOwningProject();
        }else owningProject=(Project)model.getDataFactory();

          for (int i=0;i<descendants.length;i++){
            if (descendants[i].getImpl() instanceof Task){
              Task task=(Task)descendants[i].getImpl();

              Node parentSubproject=getParentSubproject((Node)descendants[i].getParent());
              if (parentSubproject!=null) owningProject=((SubProj)parentSubproject.getImpl()).getSubproject();
              if (!task.isExternal()) // fixes  subproject bug with external links
                task.setProjectId(owningProject.getUniqueId()); //useful?
              owningProject.validateObject(task,model,this,null,false);

              Set<Dependency> depsSet=new HashSet<Dependency>();
View Full Code Here


    public void cleanVoidChildren(){
      cleanVoidChildren(root);
    }
    private void cleanVoidChildren(Node node){
      for (Iterator i=node.childrenIterator();i.hasNext();){
        Node child=(Node)i.next();
        if (child.isVoid()) i.remove();
        else cleanVoidChildren(child);
      }
    }
View Full Code Here

    //warning: modify nodes list
    private static Node[] addDescendants(List nodes){
      ArrayList descendants=new ArrayList();
         for (ListIterator i=nodes.listIterator();i.hasNext();){
           Node node=(Node)i.next();
           extractSameProjectBranch(node,descendants);
//           boolean rootNode=true;
//          for (Enumeration e=((NodeBridge)node).preorderEnumeration();e.hasMoreElements();rootNode=false){
//            Node current=(Node)e.nextElement();
//            if (!rootNode) descendants.add(current);
View Full Code Here

//        //subproject.setProject(null);
//
//      }else{
      descendants.add(parent);
        for (Enumeration e=parent.children();e.hasMoreElements();){
          Node current=(Node)e.nextElement();
          extractSameProjectBranch(current,descendants);
        }
//      }
    }
View Full Code Here

      //boolean singleRemoval=!(node.getImpl() instanceof Assignment);
        try {
        node.removeFromParent();
          /*if (singleRemoval)*/ beginUpdate();
//        System.out.println("removeNoEvent("+node+")");
        Node current;
        int badCount = 0;
        LinkedList enumeratedNodes=new LinkedList();
        for (Enumeration e=((NodeBridge)node).postorderEnumeration();e.hasMoreElements();){
          enumeratedNodes.add(e.nextElement());
        }
View Full Code Here


   private boolean internalIndent(Node node,int deltaLevel,int actionType,List modifiedVoids){ //only +1 -1
      if (node==null||node==root||!node.isIndentable(deltaLevel)) return false;
       if (deltaLevel==1){ //indent
           Node parent=getParent(node);
          int index=parent.getIndex(node);
          if (index==0) return false;
          Node sibling;
          Node previous=null;

          for (ListIterator i=parent.childrenIterator(index);i.hasPrevious();){
            sibling=(Node)i.previous();
            if (node.canBeChildOf(sibling)){
              previous=sibling;
              break;
            } else if (sibling.isVoid()){
              modifiedVoids.add(sibling);
            }
          }
          if (previous==null||previous.getImpl() instanceof Assignment){

            return false;
          }
          for (Iterator i=modifiedVoids.iterator();i.hasNext();){
            previous.add((Node)i.next());
          }
          previous.add(node);
        if (isEvent(actionType)) fireNodesChanged(this,new Node[]{node});
      }else if (deltaLevel==-1){ //outdent
           Node parent=getParent(node);
           if (parent==null || parent==root) return false;
           if (parent.isLazyParent()) // don't allow outdenting of subprojects' children
             return false;
           Node grandParent=getParent(parent);

           //voids
           int index=parent.getIndex(node);
           if (index>0){
             Node sibling;
              for (ListIterator i=parent.childrenIterator(index);i.hasPrevious();){
                sibling=(Node)i.previous();
                if (sibling.isVoid()){
                  modifiedVoids.add(sibling);
                } else break;
              }
           }
View Full Code Here

/**
*
*/
public class NotVoidFilter extends NodeFilter {
  public boolean evaluate(Object obj) {
    Node node=(Node)obj;
    return !node.isVoid();
  }
View Full Code Here

        List list=new ArrayList();
        buildList(parent,list);
        return list;
   }
    private void buildList(Node parent, List list) {
      Node p=(parent==null)?root:parent;
        if (p!=root) list.add(p);
      Collection children=getChildren(p);
      if (children!=null) {
          for (Iterator i=children.iterator();i.hasNext();) {
            buildList((Node)i.next(),list);
View Full Code Here

//        return buildList(null).iterator();
//    }

    private Node searchPrevious(Node node){
        if (node==null||node==root) return null;
        Node previous=getParent(node);
      Collection children=getChildren(previous);
      if (children == null)
        return null;
        for (Iterator i=children.iterator();i.hasNext();) {
          Node currentNode=(Node)i.next();
          if (currentNode.equals(node)) return previous;
          previous=currentNode;
        }
        return null;
    }
View Full Code Here

        }
        return null;
    }

    private Node searchLast(Node node){
        Node current=(node==null)?root:node;
        while (!isLeaf(current)){
            List children=(List)getChildren(current);
            current=(Node)children.get(children.size()-1);
        }
        return current;
View Full Code Here

TOP

Related Classes of com.projity.grouping.core.Node

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.