Source Code Cross Referenced for GraphExpandProcessor.java in  » IDE-Netbeans » bpel » org » netbeans » modules » bpel » mapper » 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.mapper.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:
020:        package org.netbeans.modules.bpel.mapper.model;
021:
022:        import java.util.ArrayList;
023:        import java.util.Collections;
024:        import java.util.List;
025:        import java.util.Map;
026:        import javax.swing.tree.TreePath;
027:        import org.netbeans.modules.bpel.mapper.model.CopyToProcessor.CopyToForm;
028:        import org.netbeans.modules.bpel.mapper.multiview.BpelDesignContext;
029:        import org.netbeans.modules.bpel.mapper.tree.models.ConditionValueTreeModel;
030:        import org.netbeans.modules.bpel.mapper.tree.models.DateValueTreeModel;
031:        import org.netbeans.modules.bpel.mapper.tree.models.ForEachConditionsTreeModel;
032:        import org.netbeans.modules.bpel.mapper.tree.search.ResultNodeFinder;
033:        import org.netbeans.modules.bpel.mapper.tree.search.SimpleFinder;
034:        import org.netbeans.modules.bpel.mapper.tree.spi.MapperTcContext;
035:        import org.netbeans.modules.bpel.mapper.tree.spi.MapperTreeModel;
036:        import org.netbeans.modules.bpel.mapper.tree.spi.TreeItemFinder;
037:        import org.netbeans.modules.bpel.model.api.Assign;
038:        import org.netbeans.modules.bpel.model.api.BpelEntity;
039:        import org.netbeans.modules.bpel.model.api.BpelModel;
040:        import org.netbeans.modules.bpel.model.api.CompletionCondition;
041:        import org.netbeans.modules.bpel.model.api.Copy;
042:        import org.netbeans.modules.bpel.model.api.DeadlineExpression;
043:        import org.netbeans.modules.bpel.model.api.ElseIf;
044:        import org.netbeans.modules.bpel.model.api.FinalCounterValue;
045:        import org.netbeans.modules.bpel.model.api.For;
046:        import org.netbeans.modules.bpel.model.api.ForEach;
047:        import org.netbeans.modules.bpel.model.api.If;
048:        import org.netbeans.modules.bpel.model.api.OnAlarmEvent;
049:        import org.netbeans.modules.bpel.model.api.OnAlarmPick;
050:        import org.netbeans.modules.bpel.model.api.RepeatUntil;
051:        import org.netbeans.modules.bpel.model.api.Process;
052:        import org.netbeans.modules.bpel.model.api.StartCounterValue;
053:        import org.netbeans.modules.bpel.model.api.TimeEvent;
054:        import org.netbeans.modules.bpel.model.api.TimeEventHolder;
055:        import org.netbeans.modules.bpel.model.api.To;
056:        import org.netbeans.modules.bpel.model.api.Wait;
057:        import org.netbeans.modules.bpel.model.api.While;
058:        import org.netbeans.modules.soa.mappercore.LeftTree;
059:        import org.netbeans.modules.soa.mappercore.Mapper;
060:        import org.netbeans.modules.soa.mappercore.model.Graph;
061:        import org.netbeans.modules.soa.mappercore.model.Link;
062:        import org.netbeans.modules.soa.mappercore.model.MapperModel;
063:        import org.netbeans.modules.soa.mappercore.model.SourcePin;
064:        import org.netbeans.modules.soa.mappercore.model.TreeSourcePin;
065:
066:        /**
067:         *
068:         * @author supernikita
069:         */
070:        public class GraphExpandProcessor {
071:
072:            // TODO m add graphEntity support
073:            public static void expandGraph(MapperTcContext mapperTcContext,
074:                    BpelDesignContext context) {
075:                //
076:                Mapper mapper = mapperTcContext.getMapper();
077:                MapperModel mModel = mapper.getModel();
078:                //
079:                BpelEntity contextEntity = context.getContextEntity();
080:                expandVariablesNode(mapper, contextEntity.getBpelModel(), true,
081:                        true);
082:                //
083:                BpelEntity graphEntity = context.getGraphEntity();
084:                List<TreePath> tPathList = getTargetPathes(mapperTcContext,
085:                        graphEntity);
086:                boolean expandAll = contextEntity instanceof  ForEach;
087:                boolean isFirst = true;
088:                for (TreePath tPath : tPathList) {
089:                    //
090:                    Graph graph = ((BpelMapperModel) mModel).getGraphsInside(
091:                            null).get(tPath);
092:                    //
093:                    mapper.setExpandedState(tPath, true);
094:                    if (graph != null) {
095:                        mapper.setExpandedGraphState(tPath, true);
096:                    }
097:                    //
098:                    if (expandAll || isFirst) {
099:                        mapper.setSelected(tPath);
100:                        //
101:                        if (graph != null) {
102:                            mapper.getRightTree().scrollRectToVisible(
103:                                    graph.getBounds());
104:                            //
105:                            // Expand source tree
106:                            LeftTree leftTree = mapper.getLeftTree();
107:                            expandIngoingLinks(graph, leftTree);
108:                        }
109:                    }
110:                    //
111:                    isFirst = false;
112:                }
113:            }
114:
115:            public static void expandAllGraphs(Mapper mapper, MapperModel mModel) {
116:                Map<TreePath, Graph> graphMap = ((BpelMapperModel) mModel)
117:                        .getGraphsInside(null);
118:                for (TreePath tPath : graphMap.keySet()) {
119:                    Graph graph = graphMap.get(tPath);
120:                    //
121:                    mapper.setExpandedState(tPath, true);
122:                    if (graph != null) {
123:                        mapper.setExpandedGraphState(tPath, true);
124:                        //
125:                        // Expand source tree
126:                        LeftTree leftTree = mapper.getLeftTree();
127:                        expandIngoingLinks(graph, leftTree);
128:                    }
129:                }
130:            }
131:
132:            public static void selectGraph(Mapper mapper, TreePath tPath,
133:                    Graph graph) {
134:                //
135:                mapper.setSelected(tPath);
136:                //
137:                if (graph != null) {
138:                    mapper.getRightTree()
139:                            .scrollRectToVisible(graph.getBounds());
140:                }
141:            }
142:
143:            /**
144:             * Returns the list of TreePath for the specified entity which have to be 
145:             * expanded.
146:             * @param mapperTcContext
147:             * @param bpelEntity
148:             * @return
149:             */
150:            private static List<TreePath> getTargetPathes(
151:                    MapperTcContext mapperTcContext, BpelEntity bpelEntity) {
152:                //
153:                Mapper mapper = mapperTcContext.getMapper();
154:                MapperModel mm = mapper.getModel();
155:                assert mm instanceof  BpelMapperModel;
156:                BpelMapperModel mModel = ((BpelMapperModel) mm);
157:                //
158:                ArrayList<TreePath> result = new ArrayList<TreePath>();
159:                //
160:                Class<? extends BpelEntity> entityType = bpelEntity
161:                        .getElementType();
162:                if (entityType == Copy.class) {
163:                    Copy copy = (Copy) bpelEntity;
164:                    // Expand target tree
165:                    To copyTo = copy.getTo();
166:                    CopyToForm form = CopyToProcessor.getCopyToForm(copyTo);
167:                    ArrayList<TreeItemFinder> toNodeFinderList = CopyToProcessor
168:                            .constructFindersList(form, copy, copyTo, null);
169:                    TreePath targetTreePath = mModel.getRightTreeModel()
170:                            .findFirstNode(toNodeFinderList);
171:                    if (targetTreePath != null) {
172:                        result.add(targetTreePath);
173:                    }
174:                } else if (entityType == Assign.class) {
175:                    Assign assign = (Assign) bpelEntity;
176:                    List<Copy> copyList = assign.getChildren(Copy.class);
177:                    if (!copyList.isEmpty()) {
178:                        Copy firstCopy = copyList.iterator().next();
179:                        return getTargetPathes(mapperTcContext, firstCopy);
180:                    }
181:                    //
182:                } else if (entityType == Wait.class
183:                        || entityType == OnAlarmPick.class
184:                        || entityType == OnAlarmEvent.class) {
185:                    //
186:                    TimeEventHolder timeEH = (TimeEventHolder) bpelEntity;
187:                    TimeEvent timeEvent = timeEH.getTimeEvent();
188:                    if (timeEvent != null) {
189:                        String targetNodeName = null;
190:                        if (timeEvent instanceof  For) {
191:                            targetNodeName = DateValueTreeModel.DURATION_CONDITION;
192:                        } else if (timeEvent instanceof  DeadlineExpression) {
193:                            targetNodeName = DateValueTreeModel.DEADLINE_CONDITION;
194:                        }
195:                        //
196:                        List<TreeItemFinder> finderList = Collections
197:                                .singletonList((TreeItemFinder) new ResultNodeFinder(
198:                                        targetNodeName));
199:                        TreePath targetTreePath = mModel.getRightTreeModel()
200:                                .findFirstNode(finderList);
201:                        if (targetTreePath != null) {
202:                            result.add(targetTreePath);
203:                        }
204:                    }
205:                    //
206:                } else if (entityType == If.class || entityType == ElseIf.class
207:                        || entityType == While.class
208:                        || entityType == RepeatUntil.class) {
209:                    //
210:                    List<TreeItemFinder> finderList = Collections
211:                            .singletonList((TreeItemFinder) new ResultNodeFinder(
212:                                    ConditionValueTreeModel.BOOLEAN_CONDITION));
213:                    TreePath targetTreePath = mModel.getRightTreeModel()
214:                            .findFirstNode(finderList);
215:                    if (targetTreePath != null) {
216:                        result.add(targetTreePath);
217:                    }
218:                } else if (entityType == ForEach.class) {
219:                    //
220:                    List<TreeItemFinder> finderList = Collections
221:                            .singletonList((TreeItemFinder) new ResultNodeFinder(
222:                                    ForEachConditionsTreeModel.START_VALUE));
223:                    TreePath targetTreePath = mModel.getRightTreeModel()
224:                            .findFirstNode(finderList);
225:                    if (targetTreePath != null) {
226:                        result.add(targetTreePath);
227:                    }
228:                    //
229:                    finderList = Collections
230:                            .singletonList((TreeItemFinder) new ResultNodeFinder(
231:                                    ForEachConditionsTreeModel.FINAL_VALUE));
232:                    targetTreePath = mModel.getRightTreeModel().findFirstNode(
233:                            finderList);
234:                    if (targetTreePath != null) {
235:                        result.add(targetTreePath);
236:                    }
237:                    //
238:                    finderList = Collections
239:                            .singletonList((TreeItemFinder) new ResultNodeFinder(
240:                                    ForEachConditionsTreeModel.COMPLETION_CONDITION));
241:                    targetTreePath = mModel.getRightTreeModel().findFirstNode(
242:                            finderList);
243:                    if (targetTreePath != null) {
244:                        result.add(targetTreePath);
245:                    }
246:                } else if (entityType == StartCounterValue.class) {
247:                    List<TreeItemFinder> finderList = Collections
248:                            .singletonList((TreeItemFinder) new ResultNodeFinder(
249:                                    ForEachConditionsTreeModel.START_VALUE));
250:                    TreePath targetTreePath = mModel.getRightTreeModel()
251:                            .findFirstNode(finderList);
252:                    if (targetTreePath != null) {
253:                        result.add(targetTreePath);
254:                    }
255:                } else if (entityType == FinalCounterValue.class) {
256:                    List<TreeItemFinder> finderList = Collections
257:                            .singletonList((TreeItemFinder) new ResultNodeFinder(
258:                                    ForEachConditionsTreeModel.FINAL_VALUE));
259:                    TreePath targetTreePath = mModel.getRightTreeModel()
260:                            .findFirstNode(finderList);
261:                    if (targetTreePath != null) {
262:                        result.add(targetTreePath);
263:                    }
264:                } else if (entityType == CompletionCondition.class) {
265:                    List<TreeItemFinder> finderList = Collections
266:                            .singletonList((TreeItemFinder) new ResultNodeFinder(
267:                                    ForEachConditionsTreeModel.COMPLETION_CONDITION));
268:                    TreePath targetTreePath = mModel.getRightTreeModel()
269:                            .findFirstNode(finderList);
270:                    if (targetTreePath != null) {
271:                        result.add(targetTreePath);
272:                    }
273:                }
274:                //
275:                return result;
276:            }
277:
278:            /**
279:             * Expands all tree nodes in the source tree to which ingoing links 
280:             * of the graph are connected. 
281:             * @param graph
282:             * @param leftTree
283:             */
284:            public static void expandIngoingLinks(Graph graph, LeftTree leftTree) {
285:                List<Link> ingoingLinks = graph.getIngoingLinks();
286:                for (Link link : ingoingLinks) {
287:                    SourcePin sourcePin = link.getSource();
288:                    if (sourcePin != null && sourcePin instanceof  TreeSourcePin) {
289:                        TreePath sourcePath = ((TreeSourcePin) sourcePin)
290:                                .getTreePath();
291:                        if (sourcePath != null) {
292:                            leftTree.expandPath(sourcePath.getParentPath());
293:                        }
294:                    }
295:                }
296:            }
297:
298:            /**
299:             * Expands the tree node "Variables" in the source and (or) the target trees.
300:             * @param mapper
301:             * @param bpelModel
302:             * @param leftTree
303:             * @param rightTree
304:             */
305:            public static void expandVariablesNode(Mapper mapper,
306:                    final BpelModel bpelModel, boolean leftTree,
307:                    boolean rightTree) {
308:                //
309:                TreeItemFinder finder = new SimpleFinder() {
310:                    protected boolean isFit(Object treeItem) {
311:                        if (treeItem instanceof  Process
312:                                && bpelModel.getProcess().equals(treeItem)) {
313:                            // found!!!
314:                            return true;
315:                        }
316:                        return false;
317:                    }
318:
319:                    protected boolean drillDeeper(Object treeItem) {
320:                        if (treeItem == MapperTreeModel.TREE_ROOT) {
321:                            return true;
322:                        }
323:                        return false;
324:                    }
325:                };
326:                //
327:                MapperModel mm = mapper.getModel();
328:                assert mm instanceof  BpelMapperModel;
329:                BpelMapperModel mModel = (BpelMapperModel) mm;
330:                //
331:                if (leftTree) {
332:                    TreePath tPath = mModel.getLeftTreeModel().findFirstNode(
333:                            Collections.singletonList(finder));
334:                    if (tPath != null) {
335:                        mapper.getLeftTree().expandPath(tPath);
336:                    }
337:                }
338:                //
339:                if (rightTree) {
340:                    TreePath tPath = mModel.getRightTreeModel().findFirstNode(
341:                            Collections.singletonList(finder));
342:                    if (tPath != null) {
343:                        mapper.setExpandedGraphState(tPath, true);
344:                    }
345:                }
346:                //
347:
348:            }
349:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.