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:
013: //project specific classes
014: import org.jfolder.common.web.template.SubmitActionContext;
015: import org.jfolder.console.base.BaseSubConsolePageContext;
016: import org.jfolder.console.base.ConsolePageContext;
017: import org.jfolder.console.base.ConsolePageParameters;
018: import org.jfolder.console.base.NamesForSubCpc;
019:
020: //other classes
021:
022: public class BaseSubPaneBarConsolePageContext extends
023: BaseSubConsolePageContext {
024:
025: //private int height = 0;
026: private String iconUrls[] = null;
027: private String iconLabels[] = null;
028: private SubmitActionContext sacs[] = null;
029:
030: private BaseSubPaneBarConsolePageContext(ConsolePageContext inCpc,
031: int inHeight, int inColumnWidth, String inIconUrls[],
032: String inIconLabels[], SubmitActionContext inSacs[]) {
033:
034: super (inCpc, NamesForSubCpc.getBaseSubPaneBarCpcName());
035: setColumnWidth(inColumnWidth);
036: this .iconUrls = inIconUrls;
037: this .iconLabels = inIconLabels;
038: this .sacs = inSacs;
039: }
040:
041: public final static BaseSubPaneBarConsolePageContext newInstance(
042: ConsolePageContext inCpc, int inHeight, int inColumnWidth,
043: String inIconUrls[], String inIconLabels[],
044: SubmitActionContext inSacs[]) throws IOException {
045:
046: BaseSubPaneBarConsolePageContext outValue = null;
047:
048: if (inCpc.isSubConsolePageContextPresent(NamesForSubCpc
049: .getBaseSubPaneBarCpcName())) {
050: //
051: Object o = inCpc.getSubConsolePageContext(NamesForSubCpc
052: .getBaseSubPaneBarCpcName());
053: outValue = (BaseSubPaneBarConsolePageContext) o;
054: } else {
055: outValue = new BaseSubPaneBarConsolePageContext(inCpc,
056: inHeight, inColumnWidth, inIconUrls, inIconLabels,
057: inSacs);
058: inCpc.registerSubConsolePageContext(NamesForSubCpc
059: .getBaseSubPaneBarCpcName(), outValue);
060: }
061:
062: outValue.copyFromParent(inCpc);
063: outValue.createConsolePage(inCpc.getWriter(), inCpc
064: .getPageSetupContext());
065:
066: return outValue;
067: }
068:
069: protected void renderConsolePage() throws IOException {
070:
071: final String BLANK_GIF = ConsolePageParameters.IMAGES_ROOT
072: + "/tree-blank.gif";
073:
074: //HashMap attrsMap = new HashMap();
075: //attrsMap.put("style", "background-color: #666666;");
076: //
077: startTable(this .iconUrls.length);
078: startRow();
079:
080: for (int i = 0; i < this .iconUrls.length; i++) {
081: String nextIconUrl = this .iconUrls[i];
082: String nextIconLabel = this .iconLabels[i];
083: SubmitActionContext nextSac = this .sacs[i];
084:
085: String content = null;
086: if (nextIconUrl != null) {
087: content = nextIconUrl;
088: } else {
089: content = BLANK_GIF;
090: }
091:
092: if (nextIconLabel != null) {
093: nextIconLabel = " title=\"" + nextIconLabel + "\"";
094: } else {
095: nextIconLabel = "";
096: }
097: content = ("<img border=\"0\" " + nextIconLabel + " src=\""
098: + content + "\" height=\"" + getColumnWidth()
099: + "\" width=\"" + getColumnWidth() + "\"/>");
100:
101: if (nextSac != null) {
102: content = "<a onmouseover=\"this.style.cursor = 'pointer';\""
103: + " onmouseout=\"this.style.cursor = 'default';\""
104: + " style=\"text-decoration: none;\" onclick=\""
105: + submitActionCall(nextSac)
106: + "\">"
107: + content
108: + "</a>";
109: } else {
110: //no change
111: }
112:
113: startAndEndCell(1, content);
114: }
115:
116: endRow();
117: endTable();
118: }
119:
120: }
|