Source Code Cross Referenced for FlowEventHandlerEdgePresenter.java in  » IDE-Netbeans » vmd.analyzer » org » netbeans » modules » vmd » midp » flow » 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 » IDE Netbeans » vmd.analyzer » org.netbeans.modules.vmd.midp.flow 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.vmd.midp.flow;
042:
043:        import org.netbeans.api.visual.anchor.Anchor;
044:        import org.netbeans.api.visual.vmd.VMDConnectionWidget;
045:        import org.netbeans.api.visual.vmd.VMDFactory;
046:        import org.netbeans.api.visual.widget.ConnectionWidget;
047:        import org.netbeans.api.visual.widget.Widget;
048:        import org.netbeans.modules.vmd.api.flow.FlowEdgePresenter;
049:        import org.netbeans.modules.vmd.api.flow.visual.*;
050:        import org.netbeans.modules.vmd.api.model.DesignComponent;
051:        import org.netbeans.modules.vmd.api.model.DesignEventFilter;
052:        import org.netbeans.modules.vmd.api.model.presenters.actions.ActionsPresenter;
053:        import org.netbeans.modules.vmd.midp.actions.GoToSourceAction;
054:        import org.netbeans.modules.vmd.midp.components.MidpDocumentSupport;
055:        import org.netbeans.modules.vmd.midp.components.handlers.EventHandlerCD;
056:
057:        import javax.swing.*;
058:        import java.util.Collection;
059:        import java.util.List;
060:
061:        /**
062:         * @author David Kaspar
063:         */
064:        // TODO - extract abstract methods for acquiring source and target
065:        // TODO - rewrite to get relationship to the EventSource just by looking at the parent component
066:        public abstract class FlowEventHandlerEdgePresenter extends
067:                FlowEdgePresenter {
068:
069:            private final EventHandlerPinDecoratorBehaviour pinCtrl = new EventHandlerPinDecoratorBehaviour();
070:            private final EventHandlerEdgeDecoratorBehaviour edgeCtrl = new EventHandlerEdgeDecoratorBehaviour();
071:
072:            private FlowEdgeDescriptor edgeDescriptor;
073:
074:            protected abstract DesignComponent getTargetComponent();
075:
076:            protected String getEdgeID() {
077:                return FlowIDSupport.createEventHandlerEdgeID(getComponent());
078:            }
079:
080:            protected String getTargetPinID(DesignComponent target) {
081:                return FlowIDSupport.createEventHandlerTargetPinID(
082:                        getComponent(), target);
083:            }
084:
085:            protected boolean isDynamicTargetPin() {
086:                return true;
087:            }
088:
089:            protected boolean isVisible() {
090:                return super .isVisible() && getSourceComponent() != null;
091:            }
092:
093:            protected DesignComponent getSourceComponent() {
094:                return getComponent().readProperty(
095:                        EventHandlerCD.PROP_EVENT_SOURCE).getComponent();
096:            }
097:
098:            protected String getSourcePinID(DesignComponent source) {
099:                return FlowIDSupport.createEventSourcePinID(source);
100:            }
101:
102:            protected DesignComponent getRepresentedSourceComponent(
103:                    DesignComponent source) {
104:                return source;
105:            }
106:
107:            protected DesignComponent getRepresentedTargetComponent(
108:                    DesignComponent target) {
109:                return target;
110:            }
111:
112:            protected DesignComponent getRepresentedComponent() {
113:                return getComponent();
114:            }
115:
116:            protected DesignEventFilter getEventFilter() {
117:                return new DesignEventFilter().addParentFilter(getComponent(),
118:                        1, false);
119:            }
120:
121:            public final void updateDescriptors() {
122:                edgeDescriptor = null;
123:                if (!isVisible())
124:                    return;
125:                DesignComponent source = getSourceComponent();
126:                if (source == null)
127:                    return;
128:                DesignComponent target = getTargetComponent();
129:                if (target == null)
130:                    return;
131:
132:                edgeDescriptor = new FlowEdgeDescriptor(
133:                        getRepresentedComponent(), getEdgeID(),
134:                        new FlowPinDescriptor(
135:                                getRepresentedSourceComponent(source),
136:                                getSourcePinID(source)), false,
137:                        new FlowPinDescriptor(
138:                                getRepresentedTargetComponent(target),
139:                                getTargetPinID(target)), isDynamicTargetPin());
140:            }
141:
142:            protected final FlowNodeDescriptor getSourceNodeDescriptor(
143:                    FlowPinDescriptor sourcePinDescriptor) {
144:                return FlowEventSourcePinPresenter
145:                        .getNodeDescriptor(getSourceComponent());
146:            }
147:
148:            protected final FlowNodeDescriptor getTargetNodeDescriptor(
149:                    FlowPinDescriptor targetPinDescriptor) {
150:                DesignComponent targetComponent = getTargetComponent();
151:                return new FlowNodeDescriptor(targetComponent, FlowIDSupport
152:                        .createNodeID4SingleNode(targetComponent));
153:            }
154:
155:            public final FlowEdgeDescriptor getEdgeDescriptor() {
156:                return edgeDescriptor;
157:            }
158:
159:            public FlowEdgeDescriptor.EdgeDecorator getDecorator() {
160:                return edgeCtrl;
161:            }
162:
163:            public FlowEdgeDescriptor.EdgeBehaviour getBehaviour() {
164:                return edgeCtrl;
165:            }
166:
167:            public FlowPinDescriptor.PinDecorator getDynamicPinDecorator() {
168:                return pinCtrl;
169:            }
170:
171:            public FlowPinDescriptor.PinBehaviour getDynamicPinBehaviour() {
172:                return pinCtrl;
173:            }
174:
175:            public static class EventHandlerPinDecoratorBehaviour implements 
176:                    FlowPinDescriptor.PinDecorator,
177:                    FlowPinDescriptor.PinBehaviour {
178:
179:                public Widget createWidget(FlowPinDescriptor descriptor,
180:                        FlowScene scene) {
181:                    return null;
182:                }
183:
184:                public Anchor createAnchor(FlowPinDescriptor descriptor,
185:                        FlowScene scene) {
186:                    FlowNodeDescriptor node = scene.getPinNode(descriptor);
187:                    return scene.getDecorator(node).createAnchor(node, scene);
188:                }
189:
190:                public void update(FlowPinDescriptor descriptor, FlowScene scene) {
191:                }
192:
193:                public String getOrderCategory(FlowPinDescriptor descriptor) {
194:                    return null;
195:                }
196:
197:                public void updateBadges(FlowPinDescriptor descriptor,
198:                        FlowScene scene, List<FlowBadgeDescriptor> badges) {
199:                }
200:
201:                public boolean isConnectionSource(FlowPinDescriptor pin) {
202:                    return false;
203:                }
204:
205:                public boolean isConnectionTarget(FlowPinDescriptor sourcePin,
206:                        FlowDescriptor target) {
207:                    return false;
208:                }
209:
210:                public void createConnection(FlowPinDescriptor sourcePin,
211:                        FlowDescriptor target) {
212:                }
213:
214:            }
215:
216:            public class EventHandlerEdgeDecoratorBehaviour implements 
217:                    FlowEdgeDescriptor.EdgeDecorator,
218:                    FlowEdgeDescriptor.EdgeBehaviour,
219:                    FlowDescriptor.EditActionBehaviour {
220:
221:                public Widget create(FlowEdgeDescriptor descriptor,
222:                        FlowScene scene) {
223:                    VMDConnectionWidget widget = new VMDConnectionWidget(scene,
224:                            VMDFactory.getNetBeans60Scheme());
225:                    widget.setRouter(scene.createEdgeRouter());
226:                    scene.addEdgeCommonActions(widget);
227:                    widget.getActions().addAction(
228:                            scene.createMoveControlPointAction());
229:                    return widget;
230:                }
231:
232:                public void update(FlowEdgeDescriptor descriptor,
233:                        FlowScene scene) {
234:                }
235:
236:                public void setSourceAnchor(FlowEdgeDescriptor descriptor,
237:                        FlowScene scene, Anchor sourceAnchor) {
238:                    ConnectionWidget widget = (ConnectionWidget) scene
239:                            .findWidget(descriptor);
240:                    widget.setSourceAnchor(sourceAnchor);
241:                }
242:
243:                public void setTargetAnchor(FlowEdgeDescriptor descriptor,
244:                        FlowScene scene, Anchor targetAnchor) {
245:                    ConnectionWidget widget = (ConnectionWidget) scene
246:                            .findWidget(descriptor);
247:                    widget.setTargetAnchor(targetAnchor);
248:                }
249:
250:                public boolean isSourceReconnectable(
251:                        FlowEdgeDescriptor descriptor) {
252:                    return false; // TODO - reconnecting source pin
253:                }
254:
255:                public boolean isTargetReconnectable(
256:                        FlowEdgeDescriptor descriptor) {
257:                    return true;
258:                }
259:
260:                public boolean isReplacement(FlowEdgeDescriptor descriptor,
261:                        FlowDescriptor replacementDescriptor,
262:                        boolean reconnectingSource) {
263:                    if (reconnectingSource)
264:                        return false; // TODO - reconnecting source pin
265:                    else
266:                        return MidpDocumentSupport
267:                                .isCreatableEventHandlerTo(replacementDescriptor != null ? replacementDescriptor
268:                                        .getRepresentedComponent()
269:                                        : null);
270:                }
271:
272:                public void setReplacement(FlowEdgeDescriptor descriptor,
273:                        FlowDescriptor replacementDescriptor,
274:                        boolean reconnectingSource) {
275:                    // TODO - reconnecting source pin
276:                    if (!reconnectingSource) {
277:                        DesignComponent eventSource = getSourceComponent();
278:                        if (eventSource != null)
279:                            MidpDocumentSupport
280:                                    .updateEventHandlerFromTarget(
281:                                            eventSource,
282:                                            replacementDescriptor != null ? replacementDescriptor
283:                                                    .getRepresentedComponent()
284:                                                    : null);
285:                    }
286:                }
287:
288:                public void edit(FlowDescriptor descriptor) {
289:                    Collection<? extends ActionsPresenter> presenters = descriptor
290:                            .getRepresentedComponent().getPresenters(
291:                                    ActionsPresenter.class);
292:                    for (ActionsPresenter presenter : presenters) {
293:                        for (Action action : presenter.getActions()) {
294:                            if (action instanceof  GoToSourceAction) {
295:                                if (action.isEnabled())
296:                                    action.actionPerformed(null);
297:                                return;
298:                            }
299:                        }
300:                    }
301:                }
302:
303:            }
304:
305:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.