Source Code Cross Referenced for BendpointEditPolicy.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » ui » componentflow » componentFlowEditor » diagram » edit » policies » 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 » ESB » cbesb 1.2 » com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.edit.policies 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ChainBuilder ESB
003:         *          Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2006 Bostech Corporation
006:         * 
007:         * This program is free software; you can redistribute it and/or modify it 
008:         * under the terms of the GNU General Public License as published by the 
009:         * Free Software Foundation; either version 2 of the License, or (at your option) 
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, 
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
014:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
015:         * for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License along with 
018:         * this program; if not, write to the Free Software Foundation, Inc., 
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         *
021:         *
022:         * $Id$
023:         */
024:        package com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.edit.policies;
025:
026:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.edit.parts.WrappingCommand;
027:
028:        import java.util.ArrayList;
029:        import java.util.List;
030:
031:        import org.eclipse.draw2d.Connection;
032:
033:        import org.eclipse.draw2d.geometry.Dimension;
034:        import org.eclipse.draw2d.geometry.Point;
035:
036:        import org.eclipse.emf.common.command.AbstractCommand;
037:
038:        import org.eclipse.emf.transaction.TransactionalEditingDomain;
039:
040:        import org.eclipse.emf.transaction.util.TransactionUtil;
041:
042:        import org.eclipse.gef.commands.Command;
043:
044:        import org.eclipse.gef.requests.BendpointRequest;
045:
046:        import org.eclipse.gmf.runtime.notation.Edge;
047:        import org.eclipse.gmf.runtime.notation.NotationFactory;
048:        import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
049:
050:        import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
051:
052:        /**
053:         * @generated
054:         */
055:        public class BendpointEditPolicy extends
056:                org.eclipse.gef.editpolicies.BendpointEditPolicy {
057:            /**
058:             * @generated
059:             */
060:            protected Edge getDiagramEdge() {
061:                return (Edge) getHost().getModel();
062:            }
063:
064:            /**
065:             * @generated
066:             */
067:            protected Command getCreateBendpointCommand(BendpointRequest request) {
068:                return getModifyBendpointCommand(new BendpointCreator(request
069:                        .getIndex(), request.getLocation()));
070:            }
071:
072:            /**
073:             * @generated
074:             */
075:            protected Command getDeleteBendpointCommand(BendpointRequest request) {
076:                return getModifyBendpointCommand(new BendpointDeleter(request
077:                        .getIndex()));
078:            }
079:
080:            /**
081:             * @generated
082:             */
083:            protected Command getMoveBendpointCommand(BendpointRequest request) {
084:                return getModifyBendpointCommand(new BendpointMover(request
085:                        .getIndex(), request.getLocation()));
086:            }
087:
088:            /**
089:             * @generated
090:             */
091:            private Command getModifyBendpointCommand(BendpointModifier modifier) {
092:                TransactionalEditingDomain editingDomain = TransactionUtil
093:                        .getEditingDomain(getDiagramEdge().getDiagram()
094:                                .getElement());
095:                return new WrappingCommand(editingDomain,
096:                        new BendpointModificationCommand(modifier));
097:            }
098:
099:            /**
100:             * @generated
101:             */
102:            private class BendpointModificationCommand extends AbstractCommand {
103:                /**
104:                 * @generated
105:                 */
106:                private BendpointModifier bendpointModifier;
107:
108:                /**
109:                 * @generated
110:                 */
111:                private List oldPoints;
112:
113:                /**
114:                 * @generated
115:                 */
116:                public BendpointModificationCommand(
117:                        BendpointModifier bendpointModifier) {
118:                    this .bendpointModifier = bendpointModifier;
119:                }
120:
121:                /**
122:                 * @generated
123:                 */
124:                public void execute() {
125:                    Connection connection = getConnection();
126:                    final Point ptRef1 = connection.getSourceAnchor()
127:                            .getReferencePoint().getCopy();
128:                    connection.translateToRelative(ptRef1);
129:                    final Point ptRef2 = connection.getTargetAnchor()
130:                            .getReferencePoint().getCopy();
131:                    connection.translateToRelative(ptRef2);
132:                    RelativeBendpoints bendpoints = (RelativeBendpoints) getDiagramEdge()
133:                            .getBendpoints();
134:                    if (bendpoints == null) {
135:                        bendpoints = NotationFactory.eINSTANCE
136:                                .createRelativeBendpoints();
137:                        getDiagramEdge().setBendpoints(bendpoints);
138:                    }
139:                    oldPoints = bendpoints.getPoints();
140:                    List newPoints = new ArrayList(oldPoints);
141:                    bendpointModifier.applyModification(newPoints,
142:                            new BendpointConverter() {
143:                                public RelativeBendpoint convert(Point point) {
144:                                    Dimension s = point.getDifference(ptRef1);
145:                                    Dimension t = point.getDifference(ptRef2);
146:                                    return new RelativeBendpoint(s.width,
147:                                            s.height, t.width, t.height);
148:                                }
149:                            });
150:                    bendpoints.setPoints(newPoints);
151:                }
152:
153:                /**
154:                 * @generated
155:                 */
156:                public void undo() {
157:                    RelativeBendpoints bendpoints = (RelativeBendpoints) getDiagramEdge()
158:                            .getBendpoints();
159:                    bendpoints.setPoints(oldPoints);
160:                }
161:
162:                /**
163:                 * @generated
164:                 */
165:                public void redo() {
166:                    execute();
167:                }
168:
169:                /**
170:                 * @generated
171:                 */
172:                public boolean canExecute() {
173:                    return true;
174:                }
175:            }
176:
177:            /**
178:             * @generated
179:             */
180:            private static interface BendpointConverter {
181:                public RelativeBendpoint convert(Point point);
182:            }
183:
184:            /**
185:             * @generated
186:             */
187:            private static interface BendpointModifier {
188:                public void applyModification(
189:                        List/*<RelativeBendpoint>*/originalBendpoints,
190:                        BendpointConverter converter);
191:            }
192:
193:            /**
194:             * @generated
195:             */
196:            private static class BendpointDeleter implements  BendpointModifier {
197:                /**
198:                 * @generated
199:                 */
200:                private int index;
201:
202:                /**
203:                 * @generated
204:                 */
205:                public BendpointDeleter(int index) {
206:                    this .index = index;
207:                }
208:
209:                /**
210:                 * @generated
211:                 */
212:                public void applyModification(List originalBendpoints,
213:                        BendpointConverter converter) {
214:                    originalBendpoints.remove(index);
215:                }
216:            }
217:
218:            /**
219:             * @generated
220:             */
221:            private static class BendpointMover implements  BendpointModifier {
222:                /**
223:                 * @generated
224:                 */
225:                private int index;
226:
227:                /**
228:                 * @generated
229:                 */
230:                private Point point;
231:
232:                /**
233:                 * @generated
234:                 */
235:                public BendpointMover(int index, Point point) {
236:                    this .index = index;
237:                    this .point = point;
238:                }
239:
240:                /**
241:                 * @generated
242:                 */
243:                public void applyModification(List originalBendpoints,
244:                        BendpointConverter converter) {
245:                    originalBendpoints.set(index, converter.convert(point));
246:                }
247:            }
248:
249:            /**
250:             * @generated
251:             */
252:            private static class BendpointCreator implements  BendpointModifier {
253:                /**
254:                 * @generated
255:                 */
256:                private int index;
257:
258:                /**
259:                 * @generated
260:                 */
261:                private Point point;
262:
263:                /**
264:                 * @generated
265:                 */
266:                public BendpointCreator(int index, Point point) {
267:                    this .index = index;
268:                    this .point = point;
269:                }
270:
271:                /**
272:                 * @generated
273:                 */
274:                public void applyModification(List originalBendpoints,
275:                        BendpointConverter converter) {
276:                    originalBendpoints.add(index, converter.convert(point));
277:                }
278:            }
279:        }
www_.__j___a___v_a___2__s___.__com_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.