Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1f45d22a2afb1b3600cb4ce0f67ac7460f40613c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 * Copyright (c) 2006, 2010 Borland Software Corporation and others
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Dmitry Stadnik (Borland) - initial API and implementation
 */
«REM»DOCUMENTATION: PapyrusGencode«ENDREM»
«REM»change to manage the figure of the comment«ENDREM»
«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»

«DEFINE EditPartFactory FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
package «editPartsPackageName»;

«EXPAND xpt::Common::generatedClassComment»
public class «editPartFactoryClassName» implements org.eclipse.gef.EditPartFactory {

	«EXPAND createEditPartMethod-»
	
	«EXPAND createUnrecognizedEditPart-»
	
	«EXPAND getTextCellEditorLocator-»
	
	«EXPAND additions-»
}
«ENDDEFINE»

«DEFINE createEditPartMethod FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
	public org.eclipse.gef.EditPart createEditPart(org.eclipse.gef.EditPart context, Object model) {
		if (model instanceof org.eclipse.gmf.runtime.notation.View) {
			org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) model;
			switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(view)) {
				«EXPAND createEditPart FOR self-»
				«FOREACH getAllNodes()->asSequence() AS node-»
					«EXPAND createEditPart FOR node-»
					«EXPAND createEditPart FOREACH node.labels-»
				«ENDFOREACH-»
				«EXPAND createEditPart FOREACH compartments-»
				«FOREACH links->asSequence() AS link-»
					«EXPAND createEditPart FOR link-»
					«EXPAND createEditPart FOREACH link.labels»
				«ENDFOREACH-»
			}
		}
		return createUnrecognizedEditPart(context, model);
	}
«ENDDEFINE»

«DEFINE createEditPart FOR gmfgen::GenCommonBase»
	«EXPAND xpt::Common::caseVisualID»
		return new «getEditPartQualifiedClassName()»(view);
«ENDDEFINE»

«DEFINE createUnrecognizedEditPart FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
	 private org.eclipse.gef.EditPart createUnrecognizedEditPart(org.eclipse.gef.EditPart context, Object model) {
	 	// Handle creation of unrecognized child node EditParts here
	 	return null;
	 }
«ENDDEFINE»

«DEFINE getTextCellEditorLocator FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
	public static org.eclipse.gef.tools.CellEditorLocator getTextCellEditorLocator(
			org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart source) {
         if (source.getFigure() instanceof org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure){
			return new MultilineCellEditorLocator(
					(org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure) source.getFigure());
    	}
        else {
           return org.eclipse.gmf.tooling.runtime.directedit.locator.CellEditorLocatorAccess.INSTANCE.getTextCellEditorLocator(source);

        }
    }
    
    
    «EXPAND xpt::Common::generatedClassComment»
    static private class MultilineCellEditorLocator implements org.eclipse.gef.tools.CellEditorLocator {

		«EXPAND xpt::Common::generatedClassComment»
		private org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure multilineEditableFigure;

		«EXPAND xpt::Common::generatedClassComment»
		public MultilineCellEditorLocator(org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure figure) {
			this.multilineEditableFigure = figure;
		}

		«EXPAND xpt::Common::generatedClassComment»
		public org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure getMultilineEditableFigure() {
			return multilineEditableFigure;
		}

		«EXPAND xpt::Common::generatedClassComment»
		public void relocate(org.eclipse.jface.viewers.CellEditor celleditor) {
			org.eclipse.swt.widgets.Text text = (org.eclipse.swt.widgets.Text) celleditor.getControl();
			org.eclipse.draw2d.geometry.Rectangle rect = getMultilineEditableFigure().getBounds().getCopy();
			rect.x=getMultilineEditableFigure().getEditionLocation().x;
			rect.y=getMultilineEditableFigure().getEditionLocation().y;
			getMultilineEditableFigure().translateToAbsolute(rect);
			if (getMultilineEditableFigure().getText().length() > 0) {
				rect.setSize(new org.eclipse.draw2d.geometry.Dimension(text.computeSize(rect.width,
						SWT.DEFAULT)));
			}
			if (!rect.equals(new org.eclipse.draw2d.geometry.Rectangle(text.getBounds()))) {
				text.setBounds(rect.x, rect.y, rect.width, rect.height);
			}
		}
	}
«ENDDEFINE»

«DEFINE additions FOR gmfgen::GenDiagram-»
«ENDDEFINE»

Back to the top