Пример #1
0
  /**
   * Return a list of the model children that should be displayed. This includes activities (if
   * includeActivity is true), fault handlers, compensation handlers and event handlers.
   */
  protected List<EObject> getModelChildren(boolean includeActivity) {
    ArrayList<EObject> children = new ArrayList<EObject>();
    if (includeActivity) {
      // Use IContainer here for implicit sequence handling
      IContainer container = BPELUtil.adapt(getModel(), IContainer.class);
      for (Iterator<EObject> it = container.getChildren(getModel()).iterator(); it.hasNext(); ) {
        EObject child = it.next();
        if (child instanceof Activity) children.add(child);
      }
    }

    if (showFH) {
      FaultHandler faultHandler = this.getFaultHandler();
      if (faultHandler != null) children.add(children.size(), faultHandler);
    }

    if (showCH) {
      CompensationHandler compensationHandler = this.getCompensationHandler();
      if (compensationHandler != null) children.add(children.size(), compensationHandler);
    }

    if (showTH) {
      TerminationHandler terminationHandler = this.getTerminationHandler();
      if (terminationHandler != null) children.add(children.size(), terminationHandler);
    }

    if (showEH) {
      EventHandler eventHandler = this.getEventHandler();
      if (eventHandler != null) children.add(children.size(), eventHandler);
    }

    return children;
  }
Пример #2
0
 public EventHandler getEventHandler() {
   IEventHandlerHolder holder = BPELUtil.adapt(getActivity(), IEventHandlerHolder.class);
   if (holder != null) {
     return holder.getEventHandler(getActivity());
   }
   return null;
 }
Пример #3
0
 public FaultHandler getFaultHandler() {
   IFaultHandlerHolder holder = BPELUtil.adapt(getProcess(), IFaultHandlerHolder.class);
   if (holder != null) {
     return holder.getFaultHandler(getProcess());
   }
   return null;
 }
Пример #4
0
  protected IFigure createFigure() {
    if (image == null) {
      ILabeledElement element = BPELUtil.adapt(getStartNode(), ILabeledElement.class);
      image = element.getSmallImage(getStartNode());
      Rectangle rect = image.getBounds();
      imageWidth = rect.width;
      imageHeight = rect.height;
    }
    this.hasFH = getFaultHandler() != null;
    this.hasEH = getEventHandler() != null;
    // Cause the handlerIcons don't belong to the
    // bounds of the StartNodeFigure (as a result of
    // moving them a bit to the right in vertical layout and a bit to to the bottom
    // in horizontal layout) hit testing
    // doesn't reach the Startnode. So add an invisible
    // border
    StartNodeFigure snf = new StartNodeFigure();
    if (!ModelHelper.isHorizontalLayout(getModel()))
      snf.setBorder(new MarginBorder(0, 7 + BORDER_WIDTH, 0, 7 + BORDER_WIDTH));
    else snf.setBorder(new MarginBorder(5, 0, 5, 0));

    faultImageFigure = new ImageFigure(faultImage);
    faultImageFigure.setParent(snf);

    eventImageFigure = new ImageFigure(eventImage);
    eventImageFigure.setParent(snf);

    return snf;
  }
Пример #5
0
 public TerminationHandler getTerminationHandler() {
   ITerminationHandlerHolder holder =
       BPELUtil.adapt(getActivity(), ITerminationHandlerHolder.class);
   if (holder != null) {
     return holder.getTerminationHandler(getActivity());
   }
   return null;
 }
Пример #6
0
 public CompensationHandler getCompensationHandler() {
   ICompensationHandlerHolder holder =
       BPELUtil.adapt(getActivity(), ICompensationHandlerHolder.class);
   if (holder != null) {
     return holder.getCompensationHandler(getActivity());
   }
   return null;
 }
Пример #7
0
 /** Return a string which should be displayed in this node while collapsed. */
 @Override
 protected String getLabel() {
   ILabeledElement element = BPELUtil.adapt(getActivity(), ILabeledElement.class);
   if (element != null) {
     return element.getLabel(getActivity());
   }
   return null;
 }
  /**
   * (non-Javadoc)
   *
   * @see org.eclipse.bpel.ui.IHoverHelper#getHoverFigure(org.eclipse.emf.ecore.EObject)
   */
  public IFigure getHoverFigure(EObject modelObject) {

    IHoverHelper delegate = BPELUtil.adapt(modelObject, IHoverHelper.class);
    if (delegate != null) {
      return delegate.getHoverFigure(modelObject);
    }
    return null;
  }
Пример #9
0
  @Override
  protected IFigure createFigure() {
    // TODO: Shouldn't have to initialize labels in each subclass.
    initializeLabels();
    if (collapsedImage == null) {
      // Create the actual figure for the collapsed edit part
      ILabeledElement element = BPELUtil.adapt(getActivity(), ILabeledElement.class);
      collapsedImage = element.getSmallImage(getActivity());
    }
    this.collapsedImageLabel = new Label(collapsedImage);
    this.collapsedNameLabel = new Label(getLabel());

    // TODO: Shouldn't have to set the decorator in each subclass.
    editPartMarkerDecorator =
        new BPELEditPartMarkerDecorator(
            (EObject) getModel(),
            new CollapsableDecorationLayout(/*collapsedImage.getBounds().width*/ 0));
    editPartMarkerDecorator.addMarkerMotionListener(getMarkerMotionListener());

    this.parentFigure = new Figure();
    AlignedFlowLayout layout = new AlignedFlowLayout();
    layout.setHorizontal(true);
    layout.setHorizontalSpacing(0);
    layout.setVerticalSpacing(0);
    parentFigure.setLayoutManager(layout);

    this.contentFigure = new CollapsableScopeContainerFigure(getModel(), getImage(), getLabel());
    contentFigure.addMouseMotionListener(getMouseMotionListener());
    contentFigure.setEditPart(this);
    contentFigure.setForegroundColor(
        BPELUIPlugin.INSTANCE.getColorRegistry().get(IBPELUIConstants.COLOR_BLACK));
    parentFigure.add(contentFigure);

    // Configure the border and contents based on collapsed state
    if (isCollapsed()) {
      configureCollapsedFigure(contentFigure);
    } else {
      configureExpandedFigure(contentFigure);
    }

    boolean isHorizontal = ModelHelper.isHorizontalLayout(getModel());

    this.auxilaryFigure = new AuxiliaryFigure();
    layout = new AlignedFlowLayout();
    layout.setHorizontal(!isHorizontal);
    auxilaryFigure.setLayoutManager(layout);
    contentFigure.addFigureListener(auxilaryFigure);

    parentFigure.add(auxilaryFigure);

    ScopeBorder border = getScopeBorder();
    border.setShowFault(getFaultHandler() != null);
    border.setShowCompensation(getCompensationHandler() != null);
    border.setShowTermination(getTerminationHandler() != null);
    border.setShowEvent(getEventHandler() != null);

    return editPartMarkerDecorator.createFigure(parentFigure);
  }
 @Override
 protected void basicSetInput(EObject newInput) {
   if (newInput instanceof SampleStructuredActivity) {
     super.basicSetInput(newInput);
     updateVariableTypeSelector();
     updateVariableName();
     variableNamedElement = BPELUtil.adapt(getActivity().getVariable(), INamedElement.class);
     variableNameEditController.setInput(getActivity().getVariable());
   }
 }
Пример #11
0
  /**
   * Make sure the images in the drawers are up to date. Recalculate them and inform the border of
   * any changes.
   */
  @Override
  protected void refreshDrawerImages() {
    ScopeBorder border = getScopeBorder();

    if (topImage != null) {
      topImage.dispose();
      topImage = null;
    }
    if (bottomImage != null) {
      bottomImage.dispose();
      bottomImage = null;
    }
    IMarkerHolder holder = BPELUtil.adapt(getActivity(), IMarkerHolder.class);
    IMarker[] markers = holder.getMarkers(getActivity());
    int topMarkerPriority = Integer.MIN_VALUE;
    int bottomMarkerPriority = Integer.MIN_VALUE;
    IMarker topMarker = null;
    IMarker bottomMarker = null;
    for (int i = 0; i < markers.length; i++) {
      IMarker marker = markers[i];
      String value =
          marker.getAttribute(
              IModelMarkerConstants.DECORATION_GRAPHICAL_MARKER_ANCHOR_POINT_ATTR,
              ""); //$NON-NLS-1$
      if (value.equals(IBPELUIConstants.MARKER_ANCHORPOINT_DRAWER_TOP)) {
        if (marker.getAttribute(IModelMarkerConstants.DECORATION_MARKER_VISIBLE_ATTR, true)) {
          int priority =
              marker.getAttribute(
                  IModelMarkerConstants.DECORATION_MARKER_PRIORITY_ATTR, Integer.MIN_VALUE);
          if (priority > topMarkerPriority) {
            topMarkerPriority = priority;
            topImage = BPELUtil.getImage(marker);
            topMarker = marker;
          }
        }
      } else if (value.equals(IBPELUIConstants.MARKER_ANCHORPOINT_DRAWER_BOTTOM)) {
        if (marker.getAttribute(IModelMarkerConstants.DECORATION_MARKER_VISIBLE_ATTR, true)) {
          int priority =
              marker.getAttribute(
                  IModelMarkerConstants.DECORATION_MARKER_PRIORITY_ATTR, Integer.MIN_VALUE);
          if (priority > bottomMarkerPriority) {
            bottomMarkerPriority = priority;
            bottomImage = BPELUtil.getImage(marker);
            bottomMarker = marker;
          }
        }
      }
    }
    border.setTopImage(topImage);
    border.setBottomImage(bottomImage);
    border.setTopMarker(topMarker);
    border.setBottomMarker(bottomMarker);
  }
  @SuppressWarnings("nls")
  @Override
  protected void store(IVirtualCopyRuleSide aModel) {
    From from = BPELUtil.adapt(aModel.getCopyRuleSide(), From.class);

    ServiceRef serviceRef = from.getServiceRef();
    if (serviceRef == null) {
      serviceRef = BPELFactory.eINSTANCE.createServiceRef();
      from.setServiceRef(serviceRef);
    }
    // TODO: Delegate to the endpoint handler to store the endpoint
    // into the ServiceRef.
  }
 @Override
 protected boolean calculateEnabled() {
   List selList = getSelectedObjects();
   if (selList.size() != 1) return false;
   Object o = selList.get(0);
   if (o instanceof Scope) {
     ITerminationHandlerHolder holder = BPELUtil.adapt(o, ITerminationHandlerHolder.class);
     if (holder != null) {
       if (holder.getTerminationHandler(o) != null) return true;
     }
   }
   return false;
 }
  @Override
  protected boolean calculateEnabled() {

    List<?> objects = getSelectedObjects();

    if (objects.size() != 1) {

      fSelection = null;
      return false;
    }

    Object sel = objects.get(0);

    if (sel instanceof EditPart) {
      EditPart part = (EditPart) sel;
      sel = part.getModel();
    }

    if (sel instanceof BPELExtensibleElement) {
      fSelection = (BPELExtensibleElement) sel;
    }

    if (fSelection == null) {
      fSelection = null;
      return false;
    }

    IContainer container = BPELUtil.adapt(fSelection, IContainer.class);
    if (container == null) {
      fSelection = null;
      return false;
    }
    // make sure it can contain something of this type
    if (container.canAddObject(fSelection, cachedInstance, null) == false) {
      fSelection = null;
      return false;
    }

    return true;
  }
 /**
  * @see
  *     org.eclipse.bpel.ui.properties.IAssignCategory#isCategoryForModel(org.eclipse.emf.ecore.EObject)
  */
 @Override
 public boolean isCategoryForModel(EObject aModel) {
   From from = BPELUtil.adapt(aModel, From.class);
   return from != null && from.getServiceRef() != null;
 }
 @SuppressWarnings("nls")
 @Override
 protected void basicSetInput(EObject newInput) {
   fCopyRuleSide = BPELUtil.adapt(newInput, IVirtualCopyRuleSide.class);
   super.basicSetInput(newInput);
 }