示例#1
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;
    }
  }
示例#2
0
  @Override
  protected IFigure createFigure() {
    final IFigure figure = createBaseFigure();
    ComponentInterface ci =
        ((WorkflowNode) getModel())
            .getComponentDescription()
            .getComponentInstallation()
            .getComponentRevision()
            .getComponentInterface();

    if (ci.getShape() == ComponentShape.CIRCLE) {
      final int size = 16;
      final int newOffset = 3;
      errorFigure.setBounds(new Rectangle(newOffset, newOffset, size, size));
      warningFigure.setBounds(new Rectangle(newOffset, newOffset, size, size));
      final int localX = 22;
      final int localY = 20;
      localFigure.setBounds(new Rectangle(localX, localY, size, size));
    } else if (ci.getSize() == ComponentSize.SMALL) {
      final int size = 16;
      final int newOffsetX = 22;
      final int newOffsetY = 1;
      warningFigure.setBounds(new Rectangle(newOffsetX, newOffsetY, size, size));
      final int localX = 22;
      final int localY = 22;
      localFigure.setBounds(new Rectangle(localX, localY, size, size));
    }
    figure.add(errorFigure);
    figure.add(warningFigure);
    figure.add(localFigure);
    figure.add(deprecatedFigure);
    return figure;
  }