001: package newprocess.diagram.edit.parts;
002:
003: import newprocess.diagram.cust.figures.TermDefaultSizeNodeFigure;
004: import newprocess.diagram.cust.policies.HighlightEditPolicy;
005: import newprocess.diagram.edit.policies.ConditionTermItemSemanticEditPolicy;
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.AbstractBorderItemEditPart;
020: import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
021: import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
022: import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
023: import org.eclipse.gmf.runtime.notation.View;
024: import org.eclipse.swt.graphics.Color;
025:
026: /**
027: * @generated
028: */
029: public class ConditionTermEditPart extends AbstractBorderItemEditPart {
030:
031: /**
032: * @generated
033: */
034: public static final int VISUAL_ID = 3005;
035:
036: /**
037: * @generated
038: */
039: protected IFigure contentPane;
040:
041: /**
042: * @generated
043: */
044: protected IFigure primaryShape;
045:
046: /**
047: * @generated
048: */
049: public ConditionTermEditPart(View view) {
050: super (view);
051: }
052:
053: /**
054: * @generated NOT
055: * @author sh
056: */
057: protected void createDefaultEditPolicies() {
058: super .createDefaultEditPolicies();
059:
060: installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE,
061: getPrimaryDragEditPolicy());
062: installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
063: new ConditionTermItemSemanticEditPolicy());
064: installEditPolicy(EditPolicy.LAYOUT_ROLE,
065: createLayoutEditPolicy());
066: installEditPolicy(EditPolicyRoles.SNAP_FEEDBACK_ROLE,
067: new HighlightEditPolicy());
068: }
069:
070: /**
071: * @generated
072: */
073: protected LayoutEditPolicy createLayoutEditPolicy() {
074: LayoutEditPolicy lep = new LayoutEditPolicy() {
075:
076: protected EditPolicy createChildEditPolicy(EditPart child) {
077: EditPolicy result = child
078: .getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
079: if (result == null) {
080: result = new NonResizableEditPolicy();
081: }
082: return result;
083: }
084:
085: protected Command getMoveChildrenCommand(Request request) {
086: return null;
087: }
088:
089: protected Command getCreateCommand(CreateRequest request) {
090: return null;
091: }
092: };
093: return lep;
094: }
095:
096: /**
097: * @generated
098: */
099: protected IFigure createNodeShape() {
100: ConditionTermFigure figure = new ConditionTermFigure();
101: return primaryShape = figure;
102: }
103:
104: /**
105: * @generated
106: */
107: public ConditionTermFigure getPrimaryShape() {
108: return (ConditionTermFigure) primaryShape;
109: }
110:
111: /**
112: * @generated NOT
113: * @author sh
114: */
115: protected NodeFigure createNodePlate() {
116: TermDefaultSizeNodeFigure result = new TermDefaultSizeNodeFigure(
117: getMapMode().DPtoLP(10), getMapMode().DPtoLP(5));
118: // tell the Editpart to it�s figure. It�s ugly and not MVC but allows to
119: // untagle prot connections
120: result.setMyPort(this );
121: //FIXME: workaround for #154536
122: result.getBounds().setSize(result.getPreferredSize());
123: return result;
124: }
125:
126: /**
127: * Creates figure for this edit part.
128: *
129: * Body of this method does not depend on settings in generation model
130: * so you may safely remove <i>generated</i> tag and modify it.
131: *
132: * @generated
133: */
134: protected NodeFigure createNodeFigure() {
135: NodeFigure figure = createNodePlate();
136: figure.setLayoutManager(new StackLayout());
137: IFigure shape = createNodeShape();
138: figure.add(shape);
139: contentPane = setupContentPane(shape);
140: return figure;
141: }
142:
143: /**
144: * Default implementation treats passed figure as content pane.
145: * Respects layout one may have set for generated figure.
146: * @param nodeShape instance of generated figure class
147: * @generated
148: */
149: protected IFigure setupContentPane(IFigure nodeShape) {
150: if (nodeShape.getLayoutManager() == null) {
151: ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
152: layout.setSpacing(getMapMode().DPtoLP(5));
153: nodeShape.setLayoutManager(layout);
154: }
155: return nodeShape; // use nodeShape itself as contentPane
156: }
157:
158: /**
159: * @generated
160: */
161: public IFigure getContentPane() {
162: if (contentPane != null) {
163: return contentPane;
164: }
165: return super .getContentPane();
166: }
167:
168: /**
169: * @generated
170: */
171: public class ConditionTermFigure extends RectangleFigure {
172: /**
173: * @generated
174: */
175: public ConditionTermFigure() {
176: this .setFill(true);
177: this .setFillXOR(false);
178: this .setOutline(true);
179: this .setOutlineXOR(false);
180: this .setLineWidth(1);
181: this .setLineStyle(Graphics.LINE_SOLID);
182: this .setBackgroundColor(CONDITIONTERMFIGURE_BACK);
183: this .setPreferredSize(new Dimension(
184: getMapMode().DPtoLP(10), getMapMode().DPtoLP(5)));
185: this .setMaximumSize(new Dimension(getMapMode().DPtoLP(10),
186: getMapMode().DPtoLP(5)));
187: this .setMinimumSize(new Dimension(getMapMode().DPtoLP(10),
188: getMapMode().DPtoLP(5)));
189: }
190:
191: /**
192: * @generated
193: */
194: private boolean myUseLocalCoordinates = false;
195:
196: /**
197: * @generated
198: */
199: protected boolean useLocalCoordinates() {
200: return myUseLocalCoordinates;
201: }
202:
203: /**
204: * @generated
205: */
206: protected void setUseLocalCoordinates(
207: boolean useLocalCoordinates) {
208: myUseLocalCoordinates = useLocalCoordinates;
209: }
210:
211: }
212:
213: /**
214: * @generated
215: */
216: static final Color CONDITIONTERMFIGURE_BACK = new Color(null, 49,
217: 106, 197);
218:
219: }
|