@Override
  public boolean appliesTo(IWorkbenchPart part, ISelection selection) {

    // should we delegate to the section to determine whether it should be included in this tab?
    if (sectionClass instanceof IBpmn2PropertySection) {
      return ((IBpmn2PropertySection) sectionClass).appliesTo(part, selection);
    }

    // if an input description was specified, check if the selected business object is of this
    // description.
    if (appliesToClass != null) {
      PictogramElement pe = BusinessObjectUtil.getPictogramElementForSelection(selection);
      // this is a special hack to allow selection of connection decorator labels:
      // the connection decorator does not have a business object linked to it,
      // but its parent (the connection) does.
      if (pe.getLink() == null && pe.eContainer() instanceof PictogramElement)
        pe = (PictogramElement) pe.eContainer();

      // check all linked BusinessObjects for a match
      if (pe.getLink() != null) {
        for (EObject eObj : pe.getLink().getBusinessObjects()) {
          if (appliesToClass.isInstance(eObj)) {
            return true;
          }
        }
      }
      return false;
    }
    return true;
  }
  @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);
      }
    }
  }
 private File getFileDomainObject(IContext context) {
   if (context instanceof ICustomContext) {
     PictogramElement[] pictogramElements = ((ICustomContext) context).getPictogramElements();
     if (pictogramElements.length == 1) {
       PictogramElement pictogramElement = pictogramElements[0];
       Object domainObject = getBusinessObjectForPictogramElement(pictogramElement);
       if (domainObject instanceof File) {
         if (pictogramElement instanceof Shape
             && pictogramElement.eContainer() instanceof ContainerShape
             && pictogramElement.eContainer().eContainer() instanceof ContainerShape) {
           if (getBusinessObjectForPictogramElement(
                   (ContainerShape) pictogramElement.eContainer().eContainer())
               instanceof Folder) {
             return (File) domainObject;
           }
         }
       }
     }
   }
   return null;
 }
Exemplo n.º 4
0
 public static boolean isChoreographyParticipantBand(PictogramElement element) {
   if (element != null) {
     EObject container = element.eContainer();
     if (container instanceof PictogramElement) {
       PictogramElement containerElem = (PictogramElement) container;
       Object bo =
           Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(containerElem);
       if (bo instanceof ChoreographyActivity) {
         return true;
       }
     }
   }
   return false;
 }