001: package newprocess.diagram.edit.parts;
002:
003: import newprocess.diagram.cust.policies.NodeComponentEditPolicy;
004: import newprocess.diagram.edit.policies.RootItemSemanticEditPolicy;
005:
006: import org.eclipse.draw2d.Graphics;
007: import org.eclipse.draw2d.IFigure;
008: import org.eclipse.draw2d.RectangleFigure;
009: import org.eclipse.draw2d.StackLayout;
010: import org.eclipse.draw2d.geometry.Dimension;
011: import org.eclipse.gef.EditPart;
012: import org.eclipse.gef.EditPolicy;
013: import org.eclipse.gef.Request;
014: import org.eclipse.gef.commands.Command;
015: import org.eclipse.gef.editpolicies.LayoutEditPolicy;
016: import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
017: import org.eclipse.gef.requests.CreateRequest;
018: import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart;
019: import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
020: import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
021: import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
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 RootEditPart extends AbstractBorderItemEditPart {
030:
031: /**
032: * @generated
033: */
034: public static final int VISUAL_ID = 3002;
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 RootEditPart(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 RootItemSemanticEditPolicy());
064: installEditPolicy(EditPolicy.LAYOUT_ROLE,
065: createLayoutEditPolicy());
066: // install this policy to disable deleting of RootPorts
067: installEditPolicy(EditPolicy.COMPONENT_ROLE,
068: new NodeComponentEditPolicy());
069: }
070:
071: /**
072: * @generated
073: */
074: protected LayoutEditPolicy createLayoutEditPolicy() {
075: LayoutEditPolicy lep = new LayoutEditPolicy() {
076:
077: protected EditPolicy createChildEditPolicy(EditPart child) {
078: EditPolicy result = child
079: .getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
080: if (result == null) {
081: result = new NonResizableEditPolicy();
082: }
083: return result;
084: }
085:
086: protected Command getMoveChildrenCommand(Request request) {
087: return null;
088: }
089:
090: protected Command getCreateCommand(CreateRequest request) {
091: return null;
092: }
093: };
094: return lep;
095: }
096:
097: /**
098: * @generated
099: */
100: protected IFigure createNodeShape() {
101: ConditionTermFigure figure = new ConditionTermFigure();
102: return primaryShape = figure;
103: }
104:
105: /**
106: * @generated
107: */
108: public ConditionTermFigure getPrimaryShape() {
109: return (ConditionTermFigure) primaryShape;
110: }
111:
112: /**
113: * @generated
114: */
115: protected NodeFigure createNodePlate() {
116: DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(
117: getMapMode().DPtoLP(10), getMapMode().DPtoLP(5));
118:
119: //FIXME: workaround for #154536
120: result.getBounds().setSize(result.getPreferredSize());
121: return result;
122: }
123:
124: /**
125: * Creates figure for this edit part.
126: *
127: * Body of this method does not depend on settings in generation model
128: * so you may safely remove <i>generated</i> tag and modify it.
129: *
130: * @generated
131: */
132: protected NodeFigure createNodeFigure() {
133: NodeFigure figure = createNodePlate();
134: figure.setLayoutManager(new StackLayout());
135: IFigure shape = createNodeShape();
136: figure.add(shape);
137: contentPane = setupContentPane(shape);
138: return figure;
139: }
140:
141: /**
142: * Default implementation treats passed figure as content pane.
143: * Respects layout one may have set for generated figure.
144: * @param nodeShape instance of generated figure class
145: * @generated
146: */
147: protected IFigure setupContentPane(IFigure nodeShape) {
148: if (nodeShape.getLayoutManager() == null) {
149: ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
150: layout.setSpacing(getMapMode().DPtoLP(5));
151: nodeShape.setLayoutManager(layout);
152: }
153: return nodeShape; // use nodeShape itself as contentPane
154: }
155:
156: /**
157: * @generated
158: */
159: public IFigure getContentPane() {
160: if (contentPane != null) {
161: return contentPane;
162: }
163: return super .getContentPane();
164: }
165:
166: /**
167: * @generated
168: */
169: public class ConditionTermFigure extends RectangleFigure {
170: /**
171: * @generated
172: */
173: public ConditionTermFigure() {
174: this .setFill(true);
175: this .setFillXOR(false);
176: this .setOutline(true);
177: this .setOutlineXOR(false);
178: this .setLineWidth(1);
179: this .setLineStyle(Graphics.LINE_SOLID);
180: this .setBackgroundColor(CONDITIONTERMFIGURE_BACK);
181: this .setPreferredSize(new Dimension(
182: getMapMode().DPtoLP(10), getMapMode().DPtoLP(5)));
183: this .setMaximumSize(new Dimension(getMapMode().DPtoLP(10),
184: getMapMode().DPtoLP(5)));
185: this .setMinimumSize(new Dimension(getMapMode().DPtoLP(10),
186: getMapMode().DPtoLP(5)));
187: }
188:
189: /**
190: * @generated
191: */
192: private boolean myUseLocalCoordinates = false;
193:
194: /**
195: * @generated
196: */
197: protected boolean useLocalCoordinates() {
198: return myUseLocalCoordinates;
199: }
200:
201: /**
202: * @generated
203: */
204: protected void setUseLocalCoordinates(
205: boolean useLocalCoordinates) {
206: myUseLocalCoordinates = useLocalCoordinates;
207: }
208:
209: }
210:
211: /**
212: * @generated
213: */
214: static final Color CONDITIONTERMFIGURE_BACK = new Color(null, 49,
215: 106, 197);
216:
217: }
|