示例#1
0
 @Override
 protected void removeChildVisual(EditPart childEditPart) {
   IFigure figure = ((AbstractGraphicalEditPart) childEditPart).getFigure();
   if (figure instanceof InstanceFigure) {
     InstanceFigure instanceFig = ((InstanceFigure) figure);
     ((DiagramModel) getModel()).getInstancePanel().remove(instanceFig);
     getLayer(SeqEditor.LIFE_LINE_IN_INSTANCE_PANEL_LAYER)
         .remove(instanceFig.getLifeLineInInstancePanel());
     getContentPane().remove(instanceFig.getChildrenContainer());
     getLayer(SeqEditor.LIFE_LINE_LAYER).remove(instanceFig.getLifeLine());
   } else if (figure instanceof HiddenFigure) {
     int index = getContentPane().getChildren().indexOf(figure);
     List<?> instancePanelChildren = ((DiagramModel) getModel()).getInstancePanel().getChildren();
     if (index >= 0
         && index < instancePanelChildren.size()
         && instancePanelChildren.get(index) instanceof HiddenFigure) {
       ((DiagramModel) getModel())
           .getInstancePanel()
           .remove((HiddenFigure) instancePanelChildren.get(index));
     }
     super.removeChildVisual(childEditPart);
   } else if (figure instanceof ControlFlowBlock) {
     SeqOrderedLayoutEditPolicy policy =
         (SeqOrderedLayoutEditPolicy) getEditPolicy(EditPolicy.LAYOUT_ROLE);
     policy.removeConditionalFigure(figure);
   } else {
     super.removeChildVisual(childEditPart);
   }
 }
示例#2
0
 @Override
 protected void addChildVisual(EditPart childEditPart, int index) {
   IFigure figure = ((AbstractGraphicalEditPart) childEditPart).getFigure();
   if (figure instanceof InstanceFigure) {
     InstanceFigure instanceFig = ((InstanceFigure) figure);
     ((DiagramModel) getModel()).getInstancePanel().add(instanceFig, index);
     getLayer(SeqEditor.LIFE_LINE_IN_INSTANCE_PANEL_LAYER)
         .add(instanceFig.getLifeLineInInstancePanel());
     getContentPane().add(instanceFig.getChildrenContainer(), index);
     getLayer(SeqEditor.LIFE_LINE_LAYER).add(instanceFig.getLifeLine());
   } else if (figure instanceof HiddenFigure) {
     super.addChildVisual(childEditPart, index);
     ((DiagramModel) getModel()).getInstancePanel().add(new HiddenFigure(false, ""), index);
   } else if (figure instanceof ControlFlowBlock) {
     SeqOrderedLayoutEditPolicy policy =
         (SeqOrderedLayoutEditPolicy) getEditPolicy(EditPolicy.LAYOUT_ROLE);
     policy.addConditionalFigure(figure);
   } else {
     super.addChildVisual(childEditPart, index);
   }
 }
示例#3
0
 @Override
 public void deactivate() {
   if (!isActive()) return;
   BuildStatus.updateDiagramItemMap(
       getViewer().getEditDomain().getCommandStack().toString(), getAllChildren());
   getViewer()
       .getEditDomain()
       .getCommandStack()
       .removeCommandStackEventListener(stackEventListener);
   super.deactivate();
   ((DiagramModel) getModel()).removePropertyChangeListener(this);
 }
示例#4
0
 @Override
 public void propertyChange(PropertyChangeEvent evt) {
   super.propertyChange(evt);
   String propName = evt.getPropertyName();
   if (NodeModel.PROPERTY_CHILDREN.equals(propName)) {
     refreshChildren();
   } else if (NodeModel.PROPERTY_CONDITIONAL_CHILDREN.equals(propName)) {
     refreshChildren();
   } else if (NodeModel.PROPERTY_REORDER.equals(propName)) {
     ArtifactFragment childModel = (ArtifactFragment) evt.getOldValue();
     EditPart childEP = null;
     for (Object ep : getChildren()) {
       if (ep instanceof EditPart && ((EditPart) ep).getModel().equals(childModel)) {
         childEP = (EditPart) ep;
         break;
       }
     }
     if (childEP != null) reorderChild(childEP, (Integer) evt.getNewValue());
   }
 }
示例#5
0
  @Override
  public void performRequest(Request request) {
    if (request.getType() == RequestConstants.REQ_DIRECT_EDIT
        || request.getType() == RequestConstants.REQ_OPEN) {
      for (ControlFlowEditPart controlFlowEP : getRootConditionalChildren()) {
        controlFlowEP.refresh();
        // make sure loaded diagram puts figs in the right spot
        if (!((ControlFlowModel) controlFlowEP.getModel()).getInnerConditionalModels().isEmpty()) {
          controlFlowEP.refresh();
        }
        // ControlFlowBlock block = null;
        if (controlFlowEP != null && controlFlowEP instanceof UserCreatedControlFlowEditPart) {
          if (((ControlFlowBlock) controlFlowEP.getFigure())
              .getBounds()
              .contains(((LocationRequest) request).getLocation())) {
            ((UserCreatedControlFlowEditPart) controlFlowEP).performDirectEdit();
          }
        }
      }

    } else super.performRequest(request);
  }
示例#6
0
  @Override
  public void activate() {
    if (isActive()) return;
    super.activate();
    Value detailLevel = null;
    try {
      detailLevel =
          ((RepositoryMgr) ((RootArtifact) getModel()).getRepo())
              .getFileRepo()
              .getStatement(RSECore.createRseUri("DetailNode"), RSECore.detailLevelURI, null)
              .getObject();
    } catch (Throwable t) {

    }
    if (detailLevel != null) {
      ((RootArtifact) getModel())
          .setDetailLevel(Integer.valueOf(((Literal) detailLevel).getLabel()));
    }

    DiagramModel diagramModel = ((DiagramModel) getModel());
    diagramModel.addPropertyChangeListener(this);
    NonEmptyFigureSupport.listenToModel((ArtifactFragment) getModel(), nonEmptyFigure);
    getViewer().getEditDomain().getCommandStack().addCommandStackEventListener(stackEventListener);
    addInstancePanel();

    if (diagramModel.getRepo() != null && diagramModel.getSavedDiagramResource() != null) {
      // Use the file repo to get the information
      ReloRdfRepository repo = diagramModel.getRepo().getFileRepo();
      Map<Resource, ArtifactFragment> instanceRes2AFMap = new HashMap<Resource, ArtifactFragment>();
      instanceResToAF = new HashMap<Resource, ArtifactFragment>();
      addSavedContainee(
          diagramModel, diagramModel.getSavedDiagramResource(), instanceRes2AFMap, repo);
      addSavedControlFlows(
          diagramModel, diagramModel.getSavedDiagramResource(), instanceRes2AFMap, repo);
      addSavedConnections(diagramModel, instanceRes2AFMap, repo);
    }
  }