001: package newprocess.diagram.edit.parts;
002:
003: import newprocess.diagram.edit.policies.AndOperatorItemSemanticEditPolicy;
004:
005: import org.eclipse.draw2d.ColorConstants;
006: import org.eclipse.draw2d.Ellipse;
007: import org.eclipse.draw2d.Graphics;
008: import org.eclipse.draw2d.IFigure;
009: import org.eclipse.draw2d.PositionConstants;
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.editpolicies.ResizableEditPolicy;
019: import org.eclipse.gef.requests.CreateRequest;
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:
028: /**
029: * @generated
030: */
031: public class AndOperatorEditPart extends ShapeNodeEditPart {
032:
033: /**
034: * @generated
035: */
036: public static final int VISUAL_ID = 3004;
037:
038: /**
039: * @generated
040: */
041: protected IFigure contentPane;
042:
043: /**
044: * @generated
045: */
046: protected IFigure primaryShape;
047:
048: /**
049: * @generated
050: */
051: public AndOperatorEditPart(View view) {
052: super (view);
053: }
054:
055: /**
056: * @generated
057: */
058: protected void createDefaultEditPolicies() {
059: super .createDefaultEditPolicies();
060:
061: installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
062: new AndOperatorItemSemanticEditPolicy());
063: installEditPolicy(EditPolicy.LAYOUT_ROLE,
064: createLayoutEditPolicy());
065: }
066:
067: /**
068: * @generated
069: */
070: protected LayoutEditPolicy createLayoutEditPolicy() {
071: LayoutEditPolicy lep = new LayoutEditPolicy() {
072:
073: protected EditPolicy createChildEditPolicy(EditPart child) {
074: EditPolicy result = child
075: .getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
076: if (result == null) {
077: result = new NonResizableEditPolicy();
078: }
079: return result;
080: }
081:
082: protected Command getMoveChildrenCommand(Request request) {
083: return null;
084: }
085:
086: protected Command getCreateCommand(CreateRequest request) {
087: return null;
088: }
089: };
090: return lep;
091: }
092:
093: /**
094: * @generated
095: */
096: protected IFigure createNodeShape() {
097: AndOperatorFigure figure = new AndOperatorFigure();
098: return primaryShape = figure;
099: }
100:
101: /**
102: * @generated
103: */
104: public AndOperatorFigure getPrimaryShape() {
105: return (AndOperatorFigure) primaryShape;
106: }
107:
108: /**
109: * @generated
110: */
111: protected NodeFigure createNodePlate() {
112: DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(
113: getMapMode().DPtoLP(20), getMapMode().DPtoLP(20));
114:
115: return result;
116: }
117:
118: /**
119: * @generated
120: */
121: public EditPolicy getPrimaryDragEditPolicy() {
122: EditPolicy result = super .getPrimaryDragEditPolicy();
123: if (result instanceof ResizableEditPolicy) {
124: ResizableEditPolicy ep = (ResizableEditPolicy) result;
125: ep.setResizeDirections(PositionConstants.NONE);
126: }
127: return result;
128: }
129:
130: /**
131: * Creates figure for this edit part.
132: *
133: * Body of this method does not depend on settings in generation model
134: * so you may safely remove <i>generated</i> tag and modify it.
135: *
136: * @generated
137: */
138: protected NodeFigure createNodeFigure() {
139: NodeFigure figure = createNodePlate();
140: figure.setLayoutManager(new StackLayout());
141: IFigure shape = createNodeShape();
142: figure.add(shape);
143: contentPane = setupContentPane(shape);
144: return figure;
145: }
146:
147: /**
148: * Default implementation treats passed figure as content pane.
149: * Respects layout one may have set for generated figure.
150: * @param nodeShape instance of generated figure class
151: * @generated
152: */
153: protected IFigure setupContentPane(IFigure nodeShape) {
154: if (nodeShape.getLayoutManager() == null) {
155: ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
156: layout.setSpacing(getMapMode().DPtoLP(5));
157: nodeShape.setLayoutManager(layout);
158: }
159: return nodeShape; // use nodeShape itself as contentPane
160: }
161:
162: /**
163: * @generated
164: */
165: public IFigure getContentPane() {
166: if (contentPane != null) {
167: return contentPane;
168: }
169: return super .getContentPane();
170: }
171:
172: /**
173: * @generated
174: */
175: public class AndOperatorFigure extends Ellipse {
176: /**
177: * @generated
178: */
179: public AndOperatorFigure() {
180: this .setFill(true);
181: this .setFillXOR(false);
182: this .setOutline(true);
183: this .setOutlineXOR(false);
184: this .setLineWidth(1);
185: this .setLineStyle(Graphics.LINE_SOLID);
186: this .setForegroundColor(ColorConstants.black);
187: this .setBackgroundColor(ColorConstants.white);
188: this .setPreferredSize(new Dimension(
189: getMapMode().DPtoLP(20), getMapMode().DPtoLP(20)));
190: this .setMaximumSize(new Dimension(getMapMode().DPtoLP(20),
191: getMapMode().DPtoLP(20)));
192: this .setMinimumSize(new Dimension(getMapMode().DPtoLP(20),
193: getMapMode().DPtoLP(20)));
194: createContents();
195: }
196:
197: /**
198: * @generated
199: */
200: private void createContents() {
201:
202: WrapLabel andOperatorNameFigure0 = new WrapLabel();
203: andOperatorNameFigure0.setText("&&");
204:
205: this .add(andOperatorNameFigure0);
206: setFigureAndOperatorNameFigure(andOperatorNameFigure0);
207:
208: }
209:
210: /**
211: * @generated
212: */
213: private WrapLabel fAndOperatorNameFigure;
214:
215: /**
216: * @generated
217: */
218: public WrapLabel getFigureAndOperatorNameFigure() {
219: return fAndOperatorNameFigure;
220: }
221:
222: /**
223: * @generated
224: */
225: private void setFigureAndOperatorNameFigure(WrapLabel fig) {
226: fAndOperatorNameFigure = fig;
227: }
228:
229: /**
230: * @generated
231: */
232: private boolean myUseLocalCoordinates = false;
233:
234: /**
235: * @generated
236: */
237: protected boolean useLocalCoordinates() {
238: return myUseLocalCoordinates;
239: }
240:
241: /**
242: * @generated
243: */
244: protected void setUseLocalCoordinates(
245: boolean useLocalCoordinates) {
246: myUseLocalCoordinates = useLocalCoordinates;
247: }
248:
249: }
250:
251: }
|