예제 #1
0
 private void convertVertexTypes(Graph graph, Map<ObjectType, ObjectType> vertexTypes) {
   Set<Vertex> vertices = originalGraph.vertexSet();
   for (Vertex vertex : vertices) {
     ObjectType newType = vertexTypes.get(vertex.getType());
     if (newType != null) {
       vertex = new Vertex(vertex);
       vertex.setType(newType);
       graph.addVertex(vertex);
     }
   }
 }
예제 #2
0
 /** Updates the description of this page. */
 private void updateDescription() {
   setDescription(
       "Convert \""
           + originalGraph.getType().getName()
           + "\" to \""
           + newGraphType.getName()
           + "\".");
 }
예제 #3
0
  private void convertEdgeTypes(Graph graph, Map<ObjectType, ObjectType> edgeTypes) {
    Set<Edge> edges = originalGraph.edgeSet();
    for (Edge edge : edges) {
      ObjectType newType = edgeTypes.get(edge.getType());
      if (newType != null) {
        edge = new Edge(edge);
        String sourceId = (String) edge.getSource().getValue(ObjectType.PARAMETER_ID);
        String targetId = (String) edge.getTarget().getValue(ObjectType.PARAMETER_ID);
        Vertex source = graph.findVertex(sourceId);
        Vertex target = graph.findVertex(targetId);

        if (source != null && target != null) {
          edge.setSource(source);
          edge.setTarget(target);
          edge.setType(newType);
          graph.addEdge(edge);
        }
      }
    }
  }
예제 #4
0
  /**
   * Constructor for SampleNewWizardPage.
   *
   * @param selection
   */
  public WizardConvertPage(IStructuredSelection selection) {
    super("convertGraph");

    setTitle("Convert types");

    Object obj = selection.getFirstElement();
    if (obj instanceof GraphEditor) {
      GraphEditor editor = (GraphEditor) obj;
      originalGraph = editor.getContents();

      // fills the original graph, vertex and edge types
      Configuration configuration = originalGraph.getConfiguration();
      originalEdgeTypes = configuration.getEdgeTypes();
      originalVertexTypes = configuration.getVertexTypes();
    }
  }