View | Details | Raw Unified | Return to bug 143934
Collapse All | Expand All

(-)src/org/eclipse/gmf/tests/gef/DiagramNodeTest.java (-80 / +42 lines)
Lines 18-189 Link Here
18
import org.eclipse.gef.RequestConstants;
18
import org.eclipse.gef.RequestConstants;
19
import org.eclipse.gef.commands.Command;
19
import org.eclipse.gef.commands.Command;
20
import org.eclipse.gef.requests.ChangeBoundsRequest;
20
import org.eclipse.gef.requests.ChangeBoundsRequest;
21
import org.eclipse.gmf.codegen.gmfgen.GenCompartment;
22
import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
21
import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
23
import org.eclipse.gmf.runtime.notation.FillStyle;
22
import org.eclipse.gmf.runtime.notation.FillStyle;
24
import org.eclipse.gmf.runtime.notation.LineStyle;
23
import org.eclipse.gmf.runtime.notation.LineStyle;
25
import org.eclipse.gmf.runtime.notation.Location;
24
import org.eclipse.gmf.runtime.notation.Location;
26
import org.eclipse.gmf.runtime.notation.Node;
25
import org.eclipse.gmf.runtime.notation.Node;
27
import org.eclipse.gmf.runtime.notation.NotationFactory;
28
import org.eclipse.gmf.runtime.notation.NotationPackage;
26
import org.eclipse.gmf.runtime.notation.NotationPackage;
29
import org.eclipse.gmf.runtime.notation.Size;
27
import org.eclipse.gmf.runtime.notation.Size;
30
import org.eclipse.gmf.runtime.notation.View;
31
import org.eclipse.gmf.tests.rt.GeneratedCanvasTest;
32
import org.eclipse.gmf.tests.setup.CompartmentsSessionSetup;
33
import org.eclipse.gmf.tests.setup.DiaGenSource;
34
import org.eclipse.gmf.tests.setup.RTSetup;
35
import org.eclipse.gmf.tests.setup.RTSource;
36
import org.eclipse.gmf.tests.setup.SessionSetup;
37
import org.eclipse.swt.graphics.RGB;
28
import org.eclipse.swt.graphics.RGB;
38
29
39
public class DiagramNodeTest extends GeneratedCanvasTest {
30
public class DiagramNodeTest extends CompartmentTestBase {
40
31
41
	private final Point myMoveDelta = new Point(10, 20);
32
	private final Point myMoveDelta = new Point(10, 20);
42
	private final Dimension mySizeDelta = new Dimension(100, 50);
33
	private final Dimension mySizeDelta = new Dimension(100, 50);
43
	private EditPart myNodeEditPart;
44
34
45
	public DiagramNodeTest(String name) {
35
	public DiagramNodeTest(String name) {
46
		super(name);
36
		super(name);
47
	}
37
	}
48
38
49
	protected EditPart getNodeEditPart() {
50
		return myNodeEditPart;
51
	}
52
	
53
	protected SessionSetup createDefaultSetup() {
54
		return CompartmentsSessionSetup.newInstance();
55
	}
56
57
	// TODO EditPartViewer[Source|Setup]
58
	protected void setUp() throws Exception {
59
		super.setUp();
60
		myNodeEditPart = findEditPart(getCanvasInstance().getNode());
61
	}
62
	
63
	protected RTSource createCanvasInstance() throws Exception {
64
		class RTSetupExt extends RTSetup {
65
			protected void initDiagramFileContents(DomainInstanceProducer instanceProducer, DiaGenSource genSource) {
66
				super.initDiagramFileContents(instanceProducer, genSource);
67
				Node compartment = NotationFactory.eINSTANCE.createNode();
68
				GenCompartment genCompartment = (GenCompartment) getSetup().getGenModel().getNodeA().getCompartments().get(0); 
69
				compartment.setType(String.valueOf(genCompartment.getVisualID()));
70
				getNode().getTransientChildren().add(compartment);
71
				assertTrue(getNode().getChildren().contains(compartment));
72
			}
73
		}
74
		return new RTSetupExt().init(getSetup().getGenProject().getBundle(), getSetup().getGenModel());
75
	}
76
	
77
	public void testChangeBounds() {
39
	public void testChangeBounds() {
78
		final Point originalLocation = getLocation();
40
		final EditPart editPart = getNodeEditPartA();
79
		final Dimension originalSize = getSize();
41
		final Node notation = getNotation(editPart);
42
		
43
		final Point originalLocation = getLocation(notation);
44
		final Dimension originalSize = getSize(notation);
80
		final Point expectedLocation = originalLocation.getTranslated(myMoveDelta);
45
		final Point expectedLocation = originalLocation.getTranslated(myMoveDelta);
81
		final Dimension expectedNewSize = originalSize.getExpanded(mySizeDelta);
46
		final Dimension expectedNewSize = originalSize.getExpanded(mySizeDelta);
82
		ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
47
		ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
83
		// TODO use expectedLocation as fields, and calculate deltas here locally 
48
		// TODO use expectedLocation as fields, and calculate deltas here locally 
84
		req.setMoveDelta(myMoveDelta);
49
		req.setMoveDelta(myMoveDelta);
85
		req.setSizeDelta(mySizeDelta);
50
		req.setSizeDelta(mySizeDelta);
86
		req.setEditParts(getNodeEditPart());
51
		req.setEditParts(editPart);
87
		req.setResizeDirection(PositionConstants.NORTH_WEST);
52
		req.setResizeDirection(PositionConstants.NORTH_WEST);
88
		Command cmd = getNodeEditPart().getCommand(req);
53
		Command cmd = editPart.getCommand(req);
89
		assertNotNull("No resize command", cmd);
54
		assertNotNull("No resize command", cmd);
90
		assertTrue("Can't execute resize command", cmd.canExecute());
55
		assertTrue("Can't execute resize command", cmd.canExecute());
91
		getCommandStack().execute(cmd);
56
		getCommandStack().execute(cmd);
92
		assertBoundValues(expectedLocation, expectedNewSize, "exec");
57
		assertBoundValues(notation, expectedLocation, expectedNewSize, "exec");
93
58
94
		assertTrue("Can't undo resize command", getCommandStack().canUndo());
59
		assertTrue("Can't undo resize command", getCommandStack().canUndo());
95
		getCommandStack().undo();
60
		getCommandStack().undo();
96
		assertBoundValues(originalLocation, originalSize, "undo");
61
		assertBoundValues(notation, originalLocation, originalSize, "undo");
97
62
98
		assertTrue("Can't redo resize command", getCommandStack().canRedo());
63
		assertTrue("Can't redo resize command", getCommandStack().canRedo());
99
		getCommandStack().redo();
64
		getCommandStack().redo();
100
		assertBoundValues(expectedLocation, expectedNewSize, "redo");
65
		assertBoundValues(notation, expectedLocation, expectedNewSize, "redo");
101
	}
66
	}
102
67
	
103
	private void assertBoundValues(Point expectedLocation, Dimension expectedSize, String assertTag) {
68
	private void assertBoundValues(Node notation, Point expectedLocation, Dimension expectedSize, String assertTag) {
104
		assertEquals("Location doesn't match one set after [" + assertTag + ']', expectedLocation, getLocation());
69
		assertEquals("Location doesn't match one set after [" + assertTag + ']', expectedLocation, getLocation(notation));
105
		assertEquals("Size doesn't match one set after [" + assertTag + ']', expectedSize, getSize());
70
		assertEquals("Size doesn't match one set after [" + assertTag + ']', expectedSize, getSize(notation));
106
	}
71
	}
107
72
108
	private int getForegroundColor() {
73
	private int getForegroundColor(Node notation) {
109
		// @see o.e.g.r.d.ui.GraphicalEditPart#refreshForegroundColor
74
		// @see o.e.g.r.d.ui.GraphicalEditPart#refreshForegroundColor
110
		LineStyle ls = (LineStyle) getNode().getStyle(NotationPackage.eINSTANCE.getLineStyle());
75
		LineStyle ls = (LineStyle) notation.getStyle(NotationPackage.eINSTANCE.getLineStyle());
111
		return ls.getLineColor();
76
		return ls.getLineColor();
112
		//return PresentationResourceManager.getInstance().getColor(new Integer(ls.getLineColor()));
77
		//return PresentationResourceManager.getInstance().getColor(new Integer(ls.getLineColor()));
113
	}
78
	}
114
79
115
	private int getBackgroundColor() {
80
	private int getBackgroundColor(Node notation) {
116
		FillStyle fs = (FillStyle) getNode().getStyle(NotationPackage.eINSTANCE.getFillStyle());
81
		FillStyle fs = (FillStyle) notation.getStyle(NotationPackage.eINSTANCE.getFillStyle());
117
		return fs.getFillColor();
82
		return fs.getFillColor();
118
		//return PresentationResourceManager.getInstance().getColor(new Integer(fs.getFillColor()));
83
		//return PresentationResourceManager.getInstance().getColor(new Integer(fs.getFillColor()));
119
	}
84
	}
120
85
121
	private Dimension getSize() {
86
	private Dimension getSize(Node notation) {
122
		Size b = (Size) getNode().getLayoutConstraint();
87
		Size b = (Size) notation.getLayoutConstraint();
123
		return new Dimension(b.getWidth(), b.getHeight());
88
		return new Dimension(b.getWidth(), b.getHeight());
124
	}
89
	}
125
90
126
	private Point getLocation() {
91
	private Point getLocation(Node notation) {
127
		Location l = (Location) getNode().getLayoutConstraint();
92
		Location l = (Location) notation.getLayoutConstraint();
128
		return new Point(l.getX(), l.getY());
93
		return new Point(l.getX(), l.getY());
129
	}
94
	}
130
95
131
	public void testChangeColors() {
96
	public void testChangeColors() {
132
		final int originalBackgroundColor = getBackgroundColor(); 
97
		final Node notation = getNotation(getNodeEditPartA());
133
		final int originalForegroundColor = getForegroundColor();
98
		
99
		final int originalBackgroundColor = getBackgroundColor(notation); 
100
		final int originalForegroundColor = getForegroundColor(notation);
134
		
101
		
135
		final int newBackgroundColor = FigureUtilities.RGBToInteger(new RGB(255, 0, 0)).intValue(); // RED
102
		final int newBackgroundColor = FigureUtilities.RGBToInteger(new RGB(255, 0, 0)).intValue(); // RED
136
		final int newForegroundColor = FigureUtilities.RGBToInteger(new RGB(0, 255, 255)).intValue(); // CYAN
103
		final int newForegroundColor = FigureUtilities.RGBToInteger(new RGB(0, 255, 255)).intValue(); // CYAN
137
		assert newBackgroundColor != originalBackgroundColor;
104
		assert newBackgroundColor != originalBackgroundColor;
138
		assert newForegroundColor != originalForegroundColor;
105
		assert newForegroundColor != originalForegroundColor;
139
106
140
		final Command foreCmd = createChangeColorCommand(newForegroundColor, true);
107
		final Command foreCmd = createChangeColorCommand(notation, newForegroundColor, true);
141
		assertNotNull("No changeForegroundColor command", foreCmd);
108
		assertNotNull("No changeForegroundColor command", foreCmd);
142
		assertTrue("Can't execute changeForegroundColor command", foreCmd.canExecute());
109
		assertTrue("Can't execute changeForegroundColor command", foreCmd.canExecute());
143
110
144
		getCommandStack().execute(foreCmd);
111
		getCommandStack().execute(foreCmd);
145
		assertColorValues(newForegroundColor, originalBackgroundColor, "exec(fore)");
112
		assertColorValues(notation, newForegroundColor, originalBackgroundColor, "exec(fore)");
146
113
147
		assertTrue("Can't undo changeForegroundColor command", getCommandStack().canUndo());
114
		assertTrue("Can't undo changeForegroundColor command", getCommandStack().canUndo());
148
		getCommandStack().undo();
115
		getCommandStack().undo();
149
		assertColorValues(originalForegroundColor, originalBackgroundColor, "undo(fore)");
116
		assertColorValues(notation, originalForegroundColor, originalBackgroundColor, "undo(fore)");
150
117
151
		assertTrue("Can't redo changeForegroundColor command", getCommandStack().canRedo());
118
		assertTrue("Can't redo changeForegroundColor command", getCommandStack().canRedo());
152
		getCommandStack().redo();
119
		getCommandStack().redo();
153
		assertColorValues(newForegroundColor, originalBackgroundColor, "redo(fore)");
120
		assertColorValues(notation, newForegroundColor, originalBackgroundColor, "redo(fore)");
154
121
155
		// after redo, newForeroundColor should be considered as originalForeground
122
		// after redo, newForeroundColor should be considered as originalForeground
156
		// unless one change the order of fore/back checks
123
		// unless one change the order of fore/back checks
157
		final Command backCmd = createChangeColorCommand(newBackgroundColor, false);
124
		final Command backCmd = createChangeColorCommand(notation, newBackgroundColor, false);
158
		assertNotNull("No changeBackgroundColor command", backCmd);
125
		assertNotNull("No changeBackgroundColor command", backCmd);
159
		assertTrue("Can't execute changeBackgroundColor command", backCmd.canExecute());
126
		assertTrue("Can't execute changeBackgroundColor command", backCmd.canExecute());
160
127
161
		getCommandStack().execute(backCmd);
128
		getCommandStack().execute(backCmd);
162
		assertColorValues(newForegroundColor, newBackgroundColor, "exec(back)");
129
		assertColorValues(notation, newForegroundColor, newBackgroundColor, "exec(back)");
163
130
164
		assertTrue("Can't undo changeBackgroundColor command", getCommandStack().canUndo());
131
		assertTrue("Can't undo changeBackgroundColor command", getCommandStack().canUndo());
165
		getCommandStack().undo();
132
		getCommandStack().undo();
166
		assertColorValues(newForegroundColor, originalBackgroundColor, "undo(back)");
133
		assertColorValues(notation, newForegroundColor, originalBackgroundColor, "undo(back)");
167
134
168
		assertTrue("Can't redo changeBackgroundColor command", getCommandStack().canRedo());
135
		assertTrue("Can't redo changeBackgroundColor command", getCommandStack().canRedo());
169
		getCommandStack().redo();
136
		getCommandStack().redo();
170
		assertColorValues(newForegroundColor, newBackgroundColor, "redo(back)");
137
		assertColorValues(notation, newForegroundColor, newBackgroundColor, "redo(back)");
171
	}
138
	}
172
139
173
	private Command createChangeColorCommand(final int newColor, final boolean isForeground) {
140
	private Command createChangeColorCommand(Node notation, final int newColor, final boolean isForeground) {
174
		return getViewerConfiguration().getSetNotationalElementStructuralFeature((View)getNodeEditPart().getModel(), isForeground ? NotationPackage.eINSTANCE.getLineStyle_LineColor() : NotationPackage.eINSTANCE.getFillStyle_FillColor(), new Integer(newColor));
141
		return getViewerConfiguration().getSetNotationalElementStructuralFeature(notation, 
142
				isForeground ? NotationPackage.eINSTANCE.getLineStyle_LineColor() : NotationPackage.eINSTANCE.getFillStyle_FillColor(), 
143
				new Integer(newColor));
175
	}
144
	}
176
145
177
	private void assertColorValues(int expectedForegroundColor, int expectedBackgroundColor, String assertTag) {
146
	private void assertColorValues(Node notation, int expectedForegroundColor, int expectedBackgroundColor, String assertTag) {
178
		assertEquals("Foreground color doesn't match after [" + assertTag + ']', expectedForegroundColor, getForegroundColor());
147
		assertEquals("Foreground color doesn't match after [" + assertTag + ']', expectedForegroundColor, getForegroundColor(notation));
179
		assertEquals("Background color doesn't match after [" + assertTag + ']', expectedBackgroundColor, getBackgroundColor());
148
		assertEquals("Background color doesn't match after [" + assertTag + ']', expectedBackgroundColor, getBackgroundColor(notation));
180
	}
149
	}
181
150
182
//	private Request createChangeColorRequest() {
183
//		return new Request();
184
//	}
185
186
	protected Node getNode() {
187
		return (Node) getNodeEditPart().getModel();
188
	}
189
}
151
}
(-)src/org/eclipse/gmf/tests/rt/RuntimeDiagramTestBase.java (-36 lines)
Lines 16-26 Link Here
16
import org.eclipse.emf.common.notify.Notification;
16
import org.eclipse.emf.common.notify.Notification;
17
import org.eclipse.emf.common.notify.impl.AdapterImpl;
17
import org.eclipse.emf.common.notify.impl.AdapterImpl;
18
import org.eclipse.gef.commands.Command;
18
import org.eclipse.gef.commands.Command;
19
import org.eclipse.gmf.codegen.gmfgen.GenCommonBase;
20
import org.eclipse.gmf.codegen.gmfgen.GenLink;
19
import org.eclipse.gmf.codegen.gmfgen.GenLink;
21
import org.eclipse.gmf.runtime.notation.Diagram;
20
import org.eclipse.gmf.runtime.notation.Diagram;
22
import org.eclipse.gmf.runtime.notation.Edge;
21
import org.eclipse.gmf.runtime.notation.Edge;
23
import org.eclipse.gmf.runtime.notation.Node;
24
import org.eclipse.gmf.runtime.notation.View;
22
import org.eclipse.gmf.runtime.notation.View;
25
import org.eclipse.gmf.tests.setup.DiaGenSource;
23
import org.eclipse.gmf.tests.setup.DiaGenSource;
26
import org.eclipse.gmf.tests.setup.LinksSessionSetup;
24
import org.eclipse.gmf.tests.setup.LinksSessionSetup;
Lines 35-44 Link Here
35
		super(name);
33
		super(name);
36
	}
34
	}
37
35
38
	protected Diagram getDiagram() {
39
		return (Diagram) getDiagramEditPart().getModel();
40
	}
41
42
	protected DiaGenSource getGenModel() {
36
	protected DiaGenSource getGenModel() {
43
		return getSetup().getGenModel();
37
		return getSetup().getGenModel();
44
	}
38
	}
Lines 47-82 Link Here
47
		return LinksSessionSetup.newInstance();
41
		return LinksSessionSetup.newInstance();
48
	}
42
	}
49
43
50
	protected Node createNode(GenCommonBase nodeType, View notationContainer) {
51
		final Object[] newObjHolder = new Object[1];
52
53
		Adapter adapter = new AdapterImpl() {
54
			public void notifyChanged(Notification msg) {
55
				super.notifyChanged(msg);
56
				if (msg.getEventType() == Notification.ADD) {
57
					newObjHolder[0] = msg.getNewValue();
58
				}
59
			}
60
61
			public boolean isAdapterForType(Object type) {
62
				return true;
63
			}
64
		};
65
		Command cmd = getViewerConfiguration().getCreateNodeCommand(notationContainer, nodeType);
66
		Assert.assertNotNull("No command is available for request", cmd); //$NON-NLS-1$		
67
		notationContainer.eAdapters().add(adapter);
68
		try {
69
			execute(cmd);
70
		} catch (Exception e) {
71
			e.printStackTrace();
72
			Assert.fail("Node creation failure: " + e.getLocalizedMessage()); //$NON-NLS-1$			
73
		} finally {
74
			notationContainer.eAdapters().remove(adapter);
75
		}
76
		assertTrue("Faile to create notation model Node", newObjHolder[0] instanceof Node); //$NON-NLS-1$
77
		return (Node) newObjHolder[0];
78
	}
79
80
	protected boolean canStartLinkFrom(GenLink linkType, View source) {
44
	protected boolean canStartLinkFrom(GenLink linkType, View source) {
81
		Command cmd = getViewerConfiguration().getStartLinkCommand(source, linkType);
45
		Command cmd = getViewerConfiguration().getStartLinkCommand(source, linkType);
82
		return cmd != null && cmd.canExecute();
46
		return cmd != null && cmd.canExecute();
(-)src/org/eclipse/gmf/tests/rt/GeneratedCanvasTest.java (+41 lines)
Lines 11-20 Link Here
11
 */
11
 */
12
package org.eclipse.gmf.tests.rt;
12
package org.eclipse.gmf.tests.rt;
13
13
14
import junit.framework.Assert;
15
16
import org.eclipse.emf.common.notify.Adapter;
17
import org.eclipse.emf.common.notify.Notification;
18
import org.eclipse.emf.common.notify.impl.AdapterImpl;
14
import org.eclipse.gef.EditPart;
19
import org.eclipse.gef.EditPart;
15
import org.eclipse.gef.commands.Command;
20
import org.eclipse.gef.commands.Command;
16
import org.eclipse.gef.commands.CommandStack;
21
import org.eclipse.gef.commands.CommandStack;
22
import org.eclipse.gmf.codegen.gmfgen.GenCommonBase;
17
import org.eclipse.gmf.runtime.notation.Diagram;
23
import org.eclipse.gmf.runtime.notation.Diagram;
24
import org.eclipse.gmf.runtime.notation.Node;
18
import org.eclipse.gmf.runtime.notation.View;
25
import org.eclipse.gmf.runtime.notation.View;
19
import org.eclipse.gmf.tests.ConfiguredTestCase;
26
import org.eclipse.gmf.tests.ConfiguredTestCase;
20
import org.eclipse.gmf.tests.setup.RTSetup;
27
import org.eclipse.gmf.tests.setup.RTSetup;
Lines 61-66 Link Here
61
	public ViewerConfiguration getViewerConfiguration() {
68
	public ViewerConfiguration getViewerConfiguration() {
62
		return myViewerConfiguration;
69
		return myViewerConfiguration;
63
	}
70
	}
71
	
72
	protected Node createNode(GenCommonBase nodeType, View notationContainer) {
73
		final Object[] newObjHolder = new Object[1];
74
75
		Adapter adapter = new AdapterImpl() {
76
			public void notifyChanged(Notification msg) {
77
				super.notifyChanged(msg);
78
				if (msg.getEventType() == Notification.ADD) {
79
					newObjHolder[0] = msg.getNewValue();
80
				}
81
			}
82
83
			public boolean isAdapterForType(Object type) {
84
				return true;
85
			}
86
		};
87
		Command cmd = getViewerConfiguration().getCreateNodeCommand(notationContainer, nodeType);
88
		Assert.assertNotNull("No command is available for request", cmd); //$NON-NLS-1$		
89
		notationContainer.eAdapters().add(adapter);
90
		try {
91
			execute(cmd);
92
		} catch (Exception e) {
93
			e.printStackTrace();
94
			Assert.fail("Node creation failure: " + e.getLocalizedMessage()); //$NON-NLS-1$			
95
		} finally {
96
			notationContainer.eAdapters().remove(adapter);
97
		}
98
		assertTrue("Faile to create notation model Node", newObjHolder[0] instanceof Node); //$NON-NLS-1$
99
		return (Node) newObjHolder[0];
100
	}
101
	
102
	protected Diagram getDiagram() {
103
		return (Diagram) getDiagramEditPart().getModel();
104
	}
64
105
65
	protected void tearDown() throws Exception {
106
	protected void tearDown() throws Exception {
66
		if (myParentShell != null) {
107
		if (myParentShell != null) {
(-)src/org/eclipse/gmf/tests/setup/RTSource.java (-1 / +2 lines)
Lines 21-26 Link Here
21
 */
21
 */
22
public interface RTSource {
22
public interface RTSource {
23
	Diagram getCanvas();
23
	Diagram getCanvas();
24
	Node getNode();
24
	Node getNodeA();
25
	Node getNodeB();
25
	Edge getLink();
26
	Edge getLink();
26
}
27
}
(-)src/org/eclipse/gmf/tests/setup/CompartmentsSessionSetup.java (-33 / +80 lines)
Lines 12-17 Link Here
12
12
13
package org.eclipse.gmf.tests.setup;
13
package org.eclipse.gmf.tests.setup;
14
14
15
import java.util.Iterator;
16
15
import junit.framework.Assert;
17
import junit.framework.Assert;
16
18
17
import org.eclipse.emf.ecore.EAttribute;
19
import org.eclipse.emf.ecore.EAttribute;
Lines 20-27 Link Here
20
import org.eclipse.emf.ecore.ETypedElement;
22
import org.eclipse.emf.ecore.ETypedElement;
21
import org.eclipse.emf.ecore.EcoreFactory;
23
import org.eclipse.emf.ecore.EcoreFactory;
22
import org.eclipse.emf.ecore.EcorePackage;
24
import org.eclipse.emf.ecore.EcorePackage;
25
import org.eclipse.emf.ecore.util.EcoreUtil;
23
import org.eclipse.gmf.gmfgraph.Canvas;
26
import org.eclipse.gmf.gmfgraph.Canvas;
24
import org.eclipse.gmf.gmfgraph.Compartment;
27
import org.eclipse.gmf.gmfgraph.Compartment;
28
import org.eclipse.gmf.gmfgraph.DiagramLabel;
25
import org.eclipse.gmf.gmfgraph.Figure;
29
import org.eclipse.gmf.gmfgraph.Figure;
26
import org.eclipse.gmf.gmfgraph.FigureGallery;
30
import org.eclipse.gmf.gmfgraph.FigureGallery;
27
import org.eclipse.gmf.gmfgraph.GMFGraphFactory;
31
import org.eclipse.gmf.gmfgraph.GMFGraphFactory;
Lines 54-68 Link Here
54
	
58
	
55
	protected MapDefSource createMapModel() {
59
	protected MapDefSource createMapModel() {
56
		MapDefSource mapDefSource = new MapSetupWithCompartments().init(getGraphDefModel(), getDomainModel(), new ToolDefSetup());
60
		MapDefSource mapDefSource = new MapSetupWithCompartments().init(getGraphDefModel(), getDomainModel(), new ToolDefSetup());
57
		Assert.assertFalse(mapDefSource.getNodeA().getCompartments().isEmpty());
61
		assertCompartmentMapping(mapDefSource.getNodeA());
58
		CompartmentMapping compartmentMapping = (CompartmentMapping) mapDefSource.getNodeA().getCompartments().get(0);
62
		assertCompartmentMapping(mapDefSource.getNodeB());
59
		Assert.assertSame(mapDefSource.getNodeA(), compartmentMapping.getParentNode());
60
		return mapDefSource;
63
		return mapDefSource;
61
	}
64
	}
62
	
65
	
66
	private void assertCompartmentMapping(NodeMapping nodeMapping){
67
		Assert.assertFalse(nodeMapping.getCompartments().isEmpty());
68
		for (Iterator compartments = nodeMapping.getCompartments().iterator(); compartments.hasNext();){
69
			CompartmentMapping next = (CompartmentMapping)compartments.next();
70
			Assert.assertSame(nodeMapping, next.getParentNode());
71
		}
72
	}
73
	
63
	protected DiaGenSource createGenModel() {
74
	protected DiaGenSource createGenModel() {
64
		DiaGenSource result = new DiaGenSetup().init(getMapModel());
75
		DiaGenSource result = new DiaGenSetup().init(getMapModel());
65
		Assert.assertFalse(result.getNodeA().getCompartments().isEmpty());
76
		Assert.assertFalse(result.getNodeA().getCompartments().isEmpty());
77
		Assert.assertFalse(result.getNodeB().getCompartments().isEmpty());
66
		return result;
78
		return result;
67
	}
79
	}
68
	
80
	
Lines 75-95 Link Here
75
	}
87
	}
76
	
88
	
77
	public static interface DiaDefSourceExtension extends DiaDefSource {
89
	public static interface DiaDefSourceExtension extends DiaDefSource {
78
		public Compartment getCompartment();
90
		/**
91
		 * @return compartment, hasTitle = true, collapsible = true
92
		 */
93
		public Compartment getCompartmentA();
94
		/**
95
		 * @return compartment, hasTitle = false, collapsible = false
96
		 */
97
		public Compartment getCompartmentB();
79
	}
98
	}
80
	
99
	
81
	public static interface DomainModelSourceExtension extends DomainModelSource {
100
	public static interface DomainModelSourceExtension extends DomainModelSource {
82
		public NodeData getChildOfA();
101
		public NodeData getChildOfA();
102
		public NodeData getChildOfB();
83
	}
103
	}
84
	
104
	
85
	protected static class DiaDefSetupWithCompartments extends DiaDefSetup implements DiaDefSourceExtension {
105
	protected static class DiaDefSetupWithCompartments extends DiaDefSetup implements DiaDefSourceExtension {
106
		private Compartment myCollapsibleCompartmentWithTitle;
107
		private Compartment myCompartmentNoTitleNoCollapse;
108
		
86
		public void setupCanvasDef(Canvas canvasDef) {
109
		public void setupCanvasDef(Canvas canvasDef) {
87
			FigureGallery oneMoreGallery = GMFGraphFactory.eINSTANCE.createFigureGallery();
110
			FigureGallery oneMoreGallery = GMFGraphFactory.eINSTANCE.createFigureGallery();
88
			canvasDef.getFigures().add(oneMoreGallery);
111
			canvasDef.getFigures().add(oneMoreGallery);
89
			Figure compartmentFigure = GMFGraphFactory.eINSTANCE.createRectangle();
112
			Figure compartmentFigure = GMFGraphFactory.eINSTANCE.createRectangle();
90
			oneMoreGallery.getFigures().add(compartmentFigure);
113
			oneMoreGallery.getFigures().add(compartmentFigure);
91
			Compartment compartment = createCompartment(compartmentFigure, "CompartmentA", true, true);
114
			myCollapsibleCompartmentWithTitle = createCompartment(compartmentFigure, "Compartment_Title_Collapse", true, true);
92
			canvasDef.getCompartments().add(compartment);
115
			canvasDef.getCompartments().add(myCollapsibleCompartmentWithTitle);
116
			
117
			myCompartmentNoTitleNoCollapse = createCompartment(compartmentFigure, "Compartment_NoTitle_No_Collapse", false, false);
118
			canvasDef.getCompartments().add(myCompartmentNoTitleNoCollapse);
93
		}
119
		}
94
		
120
		
95
		protected void setupNodeDef(Node nodeDef) {
121
		protected void setupNodeDef(Node nodeDef) {
Lines 97-146 Link Here
97
			figure.setLayout(GMFGraphFactory.eINSTANCE.createBorderLayout());
123
			figure.setLayout(GMFGraphFactory.eINSTANCE.createBorderLayout());
98
		}
124
		}
99
		
125
		
100
		public Compartment getCompartment(){
126
		public Compartment getCompartmentA() {
101
			return (Compartment)getCanvasDef().getCompartments().get(0);
127
			return myCollapsibleCompartmentWithTitle;
102
		}
128
		}
103
129
		
130
		public Compartment getCompartmentB() {
131
			return myCompartmentNoTitleNoCollapse;
132
		}
133
		
104
		private Compartment createCompartment(Figure figure, String name, boolean collapsible, boolean needsTitle){
134
		private Compartment createCompartment(Figure figure, String name, boolean collapsible, boolean needsTitle){
105
			Compartment result = GMFGraphFactory.eINSTANCE.createCompartment();
135
			Compartment result = GMFGraphFactory.eINSTANCE.createCompartment();
106
			result.setCollapsible(true);
107
			result.setFigure(figure);
136
			result.setFigure(figure);
108
			result.setName(name);
137
			result.setName(name);
109
			result.setNeedsTitle(needsTitle);
138
			result.setNeedsTitle(needsTitle);
139
			result.setCollapsible(collapsible);
110
			return result;
140
			return result;
111
		}
141
		}
112
113
	}
142
	}
114
	
143
	
115
	protected static class DomainSetupWithChildren extends DomainModelSetup implements DomainModelSourceExtension {
144
	protected static class DomainSetupWithChildren extends DomainModelSetup implements DomainModelSourceExtension {
116
		private NodeData myChildOfA;
145
		private NodeData myChildOfA;
146
		private NodeData myChildOfB;
117
		
147
		
118
		public DomainModelSetup init() {
148
		public DomainModelSetup init() {
119
			DomainModelSetup result = super.init();
149
			DomainModelSetup result = super.init();
120
			result.getModel().setName("ModelWithChildren");
150
			result.getModel().setName("ModelWithChildren");
121
151
122
			EClass childClass = EcoreFactory.eINSTANCE.createEClass();
152
			EClass childClass = EcoreFactory.eINSTANCE.createEClass();
123
			childClass.setName("ChildOfA");
153
			childClass.setName("Child");
124
			EAttribute childLabel = EcoreFactory.eINSTANCE.createEAttribute();
154
			EAttribute childLabel = EcoreFactory.eINSTANCE.createEAttribute();
125
			childLabel.setName("childLabel");
155
			childLabel.setName("childLabel");
126
			childLabel.setEType(EcorePackage.eINSTANCE.getEString());
156
			childLabel.setEType(EcorePackage.eINSTANCE.getEString());
127
			childClass.getEStructuralFeatures().add(childLabel);
157
			childClass.getEStructuralFeatures().add(childLabel);
128
			result.getModel().getEClassifiers().add(childClass);
158
			result.getModel().getEClassifiers().add(childClass);
129
			
159
			
130
			EReference containment = EcoreFactory.eINSTANCE.createEReference();
160
			EReference containmentForA = EcoreFactory.eINSTANCE.createEReference();
131
			containment.setContainment(true);
161
			containmentForA.setContainment(true);
132
			containment.setName("childrenOfA");
162
			containmentForA.setName("childrenOfA");
133
			containment.setEType(childClass);
163
			containmentForA.setEType(childClass);
134
			containment.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY);
164
			containmentForA.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY);
135
			result.getNodeA().getEClass().getEStructuralFeatures().add(containment);
165
			result.getNodeA().getEClass().getEStructuralFeatures().add(containmentForA);
166
			
167
			EReference containmentForB = (EReference) EcoreUtil.copy(containmentForA);
168
			containmentForB.setName("childrenOfB");
169
			result.getNodeB().getEClass().getEStructuralFeatures().add(containmentForB);
136
			
170
			
137
			myChildOfA = new NodeData(childClass, childLabel, containment);
171
			myChildOfA = new NodeData(childClass, childLabel, containmentForA);
172
			myChildOfB = new NodeData(childClass, childLabel, containmentForB);
138
			return result;
173
			return result;
139
		}
174
		}
140
		
175
		
141
		public NodeData getChildOfA() {
176
		public NodeData getChildOfA() {
142
			return myChildOfA;
177
			return myChildOfA;
143
		}
178
		}
179
		
180
		public NodeData getChildOfB(){
181
			return myChildOfB;
182
		}	
144
	}
183
	}
145
	
184
	
146
	protected static class MapSetupWithCompartments extends MapSetup {
185
	protected static class MapSetupWithCompartments extends MapSetup {
Lines 150-175 Link Here
150
			
189
			
151
			DomainSetupWithChildren domainWithChildren = (DomainSetupWithChildren)domainSource;
190
			DomainSetupWithChildren domainWithChildren = (DomainSetupWithChildren)domainSource;
152
			DiaDefSetupWithCompartments diaDefSetupWithCompartments = (DiaDefSetupWithCompartments)ddSource;
191
			DiaDefSetupWithCompartments diaDefSetupWithCompartments = (DiaDefSetupWithCompartments)ddSource;
153
			Assert.assertNotNull(diaDefSetupWithCompartments.getCompartment());
192
			Assert.assertNotNull(diaDefSetupWithCompartments.getCompartmentA());
193
			Assert.assertNotNull(diaDefSetupWithCompartments.getCompartmentB());
154
			
194
			
155
			MapSetup result = super.init(ddSource, domainSource, toolDef);
195
			MapSetup result = super.init(ddSource, domainSource, toolDef);
156
			
196
			
157
			NodeData childOfAData = domainWithChildren.getChildOfA();
197
			setupReferenceAndCompartment(ddSource, diaDefSetupWithCompartments.getCompartmentA(), domainWithChildren.getChildOfA(), result.getNodeA());
158
			NodeMapping childOfAMapping = createNodeMapping(ddSource.getNodeDef(), childOfAData.getEClass(), ddSource.getLabelDef(), childOfAData.getNameAttr(), childOfAData.getContainment(), false);
198
			setupReferenceAndCompartment(ddSource, diaDefSetupWithCompartments.getCompartmentB(), domainWithChildren.getChildOfB(), result.getNodeB());
159
			
160
			ChildReference childOfAReference = GMFMapFactory.eINSTANCE.createChildReference();
161
			childOfAReference.setOwnedChild(childOfAMapping);
162
			childOfAReference.setChildrenFeature(childOfAData.getContainment());
163
			childOfAReference.setContainmentFeature(childOfAData.getContainment());
164
			result.getNodeA().getChildren().add(childOfAReference);
165
			
166
			CompartmentMapping childOfACompartment = GMFMapFactory.eINSTANCE.createCompartmentMapping();
167
			childOfACompartment.setCompartment(diaDefSetupWithCompartments.getCompartment());
168
			childOfACompartment.getChildren().add(childOfAReference);
169
			result.getNodeA().getCompartments().add(childOfACompartment);
170
199
171
			return result;
200
			return result;
172
		}
201
		}
202
		
203
		private ChildReference setupReferenceAndCompartment(DiaDefSource ddSource, Compartment diagramCompartment, NodeData data, NodeMapping parentMapping){
204
			Node diagramNode = ddSource.getNodeDef();
205
			DiagramLabel diagramLabel = ddSource.getLabelDef(); 
206
			NodeMapping childMapping = createNodeMapping(diagramNode, data.getEClass(), diagramLabel, data.getNameAttr(), data.getContainment(), false);
207
			
208
			ChildReference childReference = GMFMapFactory.eINSTANCE.createChildReference();
209
			childReference.setOwnedChild(childMapping);
210
			childReference.setChildrenFeature(data.getContainment());
211
			childReference.setContainmentFeature(data.getContainment());
212
			
213
			CompartmentMapping compartmentMapping = GMFMapFactory.eINSTANCE.createCompartmentMapping();
214
			compartmentMapping.setCompartment(diagramCompartment);
215
			compartmentMapping.getChildren().add(childReference);
216
			
217
			parentMapping.getCompartments().add(compartmentMapping);
218
			return childReference;
219
		}
173
	}
220
	}
174
	
221
	
175
}
222
}
(-)src/org/eclipse/gmf/tests/setup/RTSetup.java (-19 / +34 lines)
Lines 34-39 Link Here
34
import org.eclipse.emf.ecore.resource.ResourceSet;
34
import org.eclipse.emf.ecore.resource.ResourceSet;
35
import org.eclipse.emf.transaction.TransactionalEditingDomain;
35
import org.eclipse.emf.transaction.TransactionalEditingDomain;
36
import org.eclipse.emf.workspace.AbstractEMFOperation;
36
import org.eclipse.emf.workspace.AbstractEMFOperation;
37
import org.eclipse.gmf.codegen.gmfgen.GenNode;
37
import org.eclipse.gmf.codegen.gmfgen.TypeLinkModelFacet;
38
import org.eclipse.gmf.codegen.gmfgen.TypeLinkModelFacet;
38
import org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory;
39
import org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory;
39
import org.eclipse.gmf.runtime.notation.Bounds;
40
import org.eclipse.gmf.runtime.notation.Bounds;
Lines 53-59 Link Here
53
public class RTSetup implements RTSource {
54
public class RTSetup implements RTSource {
54
55
55
	private Diagram myCanvas;
56
	private Diagram myCanvas;
56
	private Node myNode;
57
	private Node myNodeA;
58
	private Node myNodeB;
57
	private Edge myLink;
59
	private Edge myLink;
58
	
60
	
59
	private EObject myDiagramElement;
61
	private EObject myDiagramElement;
Lines 78-95 Link Here
78
	 */
80
	 */
79
	protected void initDiagramFileContents(DomainInstanceProducer instanceProducer, DiaGenSource genSource) {
81
	protected void initDiagramFileContents(DomainInstanceProducer instanceProducer, DiaGenSource genSource) {
80
		myCanvas = NotationFactory.eINSTANCE.createDiagram();
82
		myCanvas = NotationFactory.eINSTANCE.createDiagram();
81
		myNode = NotationFactory.eINSTANCE.createNode();
82
		myLink = NotationFactory.eINSTANCE.createEdge();
83
		myCanvas.getPersistedChildren().add(myNode);
84
		myCanvas.getPersistedEdges().add(myLink);
85
86
		myDiagramElement = instanceProducer.createInstance(genSource.getGenDiagram().getDomainDiagramElement());
87
		myCanvas.setElement(myDiagramElement);
83
		myCanvas.setElement(myDiagramElement);
88
		myCanvas.setType(genSource.getGenDiagram().getEditorGen().getModelID());
84
		myCanvas.setType(genSource.getGenDiagram().getEditorGen().getModelID());
89
		EObject nodeElement = instanceProducer.createInstance(genSource.getNodeA().getDomainMetaClass());
85
		myDiagramElement = instanceProducer.createInstance(genSource.getGenDiagram().getDomainDiagramElement());
90
		instanceProducer.setFeatureValue(myDiagramElement, nodeElement, genSource.getNodeA().getModelFacet().getContainmentMetaFeature());
86
		
91
		myNode.setElement(nodeElement);
87
		myNodeA = setupNotationNode(genSource.getNodeA(), instanceProducer);
92
		myNode.setType(String.valueOf(genSource.getNodeA().getVisualID()));
88
		myNodeB = setupNotationNode(genSource.getNodeB(), instanceProducer);
89
90
		myLink = NotationFactory.eINSTANCE.createEdge();
91
		myCanvas.getPersistedEdges().add(myLink);
92
		
93
		//myNode.setVisualID(genSource.getGenNode().getVisualID());
93
		//myNode.setVisualID(genSource.getGenNode().getVisualID());
94
		TypeLinkModelFacet mf = (TypeLinkModelFacet) genSource.getLinkC().getModelFacet();
94
		TypeLinkModelFacet mf = (TypeLinkModelFacet) genSource.getLinkC().getModelFacet();
95
		EObject linkElement = instanceProducer.createInstance(mf.getMetaClass());
95
		EObject linkElement = instanceProducer.createInstance(mf.getMetaClass());
Lines 97-108 Link Here
97
		myLink.setType(String.valueOf(genSource.getLinkC().getVisualID()));
97
		myLink.setType(String.valueOf(genSource.getLinkC().getVisualID()));
98
		//myLink.setVisualID(genSource.getGenLink().getVisualID());
98
		//myLink.setVisualID(genSource.getGenLink().getVisualID());
99
99
100
		myNode.getStyles().add(NotationFactory.eINSTANCE.createShapeStyle());
101
		final Bounds b = NotationFactory.eINSTANCE.createBounds();
102
		b.setWidth(0);
103
		b.setHeight(0);
104
		myNode.setLayoutConstraint(b);
105
106
		myCanvas.setType(genSource.getGenDiagram().getEditorGen().getDomainGenModel().getModelName());
100
		myCanvas.setType(genSource.getGenDiagram().getEditorGen().getDomainGenModel().getModelName());
107
101
108
		/*
102
		/*
Lines 118-123 Link Here
118
		*/
112
		*/
119
	}
113
	}
120
	
114
	
115
	private Node setupNotationNode(GenNode genNode, DomainInstanceProducer instanceProducer){
116
		Node result = NotationFactory.eINSTANCE.createNode();
117
		myCanvas.getPersistedChildren().add(result);
118
		EObject nodeElement = instanceProducer.createInstance(genNode.getDomainMetaClass());
119
		instanceProducer.setFeatureValue(myDiagramElement, nodeElement, genNode.getModelFacet().getContainmentMetaFeature());
120
		result.setElement(nodeElement);
121
		result.setType(String.valueOf(genNode.getVisualID()));
122
123
		result.getStyles().add(NotationFactory.eINSTANCE.createShapeStyle());
124
		Bounds b = NotationFactory.eINSTANCE.createBounds();
125
		b.setWidth(0);
126
		b.setHeight(0);
127
		result.setLayoutConstraint(b);
128
		
129
		return result;
130
	}
131
	
121
	private void saveDiagramFile(String editingDomainId){
132
	private void saveDiagramFile(String editingDomainId){
122
        TransactionalEditingDomain ted = DiagramEditingDomainFactory.getInstance().createEditingDomain();
133
        TransactionalEditingDomain ted = DiagramEditingDomainFactory.getInstance().createEditingDomain();
123
        ted.setID(editingDomainId);
134
        ted.setID(editingDomainId);
Lines 150-157 Link Here
150
		return myCanvas;
161
		return myCanvas;
151
	}
162
	}
152
163
153
	public final Node getNode() {
164
	public final Node getNodeA() {
154
		return myNode;
165
		return myNodeA;
166
	}
167
	
168
	public final Node getNodeB() {
169
		return myNodeB;
155
	}
170
	}
156
171
157
	public Edge getLink() {
172
	public Edge getLink() {
(-)src/org/eclipse/gmf/tests/AllTests.java (+2 lines)
Lines 20-25 Link Here
20
import junit.framework.TestSuite;
20
import junit.framework.TestSuite;
21
21
22
import org.eclipse.gmf.runtime.emf.type.core.internal.EMFTypePlugin;
22
import org.eclipse.gmf.runtime.emf.type.core.internal.EMFTypePlugin;
23
import org.eclipse.gmf.tests.gef.CompartmentPropertiesTest;
23
import org.eclipse.gmf.tests.gef.DiagramNodeTest;
24
import org.eclipse.gmf.tests.gef.DiagramNodeTest;
24
import org.eclipse.gmf.tests.gen.AuditHandcodedTest;
25
import org.eclipse.gmf.tests.gen.AuditHandcodedTest;
25
import org.eclipse.gmf.tests.gen.CodegenReconcileTest;
26
import org.eclipse.gmf.tests.gen.CodegenReconcileTest;
Lines 92-97 Link Here
92
		suite.addTestSuite(CompilationTest.class);
93
		suite.addTestSuite(CompilationTest.class);
93
94
94
		suite.addTest(feed(DiagramNodeTest.class, compartmentsSession));
95
		suite.addTest(feed(DiagramNodeTest.class, compartmentsSession));
96
		suite.addTest(feed(CompartmentPropertiesTest.class, compartmentsSession));
95
		suite.addTest(feed(NamingStrategyTest.class, sessionSetup));
97
		suite.addTest(feed(NamingStrategyTest.class, sessionSetup));
96
		suite.addTest(feed(GenModelTransformerBasicRTTest.class, sessionSetup));
98
		suite.addTest(feed(GenModelTransformerBasicRTTest.class, sessionSetup));
97
99
(-)src/org/eclipse/gmf/tests/gef/CompartmentPropertiesTest.java (+133 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2006 Borland Software Corporation
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
 *    Michael Golubev (Borland) - initial API and implementation
11
 */
12
13
package org.eclipse.gmf.tests.gef;
14
15
16
import org.eclipse.draw2d.IFigure;
17
import org.eclipse.draw2d.ScrollPane;
18
import org.eclipse.gmf.codegen.gmfgen.GenCompartment;
19
import org.eclipse.gmf.codegen.gmfgen.GenNode;
20
import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
21
import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure;
22
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrapLabel;
23
import org.eclipse.gmf.runtime.notation.DrawerStyle;
24
import org.eclipse.gmf.runtime.notation.NotationPackage;
25
import org.eclipse.gmf.runtime.notation.TitleStyle;
26
import org.eclipse.gmf.runtime.notation.View;
27
28
public final class CompartmentPropertiesTest extends CompartmentTestBase {
29
	private static final NotationPackage NOTATION = NotationPackage.eINSTANCE; 
30
	
31
	public CompartmentPropertiesTest(String name) {
32
		super(name);
33
	}
34
	
35
	/**
36
	 * Simplified version of testCompartmentTitles() 
37
	 * Checks GEF properties for notation elements explictly created via RTSource.
38
	 * Emulates opening of the diagram created earlier  
39
	 */
40
	public void testCompartmentTitles_Static(){
41
		checkNoTitle(getCompartmentEditPartB());
42
		checkHasTitle(getCompartmentEditPartA());
43
		//notation elements were explicitly created in RTSource, 
44
		//it does not make sense to check their styles
45
	}
46
	
47
	public void off_XXX_can_not_create_command_testCompartmentTitles(){
48
		CompartmentEditPart newCompartmentA = createNewCompartment(getSetup().getGenModel().getNodeA());
49
		checkHasTitle(newCompartmentA);
50
		View withTitleStyle = getNotation(newCompartmentA);
51
		TitleStyle titleStyle = (TitleStyle) withTitleStyle.getStyle(NOTATION.getTitleStyle());
52
		assertNotNull(titleStyle);
53
		assertTrue(titleStyle.isShowTitle());
54
		
55
		
56
		CompartmentEditPart newCompartmentB = createNewCompartment(getSetup().getGenModel().getNodeB());
57
		checkNoTitle(newCompartmentB);
58
		View withoutTitleStyle = getNotation(newCompartmentB);
59
		assertNull("[#143934] Required to disable title configuration in property sheet", 
60
				withoutTitleStyle.getStyle(NOTATION.getTitleStyle()));
61
	}
62
	
63
	public void testCompartmentCollapsed_Static(){
64
		checkIsCollapsed(getCompartmentEditPartA(), false); //even collapsible figure should not be collpased by default
65
		checkIsCollapsed(getCompartmentEditPartB(), false);
66
	}
67
	
68
	public void off_XXX_can_not_create_command_testCompartmentCollapsed(){
69
		CompartmentEditPart newCompartmentA = createNewCompartment(getSetup().getGenModel().getNodeA());
70
		checkIsCollapsed(newCompartmentA, false); 
71
		
72
		View collapsible = getNotation(newCompartmentA);
73
		DrawerStyle drawerStyle = (DrawerStyle) collapsible.getStyle(NOTATION.getDrawerStyle());
74
		assertNotNull(drawerStyle);
75
		assertFalse(drawerStyle.isCollapsed());
76
		
77
		CompartmentEditPart newCompartmentB = createNewCompartment(getSetup().getGenModel().getNodeB());
78
		checkIsCollapsed(newCompartmentB, false); //sic!
79
		View notCollapsible = getNotation(newCompartmentB);
80
		assertNull(notCollapsible.getStyle(NOTATION.getDrawerStyle()));
81
	}
82
83
	private void checkIsCollapsed(CompartmentEditPart editPart, boolean expected){
84
		checkCompartmentFigure(editPart);
85
		ResizableCompartmentFigure figure = (ResizableCompartmentFigure) editPart.getFigure();
86
		ScrollPane scrollPane = figure.getScrollPane();
87
		assertEquals(expected, scrollPane.getVerticalScrollBarVisibility() == ScrollPane.NEVER);
88
	}
89
	
90
	private void checkNoTitle(CompartmentEditPart editPart){
91
		checkCompartmentFigure(editPart);
92
		ResizableCompartmentFigure noTitle = (ResizableCompartmentFigure) editPart.getFigure();
93
		IFigure textPane = noTitle.getTextPane();
94
		assertTrue(
95
				!textPane.isVisible() || 
96
				textPane.getChildren().isEmpty() ||
97
				!((IFigure)textPane.getChildren().get(0)).isVisible());
98
	}
99
100
	private void checkHasTitle(CompartmentEditPart editPart){
101
		checkCompartmentFigure(editPart);
102
		ResizableCompartmentFigure withTitle = (ResizableCompartmentFigure) editPart.getFigure();
103
		IFigure textPane = withTitle.getTextPane();
104
		assertNotNull(textPane);
105
		assertTrue(textPane.isVisible());
106
		assertFalse(textPane.getChildren().isEmpty());
107
		IFigure label = (IFigure) textPane.getChildren().get(0);
108
		assertTrue(label instanceof WrapLabel);
109
		assertTrue(label.isVisible());
110
		String text = ((WrapLabel)label).getText();
111
		assertTrue(text != null && text.trim().length() > 0);
112
	}
113
114
	private void checkCompartmentFigure(CompartmentEditPart editPart) {
115
		assertTrue(editPart.getFigure() instanceof ResizableCompartmentFigure);
116
		ResizableCompartmentFigure figure = (ResizableCompartmentFigure) editPart.getFigure();
117
		IFigure textPane = figure.getTextPane();
118
		assertNotNull(textPane); //even if no labels
119
	}
120
121
	private CompartmentEditPart createNewCompartment(GenNode genTopLevelParent){
122
		GenCompartment genCompartment = getGenCompartment(genTopLevelParent);
123
		View notationParent = createNode(genTopLevelParent, getDiagram());
124
		assertNotNull(notationParent);
125
		View notationCompartment = findChildView(notationParent, genCompartment);
126
		assertNotNull(notationCompartment);
127
		
128
		CompartmentEditPart editPart = (CompartmentEditPart) findEditPart(notationCompartment);
129
		assertNotNull(editPart);
130
		return editPart;
131
	}
132
	
133
}
(-)src/org/eclipse/gmf/tests/gef/CompartmentTestBase.java (+128 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2006 Borland Software Corporation
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
 *    Michael Golubev (Borland) - initial API and implementation
11
 */
12
13
package org.eclipse.gmf.tests.gef;
14
15
import java.util.Iterator;
16
17
import org.eclipse.gef.EditPart;
18
import org.eclipse.gmf.codegen.gmfgen.GenCommonBase;
19
import org.eclipse.gmf.codegen.gmfgen.GenCompartment;
20
import org.eclipse.gmf.codegen.gmfgen.GenNode;
21
import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
22
import org.eclipse.gmf.runtime.notation.Node;
23
import org.eclipse.gmf.runtime.notation.NotationFactory;
24
import org.eclipse.gmf.runtime.notation.View;
25
import org.eclipse.gmf.tests.rt.GeneratedCanvasTest;
26
import org.eclipse.gmf.tests.setup.CompartmentsSessionSetup;
27
import org.eclipse.gmf.tests.setup.DiaGenSource;
28
import org.eclipse.gmf.tests.setup.RTSetup;
29
import org.eclipse.gmf.tests.setup.RTSource;
30
import org.eclipse.gmf.tests.setup.SessionSetup;
31
32
public abstract class CompartmentTestBase extends GeneratedCanvasTest {
33
	private EditPart myNodeEditPartA;
34
	private EditPart myNodeEditPartB;
35
36
	private CompartmentEditPart myCompartmentA;
37
	private CompartmentEditPart myCompartmentB;
38
	
39
	public CompartmentTestBase(String name) {
40
		super(name);
41
	}
42
43
	protected final EditPart getNodeEditPartA() {
44
		return myNodeEditPartA;
45
	}
46
	
47
	protected final EditPart getNodeEditPartB() {
48
		return myNodeEditPartB;
49
	}
50
	
51
	protected final CompartmentEditPart getCompartmentEditPartA(){
52
		return myCompartmentA;
53
	}
54
	
55
	protected final CompartmentEditPart getCompartmentEditPartB(){
56
		return myCompartmentB;
57
	}
58
	
59
	protected final GenCompartment getGenCompartment(GenNode genNode){
60
		return (GenCompartment)genNode.getCompartments().get(0);
61
	}
62
63
	// TODO EditPartViewer[Source|Setup]
64
	protected void setUp() throws Exception {
65
		super.setUp();
66
		myNodeEditPartA = findEditPart(getCompartmentsRTSetup().getNodeA());
67
		myNodeEditPartB = findEditPart(getCompartmentsRTSetup().getNodeB());
68
		myCompartmentA = (CompartmentEditPart)findEditPart(getCompartmentsRTSetup().getNotationCompartmentA());
69
		myCompartmentB = (CompartmentEditPart)findEditPart(getCompartmentsRTSetup().getNotationCompartmentB());
70
	}
71
	
72
	protected RTSource createCanvasInstance() throws Exception {
73
		return new CompartmentsRTSetup().init(getSetup().getGenProject().getBundle(), getSetup().getGenModel());
74
	}
75
	
76
	protected SessionSetup createDefaultSetup() {
77
		return CompartmentsSessionSetup.newInstance();
78
	}
79
80
	protected final Node getNotation(EditPart editPart) {
81
		return (Node) editPart.getModel();
82
	}
83
	
84
	protected class CompartmentsRTSetup extends RTSetup {
85
		private Node myNotationCompartmentA;
86
		private Node myNotationCompartmentB;
87
		
88
		protected void initDiagramFileContents(DomainInstanceProducer instanceProducer, DiaGenSource genSource) {
89
			super.initDiagramFileContents(instanceProducer, genSource);
90
			myNotationCompartmentA = setupNotationCompartment(getNodeA(), genSource.getNodeA());
91
			myNotationCompartmentB = setupNotationCompartment(getNodeB(), genSource.getNodeB());
92
		}
93
		
94
		private Node setupNotationCompartment(Node notationParent, GenNode genParent){
95
			Node notationCompartment = NotationFactory.eINSTANCE.createNode();
96
			GenCompartment genCompartment = (GenCompartment) genParent.getCompartments().get(0);
97
			notationCompartment.setType(String.valueOf(genCompartment.getVisualID()));
98
			notationParent.getTransientChildren().add(notationCompartment);
99
			assertTrue(notationParent.getChildren().contains(notationCompartment));
100
			return notationCompartment;
101
		}
102
		
103
		public Node getNotationCompartmentA() {
104
			return myNotationCompartmentA;
105
		}
106
		
107
		public Node getNotationCompartmentB() {
108
			return myNotationCompartmentB;
109
		}
110
		
111
	} 
112
	
113
	protected CompartmentsRTSetup getCompartmentsRTSetup(){
114
		return (CompartmentsRTSetup)getCanvasInstance();
115
	}
116
	
117
	protected static View findChildView(View parentView, GenCommonBase childType){
118
		String notationType = String.valueOf(childType.getVisualID());
119
		for (Iterator children = parentView.getChildren().iterator(); children.hasNext();){
120
			View next = (View) children.next();
121
			if (notationType.equals(next.getType())){
122
				return next;
123
			}
124
		}
125
		return null;
126
	}
127
	
128
}
(-)src-templates/org/eclipse/gmf/codegen/templates/providers/ViewFactoryGenerator.java (-101 / +173 lines)
Lines 34-90 Link Here
34
  protected final String TEXT_15 = NL + "\t\t\tsemanticHint = ";
34
  protected final String TEXT_15 = NL + "\t\t\tsemanticHint = ";
35
  protected final String TEXT_16 = ".getType(";
35
  protected final String TEXT_16 = ".getType(";
36
  protected final String TEXT_17 = ".VISUAL_ID);" + NL + "\t\t\tview.setType(semanticHint);" + NL + "\t\t}";
36
  protected final String TEXT_17 = ".VISUAL_ID);" + NL + "\t\t\tview.setType(semanticHint);" + NL + "\t\t}";
37
  protected final String TEXT_18 = NL + "\t\tsuper.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);" + NL + "\t\tif (!";
37
  protected final String TEXT_18 = NL + "\t\tsuper.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);";
38
  protected final String TEXT_19 = ".MODEL_ID.equals(";
38
  protected final String TEXT_19 = NL + "\t\tsetupCompartmentTitle(view);" + NL + "\t\tsetupCompartmentCollapsed(view);";
39
  protected final String TEXT_20 = ".getModelID(containerView))) {" + NL + "\t\t\t";
39
  protected final String TEXT_20 = "\t\t" + NL + "\t\tif (!";
40
  protected final String TEXT_21 = " shortcutAnnotation = ";
40
  protected final String TEXT_21 = ".MODEL_ID.equals(";
41
  protected final String TEXT_22 = ".eINSTANCE.createEAnnotation();" + NL + "\t\t\tshortcutAnnotation.setSource(\"Shortcut\"); //$NON-NLS-1$" + NL + "\t\t\tshortcutAnnotation.getDetails().put(\"modelID\", ";
41
  protected final String TEXT_22 = ".getModelID(containerView))) {" + NL + "\t\t\t";
42
  protected final String TEXT_23 = ".MODEL_ID); //$NON-NLS-1$" + NL + "\t\t\tview.getEAnnotations().add(shortcutAnnotation);" + NL + "\t\t}";
42
  protected final String TEXT_23 = " shortcutAnnotation = ";
43
  protected final String TEXT_24 = NL + "\t\t";
43
  protected final String TEXT_24 = ".eINSTANCE.createEAnnotation();" + NL + "\t\t\tshortcutAnnotation.setSource(\"Shortcut\"); //$NON-NLS-1$" + NL + "\t\t\tshortcutAnnotation.getDetails().put(\"modelID\", ";
44
  protected final String TEXT_25 = ".setStructuralFeatureValue(view, ";
44
  protected final String TEXT_25 = ".MODEL_ID); //$NON-NLS-1$" + NL + "\t\t\tview.getEAnnotations().add(shortcutAnnotation);" + NL + "\t\t}";
45
  protected final String TEXT_26 = ".eINSTANCE.getLineStyle_LineColor()," + NL + "\t\t\t";
45
  protected final String TEXT_26 = NL + "\t\t";
46
  protected final String TEXT_27 = ".colorToInteger(";
46
  protected final String TEXT_27 = ".setStructuralFeatureValue(view, ";
47
  protected final String TEXT_28 = ".";
47
  protected final String TEXT_28 = ".eINSTANCE.getLineStyle_LineColor()," + NL + "\t\t\t";
48
  protected final String TEXT_29 = "));";
48
  protected final String TEXT_29 = ".colorToInteger(";
49
  protected final String TEXT_30 = NL + "\t\t";
49
  protected final String TEXT_30 = ".";
50
  protected final String TEXT_31 = ".setStructuralFeatureValue(view, ";
50
  protected final String TEXT_31 = "));";
51
  protected final String TEXT_32 = ".eINSTANCE.getFillStyle_FillColor()," + NL + "\t\t\t";
51
  protected final String TEXT_32 = NL + "\t\t";
52
  protected final String TEXT_33 = ".colorToInteger(";
52
  protected final String TEXT_33 = ".setStructuralFeatureValue(view, ";
53
  protected final String TEXT_34 = ".";
53
  protected final String TEXT_34 = ".eINSTANCE.getFillStyle_FillColor()," + NL + "\t\t\t";
54
  protected final String TEXT_35 = "));";
54
  protected final String TEXT_35 = ".colorToInteger(";
55
  protected final String TEXT_36 = NL + "\t\tgetViewService().createNode(semanticAdapter, view, ";
55
  protected final String TEXT_36 = ".";
56
  protected final String TEXT_37 = ".getType(";
56
  protected final String TEXT_37 = "));";
57
  protected final String TEXT_38 = ".VISUAL_ID)," + NL + "\t\t\t";
57
  protected final String TEXT_38 = NL + "\t\tgetViewService().createNode(semanticAdapter, view, ";
58
  protected final String TEXT_39 = ".APPEND, true, getPreferencesHint());";
58
  protected final String TEXT_39 = ".getType(";
59
  protected final String TEXT_40 = NL + "\t\tgetViewService().createNode(semanticAdapter, view, ";
59
  protected final String TEXT_40 = ".VISUAL_ID)," + NL + "\t\t\t";
60
  protected final String TEXT_41 = ".getType(";
60
  protected final String TEXT_41 = ".APPEND, true, getPreferencesHint());";
61
  protected final String TEXT_42 = ".VISUAL_ID)," + NL + "\t\t\t";
61
  protected final String TEXT_42 = NL + "\t\tgetViewService().createNode(semanticAdapter, view, ";
62
  protected final String TEXT_43 = ".APPEND, true, getPreferencesHint());";
62
  protected final String TEXT_43 = ".getType(";
63
  protected final String TEXT_44 = NL + "\t\tgetViewService().createNode(semanticAdapter, view, ";
63
  protected final String TEXT_44 = ".VISUAL_ID)," + NL + "\t\t\t";
64
  protected final String TEXT_45 = ".getType(";
64
  protected final String TEXT_45 = ".APPEND, true, getPreferencesHint());";
65
  protected final String TEXT_46 = ".VISUAL_ID)," + NL + "\t\t\t";
65
  protected final String TEXT_46 = NL + "\t\tgetViewService().createNode(semanticAdapter, view, ";
66
  protected final String TEXT_47 = ".APPEND, true, getPreferencesHint());";
66
  protected final String TEXT_47 = ".getType(";
67
  protected final String TEXT_48 = NL + "\t}";
67
  protected final String TEXT_48 = ".VISUAL_ID)," + NL + "\t\t\t";
68
  protected final String TEXT_49 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
68
  protected final String TEXT_49 = ".APPEND, true, getPreferencesHint());";
69
  protected final String TEXT_50 = " createStyles(View view) {" + NL + "\t\t";
69
  protected final String TEXT_50 = NL + "\t}";
70
  protected final String TEXT_51 = " styles = super.createStyles(view);" + NL + "\t\tstyles.add(";
70
  protected final String TEXT_51 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
71
  protected final String TEXT_52 = ".eINSTANCE.createShapeStyle());" + NL + "\t\treturn styles;" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
71
  protected final String TEXT_52 = " createStyles(View view) {" + NL + "\t\t";
72
  protected final String TEXT_53 = " createLayoutConstraint() {" + NL + "\t\treturn ";
72
  protected final String TEXT_53 = " styles = super.createStyles(view);" + NL + "\t\tstyles.add(";
73
  protected final String TEXT_54 = ".eINSTANCE.createBounds();" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void initializeFromPreferences(View view) {" + NL + "\t\tsuper.initializeFromPreferences(view);" + NL + "" + NL + "\t\t";
73
  protected final String TEXT_54 = ".eINSTANCE.createShapeStyle());" + NL + "\t\treturn styles;" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
74
  protected final String TEXT_55 = " store = (";
74
  protected final String TEXT_55 = " createLayoutConstraint() {" + NL + "\t\treturn ";
75
  protected final String TEXT_56 = ") getPreferencesHint().getPreferenceStore();" + NL + "" + NL + "\t\t// fill color" + NL + "\t\t";
75
  protected final String TEXT_56 = ".eINSTANCE.createBounds();" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void initializeFromPreferences(View view) {" + NL + "\t\tsuper.initializeFromPreferences(view);" + NL + "" + NL + "\t\t";
76
  protected final String TEXT_57 = " fillRGB = ";
76
  protected final String TEXT_57 = " store = (";
77
  protected final String TEXT_58 = ".getColor(store, ";
77
  protected final String TEXT_58 = ") getPreferencesHint().getPreferenceStore();" + NL + "" + NL + "\t\t// fill color" + NL + "\t\t";
78
  protected final String TEXT_59 = ".PREF_FILL_COLOR);" + NL + "\t\t";
78
  protected final String TEXT_59 = " fillRGB = ";
79
  protected final String TEXT_60 = ".setStructuralFeatureValue(view, ";
79
  protected final String TEXT_60 = ".getColor(store, ";
80
  protected final String TEXT_61 = ".eINSTANCE.getFillStyle_FillColor(), ";
80
  protected final String TEXT_61 = ".PREF_FILL_COLOR);" + NL + "\t\t";
81
  protected final String TEXT_62 = ".RGBToInteger(fillRGB));" + NL + "\t}";
81
  protected final String TEXT_62 = ".setStructuralFeatureValue(view, ";
82
  protected final String TEXT_63 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
82
  protected final String TEXT_63 = ".eINSTANCE.getFillStyle_FillColor(), ";
83
  protected final String TEXT_64 = " getMeasurementUnit() {" + NL + "\t\treturn ";
83
  protected final String TEXT_64 = ".RGBToInteger(fillRGB));" + NL + "\t}";
84
  protected final String TEXT_65 = ".";
84
  protected final String TEXT_65 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
85
  protected final String TEXT_66 = "_LITERAL;" + NL + "\t}";
85
  protected final String TEXT_66 = " getMeasurementUnit() {" + NL + "\t\treturn ";
86
  protected final String TEXT_67 = NL + "}";
86
  protected final String TEXT_67 = ".";
87
  protected final String TEXT_68 = NL;
87
  protected final String TEXT_68 = "_LITERAL;" + NL + "\t}";
88
  protected final String TEXT_69 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setupCompartmentTitle(View view) {" + NL + "\t\t";
89
  protected final String TEXT_70 = " titleStyle = (";
90
  protected final String TEXT_71 = ")view.getStyle(";
91
  protected final String TEXT_72 = ".eINSTANCE.getTitleStyle());";
92
  protected final String TEXT_73 = "\t\t" + NL + "\t\tif (titleStyle == null){" + NL + "\t\t\ttitleStyle = (";
93
  protected final String TEXT_74 = ") view.createStyle(";
94
  protected final String TEXT_75 = ".eINSTANCE.getTitleStyle());" + NL + "\t\t}" + NL + "\t\ttitleStyle.setShowTitle(true);";
95
  protected final String TEXT_76 = NL + "\t\tif (titleStyle != null){" + NL + "\t\t\tview.getStyles().remove(titleStyle);" + NL + "\t\t}";
96
  protected final String TEXT_77 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setupCompartmentCollapsed(View view) {" + NL + "\t\t";
97
  protected final String TEXT_78 = " drawerStyle = (";
98
  protected final String TEXT_79 = ")view.getStyle(";
99
  protected final String TEXT_80 = ".eINSTANCE.getDrawerStyle());";
100
  protected final String TEXT_81 = "\t\t" + NL + "\t\tif (drawerStyle == null){" + NL + "\t\t\tdrawerStyle = (";
101
  protected final String TEXT_82 = ") view.createStyle(";
102
  protected final String TEXT_83 = ".eINSTANCE.getDrawerStyle());" + NL + "\t\t}" + NL + "\t\tdrawerStyle.setCollapsed(false);";
103
  protected final String TEXT_84 = NL + "\t\tif (drawerStyle != null){" + NL + "\t\t\tview.getStyles().remove(drawerStyle);" + NL + "\t\t}";
104
  protected final String TEXT_85 = NL + "\t}" + NL;
105
  protected final String TEXT_86 = NL + "}";
106
  protected final String TEXT_87 = NL;
88
107
89
  public String generate(Object argument)
108
  public String generate(Object argument)
90
  {
109
  {
Lines 158-231 Link Here
158
    stringBuffer.append(TEXT_17);
177
    stringBuffer.append(TEXT_17);
159
    /* [--] importmant for the create shortcut functionality*/
178
    /* [--] importmant for the create shortcut functionality*/
160
    stringBuffer.append(TEXT_18);
179
    stringBuffer.append(TEXT_18);
161
    stringBuffer.append(importManager.getImportedName(genDiagram.getEditPartQualifiedClassName()));
180
    
181
if (isCompartment){
182
162
    stringBuffer.append(TEXT_19);
183
    stringBuffer.append(TEXT_19);
163
    stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
184
    
185
}
186
164
    stringBuffer.append(TEXT_20);
187
    stringBuffer.append(TEXT_20);
165
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.EAnnotation"));
188
    stringBuffer.append(importManager.getImportedName(genDiagram.getEditPartQualifiedClassName()));
166
    stringBuffer.append(TEXT_21);
189
    stringBuffer.append(TEXT_21);
167
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.EcoreFactory"));
190
    stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
168
    stringBuffer.append(TEXT_22);
191
    stringBuffer.append(TEXT_22);
169
    stringBuffer.append(importManager.getImportedName(genDiagram.getEditPartQualifiedClassName()));
192
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.EAnnotation"));
170
    stringBuffer.append(TEXT_23);
193
    stringBuffer.append(TEXT_23);
194
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.EcoreFactory"));
195
    stringBuffer.append(TEXT_24);
196
    stringBuffer.append(importManager.getImportedName(genDiagram.getEditPartQualifiedClassName()));
197
    stringBuffer.append(TEXT_25);
171
    
198
    
172
}
199
}
173
200
174
ColorAttributes colorAttrs = genElement.getViewmap() != null ? (ColorAttributes) genElement.getViewmap().find(ColorAttributes.class) : null;
201
ColorAttributes colorAttrs = genElement.getViewmap() != null ? (ColorAttributes) genElement.getViewmap().find(ColorAttributes.class) : null;
175
if (colorAttrs != null && colorAttrs.getForegroundColor() != null && colorAttrs.getForegroundColor().trim().length() > 0) {
202
if (colorAttrs != null && colorAttrs.getForegroundColor() != null && colorAttrs.getForegroundColor().trim().length() > 0) {
176
    stringBuffer.append(TEXT_24);
203
    stringBuffer.append(TEXT_26);
177
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil"));
204
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil"));
178
    stringBuffer.append(TEXT_25);
205
    stringBuffer.append(TEXT_27);
179
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
206
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
180
    stringBuffer.append(TEXT_26);
207
    stringBuffer.append(TEXT_28);
181
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities"));
208
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities"));
182
    stringBuffer.append(TEXT_27);
209
    stringBuffer.append(TEXT_29);
183
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.ColorConstants"));
210
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.ColorConstants"));
184
    stringBuffer.append(TEXT_28);
211
    stringBuffer.append(TEXT_30);
185
    stringBuffer.append(colorAttrs.getForegroundColor());
212
    stringBuffer.append(colorAttrs.getForegroundColor());
186
    stringBuffer.append(TEXT_29);
213
    stringBuffer.append(TEXT_31);
187
    
214
    
188
}
215
}
189
if (isNode) {
216
if (isNode) {
190
	GenNode genNode = (GenNode) genElement;
217
	GenNode genNode = (GenNode) genElement;
191
	if (colorAttrs != null && colorAttrs.getBackgroundColor() != null && colorAttrs.getBackgroundColor().trim().length() > 0) {
218
	if (colorAttrs != null && colorAttrs.getBackgroundColor() != null && colorAttrs.getBackgroundColor().trim().length() > 0) {
192
    stringBuffer.append(TEXT_30);
219
    stringBuffer.append(TEXT_32);
193
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil"));
220
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil"));
194
    stringBuffer.append(TEXT_31);
221
    stringBuffer.append(TEXT_33);
195
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
222
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
196
    stringBuffer.append(TEXT_32);
223
    stringBuffer.append(TEXT_34);
197
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities"));
224
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities"));
198
    stringBuffer.append(TEXT_33);
225
    stringBuffer.append(TEXT_35);
199
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.ColorConstants"));
226
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.ColorConstants"));
200
    stringBuffer.append(TEXT_34);
227
    stringBuffer.append(TEXT_36);
201
    stringBuffer.append(colorAttrs.getBackgroundColor());
228
    stringBuffer.append(colorAttrs.getBackgroundColor());
202
    stringBuffer.append(TEXT_35);
229
    stringBuffer.append(TEXT_37);
203
    
230
    
204
	}	
231
	}	
205
	List labels = genNode.getLabels();
232
	List labels = genNode.getLabels();
206
	for (int j = 0; j < labels.size(); j++) {
233
	for (int j = 0; j < labels.size(); j++) {
207
		GenNodeLabel label = (GenNodeLabel) labels.get(j);
234
		GenNodeLabel label = (GenNodeLabel) labels.get(j);
208
235
209
    stringBuffer.append(TEXT_36);
236
    stringBuffer.append(TEXT_38);
210
    stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
237
    stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
211
    stringBuffer.append(TEXT_37);
238
    stringBuffer.append(TEXT_39);
212
    stringBuffer.append(importManager.getImportedName(label.getEditPartQualifiedClassName()));
239
    stringBuffer.append(importManager.getImportedName(label.getEditPartQualifiedClassName()));
213
    stringBuffer.append(TEXT_38);
240
    stringBuffer.append(TEXT_40);
214
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil"));
241
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil"));
215
    stringBuffer.append(TEXT_39);
242
    stringBuffer.append(TEXT_41);
216
    
243
    
217
	}
244
	}
218
	List genChildContainers = genNode.getCompartments();
245
	List genChildContainers = genNode.getCompartments();
219
	for (int j = 0; j < genChildContainers.size(); j++) {
246
	for (int j = 0; j < genChildContainers.size(); j++) {
220
		GenCompartment genChildContainer = (GenCompartment) genChildContainers.get(j);
247
		GenCompartment genChildContainer = (GenCompartment) genChildContainers.get(j);
221
248
222
    stringBuffer.append(TEXT_40);
249
    stringBuffer.append(TEXT_42);
223
    stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
250
    stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
224
    stringBuffer.append(TEXT_41);
251
    stringBuffer.append(TEXT_43);
225
    stringBuffer.append(importManager.getImportedName(genChildContainer.getEditPartQualifiedClassName()));
252
    stringBuffer.append(importManager.getImportedName(genChildContainer.getEditPartQualifiedClassName()));
226
    stringBuffer.append(TEXT_42);
253
    stringBuffer.append(TEXT_44);
227
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil"));
254
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil"));
228
    stringBuffer.append(TEXT_43);
255
    stringBuffer.append(TEXT_45);
229
    
256
    
230
	}
257
	}
231
} else if (isLink) {
258
} else if (isLink) {
Lines 234-292 Link Here
234
	for (int j = 0; j < labels.size(); j++) {
261
	for (int j = 0; j < labels.size(); j++) {
235
		GenLinkLabel label = (GenLinkLabel) labels.get(j);
262
		GenLinkLabel label = (GenLinkLabel) labels.get(j);
236
263
237
    stringBuffer.append(TEXT_44);
264
    stringBuffer.append(TEXT_46);
238
    stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
265
    stringBuffer.append(importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName()));
239
    stringBuffer.append(TEXT_45);
266
    stringBuffer.append(TEXT_47);
240
    stringBuffer.append(importManager.getImportedName(label.getEditPartQualifiedClassName()));
267
    stringBuffer.append(importManager.getImportedName(label.getEditPartQualifiedClassName()));
241
    stringBuffer.append(TEXT_46);
268
    stringBuffer.append(TEXT_48);
242
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil"));
269
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil"));
243
    stringBuffer.append(TEXT_47);
270
    stringBuffer.append(TEXT_49);
244
    
271
    
245
	}
272
	}
246
}
273
}
247
274
248
    stringBuffer.append(TEXT_48);
249
    if (isCompartmentWithOwnBounds) {
250
    stringBuffer.append(TEXT_49);
251
    stringBuffer.append(importManager.getImportedName("java.util.List"));
252
    stringBuffer.append(TEXT_50);
275
    stringBuffer.append(TEXT_50);
253
    stringBuffer.append(importManager.getImportedName("java.util.List"));
276
    if (isCompartmentWithOwnBounds) {
254
    stringBuffer.append(TEXT_51);
277
    stringBuffer.append(TEXT_51);
255
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationFactory"));
278
    stringBuffer.append(importManager.getImportedName("java.util.List"));
256
    stringBuffer.append(TEXT_52);
279
    stringBuffer.append(TEXT_52);
257
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.LayoutConstraint"));
280
    stringBuffer.append(importManager.getImportedName("java.util.List"));
258
    stringBuffer.append(TEXT_53);
281
    stringBuffer.append(TEXT_53);
259
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationFactory"));
282
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationFactory"));
260
    stringBuffer.append(TEXT_54);
283
    stringBuffer.append(TEXT_54);
261
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.preference.IPreferenceStore"));
284
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.LayoutConstraint"));
262
    stringBuffer.append(TEXT_55);
285
    stringBuffer.append(TEXT_55);
263
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.preference.IPreferenceStore"));
286
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationFactory"));
264
    stringBuffer.append(TEXT_56);
287
    stringBuffer.append(TEXT_56);
265
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.graphics.RGB"));
288
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.preference.IPreferenceStore"));
266
    stringBuffer.append(TEXT_57);
289
    stringBuffer.append(TEXT_57);
267
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.preference.PreferenceConverter"));
290
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.preference.IPreferenceStore"));
268
    stringBuffer.append(TEXT_58);
291
    stringBuffer.append(TEXT_58);
269
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants"));
292
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.graphics.RGB"));
270
    stringBuffer.append(TEXT_59);
293
    stringBuffer.append(TEXT_59);
271
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil"));
294
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.preference.PreferenceConverter"));
272
    stringBuffer.append(TEXT_60);
295
    stringBuffer.append(TEXT_60);
273
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
296
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants"));
274
    stringBuffer.append(TEXT_61);
297
    stringBuffer.append(TEXT_61);
275
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities"));
298
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.util.ViewUtil"));
276
    stringBuffer.append(TEXT_62);
299
    stringBuffer.append(TEXT_62);
300
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
301
    stringBuffer.append(TEXT_63);
302
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities"));
303
    stringBuffer.append(TEXT_64);
277
    }
304
    }
278
    if (isDiagram && genDiagram.getUnits() != null && genDiagram.getUnits().trim().length() > 0) {
305
    if (isDiagram && genDiagram.getUnits() != null && genDiagram.getUnits().trim().length() > 0) {
279
    stringBuffer.append(TEXT_63);
306
    stringBuffer.append(TEXT_65);
280
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.MeasurementUnit"));
307
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.MeasurementUnit"));
281
    stringBuffer.append(TEXT_64);
308
    stringBuffer.append(TEXT_66);
282
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.MeasurementUnit"));
309
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.MeasurementUnit"));
283
    stringBuffer.append(TEXT_65);
310
    stringBuffer.append(TEXT_67);
284
    stringBuffer.append(genDiagram.getUnits().toUpperCase());
311
    stringBuffer.append(genDiagram.getUnits().toUpperCase());
285
    stringBuffer.append(TEXT_66);
312
    stringBuffer.append(TEXT_68);
286
    }
313
    }
287
    stringBuffer.append(TEXT_67);
314
    
315
if (isCompartment) {
316
	String titleStyleFQN = importManager.getImportedName("org.eclipse.gmf.runtime.notation.TitleStyle");
317
	String drawerStyleFQN = importManager.getImportedName("org.eclipse.gmf.runtime.notation.DrawerStyle");	
318
	String notationPackageFQN = importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage");
319
	GenCompartment genCompartment = (GenCompartment)genElement;
320
321
    stringBuffer.append(TEXT_69);
322
    stringBuffer.append(titleStyleFQN);
323
    stringBuffer.append(TEXT_70);
324
    stringBuffer.append(titleStyleFQN);
325
    stringBuffer.append(TEXT_71);
326
    stringBuffer.append(notationPackageFQN);
327
    stringBuffer.append(TEXT_72);
328
    
329
if(genCompartment.isNeedsTitle()){
330
331
    stringBuffer.append(TEXT_73);
332
    stringBuffer.append(titleStyleFQN);
333
    stringBuffer.append(TEXT_74);
334
    stringBuffer.append(notationPackageFQN);
335
    stringBuffer.append(TEXT_75);
336
    } else {
337
    stringBuffer.append(TEXT_76);
338
    }
339
    stringBuffer.append(TEXT_77);
340
    stringBuffer.append(drawerStyleFQN);
341
    stringBuffer.append(TEXT_78);
342
    stringBuffer.append(drawerStyleFQN);
343
    stringBuffer.append(TEXT_79);
344
    stringBuffer.append(notationPackageFQN);
345
    stringBuffer.append(TEXT_80);
346
    
347
if(genCompartment.isCanCollapse()){
348
349
    stringBuffer.append(TEXT_81);
350
    stringBuffer.append(drawerStyleFQN);
351
    stringBuffer.append(TEXT_82);
352
    stringBuffer.append(notationPackageFQN);
353
    stringBuffer.append(TEXT_83);
354
    } else {
355
    stringBuffer.append(TEXT_84);
356
    }
357
    stringBuffer.append(TEXT_85);
358
    }
359
    stringBuffer.append(TEXT_86);
288
    importManager.emitSortedImports();
360
    importManager.emitSortedImports();
289
    stringBuffer.append(TEXT_68);
361
    stringBuffer.append(TEXT_87);
290
    return stringBuffer.toString();
362
    return stringBuffer.toString();
291
  }
363
  }
292
}
364
}
(-)templates/parts/CompartmentEditPart.javajet (-1 / +15 lines)
Lines 43-51 Link Here
43
	/**
43
	/**
44
	 * @generated
44
	 * @generated
45
	 */
45
	 */
46
	protected String getTitleName() {
46
	public String getCompartmentName() {
47
		return "<%=genCompartment.getTitle()%>";
47
		return "<%=genCompartment.getTitle()%>";
48
	}
48
	}
49
<%if (!genCompartment.isNeedsTitle()) {
50
	//by default titles are shown even if there are no TitleStyle
51
	//we need to switch it off
52
%>
53
54
	/**
55
	 * @generated
56
	 */
57
	public <%=importManager.getImportedName("org.eclipse.draw2d.IFigure")%> createFigure() {
58
		<%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure")%> result = (<%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure")%>)super.createFigure();
59
		result.setTitleVisibility(false);
60
		return result;
61
	}
62
<%}%>
49
63
50
	/**
64
	/**
51
	 * @generated
65
	 * @generated
(-)templates/providers/ViewFactory.javajet (+54 lines)
Lines 61-66 Link Here
61
			view.setType(semanticHint);
61
			view.setType(semanticHint);
62
		}<%/* [--] importmant for the create shortcut functionality*/%>
62
		}<%/* [--] importmant for the create shortcut functionality*/%>
63
		super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
63
		super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
64
<%
65
if (isCompartment){
66
%>
67
		setupCompartmentTitle(view);
68
		setupCompartmentCollapsed(view);
69
<%
70
}
71
%>		
64
		if (!<%=importManager.getImportedName(genDiagram.getEditPartQualifiedClassName())%>.MODEL_ID.equals(<%=importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())%>.getModelID(containerView))) {
72
		if (!<%=importManager.getImportedName(genDiagram.getEditPartQualifiedClassName())%>.MODEL_ID.equals(<%=importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())%>.getModelID(containerView))) {
65
			<%=importManager.getImportedName("org.eclipse.emf.ecore.EAnnotation")%> shortcutAnnotation = <%=importManager.getImportedName("org.eclipse.emf.ecore.EcoreFactory")%>.eINSTANCE.createEAnnotation();
73
			<%=importManager.getImportedName("org.eclipse.emf.ecore.EAnnotation")%> shortcutAnnotation = <%=importManager.getImportedName("org.eclipse.emf.ecore.EcoreFactory")%>.eINSTANCE.createEAnnotation();
66
			shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$
74
			shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$
Lines 151-155 Link Here
151
		return <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.MeasurementUnit")%>.<%=genDiagram.getUnits().toUpperCase()%>_LITERAL;
159
		return <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.MeasurementUnit")%>.<%=genDiagram.getUnits().toUpperCase()%>_LITERAL;
152
	}
160
	}
153
<%}%>
161
<%}%>
162
<%
163
if (isCompartment) {
164
	String titleStyleFQN = importManager.getImportedName("org.eclipse.gmf.runtime.notation.TitleStyle");
165
	String drawerStyleFQN = importManager.getImportedName("org.eclipse.gmf.runtime.notation.DrawerStyle");	
166
	String notationPackageFQN = importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage");
167
	GenCompartment genCompartment = (GenCompartment)genElement;
168
%>
169
	/**
170
	 * @generated
171
	 */
172
	protected void setupCompartmentTitle(View view) {
173
		<%=titleStyleFQN%> titleStyle = (<%=titleStyleFQN%>)view.getStyle(<%=notationPackageFQN%>.eINSTANCE.getTitleStyle());
174
<%
175
if(genCompartment.isNeedsTitle()){
176
%>		
177
		if (titleStyle == null){
178
			titleStyle = (<%=titleStyleFQN%>) view.createStyle(<%=notationPackageFQN%>.eINSTANCE.getTitleStyle());
179
		}
180
		titleStyle.setShowTitle(true);
181
<%} else {%>
182
		if (titleStyle != null){
183
			view.getStyles().remove(titleStyle);
184
		}
185
<%}%>
186
	}
187
188
	/**
189
	 * @generated
190
	 */
191
	protected void setupCompartmentCollapsed(View view) {
192
		<%=drawerStyleFQN%> drawerStyle = (<%=drawerStyleFQN%>)view.getStyle(<%=notationPackageFQN%>.eINSTANCE.getDrawerStyle());
193
<%
194
if(genCompartment.isCanCollapse()){
195
%>		
196
		if (drawerStyle == null){
197
			drawerStyle = (<%=drawerStyleFQN%>) view.createStyle(<%=notationPackageFQN%>.eINSTANCE.getDrawerStyle());
198
		}
199
		drawerStyle.setCollapsed(false);
200
<%} else {%>
201
		if (drawerStyle != null){
202
			view.getStyles().remove(drawerStyle);
203
		}
204
<%}%>
205
	}
206
207
<%}%>
154
}
208
}
155
<%importManager.emitSortedImports();%>
209
<%importManager.emitSortedImports();%>
(-)src-templates/org/eclipse/gmf/codegen/templates/parts/CompartmentEditPartGenerator.java (-62 / +80 lines)
Lines 31-69 Link Here
31
  protected final String TEXT_12 = "(View view) {" + NL + "\t\tsuper(view);" + NL + "\t}";
31
  protected final String TEXT_12 = "(View view) {" + NL + "\t\tsuper(view);" + NL + "\t}";
32
  protected final String TEXT_13 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected boolean hasModelChildrenChanged(";
32
  protected final String TEXT_13 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected boolean hasModelChildrenChanged(";
33
  protected final String TEXT_14 = " evt) {" + NL + "\t\treturn false;" + NL + "\t}";
33
  protected final String TEXT_14 = " evt) {" + NL + "\t\treturn false;" + NL + "\t}";
34
  protected final String TEXT_15 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected String getTitleName() {" + NL + "\t\treturn \"";
34
  protected final String TEXT_15 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic String getCompartmentName() {" + NL + "\t\treturn \"";
35
  protected final String TEXT_16 = "\";" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void createDefaultEditPolicies() {" + NL + "\t\tsuper.createDefaultEditPolicies();" + NL + "\t\tinstallEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ";
35
  protected final String TEXT_16 = "\";" + NL + "\t}";
36
  protected final String TEXT_17 = "());";
36
  protected final String TEXT_17 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
37
  protected final String TEXT_18 = NL + "\t\tinstallEditPolicy(EditPolicyRoles.CREATION_ROLE, new ";
37
  protected final String TEXT_18 = " createFigure() {" + NL + "\t\t";
38
  protected final String TEXT_19 = "());" + NL + "\t\tinstallEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ";
38
  protected final String TEXT_19 = " result = (";
39
  protected final String TEXT_20 = "());" + NL + "\t\tinstallEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new ";
39
  protected final String TEXT_20 = ")super.createFigure();" + NL + "\t\tresult.setTitleVisibility(false);" + NL + "\t\treturn result;" + NL + "\t}";
40
  protected final String TEXT_21 = "());";
40
  protected final String TEXT_21 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void createDefaultEditPolicies() {" + NL + "\t\tsuper.createDefaultEditPolicies();" + NL + "\t\tinstallEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ";
41
  protected final String TEXT_22 = NL + "\t}";
41
  protected final String TEXT_22 = "());";
42
  protected final String TEXT_23 = "\t" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\t//public ";
42
  protected final String TEXT_23 = NL + "\t\tinstallEditPolicy(EditPolicyRoles.CREATION_ROLE, new ";
43
  protected final String TEXT_24 = " createFigure() {" + NL + "\t//\t";
43
  protected final String TEXT_24 = "());" + NL + "\t\tinstallEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ";
44
  protected final String TEXT_25 = " result = super.createFigure();" + NL + "\t//\tresult.setBorder(new ";
44
  protected final String TEXT_25 = "());" + NL + "\t\tinstallEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new ";
45
  protected final String TEXT_26 = "());" + NL + "\t//\treturn result;" + NL + "\t//}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void refreshVisuals() {" + NL + "\t\tsuper.refreshVisuals();" + NL + "\t\trefreshBounds();" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void handleNotificationEvent(";
45
  protected final String TEXT_26 = "());";
46
  protected final String TEXT_27 = " notification) {" + NL + "\t\tsuper.handleNotificationEvent(notification);" + NL + "\t\tObject feature = notification.getFeature();" + NL + "\t\tif (";
46
  protected final String TEXT_27 = NL + "\t}";
47
  protected final String TEXT_28 = ".eINSTANCE.getSize_Width().equals(feature)" + NL + "\t\t\t|| ";
47
  protected final String TEXT_28 = "\t" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\t//public ";
48
  protected final String TEXT_29 = ".eINSTANCE.getSize_Height().equals(feature)" + NL + "\t\t\t|| ";
48
  protected final String TEXT_29 = " createFigure() {" + NL + "\t//\t";
49
  protected final String TEXT_30 = ".eINSTANCE.getLocation_X().equals(feature)" + NL + "\t\t\t|| ";
49
  protected final String TEXT_30 = " result = super.createFigure();" + NL + "\t//\tresult.setBorder(new ";
50
  protected final String TEXT_31 = ".eINSTANCE.getLocation_Y().equals(feature)) {" + NL + "\t\t\trefreshBounds();" + NL + "\t\t} " + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void refreshBounds() {" + NL + "\t\tint width = ((Integer) getStructuralFeatureValue(";
50
  protected final String TEXT_31 = "());" + NL + "\t//\treturn result;" + NL + "\t//}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void refreshVisuals() {" + NL + "\t\tsuper.refreshVisuals();" + NL + "\t\trefreshBounds();" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void handleNotificationEvent(";
51
  protected final String TEXT_32 = ".eINSTANCE.getSize_Width())).intValue();" + NL + "\t\tint height = ((Integer) getStructuralFeatureValue(";
51
  protected final String TEXT_32 = " notification) {" + NL + "\t\tsuper.handleNotificationEvent(notification);" + NL + "\t\tObject feature = notification.getFeature();" + NL + "\t\tif (";
52
  protected final String TEXT_33 = ".eINSTANCE.getSize_Height())).intValue();" + NL + "\t\t";
52
  protected final String TEXT_33 = ".eINSTANCE.getSize_Width().equals(feature)" + NL + "\t\t\t|| ";
53
  protected final String TEXT_34 = " size = new ";
53
  protected final String TEXT_34 = ".eINSTANCE.getSize_Height().equals(feature)" + NL + "\t\t\t|| ";
54
  protected final String TEXT_35 = "(width, height);" + NL + "\t\tint x = ((Integer) getStructuralFeatureValue(";
54
  protected final String TEXT_35 = ".eINSTANCE.getLocation_X().equals(feature)" + NL + "\t\t\t|| ";
55
  protected final String TEXT_36 = ".eINSTANCE.getLocation_X())).intValue();" + NL + "\t\tint y = ((Integer) getStructuralFeatureValue(";
55
  protected final String TEXT_36 = ".eINSTANCE.getLocation_Y().equals(feature)) {" + NL + "\t\t\trefreshBounds();" + NL + "\t\t} " + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void refreshBounds() {" + NL + "\t\tint width = ((Integer) getStructuralFeatureValue(";
56
  protected final String TEXT_37 = ".eINSTANCE.getLocation_Y())).intValue();" + NL + "\t\t";
56
  protected final String TEXT_37 = ".eINSTANCE.getSize_Width())).intValue();" + NL + "\t\tint height = ((Integer) getStructuralFeatureValue(";
57
  protected final String TEXT_38 = " loc = new ";
57
  protected final String TEXT_38 = ".eINSTANCE.getSize_Height())).intValue();" + NL + "\t\t";
58
  protected final String TEXT_39 = "(x, y);" + NL + "\t\t((";
58
  protected final String TEXT_39 = " size = new ";
59
  protected final String TEXT_40 = ") getParent()).setLayoutConstraint(this, getFigure(), new ";
59
  protected final String TEXT_40 = "(width, height);" + NL + "\t\tint x = ((Integer) getStructuralFeatureValue(";
60
  protected final String TEXT_41 = "(loc, size));" + NL + "\t}";
60
  protected final String TEXT_41 = ".eINSTANCE.getLocation_X())).intValue();" + NL + "\t\tint y = ((Integer) getStructuralFeatureValue(";
61
  protected final String TEXT_42 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setRatio(Double ratio) {";
61
  protected final String TEXT_42 = ".eINSTANCE.getLocation_Y())).intValue();" + NL + "\t\t";
62
  protected final String TEXT_43 = NL + "\t\tif (getFigure().getParent().getLayoutManager() instanceof ";
62
  protected final String TEXT_43 = " loc = new ";
63
  protected final String TEXT_44 = ") {" + NL + "\t\t\tsuper.setRatio(ratio);" + NL + "\t\t}";
63
  protected final String TEXT_44 = "(x, y);" + NL + "\t\t((";
64
  protected final String TEXT_45 = NL + "\t\t// nothing to do -- parent layout does not accept Double constraints as ratio" + NL + "\t\t// super.setRatio(ratio); ";
64
  protected final String TEXT_45 = ") getParent()).setLayoutConstraint(this, getFigure(), new ";
65
  protected final String TEXT_46 = NL + "\t}" + NL + "}";
65
  protected final String TEXT_46 = "(loc, size));" + NL + "\t}";
66
  protected final String TEXT_47 = NL;
66
  protected final String TEXT_47 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setRatio(Double ratio) {";
67
  protected final String TEXT_48 = NL + "\t\tif (getFigure().getParent().getLayoutManager() instanceof ";
68
  protected final String TEXT_49 = ") {" + NL + "\t\t\tsuper.setRatio(ratio);" + NL + "\t\t}";
69
  protected final String TEXT_50 = NL + "\t\t// nothing to do -- parent layout does not accept Double constraints as ratio" + NL + "\t\t// super.setRatio(ratio); ";
70
  protected final String TEXT_51 = NL + "\t}" + NL + "}";
71
  protected final String TEXT_52 = NL;
67
72
68
	protected final String getFeatureValueGetter(String containerName, GenFeature feature, boolean isContainerEObject, ImportAssistant importManager) {
73
	protected final String getFeatureValueGetter(String containerName, GenFeature feature, boolean isContainerEObject, ImportAssistant importManager) {
69
		StringBuffer result = new StringBuffer();
74
		StringBuffer result = new StringBuffer();
Lines 206-282 Link Here
206
    stringBuffer.append(TEXT_15);
211
    stringBuffer.append(TEXT_15);
207
    stringBuffer.append(genCompartment.getTitle());
212
    stringBuffer.append(genCompartment.getTitle());
208
    stringBuffer.append(TEXT_16);
213
    stringBuffer.append(TEXT_16);
209
    stringBuffer.append(importManager.getImportedName(genCompartment.getItemSemanticEditPolicyQualifiedClassName()));
214
    if (!genCompartment.isNeedsTitle()) {
215
	//by default titles are shown even if there are no TitleStyle
216
	//we need to switch it off
217
210
    stringBuffer.append(TEXT_17);
218
    stringBuffer.append(TEXT_17);
211
    if (!genCompartment.getChildNodes().isEmpty()) {
219
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.IFigure"));
212
    stringBuffer.append(TEXT_18);
220
    stringBuffer.append(TEXT_18);
213
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy"));
221
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure"));
214
    stringBuffer.append(TEXT_19);
222
    stringBuffer.append(TEXT_19);
215
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy"));
223
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure"));
216
    stringBuffer.append(TEXT_20);
224
    stringBuffer.append(TEXT_20);
217
    stringBuffer.append(importManager.getImportedName(genCompartment.getCanonicalEditPolicyQualifiedClassName()));
218
    stringBuffer.append(TEXT_21);
219
    }
225
    }
226
    stringBuffer.append(TEXT_21);
227
    stringBuffer.append(importManager.getImportedName(genCompartment.getItemSemanticEditPolicyQualifiedClassName()));
220
    stringBuffer.append(TEXT_22);
228
    stringBuffer.append(TEXT_22);
221
    
229
    if (!genCompartment.getChildNodes().isEmpty()) {
222
if (ViewmapLayoutTypeHelper.getSharedInstance().isStoringChildPositions(genCompartment.getNode().getLayoutType())) {
223
    stringBuffer.append(TEXT_23);
230
    stringBuffer.append(TEXT_23);
224
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.IFigure"));
231
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy"));
225
    stringBuffer.append(TEXT_24);
232
    stringBuffer.append(TEXT_24);
226
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.IFigure"));
233
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy"));
227
    stringBuffer.append(TEXT_25);
234
    stringBuffer.append(TEXT_25);
228
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.LineBorder"));
235
    stringBuffer.append(importManager.getImportedName(genCompartment.getCanonicalEditPolicyQualifiedClassName()));
229
    stringBuffer.append(TEXT_26);
236
    stringBuffer.append(TEXT_26);
230
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.common.notify.Notification"));
237
    }
231
    stringBuffer.append(TEXT_27);
238
    stringBuffer.append(TEXT_27);
232
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
239
    
240
if (ViewmapLayoutTypeHelper.getSharedInstance().isStoringChildPositions(genCompartment.getNode().getLayoutType())) {
233
    stringBuffer.append(TEXT_28);
241
    stringBuffer.append(TEXT_28);
234
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
242
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.IFigure"));
235
    stringBuffer.append(TEXT_29);
243
    stringBuffer.append(TEXT_29);
236
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
244
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.IFigure"));
237
    stringBuffer.append(TEXT_30);
245
    stringBuffer.append(TEXT_30);
238
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
246
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.LineBorder"));
239
    stringBuffer.append(TEXT_31);
247
    stringBuffer.append(TEXT_31);
240
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
248
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.common.notify.Notification"));
241
    stringBuffer.append(TEXT_32);
249
    stringBuffer.append(TEXT_32);
242
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
250
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
243
    stringBuffer.append(TEXT_33);
251
    stringBuffer.append(TEXT_33);
244
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension"));
252
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
245
    stringBuffer.append(TEXT_34);
253
    stringBuffer.append(TEXT_34);
246
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension"));
254
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
247
    stringBuffer.append(TEXT_35);
255
    stringBuffer.append(TEXT_35);
248
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
256
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
249
    stringBuffer.append(TEXT_36);
257
    stringBuffer.append(TEXT_36);
250
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
258
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
251
    stringBuffer.append(TEXT_37);
259
    stringBuffer.append(TEXT_37);
252
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Point"));
260
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
253
    stringBuffer.append(TEXT_38);
261
    stringBuffer.append(TEXT_38);
254
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Point"));
262
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension"));
255
    stringBuffer.append(TEXT_39);
263
    stringBuffer.append(TEXT_39);
256
    stringBuffer.append(importManager.getImportedName("org.eclipse.gef.GraphicalEditPart"));
264
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension"));
257
    stringBuffer.append(TEXT_40);
265
    stringBuffer.append(TEXT_40);
258
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Rectangle"));
266
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
259
    stringBuffer.append(TEXT_41);
267
    stringBuffer.append(TEXT_41);
268
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"));
269
    stringBuffer.append(TEXT_42);
270
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Point"));
271
    stringBuffer.append(TEXT_43);
272
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Point"));
273
    stringBuffer.append(TEXT_44);
274
    stringBuffer.append(importManager.getImportedName("org.eclipse.gef.GraphicalEditPart"));
275
    stringBuffer.append(TEXT_45);
276
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Rectangle"));
277
    stringBuffer.append(TEXT_46);
260
    
278
    
261
} // helper.isStoring
279
} // helper.isStoring
262
280
263
    stringBuffer.append(TEXT_42);
281
    stringBuffer.append(TEXT_47);
264
    
282
    
265
if (ViewmapLayoutType.UNKNOWN_LITERAL.equals(genCompartment.getNode().getLayoutType())) {
283
if (ViewmapLayoutType.UNKNOWN_LITERAL.equals(genCompartment.getNode().getLayoutType())) {
266
284
267
    stringBuffer.append(TEXT_43);
285
    stringBuffer.append(TEXT_48);
268
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout"));
286
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout"));
269
    stringBuffer.append(TEXT_44);
287
    stringBuffer.append(TEXT_49);
270
    
288
    
271
} else {
289
} else {
272
290
273
    stringBuffer.append(TEXT_45);
291
    stringBuffer.append(TEXT_50);
274
    
292
    
275
}
293
}
276
294
277
    stringBuffer.append(TEXT_46);
295
    stringBuffer.append(TEXT_51);
278
    importManager.emitSortedImports();
296
    importManager.emitSortedImports();
279
    stringBuffer.append(TEXT_47);
297
    stringBuffer.append(TEXT_52);
280
    return stringBuffer.toString();
298
    return stringBuffer.toString();
281
  }
299
  }
282
}
300
}

Return to bug 143934