Package com.projity.grouping.core

Examples of com.projity.grouping.core.Node


    add((Node)hierarchy.getRoot(),child,actionType);
  }

  public Node newNode(Node parent,int position,int actionType){
    //check if position is correct
    Node node;
    int p=position;
    int i=0;
    for (Enumeration e=parent.children();e.hasMoreElements();i++){
      node=(Node)e.nextElement();
      if (i==p){
        if (node.getImpl() instanceof Assignment) p++;
        else{
          Node newNode=NodeFactory.getInstance().createVoidNode();
          add(parent,newNode,p,NodeModel.NORMAL);
          return newNode;
        }
      }
    }
    Node newNode=NodeFactory.getInstance().createVoidNode();
    add(parent,newNode,-1,NodeModel.NORMAL);
    return newNode;

  }
View Full Code Here


   * @param parent
   * @param collection
   */
  public void addImplCollection(Node parent, Collection collection,int actionType) {
    Iterator i = collection.iterator();
    Node child;
    while (i.hasNext()) {
      child = NodeFactory.getInstance().createNode(i.next());
      add(parent,child,actionType);
    }

View Full Code Here

    try {
      ArrayList roots=new ArrayList();
      HierarchyUtils.extractParents(nodes, roots);
      if (filterAssignments)
        for (Iterator i=roots.iterator();i.hasNext();){
          Node node=(Node)i.next();
          if (node.getImpl() instanceof Assignment){
            i.remove();
            //AssignmentService.getInstance().remove(node, this, true);
          }
        }
      boolean containsSubprojects=false;
      List parents=new ArrayList();
      List positions=new ArrayList();
      NodeBridge node,parent;
      for (Iterator i=roots.iterator();i.hasNext();){
        node=(NodeBridge)i.next();
        if (NodeModelUtil.nodeIsSubproject(node))
          containsSubprojects=true;
        parent=(NodeBridge)node.getParent();
        parents.add(parent);
        positions.add(new Integer(parent.getIndex(node)));
      }
      if (!confirmRemove(roots))
        return;
View Full Code Here

    Set assignedNodes=new HashSet();
    Map implMap=new HashMap();
    Set<Dependency> predecessors=new HashSet<Dependency>();
    Set<Dependency> successors=new HashSet<Dependency>();
    for (ListIterator i=parentNodes.listIterator();i.hasNext();){
      Node parent=(Node)i.next();
      Node newParent=cloneNode(parent,null,implMap,predecessors,successors);
      cloneBranch(parent,newParent,assignedNodes,implMap,predecessors,successors);
      i.remove();
      i.add(newParent);
    }

    //rebuild dependencies
    if (Environment.isKeepExternalLinks()){
      for (Dependency dependency : successors) {
        TaskLinkReference pt=(TaskLinkReference)dependency.getPredecessor();
        TaskLinkReference st=(TaskLinkReference)dependency.getSuccessor();

        HasDependencies predecessor=(Task)implMap.get(pt);
        HasDependencies successor=(Task)implMap.get(st);

        if (predecessor==null) predecessor=new TaskLinkReferenceImpl(pt.getUniqueId(),pt.getProject());
        if (successor==null) successor=new TaskLinkReferenceImpl(st.getUniqueId(),st.getProject());
        Dependency d=Dependency.getInstance(predecessor, successor, dependency.getDependencyType(), dependency.getLag());
        d.setDirty(true);
        predecessor.getDependencyList(false).add(d);
        successor.getDependencyList(true).add(d);
        predecessors.remove(d);
      }
      for (Dependency dependency : predecessors) {
        TaskLinkReference pt=(TaskLinkReference)dependency.getPredecessor();
        TaskLinkReference st=(TaskLinkReference)dependency.getSuccessor();

        TaskLinkReference predecessor=(TaskLinkReference)implMap.get(pt);
        TaskLinkReference successor=(TaskLinkReference)implMap.get(st);

        if (predecessor==null) predecessor=new TaskLinkReferenceImpl(pt.getUniqueId(),pt.getProject());
        if (successor==null) successor=new TaskLinkReferenceImpl(st.getUniqueId(),st.getProject());
        Dependency d=Dependency.getInstance(predecessor, successor, dependency.getDependencyType(), dependency.getLag());
        d.setDirty(true);
        predecessor.getDependencyList(false).add(d);
        successor.getDependencyList(true).add(d);
        //successors.remove(d);
      }

    }else{
      for (Dependency dependency : predecessors) {
        if (successors.contains(dependency)){
          Task predecessor=(Task)implMap.get(dependency.getPredecessor());
          Task successor=(Task)implMap.get(dependency.getSuccessor());
          if (predecessor!=null&&successor!=null){
            Dependency d=Dependency.getInstance(predecessor, successor, dependency.getDependencyType(), dependency.getLag());
            d.setDirty(true);
            //Serializer.connectDependency(dependency, predecessor, successor);
            predecessor.getDependencyList(false).add(d);
            successor.getDependencyList(true).add(d);
          }
        }
      }

    }

    for (Iterator i=assignedNodes.iterator();i.hasNext();){
      addAssignments((Node)i.next());
    }

    for (ListIterator i=parentNodes.listIterator();i.hasNext();){
      Node node=(Node)i.next();
      cleanBranch(node);
    }

    return parentNodes;
  }
View Full Code Here

    return parentNodes;
  }
  private void cloneBranch(Node parent,Node newParent,Set assignedNodes,Map implMap,Set<Dependency> predecessors,Set<Dependency> successors){
    for (Iterator i=parent.childrenIterator();i.hasNext();){
        Node child=(Node)i.next();
        if (child.getImpl() instanceof Assignment){
          assignedNodes.add(newParent);
        }else{
          Node newChild=cloneNode(child,newParent,implMap,predecessors,successors);
          cloneBranch(child,newChild,assignedNodes,implMap,predecessors,successors);
        }
    }
  }
View Full Code Here

    Object parentImpl = (newParent==null)?null:newParent.getImpl();
    NodeModelDataFactory factory = getFactory(parentImpl);

    factory.addUnvalidatedObject(newNodeImpl,this,parentImpl);

    Node newNode=NodeFactory.getInstance().createNode(newNodeImpl);
    if (newParent!=null) newParent.add(newNode);
    if (parentImpl != null&& parentImpl instanceof Task)
      ((Task)parentImpl).setWbsChildrenNodes(getHierarchy().getChildren(newParent)); //rebuild children task's wbs cache
    return newNode;
  }
View Full Code Here

    return null;
  }

  private void cleanBranch(Node parent){
    for (Iterator i=parent.childrenIterator();i.hasNext();){
        Node child=(Node)i.next();
        cleanNodeImpl(child.getImpl());
        cleanBranch(child);
    }
  }
View Full Code Here

      AssociationList assignments=((HasAssignments)node.getImpl()).getAssignments();
      if (assignments==null) return;
      for (ListIterator i=assignments.listIterator(assignments.size());i.hasPrevious();){
        Assignment assignment=(Assignment)i.previous();
        if (assignment.isDefault()) continue;
        Node assignmentNode=NodeFactory.getInstance().createNode(assignment);
        node.insert(assignmentNode,0);
      }
    }
  }
View Full Code Here

  }

  public Node replaceImplAndSetFieldValue(Node node, LinkedList previous, Field field, Object eventSource, Object value,FieldContext context,int actionType) throws FieldParseException {
    //the line following a subproject is connected to the main project
    if (previous!=null&&previous.size()>0){
      Node p=(Node)previous.getFirst();
      if (p!=null&&p.isInSubproject()&&node.getSubprojectLevel()<p.getSubprojectLevel()){
        while (node.getSubprojectLevel()<p.getSubprojectLevel()) p=(Node)p.getParent();
        LinkedList newPrevious=new LinkedList();
        newPrevious.add(p);
        Node vn,pvn;
        for (Iterator i=previous.iterator();i.hasNext();){
          vn=(Node)i.next();
          pvn=(Node)vn.getParent();
          while(pvn!=null&&pvn!=p) pvn=(Node)pvn.getParent();
          if (pvn!=p) newPrevious.add(vn);
        }
        Object parentImpl = p.getImpl();
        NodeModelDataFactory factory = getFactory(parentImpl);
        return replaceImplAndSetFieldValue(node,newPrevious,factory.createUnvalidatedObject(this, parentImpl),field,eventSource,value,context,actionType);

      }
//      if (p!=null&&p.getImpl() instanceof NormalTask){
//        Task task=(Task)p.getImpl();
//        boolean subprojectParent=false;
//        while (task.getOwningProject()!=task.getProject()){
//          Node pParent=(Node)p.getParent();
//          if (pParent.getIndex(p)==pParent.getChildCount()-1){
//            p=pParent;
//            subprojectParent=true;
//          }else{
//            subprojectParent=false;
//            break;
//          }
//        }
//        if (subprojectParent){
//          LinkedList newPrevious=(LinkedList)previous.clone();
//          newPrevious.set(0, p);
//          Object parentImpl = p.getImpl();
//          NodeModelDataFactory factory = getFactory(parentImpl);
//          return replaceImplAndSetFieldValue(node,newPrevious,factory.createUnvalidatedObject(this, parentImpl),field,eventSource,value,context,actionType);
//
//        }
//      }

    }

    Node parent=(Node)node.getParent();
    Object parentImpl = (parent==getHierarchy().getRoot())?null:parent.getImpl();
    NodeModelDataFactory factory = getFactory(parentImpl);
    return replaceImplAndSetFieldValue(node,previous,factory.createUnvalidatedObject(this, parentImpl),field,eventSource,value,context,actionType);
  }
View Full Code Here

  public Node replaceImplAndSetFieldValue(Node node, LinkedList previous, Object newImpl, Field field, Object eventSource, Object value,FieldContext context,int actionType) throws FieldParseException {
    List previousPosition=null;
    //move in hierarchy
    if (previous!=null){
      LinkedList p=(LinkedList)previous.clone();
      Node sibling=(Node)p.removeFirst();
      Node parent=(Node)sibling.getParent();
      p.add(node);
      if (getUndoableEditSupport()!=null&isUndo(actionType)){
        previousPosition=new ArrayList(p.size());
        for (Iterator i=p.iterator();i.hasNext();){
          Node n=(Node)i.next();
          previousPosition.add(new NodeImplChangeAndValueSetEdit.Position((Node)n.getParent(),n,n.getParent().getIndex(n)));
        }
      }
      remove(p, NodeModel.SILENT);
      add(parent,p,parent.getIndex(sibling)+1,NodeModel.SILENT);
      //TODO need undo here
    }



    Node parent=(Node)node.getParent();

    Object parentImpl = (parent==getHierarchy().getRoot())?null:parent.getImpl();
    NodeModelDataFactory factory = getFactory(parentImpl);
    factory.addUnvalidatedObject(newImpl,this, parentImpl);
    Object oldImpl=node.getImpl();
    node.setImpl(newImpl);
    try {
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.