422
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 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 |
* bblajer (Borland) - initial API and implementation
|
|
11 |
*/
|
|
12 |
|
|
13 |
«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
|
|
14 |
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
|
|
15 |
«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
|
|
16 |
|
|
17 |
«DEFINE CompartmentEditPart FOR gmfgen::GenCompartment-»
|
|
18 |
«EXPAND xpt::Common::copyright FOR getDiagram().editorGen»
|
|
19 |
package «getDiagram().editPartsPackageName»;
|
|
20 |
|
|
21 |
«EXPAND xpt::Common::generatedClassComment»
|
|
22 |
public class «editPartClassName» «EXPAND supertypes» {
|
|
23 |
«EXPAND xpt::diagram::parts::Common::visualIDConstant-»
|
|
24 |
|
|
25 |
«EXPAND xpt::diagram::parts::Common::ctors-»
|
|
26 |
«EXPAND xpt::diagram::parts::Common::notSelectable-»
|
|
27 |
«EXPAND getModelChildren-»
|
|
28 |
«EXPAND xpt::diagram::parts::Common::declareViewCode-»
|
|
29 |
«EXPAND createEditPolicies-»
|
|
30 |
|
|
31 |
«EXPAND createSelectionHandles-»
|
|
32 |
«EXPAND xpt::diagram::parts::requests::performRequest-»
|
|
33 |
«EXPAND getTitleName-»
|
|
34 |
«EXPAND createFigure-»
|
|
35 |
«EXPAND xpt::diagram::parts::Common::getAdapter-»
|
|
36 |
«EXPAND xpt::diagram::parts::Common::contentPane-»
|
|
37 |
«EXPAND setupCompartmentHolder-»
|
|
38 |
«EXPAND xpt::diagram::parts::Common::activate-»
|
|
39 |
«EXPAND xpt::diagram::parts::Common::deactivate-»
|
|
40 |
«EXPAND xpt::diagram::parts::Common::getTransactionalUpdateManager-»
|
|
41 |
«EXPAND xpt::diagram::parts::NotationModelRefresher::all-»
|
|
42 |
«EXPAND xpt::diagram::parts::refresh::refresher-»
|
|
43 |
«EXPAND additions-»
|
|
44 |
}
|
|
45 |
«ENDDEFINE»
|
|
46 |
|
|
47 |
«DEFINE supertypes FOR gmfgen::GenCompartment»extends org.eclipse.gef.editparts.AbstractGraphicalEditPart implements org.eclipse.gmf.runtime.lite.edit.parts.update.IUpdatableEditPart«ENDDEFINE»
|
|
48 |
|
|
49 |
«DEFINE getModelChildren FOR gmfgen::GenCompartment-»
|
|
50 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
51 |
protected java.util.List getModelChildren() {
|
|
52 |
org.eclipse.gmf.runtime.notation.DrawerStyle style = (org.eclipse.gmf.runtime.notation.DrawerStyle) «EXPAND xpt::diagram::parts::Common::getViewCode».getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getDrawerStyle());
|
|
53 |
if (style != null && style.isCollapsed()) {
|
|
54 |
return java.util.Collections.EMPTY_LIST;
|
|
55 |
}
|
|
56 |
return «EXPAND xpt::diagram::parts::Common::getViewCode».getVisibleChildren();
|
|
57 |
}
|
|
58 |
«ENDDEFINE»
|
|
59 |
|
|
60 |
«DEFINE createEditPolicies FOR gmfgen::GenCompartment-»
|
|
61 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
62 |
protected void createEditPolicies() {
|
|
63 |
installEditPolicy(org.eclipse.gef.EditPolicy.LAYOUT_ROLE, new «EXPAND xpt::diagram::policies::LayoutEditPolicy::qualifiedClassName»());
|
|
64 |
«EXPAND xpt::diagram::parts::Common::behaviour-»
|
|
65 |
«EXPAND xpt::diagram::parts::NotationModelRefresher::installClause-»
|
|
66 |
}
|
|
67 |
«ENDDEFINE»
|
|
68 |
|
|
69 |
«DEFINE createSelectionHandles FOR gmfgen::GenCompartment-»
|
|
70 |
«EXPAND xpt::Common::generatedMemberComment("Returns the selection handles that should be contributed to the parent when it becomes selected.")»
|
|
71 |
public java.util.List createSelectionHandles() {
|
|
72 |
«IF canCollapse-»
|
|
73 |
return java.util.Collections.singletonList(new org.eclipse.gmf.runtime.lite.handles.CompartmentCollapseHandle(this, getTitleName()));
|
|
74 |
«ELSE-»
|
|
75 |
return java.util.Collections.singletonList(new org.eclipse.gmf.runtime.lite.handles.CompartmentNameHandle(this, getTitleName()));
|
|
76 |
«ENDIF-»
|
|
77 |
}
|
|
78 |
«ENDDEFINE»
|
|
79 |
|
|
80 |
«DEFINE getTitleName FOR gmfgen::GenCompartment-»
|
|
81 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
82 |
protected String getTitleName() {
|
|
83 |
«IF needsTitle-»
|
|
84 |
return "«title»"; «EXPAND xpt::Common::nonNLS»
|
|
85 |
«ELSE-»
|
|
86 |
return ""; «EXPAND xpt::Common::nonNLS»
|
|
87 |
«ENDIF-»
|
|
88 |
}
|
|
89 |
«ENDDEFINE»
|
|
90 |
|
|
91 |
«DEFINE createFigure FOR gmfgen::GenCompartment-»
|
|
92 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
93 |
public org.eclipse.draw2d.IFigure createFigure() {
|
|
94 |
org.eclipse.draw2d.Figure result = new org.eclipse.gmf.runtime.lite.figures.CompartmentFigure();
|
|
95 |
result.setLayoutManager(new org.eclipse.draw2d.StackLayout());
|
|
96 |
org.eclipse.draw2d.ScrollPane scrollPane = new org.eclipse.draw2d.ScrollPane();
|
|
97 |
result.add(scrollPane);
|
|
98 |
«IF listLayout-»
|
|
99 |
org.eclipse.draw2d.Viewport viewport = new org.eclipse.draw2d.Viewport();
|
|
100 |
contentPane = new org.eclipse.draw2d.Figure();
|
|
101 |
contentPane.setLayoutManager(new org.eclipse.draw2d.ToolbarLayout());
|
|
102 |
«ELSE-»
|
|
103 |
org.eclipse.draw2d.Viewport viewport = new org.eclipse.draw2d.FreeformViewport();
|
|
104 |
contentPane = new org.eclipse.draw2d.FreeformLayer();
|
|
105 |
contentPane.setLayoutManager(new org.eclipse.draw2d.FreeformLayout());
|
|
106 |
«ENDIF-»
|
|
107 |
viewport.setContents(contentPane);
|
|
108 |
scrollPane.setViewport(viewport);
|
|
109 |
return result;
|
|
110 |
}
|
|
111 |
«ENDDEFINE»
|
|
112 |
|
|
113 |
«DEFINE setupCompartmentHolder FOR gmfgen::GenCompartment-»
|
|
114 |
«EXPAND setupCompartmentHolder FOR viewmap-»
|
|
115 |
«ENDDEFINE»
|
|
116 |
|
|
117 |
«DEFINE setupCompartmentHolder FOR gmfgen::Viewmap»«ENDDEFINE»
|
|
118 |
|
|
119 |
«DEFINE setupCompartmentHolder FOR gmfgen::ParentAssignedViewmap-»
|
|
120 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
121 |
public void setupCompartmentHolder(org.eclipse.draw2d.IFigure shape) {
|
|
122 |
if (shape.getLayoutManager() == null) {
|
|
123 |
shape.setLayoutManager(new org.eclipse.draw2d.StackLayout());
|
|
124 |
}
|
|
125 |
}
|
|
126 |
«ENDDEFINE»
|
|
127 |
|
|
128 |
«DEFINE additions FOR gmfgen::GenCompartment-»
|
|
129 |
«ENDDEFINE»
|