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