View | Details | Raw Unified | Return to bug 146009 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/gmf/tests/setup/RTSetup.java (-1 / +7 lines)
Lines 105-111 Link Here
105
		
105
		
106
		FeatureLinkModelFacet byRefFacet = (FeatureLinkModelFacet) genSource.getLinkD().getModelFacet();
106
		FeatureLinkModelFacet byRefFacet = (FeatureLinkModelFacet) genSource.getLinkD().getModelFacet();
107
		Assert.assertNotNull(byRefFacet);
107
		Assert.assertNotNull(byRefFacet);
108
		instanceProducer.setFeatureValue(myNodeA.getElement(), myNodeB.getElement(), byRefFacet.getMetaFeature());
108
		EStructuralFeature metaFeature = byRefFacet.getMetaFeature().getEcoreFeature();
109
		//The direction of the link is unspecified, could be from A to B or vice versa
110
		if (myNodeA.eClass().getEAllStructuralFeatures().contains(metaFeature)) {
111
			instanceProducer.setFeatureValue(myNodeA.getElement(), myNodeB.getElement(), byRefFacet.getMetaFeature());
112
		} else if (myNodeB.eClass().getEAllStructuralFeatures().contains(metaFeature)) {
113
			instanceProducer.setFeatureValue(myNodeB.getElement(), myNodeA.getElement(), byRefFacet.getMetaFeature());
114
		}
109
		myLinkByRef = NotationFactory.eINSTANCE.createEdge();
115
		myLinkByRef = NotationFactory.eINSTANCE.createEdge();
110
		myCanvas.getPersistedEdges().add(myLinkByRef);
116
		myCanvas.getPersistedEdges().add(myLinkByRef);
111
		myLinkByRef.setType(String.valueOf(genSource.getLinkD().getVisualID()));
117
		myLinkByRef.setType(String.valueOf(genSource.getLinkD().getVisualID()));
(-)src/org/eclipse/gmf/tests/lite/Activator.java (+8 lines)
Lines 11-17 Link Here
11
 */
11
 */
12
package org.eclipse.gmf.tests.lite;
12
package org.eclipse.gmf.tests.lite;
13
13
14
import java.io.IOException;
15
14
import org.eclipse.core.runtime.Plugin;
16
import org.eclipse.core.runtime.Plugin;
17
import org.eclipse.emf.common.util.URI;
15
import org.osgi.framework.BundleContext;
18
import org.osgi.framework.BundleContext;
16
19
17
/**
20
/**
Lines 49-54 Link Here
49
		super.stop(context);
52
		super.stop(context);
50
	}
53
	}
51
54
55
	public static URI createURI(String bundledFileName) throws IOException {
56
		assert bundledFileName.charAt(0) == '/';
57
		return URI.createURI("platform:/plugin/" + getDefault().getBundle().getSymbolicName() + bundledFileName);
58
	}
59
52
	/**
60
	/**
53
	 * Returns the shared instance
61
	 * Returns the shared instance
54
	 *
62
	 *
(-)src/org/eclipse/gmf/tests/lite/AllTests.java (+5 lines)
Lines 15-23 Link Here
15
import org.eclipse.gmf.tests.gef.DiagramNodeTest;
15
import org.eclipse.gmf.tests.gef.DiagramNodeTest;
16
import org.eclipse.gmf.tests.lite.gef.DiagramElementTest;
16
import org.eclipse.gmf.tests.lite.gef.DiagramElementTest;
17
import org.eclipse.gmf.tests.lite.gef.DiagramLinksTest;
17
import org.eclipse.gmf.tests.lite.gef.DiagramLinksTest;
18
import org.eclipse.gmf.tests.lite.gef.NotationRefreshTest;
18
import org.eclipse.gmf.tests.lite.gen.LiteCompilationTest;
19
import org.eclipse.gmf.tests.lite.gen.LiteCompilationTest;
19
import org.eclipse.gmf.tests.lite.gen.RCPLiteCompilationTest;
20
import org.eclipse.gmf.tests.lite.gen.RCPLiteCompilationTest;
20
import org.eclipse.gmf.tests.lite.rt.ElementInitializerTest;
21
import org.eclipse.gmf.tests.lite.rt.ElementInitializerTest;
22
import org.eclipse.gmf.tests.lite.setup.LibraryConstrainedSetup;
21
import org.eclipse.gmf.tests.lite.setup.LiteLinksSessionSetup;
23
import org.eclipse.gmf.tests.lite.setup.LiteLinksSessionSetup;
22
import org.eclipse.gmf.tests.lite.setup.LiteSessionSetup;
24
import org.eclipse.gmf.tests.lite.setup.LiteSessionSetup;
23
import org.eclipse.gmf.tests.rt.LinkCreationConstraintsTest;
25
import org.eclipse.gmf.tests.rt.LinkCreationConstraintsTest;
Lines 36-41 Link Here
36
38
37
		final SessionSetup sessionSetup = LiteSessionSetup.getInstance();
39
		final SessionSetup sessionSetup = LiteSessionSetup.getInstance();
38
		final LinksSessionSetup sessionSetup2 = LiteLinksSessionSetup.getInstance();
40
		final LinksSessionSetup sessionSetup2 = LiteLinksSessionSetup.getInstance();
41
		final LibraryConstrainedSetup sessionSetup3 = LibraryConstrainedSetup.getInstance();
39
		SessionSetup.disallowSingleTestCaseUse();
42
		SessionSetup.disallowSingleTestCaseUse();
40
43
41
		suite.addTest(feed(DiagramNodeTest.class, sessionSetup));
44
		suite.addTest(feed(DiagramNodeTest.class, sessionSetup));
Lines 43-54 Link Here
43
		suite.addTest(feed(DiagramLinksTest.class, sessionSetup2));
46
		suite.addTest(feed(DiagramLinksTest.class, sessionSetup2));
44
		suite.addTest(feed(ElementInitializerTest.class, sessionSetup2));
47
		suite.addTest(feed(ElementInitializerTest.class, sessionSetup2));
45
		suite.addTest(feed(LinkCreationConstraintsTest.class, sessionSetup2));
48
		suite.addTest(feed(LinkCreationConstraintsTest.class, sessionSetup2));
49
		suite.addTest(feed(NotationRefreshTest.class, sessionSetup3));
46
50
47
		suite.addTest(new TestCase("testCleanup") {
51
		suite.addTest(new TestCase("testCleanup") {
48
			protected void runTest() throws Throwable {
52
			protected void runTest() throws Throwable {
49
				try {
53
				try {
50
					sessionSetup.cleanup();
54
					sessionSetup.cleanup();
51
					sessionSetup2.cleanup();
55
					sessionSetup2.cleanup();
56
					sessionSetup3.cleanup();
52
				} catch (RuntimeException ex) {
57
				} catch (RuntimeException ex) {
53
					throw ex;
58
					throw ex;
54
				} catch (Exception ex) {
59
				} catch (Exception ex) {
(-)models/library/library.ecore (+68 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<ecore:EPackage xmi:version="2.0"
3
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="library"
5
    nsURI="http:///org/eclipse/example/library.ecore" nsPrefix="org.eclipse.example.library">
6
  <eClassifiers xsi:type="ecore:EClass" name="Library">
7
    <eAnnotations source="http:///org/eclipse/example/library.ecore">
8
      <details key="note" value="Diagram element"/>
9
    </eAnnotations>
10
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
11
    <eStructuralFeatures xsi:type="ecore:EReference" name="writers" upperBound="-1"
12
        eType="#//Writer" containment="true"/>
13
    <eStructuralFeatures xsi:type="ecore:EReference" name="books" upperBound="-1"
14
        eType="#//Book" containment="true"/>
15
  </eClassifiers>
16
  <eClassifiers xsi:type="ecore:EClass" name="Writer">
17
    <eAnnotations source="http:///org/eclipse/example/library.ecore">
18
      <details key="note" value="Should be modeled as node; show name on diagram"/>
19
    </eAnnotations>
20
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
21
    <eStructuralFeatures xsi:type="ecore:EReference" name="books" upperBound="-1"
22
        eType="#//Book" eOpposite="#//Book/author"/>
23
    <eStructuralFeatures xsi:type="ecore:EReference" name="opinions" upperBound="-1"
24
        eType="#//Opinion" containment="true" eOpposite="#//Opinion/writer"/>
25
  </eClassifiers>
26
  <eClassifiers xsi:type="ecore:EClass" name="Book">
27
    <eAnnotations source="http:///org/eclipse/example/library.ecore">
28
      <details key="note" value="Should be modeled as node; show title on diagram"/>
29
    </eAnnotations>
30
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="title" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
31
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="pages" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
32
        defaultValueLiteral="100"/>
33
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="category" eType="#//BookCategory"/>
34
    <eStructuralFeatures xsi:type="ecore:EReference" name="author" lowerBound="1"
35
        eType="#//Writer" eOpposite="#//Writer/books">
36
      <eAnnotations source="http:///org/eclipse/example/library.ecore">
37
        <details key="note" value="Should be modeled as link"/>
38
      </eAnnotations>
39
    </eStructuralFeatures>
40
    <eStructuralFeatures xsi:type="ecore:EReference" name="reviews" upperBound="-1"
41
        eType="#//Review" containment="true" eOpposite="#//Review/book"/>
42
  </eClassifiers>
43
  <eClassifiers xsi:type="ecore:EEnum" name="BookCategory">
44
    <eLiterals name="Mystery"/>
45
    <eLiterals name="ScienceFiction" value="1"/>
46
    <eLiterals name="Biography" value="2"/>
47
  </eClassifiers>
48
  <eClassifiers xsi:type="ecore:EClass" name="Review">
49
    <eAnnotations source="http:///org/eclipse/example/library.ecore">
50
      <details key="note" value="Should be modeled as node inside book compartments"/>
51
    </eAnnotations>
52
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="title" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
53
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="positive" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"
54
        defaultValueLiteral="true"/>
55
    <eStructuralFeatures xsi:type="ecore:EReference" name="book" lowerBound="1" eType="#//Book"
56
        eOpposite="#//Book/reviews"/>
57
  </eClassifiers>
58
  <eClassifiers xsi:type="ecore:EClass" name="Opinion">
59
    <eAnnotations source="http:///org/eclipse/example/library.ecore">
60
      <details key="note" value="Should be modeled as directed link from writer to book"/>
61
    </eAnnotations>
62
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="text" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
63
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="context" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
64
    <eStructuralFeatures xsi:type="ecore:EReference" name="writer" lowerBound="1"
65
        eType="#//Writer" eOpposite="#//Writer/opinions"/>
66
    <eStructuralFeatures xsi:type="ecore:EReference" name="book" lowerBound="1" eType="#//Book"/>
67
  </eClassifiers>
68
</ecore:EPackage>
(-)models/library/library_constrained.gmfgen (+354 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<gmfgen:GenEditorGenerator xmi:version="2.0"
3
    xmlns:xmi="http://www.omg.org/XMI"
4
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
    xmlns:gmfgen="http://www.eclipse.org/gmf/2005/GenModel">
6
  <diagram
7
      visualID="1000"
8
      editPartClassName="LibraryEditPart"
9
      itemSemanticEditPolicyClassName="LibraryItemSemanticEditPolicy"
10
      notationViewFactoryClassName="LibraryViewFactory"
11
      iconProviderPriority="Low"
12
      canonicalEditPolicyClassName="LibraryCanonicalEditPolicy">
13
    <diagramRunTimeClass
14
        href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Diagram"/>
15
    <elementType
16
        xsi:type="gmfgen:MetamodelType"
17
        editHelperClassName="LibraryEditHelper"/>
18
    <viewmap
19
        xsi:type="gmfgen:FigureViewmap"
20
        figureQualifiedClassName="org.eclipse.draw2d.FreeformLayer"/>
21
    <domainDiagramElement
22
        href="library.genmodel#//library/Library"/>
23
    <childNodes
24
        xsi:type="gmfgen:GenChildLabelNode"
25
        visualID="3001"
26
        editPartClassName="ReviewEditPart"
27
        itemSemanticEditPolicyClassName="ReviewItemSemanticEditPolicy"
28
        notationViewFactoryClassName="ReviewViewFactory"
29
        canonicalEditPolicyClassName="ReviewCanonicalEditPolicy"
30
        graphicalNodeEditPolicyClassName="ReviewGraphicalNodeEditPolicy"
31
        containers="//@diagram/@compartments.0"
32
        labelElementIcon="true">
33
      <diagramRunTimeClass
34
          href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
35
      <elementType
36
          xsi:type="gmfgen:MetamodelType"
37
          editHelperClassName="ReviewEditHelper"/>
38
      <viewmap
39
          xsi:type="gmfgen:FigureViewmap"
40
          figureQualifiedClassName="org.eclipse.draw2d.Label">
41
        <requiredPluginIDs>org.eclipse.draw2d</requiredPluginIDs>
42
      </viewmap>
43
      <modelFacet>
44
        <metaClass
45
            href="library.genmodel#//library/Review"/>
46
        <containmentMetaFeature
47
            href="library.genmodel#//library/Book/reviews"/>
48
        <childMetaFeature
49
            href="library.genmodel#//library/Book/reviews"/>
50
      </modelFacet>
51
      <labelModelFacet
52
          xsi:type="gmfgen:FeatureLabelModelFacet">
53
        <metaFeature
54
            href="library.genmodel#//library/Review/title"/>
55
      </labelModelFacet>
56
    </childNodes>
57
    <childNodes
58
        xsi:type="gmfgen:GenChildLabelNode"
59
        visualID="3002"
60
        editPartClassName="Review2EditPart"
61
        itemSemanticEditPolicyClassName="Review2ItemSemanticEditPolicy"
62
        notationViewFactoryClassName="Review2ViewFactory"
63
        canonicalEditPolicyClassName="Review2CanonicalEditPolicy"
64
        graphicalNodeEditPolicyClassName="Review2GraphicalNodeEditPolicy"
65
        containers="//@diagram/@compartments.1"
66
        labelElementIcon="true">
67
      <diagramRunTimeClass
68
          href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
69
      <elementType
70
          xsi:type="gmfgen:SpecializationType"
71
          metamodelType="//@diagram/@childNodes.0/@elementType"
72
          editHelperAdviceClassName="ReviewEditHelperAdvice"/>
73
      <viewmap
74
          xsi:type="gmfgen:FigureViewmap"
75
          figureQualifiedClassName="org.eclipse.draw2d.Label">
76
        <requiredPluginIDs>org.eclipse.draw2d</requiredPluginIDs>
77
      </viewmap>
78
      <modelFacet>
79
        <metaClass
80
            href="library.genmodel#//library/Review"/>
81
        <containmentMetaFeature
82
            href="library.genmodel#//library/Book/reviews"/>
83
        <childMetaFeature
84
            href="library.genmodel#//library/Book/reviews"/>
85
      </modelFacet>
86
      <labelModelFacet
87
          xsi:type="gmfgen:FeatureLabelModelFacet">
88
        <metaFeature
89
            href="library.genmodel#//library/Review/title"/>
90
      </labelModelFacet>
91
    </childNodes>
92
    <topLevelNodes
93
        visualID="2001"
94
        editPartClassName="WriterEditPart"
95
        itemSemanticEditPolicyClassName="WriterItemSemanticEditPolicy"
96
        notationViewFactoryClassName="WriterViewFactory"
97
        canonicalEditPolicyClassName="WriterCanonicalEditPolicy"
98
        graphicalNodeEditPolicyClassName="WriterGraphicalNodeEditPolicy">
99
      <diagramRunTimeClass
100
          href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
101
      <elementType
102
          xsi:type="gmfgen:MetamodelType"
103
          editHelperClassName="WriterEditHelper"/>
104
      <viewmap
105
          xsi:type="gmfgen:InnerClassViewmap"
106
          layoutType="TOOLBAR_LAYOUT"
107
          className="NamedNodeRectangle"
108
          classBody="&#xD;&#xA;&#xD;&#xA;/**&#xD;&#xA; * @generated&#xD;&#xA; */&#xD;&#xA;public class NamedNodeRectangle extends org.eclipse.draw2d.RectangleFigure {&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;public NamedNodeRectangle() {&#x9;&#xD;&#xA;&#x9;&#x9;&#xD;&#xA;&#x9;&#x9;org.eclipse.draw2d.ToolbarLayout myGenLayoutManager = new org.eclipse.draw2d.ToolbarLayout();&#xD;&#xA;&#x9;&#x9;&#x9;&#x9;myGenLayoutManager.setStretchMinorAxis(true);&#xD;&#xA;&#x9;&#x9;myGenLayoutManager.setMinorAlignment(org.eclipse.draw2d.ToolbarLayout.ALIGN_CENTER);&#x9;&#x9;&#xD;&#xA;&#x9;&#x9;myGenLayoutManager.setSpacing(0);&#xD;&#xA;&#x9;&#x9;myGenLayoutManager.setVertical(true);&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#x9;&#xD;&#xA;&#x9;&#x9;this.setLayoutManager(myGenLayoutManager);&#xD;&#xA;&#xD;&#xA;&#x9;&#x9;&#xD;&#xA;&#x9;&#x9;createContents();&#xD;&#xA;&#x9;}&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;private void createContents(){&#xD;&#xA;&#x9;&#x9;org.eclipse.draw2d.Label fig_0 = new org.eclipse.draw2d.Label();&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#x9;&#x9;setFigureNamedNode_NameLabelFigure(fig_0);&#xD;&#xA;&#x9;&#x9;&#xD;&#xA;&#x9;&#x9;Object layData0 = null;&#xD;&#xA;&#xD;&#xA;&#x9;&#x9;this.add(fig_0, layData0);&#xD;&#xA;&#x9;}&#xD;&#xA;&#x9;&#xD;&#xA;&#x9;&#x9;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;private org.eclipse.draw2d.Label fNamedNode_NameLabelFigure; &#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;public org.eclipse.draw2d.Label getFigureNamedNode_NameLabelFigure() {&#xD;&#xA;&#x9;&#x9;return fNamedNode_NameLabelFigure;&#xD;&#xA;&#x9;}&#xD;&#xA;&#x9;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;private void setFigureNamedNode_NameLabelFigure(org.eclipse.draw2d.Label fig){&#xD;&#xA;&#x9;&#x9;fNamedNode_NameLabelFigure = fig;&#xD;&#xA;&#x9;}&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;private boolean myUseLocalCoordinates = false;&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;protected boolean useLocalCoordinates() {&#xD;&#xA;&#x9;&#x9;return myUseLocalCoordinates;&#xD;&#xA;&#x9;}&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;protected void setUseLocalCoordinates(boolean useLocalCoordinates) {&#xD;&#xA;&#x9;&#x9;myUseLocalCoordinates = useLocalCoordinates;&#xD;&#xA;&#x9;}&#xD;&#xA;&#x9;&#xD;&#xA;}&#xD;&#xA;">
109
        <requiredPluginIDs>org.eclipse.draw2d</requiredPluginIDs>
110
      </viewmap>
111
      <modelFacet>
112
        <metaClass
113
            href="library.genmodel#//library/Writer"/>
114
        <containmentMetaFeature
115
            href="library.genmodel#//library/Library/writers"/>
116
        <childMetaFeature
117
            href="library.genmodel#//library/Library/writers"/>
118
      </modelFacet>
119
      <labels
120
          visualID="5001"
121
          editPartClassName="WriterNameEditPart"
122
          itemSemanticEditPolicyClassName="WriterNameItemSemanticEditPolicy"
123
          notationViewFactoryClassName="WriterNameViewFactory"
124
          elementIcon="true">
125
        <diagramRunTimeClass
126
            href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
127
        <viewmap
128
            xsi:type="gmfgen:ParentAssignedViewmap"
129
            getterName="getFigureNamedNode_NameLabelFigure"
130
            figureQualifiedClassName="org.eclipse.draw2d.Label"/>
131
        <modelFacet
132
            xsi:type="gmfgen:FeatureLabelModelFacet">
133
          <metaFeature
134
              href="library.genmodel#//library/Writer/name"/>
135
        </modelFacet>
136
      </labels>
137
    </topLevelNodes>
138
    <topLevelNodes
139
        visualID="2002"
140
        editPartClassName="BookEditPart"
141
        itemSemanticEditPolicyClassName="BookItemSemanticEditPolicy"
142
        notationViewFactoryClassName="BookViewFactory"
143
        canonicalEditPolicyClassName="BookCanonicalEditPolicy"
144
        compartments="//@diagram/@compartments.0"
145
        graphicalNodeEditPolicyClassName="BookGraphicalNodeEditPolicy">
146
      <diagramRunTimeClass
147
          href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
148
      <elementType
149
          xsi:type="gmfgen:MetamodelType"
150
          editHelperClassName="BookEditHelper"/>
151
      <viewmap
152
          xsi:type="gmfgen:InnerClassViewmap"
153
          layoutType="TOOLBAR_LAYOUT"
154
          className="NamedNodeRectangle"
155
          classBody="&#xD;&#xA;&#xD;&#xA;/**&#xD;&#xA; * @generated&#xD;&#xA; */&#xD;&#xA;public class NamedNodeRectangle extends org.eclipse.draw2d.RectangleFigure {&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;public NamedNodeRectangle() {&#x9;&#xD;&#xA;&#x9;&#x9;&#xD;&#xA;&#x9;&#x9;org.eclipse.draw2d.ToolbarLayout myGenLayoutManager = new org.eclipse.draw2d.ToolbarLayout();&#xD;&#xA;&#x9;&#x9;&#x9;&#x9;myGenLayoutManager.setStretchMinorAxis(true);&#xD;&#xA;&#x9;&#x9;myGenLayoutManager.setMinorAlignment(org.eclipse.draw2d.ToolbarLayout.ALIGN_CENTER);&#x9;&#x9;&#xD;&#xA;&#x9;&#x9;myGenLayoutManager.setSpacing(0);&#xD;&#xA;&#x9;&#x9;myGenLayoutManager.setVertical(true);&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#x9;&#xD;&#xA;&#x9;&#x9;this.setLayoutManager(myGenLayoutManager);&#xD;&#xA;&#xD;&#xA;&#x9;&#x9;&#xD;&#xA;&#x9;&#x9;createContents();&#xD;&#xA;&#x9;}&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;private void createContents(){&#xD;&#xA;&#x9;&#x9;org.eclipse.draw2d.Label fig_0 = new org.eclipse.draw2d.Label();&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#x9;&#x9;setFigureNamedNode_NameLabelFigure(fig_0);&#xD;&#xA;&#x9;&#x9;&#xD;&#xA;&#x9;&#x9;Object layData0 = null;&#xD;&#xA;&#xD;&#xA;&#x9;&#x9;this.add(fig_0, layData0);&#xD;&#xA;&#x9;}&#xD;&#xA;&#x9;&#xD;&#xA;&#x9;&#x9;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;private org.eclipse.draw2d.Label fNamedNode_NameLabelFigure; &#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;public org.eclipse.draw2d.Label getFigureNamedNode_NameLabelFigure() {&#xD;&#xA;&#x9;&#x9;return fNamedNode_NameLabelFigure;&#xD;&#xA;&#x9;}&#xD;&#xA;&#x9;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;private void setFigureNamedNode_NameLabelFigure(org.eclipse.draw2d.Label fig){&#xD;&#xA;&#x9;&#x9;fNamedNode_NameLabelFigure = fig;&#xD;&#xA;&#x9;}&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;private boolean myUseLocalCoordinates = false;&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;protected boolean useLocalCoordinates() {&#xD;&#xA;&#x9;&#x9;return myUseLocalCoordinates;&#xD;&#xA;&#x9;}&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;protected void setUseLocalCoordinates(boolean useLocalCoordinates) {&#xD;&#xA;&#x9;&#x9;myUseLocalCoordinates = useLocalCoordinates;&#xD;&#xA;&#x9;}&#xD;&#xA;&#x9;&#xD;&#xA;}&#xD;&#xA;">
156
        <requiredPluginIDs>org.eclipse.draw2d</requiredPluginIDs>
157
      </viewmap>
158
      <modelFacet>
159
        <metaClass
160
            href="library.genmodel#//library/Book"/>
161
        <containmentMetaFeature
162
            href="library.genmodel#//library/Library/books"/>
163
        <childMetaFeature
164
            href="library.genmodel#//library/Library/books"/>
165
        <modelElementSelector
166
            body="pages &lt;= 150"/>
167
      </modelFacet>
168
      <labels
169
          visualID="5002"
170
          editPartClassName="BookTitleEditPart"
171
          itemSemanticEditPolicyClassName="BookTitleItemSemanticEditPolicy"
172
          notationViewFactoryClassName="BookTitleViewFactory"
173
          elementIcon="true">
174
        <diagramRunTimeClass
175
            href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
176
        <viewmap
177
            xsi:type="gmfgen:ParentAssignedViewmap"
178
            getterName="getFigureNamedNode_NameLabelFigure"
179
            figureQualifiedClassName="org.eclipse.draw2d.Label"/>
180
        <modelFacet
181
            xsi:type="gmfgen:FeatureLabelModelFacet">
182
          <metaFeature
183
              href="library.genmodel#//library/Book/title"/>
184
        </modelFacet>
185
      </labels>
186
    </topLevelNodes>
187
    <topLevelNodes
188
        visualID="2003"
189
        editPartClassName="Book2EditPart"
190
        itemSemanticEditPolicyClassName="Book2ItemSemanticEditPolicy"
191
        notationViewFactoryClassName="Book2ViewFactory"
192
        canonicalEditPolicyClassName="Book2CanonicalEditPolicy"
193
        compartments="//@diagram/@compartments.1"
194
        graphicalNodeEditPolicyClassName="Book2GraphicalNodeEditPolicy">
195
      <diagramRunTimeClass
196
          href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
197
      <elementType
198
          xsi:type="gmfgen:SpecializationType"
199
          metamodelType="//@diagram/@topLevelNodes.1/@elementType"
200
          editHelperAdviceClassName="BookEditHelperAdvice"/>
201
      <viewmap
202
          xsi:type="gmfgen:InnerClassViewmap"
203
          layoutType="TOOLBAR_LAYOUT"
204
          className="NamedNodeRectangle"
205
          classBody="&#xD;&#xA;&#xD;&#xA;/**&#xD;&#xA; * @generated&#xD;&#xA; */&#xD;&#xA;public class NamedNodeRectangle extends org.eclipse.draw2d.RectangleFigure {&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;public NamedNodeRectangle() {&#x9;&#xD;&#xA;&#x9;&#x9;&#xD;&#xA;&#x9;&#x9;org.eclipse.draw2d.ToolbarLayout myGenLayoutManager = new org.eclipse.draw2d.ToolbarLayout();&#xD;&#xA;&#x9;&#x9;&#x9;&#x9;myGenLayoutManager.setStretchMinorAxis(true);&#xD;&#xA;&#x9;&#x9;myGenLayoutManager.setMinorAlignment(org.eclipse.draw2d.ToolbarLayout.ALIGN_CENTER);&#x9;&#x9;&#xD;&#xA;&#x9;&#x9;myGenLayoutManager.setSpacing(0);&#xD;&#xA;&#x9;&#x9;myGenLayoutManager.setVertical(true);&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#x9;&#xD;&#xA;&#x9;&#x9;this.setLayoutManager(myGenLayoutManager);&#xD;&#xA;&#xD;&#xA;&#x9;&#x9;&#xD;&#xA;&#x9;&#x9;createContents();&#xD;&#xA;&#x9;}&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;private void createContents(){&#xD;&#xA;&#x9;&#x9;org.eclipse.draw2d.Label fig_0 = new org.eclipse.draw2d.Label();&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#x9;&#x9;setFigureNamedNode_NameLabelFigure(fig_0);&#xD;&#xA;&#x9;&#x9;&#xD;&#xA;&#x9;&#x9;Object layData0 = null;&#xD;&#xA;&#xD;&#xA;&#x9;&#x9;this.add(fig_0, layData0);&#xD;&#xA;&#x9;}&#xD;&#xA;&#x9;&#xD;&#xA;&#x9;&#x9;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;private org.eclipse.draw2d.Label fNamedNode_NameLabelFigure; &#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;public org.eclipse.draw2d.Label getFigureNamedNode_NameLabelFigure() {&#xD;&#xA;&#x9;&#x9;return fNamedNode_NameLabelFigure;&#xD;&#xA;&#x9;}&#xD;&#xA;&#x9;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;private void setFigureNamedNode_NameLabelFigure(org.eclipse.draw2d.Label fig){&#xD;&#xA;&#x9;&#x9;fNamedNode_NameLabelFigure = fig;&#xD;&#xA;&#x9;}&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;private boolean myUseLocalCoordinates = false;&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;protected boolean useLocalCoordinates() {&#xD;&#xA;&#x9;&#x9;return myUseLocalCoordinates;&#xD;&#xA;&#x9;}&#xD;&#xA;&#xD;&#xA;&#x9;/**&#xD;&#xA;&#x9; * @generated&#xD;&#xA;&#x9; */&#xD;&#xA;&#x9;protected void setUseLocalCoordinates(boolean useLocalCoordinates) {&#xD;&#xA;&#x9;&#x9;myUseLocalCoordinates = useLocalCoordinates;&#xD;&#xA;&#x9;}&#xD;&#xA;&#x9;&#xD;&#xA;}&#xD;&#xA;">
206
        <requiredPluginIDs>org.eclipse.draw2d</requiredPluginIDs>
207
      </viewmap>
208
      <modelFacet>
209
        <metaClass
210
            href="library.genmodel#//library/Book"/>
211
        <containmentMetaFeature
212
            href="library.genmodel#//library/Library/books"/>
213
        <childMetaFeature
214
            href="library.genmodel#//library/Library/books"/>
215
        <modelElementSelector
216
            body="pages > 150"/>
217
      </modelFacet>
218
      <labels
219
          visualID="5003"
220
          editPartClassName="BookTitle2EditPart"
221
          itemSemanticEditPolicyClassName="BookTitle2ItemSemanticEditPolicy"
222
          notationViewFactoryClassName="BookTitle2ViewFactory"
223
          elementIcon="true">
224
        <diagramRunTimeClass
225
            href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
226
        <viewmap
227
            xsi:type="gmfgen:ParentAssignedViewmap"
228
            getterName="getFigureNamedNode_NameLabelFigure"
229
            figureQualifiedClassName="org.eclipse.draw2d.Label"/>
230
        <modelFacet
231
            xsi:type="gmfgen:FeatureLabelModelFacet">
232
          <metaFeature
233
              href="library.genmodel#//library/Book/title"/>
234
        </modelFacet>
235
      </labels>
236
    </topLevelNodes>
237
    <links
238
        visualID="4001"
239
        editPartClassName="OpinionEditPart"
240
        itemSemanticEditPolicyClassName="OpinionItemSemanticEditPolicy"
241
        notationViewFactoryClassName="OpinionViewFactory">
242
      <diagramRunTimeClass
243
          href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Edge"/>
244
      <elementType
245
          xsi:type="gmfgen:MetamodelType"
246
          editHelperClassName="OpinionEditHelper"/>
247
      <viewmap
248
          xsi:type="gmfgen:FigureViewmap"
249
          figureQualifiedClassName="org.eclipse.draw2d.PolylineConnection">
250
        <requiredPluginIDs>org.eclipse.draw2d</requiredPluginIDs>
251
      </viewmap>
252
      <modelFacet
253
          xsi:type="gmfgen:TypeLinkModelFacet">
254
        <metaClass
255
            href="library.genmodel#//library/Opinion"/>
256
        <containmentMetaFeature
257
            href="library.genmodel#//library/Writer/opinions"/>
258
        <childMetaFeature
259
            href="library.genmodel#//library/Writer/opinions"/>
260
        <targetMetaFeature
261
            href="library.genmodel#//library/Opinion/book"/>
262
      </modelFacet>
263
      <labels
264
          visualID="6001"
265
          editPartClassName="OpinionTextEditPart"
266
          itemSemanticEditPolicyClassName="OpinionTextItemSemanticEditPolicy"
267
          notationViewFactoryClassName="OpinionTextViewFactory">
268
        <diagramRunTimeClass
269
            href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
270
        <viewmap
271
            xsi:type="gmfgen:FigureViewmap"
272
            figureQualifiedClassName="org.eclipse.draw2d.Label">
273
          <attributes
274
              xsi:type="gmfgen:LabelOffsetAttributes"
275
              y="40"/>
276
          <requiredPluginIDs>org.eclipse.draw2d</requiredPluginIDs>
277
        </viewmap>
278
        <modelFacet
279
            xsi:type="gmfgen:FeatureLabelModelFacet"
280
            editPattern="">
281
          <metaFeature
282
              href="library.genmodel#//library/Opinion/text"/>
283
        </modelFacet>
284
      </labels>
285
    </links>
286
    <links
287
        visualID="4002"
288
        editPartClassName="BookAuthorEditPart"
289
        itemSemanticEditPolicyClassName="BookAuthorItemSemanticEditPolicy"
290
        notationViewFactoryClassName="BookAuthorViewFactory">
291
      <diagramRunTimeClass
292
          href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Edge"/>
293
      <elementType
294
          xsi:type="gmfgen:SpecializationType"
295
          editHelperAdviceClassName="BookAuthorEditHelperAdvice"/>
296
      <viewmap
297
          xsi:type="gmfgen:FigureViewmap"
298
          figureQualifiedClassName="org.eclipse.draw2d.PolylineConnection">
299
        <requiredPluginIDs>org.eclipse.draw2d</requiredPluginIDs>
300
      </viewmap>
301
      <modelFacet
302
          xsi:type="gmfgen:FeatureLinkModelFacet">
303
        <metaFeature
304
            href="library.genmodel#//library/Book/author"/>
305
      </modelFacet>
306
    </links>
307
    <compartments
308
        visualID="7001"
309
        editPartClassName="BookCompartmentEditPart"
310
        itemSemanticEditPolicyClassName="BookCompartmentItemSemanticEditPolicy"
311
        notationViewFactoryClassName="BookCompartmentViewFactory"
312
        childNodes="//@diagram/@childNodes.0"
313
        canonicalEditPolicyClassName="BookCompartmentCanonicalEditPolicy"
314
        title="Compartment"
315
        node="//@diagram/@topLevelNodes.1">
316
      <diagramRunTimeClass
317
          href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
318
      <viewmap
319
          xsi:type="gmfgen:FigureViewmap"
320
          figureQualifiedClassName="org.eclipse.draw2d.LabeledContainer">
321
        <requiredPluginIDs>org.eclipse.draw2d</requiredPluginIDs>
322
      </viewmap>
323
    </compartments>
324
    <compartments
325
        visualID="7002"
326
        editPartClassName="BookCompartment2EditPart"
327
        itemSemanticEditPolicyClassName="BookCompartment2ItemSemanticEditPolicy"
328
        notationViewFactoryClassName="BookCompartment2ViewFactory"
329
        childNodes="//@diagram/@childNodes.1"
330
        canonicalEditPolicyClassName="BookCompartment2CanonicalEditPolicy"
331
        title="Compartment"
332
        node="//@diagram/@topLevelNodes.2">
333
      <diagramRunTimeClass
334
          href="../../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
335
      <viewmap
336
          xsi:type="gmfgen:FigureViewmap"
337
          figureQualifiedClassName="org.eclipse.draw2d.LabeledContainer">
338
        <requiredPluginIDs>org.eclipse.draw2d</requiredPluginIDs>
339
      </viewmap>
340
    </compartments>
341
  </diagram>
342
  <plugin/>
343
  <editor/>
344
  <domainGenModel
345
      href="library.genmodel#/"/>
346
  <expressionProviders>
347
    <providers
348
        xsi:type="gmfgen:GenExpressionInterpreter"
349
        expressions="//@diagram/@topLevelNodes.1/@modelFacet/@modelElementSelector //@diagram/@topLevelNodes.2/@modelFacet/@modelElementSelector">
350
      <requiredPluginIDs>org.eclipse.emf.ocl</requiredPluginIDs>
351
      <requiredPluginIDs>org.eclipse.emf.query.ocl</requiredPluginIDs>
352
    </providers>
353
  </expressionProviders>
354
</gmfgen:GenEditorGenerator>
(-)src/org/eclipse/gmf/tests/lite/setup/LibraryConstrainedSetup.java (+108 lines)
Added Link Here
1
/**
2
 * Copyright (c) 2006 Eclipse.org
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *    bblajer - initial API and implementation
11
 */
12
package org.eclipse.gmf.tests.lite.setup;
13
14
import java.io.IOException;
15
16
import junit.framework.Assert;
17
18
import org.eclipse.emf.ecore.EClass;
19
import org.eclipse.emf.ecore.EReference;
20
import org.eclipse.gmf.tests.EPath;
21
import org.eclipse.gmf.tests.lite.Activator;
22
import org.eclipse.gmf.tests.lite.gen.LiteGeneratorConfiguration;
23
import org.eclipse.gmf.tests.setup.DiaGenFileSetup;
24
import org.eclipse.gmf.tests.setup.DiaGenSource;
25
import org.eclipse.gmf.tests.setup.DomainModelFileSetup;
26
import org.eclipse.gmf.tests.setup.DomainModelSource;
27
import org.eclipse.gmf.tests.setup.GeneratorConfiguration;
28
import org.eclipse.gmf.tests.setup.MapDefFileSetup;
29
import org.eclipse.gmf.tests.setup.MapDefSource;
30
import org.eclipse.gmf.tests.setup.SessionSetup;
31
32
public class LibraryConstrainedSetup extends SessionSetup {
33
	private static String modelURI = "/models/library/library.ecore"; //$NON-NLS-1$
34
	private static String mapURI = "/models/library/library_constrained.gmfmap"; //$NON-NLS-1$
35
	private static String genURI = "/models/library/library_constrained.gmfgen"; //$NON-NLS-1$
36
37
	protected LibraryConstrainedSetup() {
38
	}
39
40
	public static LibraryConstrainedSetup getInstance() {
41
		if (factoryClosed) {
42
			return null;
43
		}
44
		return new LibraryConstrainedSetup();
45
	}
46
47
	protected DomainModelSource createDomainModel() {
48
		DomainModelFileSetup modelSetup = new DomainModelFileSetup() {
49
			public EClass getDiagramElement() {
50
				return (EClass) EPath.ECORE.lookup(getModel(), "Library"); //$NON-NLS-1$
51
			}
52
			public NodeData getNodeA() {
53
				EClass n = (EClass) EPath.ECORE.lookup(getModel(), "Writer"); //$NON-NLS-1$
54
				EReference c = (EReference) EPath.ECORE.lookup(getModel(), "Library::writers"); //$NON-NLS-1$
55
				return new NodeData(n, null, c);
56
			}
57
			public NodeData getNodeB() {
58
				EClass n = (EClass) EPath.ECORE.lookup(getModel(), "Book"); //$NON-NLS-1$
59
				EReference c = (EReference) EPath.ECORE.lookup(getModel(), "Library::books"); //$NON-NLS-1$
60
				return new NodeData(n, null, c);
61
			}
62
			public EReference getLinkAsRef() {
63
				return (EReference) EPath.ECORE.lookup(getModel(), "Book::author"); //$NON-NLS-1$
64
			}
65
			public LinkData getLinkAsClass() {
66
				EClass l = (EClass) EPath.ECORE.lookup(getModel(), "Opinion"); //$NON-NLS-1$
67
				EReference t = (EReference) EPath.ECORE.lookup(getModel(), "Opinion::book"); //$NON-NLS-1$
68
				EReference c = (EReference) EPath.ECORE.lookup(getModel(), "Writer::opinions"); //$NON-NLS-1$
69
				return new LinkData(l, t, c);
70
			}
71
		};
72
		try {
73
			modelSetup.init(Activator.createURI(modelURI));
74
		} catch (IOException e) {
75
			e.printStackTrace();
76
			Assert.fail("Failed to setup the domain model. " + e.getLocalizedMessage()); //$NON-NLS-1$
77
		}
78
		return modelSetup;
79
	}
80
81
	protected MapDefSource createMapModel() {
82
		MapDefFileSetup mapSetup = new MapDefFileSetup() {
83
		};
84
		try {
85
			mapSetup.init(Activator.createURI(mapURI));
86
		} catch (IOException e) {
87
			e.printStackTrace();
88
			Assert.fail("Failed to setup the gmfmap. " + e.getLocalizedMessage()); //$NON-NLS-1$
89
		}
90
		return mapSetup;
91
	}
92
93
	protected DiaGenSource createGenModel() {
94
		DiaGenFileSetup genSetup = new DiaGenFileSetup() {
95
		};
96
		try {
97
			genSetup.init(Activator.createURI(genURI));
98
		} catch (IOException e) {
99
			e.printStackTrace();
100
			Assert.fail("Failed to setup the gmfmap. " + e.getLocalizedMessage()); //$NON-NLS-1$
101
		}
102
		return genSetup;
103
	}
104
105
	protected GeneratorConfiguration createGeneratorConfiguration() {
106
		return new LiteGeneratorConfiguration();
107
	}
108
}
(-)models/library/library_constrained.gmfmap (+136 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<gmfmap:Mapping xmi:version="2.0"
3
    xmlns:xmi="http://www.omg.org/XMI"
4
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
6
    xmlns:gmfmap="http://www.eclipse.org/gmf/2005/mappings">
7
  <nodes>
8
    <containmentFeature
9
        href="library.ecore#//Library/writers"/>
10
    <ownedChild>
11
      <domainMetaElement
12
          href="library.ecore#//Writer"/>
13
      <labelMappings>
14
        <diagramLabel
15
            href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#NamedNode_Name"/>
16
        <features
17
            href="library.ecore#//Writer/name"/>
18
      </labelMappings>
19
      <diagramNode
20
          href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#NamedNode"/>
21
    </ownedChild>
22
  </nodes>
23
  <nodes>
24
    <containmentFeature
25
        href="library.ecore#//Library/books"/>
26
    <ownedChild>
27
      <domainMetaElement
28
          href="library.ecore#//Book"/>
29
      <domainSpecialization
30
          body="pages > 150"/>
31
      <labelMappings>
32
        <diagramLabel
33
            href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#NamedNode_Name"/>
34
        <features
35
            href="library.ecore#//Book/title"/>
36
      </labelMappings>
37
      <diagramNode
38
          href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#NamedNode"/>
39
      <children
40
          compartment="//@nodes.1/@ownedChild/@compartments.0">
41
        <containmentFeature
42
            href="library.ecore#//Book/reviews"/>
43
        <ownedChild>
44
          <domainMetaElement
45
              href="library.ecore#//Review"/>
46
          <labelMappings>
47
            <diagramLabel
48
                href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#Label"/>
49
            <features
50
                href="library.ecore#//Review/title"/>
51
          </labelMappings>
52
          <diagramNode
53
              href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#Label"/>
54
        </ownedChild>
55
      </children>
56
      <compartments
57
          children="//@nodes.1/@ownedChild/@children.0">
58
        <compartment
59
            href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#Compartment"/>
60
      </compartments>
61
    </ownedChild>
62
  </nodes>
63
  <nodes>
64
    <containmentFeature
65
        href="library.ecore#//Library/books"/>
66
    <ownedChild>
67
      <domainMetaElement
68
          href="library.ecore#//Book"/>
69
      <domainSpecialization
70
          body="pages &lt;= 150"/>
71
      <labelMappings>
72
        <diagramLabel
73
            href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#NamedNode_Name"/>
74
        <features
75
            href="library.ecore#//Book/title"/>
76
      </labelMappings>
77
      <diagramNode
78
          href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#NamedNode"/>
79
      <children
80
          compartment="//@nodes.2/@ownedChild/@compartments.0">
81
        <containmentFeature
82
            href="library.ecore#//Book/reviews"/>
83
        <ownedChild>
84
          <domainMetaElement
85
              href="library.ecore#//Review"/>
86
          <labelMappings>
87
            <diagramLabel
88
                href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#Label"/>
89
            <features
90
                href="library.ecore#//Review/title"/>
91
          </labelMappings>
92
          <diagramNode
93
              href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#Label"/>
94
        </ownedChild>
95
      </children>
96
      <compartments
97
          children="//@nodes.2/@ownedChild/@children.0">
98
        <compartment
99
            href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#Compartment"/>
100
      </compartments>
101
    </ownedChild>
102
  </nodes>
103
  <links>
104
    <domainMetaElement
105
        href="library.ecore#//Opinion"/>
106
    <labelMappings
107
        editPattern="">
108
      <diagramLabel
109
          href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#Label"/>
110
      <features
111
          href="library.ecore#//Opinion/text"/>
112
    </labelMappings>
113
    <containmentFeature
114
        href="library.ecore#//Writer/opinions"/>
115
    <diagramLink
116
        href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#Link"/>
117
    <linkMetaFeature
118
        xsi:type="ecore:EReference"
119
        href="library.ecore#//Opinion/book"/>
120
  </links>
121
  <links>
122
    <diagramLink
123
        href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#Link"/>
124
    <linkMetaFeature
125
        xsi:type="ecore:EReference"
126
        href="library.ecore#//Book/author"/>
127
  </links>
128
  <diagram>
129
    <diagramCanvas
130
        href="../../../../plugin/org.eclipse.gmf.graphdef/models/basic.gmfgraph#Surface"/>
131
    <domainModel
132
        href="library.ecore#/"/>
133
    <domainMetaElement
134
        href="library.ecore#//Library"/>
135
  </diagram>
136
</gmfmap:Mapping>
(-)src/org/eclipse/gmf/tests/lite/gef/NotationRefreshTest.java (+124 lines)
Added Link Here
1
/**
2
 * Copyright (c) 2006 Eclipse.org
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *    bblajer - initial API and implementation
11
 */
12
package org.eclipse.gmf.tests.lite.gef;
13
14
import java.util.Iterator;
15
16
import org.eclipse.core.runtime.NullProgressMonitor;
17
import org.eclipse.draw2d.geometry.Rectangle;
18
import org.eclipse.emf.common.command.Command;
19
import org.eclipse.emf.ecore.EClass;
20
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.emf.ecore.EStructuralFeature;
22
import org.eclipse.emf.edit.command.AddCommand;
23
import org.eclipse.emf.edit.command.RemoveCommand;
24
import org.eclipse.emf.edit.command.SetCommand;
25
import org.eclipse.emf.transaction.TransactionalEditingDomain;
26
import org.eclipse.emf.transaction.util.TransactionUtil;
27
import org.eclipse.emf.workspace.EMFCommandOperation;
28
import org.eclipse.gef.EditPart;
29
import org.eclipse.gmf.runtime.notation.Bounds;
30
import org.eclipse.gmf.runtime.notation.Diagram;
31
import org.eclipse.gmf.runtime.notation.Node;
32
import org.eclipse.gmf.runtime.notation.View;
33
import org.eclipse.gmf.tests.rt.RuntimeDiagramTestBase;
34
35
public class NotationRefreshTest extends RuntimeDiagramTestBase {
36
	public NotationRefreshTest(String name) {
37
		super(name);
38
	}
39
40
	public void testNotationRefreshOnDeleteNode() throws Exception {
41
		EditPart diagramEP = getDiagramEditPart();
42
		Diagram diagram = (Diagram) diagramEP.getModel();
43
		EObject diagramElement = diagram.getElement();
44
		TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(diagramElement);
45
		View nodeA = getCanvasInstance().getNodeA();
46
		EObject elementA = nodeA.getElement();
47
		EditPart editPartA = findEditPart(nodeA);
48
		Command command = RemoveCommand.create(editingDomain, elementA.eContainer(), elementA.eContainingFeature(), elementA);
49
		assertTrue("Failed to obtain command to remove an instance of the domain model element", command != null && command.canExecute());
50
		new EMFCommandOperation(editingDomain, command).execute(new NullProgressMonitor(), null);
51
		assertNull("RemoveCommand not executed properly", elementA.eContainer());
52
		assertNull("Notational refresh failed on domain element removal", findView(diagram, elementA));
53
		assertNull("EditPart not removed automatically", findEditPart(nodeA));
54
		assertFalse(editPartA.isActive());
55
	}
56
57
	public void testNotationRefreshOnCreateNode() throws Exception {
58
		EditPart diagramEP = getDiagramEditPart();
59
		Diagram diagram = (Diagram) diagramEP.getModel();
60
		EObject diagramElement = diagram.getElement();
61
		TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(diagramElement);
62
		EStructuralFeature feature = getCanvasInstance().getNodeA().getElement().eContainmentFeature();
63
		EClass newChildClass = getCanvasInstance().getNodeA().getElement().eClass();
64
		EObject newChild = newChildClass.getEPackage().getEFactoryInstance().create(newChildClass);
65
		
66
		Command command = AddCommand.create(editingDomain, diagramElement, feature, newChild);
67
		assertTrue("Failed to obtain command to create a new instance of the domain model element", command != null && command.canExecute());
68
		new EMFCommandOperation(editingDomain, command).execute(new NullProgressMonitor(), null);
69
		assertSame("AddCommand not executed properly", diagramElement, newChild.eContainer());
70
		View newChildView = findView(diagram, newChild);
71
		assertNotNull("Notational refresh failed on domain element creation", newChildView);
72
		int visualId = getType(newChildView);
73
		assertEquals(getGenModel().getNodeA().getVisualID(), visualId);
74
		EditPart newChildEP = findEditPart(newChildView);
75
		assertNotNull("EditPart not created automatically", newChildEP);
76
	}
77
78
	public void testNotationRefreshOnAttributeChangeThatAffectsSelector() throws Exception {
79
		EditPart diagramEP = getDiagramEditPart();
80
		Diagram diagram = (Diagram) diagramEP.getModel();
81
		EObject diagramElement = diagram.getElement();
82
		TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(diagramElement);
83
		Node nodeB = getCanvasInstance().getNodeB();
84
		Bounds bounds = (Bounds) nodeB.getLayoutConstraint();
85
		Rectangle rectangle = new Rectangle(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight());
86
		assertEquals("Unexpected visual ID of the element", getGenModel().getNodeB().getVisualID(), getType(nodeB));
87
		EObject elementB = nodeB.getElement();
88
		EditPart editPartB = findEditPart(nodeB);
89
		EClass elementBClass = elementB.eClass();
90
		EStructuralFeature feature = elementBClass.getEStructuralFeature("pages");	//$NON-NLS-1$
91
		assertNotNull("Failed to find the feature that affects selector", feature);
92
		Integer newValue = new Integer(200);
93
		Command command = SetCommand.create(editingDomain, elementB, feature, newValue);
94
		assertTrue("Failed to obtain command to make a change that affects selector", command != null && command.canExecute());
95
		new EMFCommandOperation(editingDomain, command).execute(new NullProgressMonitor(), null);
96
		assertEquals("SetCommand not executed properly", newValue, elementB.eGet(feature));
97
		Node newNodeB = (Node) findView(diagram, elementB);
98
		assertNotNull("Notational refresh failed to recreate a new node upon a change that affects selector", newNodeB);
99
		assertNotSame("Notational refresh failed to replace a new node upon a change that affects selector", nodeB, newNodeB);
100
		assertTrue("Notational refresh failed to change visual ID of the element upon a change that affects selector", getGenModel().getNodeB().getVisualID() != getType(newNodeB));
101
		EditPart newEditPartB = findEditPart(newNodeB);
102
		assertNotNull("EditPart not recreated automatically", newEditPartB);
103
		assertNotSame("EditPart not replaced automatically", editPartB, newEditPartB);
104
		assertFalse(editPartB.isActive());
105
		assertTrue(newEditPartB.isActive());
106
		Bounds newBounds = (Bounds) newNodeB.getLayoutConstraint();
107
		Rectangle newRectangle = new Rectangle(newBounds.getX(), newBounds.getY(), newBounds.getWidth(), newBounds.getHeight());
108
		assertEquals("Notational refresh failed to position the new node where the old one was", rectangle, newRectangle);
109
	}
110
111
	private int getType(View view) {
112
		return Integer.parseInt(view.getType());
113
	}
114
115
	private View findView(View container, EObject child) {
116
		for(Iterator it = container.getChildren().iterator(); it.hasNext(); ) {
117
			View next = (View) it.next();
118
			if (child.equals(next.getElement())) {
119
				return next;
120
			}
121
		}
122
		return null;
123
	}
124
}
(-)models/library/library.genmodel (+44 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<genmodel:GenModel xmi:version="2.0"
3
    xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
4
    xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/library_constrained/src"
5
    editDirectory="/library_constrained.edit/src" editorDirectory="/library_constrained.editor/src"
6
    modelPluginID="library_constrained" modelName="Library" importerID="org.eclipse.emf.importer.rose">
7
  <foreignModel>C:\library.mdl</foreignModel>
8
  <genPackages prefix="Library" basePackage="org.eclipse.example" disposableProviderFactory="true"
9
      ecorePackage="library.ecore#/">
10
    <genEnums ecoreEnum="library.ecore#//BookCategory">
11
      <genEnumLiterals ecoreEnumLiteral="library.ecore#//BookCategory/Mystery"/>
12
      <genEnumLiterals ecoreEnumLiteral="library.ecore#//BookCategory/ScienceFiction"/>
13
      <genEnumLiterals ecoreEnumLiteral="library.ecore#//BookCategory/Biography"/>
14
    </genEnums>
15
    <genClasses ecoreClass="library.ecore#//Book">
16
      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute library.ecore#//Book/title"/>
17
      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute library.ecore#//Book/pages"/>
18
      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute library.ecore#//Book/category"/>
19
      <genFeatures notify="false" createChild="false" ecoreFeature="ecore:EReference library.ecore#//Book/author"/>
20
      <genFeatures children="true" createChild="true" ecoreFeature="ecore:EReference library.ecore#//Book/reviews"/>
21
    </genClasses>
22
    <genClasses ecoreClass="library.ecore#//Library">
23
      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute library.ecore#//Library/name"/>
24
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference library.ecore#//Library/writers"/>
25
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference library.ecore#//Library/books"/>
26
    </genClasses>
27
    <genClasses ecoreClass="library.ecore#//Writer">
28
      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute library.ecore#//Writer/name"/>
29
      <genFeatures notify="false" createChild="false" ecoreFeature="ecore:EReference library.ecore#//Writer/books"/>
30
      <genFeatures children="true" createChild="true" ecoreFeature="ecore:EReference library.ecore#//Writer/opinions"/>
31
    </genClasses>
32
    <genClasses ecoreClass="library.ecore#//Review">
33
      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute library.ecore#//Review/title"/>
34
      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute library.ecore#//Review/positive"/>
35
      <genFeatures property="None" notify="false" createChild="false" ecoreFeature="ecore:EReference library.ecore#//Review/book"/>
36
    </genClasses>
37
    <genClasses ecoreClass="library.ecore#//Opinion">
38
      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute library.ecore#//Opinion/text"/>
39
      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute library.ecore#//Opinion/context"/>
40
      <genFeatures notify="false" createChild="false" ecoreFeature="ecore:EReference library.ecore#//Opinion/writer"/>
41
      <genFeatures notify="false" createChild="false" ecoreFeature="ecore:EReference library.ecore#//Opinion/book"/>
42
    </genClasses>
43
  </genPackages>
44
</genmodel:GenModel>

Return to bug 146009