private IFigure getContents() {
    IFigure panel = new Panel();
    BorderLayout lm = new BorderLayout();

    panel.setLayoutManager(lm);
    arrowButton = new ArrowButton(direction);
    arrowButton.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND));
    arrowButton.setBackgroundColor(ColorConstants.white);

    Label lbl = new Label(lblText);
    lbl.setBackgroundColor(ColorConstants.black);
    lbl.setForegroundColor(ColorConstants.black);
    setTriangleColor(READY_COLOUR);

    Label imgLblFigure =
        new Label(
            TomoClientActivator.getDefault().getImageRegistry().get(ImageConstants.ICON_CTRL_BTN));
    panel.setBackgroundColor(ColorConstants.white);
    panel.add(imgLblFigure);
    panel.setConstraint(imgLblFigure, BorderLayout.TOP);

    arrowButton.add(lbl);
    panel.add(arrowButton);
    panel.setConstraint(arrowButton, BorderLayout.CENTER);
    lbl.addMouseListener(mousePressListener);
    return panel;
  }
示例#2
0
  protected IFigure createBaseFigure() {
    Image image = null;
    byte[] icon = null;

    ComponentInterface ci =
        ((WorkflowNode) getModel())
            .getComponentDescription()
            .getComponentInstallation()
            .getComponentRevision()
            .getComponentInterface();

    if (ci.getSize() == ComponentSize.SMALL) {
      icon = ((WorkflowNode) getModel()).getComponentDescription().getIcon24();
    } else {
      icon = ((WorkflowNode) getModel()).getComponentDescription().getIcon32();
    }
    if (icon != null) {
      try {
        image = new Image(Display.getCurrent(), new ByteArrayInputStream(icon));
      } catch (SWTException e) {
        // The images of integrated tools may be broken, so the default will be used.
        LogFactory.getLog(getClass()).info("Could not load tool icon, loading default. ", e);
        image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_32);
      }
    } else if (ci.getIdentifier().startsWith(ComponentUtils.MISSING_COMPONENT_PREFIX)) {
      if (ci.getSize() == ComponentSize.SMALL) {
        image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_24_GREY);
      } else {
        image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_32_GREY);
      }
    } else {
      if (ci.getSize() == ComponentSize.SMALL) {
        image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_24);
      } else {
        image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_32);
      }
    }
    Color color = getColor(ci);

    if (ci.getSize() == ComponentSize.SMALL) {
      IconLabel iconLabel = new IconLabel(image, ci);
      iconLabel.setOpaque(true);
      iconLabel.setBorder(null);
      iconLabel.setBackgroundColor(color);
      return iconLabel;
    } else {
      final String labelText = ((WorkflowNode) getModel()).getName();
      final Label label = new Label(labelText, image);
      label.setTextPlacement(PositionConstants.SOUTH);
      label.setBorder(new LineBorder());
      label.setOpaque(true);
      label.setBackgroundColor(color);
      return label;
    }
  }
 /** @generated */
 protected IFigure createSelectionFeedbackFigure() {
   if (getHostFigure() instanceof Label) {
     Label feedbackFigure = new Label();
     feedbackFigure.setOpaque(true);
     feedbackFigure.setBackgroundColor(ColorConstants.menuBackgroundSelected);
     feedbackFigure.setForegroundColor(ColorConstants.menuForegroundSelected);
     return feedbackFigure;
   } else {
     RectangleFigure feedbackFigure = new RectangleFigure();
     feedbackFigure.setFill(false);
     return feedbackFigure;
   }
 }
    public InterceptorsFigure() {
      ToolbarLayout layout = new ToolbarLayout();
      setLayoutManager(layout);
      setBorder(new LineBorder(ColorConstants.black, 1));

      /* Header Label */
      Label constantLabel = new Label("Interceptors");
      constantLabel.setLabelAlignment(PositionConstants.LEFT);
      constantLabel.setIcon(
          S2EditorUI.getImageDescriptor("icons/arraypartition_obj.gif").createImage());
      constantLabel.setBackgroundColor(new Color(null, 0xb7, 0xe4, 0xa8));
      constantLabel.setOpaque(true);
      constantLabel.setForegroundColor(ColorConstants.titleForeground);
      constantLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
      add(constantLabel);

      bodyFigure = new BodyFigure();
      add(bodyFigure);
    }
示例#5
0
  public ComboBox() {
    super();
    setOpaque(true);
    setLayoutManager(new BorderLayout());
    setBackgroundColor(VisualEditorPlugin.getDefault().getColorManager().getAirColor());

    label = new Label();
    label.setBackgroundColor(ColorConstants.white);
    label.setVisible(false);
    add(label, BorderLayout.CENTER);
    label.setText("         ");

    button = new ArrowButton(Orientable.SOUTH);
    button.setBorder(null);
    button.setOpaque(false);
    button.setEnabled(false);
    button.setPreferredSize(15, 13);
    add(button, BorderLayout.RIGHT);

    setBorder(
        new SchemeBorder(
            new ButtonScheme(
                new Color[] {buttonLightest}, new Color[] {buttonDarkest, buttonDarker})));
  }
  /**
   * @param contents IFigure
   * @param name String
   * @param route DotRoute
   * @return PolylineConnection
   */
  private PolylineConnection addConnectionFromRoute(
      final IFigure contents, final String name, final DotRoute route) {
    final float[] coords = new float[6];
    final ArrayList<AbsoluteBendpoint> bends = new ArrayList<AbsoluteBendpoint>();
    boolean isFirstPoint = true;
    final Point min = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);
    final Point max = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE);

    for (final PathIterator ite =
            new FlatteningPathIterator(
                route.getPath().getPathIterator(new AffineTransform()), PATH_ITERATOR_FLATNESS);
        !ite.isDone();
        ite.next()) {
      final int segType = ite.currentSegment(coords);

      switch (segType) {
        case PathIterator.SEG_MOVETO:
          if (isFirstPoint) {
            addBendPoint(coords, bends, min, max);
          } else {
            LOG.error("Got SEG_MOVETO after first point");
          }
          break;

        case PathIterator.SEG_LINETO:
          addBendPoint(coords, bends, min, max);
          break;

        default:
          LOG.error("Unexpected segment type " + segType);
          break;
      }

      isFirstPoint = false;
    }

    final Rectangle bounds = new Rectangle(min, max);
    final PolylineConnection conn = new PolylineConnection();

    final Point sourcePoint = bends.remove(0);
    final Point targetPoint;
    if (route.getEndPt() != null) {
      targetPoint = new PrecisionPoint(route.getEndPt().getX(), route.getEndPt().getY());
    } else {
      targetPoint = bends.remove(bends.size() - 1);
    }
    conn.setSourceAnchor(new XYRelativeAnchor(conn, sourcePoint));
    conn.setTargetAnchor(new XYRelativeAnchor(conn, targetPoint));

    if (bends.isEmpty()) {
      conn.setConnectionRouter(null);
    } else {
      conn.setConnectionRouter(new BendpointConnectionRouter());
      conn.setRoutingConstraint(bends);
    }

    if (name != null) {
      final Label label = new Label(name);
      label.setOpaque(true);
      label.setBackgroundColor(ColorConstants.buttonLightest);
      label.setBorder(new LineBorder());
      label.setFont(Application.getInstance().getFont(Application.LINK_FONT));
      final ConnectionLocator locator = new MidpointLocator(conn, bends.size() / 2);
      locator.setRelativePosition(PositionConstants.CENTER);
      // Includes the label in the connection bounds.
      // Worst case scenario, the label is on the connection edge.
      final Dimension labelSize = label.getPreferredSize();
      bounds.expand(labelSize.width, labelSize.height);
      conn.add(label, locator);
    }

    contents.add(conn, bounds);

    return conn;
  }