コード例 #1
0
  /* (non-Javadoc)
   * @see org.eclipse.bpmn2.modeler.ui.property.editors.ObjectEditor#createControl(org.eclipse.swt.widgets.Composite, java.lang.String, int)
   */
  @Override
  protected Control createControl(Composite composite, String label, int style) {
    super.createControl(composite, label, style);

    // we assume that the "Edit" button will handle editing of this read-only text field
    text.setEditable(false);
    GridData textLayoutData = (GridData) text.getLayoutData();
    textLayoutData.horizontalSpan = 1;
    boolean multiLine = ((style & SWT.MULTI) != 0);

    Composite buttons = new Composite(composite, SWT.NONE);
    buttons.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    buttons.setLayout(new FillLayout((style & SWT.MULTI) != 0 ? SWT.VERTICAL : SWT.HORIZONTAL));

    if (canAdd()) {
      addButton = getToolkit().createButton(buttons, null, SWT.PUSH);
      addButton.setImage(Activator.getDefault().getImage(IConstants.ICON_ADD_20));
      if (multiLine) textLayoutData.heightHint += 25;
    }

    if (canRemove()) {
      removeButton = getToolkit().createButton(buttons, null, SWT.PUSH);
      removeButton.setImage(Activator.getDefault().getImage(IConstants.ICON_REMOVE_20));
      if (multiLine) textLayoutData.heightHint += 25;
    }

    defaultButton = getToolkit().createButton(buttons, null, SWT.PUSH);
    defaultButton.setImage(Activator.getDefault().getImage(IConstants.ICON_EDIT_20));

    updateText();

    SelectionAdapter editListener =
        new SelectionAdapter() {

          @SuppressWarnings("unchecked")
          @Override
          public void widgetSelected(SelectionEvent e) {
            int id = ID_DEFAULT_BUTTON;
            if (e.widget == addButton) id = ID_ADD_BUTTON;
            else if (e.widget == removeButton) id = ID_REMOVE_BUTTON;
            buttonClicked(id);
          }
        };
    defaultButton.addSelectionListener(editListener);
    if (canAdd()) addButton.addSelectionListener(editListener);
    if (canRemove()) removeButton.addSelectionListener(editListener);

    return text;
  }
コード例 #2
0
 public FeatureContainer getFeatureContainer() {
   try {
     ClassLoader cl = this.getRuntime().getRuntimeExtension().getClass().getClassLoader();
     Constructor ctor = null;
     Class adapterClass = Class.forName(containerClassName, true, cl);
     ctor = adapterClass.getConstructor();
     return (FeatureContainer) ctor.newInstance();
   } catch (Exception e) {
     Activator.logError(e);
   }
   return null;
 }
コード例 #3
0
  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();

      GraphicsAlgorithm graphicsAlgorithm = connection.getStart().getGraphicsAlgorithm();
      // FIXME connections must create anchors!!!
      if (graphicsAlgorithm != null) {
        point.setX(graphicsAlgorithm.getX());
        point.setY(graphicsAlgorithm.getY());
      } else {
        point.setX(connection.getStart().getParent().getGraphicsAlgorithm().getX());
        point.setY(connection.getStart().getParent().getGraphicsAlgorithm().getY());
      }
      waypoint.add(point);

      if (connection instanceof FreeFormConnectionImpl) {
        FreeFormConnectionImpl freeForm = (FreeFormConnectionImpl) connection;
        EList<org.eclipse.graphiti.mm.algorithms.styles.Point> bendpoints =
            freeForm.getBendpoints();
        for (org.eclipse.graphiti.mm.algorithms.styles.Point bp : bendpoints) {
          addBendPoint(freeForm, point);
        }
      }

      point = DcFactory.eINSTANCE.createPoint();
      graphicsAlgorithm = connection.getEnd().getGraphicsAlgorithm();
      if (graphicsAlgorithm != null) {
        point.setX(graphicsAlgorithm.getX());
        point.setY(graphicsAlgorithm.getY());
      } else {
        point.setX(connection.getEnd().getParent().getGraphicsAlgorithm().getX());
        point.setY(connection.getEnd().getParent().getGraphicsAlgorithm().getY());
      }
      waypoint.add(point);

    } catch (IOException e) {
      Activator.logError(e);
    }
  }
コード例 #4
0
 @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);
     Connection connection = (Connection) getFeatureProvider().addIfPossible(addContext);
     ModelUtil.setID(flow);
     return connection;
   } catch (IOException e) {
     Activator.logError(e);
   }
   return null;
 }
コード例 #5
0
    @Override
    public Object[] create(ICreateContext context) {
      String state = Selectstate(BPMNToolBehaviorProvider.id_v);
      if (state.compareTo("Working") == 0) {
        SubProcess element = createBusinessObject(context);
        // if (element instanceof Task)
        // System.out.println("selectTaskId()"+selectTaskId());
        String id = selectTaskId();
        element.setId("VA" + id + "-1");
        UpdateTaskId(id);
        if (element != null) {
          changesDone = true;
          try {
            ModelHandler handler = ModelHandler.getInstance(getDiagram());
            if (FeatureSupport.isTargetLane(context) && element instanceof FlowNode) {
              ((FlowNode) element)
                  .getLanes()
                  .add((Lane) getBusinessObjectForPictogramElement(context.getTargetContainer()));
            }
            handler.addFlowElement(
                getBusinessObjectForPictogramElement(context.getTargetContainer()), element);
          } catch (IOException e) {
            Activator.logError(e);
          }
          PictogramElement pe = null;
          pe = addGraphicalRepresentation(context, element);
          return new Object[] {element, pe};
        } else changesDone = false;
        return new Object[] {null};
      } else {
        System.out.println("01102015tttttttttttt");
        JOptionPane.showMessageDialog(
            null,
            "Operation is not allowed because the version of process "
                + BPMNToolBehaviorProvider.id_v
                + " is Stable",
            "Error",
            JOptionPane.ERROR_MESSAGE);

        return new Object[] {null};
      }
    }
  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);
    }
  }
コード例 #7
0
  @Override
  public void resizeShape(IResizeShapeContext context) {

    ResizeShapeContext resizeShapeContext = (ResizeShapeContext) context;

    ContainerShape containerShape = (ContainerShape) context.getPictogramElement();
    Activity activity = BusinessObjectUtil.getFirstElementOfType(containerShape, Activity.class);
    try {
      BPMNShape shape =
          (BPMNShape)
              ModelHandlerLocator.getModelHandler(getDiagram().eResource()).findDIElement(activity);

      if (shape.isIsExpanded()) {

        // SubProcess is expanded

        GraphicsAlgorithm parentGa = containerShape.getGraphicsAlgorithm();
        int newWidth = resizeShapeContext.getWidth();
        int newHeight = resizeShapeContext.getHeight();
        SizeCalculator sizeCalc = new SizeCalculator(containerShape);
        int shiftX = sizeCalc.shiftX;
        int shiftY = sizeCalc.shiftY;
        int minWidth = sizeCalc.minWidth;
        int minHeight = sizeCalc.minHeight;

        if (shiftX < 0) {
          for (PictogramElement pe : FeatureSupport.getContainerChildren(containerShape)) {
            GraphicsAlgorithm childGa = pe.getGraphicsAlgorithm();
            if (childGa != null) {
              int x = childGa.getX() - shiftX + MARGIN;
              childGa.setX(x);
            }
          }
          resizeShapeContext.setX(resizeShapeContext.getX() + shiftX - MARGIN);
          shiftX = MARGIN;
        }

        if (shiftY < 0) {
          for (PictogramElement pe : FeatureSupport.getContainerChildren(containerShape)) {
            GraphicsAlgorithm childGa = pe.getGraphicsAlgorithm();
            if (childGa != null) {
              int y = childGa.getY() - shiftY + MARGIN;
              childGa.setY(y);
            }
          }
          resizeShapeContext.setY(resizeShapeContext.getY() + shiftY - MARGIN);
          shiftX = MARGIN;
        }

        if (shiftX < MARGIN) shiftX = MARGIN;
        if (shiftY < MARGIN) shiftY = MARGIN;
        minWidth += 2 * MARGIN;
        minHeight += 2 * MARGIN;

        if (newWidth < minWidth) {
          parentGa.setWidth(minWidth);
        }
        if (newWidth < shiftX + minWidth) {
          int shift = shiftX + minWidth - newWidth;
          if (shift > shiftX - MARGIN) {
            shift = shiftX - MARGIN;
          }
          if (shift > 0) {
            for (PictogramElement pe : FeatureSupport.getContainerChildren(containerShape)) {
              GraphicsAlgorithm childGa = pe.getGraphicsAlgorithm();
              if (childGa != null) {
                int x = childGa.getX() - shift;
                childGa.setX(x);
              }
            }
          }
        }
        if (newHeight < minHeight) {
          parentGa.setHeight(minHeight);
        }
        if (newHeight < shiftY + minHeight) {
          int shift = shiftY + minHeight - newHeight;
          if (shift > shiftY - MARGIN) {
            shift = shiftY - MARGIN;
          }
          if (shift > 0) {
            for (PictogramElement pe : FeatureSupport.getContainerChildren(containerShape)) {
              GraphicsAlgorithm childGa = pe.getGraphicsAlgorithm();
              if (childGa != null) {
                int y = childGa.getY() - shift;
                childGa.setY(y);
              }
            }
          }
        }

        if (resizeShapeContext.getWidth() < minWidth) resizeShapeContext.setWidth(minWidth);
        if (resizeShapeContext.getHeight() < minHeight) resizeShapeContext.setHeight(minHeight);
      } else {

        // SubProcess is collapsed

        for (PictogramElement pe : FeatureSupport.getContainerDecorators(containerShape)) {
          GraphicsAlgorithm childGa = pe.getGraphicsAlgorithm();
          if (childGa != null) {
            childGa.setWidth(GraphicsUtil.getActivitySize(getDiagram()).getWidth());
            childGa.setHeight(GraphicsUtil.getActivitySize(getDiagram()).getHeight());
          }
        }

        resizeShapeContext.setWidth(GraphicsUtil.getActivitySize(getDiagram()).getWidth());
        resizeShapeContext.setHeight(GraphicsUtil.getActivitySize(getDiagram()).getHeight());
      }

    } catch (Exception e) {
      Activator.logError(e);
    }
    Graphiti.getPeService().sendToBack(containerShape);

    super.resizeShape(context);
  }