public ColumnTitleFigure(MapperTablePart xmlTreePart) {
    this.xmlTreePart = xmlTreePart;
    AbstractInOutTree xmlTree = (AbstractInOutTree) xmlTreePart.getModel();
    if (xmlTree instanceof InputXmlTree) {
      InputXmlTree inputTree = (InputXmlTree) xmlTree;
      if (inputTree.isLookup()) {
        Label expression = new Label();
        expression.setText("Exp.key");
        expression.setBorder(new MarginBorder(3, 10, 3, -1));
        expression.setLabelAlignment(PositionConstants.LEFT);
        this.add(expression);
      }
    } else {
      Label expression = new Label();
      expression.setText("Expression");
      expression.setBorder(new MarginBorder(3, 10, 3, -1));
      expression.setLabelAlignment(PositionConstants.LEFT);
      this.add(expression);
    }

    Label column1 = new Label();
    column1.setText("Column");
    column1.setBorder(new MarginBorder(3, 10, 3, -1));
    column1.setLabelAlignment(PositionConstants.LEFT);
    this.add(column1);

    setLayoutManager(new ColumnTitleLayout());

    setBackgroundColor(ColorConstants.menuBackground);
    setOpaque(true);
  }
 public void setSelection(boolean sel) {
   if (sel) {
     lblCnnName.setBorder(border);
   } else {
     lblCnnName.setBorder(null);
   }
 }
  public AbstractLabeledFigure(Figure shape, Color borderColor, Color fillColor) {
    this.defaultBorderColor = borderColor;
    this.defaultFillColor = fillColor;

    setCornerDimensions(new Dimension(12, 12));

    setFill(false);
    setBorder(new MarginBorder(1));

    label = createLabel();
    label.setBorder(new MarginBorder(1, 6, 1, 6));
    label.setForegroundColor(ColorConstants.black);
    label.setOpaque(true);
    this.shape = shape;

    setLayoutManager(createFigureLayout());
    doAddShape(shape);
    doAddLabel(label);

    setBorderColor(null);
    setFillColor(null);

    setMinimumSize(new Dimension(50, -1));
    setMaximumSize(new Dimension(300, 100));
  }
Example #4
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;
    }
  }
  /**
   * @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;
  }
  /*
   * (non-Javadoc)
   *
   * @see org.talend.designer.gefabstractmap.figures.table.AbstractTable#createColumns()
   */
  @Override
  protected void createColumns() {
    TableColumn column = new TableColumn(ColumnKeyConstant.TREE_SETTING_PROPERTY);
    column.setText("Property");
    addColumn(column);

    ColumnSash sash = new ColumnSash(this);
    sash.setLeftColumn(column);
    addSeparator(sash);

    column = new TableColumn(ColumnKeyConstant.TREE_SETTING_VALUE);
    column.setText("Value");
    sash.setRightColumn(column);
    addColumn(column);

    Figure container = getTableItemContainer();

    joinModelRow = new Figure();
    joinModelRow.setLayoutManager(new RowLayout());
    Label label = new Label();
    label.setText("Join Model");
    label.setLabelAlignment(PositionConstants.LEFT);
    CompoundBorder compoundBorder =
        new CompoundBorder(new ColumnBorder(), new RowBorder(2, 5, 2, -1));
    label.setBorder(compoundBorder);
    joinModelRow.add(label);
    joinModel = new ComboCellLabel();
    joinModel.setDirectEditType(DirectEditType.JOIN_MODEL);
    joinModel.setText(inputTable.getJoinModel());
    joinModel.setLabelAlignment(PositionConstants.LEFT);
    joinModel.setBorder(new RowBorder(2, 5, 2, -1));
    joinModelRow.add(joinModel);
    container.add(joinModelRow);

    //
    joinOptimizationRow = new Figure();
    joinOptimizationRow.setLayoutManager(new RowLayout());
    label = new Label();
    label.setText("Join Optimization");
    label.setLabelAlignment(PositionConstants.LEFT);
    compoundBorder = new CompoundBorder(new ColumnBorder(), new RowBorder(2, 5, 2, -1));
    label.setBorder(compoundBorder);
    joinOptimizationRow.add(label);
    joinOptimization = new ComboCellLabel();
    joinOptimization.setDirectEditType(DirectEditType.JOIN_OPTIMIZATION);
    joinOptimization.setText(getJoinOptimizationDisplayName(inputTable.getJoinOptimization()));
    joinOptimization.setLabelAlignment(PositionConstants.LEFT);
    joinOptimization.setBorder(new RowBorder(2, 5, 2, -1));
    joinOptimizationRow.add(joinOptimization);
    container.add(joinOptimizationRow);

    //
    customPartitionerRow = new Figure();
    customPartitionerRow.setLayoutManager(new RowLayout());
    label = new Label();
    label.setText("Custom Partitioner");
    label.setLabelAlignment(PositionConstants.LEFT);
    compoundBorder = new CompoundBorder(new ColumnBorder(), new RowBorder(2, 5, 2, -1));
    label.setBorder(compoundBorder);
    customPartitionerRow.add(label);
    customPartitioner = new TextCellLabel();
    customPartitioner.setDirectEditType(DirectEditType.CUSTOM_PARTITIONER);
    customPartitioner.setText(inputTable.getCustomPartitioner());
    customPartitioner.setLabelAlignment(PositionConstants.LEFT);
    customPartitioner.setBorder(new RowBorder(2, 5, 2, -1));
    customPartitionerRow.add(customPartitioner);
    container.add(customPartitionerRow);

    //
    increaseParallelismRow = new Figure();
    increaseParallelismRow.setLayoutManager(new RowLayout());
    label = new Label();
    label.setText("Increase Parallelism");
    label.setLabelAlignment(PositionConstants.LEFT);
    compoundBorder = new CompoundBorder(new ColumnBorder(), new RowBorder(2, 5, 2, -1));
    label.setBorder(compoundBorder);
    increaseParallelismRow.add(label);
    increaseParallelism = new TextCellLabel();
    increaseParallelism.setDirectEditType(DirectEditType.INCREASE_PARALLELISM);
    increaseParallelism.setText(inputTable.getIncreaseParallelism());
    increaseParallelism.setLabelAlignment(PositionConstants.LEFT);
    increaseParallelism.setBorder(new RowBorder(2, 5, 2, -1));
    increaseParallelismRow.add(increaseParallelism);
    container.add(increaseParallelismRow);
    container.setOpaque(true);
    container.setBackgroundColor(ColorConstants.white);

    container.addMouseListener(
        new MouseListener() {

          Figure selectedFigure = null;

          @Override
          public void mousePressed(MouseEvent me) {
            boolean joinOptimization = joinOptimizationRow.containsPoint(me.x, me.y);
            if (joinOptimization) {
              if (selectedFigure != joinOptimizationRow) {
                joinOptimizationRow.setOpaque(true);
                joinOptimizationRow.setBackgroundColor(
                    ColorProviderMapper.getColor(ColorInfo.COLOR_COLUMN_TREE_SETTING));
                customPartitionerRow.setOpaque(false);
                joinModelRow.setOpaque(false);
                increaseParallelismRow.setOpaque(false);
              }
              return;
            }
            boolean customPartitioner = customPartitionerRow.containsPoint(me.x, me.y);
            if (customPartitioner) {
              if (selectedFigure != customPartitionerRow) {
                customPartitionerRow.setOpaque(true);
                customPartitionerRow.setBackgroundColor(
                    ColorProviderMapper.getColor(ColorInfo.COLOR_COLUMN_TREE_SETTING));
                joinOptimizationRow.setOpaque(false);
                joinModelRow.setOpaque(false);
                increaseParallelismRow.setOpaque(false);
              }
              return;
            }
            boolean joinModel = joinModelRow.containsPoint(me.x, me.y);
            if (joinModel) {
              if (selectedFigure != joinModelRow) {
                joinModelRow.setOpaque(true);
                joinModelRow.setBackgroundColor(
                    ColorProviderMapper.getColor(ColorInfo.COLOR_COLUMN_TREE_SETTING));
                joinOptimizationRow.setOpaque(false);
                customPartitionerRow.setOpaque(false);
                increaseParallelismRow.setOpaque(false);
              }
              return;
            }
            boolean increaseParallelism = increaseParallelismRow.containsPoint(me.x, me.y);
            if (increaseParallelism) {
              if (selectedFigure != increaseParallelismRow) {
                increaseParallelismRow.setOpaque(true);
                increaseParallelismRow.setBackgroundColor(
                    ColorProviderMapper.getColor(ColorInfo.COLOR_COLUMN_TREE_SETTING));
                joinOptimizationRow.setOpaque(false);
                customPartitionerRow.setOpaque(false);
                joinModelRow.setOpaque(false);
              }
            }
          }

          @Override
          public void mouseReleased(MouseEvent me) {}

          @Override
          public void mouseDoubleClicked(MouseEvent me) {}
        });
  }