Source Code Cross Referenced for DiagramModel.java in  » IDE-Netbeans » bpel » org » netbeans » modules » bpel » design » model » 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 » bpel » org.netbeans.modules.bpel.design.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms of the Common Development
003:         * and Distribution License (the License). You may not use this file except in
004:         * compliance with the License.
005:         * 
006:         * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007:         * or http://www.netbeans.org/cddl.txt.
008:         * 
009:         * When distributing Covered Code, include this CDDL Header Notice in each file
010:         * and include the License file at http://www.netbeans.org/cddl.txt.
011:         * If applicable, add the following below the CDDL Header, with the fields
012:         * enclosed by brackets [] replaced by your own identifying information:
013:         * "Portions Copyrighted [year] [name of copyright owner]"
014:         * 
015:         * The Original Software is NetBeans. The Initial Developer of the Original
016:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017:         * Microsystems, Inc. All Rights Reserved.
018:         */
019:        package org.netbeans.modules.bpel.design.model;
020:
021:        import java.util.ArrayList;
022:        import java.util.List;
023:        import org.netbeans.modules.bpel.design.model.patterns.CollapsedPattern;
024:        import org.netbeans.modules.bpel.design.model.patterns.ForEachPattern;
025:        import org.netbeans.modules.bpel.design.model.patterns.OnEventPattern;
026:        import org.netbeans.modules.bpel.design.model.patterns.PartnerLinksPattern;
027:        import org.netbeans.modules.bpel.design.model.patterns.RepeatUntilPattern;
028:        import org.netbeans.modules.bpel.design.model.patterns.TerminationHandlerPattern;
029:        import org.netbeans.modules.bpel.design.model.patterns.UnsupportedPattern;
030:        import org.netbeans.modules.bpel.model.api.Activity;
031:        import org.netbeans.modules.bpel.model.api.Assign;
032:        import org.netbeans.modules.bpel.model.api.BpelEntity;
033:        import org.netbeans.modules.bpel.model.api.BpelModel;
034:        import org.netbeans.modules.bpel.model.api.Catch;
035:        import org.netbeans.modules.bpel.model.api.CompensatableActivityHolder;
036:        import org.netbeans.modules.bpel.model.api.Compensate;
037:        import org.netbeans.modules.bpel.model.api.CompensationHandler;
038:        import org.netbeans.modules.bpel.model.api.Empty;
039:        import org.netbeans.modules.bpel.model.api.EventHandlers;
040:        import org.netbeans.modules.bpel.model.api.Exit;
041:        import org.netbeans.modules.bpel.model.api.FaultHandlers;
042:        import org.netbeans.modules.bpel.model.api.Flow;
043:        import org.netbeans.modules.bpel.model.api.Invoke;
044:        import org.netbeans.modules.bpel.model.api.OnAlarmEvent;
045:        import org.netbeans.modules.bpel.model.api.OnAlarmPick;
046:        import org.netbeans.modules.bpel.model.api.OnEvent;
047:        import org.netbeans.modules.bpel.model.api.OnMessage;
048:        import org.netbeans.modules.bpel.model.api.PartnerLink;
049:        import org.netbeans.modules.bpel.model.api.PartnerLinkContainer;
050:        import org.netbeans.modules.bpel.model.api.Pick;
051:        import org.netbeans.modules.bpel.model.api.Process;
052:        import org.netbeans.modules.bpel.model.api.Receive;
053:        import org.netbeans.modules.bpel.model.api.RepeatUntil;
054:        import org.netbeans.modules.bpel.model.api.Reply;
055:        import org.netbeans.modules.bpel.model.api.Scope;
056:        import org.netbeans.modules.bpel.model.api.Sequence;
057:        import org.netbeans.modules.bpel.model.api.TerminationHandler;
058:        import org.netbeans.modules.bpel.model.api.Throw;
059:        import org.netbeans.modules.bpel.model.api.Wait;
060:        import org.netbeans.modules.bpel.model.api.While;
061:        import org.netbeans.modules.bpel.model.api.Else;
062:        import org.netbeans.modules.bpel.model.api.ElseIf;
063:        import org.netbeans.modules.bpel.model.api.If;
064:
065:        import org.netbeans.modules.bpel.design.DesignView;
066:        import org.netbeans.modules.bpel.design.model.patterns.AssignPattern;
067:        import org.netbeans.modules.bpel.design.model.patterns.CatchAllPattern;
068:        import org.netbeans.modules.bpel.design.model.patterns.CatchPattern;
069:        import org.netbeans.modules.bpel.design.model.patterns.CompensatePattern;
070:        import org.netbeans.modules.bpel.design.model.patterns.CompensateScopePattern;
071:        import org.netbeans.modules.bpel.design.model.patterns.CompensationHandlerPattern;
072:        import org.netbeans.modules.bpel.design.model.patterns.ElseIfPattern;
073:        import org.netbeans.modules.bpel.design.model.patterns.ElsePattern;
074:        import org.netbeans.modules.bpel.design.model.patterns.EmptyPattern;
075:        import org.netbeans.modules.bpel.design.model.patterns.EventHandlersPattern;
076:        import org.netbeans.modules.bpel.design.model.patterns.FaultHandlersPattern;
077:        import org.netbeans.modules.bpel.design.model.patterns.FlowPattern;
078:        import org.netbeans.modules.bpel.design.model.patterns.InvokePattern;
079:        import org.netbeans.modules.bpel.design.model.patterns.OnAlarmEventPattern;
080:        import org.netbeans.modules.bpel.design.model.patterns.OnAlarmPickPattern;
081:        import org.netbeans.modules.bpel.design.model.patterns.OnMessagePattern;
082:        import org.netbeans.modules.bpel.design.model.patterns.PartnerlinkPattern;
083:        import org.netbeans.modules.bpel.design.model.patterns.Pattern;
084:        import org.netbeans.modules.bpel.design.model.patterns.PickPattern;
085:        import org.netbeans.modules.bpel.design.model.patterns.ProcessPattern;
086:        import org.netbeans.modules.bpel.design.model.patterns.ReceivePattern;
087:        import org.netbeans.modules.bpel.design.model.patterns.ReplyPattern;
088:
089:        import org.netbeans.modules.bpel.design.model.patterns.ScopePattern;
090:        import org.netbeans.modules.bpel.design.model.patterns.SequencePattern;
091:        import org.netbeans.modules.bpel.design.model.patterns.ExitPattern;
092:        import org.netbeans.modules.bpel.design.model.patterns.IfPattern;
093:        import org.netbeans.modules.bpel.design.model.patterns.ImportPattern;
094:        import org.netbeans.modules.bpel.design.model.patterns.ThrowPattern;
095:        import org.netbeans.modules.bpel.design.model.patterns.WaitPattern;
096:        import org.netbeans.modules.bpel.design.model.patterns.WhilePattern;
097:        import org.netbeans.modules.bpel.design.model.patterns.ReThrowPattern;
098:        import org.netbeans.modules.bpel.model.api.CompensateScope;
099:        import org.netbeans.modules.bpel.model.api.ForEach;
100:        import org.netbeans.modules.bpel.model.api.Import;
101:        import org.netbeans.modules.bpel.model.api.ReThrow;
102:        import org.netbeans.modules.bpel.model.api.support.UniqueId;
103:        import org.netbeans.modules.xml.xam.ui.XAMUtils;
104:
105:        /**
106:         *
107:         * @author Alexey Yarmolenko
108:         */
109:        public class DiagramModel {
110:
111:            private DesignView view;
112:            private Pattern rootPattern;
113:            private ModelChangeHandler changeHandler;
114:            private Object patternKey = new Object();
115:            private Object collapsedKey = new Object();
116:            private ViewFilters filters = new ViewFilters();
117:            private BpelModel bpelModel;
118:
119:            public DiagramModel(DesignView view) {
120:                this .view = view;
121:
122:                changeHandler = new ModelChangeHandler(this );
123:
124:                bpelModel = view.getBPELModel();
125:
126:                if (LAST_USED_COLLAPSED_KEY != null) {
127:                    copyCollapsedState(bpelModel.getProcess(),
128:                            LAST_USED_COLLAPSED_KEY, collapsedKey);
129:                }
130:
131:                BpelModel model = view.getBPELModel();
132:
133:                model.addEntityChangeListener(changeHandler);
134:            }
135:
136:            public Pattern getRootPattern() {
137:                return rootPattern;
138:            }
139:
140:            public void setActivated() {
141:                LAST_USED_COLLAPSED_KEY = collapsedKey;
142:            }
143:
144:            public static boolean isVisualizable(BpelEntity o) {
145:                return (o instanceof  Process) || (o instanceof  Sequence)
146:                        || (o instanceof  If) || (o instanceof  ElseIf)
147:                        || (o instanceof  Else) || (o instanceof  ForEach)
148:                        || (o instanceof  Assign) || (o instanceof  Receive)
149:                        || (o instanceof  Reply) || (o instanceof  Invoke)
150:                        || (o instanceof  Flow) || (o instanceof  While)
151:                        || (o instanceof  RepeatUntil) || (o instanceof  Wait)
152:                        || (o instanceof  Exit) || (o instanceof  Throw)
153:                        || (o instanceof  Scope) || (o instanceof  Pick)
154:                        || (o instanceof  OnMessage) || (o instanceof  OnEvent)
155:                        || (o instanceof  OnAlarmPick) || (o instanceof  Empty)
156:                        || (o instanceof  OnAlarmEvent)
157:                        || (o instanceof  CompensationHandler)
158:                        || (o instanceof  TerminationHandler)
159:                        || (o instanceof  Compensate)
160:                        || (o instanceof  EventHandlers)
161:                        || (o instanceof  FaultHandlers) || (o instanceof  Catch)
162:                        || (o instanceof  CompensatableActivityHolder)
163:                        || (o instanceof  Activity)
164:                        || (o instanceof  PartnerLink) || (o instanceof  Import)
165:                        || (o instanceof  PartnerLinkContainer);
166:            }
167:
168:            public Pattern createPattern(BpelEntity o) {
169:                Pattern result = null;
170:
171:                if (isCollapsed(o)) {
172:                    if (o instanceof  PartnerLink) {
173:                        result = new PartnerlinkPattern(this , true);
174:                    } else {
175:                        result = new CollapsedPattern(this );
176:                    }
177:                } else if (o instanceof  Process) {
178:                    result = new ProcessPattern(this );
179:                } else if (o instanceof  Sequence) {
180:                    result = new SequencePattern(this );
181:                } else if (o instanceof  If) {
182:                    result = new IfPattern(this );
183:                } else if (o instanceof  ElseIf) {
184:                    result = new ElseIfPattern(this );
185:                } else if (o instanceof  Else) {
186:                    result = new ElsePattern(this );
187:                } else if (o instanceof  ForEach) {
188:                    result = new ForEachPattern(this );
189:                } else if (o instanceof  Assign) {
190:                    result = new AssignPattern(this );
191:                } else if (o instanceof  Receive) {
192:                    result = new ReceivePattern(this );
193:                } else if (o instanceof  Reply) {
194:                    result = new ReplyPattern(this );
195:                } else if (o instanceof  Invoke) {
196:                    result = new InvokePattern(this );
197:                } else if (o instanceof  Flow) {
198:                    result = new FlowPattern(this );
199:                } else if (o instanceof  While) {
200:                    result = new WhilePattern(this );
201:                } else if (o instanceof  RepeatUntil) {
202:                    result = new RepeatUntilPattern(this );
203:                } else if (o instanceof  Wait) {
204:                    result = new WaitPattern(this );
205:                } else if (o instanceof  Exit) {
206:                    result = new ExitPattern(this );
207:                } else if (o instanceof  Throw) {
208:                    result = new ThrowPattern(this );
209:                } else if (o instanceof  ReThrow) {
210:                    result = new ReThrowPattern(this );
211:                } else if (o instanceof  Scope) {
212:                    result = new ScopePattern(this );
213:                } else if (o instanceof  Pick) {
214:                    result = new PickPattern(this );
215:                } else if (o instanceof  OnMessage) {
216:                    result = new OnMessagePattern(this );
217:                } else if (o instanceof  OnEvent) {
218:                    result = new OnEventPattern(this );
219:                } else if (o instanceof  OnAlarmPick) {
220:                    result = new OnAlarmPickPattern(this );
221:                } else if (o instanceof  Empty) {
222:                    result = new EmptyPattern(this );
223:                } else if (o instanceof  OnAlarmEvent) {
224:                    result = new OnAlarmEventPattern(this );
225:                } else if (o instanceof  CompensationHandler) {
226:                    result = new CompensationHandlerPattern(this );
227:                } else if (o instanceof  TerminationHandler) {
228:                    result = new TerminationHandlerPattern(this );
229:                } else if (o instanceof  Compensate) {
230:                    result = new CompensatePattern(this );
231:                } else if (o instanceof  CompensateScope) {
232:                    result = new CompensateScopePattern(this );
233:                } else if (o instanceof  EventHandlers) {
234:                    result = new EventHandlersPattern(this );
235:                } else if (o instanceof  FaultHandlers) {
236:                    result = new FaultHandlersPattern(this );
237:                } else if (o instanceof  Catch) {
238:                    result = new CatchPattern(this );
239:                } else if (o instanceof  CompensatableActivityHolder) {
240:                    result = new CatchAllPattern(this );
241:                } else if (o instanceof  Activity) {
242:                    result = new UnsupportedPattern(this );
243:                } else if (o instanceof  PartnerLink) {
244:                    result = new PartnerlinkPattern(this );
245:                } else if (o instanceof  Import) {
246:                    result = new ImportPattern(this );
247:                } else if (o instanceof  PartnerLinkContainer) {
248:                    result = new PartnerLinksPattern(this );
249:                } else {
250:                    return null;
251:                }
252:
253:                o.setCookie(patternKey, result);
254:                result.initPattern(o);
255:                assert result != null;
256:                return result;
257:            }
258:
259:            public DesignView getView() {
260:                return view;
261:            }
262:
263:            public List<Pattern> getPartnerLinks(PartnerRole mode) {
264:                Process ps = view.getBPELModel().getProcess();
265:
266:                if (ps != null) {
267:
268:                    PartnerLinkContainer plc = ps.getPartnerLinkContainer();
269:
270:                    if (plc != null) {
271:
272:                        PartnerLinksPattern pls = (PartnerLinksPattern) getPattern(plc);
273:
274:                        if (pls != null) {
275:
276:                            return (mode == mode.CONSUMER) ? pls.getConsumers()
277:                                    : pls.getProviders();
278:                        }
279:                    }
280:                }
281:                return new ArrayList<Pattern>();
282:            }
283:
284:            public void expandToBeVisible(BpelEntity bpelEntity) {
285:                while ((bpelEntity != null) && !isVisualizable(bpelEntity)) {
286:                    bpelEntity = bpelEntity.getParent();
287:                }
288:
289:                if (bpelEntity == null) {
290:                    return;
291:                }
292:
293:                boolean somethingWasExpanded = false;
294:
295:                for (BpelEntity entity = bpelEntity.getParent(); entity != null; entity = entity
296:                        .getParent()) {
297:                    if (entity.getCookie(collapsedKey) != null) {
298:                        entity.removeCookie(collapsedKey);
299:                        somethingWasExpanded = true;
300:                    }
301:                }
302:
303:                if (somethingWasExpanded) {
304:                    view.reloadModel();
305:                    view.diagramChanged();
306:                    view.getDecorationManager().decorationChanged();
307:                    view.getValidationDecorationProvider().updateDecorations();
308:                }
309:            }
310:
311:            public void expandAll() {
312:                expandAll(bpelModel.getProcess());
313:            }
314:
315:            public void expandAll(BpelEntity root) {
316:                if (expandRecursively(root)) {
317:                    view.reloadModel();
318:                    view.diagramChanged();
319:                    view.getDecorationManager().decorationChanged();
320:                    view.getValidationDecorationProvider().updateDecorations();
321:                }
322:            }
323:
324:            private boolean expandRecursively(BpelEntity parent) {
325:                if (parent == null) {
326:                    return false;
327:                }
328:
329:                boolean somethingWasExpanded = false;
330:
331:                List<BpelEntity> children = parent.getChildren();
332:
333:                if (children != null) {
334:                    for (BpelEntity child : children) {
335:                        somethingWasExpanded = expandRecursively(child)
336:                                || somethingWasExpanded;
337:                    }
338:                }
339:
340:                if (parent.getCookie(collapsedKey) != null) {
341:                    parent.removeCookie(collapsedKey);
342:                    somethingWasExpanded = true;
343:                }
344:
345:                return somethingWasExpanded;
346:            }
347:
348:            public void setCollapsed(BpelEntity bpelEntity, boolean value) {
349:                if (value) {
350:                    bpelEntity.setCookie(collapsedKey, VALUE_COLLAPSED);
351:                } else {
352:                    if (bpelEntity.getCookie(collapsedKey) != null) {
353:                        bpelEntity.removeCookie(collapsedKey);
354:                    }
355:                }
356:
357:                view.reloadModel();
358:                view.diagramChanged();
359:                view.getDecorationManager().decorationChanged();
360:                view.getValidationDecorationProvider().updateDecorations();
361:            }
362:
363:            public boolean isCollapsed(BpelEntity bpelEntity) {
364:                Object collapsedValue = bpelEntity.getCookie(collapsedKey);
365:                return (collapsedValue != null);
366:            }
367:
368:            public Pattern getPattern(BpelEntity entity) {
369:                assert entity != null;
370:                return (Pattern) entity.getCookie(patternKey);
371:            }
372:
373:            public ViewFilters getFilters() {
374:                return filters;
375:            }
376:
377:            public void release() {
378:                bpelModel.removeEntityChangeListener(changeHandler);
379:
380:                //releasing the cookie key will trigger removal of all cookie references.
381:                patternKey = null;
382:                collapsedKey = null;
383:
384:                view = null;
385:
386:                rootPattern = null;
387:            }
388:
389:            public boolean isReadOnly() {
390:                return !XAMUtils.isWritable(bpelModel);
391:            }
392:
393:            public void setRootPattern(Pattern rootPattern) {
394:                this .rootPattern = rootPattern;
395:            }
396:
397:            public BpelEntity getEntity(UniqueId id) {
398:                return (id != null) ? bpelModel.getEntity(id) : null;
399:            }
400:
401:            private static void copyCollapsedState(BpelEntity bpelEntity,
402:                    Object oldCollapsedKey, Object newCollapsedKey) {
403:                if (bpelEntity == null) {
404:                    return;
405:                }
406:
407:                Object value = bpelEntity.getCookie(oldCollapsedKey);
408:
409:                if (value != null) {
410:                    bpelEntity.setCookie(newCollapsedKey, value);
411:                }
412:
413:                List<BpelEntity> children = bpelEntity.getChildren();
414:
415:                if (children != null) {
416:                    for (BpelEntity child : children) {
417:                        copyCollapsedState(child, oldCollapsedKey,
418:                                newCollapsedKey);
419:                    }
420:                }
421:            }
422:
423:            private static final Object VALUE_COLLAPSED = new Object();
424:            private static Object LAST_USED_COLLAPSED_KEY = null;
425:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.