Source Code Cross Referenced for BasePanelessRcthTextConsolePageContext.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.Collections;
014:        import java.util.HashMap;
015:        import java.util.Iterator;
016:        import org.w3c.dom.Document;
017:
018:        //project specific classes
019:        import org.jfolder.common.UnexpectedSystemException;
020:        import org.jfolder.common.tagging.ConceptTag;
021:        import org.jfolder.common.tagging.ConceptTagCharacteristic;
022:        import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
023:        import org.jfolder.common.tagging.ConceptTagPreferences;
024:        import org.jfolder.common.tagging.ConceptTagSetHolder;
025:        import org.jfolder.common.tagging.RootConceptTagHolder;
026:        import org.jfolder.common.utils.misc.MiscHelper;
027:        import org.jfolder.common.utils.xml.XMLHelper;
028:        import org.jfolder.common.web.template.ConsoleParameterContext;
029:        import org.jfolder.common.web.template.SubmitActionContext;
030:        import org.jfolder.common.web.template.SubmitActionParameters;
031:        import org.jfolder.console.base.ConsolePageContext;
032:        import org.jfolder.console.base.NamesForSubCpc;
033:
034:        //other classes
035:
036:        public class BasePanelessRcthTextConsolePageContext extends
037:                BaseSubPaneContentConsolePageContext {
038:
039:            private final static int INDENT = 5;
040:
041:            private String sectionId = null;
042:            private int baseToggleLinkListLength = 0;
043:
044:            private BasePanelessRcthTextConsolePageContext(
045:                    ConsolePageContext inCpc) {
046:
047:                super (inCpc, NamesForSubCpc.getBasePanelessRcthTextCpcName());
048:                setColumnWidth(200);
049:
050:                //this.height = inHeight;
051:            }
052:
053:            public final static BasePanelessRcthTextConsolePageContext newInstance(
054:                    ConsolePageContext inCpc) throws IOException {
055:
056:                BasePanelessRcthTextConsolePageContext outValue = null;
057:
058:                if (inCpc.isSubConsolePageContextPresent(NamesForSubCpc
059:                        .getBasePanelessRcthTextCpcName())) {
060:                    //
061:                    Object o = inCpc.getSubConsolePageContext(NamesForSubCpc
062:                            .getBasePanelessRcthTextCpcName());
063:                    outValue = (BasePanelessRcthTextConsolePageContext) o;
064:                } else {
065:                    outValue = new BasePanelessRcthTextConsolePageContext(inCpc);
066:                    inCpc.registerSubConsolePageContext(NamesForSubCpc
067:                            .getBasePanelessRcthTextCpcName(), outValue);
068:                }
069:
070:                outValue.copyFromParent(inCpc);
071:                outValue.createConsolePage(inCpc.getWriter(), inCpc
072:                        .getPageSetupContext());
073:
074:                return outValue;
075:            }
076:
077:            public String getSectionId() {
078:                return this .sectionId;
079:            }
080:
081:            public String getDownShiftToHighlightHandle() {
082:                throw UnexpectedSystemException.unknownState();
083:            }
084:
085:            protected void renderConsolePage() throws IOException {
086:
087:                this .sectionId = getConsolePageSession().getToggleLink();
088:
089:                RootConceptTagHolder rcth = getConsolePageSession()
090:                        .getCurrentApplicationRootHolder();
091:                //ConceptTagPreferences ctp = rcth.getPreferences();
092:                //ConceptTagConstraintHolder ctconh = rcth.getConstraintHolder();
093:
094:                //String unconSymbol = ctp.getUnconstrainedSymbol();
095:                //String rootConName = ctp.getRootConstraint();
096:                //ConceptTagConstraint ctcon = null;
097:                //if (!rootConName.equals(unconSymbol)) {
098:                //    ctcon = ctconh.getConstraint(rootConName);
099:                //}
100:                //else {
101:                //    ctcon = ctconh.getUndefinedConstraint();
102:                //}
103:
104:                getConsolePageSession().pushToggleLinkTextBase();
105:                this .baseToggleLinkListLength = getConsolePageSession()
106:                        .getToggleLinkAsArrayList().size();
107:                //
108:                //
109:                //getConsolePageSession().registerCommonStem(
110:                //    getConsolePageSession().getToggleLink());
111:                //
112:                //
113:                //getConsolePageSession().pushToggleLink(ctp.getRootConstraint());
114:                //getConsolePageSession().pushToggleLink("0");
115:                //
116:                //
117:                //addDefaultTreeBranch(getConsolePageSession().getToggleLink());
118:                //
119:                Document rcthDoc = rcth.getXMLRepresentationAsDocument();
120:                HashMap namespacesToPrefixes = XMLHelper
121:                        .initializeNameSpaceNames(rcthDoc, new HashMap());
122:                //namespacesToPrefixes = getInvertedNamespaces(namespacesToPrefixes);
123:                ConceptTagCharacteristic rootCtchar = rcth
124:                        .getFirstCharacteristic();
125:                //
126:                //
127:                //
128:                //printAndIndent("<table>");
129:                renderRcthDocument(rootCtchar, namespacesToPrefixes, 0, true,
130:                        false, false);
131:                //revertAndPrint("</table>");
132:                //renderConstraintHolder(ctcon.getConstraintHolder(0),
133:                //    getTextState(), new ArrayList());
134:                //
135:                //getConsolePageSession().popToggleLink();
136:                //getConsolePageSession().popToggleLink();
137:                //
138:                //
139:                //
140:                getConsolePageSession().popToggleLink();
141:            }
142:
143:            private void renderRcthDocument(ConceptTagCharacteristic inCtchar,
144:                    HashMap inNs, int inIndent, boolean inShowNs,
145:                    boolean inAttr, boolean inStyle) throws IOException {
146:
147:                if (inCtchar != null) {
148:
149:                    String conName = inCtchar.getConstraintName();
150:
151:                    getConsolePageSession().pushToggleLink(conName);
152:                    //
153:                    //
154:                    //
155:
156:                    ConceptTagPreferences localCtp = inCtchar.getPreferences();
157:                    ConceptTagSetHolder localCtsh = localCtp.getSetHolder();
158:                    boolean ctcharIsUndef = !inCtchar.isAttributeHolder()
159:                            && !inCtchar.isStyleHolder()
160:                            && conName
161:                                    .equals(localCtp.getUnconstrainedSymbol());
162:                    //
163:                    String conAsAttr = "";
164:                    if (!ctcharIsUndef) {
165:                        conAsAttr = getNamespaceAndName(inNs, localCtp
166:                                .getConstraintNamespace(), localCtp
167:                                .getConstraintName());
168:                        conAsAttr = (" " + conAsAttr + "=\"" + conName + "\"");
169:                    }
170:
171:                    for (int i = 0; i < inCtchar.getValueLength(); i++) {
172:                        //
173:                        getConsolePageSession().pushToggleLink(i + "");
174:
175:                        if (inAttr) {
176:                            //
177:                            String nextDisplay = getNamespaceAndName(inNs,
178:                                    null, localCtp.getAttributeConstraintName());
179:                            nextDisplay = nextDisplay + "=\""
180:                                    + inCtchar.getValueAsString(i, null) + "\"";
181:                            renderRcthItem(nextDisplay, inIndent, true);
182:                            //
183:                        } else if (inStyle) {
184:                            //
185:                            //String nextDisplay = getNamespaceAndName(
186:                            //    inNs, null, conName);
187:                            String nextDisplay = conName + ": "
188:                                    + inCtchar.getValueAsString(i, null) + ";";
189:                            //if (i < (inCtchar.getValueLength() - 1)) {
190:                            //    nextDisplay = nextDisplay + ";";
191:                            //}
192:                            renderRcthItem(nextDisplay, inIndent, true);
193:                            //
194:                        } else if (ctcharIsUndef && inCtchar.isStatic(i, null)) {
195:                            renderRcthItem(inCtchar.getValueAsString(i, null),
196:                                    inIndent, false);
197:                        } else if (!ctcharIsUndef && inCtchar.isStatic(i, null)) {
198:                            //
199:                            String nextCtcharhDisplay = getNamespaceAndName(
200:                                    inNs, localCtp.getStaticNamespace(),
201:                                    localCtp.getStaticName());
202:                            //
203:                            renderRcthItem(("<" + nextCtcharhDisplay
204:                                    + conAsAttr + ">"), inIndent, true);
205:                            renderRcthItem(inCtchar.getValueAsString(i, null),
206:                                    inIndent + INDENT, true);
207:                            renderRcthItem("</" + nextCtcharhDisplay + ">",
208:                                    inIndent, true);
209:                        } else if (inCtchar.isHolder(i, null)) {
210:
211:                            ConceptTagCharacteristicHolder nextCtcharh = inCtchar
212:                                    .getValueAsHolder(i, null);
213:
214:                            //
215:                            String nextCtcharhDisplay = null;
216:                            if (nextCtcharh.isConceptTagPresent()) {
217:                                ConceptTag nextCt = nextCtcharh.getConceptTag();
218:                                String nextCtClass = nextCt.getClass()
219:                                        .getName();
220:                                nextCtcharhDisplay = getNamespaceAndName(
221:                                        inNs,
222:                                        localCtsh
223:                                                .getConceptTagNamespace(nextCtClass),
224:                                        localCtsh
225:                                                .getConceptTagName(nextCtClass));
226:                            } else {
227:                                nextCtcharhDisplay = getNamespaceAndName(inNs,
228:                                        localCtp.getCompoundNamespace(),
229:                                        localCtp.getCompoundName());
230:                            }
231:
232:                            //
233:                            ConceptTagCharacteristicHolder nextAttrsCtcharh = nextCtcharh
234:                                    .getAttributes();
235:                            int attrCount = 0;
236:                            if (nextAttrsCtcharh != null) {
237:                                attrCount = nextAttrsCtcharh
238:                                        .getCharacteristicCount();
239:                            }
240:                            //
241:                            ConceptTagCharacteristicHolder nextStylesCtcharh = nextCtcharh
242:                                    .getStyles();
243:                            int styleCount = 0;
244:                            if (nextStylesCtcharh != null) {
245:                                styleCount = nextStylesCtcharh
246:                                        .getCharacteristicCount();
247:                            }
248:                            boolean delayEndAngledBracket = (inShowNs && !inNs
249:                                    .isEmpty())
250:                                    || (attrCount > 0) || (styleCount > 0);
251:
252:                            if (delayEndAngledBracket) {
253:                                renderRcthItem(
254:                                        ("<" + nextCtcharhDisplay + conAsAttr),
255:                                        inIndent, true);
256:                            } else {
257:                                renderRcthItem(("<" + nextCtcharhDisplay
258:                                        + conAsAttr + ">"), inIndent, true);
259:                            }
260:
261:                            if (inShowNs) {
262:                                MiscHelper.println("BasPanlesRtextCpc inNs = "
263:                                        + inNs);
264:                                HashMap prefixNs = getInvertedNamespaces(inNs);
265:                                ArrayList nsList = new ArrayList(prefixNs
266:                                        .keySet());
267:                                Collections.sort(nsList);
268:
269:                                for (int j = 0; j < nsList.size(); j++) {
270:                                    Object nextNs = nsList.get(j);
271:                                    String nextDisplay = "xmlns:" + nextNs
272:                                            + "=\"" + prefixNs.get(nextNs)
273:                                            + "\"";
274:                                    renderRcthItem(nextDisplay, inIndent
275:                                            + INDENT, true);
276:                                }
277:                            }
278:
279:                            if (nextCtcharh.getAttributes() != null) {
280:                                //
281:                                getConsolePageSession().pushToggleLink(
282:                                        localCtp.getAttributeConstraintName());
283:                                //
284:                                for (int j = 0; j < attrCount; j++) {
285:                                    ConceptTagCharacteristic nextAttrsCtchar = nextAttrsCtcharh
286:                                            .getCharacteristic(j);
287:                                    renderRcthDocument(nextAttrsCtchar, inNs,
288:                                            (inIndent + INDENT), false, true,
289:                                            false);
290:                                }
291:                                //
292:                                getConsolePageSession().popToggleLink();
293:                            }
294:
295:                            if (nextCtcharh.getStyles() != null) {
296:                                //
297:                                getConsolePageSession().pushToggleLink(
298:                                        localCtp.getStyleConstraintName());
299:                                //
300:                                //
301:                                //
302:
303:                                if (styleCount > 0) {
304:                                    renderRcthItem("style=\"", inIndent
305:                                            + INDENT, true);
306:                                }
307:                                //
308:                                //
309:                                for (int j = 0; j < styleCount; j++) {
310:                                    ConceptTagCharacteristic nextStylesCtchar = nextStylesCtcharh
311:                                            .getCharacteristic(j);
312:                                    renderRcthDocument(nextStylesCtchar, inNs,
313:                                            (inIndent + (2 * INDENT)), false,
314:                                            false, true);
315:                                }
316:                                //
317:                                //
318:                                if (styleCount > 0) {
319:                                    renderRcthItem("\"", inIndent + INDENT,
320:                                            true);
321:                                }
322:                                //
323:                                //
324:                                //
325:                                getConsolePageSession().popToggleLink();
326:                            }
327:
328:                            if (delayEndAngledBracket) {
329:                                renderRcthItem(">", inIndent + INDENT, true);
330:                            }
331:
332:                            //
333:                            //
334:                            //
335:                            //
336:                            //
337:                            int jcount = nextCtcharh.getCharacteristicCount();
338:                            for (int j = 0; j < jcount; j++) {
339:                                ConceptTagCharacteristic nextCtchar = nextCtcharh
340:                                        .getCharacteristic(j);
341:                                renderRcthDocument(nextCtchar, inNs, inIndent
342:                                        + INDENT, false, false, false);
343:                            }
344:
345:                            //
346:                            renderRcthDocument(nextCtcharh
347:                                    .getUndefinedCharacteristic(), inNs,
348:                                    (inIndent + INDENT), false, false, false);
349:
350:                            renderRcthItem("</" + nextCtcharhDisplay + ">",
351:                                    inIndent, true);
352:                        } else {
353:                            //
354:                            throw UnexpectedSystemException.unknownState();
355:                        }
356:
357:                        getConsolePageSession().popToggleLink();
358:                    }
359:                    //
360:                    //
361:                    //
362:                    getConsolePageSession().popToggleLink();
363:                }
364:            }
365:
366:            //
367:
368:            private void renderRcthItem(String inValue, int inIndent,
369:                    boolean inFormat) throws IOException {
370:                //
371:
372:                //
373:                String displayValue = inValue;
374:                if (inFormat) {
375:                    displayValue = XMLHelper.fromStringToCData(inValue);
376:                }
377:                simpleAndPrint(padNbsp(inIndent) + createGoTo(displayValue)
378:                        + "<br/>");
379:
380:            }
381:
382:            public String createGoTo(String inValue) {
383:
384:                String outValue = null;
385:
386:                SubmitActionContext sacGoTo = SubmitActionContext
387:                        .newInstance(this );
388:                //sacGoTo.setGoToPage(ConsolePageParameters.SERVLET_WEB_STUDIO_FRAME);
389:                sacGoTo.addAction(ConsoleParameterContext.FIRST_INPUT,
390:                        singleQuotes(SubmitActionParameters.MOVE));
391:                //
392:                sacGoTo.addParameter(ConsoleParameterContext.FIRST_INPUT,
393:                        singleQuotes(getConsolePageSession()
394:                                .getToggleLinkSubSectionAsHandle(
395:                                        this .baseToggleLinkListLength)));
396:
397:                outValue = "<a href=\"javascript:" + submitActionCall(sacGoTo)
398:                        + "\">" + inValue + "</a>";
399:
400:                return outValue;
401:            }
402:
403:            private final static HashMap getInvertedNamespaces(HashMap inHm) {
404:
405:                HashMap outValue = new HashMap();
406:
407:                Iterator iter = inHm.keySet().iterator();
408:                while (iter.hasNext()) {
409:                    Object nextKey = iter.next();
410:                    Object nextValue = inHm.get(nextKey);
411:
412:                    outValue.put(nextValue, nextKey);
413:                }
414:
415:                return outValue;
416:            }
417:
418:            private final static String getNamespaceAndName(
419:                    HashMap inNsToPrefix, String inNamespace, String inName) {
420:
421:                String outValue = null;
422:
423:                if (inNamespace != null) {
424:                    outValue = inNsToPrefix.get(inNamespace) + ":" + inName;
425:                } else {
426:                    outValue = inName;
427:                }
428:
429:                return outValue;
430:            }
431:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.