1 | /* |
2 | * Copyright 2007, SDQ, IPD, Uni Karlsruhe (TH) |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.composite.part; |
5 | |
6 | import java.util.ArrayList; |
7 | import java.util.List; |
8 | |
9 | import org.eclipse.gef.Tool; |
10 | import org.eclipse.gef.palette.PaletteContainer; |
11 | import org.eclipse.gef.palette.PaletteDrawer; |
12 | import org.eclipse.gef.palette.PaletteRoot; |
13 | import org.eclipse.gef.palette.ToolEntry; |
14 | import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool; |
15 | import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool; |
16 | |
17 | import de.uka.ipd.sdq.pcm.gmf.composite.providers.PalladioComponentModelElementTypes; |
18 | |
19 | /** |
20 | * @generated |
21 | */ |
22 | public class PalladioComponentModelPaletteFactory { |
23 | |
24 | /** |
25 | * @generated |
26 | */ |
27 | public void fillPalette(PaletteRoot paletteRoot) { |
28 | paletteRoot.add(createNodes1Group()); |
29 | paletteRoot.add(createLinks2Group()); |
30 | } |
31 | |
32 | /** |
33 | * Creates "Nodes" palette tool group |
34 | * @generated |
35 | */ |
36 | private PaletteContainer createNodes1Group() { |
37 | PaletteDrawer paletteContainer = new PaletteDrawer( |
38 | Messages.Nodes1Group_title); |
39 | paletteContainer.setId("createNodes1Group"); //$NON-NLS-1$ |
40 | paletteContainer.add(createAssemblyContext1CreationTool()); |
41 | paletteContainer.add(createSystemOperationRequiredRole2CreationTool()); |
42 | paletteContainer.add(createSystemOperationProvidedRole3CreationTool()); |
43 | return paletteContainer; |
44 | } |
45 | |
46 | /** |
47 | * Creates "Links" palette tool group |
48 | * @generated |
49 | */ |
50 | private PaletteContainer createLinks2Group() { |
51 | PaletteDrawer paletteContainer = new PaletteDrawer( |
52 | Messages.Links2Group_title); |
53 | paletteContainer.setId("createLinks2Group"); //$NON-NLS-1$ |
54 | paletteContainer |
55 | .add(createOperationRequiredDelegationConnector1CreationTool()); |
56 | paletteContainer.add(createAssemblyConnector2CreationTool()); |
57 | paletteContainer |
58 | .add(createAssemblyInfrastructureConnector3CreationTool()); |
59 | paletteContainer.add(createAssemblyEventConnector4CreationTool()); |
60 | paletteContainer |
61 | .add(createOperationProvidedDelegationConnector5CreationTool()); |
62 | return paletteContainer; |
63 | } |
64 | |
65 | /** |
66 | * @generated |
67 | */ |
68 | private ToolEntry createAssemblyContext1CreationTool() { |
69 | List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1); |
70 | types.add(PalladioComponentModelElementTypes.AssemblyContext_3006); |
71 | NodeToolEntry entry = new NodeToolEntry( |
72 | Messages.AssemblyContext1CreationTool_title, |
73 | Messages.AssemblyContext1CreationTool_desc, types); |
74 | entry.setId("createAssemblyContext1CreationTool"); //$NON-NLS-1$ |
75 | entry |
76 | .setSmallIcon(PalladioComponentModelElementTypes |
77 | .getImageDescriptor(PalladioComponentModelElementTypes.AssemblyContext_3006)); |
78 | entry.setLargeIcon(entry.getSmallIcon()); |
79 | return entry; |
80 | } |
81 | |
82 | /** |
83 | * @generated |
84 | */ |
85 | private ToolEntry createSystemOperationRequiredRole2CreationTool() { |
86 | List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1); |
87 | types |
88 | .add(PalladioComponentModelElementTypes.OperationRequiredRole_3012); |
89 | NodeToolEntry entry = new NodeToolEntry( |
90 | Messages.SystemOperationRequiredRole2CreationTool_title, |
91 | Messages.SystemOperationRequiredRole2CreationTool_desc, types); |
92 | entry.setId("createSystemOperationRequiredRole2CreationTool"); //$NON-NLS-1$ |
93 | entry |
94 | .setSmallIcon(PalladioComponentModelElementTypes |
95 | .getImageDescriptor(PalladioComponentModelElementTypes.OperationRequiredRole_3012)); |
96 | entry.setLargeIcon(entry.getSmallIcon()); |
97 | return entry; |
98 | } |
99 | |
100 | /** |
101 | * @generated |
102 | */ |
103 | private ToolEntry createSystemOperationProvidedRole3CreationTool() { |
104 | List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1); |
105 | types |
106 | .add(PalladioComponentModelElementTypes.OperationProvidedRole_3011); |
107 | NodeToolEntry entry = new NodeToolEntry( |
108 | Messages.SystemOperationProvidedRole3CreationTool_title, |
109 | Messages.SystemOperationProvidedRole3CreationTool_desc, types); |
110 | entry.setId("createSystemOperationProvidedRole3CreationTool"); //$NON-NLS-1$ |
111 | entry |
112 | .setSmallIcon(PalladioComponentModelElementTypes |
113 | .getImageDescriptor(PalladioComponentModelElementTypes.OperationProvidedRole_3011)); |
114 | entry.setLargeIcon(entry.getSmallIcon()); |
115 | return entry; |
116 | } |
117 | |
118 | /** |
119 | * @generated |
120 | */ |
121 | private ToolEntry createOperationRequiredDelegationConnector1CreationTool() { |
122 | List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1); |
123 | types |
124 | .add(PalladioComponentModelElementTypes.RequiredDelegationConnector_4005); |
125 | LinkToolEntry entry = new LinkToolEntry( |
126 | Messages.OperationRequiredDelegationConnector1CreationTool_title, |
127 | Messages.OperationRequiredDelegationConnector1CreationTool_desc, |
128 | types); |
129 | entry.setId("createOperationRequiredDelegationConnector1CreationTool"); //$NON-NLS-1$ |
130 | entry |
131 | .setSmallIcon(PalladioComponentModelElementTypes |
132 | .getImageDescriptor(PalladioComponentModelElementTypes.RequiredDelegationConnector_4005)); |
133 | entry.setLargeIcon(entry.getSmallIcon()); |
134 | return entry; |
135 | } |
136 | |
137 | /** |
138 | * @generated |
139 | */ |
140 | private ToolEntry createAssemblyConnector2CreationTool() { |
141 | List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1); |
142 | types.add(PalladioComponentModelElementTypes.AssemblyConnector_4004); |
143 | LinkToolEntry entry = new LinkToolEntry( |
144 | Messages.AssemblyConnector2CreationTool_title, |
145 | Messages.AssemblyConnector2CreationTool_desc, types); |
146 | entry.setId("createAssemblyConnector2CreationTool"); //$NON-NLS-1$ |
147 | entry |
148 | .setSmallIcon(PalladioComponentModelElementTypes |
149 | .getImageDescriptor(PalladioComponentModelElementTypes.AssemblyConnector_4004)); |
150 | entry.setLargeIcon(entry.getSmallIcon()); |
151 | return entry; |
152 | } |
153 | |
154 | /** |
155 | * @generated |
156 | */ |
157 | private ToolEntry createAssemblyInfrastructureConnector3CreationTool() { |
158 | List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1); |
159 | types |
160 | .add(PalladioComponentModelElementTypes.AssemblyInfrastructureConnector_4008); |
161 | LinkToolEntry entry = new LinkToolEntry( |
162 | Messages.AssemblyInfrastructureConnector3CreationTool_title, |
163 | Messages.AssemblyInfrastructureConnector3CreationTool_desc, |
164 | types); |
165 | entry.setId("createAssemblyInfrastructureConnector3CreationTool"); //$NON-NLS-1$ |
166 | entry |
167 | .setSmallIcon(PalladioComponentModelElementTypes |
168 | .getImageDescriptor(PalladioComponentModelElementTypes.AssemblyInfrastructureConnector_4008)); |
169 | entry.setLargeIcon(entry.getSmallIcon()); |
170 | return entry; |
171 | } |
172 | |
173 | /** |
174 | * @generated |
175 | */ |
176 | private ToolEntry createAssemblyEventConnector4CreationTool() { |
177 | List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1); |
178 | types |
179 | .add(PalladioComponentModelElementTypes.AssemblyEventConnector_4007); |
180 | LinkToolEntry entry = new LinkToolEntry( |
181 | Messages.AssemblyEventConnector4CreationTool_title, |
182 | Messages.AssemblyEventConnector4CreationTool_desc, types); |
183 | entry.setId("createAssemblyEventConnector4CreationTool"); //$NON-NLS-1$ |
184 | entry |
185 | .setSmallIcon(PalladioComponentModelElementTypes |
186 | .getImageDescriptor(PalladioComponentModelElementTypes.AssemblyEventConnector_4007)); |
187 | entry.setLargeIcon(entry.getSmallIcon()); |
188 | return entry; |
189 | } |
190 | |
191 | /** |
192 | * @generated |
193 | */ |
194 | private ToolEntry createOperationProvidedDelegationConnector5CreationTool() { |
195 | List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1); |
196 | types |
197 | .add(PalladioComponentModelElementTypes.ProvidedDelegationConnector_4006); |
198 | LinkToolEntry entry = new LinkToolEntry( |
199 | Messages.OperationProvidedDelegationConnector5CreationTool_title, |
200 | Messages.OperationProvidedDelegationConnector5CreationTool_desc, |
201 | types); |
202 | entry.setId("createOperationProvidedDelegationConnector5CreationTool"); //$NON-NLS-1$ |
203 | entry |
204 | .setSmallIcon(PalladioComponentModelElementTypes |
205 | .getImageDescriptor(PalladioComponentModelElementTypes.ProvidedDelegationConnector_4006)); |
206 | entry.setLargeIcon(entry.getSmallIcon()); |
207 | return entry; |
208 | } |
209 | |
210 | /** |
211 | * @generated |
212 | */ |
213 | private static class NodeToolEntry extends ToolEntry { |
214 | |
215 | /** |
216 | * @generated |
217 | */ |
218 | private final List elementTypes; |
219 | |
220 | /** |
221 | * @generated |
222 | */ |
223 | private NodeToolEntry(String title, String description, |
224 | List elementTypes) { |
225 | super(title, description, null, null); |
226 | this.elementTypes = elementTypes; |
227 | } |
228 | |
229 | /** |
230 | * @generated |
231 | */ |
232 | public Tool createTool() { |
233 | Tool tool = new UnspecifiedTypeCreationTool(elementTypes); |
234 | tool.setProperties(getToolProperties()); |
235 | return tool; |
236 | } |
237 | } |
238 | |
239 | /** |
240 | * @generated |
241 | */ |
242 | private static class LinkToolEntry extends ToolEntry { |
243 | |
244 | /** |
245 | * @generated |
246 | */ |
247 | private final List relationshipTypes; |
248 | |
249 | /** |
250 | * @generated |
251 | */ |
252 | private LinkToolEntry(String title, String description, |
253 | List relationshipTypes) { |
254 | super(title, description, null, null); |
255 | this.relationshipTypes = relationshipTypes; |
256 | } |
257 | |
258 | /** |
259 | * @generated |
260 | */ |
261 | public Tool createTool() { |
262 | Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes); |
263 | tool.setProperties(getToolProperties()); |
264 | return tool; |
265 | } |
266 | } |
267 | } |