Ejemplo n.º 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;
    }
  }