Source Code Cross Referenced for ConsoleTemplateContext.java in  » Workflow-Engines » JFolder » org » jfolder » common » web » template » 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.common.web.template 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * JFolder, Copyright 2001-2006 Gary Steinmetz
0003:         *
0004:         * Distributable under LGPL license.
0005:         * See terms of license at gnu.org.
0006:         */
0007:
0008:        package org.jfolder.common.web.template;
0009:
0010:        //base classes
0011:        import java.io.ByteArrayOutputStream;
0012:        import java.io.IOException;
0013:        import java.io.OutputStream;
0014:        import java.io.Writer;
0015:        import java.util.ArrayList;
0016:        import java.util.HashMap;
0017:        import java.util.Iterator;
0018:
0019:        //project specific classes
0020:        import org.jfolder.common.UnexpectedSystemException;
0021:        import org.jfolder.common.utils.misc.MiscHelper;
0022:        import org.jfolder.common.utils.xml.XMLHelper;
0023:
0024:        //other classes
0025:
0026:        public abstract class ConsoleTemplateContext extends
0027:                ConsoleTemplateFunctionsContext {
0028:
0029:            //
0030:            protected final static String ARIAL = "Arial";
0031:            protected final static String COURIER = "Courier";
0032:            protected final static String BLACK = "#000000";
0033:            protected final static String ERROR_COLOR = "#008888";
0034:            protected final static String BLUE = "#0000CC";
0035:            //
0036:            protected final static String UNDERSCORE = "_";
0037:            protected final static String _SELECT = "_SELECT";
0038:
0039:            //
0040:            private int leftMargin = 0;
0041:            private ArrayList metaTables = null;
0042:            private int longestRowWidth = 0;
0043:            private ArrayList realTableRowLengths = null;
0044:            private int columnWidth = 0;
0045:            private ArrayList menuIds = null;
0046:            //
0047:            private boolean outputText = false;
0048:            private transient ByteArrayOutputStream baos = null;
0049:            private String mimeType = null;
0050:            private String filename = null;
0051:
0052:            //
0053:            //
0054:            //private String name = null;
0055:
0056:            //
0057:            //protected ConsoleTemplateContext(String inName) {
0058:            protected ConsoleTemplateContext() {
0059:                super ();
0060:                resetConsolePageContext();
0061:                //if (inName != null) {
0062:                //    this.name = inName;
0063:                //}
0064:                //else {
0065:                //    this.name = "main";
0066:                //}
0067:            }
0068:
0069:            protected void resetConsolePageContext() {
0070:                this .metaTables = new ArrayList();
0071:                this .realTableRowLengths = new ArrayList();
0072:                this .columnWidth = ConsoleTemplateParameters.COLUMN_WIDTH;
0073:                this .menuIds = new ArrayList();
0074:                //
0075:                this .outputText = true;
0076:                this .baos = new ByteArrayOutputStream();
0077:                this .mimeType = null;
0078:                this .filename = null;
0079:            }
0080:
0081:            public void prepareForReuse() {
0082:                //
0083:                this .longestRowWidth = 0;
0084:                //
0085:                this .outputText = true;
0086:                this .baos = new ByteArrayOutputStream();
0087:                this .mimeType = null;
0088:                this .filename = null;
0089:                //
0090:                super .prepareForReuse();
0091:            }
0092:
0093:            //
0094:            public void considerDefaultSettings() {
0095:                //do nothing
0096:            }
0097:
0098:            //
0099:            public boolean isOutputText() {
0100:                return this .outputText;
0101:            }
0102:
0103:            public void setOutputText(boolean inMode) {
0104:                this .outputText = inMode;
0105:            }
0106:
0107:            public byte[] getBinaryContent() {
0108:                return this .baos.toByteArray();
0109:            }
0110:
0111:            public OutputStream getOutputStream() {
0112:
0113:                OutputStream outValue = null;
0114:
0115:                this .baos = new ByteArrayOutputStream();
0116:                outValue = this .baos;
0117:
0118:                return outValue;
0119:            }
0120:
0121:            public void setMimeType(String inType) {
0122:                this .mimeType = inType;
0123:            }
0124:
0125:            public String getMimeType() {
0126:                return this .mimeType;
0127:            }
0128:
0129:            public void setOutputFileName(String inName) {
0130:                this .filename = inName;
0131:            }
0132:
0133:            public String getOutputFileName() {
0134:                return this .filename;
0135:            }
0136:
0137:            //
0138:            protected void setColumnWidth(int inColumnWidth) {
0139:                this .columnWidth = inColumnWidth;
0140:            }
0141:
0142:            public int getColumnWidth() {
0143:                return this .columnWidth;
0144:            }
0145:
0146:            public void setLeftMargin(int inLeftMargin) {
0147:                this .leftMargin = inLeftMargin;
0148:            }
0149:
0150:            public int getLeftMargin() {
0151:                return this .leftMargin;
0152:            }
0153:
0154:            public int getLongestRowWidth() {
0155:
0156:                int outValue = 0;
0157:
0158:                if (this .metaTables.size() > 0) {
0159:                    throw new UnexpectedSystemException(
0160:                            "Table not correctly closed");
0161:                }
0162:                outValue = this .longestRowWidth;
0163:
0164:                return outValue;
0165:            }
0166:
0167:            //protected void setLongestRowWidth(int inWidth) {
0168:            //    this.longestRowWidth = inWidth;
0169:            //}
0170:            protected ConsoleTable pushMetaTable(int inWidth, int inLeftMargin) {
0171:
0172:                ConsoleTable outValue = ConsoleTable.newInstance(inWidth,
0173:                        inLeftMargin);
0174:
0175:                this .metaTables.add(outValue);
0176:
0177:                return outValue;
0178:            }
0179:
0180:            protected void popMetaTable() {
0181:                ConsoleTable st = getMetaTable();
0182:                int rowWidth = st.getWidth();
0183:                if (this .longestRowWidth < rowWidth) {
0184:                    this .longestRowWidth = rowWidth;
0185:                }
0186:                st.endTable();
0187:                this .metaTables.remove(this .metaTables.size() - 1);
0188:            }
0189:
0190:            protected ConsoleTable getMetaTable() {
0191:
0192:                ConsoleTable outValue = null;
0193:
0194:                int lastIndex = (this .metaTables.size() - 1);
0195:                outValue = (ConsoleTable) this .metaTables.get(lastIndex);
0196:
0197:                return outValue;
0198:            }
0199:
0200:            protected int pushRealTableRowLength(int inWidth, int inLeftMargin) {
0201:
0202:                int outValue = inWidth + inLeftMargin;
0203:
0204:                this .realTableRowLengths.add(new Integer(outValue));
0205:
0206:                return outValue;
0207:            }
0208:
0209:            protected void popRealTableRowLength() {
0210:                this .realTableRowLengths
0211:                        .remove(this .realTableRowLengths.size() - 1);
0212:            }
0213:
0214:            protected int getRealTableRowLength() {
0215:
0216:                Integer outValue = null;
0217:
0218:                int lastIndex = (this .realTableRowLengths.size() - 1);
0219:                outValue = (Integer) this .realTableRowLengths.get(lastIndex);
0220:
0221:                return outValue.intValue();
0222:            }
0223:
0224:            public void startTable(int inWidth) throws IOException {
0225:                startTable(inWidth, null);
0226:            }
0227:
0228:            public void startTable(int inWidth, HashMap inProps)
0229:                    throws IOException {
0230:                if (!isMetaMode()) {
0231:                    int totalWidth = getLongestRowWidth();
0232:                    printAndIndent("<table width=\""
0233:                            + ((totalWidth) * this .columnWidth)
0234:                            + "\" cellspacing=\"0\" cellpadding=\"0\""
0235:                            + getProps(inProps) + ">");
0236:                    pushRealTableRowLength(inWidth, getLeftMargin());
0237:                } else {
0238:                    pushMetaTable(inWidth, getLeftMargin());
0239:                }
0240:            }
0241:
0242:            public void startRow() throws IOException {
0243:                startRow(null);
0244:            }
0245:
0246:            private void startRow(String inId) throws IOException {
0247:                if (!isMetaMode()) {
0248:
0249:                    int leftMargin = getLeftMargin();
0250:
0251:                    String idAttr = "";
0252:                    if (inId != null) {
0253:                        idAttr = " id=\"" + inId + "\"";
0254:                    }
0255:
0256:                    printAndIndent("<tr" + idAttr + ">");
0257:                    if (leftMargin > 0) {
0258:                        //printAndIndent(
0259:                        //    "<td width=\"" + (leftMargin*this.columnWidth) + "\">");
0260:                        //simpleAndPrint(XMLHelper.NBSP_XML);
0261:                        //revertAndPrint("</td>");
0262:
0263:                        String nextIcon = ConsoleTemplateParameters.GIF_EMPTY;
0264:                        simpleAndPrint("<td width=\""
0265:                                + (leftMargin * this .columnWidth) + "\">"
0266:                                + "<img border=\"0\" src=\"" + nextIcon
0267:                                + "\" width=\""
0268:                                + (leftMargin * this .columnWidth)
0269:                                + "\" height=\"1\"/>" + "</td>");
0270:                    }
0271:                } else {
0272:                    ConsoleTable st = getMetaTable();
0273:                    st.startRow();
0274:                }
0275:            }
0276:
0277:            public void startCell(int inWidth) throws IOException {
0278:                startCell(inWidth, null);
0279:            }
0280:
0281:            public void startCell(int inWidth, HashMap inProps)
0282:                    throws IOException {
0283:                if (!isMetaMode()) {
0284:                    printAndIndent("<td width=\""
0285:                            + (inWidth * this .columnWidth) + "\""
0286:                            + getProps(inProps) + ">");
0287:                } else {
0288:                    ConsoleTable st = getMetaTable();
0289:                    st.addCell(inWidth);
0290:                }
0291:            }
0292:
0293:            public void startAndEndCell(int inWid, String inCon)
0294:                    throws IOException {
0295:                startAndEndCell(inWid, inCon, null);
0296:            }
0297:
0298:            public void startAndEndCell(int inWidth, String inContent,
0299:                    HashMap inCellProps) throws IOException {
0300:                if (!isMetaMode()) {
0301:                    simpleAndPrint("<td width=\""
0302:                            + (inWidth * this .columnWidth) + "\""
0303:                            + getProps(inCellProps) + ">" + inContent + "</td>");
0304:                } else {
0305:                    ConsoleTable st = getMetaTable();
0306:                    st.addCell(inWidth);
0307:                }
0308:            }
0309:
0310:            public void endCell() throws IOException {
0311:                if (!isMetaMode()) {
0312:                    revertAndPrint("</td>");
0313:                }
0314:            }
0315:
0316:            public void endRow() throws IOException {
0317:                if (!isMetaMode()) {
0318:                    int actualWidth = getRealTableRowLength();
0319:                    int totalWidth = getLongestRowWidth();
0320:                    int rightMargin = (totalWidth - actualWidth);
0321:                    if (rightMargin > 0) {
0322:                        //startAndEndCell(1, "<img border=\"0\" src=\""
0323:                        //    + nextIcon + "\" height=\"" + getColumnWidth()
0324:                        //    + "\" width\"" + getColumnWidth() + "\"/>");
0325:                        String nextIcon = ConsoleTemplateParameters.GIF_EMPTY;
0326:                        simpleAndPrint("<td width=\""
0327:                                + (rightMargin * this .columnWidth) + "\">"
0328:                                + "<img border=\"0\" src=\"" + nextIcon
0329:                                + "\" width=\""
0330:                                + (rightMargin * this .columnWidth)
0331:                                + "\" height=\"1\"/>" + "</td>");
0332:                    }
0333:                    revertAndPrint("</tr>");
0334:                } else {
0335:                    ConsoleTable st = getMetaTable();
0336:                    st.endRow();
0337:                }
0338:            }
0339:
0340:            public void endTable() throws IOException {
0341:                if (!isMetaMode()) {
0342:                    revertAndPrint("</table>");
0343:                    popRealTableRowLength();
0344:                } else {
0345:                    popMetaTable();
0346:                }
0347:            }
0348:
0349:            public void startAndEndStretchTableAndRowAndCell(String inContent)
0350:                    throws IOException {
0351:                startAndEndStretchTableAndRowAndCell(inContent, null);
0352:            }
0353:
0354:            public void startAndEndStretchTableAndRowAndCell(String inContent,
0355:                    HashMap inCellProps) throws IOException {
0356:                int rowWidth = 1;
0357:                if (!isMetaMode()) {
0358:                    rowWidth = getLongestRowWidth() - getLeftMargin();
0359:                }
0360:                startAndEndSimpleTableAndRowAndCell(rowWidth, inContent,
0361:                        inCellProps);
0362:            }
0363:
0364:            public void startAndEndSimpleTableAndRowAndCell(int inWidth,
0365:                    String inContent) throws IOException {
0366:                startAndEndSimpleTableAndRowAndCell(inWidth, inContent, null);
0367:            }
0368:
0369:            public void startAndEndSimpleTableAndRowAndCell(int inWidth,
0370:                    String inContent, HashMap inCellProps) throws IOException {
0371:                startTable(inWidth);
0372:                startRow();
0373:                startAndEndCell(inWidth, inContent, inCellProps);
0374:                endRow();
0375:                endTable();
0376:            }
0377:
0378:            public void startEnclosingTableAndRowAndCell(String inId)
0379:                    throws IOException {
0380:                startEnclosingTableAndRowAndCell(null, inId);
0381:            }
0382:
0383:            public void startEnclosingTableAndRowAndCell(HashMap inProps)
0384:                    throws IOException {
0385:                startEnclosingTableAndRowAndCell(inProps, null);
0386:            }
0387:
0388:            public void startEnclosingTableAndRowAndCell(HashMap inProps,
0389:                    String inId) throws IOException {
0390:                //
0391:                startEnclosingTableAndRowAndCell(inProps, inId, null);
0392:            }
0393:
0394:            public void startEnclosingTableAndRowAndCell(HashMap inProps,
0395:                    String inId, HashMap inCellProps) throws IOException {
0396:                if (!isMetaMode()) {
0397:                    //
0398:                    //
0399:                    if (inProps == null) {
0400:                        inProps = new HashMap();
0401:                    }
0402:                    int displayWidth = ((getLongestRowWidth()) * this .columnWidth);
0403:                    if (inId != null) {
0404:                        inProps.put("id", inId);
0405:                        //String branchCode =
0406:                        //    BRANCH_SEPARATOR + inId + BRANCH_SEPARATOR;
0407:                        //String localTreeState = getTreeState();
0408:                        boolean branchOpen = isTreeComponentPresent(inId);
0409:                        //(getTreeState().indexOf(branchCode) != -1);
0410:
0411:                        String displayNextTi = "none";
0412:                        if (branchOpen) {
0413:                            displayNextTi = "block";
0414:                        }
0415:                        if (inProps.containsKey("style")) {
0416:                            inProps.put("style", "display: " + displayNextTi
0417:                                    + "; " + inProps.get("style"));
0418:                        } else {
0419:                            inProps.put("style", "display: " + displayNextTi);
0420:                        }
0421:                    }
0422:                    inProps.put("width", "" + displayWidth);
0423:                    inProps.put("cellspacing", "0");
0424:                    inProps.put("cellpadding", "0");
0425:                    //
0426:                    //
0427:                    if (inCellProps == null) {
0428:                        inCellProps = new HashMap();
0429:                    }
0430:                    //
0431:                    //
0432:                    printAndIndent("<table" + toAttrs(inProps) + ">");
0433:                    printAndIndent("<tr>");
0434:                    printAndIndent("<td width=\"" + displayWidth + "\""
0435:                            + toAttrs(inCellProps) + ">");
0436:                }
0437:            }
0438:
0439:            public void endEnclosingTableAndRowAndCell() throws IOException {
0440:                if (!isMetaMode()) {
0441:                    revertAndPrint("</td>");
0442:                    revertAndPrint("</tr>");
0443:                    revertAndPrint("</table>");
0444:                }
0445:            }
0446:
0447:            public final static String getProps(HashMap inProps) {
0448:                StringBuffer outValue = new StringBuffer();
0449:                if (inProps != null) {
0450:                    Iterator iter = inProps.keySet().iterator();
0451:                    while (iter.hasNext()) {
0452:                        String nextAttr = iter.next().toString();
0453:                        String nextValue = inProps.get(nextAttr).toString();
0454:                        outValue.append(" ");
0455:                        outValue.append(nextAttr);
0456:                        outValue.append("=");
0457:                        outValue.append("\"");
0458:                        outValue.append(nextValue);
0459:                        outValue.append("\"");
0460:                    }
0461:                }
0462:                return outValue.toString();
0463:            }
0464:
0465:            public String getToggleLinkWithTargetId(String inTargetId,
0466:                    String inLabel, String inDestinationId) {
0467:                //
0468:                return getToggleLinkWithTargetId(inTargetId, inLabel,
0469:                        inDestinationId, null);
0470:            }
0471:
0472:            public String getToggleLinkWithTargetId(String inTargetId,
0473:                    String inLabel, String inDestinationId, String inAction) {
0474:                //
0475:                String outValue = null;
0476:                //
0477:                String action = "";
0478:                if (inAction != null) {
0479:                    action = " " + inAction;
0480:                }
0481:                //
0482:                outValue = "<a onmouseover=\"this.style.cursor = 'pointer'; "
0483:                        + " this.style.textDecoration = 'underline';\""
0484:                        + " onmouseout="
0485:                        + "\"this.style.textDecoration = 'none';"
0486:                        + " this.style.cursor = 'default';\""
0487:                        + " onclick=\"toggleSection('" + inDestinationId
0488:                        + "');" + action + "\" id=\"" + inTargetId + "\">"
0489:                        + inLabel + "</a>";
0490:                return outValue;
0491:            }
0492:
0493:            public void getLaunchPoint(
0494:                    //ConsoleTemplateSession inCts,
0495:                    String inSourceId, String inDestinationId, String inLabel,
0496:                    boolean inShowBelow, HashMap inTableAttrs,
0497:                    HashMap inTableStyles, HashMap inCellAttrs,
0498:                    HashMap inCellStyles) throws IOException {
0499:                //
0500:                //inCts.pushToggleLinkComponent(
0501:                //    ConsoleTemplateSession.COMPONENT_MENU_LAUNCH_POINT);
0502:                //inCts.pushToggleLink(inSourceId);
0503:                //String sourceId = inCts.getToggleLink();
0504:                //inCts.popToggleLink();
0505:                //inCts.popToggleLink();
0506:                //
0507:                //inCts.pushToggleLinkComponent(
0508:                //    ConsoleTemplateSession.COMPONENT_MENU);
0509:                //inCts.pushToggleLink(inSourceId);
0510:                //String destinationId = inCts.getToggleLink();
0511:                //inCts.popToggleLink();
0512:                //inCts.popToggleLink();
0513:                //
0514:                createButton(inSourceId, inLabel, null, getLaunchPointAction(
0515:                        inDestinationId, inShowBelow), inTableAttrs,
0516:                        inTableStyles, inCellAttrs, inCellStyles);
0517:            }
0518:
0519:            public final static String getLaunchPointAction(
0520:                    String inDestinationId, boolean inShowBelow) {
0521:                //
0522:                return getLaunchPointAction(inDestinationId, inShowBelow,
0523:                        "this");
0524:            }
0525:
0526:            public final static String getLaunchPointAction(
0527:                    String inDestinationId, boolean inShowBelow, String inTarget) {
0528:                //
0529:
0530:                String outValue = null;
0531:
0532:                String topPlacement = "getTrueOffsetTop(" + inTarget + ")";
0533:                if (inShowBelow) {
0534:                    topPlacement = "(getTrueOffsetTop(" + inTarget + ") + "
0535:                            + inTarget + ".offsetHeight)";
0536:                }
0537:
0538:                outValue = "renderMenuNode('" + (inDestinationId) + "', "
0539:                        + topPlacement + ", getTrueOffsetLeft(" + inTarget
0540:                        + "), " + 0 + ")";
0541:
0542:                return outValue;
0543:            }
0544:
0545:            private void getGeneralButton(String inId, String inLabel,
0546:                    String inOnClick, HashMap inTableAttrs,
0547:                    HashMap inTableStyles, HashMap inCellAttrs,
0548:                    HashMap inCellStyles) throws IOException {
0549:
0550:                //String topPlacement = "getTrueOffsetTop(this)";
0551:                //if (inShowBelow) {
0552:                //    topPlacement = "(getTrueOffsetTop(this) + this.offsetHeight)";
0553:                //}
0554:
0555:                HashMap cellAttrs = new HashMap();
0556:                if (inCellAttrs != null) {
0557:                    cellAttrs = ((HashMap) inCellAttrs.clone());
0558:                }
0559:                cellAttrs.put("onmouseout", "this.style.cursor = 'auto'");
0560:                cellAttrs.put("onmouseover", "this.style.cursor = 'default'");
0561:                if (inId != null) {
0562:                    cellAttrs.put("id", inId);
0563:                }
0564:                if (inOnClick != null) {
0565:                    cellAttrs.put("onclick", inOnClick);
0566:                }
0567:                //
0568:                HashMap cellStyles = new HashMap();
0569:                if (inCellStyles != null) {
0570:                    cellStyles = ((HashMap) inCellStyles.clone());
0571:                }
0572:                cellStyles.put("text-align", "center");
0573:                cellStyles.put("background-color", "#EEEEEE");
0574:                cellStyles.put("border", "1px solid #333333");
0575:                //
0576:                cellAttrs.put("style", XMLHelper.fromStylesToAttr(cellStyles));
0577:                //cellAttrs.put("style", "text-align: center;"
0578:                //    + " background-color: #EEEEEE;" + " border: '1 solid #333333'");
0579:
0580:                //
0581:                HashMap tableAttrs = new HashMap();
0582:                if (inTableAttrs != null) {
0583:                    tableAttrs = ((HashMap) inTableAttrs.clone());
0584:                }
0585:                tableAttrs.put("cellspacing", "0");
0586:                tableAttrs.put("cellpadding", "0");
0587:                if (!tableAttrs.containsKey("width")) {
0588:                    tableAttrs.put("width", "150");
0589:                }
0590:                //
0591:                HashMap tableStyles = new HashMap();
0592:                if (inTableStyles != null) {
0593:                    tableStyles = (HashMap) inTableStyles.clone();
0594:                }
0595:                //
0596:                tableAttrs
0597:                        .put("style", XMLHelper.fromStylesToAttr(tableStyles));
0598:
0599:                //
0600:                //
0601:                //
0602:                tableAttrs.put("onmouseout", "this.style.cursor = 'auto'");
0603:                tableAttrs.put("onmouseover", "this.style.cursor = 'pointer'");
0604:                //
0605:                cellAttrs.put("onmouseout", "this.style.cursor = 'auto'");
0606:                cellAttrs.put("onmouseover", "this.style.cursor = 'pointer'");
0607:
0608:                //StringBuffer attrs = new StringBuffer();
0609:                //Iterator attrMap = tableProps.keySet().iterator();
0610:                //while (attrMap.hasNext()) {
0611:                //    String propName = (String)attrMap.next();
0612:                //    String propValue = (String)tableProps.get(propName);
0613:                //    attrs.append(" ");
0614:                //    attrs.append(propName);
0615:                //    attrs.append("=\"");
0616:                //    attrs.append(propValue);
0617:                //    attrs.append("\"");
0618:                //}
0619:                printAndIndent("<table " + toAttrs(tableAttrs) + ">");
0620:                printAndIndent("<tr>");
0621:                simpleAndPrint("<td " + toAttrs(cellAttrs) + ">" + inLabel
0622:                        + "</td>");
0623:                revertAndPrint("</tr>");
0624:                revertAndPrint("</table>");
0625:            }
0626:
0627:            protected String createHorizontalRow(int inColumnWidth,
0628:                    Integer inPadding) {
0629:
0630:                StringBuffer outValue = new StringBuffer();
0631:
0632:                //
0633:                if (inPadding == null) {
0634:                    inPadding = new Integer(2);
0635:                }
0636:                int hrWidth = (inColumnWidth * getColumnWidth())
0637:                        - inPadding.intValue();
0638:                //
0639:                //HashMap attrs = new HashMap();
0640:                //HashMap styles = new HashMap();
0641:                //styles.put("width", hrWidth + "");
0642:                //
0643:                outValue.append("<hr style=\"width: " + hrWidth + "\"/>");
0644:
0645:                return outValue.toString();
0646:            }
0647:
0648:            public void createButton(String inId, String inLabel, int inWidth,
0649:                    String inOnClick, HashMap inTableAttrs,
0650:                    HashMap inTableStyles, HashMap inCellAttrs,
0651:                    HashMap inCellStyles) throws IOException {
0652:                //
0653:                createButton(inId, inLabel, new Integer(inWidth), inOnClick,
0654:                        inTableAttrs, inTableStyles, inCellAttrs, inCellStyles);
0655:            }
0656:
0657:            public void createButton(String inId, String inLabel,
0658:                    Integer inWidth, String inOnClick, HashMap inTableAttrs,
0659:                    HashMap inTableStyles, HashMap inCellAttrs,
0660:                    HashMap inCellStyles) throws IOException {
0661:
0662:                //
0663:                //
0664:                if (inTableAttrs == null) {
0665:                    inTableAttrs = new HashMap();
0666:                }
0667:                //
0668:                if (inTableStyles == null) {
0669:                    inTableStyles = new HashMap();
0670:                }
0671:                //
0672:                if (inCellAttrs == null) {
0673:                    inCellAttrs = new HashMap();
0674:                }
0675:                //
0676:                if (inCellStyles == null) {
0677:                    inCellStyles = new HashMap();
0678:                }
0679:                //
0680:                if (inWidth != null) {
0681:                    inCellAttrs.put("width", ((inWidth.intValue() - 2) + ""));
0682:                    inTableAttrs.put("width", inWidth.toString());
0683:                }
0684:                //
0685:                getGeneralButton(inId, inLabel, inOnClick, inTableAttrs,
0686:                        inTableStyles, inCellAttrs, inCellStyles);
0687:                //
0688:                //
0689:                //if (inCellAttrs == null) {
0690:                //    inCellAttrs = new HashMap();
0691:                //}
0692:                //
0693:                //HashMap tableProps = ((HashMap)inCellAttrs.clone());
0694:                //
0695:                //if (inWidth != null) {
0696:                //    inCellAttrs.put("width", ((inWidth.intValue() - 2) + ""));
0697:                //    tableProps.put("width", inWidth.toString());
0698:                //}
0699:                //
0700:                //if (inOnClick != null) {
0701:                //    tableProps.put("onclick", inOnClick);
0702:                //}
0703:                //
0704:                //if (inId != null) {
0705:                //    tableProps.put("id", inId);
0706:                //}
0707:                //
0708:                //inCellAttrs.put("align", "center");
0709:                //inCellAttrs.put("valign", "middle");
0710:                //inCellAttrs.put("onmouseout", "this.style.cursor = 'auto'");
0711:                //inCellAttrs.put("onmouseover", "this.style.cursor = 'pointer'");
0712:                //
0713:                //tableProps.put("cellspacing", "0");
0714:                //tableProps.put("cellpadding", "0");
0715:                //tableProps.put("style", "text-align: center;"
0716:                //    + " background-color: #EEEEEE;" + " border: '1 solid #666666'");
0717:                //tableProps.put("onmouseout", "this.style.cursor = 'auto'");
0718:                //tableProps.put("onmouseover", "this.style.cursor = 'pointer'");
0719:                //
0720:                //
0721:                //
0722:                //printAndIndent("<table" + toAttrs(tableProps) + ">");
0723:                //printAndIndent("<tr>");
0724:                //simpleAndPrint(
0725:                //    "<td" + toAttrs(inCellAttrs) + ">" + inLabel + "</td>");
0726:                //revertAndPrint("</tr>");
0727:                //revertAndPrint("</table>");
0728:            }
0729:
0730:            //MenuBranch Rendering
0731:            public String getMenu(ConsoleTemplateSession inCts, String inId,
0732:                    MenuBranch inBranc, HashMap inTableProps,
0733:                    HashMap inTableStyles, HashMap inCellProps,
0734:                    HashMap inCellStyles, Integer inTextLimit, Object inCtmb)
0735:                    throws IOException {
0736:                //
0737:                String outValue = null;
0738:
0739:                inCts
0740:                        .pushToggleLinkComponent(ConsoleTemplateSession.COMPONENT_MENU);
0741:                inCts.pushToggleLink(inId);
0742:                //
0743:                //
0744:                //
0745:                if (isMetaMode()) {
0746:                    inCts.registerMenu(inCts.getToggleLinkAsArrayList(),
0747:                            inBranc, inTableProps, inTableStyles, inCellProps,
0748:                            inCellStyles, inTextLimit, inCtmb);
0749:                }
0750:                //
0751:                outValue = inCts.getToggleLink();
0752:                //
0753:                inCts.popToggleLink();
0754:                inCts.popToggleLink();
0755:
0756:                return outValue;
0757:            }
0758:
0759:            public void getSubMenu(ConsoleTemplateSession inCts,
0760:                    MenuBranch inBranc, int inIndexZ, HashMap inTableAttrs,
0761:                    HashMap inTableStyles, HashMap inCellAttrs,
0762:                    HashMap inCellStyles, Integer inLimit) throws IOException {
0763:
0764:                String currentId = inCts.getToggleLink();
0765:
0766:                this .menuIds.add(currentId);
0767:                ArrayList branches = new ArrayList();
0768:                ArrayList ids = new ArrayList();
0769:                //
0770:                HashMap tableAttrs = new HashMap();
0771:                if (inTableAttrs != null) {
0772:                    tableAttrs = ((HashMap) inTableAttrs.clone());
0773:                }
0774:                tableAttrs.put("cellspacing", "0");
0775:                tableAttrs.put("cellpadding", "0");
0776:                if (!tableAttrs.containsKey("width")) {
0777:                    tableAttrs.put("width",
0778:                            ConsoleTemplateParameters.MENU_WIDTH + "");
0779:                }
0780:                //tableAttrs.put("border", "1");
0781:                tableAttrs.put("id", currentId + "");
0782:                tableAttrs.put("onmouseover", "stopEventPropogation(event)");
0783:                //if (!tableAttrs.containsKey("bordercolor")) {
0784:                //    tableAttrs.put("bordercolor", "#000000");
0785:                //}
0786:                //
0787:                HashMap tableStyles = new HashMap();
0788:                if (inTableStyles != null) {
0789:                    tableStyles = ((HashMap) inTableStyles.clone());
0790:                }
0791:                tableStyles.put("display", "none");
0792:                tableStyles.put("position", "absolute");
0793:                tableStyles.put("z-index", inIndexZ + "");
0794:                if (!tableStyles.containsKey("background-color")) {
0795:                    tableStyles.put("background-color", "#EEEEEE");
0796:                }
0797:                //
0798:                tableAttrs
0799:                        .put("style", XMLHelper.fromStylesToAttr(tableStyles));
0800:
0801:                printAndIndent("<table " + toAttrs(tableAttrs) + ">");
0802:                //printAndIndent("<table cellspacing=\"0\" cellpadding=\"0\" width=\""
0803:                //    + ConsoleTemplateParameters.MENU_WIDTH + "\" border=\"1\" id=\""
0804:                //    + currentId + "\" style=\"display: none; position: absolute;"
0805:                //    + " z-index: " + inIndexZ + "; background-color: #FFFFFF\""
0806:                //    + " onmouseover=\"stopEventPropogation(event)\""
0807:                //    + " bordercolor=\"#000000\">");
0808:                if (inBranc.getNodeLength() > 0) {
0809:                    for (int i = 0; i < inBranc.getNodeLength(); i++) {
0810:                        //
0811:                        //
0812:                        inCts.pushToggleLink(i + "");
0813:                        String nextId = inCts.getToggleLink();
0814:                        inCts.popToggleLink();
0815:
0816:                        //
0817:                        HashMap cellAttrs = new HashMap();
0818:                        if (inCellAttrs != null) {
0819:                            cellAttrs = ((HashMap) inCellAttrs.clone());
0820:                        }
0821:                        //
0822:                        inCts.pushToggleLinkMenuItem();
0823:                        inCts.pushToggleLink(i + "");
0824:                        cellAttrs.put("id", inCts.getToggleLink());
0825:                        inCts.popToggleLink();
0826:                        inCts.popToggleLink();
0827:                        //
0828:                        HashMap cellStyles = new HashMap();
0829:                        if (inCellStyles != null) {
0830:                            cellStyles = ((HashMap) inCellStyles.clone());
0831:                        }
0832:                        if (!cellStyles.containsKey("background-color")) {
0833:                            cellStyles.put("background-color", "#EEEEEE");
0834:                        }
0835:                        if (!cellStyles.containsKey("border")) {
0836:                            cellStyles.put("border", "1px solid #333333");
0837:                        }
0838:                        //
0839:                        //
0840:                        MenuItem mi = inBranc.getNode(i);
0841:                        if (inBranc.isBranch(i)) {
0842:                            cellAttrs.put("onmouseout",
0843:                                    "this.style.cursor = 'auto'");
0844:                            if (!cellAttrs.containsKey("width")) {
0845:                                cellAttrs.put("width",
0846:                                        ConsoleTemplateParameters.MENU_WIDTH
0847:                                                + "");
0848:                            }
0849:                            cellAttrs.put("onmouseover", "closeOpenTagMenus('"
0850:                                    + currentId + "'); renderMenuNode('"
0851:                                    + nextId + "', getTrueOffsetTop(this),"// - 1,"
0852:                                    + " getTrueOffsetLeft(this),"// - 1, "
0853:                                    + " this.offsetWidth"
0854:                                    //ConsoleTemplateParameters.MENU_WIDTH
0855:                                    + "); this.style.cursor = 'default'");
0856:                            renderMenuItem(nextId, cellAttrs, cellStyles, mi,
0857:                                    inLimit);
0858:                            branches.add(mi);
0859:                            ids.add(new Integer(i));
0860:                        } else {
0861:                            cellAttrs.put("onmouseover", "closeOpenTagMenus('"
0862:                                    + currentId
0863:                                    + "'); this.style.cursor = 'pointer'");
0864:                            cellAttrs.put("onmouseout",
0865:                                    "this.style.cursor = 'auto'");
0866:                            if (!cellAttrs.containsKey("width")) {
0867:                                cellAttrs.put("width",
0868:                                        ConsoleTemplateParameters.MENU_WIDTH
0869:                                                + "");
0870:                            }
0871:                            renderMenuItem(nextId, cellAttrs, cellStyles, mi,
0872:                                    inLimit);
0873:                        }
0874:                    }
0875:                } else {
0876:                    //TO DO: what if there are no nodes?
0877:                }
0878:                revertAndPrint("</table>");
0879:                for (int i = 0; i < branches.size(); i++) {
0880:                    Integer nextId = (Integer) ids.get(i);
0881:                    inCts.pushToggleLink(nextId.toString());
0882:                    getSubMenu(inCts, (MenuBranch) branches.get(i),
0883:                            (inIndexZ + 1), inTableAttrs, inTableStyles,
0884:                            inCellAttrs, inCellStyles, inLimit);
0885:                    inCts.popToggleLink();
0886:                }
0887:            }
0888:
0889:            private void renderMenuItem(String inId, HashMap inCellAttrs,
0890:                    HashMap inCellStyles, MenuItem inItem, Integer inLimit)
0891:                    throws IOException {
0892:
0893:                this .menuIds.add(inId);
0894:                HashMap baseProps = inItem.getProperties();
0895:                if (baseProps != null) {
0896:                    Iterator iter = baseProps.keySet().iterator();
0897:                    while (iter.hasNext()) {
0898:                        String propName = (String) iter.next();
0899:                        String propValue = (String) baseProps.get(propName);
0900:                        inCellAttrs.put(propName, propValue);
0901:                    }
0902:                }
0903:                if (inItem.getOnClick() != null) {
0904:                    inCellAttrs.put("onclick", inItem.getOnClick());
0905:                }
0906:                inCellAttrs.put("title", inItem.getLabel());
0907:                inCellAttrs.put("style", XMLHelper
0908:                        .fromStylesToAttr(inCellStyles));
0909:                //
0910:                //
0911:                String value = inItem.getLabel();
0912:                if (inLimit != null) {
0913:                    value = MiscHelper.shortenString(inItem.getLabel(), inLimit
0914:                            .intValue());
0915:                }
0916:                //
0917:                //
0918:                printAndIndent("<tr>");
0919:                simpleAndPrint("<td" + toAttrs(inCellAttrs) + ">" + value
0920:                        + "</td>");
0921:                revertAndPrint("</tr>");
0922:            }
0923:
0924:            private int getMenuIdsCount() {
0925:                return this .menuIds.size();
0926:            }
0927:
0928:            private String getMenuId(int inIndex) {
0929:                return (String) this .menuIds.get(inIndex);
0930:            }
0931:
0932:            private final static String toAttrs(HashMap inProps) {
0933:                return XMLHelper.convertAttrs(inProps);
0934:            }
0935:
0936:            //public final static ProjectScript[] getDeployedScripts() {
0937:            //    ProjectScript outValue[] = null;
0938:            //    WorkflowServiceCaller wsc =
0939:            //        WorkflowServiceCallerFactory.getWorkflowServiceCaller();
0940:            //    outValue = wsc.accessDeployedScripts();
0941:            //    //wl.close();
0942:            //    return outValue;
0943:            //}
0944:            public static HashMap getFontStyle(int inS, String inF,
0945:                    String inColor) {
0946:
0947:                HashMap outValue = new HashMap();
0948:                //String fontStyle = ("font-size: " + inS + "pt; font-family: "
0949:                //    + inF + "; color: " + inColor + ";");
0950:                //outValue.put("style", fontStyle);
0951:                outValue.put("style", XMLHelper
0952:                        .fromStylesToAttr(getFontStyleAsStyles(inS, inF,
0953:                                inColor)));
0954:                return outValue;
0955:            }
0956:
0957:            public static HashMap getFontStyleAsStyles(int inS, String inF,
0958:                    String inColor) {
0959:
0960:                HashMap outValue = new HashMap();
0961:
0962:                outValue.put("font-size", inS + "pt");
0963:                outValue.put("font-family", inF);
0964:                outValue.put("color", inColor);
0965:
0966:                return outValue;
0967:            }
0968:
0969:            public static HashMap addStyle(HashMap inMap, String inN, String inV) {
0970:                HashMap outValue = inMap;
0971:                if (outValue == null) {
0972:                    outValue = new HashMap();
0973:                }
0974:                String nextStyle = inN + ": " + inV + ";";
0975:                if (outValue.get("style") != null) {
0976:                    outValue.put("style", outValue.get("style") + " "
0977:                            + nextStyle);
0978:                } else {
0979:                    outValue.put("style", nextStyle);
0980:                }
0981:                return outValue;
0982:            }
0983:
0984:            public static HashMap addAttr(HashMap inM, String inN, String inV) {
0985:                HashMap outValue = inM;
0986:                if (outValue == null) {
0987:                    outValue = new HashMap();
0988:                }
0989:                outValue.put(inN, inV);
0990:                return outValue;
0991:            }
0992:
0993:            public static HashMap addAlign(HashMap inMap, String inValue) {
0994:
0995:                HashMap outValue = inMap;
0996:                if (outValue == null) {
0997:                    outValue = new HashMap();
0998:                }
0999:                outValue.put("align", inValue);
1000:                return outValue;
1001:            }
1002:
1003:            public static HashMap alignLeft(HashMap inMap) {
1004:                return addAlign(inMap, "left");
1005:            }
1006:
1007:            public static HashMap alignCenter(HashMap inMap) {
1008:                return addAlign(inMap, "center");
1009:            }
1010:
1011:            public static HashMap alignRight(HashMap inMap) {
1012:                return addAlign(inMap, "right");
1013:            }
1014:
1015:            public void createHorizontalRow(int inIndent) throws IOException {
1016:                int existingMargin = getLeftMargin();
1017:                setLeftMargin(existingMargin + inIndent);
1018:                startAndEndStretchTableAndRowAndCell("<hr/>");
1019:                setLeftMargin(existingMargin);
1020:
1021:            }
1022:
1023:            public final static String padNbsp(int inCount) {
1024:
1025:                StringBuffer outValue = new StringBuffer();
1026:
1027:                for (int i = 0; i < inCount; i++) {
1028:                    outValue.append(XMLHelper.NBSP_XML);
1029:                }
1030:
1031:                return outValue.toString();
1032:            }
1033:
1034:            public final static String formatText(String inText, HashMap inProps) {
1035:                return ("<span " + getProps(inProps) + ">" + inText + "</span>");
1036:            }
1037:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.