예제 #1
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;
  }
예제 #2
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);
  }
예제 #3
0
 /** Set the layout of the figure for expanded state. */
 @Override
 protected void configureExpandedFigure(IFigure figure) {
   FlowLayout layout = new FlowLayout();
   layout.setMajorAlignment(FlowLayout.ALIGN_CENTER);
   layout.setMinorAlignment(FlowLayout.ALIGN_CENTER);
   layout.setHorizontal(ModelHelper.isHorizontalLayout(getModel()));
   layout.setMajorSpacing(SPACING);
   layout.setMinorSpacing(SPACING);
   figure.setLayoutManager(layout);
 }
예제 #4
0
 /** @see org.eclipse.draw2d.Figure#paint(org.eclipse.draw2d.Graphics) */
 public void paint(Graphics graphics) {
   super.paint(graphics);
   computeHandlerIconPositions(ModelHelper.isHorizontalLayout(getModel()));
   if (hasFH) {
     graphics.pushState();
     graphics.setClip(faultImageFigure.getBounds().getCopy());
     faultImageFigure.paint(graphics);
     graphics.popState();
   }
   if (hasEH) {
     graphics.pushState();
     graphics.setClip(eventImageFigure.getBounds().getCopy());
     eventImageFigure.paint(graphics);
     graphics.popState();
   }
 }
예제 #5
0
  @Override
  protected void createEditPolicies() {
    super.createEditPolicies();

    // Show the selection rectangle
    installEditPolicy(
        EditPolicy.SELECTION_FEEDBACK_ROLE,
        new ContainerHighlightEditPolicy(false, true) {
          @Override
          protected int getDrawerInset() {
            return DrawerBorder.DRAWER_WIDTH;
          }

          @Override
          protected int getNorthInset() {
            if (isCollapsed()) {
              return 0;
            }

            // This one is tricky, it depends on the font size.

            return 10;
          }

          @Override
          protected int getSouthInset() {
            return isCollapsed() ? 8 : 2;
          }

          @Override
          protected int getEastInset() {
            return DrawerBorder.DRAWER_WIDTH;
          }

          @Override
          protected int getWestInset() {
            return DrawerBorder.DRAWER_WIDTH;
          }
        });

    BPELOrderedLayoutEditPolicy policy = null;
    if (ModelHelper.isHorizontalLayout(getModel()))
      policy = new SequenceHorizontalBPELOrderedLayoutPolicy();
    else policy = new BPELOrderedLayoutEditPolicy();

    installEditPolicy(EditPolicy.LAYOUT_ROLE, policy);
  }
예제 #6
0
  @Override
  protected void createEditPolicies() {
    super.createEditPolicies();

    // Show the selection rectangle
    installEditPolicy(
        EditPolicy.SELECTION_FEEDBACK_ROLE,
        new ContainerHighlightEditPolicy(false, true) {
          @Override
          protected int getDrawerInset() {
            return DrawerBorder.DRAWER_WIDTH;
          }

          @Override
          protected int getNorthInset() {
            return 0;
          }

          @Override
          protected int getSouthInset() {
            return 3;
          }

          @Override
          protected int getEastInset() {
            return DrawerBorder.DRAWER_WIDTH;
          }

          @Override
          protected int getWestInset() {
            return DrawerBorder.DRAWER_WIDTH;
          }
        });
    if (ModelHelper.isHorizontalLayout(getModel()))
      installEditPolicy(EditPolicy.LAYOUT_ROLE, new ScopeOrderedHorizontalLayoutEditPolicy());
    else installEditPolicy(EditPolicy.LAYOUT_ROLE, new ScopeOrderedLayoutEditPolicy());
  }
예제 #7
0
 private void refreshMargin() {
   if (ModelHelper.isHorizontalLayout(getModel()))
     setBorder(new MarginBorder(contentFigure.getPreferredSize().height + 10, 0, 0, 0));
   else setBorder(null);
 }