Source Code Cross Referenced for Expression2EditPart.java in  » Workflow-Engines » osbl-1_0 » newprocess » diagram » edit » parts » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » osbl 1_0 » newprocess.diagram.edit.parts 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package newprocess.diagram.edit.parts;
002:
003:        import java.util.Iterator;
004:        import java.util.List;
005:
006:        import newprocess.diagram.cust.figures.TermDefaultSizeNodeFigure;
007:        import newprocess.diagram.cust.locator.RootTermBorderItemLocator;
008:        import newprocess.diagram.cust.locator.TermtBorderItemLocator;
009:        import newprocess.diagram.cust.policies.NodeComponentEditPolicy;
010:        import newprocess.diagram.edit.policies.Expression2CanonicalEditPolicy;
011:        import newprocess.diagram.edit.policies.Expression2ItemSemanticEditPolicy;
012:
013:        import org.eclipse.draw2d.Graphics;
014:        import org.eclipse.draw2d.IFigure;
015:        import org.eclipse.draw2d.PositionConstants;
016:        import org.eclipse.draw2d.RectangleFigure;
017:        import org.eclipse.draw2d.StackLayout;
018:        import org.eclipse.draw2d.geometry.Dimension;
019:        import org.eclipse.gef.EditPart;
020:        import org.eclipse.gef.EditPolicy;
021:        import org.eclipse.gef.Request;
022:        import org.eclipse.gef.commands.Command;
023:        import org.eclipse.gef.editpolicies.LayoutEditPolicy;
024:        import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
025:        import org.eclipse.gef.requests.CreateRequest;
026:        import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart;
027:        import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
028:        import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
029:        import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy;
030:        import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
031:        import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
032:        import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
033:        import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
034:        import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
035:        import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
036:        import org.eclipse.gmf.runtime.notation.View;
037:        import org.eclipse.swt.graphics.Color;
038:
039:        /**
040:         * @generated
041:         */
042:        public class Expression2EditPart extends AbstractBorderedShapeEditPart {
043:
044:            /**
045:             * the BorderItemLocators which calculates the layout of BorderItems
046:             */
047:            private TermtBorderItemLocator termLoc = null;
048:            private RootTermBorderItemLocator rootLoc = null;
049:
050:            /**
051:             * @generated NOT
052:             * @author sh
053:             * The Expression of the SynActivities Postconditions
054:             */
055:            public static final int VISUAL_ID = 3006;
056:
057:            /**
058:             * @generated
059:             */
060:            protected IFigure contentPane;
061:
062:            /**
063:             * @generated
064:             */
065:            protected IFigure primaryShape;
066:
067:            /**
068:             * @generated
069:             */
070:            public Expression2EditPart(View view) {
071:                super (view);
072:            }
073:
074:            /**
075:             * @generated NOT
076:             * @author sh
077:             */
078:            protected void createDefaultEditPolicies() {
079:                installEditPolicy(EditPolicyRoles.CREATION_ROLE,
080:                        new CreationEditPolicy());
081:                super .createDefaultEditPolicies();
082:
083:                installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
084:                        new Expression2ItemSemanticEditPolicy());
085:                installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE,
086:                        new DragDropEditPolicy());
087:                installEditPolicy(EditPolicyRoles.CANONICAL_ROLE,
088:                        new Expression2CanonicalEditPolicy());
089:                installEditPolicy(EditPolicy.LAYOUT_ROLE,
090:                        createLayoutEditPolicy());
091:                // install this policy to disable deleting of the Expression Compartment
092:                installEditPolicy(EditPolicy.COMPONENT_ROLE,
093:                        new NodeComponentEditPolicy());
094:            }
095:
096:            /**
097:             * @generated
098:             */
099:            protected LayoutEditPolicy createLayoutEditPolicy() {
100:                LayoutEditPolicy lep = new LayoutEditPolicy() {
101:
102:                    protected EditPolicy createChildEditPolicy(EditPart child) {
103:                        if (child instanceof  IBorderItemEditPart) {
104:                            return new BorderItemSelectionEditPolicy();
105:                        }
106:                        EditPolicy result = child
107:                                .getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
108:                        if (result == null) {
109:                            result = new NonResizableEditPolicy();
110:                        }
111:                        return result;
112:                    }
113:
114:                    protected Command getMoveChildrenCommand(Request request) {
115:                        return null;
116:                    }
117:
118:                    protected Command getCreateCommand(CreateRequest request) {
119:                        return null;
120:                    }
121:                };
122:                return lep;
123:            }
124:
125:            /**
126:             * @generated
127:             */
128:            protected IFigure createNodeShape() {
129:                ExpressionFigure figure = new ExpressionFigure();
130:                return primaryShape = figure;
131:            }
132:
133:            /**
134:             * @generated
135:             */
136:            public ExpressionFigure getPrimaryShape() {
137:                return (ExpressionFigure) primaryShape;
138:            }
139:
140:            @Override
141:            protected void addChildVisual(EditPart childEditPart, int index) {
142:                if (addFixedChild(childEditPart)) {
143:                    return;
144:                }
145:                super .addChildVisual(childEditPart, -1);
146:            }
147:
148:            @Override
149:            protected void removeChildVisual(EditPart child) {
150:                if (removeFixedChild(child)) {
151:                    return;
152:                }
153:                super .removeChildVisual(child);
154:            }
155:
156:            /**
157:             * 	 
158:             */
159:            protected boolean removeFixedChild(EditPart childEditPart) {
160:                if (childEditPart instanceof  RootEditPart) {
161:                    getBorderedFigure().getBorderItemContainer().remove(
162:                            ((RootEditPart) childEditPart).getFigure());
163:                    return true;
164:                }
165:                if (childEditPart instanceof  ConditionTermEditPart) {
166:                    getBorderedFigure().getBorderItemContainer()
167:                            .remove(
168:                                    ((ConditionTermEditPart) childEditPart)
169:                                            .getFigure());
170:                    return true;
171:                }
172:                return false;
173:            }
174:
175:            @Override
176:            protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
177:                if (editPart instanceof  RootEditPart) {
178:                    return getBorderedFigure().getBorderItemContainer();
179:                }
180:                if (editPart instanceof  ConditionTermEditPart) {
181:                    return getBorderedFigure().getBorderItemContainer();
182:                }
183:                return getContentPane();
184:            }
185:
186:            /**
187:             * @author sh
188:             */
189:            protected boolean addFixedChild(EditPart childEditPart) {
190:                if (childEditPart instanceof  RootEditPart) {
191:                    if (rootLoc == null) {
192:                        rootLoc = new RootTermBorderItemLocator(
193:                                getMainFigure(), PositionConstants.NORTH);
194:                    }
195:                    getBorderedFigure().getBorderItemContainer()
196:                            .add(((RootEditPart) childEditPart).getFigure(),
197:                                    rootLoc);
198:                    return true;
199:                }
200:
201:                if (childEditPart instanceof  ConditionTermEditPart) {
202:                    TermtBorderItemLocator locator = new TermtBorderItemLocator(
203:                            getMainFigure(), PositionConstants.SOUTH);
204:                    if (termLoc == null)
205:                        termLoc = locator;
206:                    getBorderedFigure().getBorderItemContainer()
207:                            .add(
208:                                    ((ConditionTermEditPart) childEditPart)
209:                                            .getFigure(), locator);
210:                    return true;
211:                }
212:                return false;
213:            }
214:
215:            /**
216:             * @generated
217:             */
218:            protected NodeFigure createNodePlate() {
219:                DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(
220:                        getMapMode().DPtoLP(160), getMapMode().DPtoLP(100));
221:
222:                return result;
223:            }
224:
225:            /**
226:             * Creates figure for this edit part.
227:             * 
228:             * Body of this method does not depend on settings in generation model
229:             * so you may safely remove <i>generated</i> tag and modify it.
230:             * 
231:             * @generated
232:             */
233:            protected NodeFigure createMainFigure() {
234:                NodeFigure figure = createNodePlate();
235:                figure.setLayoutManager(new StackLayout());
236:                IFigure shape = createNodeShape();
237:                figure.add(shape);
238:                contentPane = setupContentPane(shape);
239:                return figure;
240:            }
241:
242:            /**
243:             * Default implementation treats passed figure as content pane.
244:             * Respects layout one may have set for generated figure.
245:             * @param nodeShape instance of generated figure class
246:             * @generated
247:             */
248:            protected IFigure setupContentPane(IFigure nodeShape) {
249:                if (nodeShape.getLayoutManager() == null) {
250:                    ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
251:                    layout.setSpacing(getMapMode().DPtoLP(5));
252:                    nodeShape.setLayoutManager(layout);
253:                }
254:                return nodeShape; // use nodeShape itself as contentPane
255:            }
256:
257:            /**
258:             * Relocates the bordered items on the expression.
259:             * If the links to proxies are crossed over the relocate 
260:             * moves the bordered items and resolves the crossings.
261:             */
262:            public void refreshBounds() {
263:                super .refreshBounds();
264:
265:                // get the item container where bordered items are added
266:                IFigure itemContainer = this .getBorderedFigure()
267:                        .getBorderItemContainer();
268:
269:                // iterate over all bordered items the expressio has and consider the root
270:                List<IFigure> childs = itemContainer.getChildren();
271:                for (Iterator<IFigure> iterator = childs.iterator(); iterator
272:                        .hasNext();) {
273:                    IFigure figure = iterator.next();
274:                    if (figure instanceof  TermDefaultSizeNodeFigure) {
275:                        // relocate the default term
276:                        this .getTermBorderItemLocator().relocate(
277:                                (IFigure) figure);
278:                        continue;
279:                    }
280:                    if (figure instanceof  DefaultSizeNodeFigure) {
281:                        // relocate the root
282:                        this .getRootTermBorderItemLocator().relocate(
283:                                (IFigure) figure);
284:                    }
285:                }
286:            }
287:
288:            /**
289:             * get the TermBorderItemLocator
290:             */
291:            public TermtBorderItemLocator getTermBorderItemLocator() {
292:                return termLoc;
293:            }
294:
295:            /**
296:             * get the RootTermBorderItemLocator
297:             * @return 
298:             */
299:            public RootTermBorderItemLocator getRootTermBorderItemLocator() {
300:                return rootLoc;
301:            }
302:
303:            /**
304:             * @generated
305:             */
306:            public IFigure getContentPane() {
307:                if (contentPane != null) {
308:                    return contentPane;
309:                }
310:                return super .getContentPane();
311:            }
312:
313:            /**
314:             * @generated
315:             */
316:            public class ExpressionFigure extends RectangleFigure {
317:                /**
318:                 * @generated
319:                 */
320:                public ExpressionFigure() {
321:                    this .setFill(true);
322:                    this .setFillXOR(false);
323:                    this .setOutline(true);
324:                    this .setOutlineXOR(false);
325:                    this .setLineWidth(1);
326:                    this .setLineStyle(Graphics.LINE_SOLID);
327:                    this .setBackgroundColor(EXPRESSIONFIGURE_BACK);
328:                    this .setPreferredSize(new Dimension(getMapMode()
329:                            .DPtoLP(160), getMapMode().DPtoLP(100)));
330:                }
331:
332:                /**
333:                 * @generated
334:                 */
335:                private boolean myUseLocalCoordinates = false;
336:
337:                /**
338:                 * @generated
339:                 */
340:                protected boolean useLocalCoordinates() {
341:                    return myUseLocalCoordinates;
342:                }
343:
344:                /**
345:                 * @generated
346:                 */
347:                protected void setUseLocalCoordinates(
348:                        boolean useLocalCoordinates) {
349:                    myUseLocalCoordinates = useLocalCoordinates;
350:                }
351:
352:                @Override
353:                public void paintFigure(Graphics graphics) {
354:                    super .paintFigure(graphics);
355:                    graphics.setForegroundColor(new Color(null, 204, 230, 255));
356:                    graphics.setBackgroundColor(new Color(null, 153, 204, 255));
357:                    int x = getLocation().x;
358:                    int y = getLocation().y;
359:                    int width = getBounds().width;
360:                    int height = getBounds().height;
361:                    graphics.setLineWidth(1);
362:                    graphics.setLineStyle(Graphics.LINE_SOLID);
363:                    graphics.fillGradient(x, y, width, height, true);
364:                }
365:            }
366:
367:            /**
368:             * @generated
369:             */
370:            static final Color EXPRESSIONFIGURE_BACK = new Color(null, 172,
371:                    206, 255);
372:
373:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.