예제 #1
0
  /** @see LabelProvider#getImage(Object) */
  @Override
  public Image getImage(Object element) {
    if (element instanceof IStructuredSelection) {
      element = ((IStructuredSelection) element).getFirstElement();
    }

    element = TransformationTreeUtil.extractObject(element);

    if (element instanceof Entity) {
      element = ((Entity) element).getDefinition();
    }

    if (element instanceof EntityDefinition || element instanceof Definition<?>) {
      return definitionLabels.getImage(element);
    }

    if (element instanceof Cell) {
      Cell cell = (Cell) element;
      AbstractFunction<?> function = FunctionUtil.getFunction(cell.getTransformationIdentifier());
      if (function != null) {
        element = function;
      }
    }

    if (element instanceof Function) {
      return functionLabels.getImage(element);
    }

    return super.getImage(element);
  }
예제 #2
0
  /**
   * sets the property of a [@link]Vertex from a [@link]TransformationNode
   *
   * @param node the node-object to get the name from
   * @param vertex the vertex to set the property
   */
  private void setVertexProperty(TransformationNode node, Vertex vertex) {

    if (node instanceof TransformationTree) {
      vertex.setProperty("name", ((TransformationTree) node).getType().getDisplayName());
      vertex.setProperty("type", "root");
    }

    if (node instanceof TargetNode) {
      vertex.setProperty("name", ((TargetNode) node).getDefinition().getDisplayName());
      vertex.setProperty("type", "target");
    }

    if (node instanceof SourceNode) {
      SourceNode snode = (SourceNode) node;
      Object value = snode.getValue();
      String name = ((SourceNode) node).getDefinition().getDisplayName();

      if (value instanceof Group) {
        vertex.setProperty("name", name);
        vertex.setProperty("group", getChildrencountString(value));
        vertex.setProperty("type", "source");
      }
      if (value instanceof Instance) {
        if (((Instance) value).getValue() != null) {
          vertex.setProperty("group", getChildrencountString(value));
          vertex.setProperty("value", ((Instance) value).getValue().toString());
          vertex.setProperty("type", "source");
        }
      } else {
        vertex.setProperty("name", name);
        vertex.setProperty("type", "source");
        if (value instanceof String) {
          vertex.setProperty("value", value);
        }
      }
    }

    if (node instanceof CellNode) {
      vertex.setProperty(
          "name",
          FunctionUtil.getFunction(((CellNode) node).getCell().getTransformationIdentifier(), null)
              .getDisplayName());
      vertex.setProperty("type", "cell");
    }
  }