@Override
 public void setValue(String value, IDirectEditingContext context) {
   PictogramElement pe = context.getPictogramElement();
   Lane lane = (Lane) getBusinessObjectForPictogramElement(pe);
   lane.setName(value);
   updatePictogramElement(((Shape) pe).getContainer());
 }
Пример #2
0
  private int findMissingDIElements(
      DiagramElementTreeNode missing, LaneSet laneSet, List<FlowElement> laneElements) {
    int added = 0;
    if (laneSet != null) {
      for (Lane lane : laneSet.getLanes()) {
        // create the missing tree node for this Lane's container
        // this is either a FlowElementsContainer or another Lane
        BaseElement container = (BaseElement) lane.eContainer().eContainer();
        DiagramElementTreeNode containerNode = missing.getChild(container);
        if (containerNode == null) containerNode = missing.addChild(container);
        DiagramElementTreeNode parentNode = containerNode.addChild(lane);

        for (FlowNode fn : lane.getFlowNodeRefs()) {
          if (isMissingDIElement(fn)) {
            parentNode.addChild(fn);
            laneElements.add(fn);
            ++added;
          }
        }
        added += findMissingDIElements(parentNode, lane.getChildLaneSet(), laneElements);

        if (added == 0) {
          containerNode.removeChild(lane);
          missing.removeChild(container);
        }
      }
    }
    return added;
  }
  public static boolean isInLane(FlowElement fe, LaneSet ls) {
    if (ls == null || ls.getLanes().size() == 0) return false;

    for (Lane ln : ls.getLanes()) {
      if (ln.getFlowNodeRefs().contains(fe)) return true;
      if (isInLane(fe, ln.getChildLaneSet())) return true;
    }
    return false;
  }
 public void moveLane(
     Lane movedLane, Participant sourceParticipant, Participant targetParticipant) {
   Process sourceProcess = getOrCreateProcess(sourceParticipant);
   Process targetProcess = getOrCreateProcess(targetParticipant);
   for (FlowNode node : movedLane.getFlowNodeRefs()) {
     moveFlowNode(node, sourceProcess, targetProcess);
   }
   if (movedLane.getChildLaneSet() != null && !movedLane.getChildLaneSet().getLanes().isEmpty()) {
     for (Lane lane : movedLane.getChildLaneSet().getLanes()) {
       moveLane(lane, sourceParticipant, targetParticipant);
     }
   }
 }
 @Test
 public void testLaneUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller.unmarshall(getTestJsonFile("pool.json"), "").getContents().get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   assertTrue(definitions.getRootElements().get(0) instanceof Process);
   Process process = getRootProcess(definitions);
   assertTrue(process.getLaneSets().size() == 1);
   assertTrue(process.getLaneSets().get(0).getLanes().size() == 1);
   Lane l = process.getLaneSets().get(0).getLanes().get(0);
   assertEquals("my first lane", l.getName());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
  public Lane createLane(Lane targetLane) {
    Lane lane = FACTORY.createLane();
    //		lane.setId(EcoreUtil.generateUUID());
    ModelUtil.setID(lane, resource);

    if (targetLane.getChildLaneSet() == null) {
      targetLane.setChildLaneSet(ModelHandler.FACTORY.createLaneSet());
    }

    LaneSet targetLaneSet = targetLane.getChildLaneSet();
    targetLaneSet.getLanes().add(lane);

    lane.getFlowNodeRefs().addAll(targetLane.getFlowNodeRefs());
    targetLane.getFlowNodeRefs().clear();

    return lane;
  }
 @Override
 public String getInitialValue(IDirectEditingContext context) {
   PictogramElement pe = context.getPictogramElement();
   Lane lane = (Lane) getBusinessObjectForPictogramElement(pe);
   return lane.getName();
 }
  protected ContainerShape createNewShape(
      ModelHandler mh, ContainerShape oldShape, EClass newType) {
    ILayoutService layoutService = Graphiti.getLayoutService();
    boolean horz = Bpmn2Preferences.getInstance().isHorizontalDefault();

    ILocation loc = layoutService.getLocationRelativeToDiagram(oldShape);
    int x = loc.getX();
    int y = loc.getY();
    int xOffset = 0;
    int yOffset = 0;
    GraphicsAlgorithm ga = oldShape.getGraphicsAlgorithm();
    int width = ga.getWidth();
    int height = ga.getHeight();

    BPMN2FeatureProvider fp = (BPMN2FeatureProvider) getFeatureProvider();
    AbstractCreateFeature createFeature =
        (AbstractCreateFeature) fp.getCreateFeatureForBusinessObject(newType.getInstanceClass());

    CreateContext createContext = new CreateContext();
    createContext.putProperty(AbstractCreateFlowElementFeature.SKIP_ADD_GRAPHICS, true);
    createContext.setTargetContainer(oldShape.getContainer());

    FlowElement newObject = null;
    if (createFeature != null) {
      newObject = (FlowElement) createFeature.create(createContext)[0];
    } else {
      newObject = (FlowElement) mh.create(newType);
    }

    ContainerShape containerShape = oldShape.getContainer();
    if (containerShape != getDiagram()) {
      // we are adding a new shape to a control (e.g a SubProcess)
      // so we need to adjust the location to be relative to the
      // control instead of the diagram
      loc = layoutService.getLocationRelativeToDiagram(containerShape);
      xOffset = loc.getX();
      yOffset = loc.getY();
    }
    BaseElement oldObject = BusinessObjectUtil.getFirstElementOfType(oldShape, BaseElement.class);

    if (oldObject instanceof Lane) {
      ((Lane) oldObject).getFlowNodeRefs().add((FlowNode) newObject);
    }
    AddContext ac = new AddContext(new AreaContext(), newObject);
    AbstractAddBpmnShapeFeature af =
        (AbstractAddBpmnShapeFeature) getFeatureProvider().getAddFeature(ac);
    int w = af.getDefaultWidth();
    int h = af.getDefaultHeight();
    if (horz) {
      x += width + 50 + w / 2;
      y += height / 2;
      boolean done = false;
      while (!done) {
        done = true;
        List<Shape> shapes = getFlowElementChildren(containerShape);
        for (Shape s : shapes) {
          if (GraphicsUtil.intersects(s, x - w / 2, y - h / 2, w, h)) {
            y += 100;
            done = false;
            break;
          }
        }
      }
    } else {
      x += width / 2;
      y += height + 50 + h / 2;
      boolean done = false;
      while (!done) {
        done = true;
        List<Shape> shapes = getFlowElementChildren(containerShape);
        for (Shape s : shapes) {
          if (GraphicsUtil.intersects(s, x - w / 2, y - h / 2, w, h)) {
            x += 100;
            done = false;
            break;
          }
        }
      }
    }
    ac.setX(x - xOffset);
    ac.setY(y - yOffset);
    ac.setTargetContainer(oldShape.getContainer());

    return (ContainerShape) getFeatureProvider().addIfPossible(ac);
  }
Пример #9
0
 public static boolean isTargetLaneOnTop(ITargetContext context) {
   Lane lane = BusinessObjectUtil.getFirstElementOfType(context.getTargetContainer(), Lane.class);
   return lane.getChildLaneSet() == null || lane.getChildLaneSet().getLanes().isEmpty();
 }
Пример #10
0
 public static boolean isLaneOnTop(Lane lane) {
   return lane.getChildLaneSet() == null || lane.getChildLaneSet().getLanes().isEmpty();
 }