001: package newprocess.diagram.edit.parts;
002:
003: import newprocess.diagram.cust.policies.NodeComponentEditPolicy;
004: import newprocess.diagram.edit.policies.LoaderItemSemanticEditPolicy;
005: import newprocess.diagram.part.New_processVisualIDRegistry;
006:
007: import org.eclipse.draw2d.Graphics;
008: import org.eclipse.draw2d.IFigure;
009: import org.eclipse.draw2d.RectangleFigure;
010: import org.eclipse.draw2d.StackLayout;
011: import org.eclipse.draw2d.geometry.Dimension;
012: import org.eclipse.gef.EditPart;
013: import org.eclipse.gef.EditPolicy;
014: import org.eclipse.gef.Request;
015: import org.eclipse.gef.commands.Command;
016: import org.eclipse.gef.editpolicies.LayoutEditPolicy;
017: import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
018: import org.eclipse.gef.requests.CreateRequest;
019: import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
020: import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
021: import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
022: import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
023: import org.eclipse.gmf.runtime.draw2d.ui.figures.WrapLabel;
024: import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
025: import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
026: import org.eclipse.gmf.runtime.notation.View;
027: import org.eclipse.swt.graphics.Color;
028:
029: /**
030: * @generated
031: */
032: public class LoaderEditPart extends ShapeNodeEditPart {
033:
034: /**
035: * @generated
036: */
037: public static final int VISUAL_ID = 3013;
038:
039: /**
040: * @generated
041: */
042: protected IFigure contentPane;
043:
044: /**
045: * @generated
046: */
047: protected IFigure primaryShape;
048:
049: /**
050: * @generated
051: */
052: public LoaderEditPart(View view) {
053: super (view);
054: }
055:
056: /**
057: * @generated NOT
058: * @author sh
059: */
060: protected void createDefaultEditPolicies() {
061: super .createDefaultEditPolicies();
062:
063: installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
064: new LoaderItemSemanticEditPolicy());
065: installEditPolicy(EditPolicy.LAYOUT_ROLE,
066: createLayoutEditPolicy());
067: // install this policy to disable deleting of the Globals Figure
068: installEditPolicy(EditPolicy.COMPONENT_ROLE,
069: new NodeComponentEditPolicy());
070: }
071:
072: /**
073: * @generated
074: */
075: protected LayoutEditPolicy createLayoutEditPolicy() {
076: LayoutEditPolicy lep = new LayoutEditPolicy() {
077:
078: protected EditPolicy createChildEditPolicy(EditPart child) {
079: EditPolicy result = child
080: .getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
081: if (result == null) {
082: result = new NonResizableEditPolicy();
083: }
084: return result;
085: }
086:
087: protected Command getMoveChildrenCommand(Request request) {
088: return null;
089: }
090:
091: protected Command getCreateCommand(CreateRequest request) {
092: return null;
093: }
094: };
095: return lep;
096: }
097:
098: /**
099: * @generated
100: */
101: protected IFigure createNodeShape() {
102: LoaderFigure figure = new LoaderFigure();
103: return primaryShape = figure;
104: }
105:
106: /**
107: * @generated
108: */
109: public LoaderFigure getPrimaryShape() {
110: return (LoaderFigure) primaryShape;
111: }
112:
113: /**
114: * @generated
115: */
116: protected boolean addFixedChild(EditPart childEditPart) {
117: if (childEditPart instanceof LoaderNameEditPart) {
118: ((LoaderNameEditPart) childEditPart)
119: .setLabel(getPrimaryShape()
120: .getFigureLoaderNameFigure());
121: return true;
122: }
123: return false;
124: }
125:
126: /**
127: * @generated
128: */
129: protected boolean removeFixedChild(EditPart childEditPart) {
130:
131: return false;
132: }
133:
134: /**
135: * @generated
136: */
137: protected void addChildVisual(EditPart childEditPart, int index) {
138: if (addFixedChild(childEditPart)) {
139: return;
140: }
141: super .addChildVisual(childEditPart, -1);
142: }
143:
144: /**
145: * @generated
146: */
147: protected void removeChildVisual(EditPart childEditPart) {
148: if (removeFixedChild(childEditPart)) {
149: return;
150: }
151: super .removeChildVisual(childEditPart);
152: }
153:
154: /**
155: * @generated
156: */
157: protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
158:
159: return super .getContentPaneFor(editPart);
160: }
161:
162: /**
163: * @generated
164: */
165: protected NodeFigure createNodePlate() {
166: DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(
167: getMapMode().DPtoLP(120), getMapMode().DPtoLP(20));
168:
169: return result;
170: }
171:
172: /**
173: * Creates figure for this edit part.
174: *
175: * Body of this method does not depend on settings in generation model
176: * so you may safely remove <i>generated</i> tag and modify it.
177: *
178: * @generated
179: */
180: protected NodeFigure createNodeFigure() {
181: NodeFigure figure = createNodePlate();
182: figure.setLayoutManager(new StackLayout());
183: IFigure shape = createNodeShape();
184: figure.add(shape);
185: contentPane = setupContentPane(shape);
186: return figure;
187: }
188:
189: /**
190: * Default implementation treats passed figure as content pane.
191: * Respects layout one may have set for generated figure.
192: * @param nodeShape instance of generated figure class
193: * @generated
194: */
195: protected IFigure setupContentPane(IFigure nodeShape) {
196: if (nodeShape.getLayoutManager() == null) {
197: ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
198: layout.setSpacing(getMapMode().DPtoLP(5));
199: nodeShape.setLayoutManager(layout);
200: }
201: return nodeShape; // use nodeShape itself as contentPane
202: }
203:
204: /**
205: * @generated
206: */
207: public IFigure getContentPane() {
208: if (contentPane != null) {
209: return contentPane;
210: }
211: return super .getContentPane();
212: }
213:
214: /**
215: * @generated
216: */
217: public EditPart getPrimaryChildEditPart() {
218: return getChildBySemanticHint(New_processVisualIDRegistry
219: .getType(LoaderNameEditPart.VISUAL_ID));
220: }
221:
222: /**
223: * @generated
224: */
225: public class LoaderFigure extends RectangleFigure {
226: /**
227: * @generated
228: */
229: public LoaderFigure() {
230: this .setFill(true);
231: this .setFillXOR(false);
232: this .setOutline(true);
233: this .setOutlineXOR(false);
234: this .setLineWidth(1);
235: this .setLineStyle(Graphics.LINE_SOLID);
236: this .setBackgroundColor(LOADERFIGURE_BACK);
237: this .setPreferredSize(new Dimension(getMapMode()
238: .DPtoLP(120), getMapMode().DPtoLP(20)));
239: createContents();
240: }
241:
242: /**
243: * @generated
244: */
245: private void createContents() {
246:
247: WrapLabel loaderNameFigure0 = new WrapLabel();
248: loaderNameFigure0.setText("<...>");
249:
250: this .add(loaderNameFigure0);
251: setFigureLoaderNameFigure(loaderNameFigure0);
252:
253: }
254:
255: /**
256: * @generated
257: */
258: private WrapLabel fLoaderNameFigure;
259:
260: /**
261: * @generated
262: */
263: public WrapLabel getFigureLoaderNameFigure() {
264: return fLoaderNameFigure;
265: }
266:
267: /**
268: * @generated
269: */
270: private void setFigureLoaderNameFigure(WrapLabel fig) {
271: fLoaderNameFigure = fig;
272: }
273:
274: /**
275: * @generated
276: */
277: private boolean myUseLocalCoordinates = false;
278:
279: /**
280: * @generated
281: */
282: protected boolean useLocalCoordinates() {
283: return myUseLocalCoordinates;
284: }
285:
286: /**
287: * @generated
288: */
289: protected void setUseLocalCoordinates(
290: boolean useLocalCoordinates) {
291: myUseLocalCoordinates = useLocalCoordinates;
292: }
293:
294: }
295:
296: /**
297: * @generated
298: */
299: static final Color LOADERFIGURE_BACK = new Color(null, 204, 255,
300: 204);
301:
302: }
|