Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0a9511a577db9542af2372e97f3d6a8af7ccd7a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * Copyright (c) 2011, 2012 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Eike Stepper - initial API and implementation
 */
package org.eclipse.emf.cdo.releng.doc.article.impl;

import org.eclipse.emf.cdo.releng.doc.article.ArticlePackage;
import org.eclipse.emf.cdo.releng.doc.article.BodyElement;
import org.eclipse.emf.cdo.releng.doc.article.Diagram;
import org.eclipse.emf.cdo.releng.doc.article.StructuralElement;

import org.eclipse.emf.ecore.EClass;

import com.sun.javadoc.Tag;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * <!-- begin-user-doc --> An implementation of the model object '<em><b>Diagram</b></em>'. <!-- end-user-doc -->
 * <p>
 * </p>
 *
 * @generated
 */
public class DiagramImpl extends BodyElementImpl implements Diagram
{
  // org.eclipse.emf.cdo.releng.doc.supplemental;bundle-version="[1.0.0,2.0.0)";resolution:=optional,
  // org.eclipse.gmf.runtime.diagram.ui.render;bundle-version="1.4.1",
  // org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
  // org.eclipse.core.runtime;bundle-version="3.7.0",
  // com.ibm.icu;bundle-version="4.4.2"

  // private org.eclipse.gmf.runtime.notation.Diagram diagram;

  /**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   *
   * @generated
   */
  protected DiagramImpl()
  {
    super();
  }

  DiagramImpl(Tag tag)
  {
    super(tag);

    loadDiagram(tag.text());
  }

  public void loadDiagram(String path)
  {
    // try
    // {
    // NotationPackage.eINSTANCE.getClass();
    // URI uri = URI.createFileURI(path);
    //
    // ResourceSet resourceSet = new ResourceSetImpl();
    // Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
    // map.put("*", new XMIResourceFactoryImpl());
    //
    // Resource resource = resourceSet.getResource(uri, true);
    // diagram = (org.eclipse.gmf.runtime.notation.Diagram)resource.getContents().get(0);
    // }
    // catch (Exception ex)
    // {
    // System.err.println("Could not load diagram " + path);
    // ex.printStackTrace();
    // }
  }

  /**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return ArticlePackage.Literals.DIAGRAM;
  }

  public BodyElement copy()
  {
    // TODO: implement DiagramImpl.copy()
    throw new UnsupportedOperationException();
  }

  public void generate(PrintWriter out, StructuralElement linkSource) throws IOException
  {
    generate(linkSource.getOutputFile().getParentFile());
  }

  public void generate(File folder) throws IOException
  {
    // String name = diagram.eResource().getURI().path();
    // int lastDot = name.lastIndexOf('.');
    // if (lastDot != -1)
    // {
    // name = name.substring(0, lastDot);
    // }
    //
    // IPath destination = new Path(new File(folder, name + ".png").getCanonicalPath());
    //
    // PreferencesHint hint = null;
    //
    // try
    // {
    // CopyToImageUtil copyToImageUtil = new CopyToImageUtil();
    //
    // Shell shell = new Shell();
    // try
    // {
    // DiagramEditPart diagramEditPart = OffscreenEditPartFactory.getInstance().createDiagramEditPart(diagram, shell,
    // hint);
    // Assert.isNotNull(diagramEditPart);
    // DiagramGenerator generator = copyToImageUtil.copyToImage(diagramEditPart, destination, ImageFileFormat.PNG,
    // new NullProgressMonitor());
    // List partInfo = generator.getDiagramPartInfo(diagramEditPart);
    // System.out.println(partInfo);
    // }
    // finally
    // {
    // shell.dispose();
    // }
    //
    // // copyToImageUtil.copyToImage(diagram, destination, ImageFileFormat.PNG, new NullProgressMonitor(), hint);
    // }
    // catch (Exception ex)
    // {
    // ex.printStackTrace();
    // }
  }

  public static void main(String[] args) throws Exception
  {
    File folder = new File("/develop/ws/cdo/plugins/org.eclipse.emf.cdo.doc/html/programmers/sessions");

    DiagramImpl impl = new DiagramImpl();
    impl.loadDiagram("/develop/ws/cdo/plugins/org.eclipse.emf.cdo.releng.doc/model/article.ecorediag");
    impl.generate(folder);
  }
} // DiagramImpl

Back to the top