Package de.FeatureModellingTool.FeatureModel

Examples of de.FeatureModellingTool.FeatureModel.Feature


            } else if (relationName.equals(CFRelation.PL_Relation)) {//Լ��ģ���ڹ�ϵ�ı䴦��
                if (!oldEFID.equals(newEFID)) {//��ϵ�������˷����仯

                    Constraint c = constraintModel.getConstraint(oldSFID);

                    Feature newF = featureModel.getFeature(newEFID);

                    String relationID = (String) focusConnection.getAttribute("id");
                    CFRelation oldR = constraintModel.getCFRelation(relationID);
                    CFRModifier modifier = oldR.getModifier();
                    boolean isSource = oldR.isSource();
                    constraintModelEditor.removeCFRelation(relationID);

                    //����id��figure��ӳ���
                    if (idToFigureMap != null) {
                        idToFigureMap.remove(relationID, focusConnection);
                    }

                    CFRelation plRelation = plRelation = constraintModelEditor.addCFRelation(relationID, newF, c, isSource, modifier);

                    if (plRelation != null) {
                        focusConnection.setAttribute("id", plRelation.getID());

                        //����id��figure��ӳ���
                        if (idToFigureMap != null) {
                            idToFigureMap.add(plRelation.getID(), focusConnection);
                        }
                    }
                } else if (!oldSFID.equals(newSFID)) { //��ϵ��Լ���˷����仯
                    Constraint cNew = constraintModel.getConstraint(newSFID);

                    Feature newF = featureModel.getFeature(newEFID);

                    String relationID = (String) focusConnection.getAttribute("id");
                    CFRModifier modifier = constraintModel.getCFRelation(relationID).getModifier();
                    constraintModelEditor.removeCFRelation(relationID);

                    //����id��figure��ӳ���
                    if (idToFigureMap != null) {
                        idToFigureMap.remove(relationID, focusConnection);
                    }

                    ConstraintFigure cf = (ConstraintFigure) newStartFigure;
                    CFRelation plRelation = null;

                    if (cf instanceof PLFigure) {
                        int direction = focusConnection.getStartConnector().getDirection();

                        if (direction == Connector.WEST_DIRECTION || direction == Connector.NORTH_DIRECTION) {
                            plRelation = constraintModelEditor.addCFRelation(relationID, newF, cNew, true, modifier);
                        } else if (direction == Connector.EAST_DIRECTION || direction == Connector.SOUTH_DIRECTION) {
                            plRelation = constraintModelEditor.addCFRelation(relationID, newF, cNew, false, modifier);
                        } else {
                            assert false;
                        }

                    } else if (cf instanceof GroupConstraintFigure) {
                        GroupConstraintFigure gcf = (GroupConstraintFigure) cf;

                        Integer pp = (Integer) gcf.getAttribute(GroupConstraintFigure.PortPosition);
                        int value = pp.intValue();
                        boolean isSource = false;

                        switch (value) {
                            case SwingConstants.NORTH:
                            case SwingConstants.WEST:
                                isSource = true;
                                break;
                            case SwingConstants.EAST:
                            case SwingConstants.SOUTH:
                                isSource = false;
                                break;
                            default:
                                assert false;
                                break;
                        }

                        plRelation = constraintModelEditor.addCFRelation(relationID, newF, cNew, isSource, modifier);

                    } else if (cf instanceof VPConstraintFigure) {
                        int direction = focusConnection.getStartConnector().getDirection();

                        if (direction == Connector.WEST_DIRECTION || direction == Connector.NORTH_DIRECTION) {
                            plRelation = constraintModelEditor.addCFRelation(relationID, newF, cNew, true, modifier);
                        } else if (direction == Connector.EAST_DIRECTION || direction == Connector.SOUTH_DIRECTION) {
                            plRelation = constraintModelEditor.addCFRelation(relationID, newF, cNew, false, modifier);
                        } else {
                            assert false;
                        }
                    } else {
                        assert false;
                    }

                    if (plRelation != null) {
                        focusConnection.setAttribute("id", plRelation.getID());

                        //����id��figure��ӳ���
                        if (idToFigureMap != null) {
                            idToFigureMap.add(plRelation.getID(), focusConnection);
                        }
                    }

                } else
                if (oldSFID.equals(newSFID) && (oldStartConnector != focusConnection.getStartConnector())) {//��ϵԼ���˵������ӷ����仯

                    String relationIDOld = (String) focusConnection.getAttribute("id");

                    CFRelation plRelationOld = constraintModel.getCFRelation(relationIDOld);

                    boolean isSource = plRelationOld.isSource();

                    Feature feature = plRelationOld.getFeature();
                    Constraint plc = (Constraint) plRelationOld.getConstraint();

                    CFRModifier modifier = constraintModel.getCFRelation(relationIDOld).getModifier();
                    constraintModelEditor.removeCFRelation(relationIDOld);
View Full Code Here


    constraints.clear();
    constraints.addAll(featureModel.getAllFeatureRelation().values());
    for (Iterator<FeatureRelation> itRelation = constraints.iterator() ; itRelation.hasNext() ; ) {
      FeatureRelation relation = itRelation.next();
      if (!htNameMap.containsKey(relation.getID())) {
        Feature start = featureModel.getFeature(htNameMap.get(relation.getStartFeature().getID()));
        Feature end = featureModel.getFeature(htNameMap.get(relation.getEndFeature().getID()));
        if (start!=null || end!=null) {
          if (start==null)
            start = relation.getStartFeature();
          if (end==null)
            end = relation.getEndFeature();
          FeatureRelation newRelation = featureModelEditor.addRelation(relation.getName() , start, end);
          htNameMap.put(relation.getID() , newRelation.getID());
        }
      }
    }
   
    constraints.clear();
    constraints.addAll(constraintModel.getAllGroupConstraint().values());
    for (Iterator<GroupConstraint> itConstraint = constraints.iterator() ; itConstraint.hasNext() ; ) {
      GroupConstraint gc = itConstraint.next();
     
      boolean newFeature = false;
      boolean allNewFeature = true;
      for (Iterator<Feature> itFeature = gc.getFeatureSet().iterator() ; itFeature.hasNext() ; ) {
        Feature constraintFeature = itFeature.next();
        if (htNameMap.containsKey(constraintFeature.getID())) {
          newFeature = true;
        } else {
          allNewFeature = false;
        }
      }
     
      GroupConstraint newConstraint = null;
      if (newFeature) {
        if (allNewFeature) {
          newConstraint = constraintModelEditor.addGroupConstraint();
          groupConstraintEditor.setType(newConstraint , gc.getType());
          htNameMap.put(gc.getID() , newConstraint.getID());
        } else {
          newConstraint = gc;
        }
       
        for (Iterator<Feature> itFeature = gc.getFeatureSet().iterator() ; itFeature.hasNext() ; ) {
          Feature constraintFeature = itFeature.next();
          if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
            constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
            groupConstraintEditor.addFeature(newConstraint , constraintFeature);
          }
        }
      }
    }
   
    constraints.clear();
    constraints.addAll(constraintModel.getAllCompositeConstraint().values());
    for (Iterator<CompositeConstraint> itConstraint = constraints.iterator() ; itConstraint.hasNext() ; ) {
      CompositeConstraint gc = itConstraint.next();
     
      boolean newFeature = false;
      boolean allNewFeature = true;
      for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator() ; itFeature.hasNext() ; ) {
        Feature constraintFeature = itFeature.next();
        if (htNameMap.containsKey(constraintFeature.getID())) {
          newFeature = true;
        } else {
          allNewFeature = false;
        }
      }
      for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator() ; itFeature.hasNext() ; ) {
        Feature constraintFeature = itFeature.next();
        if (htNameMap.containsKey(constraintFeature.getID())) {
          newFeature = true;
        } else {
          allNewFeature = false;
        }
      }

      if (newFeature) {
        CompositeConstraint newConstraint = null;
        if (allNewFeature) {
          newConstraint = constraintModelEditor.addCompositeConstraint();
          compositeConstraintEditor.setPLType(newConstraint , gc.getPLType());
          compositeConstraintEditor.setSinkType(newConstraint , gc.getSinkType());
          compositeConstraintEditor.setSourceType(newConstraint , gc.getSourceType());
          htNameMap.put(gc.getID() , newConstraint.getID());
        } else {
          newConstraint = gc;
        }
       
        for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator() ; itFeature.hasNext() ; ) {
          Feature constraintFeature = itFeature.next();
          if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
            constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
            compositeConstraintEditor.addSourceFeature(newConstraint , constraintFeature);
          }
        }
       
        for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator() ; itFeature.hasNext() ; ) {
          Feature constraintFeature = itFeature.next();
          if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
            constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
            compositeConstraintEditor.addSinkFeature(newConstraint , constraintFeature);
          }
        }
      }
    }
   
    constraints.clear();
    constraints.addAll(constraintModel.getAllVPConstraint().values());
    for (Iterator<VPConstraint> itConstraint = constraints.iterator() ; itConstraint.hasNext() ; ) {
      VPConstraint gc = itConstraint.next();
     
      boolean newFeature = false;
      boolean allNewFeature = true;
      for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator() ; itFeature.hasNext() ; ) {
        Feature constraintFeature = itFeature.next();
        if (htNameMap.containsKey(constraintFeature.getID())) {
          newFeature = true;
        } else {
          allNewFeature = false;
        }
      }
      for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator() ; itFeature.hasNext() ; ) {
        Feature constraintFeature = itFeature.next();
        if (htNameMap.containsKey(constraintFeature.getID())) {
          newFeature = true;
        } else {
          allNewFeature = false;
        }
      }

      if (newFeature) {
        VPConstraint newConstraint = null;
        if (allNewFeature) {
          newConstraint = constraintModelEditor.addVPConstraint();
          vpConstraintEditor.setType(newConstraint , gc.getType());
          htNameMap.put(gc.getID() , newConstraint.getID());
        } else {
          newConstraint = gc;
        }
       
        for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator() ; itFeature.hasNext() ; ) {
          Feature constraintFeature = itFeature.next();
          if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
            constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
            vpConstraintEditor.addSourceFeature(newConstraint , constraintFeature);
          }
        }
       
        for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator() ; itFeature.hasNext() ; ) {
          Feature constraintFeature = itFeature.next();
          if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
            constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
            vpConstraintEditor.addSinkFeature(newConstraint , constraintFeature);
          }
        }
      }
    }
   
    constraints.clear();
    constraints.addAll(constraintModel.getAllCFRelation().values());
    for (Iterator<CFRelation> itConstraint = constraints.iterator() ; itConstraint.hasNext() ; ) {
      CFRelation gc = itConstraint.next();

      boolean newFeature = false;
      Feature cfFeature = gc.getFeature();
      if (htNameMap.containsKey(gc.getFeature().getID())) {
        cfFeature =  featureModel.getFeature(htNameMap.get(gc.getFeature().getID()));
        newFeature = true;
      }
      Constraint cfConstraint = gc.getConstraint();
View Full Code Here

      , FeatureEditor featureEditor
      , FeatureModel featureModel
      , FeatureModelEditor featureModelEditor
      , Hashtable<String , String> htNameMap
      , HashSet<String> hsSubFeatureIDs) {
    Feature newFeature = featureModelEditor.addFeature(feature.getName());
    htNameMap.put(feature.getID() , newFeature.getID());
   
    featureEditor.setBindingTime(newFeature , feature.getBindingTime());
    featureEditor.setCategory(newFeature , feature.getCategory());
    featureEditor.setDescription(newFeature , feature.getDescription());
    featureEditor.setVariability(newFeature , feature.getVariability());
View Full Code Here

    }
   
    Figure rSrc = srcFigureMap.get(fSrc.getID());
    Figure rDist = figureMap.get(fDist.getID());
    for (Iterator<Feature> itFeature=features.iterator() ; itFeature.hasNext() ; ) {
      Feature feature = itFeature.next();
      Feature newFeature = fmEditor.addFeature(feature.getName());
      fEditor.setBindingTime(newFeature , feature.getBindingTime());
      fEditor.setCategory(newFeature , feature.getCategory());
      fEditor.setVariability(newFeature , feature.getVariability());
     
      nameMap.put(feature.getID() , newFeature.getID());
     
      FeatureFigure figDist = new FeatureFigure();
      figDist.setText(feature.getName());
      figDist.setAttribute("id" , feature.getID());
      figDist.setAttribute(FeatureProperties.VARIABILITY , feature.getVariability().getName());
      dvDist.add(figDist);
     
      Figure fOld = srcFigureMap.get(feature.getID());
      figDist.moveBy(rDist.getDisplayBox().x - rSrc.getDisplayBox().x + fOld.getDisplayBox().x
          , rDist.getDisplayBox().y - rSrc.getDisplayBox().y + fOld.getDisplayBox().y);
      figureMap.put(newFeature.getID() , figDist);
    }
   
    for (Iterator<FeatureRelation> itRelation=fmSrc.getAllFeatureRelation().values().iterator()
        ; itRelation.hasNext() ; ) {
      FeatureRelation relation = itRelation.next();
View Full Code Here

    Set<Feature> features = new HashSet<Feature>();
    features.add(fSrc);
    boolean changed = false;
    do {
      for (Iterator<Feature> itFeature=fmSrc.getAllFeature().values().iterator() ; itFeature.hasNext() ; ) {
        Feature feature = itFeature.next();
        if (!features.contains(feature) && features.contains(fmSrc.getParentFeature(feature.getID()))) {
          features.add(feature);
          changed = true;
        }
      }
      changed = false;
    } while (changed);
    features.remove(fSrc);

//    Hashtable<String , Figure> srcFigureMap = new Hashtable<String , Figure>();
//    for (FigureEnumeration fe=dvSrc.getDrawing().getFigures()
//        ; fe.hasMoreElements() ; ) {
//      Figure figure = fe.nextFigure();
//      srcFigureMap.put((String)figure.getAttribute("id") , figure);
//    }
//
//    Hashtable<String , String> nameMap = new Hashtable<String , String>();
    nameMap.put(fSrc.getID() , fDist.getID());
//    Hashtable<String , Figure> figureMap = new Hashtable<String , Figure>();
    for (FigureEnumeration fe=dvDist.getDrawing().getFigures()
        ; fe.hasMoreElements() ; ) {
      Figure figure = fe.nextFigure();
      if (fDist.getID().equals(figure.getAttribute("id"))) {
        figureMap.put(fDist.getID() , figure);
        break;
      }
    }
   
//    Figure rSrc = srcFigureMap.get(fSrc.getID());
    Figure rDist = figureMap.get(fDist.getID());
    for (Iterator<Feature> itFeature=features.iterator() ; itFeature.hasNext() ; ) {
      Feature feature = itFeature.next();
      Feature newFeature = fmEditor.addFeature(feature.getName());
      fEditor.setBindingTime(newFeature , feature.getBindingTime());
      fEditor.setCategory(newFeature , feature.getCategory());
      fEditor.setVariability(newFeature , feature.getVariability());
     
      nameMap.put(feature.getID() , newFeature.getID());
     
      FeatureFigure figDist = new FeatureFigure();
      figDist.setText(feature.getName());
      figDist.setAttribute("id" , feature.getID());
      figDist.setAttribute(FeatureProperties.VARIABILITY , feature.getVariability().getName());
      dvDist.add(figDist);
     
//      Figure fOld = srcFigureMap.get(feature.getID());
//      figDist.moveBy(rDist.getDisplayBox().x - rSrc.getDisplayBox().x + fOld.getDisplayBox().x
//          , rDist.getDisplayBox().y - rSrc.getDisplayBox().y + fOld.getDisplayBox().y);
      figureMap.put(newFeature.getID() , figDist);
    }
   
    for (Iterator<FeatureRelation> itRelation=fmSrc.getAllFeatureRelation().values().iterator()
        ; itRelation.hasNext() ; ) {
      FeatureRelation relation = itRelation.next();
View Full Code Here

    ArrayList<String> alCount = new ArrayList<String>();
    while (counts.size()>0) {
      for (Iterator<Entry<String,Integer>> itCount=cloneCount.entrySet().iterator() ; itCount.hasNext() ; ) {
        Entry<String,Integer> entry = itCount.next();
        if (!alCount.contains(entry.getKey())) {
          Feature feature = fmSrc.getFeature(entry.getKey());
         
          feature = fmSrc.getParentFeature(feature.getID());
          while (feature!=null) {
            counts.remove(feature.getID());
            feature = fmSrc.getParentFeature(feature.getID());
          }
        }
      }
     
      alCount.addAll(counts);
View Full Code Here

      , DrawingView dvDist
      , FeatureModelEditor fmEditor
      , FeatureEditor fEditor
      , Hashtable<String , String> nameMap
      , Hashtable<String , Figure> figureMap) {
    Feature fTarget = fmEditor.addFeature(fSrc.getName());
   
    FeatureFigure figDist = new FeatureFigure();
    figDist.setText(fTarget.getName());
    figDist.setAttribute("id" , fTarget.getID());
    figDist.setAttribute(FeatureProperties.VARIABILITY , fTarget.getVariability().getName());
    dvDist.add(figDist);
   
    nameMap.put(fSrc.getID() , fTarget.getID());
    figureMap.put(fTarget.getID() , figDist);
   
    Feature fParent = fmSrc.getParentFeature(fSrc.getID());
    if (fParent!=null) {
      for (Iterator<FeatureRelation> itRelation=fSrc.getAllRelatedRelation().iterator()  ; itRelation.hasNext() ; ) {
        FeatureRelation relation = itRelation.next();
        if (relation.getStartFeature().getID().equals(fParent.getID())) {
          FeatureRelation newRelation = fmEditor.addRelation(relation.getName() , fDist , fTarget);
         
          ConnectionFigure cf = null;
          if (FeatureRelation.ATTRIBUTE.equals(newRelation.getName())) {
            AttributeConnection dvc = new AttributeConnection();
View Full Code Here

            refineRelation.put(FeatureRelation.ATTRIBUTE, "attribute");

            Object evtSource = evt.getSource();

            if (Feature.class.isInstance(evtSource)) {
                Feature feature = (Feature) evtSource;
                FeatureNode featureNode = getTreeNode(root, feature);
                treeTable.repaint();
            } else if (FeatureModel.class.isInstance(evtSource)) {
                if (propertyName.equals(FeatureModelProperties.FEATURE_ADDED)) {
                    Feature feature = (Feature) evt.getNewValue();
                    FeatureNode featureNode = new FeatureNode(context, feature);
                    //root.add(featureNode);
                    treeTableModel.insertNodeInto(featureNode, root, root.getChildCount());
                } else if (propertyName.equals(FeatureModelProperties.FEATURE_REMOVED)) {
                    //--ɾ��һ���ڵ㣺�Ӹ��ڵ���ɾ���ýڵ㣬�����ýڵ�������ӽڵ���Ϊ���ڵ�
                    ///---�����ڵ㣨��ϵ�ڵ㣩���ٰ��������ڵ㣬��ɾ�����ڵ�
                    Feature feature = (Feature) evt.getOldValue();
                    FeatureNode featureNode = getTreeNode(root, feature);
                    FeatureNode parent = (FeatureNode) featureNode.getParent();

                    //int index = parent.getIndex(featureNode);
                    //parent.remove(featureNode);
                    treeTableModel.removeNodeFromParent(featureNode);

                    List<FeatureNode> children = new ArrayList<FeatureNode>();
                    Enumeration e = featureNode.children();
                    while (e.hasMoreElements()) { //--���������ォchild��ӵ�root,�������޸�e��ʹ�ñ����������ȷ
                        FeatureNode child = (FeatureNode) e.nextElement();
                        children.add(child);
                    }
                    Iterator<FeatureNode> it = children.iterator();
                    while (it.hasNext()) {
                        FeatureNode child = it.next();
                        //root.add(child);
                        treeTableModel.insertNodeInto(child, root, root.getChildCount());
                    }

                    boolean bHasMoreChildren = parent.children().hasMoreElements();
                    if (!bHasMoreChildren) {
                        //FeatureNode grandParent = (FeatureNode) parent.getParent();
                        //grandParent.remove(parent);
                        treeTableModel.removeNodeFromParent(parent);
                    }
                } else if (propertyName.equals(FeatureModelProperties.RELATION_ADDED)) {
                    //--��������˾�����ϵ����endNode��ΪstartNode�����ӽڵ㣬�м���Ϲ�ϵ�ڵ�
                    FeatureRelation fr = (FeatureRelation) evt.getNewValue();
                    String relationName = fr.getName();

                    if (refineRelation.containsKey(relationName)) {
                        Feature start = fr.getStartFeature();
                        Feature end = fr.getEndFeature();
                        FeatureNode startNode = getTreeNode(root, start);
                        FeatureNode endNode = getTreeNode(root, end);

                        if (relationName.equals(FeatureRelation.DECOMPOSE)) {
                            FeatureNode compNode = startNode.getCompositionNode();
                            if (compNode == null) {
                                compNode = new FeatureNode(context, FeatureNode.NODE_TYPE_COMPOSITION);
                                //startNode.add(compNode);
                                treeTableModel.insertNodeInto(compNode, startNode, startNode.getChildCount());
                            }
                            //compNode.add(endNode);
                            treeTableModel.removeNodeFromParent(endNode);
                            treeTableModel.insertNodeInto(endNode, compNode, compNode.getChildCount());
                        } else if (relationName.equals(FeatureRelation.ATTRIBUTE)) {
                            FeatureNode compNode = startNode.getCharacterizationNode();
                            if (compNode == null) {
                                compNode = new FeatureNode(context, FeatureNode.NODE_TYPE_CHARACTERIZATION);
                                //startNode.add(compNode);
                                treeTableModel.insertNodeInto(compNode, startNode, startNode.getChildCount());
                            }
                            //compNode.add(endNode);
                            treeTableModel.removeNodeFromParent(endNode);
                            treeTableModel.insertNodeInto(endNode, compNode, compNode.getChildCount());
                        }
                    }
                } else if (propertyName.equals(FeatureModelProperties.RELATION_REMOVED)) {
                    //--���ɾ���˾�����ϵ����endNode��Ϊroot, ���endNode�ĸ��ڵ�(��ϵ�ڵ㣩û�������ӽڵ��ˣ���ɾ��endNode�ĸ��ڵ�
                    FeatureRelation fr = (FeatureRelation) evt.getOldValue();
                    String relationName = fr.getName();

                    if (refineRelation.containsKey(relationName)) {
                        Feature start = fr.getStartFeature();
                        Feature end = fr.getEndFeature();
                        FeatureNode startNode = getTreeNode(root, start);
                        FeatureNode endNode = getTreeNode(root, end);
                        FeatureNode relationNode = (FeatureNode) endNode.getParent();

                        //root.add(endNode);
View Full Code Here

        constraints.clear();
        constraints.addAll(featureModel.getAllFeatureRelation().values());
        for (Iterator<FeatureRelation> itRelation = constraints.iterator(); itRelation.hasNext();) {
            FeatureRelation relation = itRelation.next();
            if (!htNameMap.containsKey(relation.getID())) {
                Feature start = featureModel.getFeature(htNameMap.get(relation.getStartFeature().getID()));
                Feature end = featureModel.getFeature(htNameMap.get(relation.getEndFeature().getID()));
                if (start != null || end != null) {
                    if (start == null) {
                        start = relation.getStartFeature();
                    }
                    if (end == null) {
                        end = relation.getEndFeature();
                    }
                    FeatureRelation newRelation = featureModelEditor.addRelation(relation.getName(), start, end);
                    htNameMap.put(relation.getID(), newRelation.getID());
                }
            }
        }

        constraints.clear();
        constraints.addAll(constraintModel.getAllGroupConstraint().values());
        for (Iterator<GroupConstraint> itConstraint = constraints.iterator(); itConstraint.hasNext();) {
            GroupConstraint gc = itConstraint.next();

            boolean newFeature = false;
            boolean allNewFeature = true;
            for (Iterator<Feature> itFeature = gc.getFeatureSet().iterator(); itFeature.hasNext();) {
                Feature constraintFeature = itFeature.next();
                if (htNameMap.containsKey(constraintFeature.getID())) {
                    newFeature = true;
                } else {
                    allNewFeature = false;
                }
            }

            GroupConstraint newConstraint = null;
            if (newFeature) {
                if (allNewFeature) {
                    newConstraint = constraintModelEditor.addGroupConstraint();
                    groupConstraintEditor.setType(newConstraint, gc.getType());
                    htNameMap.put(gc.getID(), newConstraint.getID());
                } else {
                    newConstraint = gc;
                }

                for (Iterator<Feature> itFeature = gc.getFeatureSet().iterator(); itFeature.hasNext();) {
                    Feature constraintFeature = itFeature.next();
                    if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
                        constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
                        groupConstraintEditor.addFeature(newConstraint, constraintFeature);
                    }
                }
            }
        }

        constraints.clear();
        constraints.addAll(constraintModel.getAllCompositeConstraint().values());
        for (Iterator<CompositeConstraint> itConstraint = constraints.iterator(); itConstraint.hasNext();) {
            CompositeConstraint gc = itConstraint.next();

            boolean newFeature = false;
            boolean allNewFeature = true;
            for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator(); itFeature.hasNext();) {
                Feature constraintFeature = itFeature.next();
                if (htNameMap.containsKey(constraintFeature.getID())) {
                    newFeature = true;
                } else {
                    allNewFeature = false;
                }
            }
            for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator(); itFeature.hasNext();) {
                Feature constraintFeature = itFeature.next();
                if (htNameMap.containsKey(constraintFeature.getID())) {
                    newFeature = true;
                } else {
                    allNewFeature = false;
                }
            }

            if (newFeature) {
                CompositeConstraint newConstraint = null;
                if (allNewFeature) {
                    newConstraint = constraintModelEditor.addCompositeConstraint();
                    compositeConstraintEditor.setPLType(newConstraint, gc.getPLType());
                    compositeConstraintEditor.setSinkType(newConstraint, gc.getSinkType());
                    compositeConstraintEditor.setSourceType(newConstraint, gc.getSourceType());
                    htNameMap.put(gc.getID(), newConstraint.getID());
                } else {
                    newConstraint = gc;
                }

                for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator(); itFeature.hasNext();) {
                    Feature constraintFeature = itFeature.next();
                    if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
                        constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
                        compositeConstraintEditor.addSourceFeature(newConstraint, constraintFeature);
                    }
                }

                for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator(); itFeature.hasNext();) {
                    Feature constraintFeature = itFeature.next();
                    if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
                        constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
                        compositeConstraintEditor.addSinkFeature(newConstraint, constraintFeature);
                    }
                }
            }
        }

        constraints.clear();
        constraints.addAll(constraintModel.getAllVPConstraint().values());
        for (Iterator<VPConstraint> itConstraint = constraints.iterator(); itConstraint.hasNext();) {
            VPConstraint gc = itConstraint.next();

            boolean newFeature = false;
            boolean allNewFeature = true;
            for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator(); itFeature.hasNext();) {
                Feature constraintFeature = itFeature.next();
                if (htNameMap.containsKey(constraintFeature.getID())) {
                    newFeature = true;
                } else {
                    allNewFeature = false;
                }
            }
            for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator(); itFeature.hasNext();) {
                Feature constraintFeature = itFeature.next();
                if (htNameMap.containsKey(constraintFeature.getID())) {
                    newFeature = true;
                } else {
                    allNewFeature = false;
                }
            }

            if (newFeature) {
                VPConstraint newConstraint = null;
                if (allNewFeature) {
                    newConstraint = constraintModelEditor.addVPConstraint();
                    vpConstraintEditor.setType(newConstraint, gc.getType());
                    htNameMap.put(gc.getID(), newConstraint.getID());
                } else {
                    newConstraint = gc;
                }

                for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator(); itFeature.hasNext();) {
                    Feature constraintFeature = itFeature.next();
                    if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
                        constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
                        vpConstraintEditor.addSourceFeature(newConstraint, constraintFeature);
                    }
                }

                for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator(); itFeature.hasNext();) {
                    Feature constraintFeature = itFeature.next();
                    if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
                        constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
                        vpConstraintEditor.addSinkFeature(newConstraint, constraintFeature);
                    }
                }
            }
        }

        constraints.clear();
        constraints.addAll(constraintModel.getAllCFRelation().values());
        for (Iterator<CFRelation> itConstraint = constraints.iterator(); itConstraint.hasNext();) {
            CFRelation gc = itConstraint.next();

            boolean newFeature = false;
            Feature cfFeature = gc.getFeature();
            if (htNameMap.containsKey(gc.getFeature().getID())) {
                cfFeature = featureModel.getFeature(htNameMap.get(gc.getFeature().getID()));
                newFeature = true;
            }
            Constraint cfConstraint = gc.getConstraint();
View Full Code Here

                CFRelation relation = (CFRelation) evt.getNewValue();
                Constraint constraint = relation.getConstraint();

                if (constraint instanceof VPConstraint) {
                    VPConstraint vpc = (VPConstraint) constraint;
                    Feature feature = relation.getFeature();
                    FeatureNode featureNode = getTreeNode(root, feature);

                    boolean isSource = relation.isSource();
                    if (isSource) { //--������source��ϵ: ���е�sink��Ϊsource���ӽڵ�
                        Iterator<Feature> it = vpc.getSinkFeatureSet().iterator();
                        while (it.hasNext()) {
                            Feature sink = it.next();
                            FeatureNode child = getTreeNode(root, sink);
                            ///---���û��һ�������ϵ�Ľڵ㣬������һ�������Ľڵ�
                            FeatureNode specNode = featureNode.getSpecilizationNode();
                            if (specNode == null) {
                                specNode = new FeatureNode(context, FeatureNode.NODE_TYPE_SPECILIZATION);
                                //featureNode.add(specNode);
                                treeTableModel.insertNodeInto(specNode, featureNode, featureNode.getChildCount());
                            }
                            //specNode.add(child);
                            treeTableModel.removeNodeFromParent(child);
                            treeTableModel.insertNodeInto(child, specNode, specNode.getChildCount());
                        }
                    } else { //--������sink��ϵ: ������sink��Ϊsource��specNode���ӽڵ�
                        Iterator<Feature> it = vpc.getSourceFeatureSet().iterator();
                        if (it.hasNext()) {
                            Feature source = it.next();
                            FeatureNode parent = getTreeNode(root, source);
                            FeatureNode specNode = parent.getSpecilizationNode();
                            if (specNode == null) {
                                specNode = new FeatureNode(context, FeatureNode.NODE_TYPE_SPECILIZATION);
                                //parent.add(specNode);
                                treeTableModel.insertNodeInto(specNode, parent, parent.getChildCount());
                            }
                            //specNode.add(featureNode);
                            treeTableModel.removeNodeFromParent(featureNode);
                            treeTableModel.insertNodeInto(featureNode, specNode, specNode.getChildCount());
                        }
                    }
                }
            } else if (propertyName.equals(ConstraintModelProperties.RELATION_REMOVED)) {
                //--���������VPConstraint�ϵĹ�ϵ��
                CFRelation relation = (CFRelation) evt.getOldValue();
                Constraint constraint = relation.getConstraint();

                if (constraint instanceof VPConstraint) {
                    VPConstraint vpc = (VPConstraint) constraint;
                    Feature feature = relation.getFeature();
                    FeatureNode featureNode = getTreeNode(root, feature);

                    boolean isSource = relation.isSource();
                    if (isSource) { //--ɾ����source��ϵ: ���е�sink��Ϊ���ڵ㣬��������������Ƿ�ɾ��������ϵ�ڵ�
                        Iterator<Feature> it = vpc.getSinkFeatureSet().iterator();
                        FeatureNode specNode = null;
                        while (it.hasNext()) {
                            Feature sink = it.next();
                            FeatureNode sinkNode = getTreeNode(root, sink);
                            specNode = (FeatureNode) sinkNode.getParent();
                            //root.add(sinkNode);
                            treeTableModel.insertNodeInto(sinkNode, root, root.getChildCount());
                        }
View Full Code Here

TOP

Related Classes of de.FeatureModellingTool.FeatureModel.Feature

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.