001: package newprocess.diagram.edit.parts;
002:
003: import newprocess.diagram.part.New_processVisualIDRegistry;
004:
005: import org.eclipse.draw2d.FigureUtilities;
006: import org.eclipse.draw2d.Label;
007: import org.eclipse.draw2d.geometry.Dimension;
008: import org.eclipse.draw2d.geometry.Rectangle;
009: import org.eclipse.gef.EditPart;
010: import org.eclipse.gef.EditPartFactory;
011: import org.eclipse.gef.tools.CellEditorLocator;
012: import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
013: import org.eclipse.gmf.runtime.draw2d.ui.figures.WrapLabel;
014: import org.eclipse.gmf.runtime.notation.View;
015: import org.eclipse.jface.viewers.CellEditor;
016: import org.eclipse.swt.widgets.Text;
017:
018: /**
019: * @generated
020: */
021: public class New_processEditPartFactory implements EditPartFactory {
022:
023: /**
024: * @generated
025: */
026: public EditPart createEditPart(EditPart context, Object model) {
027: if (model instanceof View) {
028: View view = (View) model;
029: switch (New_processVisualIDRegistry.getVisualID(view)) {
030:
031: case ProcessEditPart.VISUAL_ID:
032: return new ProcessEditPart(view);
033:
034: case SyncActivityEditPart.VISUAL_ID:
035: return new SyncActivityEditPart(view);
036:
037: case SyncActivityNameEditPart.VISUAL_ID:
038: return new SyncActivityNameEditPart(view);
039:
040: case ListenerEditPart.VISUAL_ID:
041: return new ListenerEditPart(view);
042:
043: case ListenerNameEditPart.VISUAL_ID:
044: return new ListenerNameEditPart(view);
045:
046: case AsyncActivityEditPart.VISUAL_ID:
047: return new AsyncActivityEditPart(view);
048:
049: case AsyncActivityNameEditPart.VISUAL_ID:
050: return new AsyncActivityNameEditPart(view);
051:
052: case EventEditPart.VISUAL_ID:
053: return new EventEditPart(view);
054:
055: case EventNameEditPart.VISUAL_ID:
056: return new EventNameEditPart(view);
057:
058: case ConditionProxyEditPart.VISUAL_ID:
059: return new ConditionProxyEditPart(view);
060:
061: case ConditionProxyProxyNameEditPart.VISUAL_ID:
062: return new ConditionProxyProxyNameEditPart(view);
063:
064: case ActorEditPart.VISUAL_ID:
065: return new ActorEditPart(view);
066:
067: case ActorNameEditPart.VISUAL_ID:
068: return new ActorNameEditPart(view);
069:
070: case MessageEditPart.VISUAL_ID:
071: return new MessageEditPart(view);
072:
073: case MessageNameEditPart.VISUAL_ID:
074: return new MessageNameEditPart(view);
075:
076: case ExpansionEditPart.VISUAL_ID:
077: return new ExpansionEditPart(view);
078:
079: case ExpansionNameEditPart.VISUAL_ID:
080: return new ExpansionNameEditPart(view);
081:
082: case ConclusionEditPart.VISUAL_ID:
083: return new ConclusionEditPart(view);
084:
085: case ConclusionNameEditPart.VISUAL_ID:
086: return new ConclusionNameEditPart(view);
087:
088: case GlobalsEditPart.VISUAL_ID:
089: return new GlobalsEditPart(view);
090:
091: case ExpressionEditPart.VISUAL_ID:
092: return new ExpressionEditPart(view);
093:
094: case RootEditPart.VISUAL_ID:
095: return new RootEditPart(view);
096:
097: case OrOperatorEditPart.VISUAL_ID:
098: return new OrOperatorEditPart(view);
099:
100: case AndOperatorEditPart.VISUAL_ID:
101: return new AndOperatorEditPart(view);
102:
103: case ConditionTermEditPart.VISUAL_ID:
104: return new ConditionTermEditPart(view);
105:
106: case Expression2EditPart.VISUAL_ID:
107: return new Expression2EditPart(view);
108:
109: case Expression3EditPart.VISUAL_ID:
110: return new Expression3EditPart(view);
111:
112: case Expression4EditPart.VISUAL_ID:
113: return new Expression4EditPart(view);
114:
115: case Expression5EditPart.VISUAL_ID:
116: return new Expression5EditPart(view);
117:
118: case Expression6EditPart.VISUAL_ID:
119: return new Expression6EditPart(view);
120:
121: case Expression7EditPart.VISUAL_ID:
122: return new Expression7EditPart(view);
123:
124: case Expression8EditPart.VISUAL_ID:
125: return new Expression8EditPart(view);
126:
127: case LoaderEditPart.VISUAL_ID:
128: return new LoaderEditPart(view);
129:
130: case LoaderNameEditPart.VISUAL_ID:
131: return new LoaderNameEditPart(view);
132:
133: case ConditionEditPart.VISUAL_ID:
134: return new ConditionEditPart(view);
135:
136: case ConditionNameEditPart.VISUAL_ID:
137: return new ConditionNameEditPart(view);
138:
139: case SyncActivitySynActivityPreconditionCompartmentEditPart.VISUAL_ID:
140: return new SyncActivitySynActivityPreconditionCompartmentEditPart(
141: view);
142:
143: case SyncActivitySynActivityPostconditionCompartmentEditPart.VISUAL_ID:
144: return new SyncActivitySynActivityPostconditionCompartmentEditPart(
145: view);
146:
147: case ExpressionExpressionCompartmentEditPart.VISUAL_ID:
148: return new ExpressionExpressionCompartmentEditPart(view);
149:
150: case ExpressionExpressionCompartment2EditPart.VISUAL_ID:
151: return new ExpressionExpressionCompartment2EditPart(
152: view);
153:
154: case ListenerListenerPreconditionCompartmentEditPart.VISUAL_ID:
155: return new ListenerListenerPreconditionCompartmentEditPart(
156: view);
157:
158: case ExpressionExpressionCompartment3EditPart.VISUAL_ID:
159: return new ExpressionExpressionCompartment3EditPart(
160: view);
161:
162: case AsyncActivityAsyncActivityPreconditionCompartmentEditPart.VISUAL_ID:
163: return new AsyncActivityAsyncActivityPreconditionCompartmentEditPart(
164: view);
165:
166: case AsyncActivityAsyncActivityPostconditionCompartmentEditPart.VISUAL_ID:
167: return new AsyncActivityAsyncActivityPostconditionCompartmentEditPart(
168: view);
169:
170: case ExpressionExpressionCompartment4EditPart.VISUAL_ID:
171: return new ExpressionExpressionCompartment4EditPart(
172: view);
173:
174: case ExpressionExpressionCompartment5EditPart.VISUAL_ID:
175: return new ExpressionExpressionCompartment5EditPart(
176: view);
177:
178: case EventEventPostconditionCompartmentEditPart.VISUAL_ID:
179: return new EventEventPostconditionCompartmentEditPart(
180: view);
181:
182: case ExpressionExpressionCompartment6EditPart.VISUAL_ID:
183: return new ExpressionExpressionCompartment6EditPart(
184: view);
185:
186: case ExpansionExpansionPostconditionCompartmentEditPart.VISUAL_ID:
187: return new ExpansionExpansionPostconditionCompartmentEditPart(
188: view);
189:
190: case ExpressionExpressionCompartment7EditPart.VISUAL_ID:
191: return new ExpressionExpressionCompartment7EditPart(
192: view);
193:
194: case ConclusionConclusionPostconditionCompartmentEditPart.VISUAL_ID:
195: return new ConclusionConclusionPostconditionCompartmentEditPart(
196: view);
197:
198: case ExpressionExpressionCompartment8EditPart.VISUAL_ID:
199: return new ExpressionExpressionCompartment8EditPart(
200: view);
201:
202: case GlobalsGlobalsLoaderCompartmentEditPart.VISUAL_ID:
203: return new GlobalsGlobalsLoaderCompartmentEditPart(view);
204:
205: case GlobalsGlobalsConditionCompartmentEditPart.VISUAL_ID:
206: return new GlobalsGlobalsConditionCompartmentEditPart(
207: view);
208:
209: case AsyncActivityActorEditPart.VISUAL_ID:
210: return new AsyncActivityActorEditPart(view);
211:
212: case RootTermEditPart.VISUAL_ID:
213: return new RootTermEditPart(view);
214:
215: case OperatorTermSubTermEditPart.VISUAL_ID:
216: return new OperatorTermSubTermEditPart(view);
217:
218: case ConditionTermConditionProxyEditPart.VISUAL_ID:
219: return new ConditionTermConditionProxyEditPart(view);
220:
221: case ConclusionConclusionProxyEditPart.VISUAL_ID:
222: return new ConclusionConclusionProxyEditPart(view);
223:
224: case ExpansionExpansionProxyEditPart.VISUAL_ID:
225: return new ExpansionExpansionProxyEditPart(view);
226: }
227: }
228: return createUnrecognizedEditPart(context, model);
229: }
230:
231: /**
232: * @generated
233: */
234: private EditPart createUnrecognizedEditPart(EditPart context,
235: Object model) {
236: // Handle creation of unrecognized child node EditParts here
237: return null;
238: }
239:
240: /**
241: * @generated
242: */
243: public static CellEditorLocator getTextCellEditorLocator(
244: ITextAwareEditPart source) {
245: if (source.getFigure() instanceof WrapLabel)
246: return new TextCellEditorLocator((WrapLabel) source
247: .getFigure());
248: else {
249: return new LabelCellEditorLocator((Label) source
250: .getFigure());
251: }
252: }
253:
254: /**
255: * @generated
256: */
257: static private class TextCellEditorLocator implements
258: CellEditorLocator {
259:
260: /**
261: * @generated
262: */
263: private WrapLabel wrapLabel;
264:
265: /**
266: * @generated
267: */
268: public TextCellEditorLocator(WrapLabel wrapLabel) {
269: this .wrapLabel = wrapLabel;
270: }
271:
272: /**
273: * @generated
274: */
275: public WrapLabel getWrapLabel() {
276: return wrapLabel;
277: }
278:
279: /**
280: * @generated
281: */
282: public void relocate(CellEditor celleditor) {
283: Text text = (Text) celleditor.getControl();
284: Rectangle rect = getWrapLabel().getTextBounds().getCopy();
285: getWrapLabel().translateToAbsolute(rect);
286: if (getWrapLabel().isTextWrapped()
287: && getWrapLabel().getText().length() > 0) {
288: rect.setSize(new Dimension(text.computeSize(rect.width,
289: org.eclipse.swt.SWT.DEFAULT)));
290: } else {
291: int avr = FigureUtilities
292: .getFontMetrics(text.getFont())
293: .getAverageCharWidth();
294: rect.setSize(new Dimension(text.computeSize(
295: org.eclipse.swt.SWT.DEFAULT,
296: org.eclipse.swt.SWT.DEFAULT))
297: .expand(avr * 2, 0));
298: }
299: if (!rect.equals(new Rectangle(text.getBounds()))) {
300: text.setBounds(rect.x, rect.y, rect.width, rect.height);
301: }
302: }
303:
304: }
305:
306: /**
307: * @generated
308: */
309: private static class LabelCellEditorLocator implements
310: CellEditorLocator {
311:
312: /**
313: * @generated
314: */
315: private Label label;
316:
317: /**
318: * @generated
319: */
320: public LabelCellEditorLocator(Label label) {
321: this .label = label;
322: }
323:
324: /**
325: * @generated
326: */
327: public Label getLabel() {
328: return label;
329: }
330:
331: /**
332: * @generated
333: */
334: public void relocate(CellEditor celleditor) {
335: Text text = (Text) celleditor.getControl();
336: Rectangle rect = getLabel().getTextBounds().getCopy();
337: getLabel().translateToAbsolute(rect);
338: int avr = FigureUtilities.getFontMetrics(text.getFont())
339: .getAverageCharWidth();
340: rect.setSize(new Dimension(text.computeSize(
341: org.eclipse.swt.SWT.DEFAULT,
342: org.eclipse.swt.SWT.DEFAULT)).expand(avr * 2, 0));
343: if (!rect.equals(new Rectangle(text.getBounds()))) {
344: text.setBounds(rect.x, rect.y, rect.width, rect.height);
345: }
346: }
347: }
348: }
|