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.web.admin.config.instance;
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.ConceptRollupTag;
017: import org.jfolder.common.tagging.ConceptTagPreferences;
018: import org.jfolder.common.utils.misc.MiscHelper;
019: import org.jfolder.common.utils.xml.XMLHelper;
020: import org.jfolder.common.web.template.ConsoleParameterContext;
021: import org.jfolder.common.web.template.SubmitActionContext;
022: import org.jfolder.common.web.template.SubmitActionParameters;
023: import org.jfolder.console.base.ConsolePageContext;
024: import org.jfolder.console.base.ConsolePageParameters;
025: import org.jfolder.console.base.ConsolePageSession;
026: import org.jfolder.console.base.NamesForParentCpc;
027: import org.jfolder.console.base.context.SubMessageHolderConsolePageContext;
028: import org.jfolder.services.workflow.WorkflowServiceCaller;
029: import org.jfolder.services.workflow.WorkflowServiceCallerFactory;
030:
031: //other classes
032:
033: public class ConfigInstanceContext extends ConsolePageContext {
034:
035: private final static String BUTTON__SAVE = "BUTTON__SAVE";
036: private final static String BUTTON__EXPORT = "BUTTON__EXPORT";
037: private final static String BUTTON__CANCEL = "BUTTON__CANCEL";
038: private final static String BUTTON__REFRESH = "BUTTON__REFRESH";
039:
040: //private ConsoleMacroContext(ConsolePageSession inCps) {
041: // super(inCps);
042: //}
043:
044: private ConfigInstanceContext(ConsolePageSession inCps) {
045:
046: super (inCps);
047: //
048: setIndentIncrement(1);
049: //
050: ConceptTagPreferences localCtp = inCps
051: .getCurrentApplicationRootHolder().getPreferences();
052: //setTreeState(ConsolePageParameters.BRANCH_SEPARATOR
053: // + localCtp.getRootHandle()
054: // + ConsolePageParameters.BRANCH_SEPARATOR);
055: setTreeState(localCtp.getRootHandle());
056: setHighlightHandle(localCtp.getRootHandle());
057: }
058:
059: public final static ConfigInstanceContext newInstance(
060: ConsolePageSession inCps) {
061:
062: ConfigInstanceContext outValue = null;
063:
064: if (inCps.isConsolePageContextPresent(NamesForParentCpc
065: .getConfigInstanceCpcName(inCps))) {
066: //
067: Object o = inCps.getConsolePageContext(NamesForParentCpc
068: .getConfigInstanceCpcName(inCps));
069: outValue = (ConfigInstanceContext) o;
070: } else {
071: outValue = new ConfigInstanceContext(inCps);
072: ConceptTagPreferences localCtp = inCps
073: .getCurrentApplicationRootHolder().getPreferences();
074: String rootHandle = localCtp.getRootHandle();
075: outValue.setDefaultHighlightHandle(rootHandle);
076: inCps.registerConsolePageContext(NamesForParentCpc
077: .getConfigInstanceCpcName(inCps), outValue);
078: }
079:
080: return outValue;
081: }
082:
083: //public final static ConsoleMacroContext newInstance(
084: // ConsolePageSession inCps) {
085: //
086: // ConsoleMacroContext outValue = null;
087: //
088: // outValue = new ConsoleMacroContext(inCps);
089: //
090: // return outValue;
091: //}
092:
093: public String getFromPage() {
094: //
095: //
096: return ConsolePageParameters.SERVLET_CONFIG_STUDIO;
097: }
098:
099: public String getHandleExtension() {
100: return NULL_HANDLE;
101: }
102:
103: //ConsoleScreenHelper
104: protected void renderConsolePage() throws IOException {
105:
106: startCommonPage();
107:
108: ConsolePageSession cs = getConsolePageSession();
109:
110: //
111: startEnclosingTableAndRowAndCell(alignCenter(null));
112: startAndEndStretchTableAndRowAndCell("<hr/>");
113: //
114: startAndEndSimpleTableAndRowAndCell(2, "Config Studio",
115: alignCenter(getFontStyle(20, ARIAL, BLACK)));
116:
117: //
118: SubMessageHolderConsolePageContext
119: .renderMessagesIfPresent(this );
120: //
121: startAndEndStretchTableAndRowAndCell("<hr/>");
122: //
123: SubmitActionContext sacSave = SubmitActionContext
124: .newInstance(this );
125: sacSave.addAction(ConsoleParameterContext.FIRST_INPUT,
126: singleQuotes(SubmitActionParameters.SAVE));
127: //
128: SubmitActionContext sacExport = SubmitActionContext
129: .newInstance(this );
130: sacExport.addAction(ConsoleParameterContext.FIRST_INPUT,
131: singleQuotes(SubmitActionParameters.EXPORT));
132: //
133: SubmitActionContext sacCancel = SubmitActionContext
134: .newInstance(this );
135: sacCancel.addAction(ConsoleParameterContext.FIRST_INPUT,
136: singleQuotes(SubmitActionParameters.RETURN));
137: sacCancel.setGoToPage(ConsolePageParameters.SERVLET_CONSOLE);
138: //
139: SubmitActionContext sacRefresh = SubmitActionContext
140: .newInstance(this );
141: sacRefresh.addAction(ConsoleParameterContext.FIRST_INPUT,
142: singleQuotes(SubmitActionParameters.REFRESH));
143: //
144: //startEnclosingTableAndRowAndCell(alignCenter(null));
145: startTable(4);
146: startRow();
147: startCell(4);
148: //
149: //
150: int localColWidth = (getColumnWidth() * 4) / 4;
151: simpleAndPrint("<table align=\"center\">");
152: simpleAndPrint("<tr>");
153: simpleAndPrint("<td width=\"" + localColWidth
154: + "\" align=\"center\">");
155: createButton(BUTTON__SAVE, "Save", 75,
156: submitActionCall(sacSave), null, null, null, null);
157: simpleAndPrint("</td>");
158: simpleAndPrint("<td width=\"" + localColWidth
159: + "\" align=\"center\">");
160: createButton(BUTTON__EXPORT, "Export", 75,
161: submitActionCall(sacExport), null, null, null, null);
162: simpleAndPrint("</td>");
163: //endCell();
164: //startCell(1);
165: simpleAndPrint("<td width=\"" + localColWidth
166: + "\" align=\"center\">");
167: createButton(BUTTON__CANCEL, "Cancel", 75,
168: submitActionCall(sacCancel), null, null, null, null);
169: simpleAndPrint("</td>");
170: //endCell();
171: //startCell(1);
172: simpleAndPrint("<td width=\"" + localColWidth
173: + "\" align=\"center\">");
174: createButton(BUTTON__REFRESH, "Refresh", 75,
175: submitActionCall(sacRefresh), null, null, null, null);
176: simpleAndPrint("</td>");
177: simpleAndPrint("</tr>");
178: simpleAndPrint("</table>");
179: //
180: //
181: endCell();
182: endRow();
183: endTable();
184: //
185: startAndEndStretchTableAndRowAndCell("<hr/>");
186: //
187: ConfigInstanceUpDownContext.newInstance(this , "temp", "other");
188: //
189: endEnclosingTableAndRowAndCell();
190:
191: endCommonPage();
192: }
193:
194: }
|