Example #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);
  }
Example #2
0
  public void switchLayout(boolean horizontal) {
    ((FlowLayout) contentFigure.getLayoutManager()).setHorizontal(horizontal);
    ((AlignedFlowLayout) auxilaryFigure.getLayoutManager()).setHorizontal(!horizontal);

    this.removeEditPolicy(EditPolicy.LAYOUT_ROLE);

    if (horizontal) {
      installEditPolicy(EditPolicy.LAYOUT_ROLE, new ScopeOrderedHorizontalLayoutEditPolicy());
    } else {
      installEditPolicy(EditPolicy.LAYOUT_ROLE, new ScopeOrderedLayoutEditPolicy());
    }
  }
Example #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();
  }