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