Source Code Cross Referenced for BasePanelessGraphConsolePageContext.java in  » Workflow-Engines » JFolder » org » jfolder » console » base » context » 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 » JFolder » org.jfolder.console.base.context 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JFolder, Copyright 2001-2006 Gary Steinmetz
003:         *
004:         * Distributable under LGPL license.
005:         * See terms of license at gnu.org.
006:         */
007:
008:        package org.jfolder.console.base.context;
009:
010:        //base classes
011:        import java.io.IOException;
012:        import java.util.ArrayList;
013:        import java.util.HashMap;
014:
015:        //project specific classes
016:        import org.jfolder.common.tagging.ConceptTagCharacteristic;
017:        import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
018:        import org.jfolder.common.tagging.ConceptTagPreferences;
019:        import org.jfolder.common.tagging.RootConceptTagHolder;
020:        import org.jfolder.common.utils.misc.CommonSeparators;
021:        import org.jfolder.common.utils.xml.XMLHelper;
022:        import org.jfolder.console.base.ConsolePageContext;
023:        import org.jfolder.console.base.NamesForSubCpc;
024:        import org.jfolder.console.base.TransitionDescriptor;
025:        import org.jfolder.workflow.model.template.v1.RootV1WorkflowTemplateTag;
026:        import org.jfolder.workflow.model.template.v1.StartWorkflowTemplateTag;
027:        import org.jfolder.workflow.model.template.v1.StateWorkflowTemplateTag;
028:        import org.jfolder.workflow.model.template.v1.StopWorkflowTemplateTag;
029:
030:        //other classes
031:
032:        public class BasePanelessGraphConsolePageContext extends
033:                ConsolePageContext {
034:
035:            private String fromPage = null;
036:            //private String handleExtension = null;
037:            private String aliasHandle = null;
038:
039:            private BasePanelessGraphConsolePageContext(ConsolePageContext inCpc) {
040:
041:                super (inCpc, NamesForSubCpc.getBasePanelessGraphCpcName());
042:                this .fromPage = inCpc.getFromPage();
043:                //this.handleExtension = inCpc.getHandleExtension();
044:                this .aliasHandle = inCpc.getAliasHandle();
045:            }
046:
047:            public final static BasePanelessGraphConsolePageContext newInstance(
048:                    ConsolePageContext inCpc) throws IOException {
049:
050:                BasePanelessGraphConsolePageContext outValue = null;
051:
052:                if (inCpc.isSubConsolePageContextPresent(NamesForSubCpc
053:                        .getBasePanelessGraphCpcName())) {
054:                    //
055:                    Object o = inCpc.getSubConsolePageContext(NamesForSubCpc
056:                            .getBasePanelessGraphCpcName());
057:                    outValue = (BasePanelessGraphConsolePageContext) o;
058:                } else {
059:                    outValue = new BasePanelessGraphConsolePageContext(inCpc);
060:                    inCpc.registerSubConsolePageContext(NamesForSubCpc
061:                            .getBasePanelessGraphCpcName(), outValue);
062:                }
063:
064:                outValue.copyFromParent(inCpc);
065:                outValue.createConsolePage(inCpc.getWriter(), inCpc
066:                        .getPageSetupContext());
067:
068:                return outValue;
069:            }
070:
071:            public String getFromPage() {
072:                return this .fromPage;
073:            }
074:
075:            //public String getHandleExtension() {
076:            //    return this.handleExtension;
077:            //}
078:
079:            public String getAliasHandle() {
080:                return this .aliasHandle;
081:            }
082:
083:            protected void renderConsolePage() throws IOException {
084:
085:                final int TRANSITION_THICKNESS = 11;
086:
087:                //startCommonPage();
088:
089:                //simpleAndPrint("GraphPage");
090:
091:                //
092:                RootConceptTagHolder rcth = getConsolePageSession()
093:                        .getCurrentApplicationRootHolder();
094:                ConceptTagPreferences ctp = rcth.getPreferences();
095:                ConceptTagCharacteristicHolder rootCtcharh = rcth
096:                        .getRootCharacteristicHolder();
097:                ConceptTagCharacteristic rootCtchar = rootCtcharh
098:                        .getCharacteristic(ctp.getRootConstraint());
099:
100:                ArrayList components = new ArrayList();
101:                String componentNames = "";
102:
103:                ArrayList transitions = new ArrayList();
104:                HashMap transitionCount = new HashMap();
105:
106:                int maxX = 0;
107:                int maxY = 0;
108:                HashMap nodeX = new HashMap();
109:                HashMap nodeY = new HashMap();
110:
111:                final int SIDE_X = 100;
112:                final int SIDE_Y = 50;
113:
114:                //MiscHelper.println("GraphContext,rootTc = " + rootTc);
115:
116:                Object o = rootCtchar.getValueAsHolder(0, null).getConceptTag();
117:                RootV1WorkflowTemplateTag pmt = (RootV1WorkflowTemplateTag) o;
118:
119:                for (int i = 0; i < pmt.getStartCount(); i++) {
120:
121:                    StartWorkflowTemplateTag nextStart = pmt.getStart(i);
122:
123:                    if (nextStart.isXCordValid() && nextStart.isYCordValid()) {
124:                        ArrayList al = new ArrayList();
125:                        al.add(nextStart.getName());
126:                        al.add("#00BB00");
127:                        al.add(new Integer(nextStart.getXCord()));
128:                        al.add(new Integer(nextStart.getYCord()));
129:                        al.add("root$0$starts$" + i);
130:                        components.add(al);
131:                        componentNames = componentNames + nextStart.getName()
132:                                + ",";
133:
134:                        if (nextStart.getXCord() > maxX) {
135:                            maxX = nextStart.getXCord();
136:                        }
137:                        if (nextStart.getYCord() > maxY) {
138:                            maxY = nextStart.getYCord();
139:                        }
140:
141:                        nodeX.put(nextStart.getName(), new Integer(nextStart
142:                                .getXCord()));
143:                        nodeY.put(nextStart.getName(), new Integer(nextStart
144:                                .getYCord()));
145:
146:                        ArrayList nextTransition = new ArrayList();
147:                        //startNode, endNode, branchNumber, transitionNumber
148:                        //defaultTransition
149:                        nextTransition.add(nextStart.getName());
150:                        nextTransition
151:                                .add(nextStart.getTransitionDestination());
152:                        nextTransition.add(new Integer(0));
153:                        nextTransition.add(new Integer(0));
154:                        transitions.add(nextTransition);
155:
156:                        for (int j = 0; j < nextStart.getIfTransitionCount(); j++) {
157:                            nextTransition = new ArrayList();
158:                            nextTransition.add(nextStart.getName());
159:                            nextTransition.add(nextStart
160:                                    .getIfTransitionDestination(j));
161:                            nextTransition.add(new Integer(0));
162:                            nextTransition.add(new Integer(j + 1));
163:                            transitions.add(nextTransition);
164:                        }
165:
166:                        for (int j = 0; j < nextStart.getBranchCount(); j++) {
167:                            nextTransition = new ArrayList();
168:                            nextTransition.add(nextStart.getName());
169:                            nextTransition.add(nextStart
170:                                    .getBranchTransitionDestination(j));
171:                            nextTransition.add(new Integer(j + 1));
172:                            nextTransition.add(new Integer(0));
173:                            transitions.add(nextTransition);
174:
175:                            for (int k = 0; k < nextStart
176:                                    .getBranchIfTransitionCount(j); k++) {
177:                                nextTransition = new ArrayList();
178:                                nextTransition.add(nextStart.getName());
179:                                nextTransition
180:                                        .add(nextStart
181:                                                .getBranchIfTransitionDestination(
182:                                                        j, k));
183:                                nextTransition.add(new Integer(j + 1));
184:                                nextTransition.add(new Integer(k + 1));
185:                                transitions.add(nextTransition);
186:                            }
187:                        }
188:
189:                        transitionCount
190:                                .put(nextStart.getName(), new Integer(0));
191:                    }
192:                }
193:
194:                //StatesTag states = pmt.getStates();
195:                for (int i = 0; i < pmt.getStateCount(); i++) {
196:                    StateWorkflowTemplateTag nextState = pmt.getState(i);
197:
198:                    if (nextState.isXCordValid() && nextState.isYCordValid()) {
199:                        ArrayList al = new ArrayList();
200:                        al.add(nextState.getName());
201:                        al.add("#3333BB");
202:                        al.add(new Integer(nextState.getXCord()));
203:                        al.add(new Integer(nextState.getYCord()));
204:                        al.add("root$0$states$" + i);
205:                        components.add(al);
206:                        componentNames = componentNames + nextState.getName()
207:                                + ",";
208:
209:                        if (nextState.getXCord() > maxX) {
210:                            maxX = nextState.getXCord();
211:                        }
212:                        if (nextState.getYCord() > maxY) {
213:                            maxY = nextState.getYCord();
214:                        }
215:
216:                        nodeX.put(nextState.getName(), new Integer(nextState
217:                                .getXCord()));
218:                        nodeY.put(nextState.getName(), new Integer(nextState
219:                                .getYCord()));
220:
221:                        ArrayList nextTransition = new ArrayList();
222:                        //startNode, endNode, branchNumber, transitionNumber
223:                        //defaultTransition
224:                        nextTransition.add(nextState.getName());
225:                        nextTransition
226:                                .add(nextState.getTransitionDestination());
227:                        nextTransition.add(new Integer(0));
228:                        nextTransition.add(new Integer(0));
229:                        transitions.add(nextTransition);
230:
231:                        for (int j = 0; j < nextState.getIfTransitionCount(); j++) {
232:                            nextTransition = new ArrayList();
233:                            nextTransition.add(nextState.getName());
234:                            nextTransition.add(nextState
235:                                    .getIfTransitionDestination(j));
236:                            nextTransition.add(new Integer(0));
237:                            nextTransition.add(new Integer(j + 1));
238:                            transitions.add(nextTransition);
239:                        }
240:
241:                        for (int j = 0; j < nextState.getBranchCount(); j++) {
242:                            nextTransition = new ArrayList();
243:                            nextTransition.add(nextState.getName());
244:                            nextTransition.add(nextState
245:                                    .getBranchTransitionDestination(j));
246:                            nextTransition.add(new Integer(j + 1));
247:                            nextTransition.add(new Integer(0));
248:                            transitions.add(nextTransition);
249:
250:                            for (int k = 0; k < nextState
251:                                    .getBranchIfTransitionCount(j); k++) {
252:                                nextTransition = new ArrayList();
253:                                nextTransition.add(nextState.getName());
254:                                nextTransition
255:                                        .add(nextState
256:                                                .getBranchIfTransitionDestination(
257:                                                        j, k));
258:                                nextTransition.add(new Integer(j + 1));
259:                                nextTransition.add(new Integer(k + 1));
260:                                transitions.add(nextTransition);
261:                            }
262:                        }
263:
264:                        transitionCount
265:                                .put(nextState.getName(), new Integer(0));
266:                    }
267:                }
268:
269:                for (int i = 0; i < pmt.getStopCount(); i++) {
270:                    StopWorkflowTemplateTag nextStop = pmt.getStop(i);
271:                    if (nextStop.isXCordValid() && nextStop.isYCordValid()) {
272:                        ArrayList al = new ArrayList();
273:                        al.add(nextStop.getName());
274:                        al.add("#BB0000");
275:                        al.add(new Integer(nextStop.getXCord()));
276:                        al.add(new Integer(nextStop.getYCord()));
277:                        al.add("root$0$stops$" + i);
278:                        components.add(al);
279:                        componentNames = componentNames + nextStop.getName()
280:                                + ",";
281:
282:                        if (nextStop.getXCord() > maxX) {
283:                            maxX = nextStop.getXCord();
284:                        }
285:                        if (nextStop.getYCord() > maxY) {
286:                            maxY = nextStop.getYCord();
287:                        }
288:
289:                        nodeX.put(nextStop.getName(), new Integer(nextStop
290:                                .getXCord()));
291:                        nodeY.put(nextStop.getName(), new Integer(nextStop
292:                                .getYCord()));
293:
294:                        transitionCount.put(nextStop.getName(), new Integer(0));
295:                    }
296:                }
297:
298:                for (int i = 0; i < transitions.size(); i++) {
299:                    ArrayList nextTransition = (ArrayList) transitions.get(i);
300:                    componentNames = componentNames + nextTransition.get(0)
301:                            + "-" + nextTransition.get(1) + ",";
302:                }
303:
304:                //String form = "top."
305:                //    + ConsolePageParameters.SECTION_TAG + ".document."
306:                //    + ConsolePageParameters.ACTION_FORM;
307:
308:                //
309:                simpleAndPrint("<!-- Starts, States, and Stops -->");
310:                simpleAndPrint("<!-- enclosing table ensures "
311:                        + "no node has a side cut of by frame -->");
312:                printAndIndent("<table height=\""
313:                        + (maxY + (2 * SIDE_Y))
314:                        + "\" width=\""
315:                        + (maxX + (2 * SIDE_X))
316:                        + "\" style=\"z-index: "
317:                        + CommonSeparators.Z_INDEX__WORKFLOW_TEMPLATE_TRANSITION
318:                        + "; display: 'block'; position: 'absolute';"
319:                        + " border-width: 1; border-color: '#FFFFFF';"
320:                        + " border-style: 'solid'; top='0px'; left='0px';\">");
321:                printAndIndent("<tr>");
322:                printAndIndent("<td>");
323:                simpleAndPrint(XMLHelper.NBSP_XML);
324:                revertAndPrint("</td>");
325:                revertAndPrint("</tr>");
326:                revertAndPrint("</table>");
327:                //
328:                for (int i = 0; i < transitions.size(); i++) {
329:                    ArrayList nextTransition = (ArrayList) transitions.get(i);
330:                    String sourceNode = (String) nextTransition.get(0);
331:                    String destNode = (String) nextTransition.get(1);
332:
333:                    Integer branchNum = (Integer) nextTransition.get(2);
334:                    Integer transNum = (Integer) nextTransition.get(3);
335:
336:                    if (transitionCount.containsKey(sourceNode)
337:                            && transitionCount.containsKey(destNode)) {
338:
339:                        int sourceCount = ((Integer) transitionCount
340:                                .get(sourceNode)).intValue();
341:                        int destCount = ((Integer) transitionCount
342:                                .get(destNode)).intValue();
343:                        //update transition count at each node
344:                        transitionCount.put(sourceNode, new Integer(
345:                                sourceCount + 1));
346:                        transitionCount.put(destNode,
347:                                new Integer(destCount + 1));
348:
349:                        TransitionDescriptor td = new TransitionDescriptor();
350:                        td.setSourceNode(sourceNode);
351:                        td.setDestinationNode(destNode);
352:                        td.setBranchNumber(branchNum.intValue());
353:                        td.setTransitionNumber(transNum.intValue());
354:                        td.setSideLength(SIDE_X);
355:                        td.setSideHeight(SIDE_Y);
356:                        td.setTransitionThickness(TRANSITION_THICKNESS);
357:                        //td.setSourceDisplacement(
358:                        //    cs.getTransitionDisplacementForGraph(sourceCount));
359:                        //td.setDestinationDisplacement(
360:                        //    cs.getTransitionDisplacementForGraph(destCount));
361:                        td.setSourceX(((Integer) nodeX.get(sourceNode))
362:                                .intValue());
363:                        td.setSourceY(((Integer) nodeY.get(sourceNode))
364:                                .intValue());
365:
366:                        td.setDestinationX(((Integer) nodeX.get(destNode))
367:                                .intValue());
368:                        td.setDestinationY(((Integer) nodeY.get(destNode))
369:                                .intValue());
370:
371:                        td.createTable(this );
372:                    }
373:                }
374:                //
375:                //<!-- node list here -->
376:                for (int i = 0; i < components.size(); i++) {
377:                    ArrayList nextComponent = (ArrayList) components.get(i);
378:                    String compName = (String) nextComponent.get(0);
379:                    String compColor = (String) nextComponent.get(1);
380:                    Integer compX = (Integer) nextComponent.get(2);
381:                    Integer compY = (Integer) nextComponent.get(3);
382:
383:                    printAndIndent("<table border=\"1\" id=\""
384:                            + compName
385:                            + "\" height=\""
386:                            + SIDE_Y
387:                            + "\" onmousedown=\"down(this, '"
388:                            + (String) nextComponent.get(4)
389:                            + "', event)\" onmouseup=\"up(this)\" width=\""
390:                            + SIDE_X
391:                            + "\" style=\"pixelTop: ; pixelLeft: ; z-index: "
392:                            + CommonSeparators.Z_INDEX__WORKFLOW_TEMPLATE_NODE
393:                            + ";"
394:                            + " display: 'block'; position: absolute; border-width: 1;"
395:                            + " border-color: " + compColor
396:                            + "; border-style: solid; top: "
397:                            + (compY.intValue() + (SIDE_Y / 2)) + "px; left: "
398:                            + (compX.intValue() + (SIDE_X / 2)) + "px;\">");
399:                    printAndIndent("<tr>");
400:                    printAndIndent("<td height=\""
401:                            + (SIDE_Y - 10)
402:                            + "\" width=\""
403:                            + (SIDE_X - 10)
404:                            + "\" align=\"center\" style=\"border-width: 1; border-color: "
405:                            + compColor
406:                            + "; border-style: solid; background-color: "
407:                            + compColor + ";\">");
408:                    simpleAndPrint("<b>" + compName + "</b>");
409:                    revertAndPrint("</td>");
410:                    revertAndPrint("</tr>");
411:                    revertAndPrint("</table>");
412:                }
413:                //
414:
415:                //endCommonPage();
416:            }
417:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.