Ejemplo n.º 1
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);
  }
Ejemplo n.º 2
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);
  }
Ejemplo n.º 3
0
  /** @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals() */
  @Override
  public void refreshVisuals() {
    refreshDrawerImages();
    super.refreshVisuals();
    // Refresh any decorations on this edit part
    editPartMarkerDecorator.refresh();
    ScopeBorder border = getScopeBorder();
    border.setShowFault(getFaultHandler() != null);
    border.setShowCompensation(getCompensationHandler() != null);
    border.setShowTermination(getTerminationHandler() != null);
    border.setShowEvent(getEventHandler() != null);

    auxilaryFigure.refreshMargin();

    // Force a repaint, as the drawer images may have changed.
    getFigure().repaint();
  }