@Override
  protected void postMoveShape(final IMoveShapeContext context) {
    super.postMoveShape(context);
    PictogramElement containerShape = context.getPictogramElement();
    Activity activity = BusinessObjectUtil.getFirstElementOfType(containerShape, Activity.class);
    GraphicsUtil.sendToFront(context.getShape());

    new AbstractBoundaryEventOperation() {
      @Override
      protected void doWorkInternal(ContainerShape container) {
        GraphicsAlgorithm ga = container.getGraphicsAlgorithm();

        MoveShapeContext newContext = new MoveShapeContext(container);
        newContext.setDeltaX(context.getDeltaX());
        newContext.setDeltaY(context.getDeltaY());
        newContext.setSourceContainer(context.getSourceContainer());
        newContext.setTargetContainer(context.getTargetContainer());
        newContext.setTargetConnection(context.getTargetConnection());
        newContext.setLocation(ga.getX(), ga.getY());
        newContext.putProperty(ACTIVITY_MOVE_PROPERTY, true);

        IMoveShapeFeature moveFeature = getFeatureProvider().getMoveShapeFeature(newContext);
        if (moveFeature.canMoveShape(newContext)) {
          moveFeature.moveShape(newContext);
        }
      }
    }.doWork(activity, getDiagram());

    if (containerShape.eContainer() instanceof ContainerShape) {
      PictogramElement pe = (PictogramElement) containerShape.eContainer();
      if (BusinessObjectUtil.containsElementOfType(pe, SubProcess.class)) {
        layoutPictogramElement(pe);
      }
    }
  }
Ejemplo n.º 2
0
 private void movePin(Pin pin, IMoveShapeContext context) {
   PictogramElement pinShape = getPinShape(pin);
   if (pinShape != null) {
     GraphicsAlgorithm pinArea = pinShape.getGraphicsAlgorithm();
     pinArea.setX(pinArea.getX() + context.getDeltaX());
     pinArea.setY(pinArea.getY() + context.getDeltaY());
   }
 }
  @Override
  protected void preMoveShape(IMoveShapeContext context) {
    MoveShapeContext msc = (MoveShapeContext) context;
    ContainerShape oldContainer = context.getSourceContainer();
    ContainerShape newContainer = context.getTargetContainer();
    IPeLayoutService peLayoutService = Graphiti.getPeLayoutService();
    //		Shape shape = context.getShape();
    //		ILocation loc = peService.getLocationRelativeToDiagram(shape);
    ILocation oldLoc = peLayoutService.getLocationRelativeToDiagram(oldContainer);
    ILocation newLoc = peLayoutService.getLocationRelativeToDiagram(newContainer);
    //		System.out.println(
    //				(oldContainer==newContainer ? "inside:\n" : "outside:\n")+
    //				"oldContainer:\n" +
    //				"  x="+oldLoc.getX()+"\n"+
    //					"  y="+oldLoc.getY()+"\n"+
    //				"newContainer:\n" +
    //				"  x="+newLoc.getX()+"\n"+
    //					"  y="+newLoc.getY()+"\n"+
    //				"shape:\n" +
    //				"  rel x="+shape.getGraphicsAlgorithm().getX()+"\n"+
    //					"  rel y="+shape.getGraphicsAlgorithm().getY()+"\n"+
    //				"  abs x="+loc.getX()+"\n"+
    //					"  abs y="+loc.getY()+"\n"+
    //				"context:\n" +
    //				"  x="+msc.getX()+"\n"+
    //					"  y="+msc.getY()+"\n"+
    //				"  deltaX="+msc.getDeltaX()+"\n"+
    //					"  deltaY="+msc.getDeltaY()+"\n"+
    //				"\n"
    //		);

    if (oldContainer != newContainer) {
      int x = newLoc.getX() + msc.getX() - oldLoc.getX();
      int y = newLoc.getY() + msc.getY() - oldLoc.getY();
      int deltaX = newLoc.getX() + msc.getDeltaX() - oldLoc.getX();
      int deltaY = newLoc.getY() + msc.getDeltaY() - oldLoc.getY();

      //			System.out.println(
      //					"new context:\n"+
      //					"  x="+( newLoc.getX() + msc.getX() - oldLoc.getX() )+"\n"+
      //								"  y="+msc.getY()+"\n"+
      //					"  deltaX="+( newLoc.getX() + msc.getDeltaX() - oldLoc.getX() )+"\n"+
      //								"  deltaY="+msc.getDeltaY()+"\n"+
      //					"\n"
      //			);

      //			msc.setX(x);
      //			msc.setY(y);
      //			msc.setDeltaX(deltaX);
      //			msc.setDeltaY(deltaY);
      //			msc.setTargetContainer(oldContainer);
    }

    super.preMoveShape(context);
  }
Ejemplo n.º 4
0
 @Override
 public void moveShape(IMoveShapeContext context) {
   super.moveShape(context);
   Object bo = getBusinessObjectForPictogramElement(context.getPictogramElement());
   if (bo instanceof Action) {
     Action action = (Action) bo;
     relocatePins(action, context);
   }
 }
  private void modifyModelStructure(IMoveShapeContext context) {
    Lane movedLane = getMovedLane(context);
    Process sourceProcess = getProcess(context.getSourceContainer());
    Process targetProcess = getProcess(context.getTargetContainer());
    moveLane(movedLane, sourceProcess, targetProcess);

    for (LaneSet laneSet : sourceProcess.getLaneSets()) {
      if (laneSet.getLanes().contains(movedLane)) {
        laneSet.getLanes().remove(movedLane);
        if (laneSet.getLanes().isEmpty()) {
          sourceProcess.getLaneSets().remove(laneSet);
        }

        if (targetProcess.getLaneSets().isEmpty()) {
          LaneSet newLaneSet = createLaneSet();
          targetProcess.getLaneSets().add(newLaneSet);
        }
        targetProcess.getLaneSets().get(0).getLanes().add(movedLane);
        break;
      }
    }
  }
Ejemplo n.º 6
0
 @Override
 public void moveShape(IMoveShapeContext context) {
   // if this Label Shape is part of a multiselection, and if its owner is included
   // in that multiselection, then do not move the label. Moving the label is
   // already handled by the label's owner.
   PictogramElement pes[] =
       getFeatureProvider()
           .getDiagramTypeProvider()
           .getDiagramBehavior()
           .getDiagramContainer()
           .getSelectedPictogramElements();
   Shape shape = context.getShape();
   for (PictogramElement pe : pes) {
     ContainerShape s = BusinessObjectUtil.getFirstElementOfType(pe, ContainerShape.class);
     if (s == shape) return;
   }
   super.moveShape(context);
 }
  private void modifyModelStructure(IMoveShapeContext context) {
    Lane movedLane = getMovedLane(context);
    Participant sourceParticipant =
        (Participant) getBusinessObjectForPictogramElement(context.getSourceContainer());
    Participant internalParticipant = null;

    try {
      ModelHandler handler = ModelHandler.getInstance(getDiagram());
      internalParticipant = handler.getInternalParticipant();
      handler.moveLane(movedLane, internalParticipant);
    } catch (IOException e) {
      Activator.logError(e);
    }

    LaneSet laneSet = null;
    for (LaneSet set : sourceParticipant.getProcessRef().getLaneSets()) {
      if (set.getLanes().contains(movedLane)) {
        laneSet = set;
        break;
      }
    }

    if (laneSet != null) {
      laneSet.getLanes().remove(movedLane);
      if (laneSet.getLanes().isEmpty()) {
        sourceParticipant.getProcessRef().getLaneSets().remove(laneSet);
      }

      Process process = internalParticipant.getProcessRef();
      if (process.getLaneSets().isEmpty()) {
        LaneSet createLaneSet = ModelHandler.FACTORY.createLaneSet();
        //				createLaneSet.setId(EcoreUtil.generateUUID());
        process.getLaneSets().add(createLaneSet);
        ModelUtil.setID(createLaneSet);
      }
      process.getLaneSets().get(0).getLanes().add(movedLane);
    }
  }
 @Override
 protected void internalMove(IMoveShapeContext context) {
   modifyModelStructure(context);
   layoutPictogramElement(context.getSourceContainer());
 }
 @Override
 protected void internalMove(IMoveShapeContext context) {
   modifyModelStructure(context);
   FeatureSupport.redraw(context.getSourceContainer());
 }