Package org.eclipse.bpmn2.modeler.core

Examples of org.eclipse.bpmn2.modeler.core.ModelHandler


    return top.anchor;
  }

  public static void reConnect(BPMNShape shape, Diagram diagram) {
    try {
      ModelHandler handler = ModelHandler.getInstance(diagram);
      for (BPMNEdge bpmnEdge : handler.getAll(BPMNEdge.class)) {
        DiagramElement sourceElement = bpmnEdge.getSourceElement();
        DiagramElement targetElement = bpmnEdge.getTargetElement();
        if (sourceElement != null && targetElement != null) {
          boolean sourceMatches = sourceElement.getId().equals(shape.getId());
          boolean targetMatches = targetElement.getId().equals(shape.getId());
View Full Code Here


    }
  }

  public static void updateDIEdge(Diagram diagram, Connection connection, Class clazz) {
    try {
      ModelHandler modelHandler = ModelHandlerLocator.getModelHandler(connection.getLink().getBusinessObjects()
          .get(0).eResource());

      EObject be = BusinessObjectUtil.getFirstElementOfType(connection, clazz);
      BPMNEdge edge = (BPMNEdge) modelHandler.findDIElement(diagram, (BaseElement) be);
      Point point = DcFactory.eINSTANCE.createPoint();

      List<Point> waypoint = edge.getWaypoint();
      waypoint.clear();
View Full Code Here

  @Override
  public Connection create(ICreateConnectionContext context) {
    try {
      A source = getSourceBo(context);
      B target = getTargetBo(context);
      ModelHandler mh = ModelHandler.getInstance(getDiagram());
      AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(),
          context.getTargetAnchor());
      BaseElement flow = createFlow(mh, source, target);
//      flow.setId(EcoreUtil.generateUUID());
      addContext.setNewObject(flow);
View Full Code Here

      if (source == null || target == null) {
        return true;
      }
      boolean different = false;
      try {
        ModelHandler handler = ModelHandler.getInstance(getDiagram());
        Participant sourceParticipant = handler.getParticipant(source);
        Participant targetParticipant = handler.getParticipant(target);
        different = !sourceParticipant.equals(targetParticipant);
      } catch (IOException e) {
        Activator.logError(e);
      }
      return different;
View Full Code Here

  @Override
  public Object[] create(ICreateContext context) {
    BoundaryEvent event = null;
    try {
      Activity activity = (Activity) getBusinessObjectForPictogramElement(context.getTargetContainer());
      ModelHandler handler = ModelHandler.getInstance(getDiagram());
      event = ModelHandler.FACTORY.createBoundaryEvent();
//      event.setId(EcoreUtil.generateUUID());
      event.setAttachedToRef(activity);
      event.setName("Boundary event");
      event.setCancelActivity(true); // by default is interrupting
      Object bo = getBusinessObjectForPictogramElement(context.getTargetContainer());
      if (bo instanceof FlowElementsContainer) {
        bo = getBusinessObjectForPictogramElement((PictogramElement) context.getTargetContainer().eContainer());
      }
      handler.addFlowElement(bo, event);
    } catch (IOException e) {
      Activator.logError(e);
    }
    addGraphicalRepresentation(context, event);
    ModelUtil.setID(event);
View Full Code Here

  public void selectionChanged(IWorkbenchPart part, ISelection selection) {

    if (part instanceof BPMN2Editor) {
      editor = (BPMN2Editor) part;
      try {
        ModelHandler modelHandler = ModelHandlerLocator.getModelHandler(editor.getDiagramTypeProvider()
            .getDiagram().eResource());
        contentProvider.updateModel(modelHandler);
        viewer.refresh(true);
      } catch (IOException e) {
        e.printStackTrace();
View Full Code Here

  public void removeBendpoint(IRemoveBendpointContext context) {
      super.removeBendpoint(context);
      try {
      FreeFormConnection connection = context.getConnection();
      BaseElement element = (BaseElement) BusinessObjectUtil.getFirstElementOfType(connection, BaseElement.class);
      ModelHandler modelHandler = ModelHandlerLocator.getModelHandler(getDiagram().eResource());
      BPMNEdge edge = (BPMNEdge) modelHandler.findDIElement(getDiagram(), element);
      edge.getWaypoint().remove(context.getBendpointIndex() + 1);
    } catch (Exception e) {
      Activator.logError(e);
    }
  }
View Full Code Here

  public void addBendpoint(IAddBendpointContext context) {
    super.addBendpoint(context);
    try {
      FreeFormConnection connection = context.getConnection();
      BaseElement element = (BaseElement) BusinessObjectUtil.getFirstElementOfType(connection, BaseElement.class);
      ModelHandler modelHandler = ModelHandlerLocator.getModelHandler(getDiagram().eResource());

      Point p = DcFactory.eINSTANCE.createPoint();
      p.setX(context.getX());
      p.setY(context.getY());

      BPMNEdge edge = (BPMNEdge) modelHandler.findDIElement(getDiagram(), element);
      int index = context.getBendpointIndex() + 1;
      edge.getWaypoint().add(index, p);
      if (index == 1) {
        AnchorUtil.reConnect((BPMNShape) edge.getSourceElement(), getDiagram());
      } else if (index == connection.getBendpoints().size()) {
View Full Code Here

  @Override
  public Object[] create(ICreateContext context) {
    Lane lane = null;
    try {
      ModelHandler mh = ModelHandlerLocator.getModelHandler(getDiagram().eResource());
      Object o = getBusinessObjectForPictogramElement(context.getTargetContainer());
      if (FeatureSupport.isTargetLane(context)) {
        Lane targetLane = (Lane) o;
        lane = mh.createLane(targetLane);
      } else {
        lane = mh.createLane(o);
      }
      lane.setName("Lane nr " + index++);
    } catch (IOException e) {
      Activator.logError(e);
    }
View Full Code Here

  public boolean moveBendpoint(IMoveBendpointContext context) {
    boolean moved = super.moveBendpoint(context);
    try {
      FreeFormConnection connection = context.getConnection();
      BaseElement element = (BaseElement) BusinessObjectUtil.getFirstElementOfType(connection, BaseElement.class);
      ModelHandler modelHandler = ModelHandlerLocator.getModelHandler(getDiagram().eResource());
      BPMNEdge edge = (BPMNEdge) modelHandler.findDIElement(getDiagram(), element);
      int index = context.getBendpointIndex() + 1;
      Point p = edge.getWaypoint().get(index);
      p.setX(context.getX());
      p.setY(context.getY());
      if (index == 1) {
View Full Code Here

TOP

Related Classes of org.eclipse.bpmn2.modeler.core.ModelHandler

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.