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.macro.execute;
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.utils.misc.MiscHelper;
018: import org.jfolder.common.utils.xml.XMLHelper;
019: import org.jfolder.common.web.template.ConsoleParameterContext;
020: import org.jfolder.common.web.template.SubmitActionContext;
021: import org.jfolder.common.web.template.SubmitActionParameters;
022: import org.jfolder.console.base.ConsolePageContext;
023: import org.jfolder.console.base.ConsolePageParameters;
024: import org.jfolder.console.base.ConsolePageSession;
025: import org.jfolder.console.macro.ConsoleMacro;
026: import org.jfolder.services.workflow.WorkflowServiceCaller;
027: import org.jfolder.services.workflow.WorkflowServiceCallerFactory;
028:
029: //other classes
030:
031: public class ConsoleMacroExecuteContext extends ConsolePageContext {
032:
033: //
034: //
035: private final static String BUTTON__START_REP = "BUTTON__START_REP";
036: private final static String BUTTON__GO_BACK = "BUTTON__GO_BACK";
037: private final static String BUTTON__APP = "BUTTON__APP";
038: private final static String INPUT_REP_MAC_UPL = "INPUT_REP_MAC_UPL";
039: //
040: private final static String BUTTON__LOAD = "BUTTON__LOAD";
041: private final static String INPUT_LOD_MAC_UPL = "INPUT_LOD_MAC_UPL";
042: //
043: private final static String BUTTON__CRE_PET_STO = "BUTTON__CRE_PET_STO";
044: //
045: private final static String FILE_UPLOAD__APP_PROGRESS = "FILE_UPLOAD__APP_PROGRESS";
046: //
047: private final static String DROP_DOWN__PET_STORE_DATABASE = "DROP_DOWN__PET_STORE_DATABASE";
048:
049: //
050: private ConsoleMacroExecuteContext(ConsolePageSession inCps) {
051: super (inCps);
052: }
053:
054: public final static ConsoleMacroExecuteContext newInstance(
055: ConsolePageSession inCps) {
056:
057: ConsoleMacroExecuteContext outValue = null;
058:
059: outValue = new ConsoleMacroExecuteContext(inCps);
060:
061: return outValue;
062: }
063:
064: public String getFromPage() {
065: //
066: //
067: return ConsolePageParameters.SERVLET_MACRO_EXECUTE;
068: }
069:
070: public String getHandleExtension() {
071: return NULL_HANDLE;
072: }
073:
074: //ConsoleScreenHelper
075: protected void renderConsolePage() throws IOException {
076:
077: startCommonPage();
078:
079: ConsolePageSession localCps = getConsolePageSession();
080:
081: //
082: startEnclosingTableAndRowAndCell(alignCenter(null));
083: startAndEndStretchTableAndRowAndCell("<hr/>");
084: //
085: startTable(3);
086: startRow();
087: startAndEndCell(3, "Execute Macro", alignCenter(getFontStyle(
088: 20, ARIAL, BLACK)));
089: endRow();
090: endTable();
091:
092: //
093: if (localCps.isCurrentMacroPresent()) {
094: renderStartReplaying();
095: }
096: renderLoad();
097: //renderCreatePetStore();
098: //
099: //
100: //
101: //
102: startAndEndStretchTableAndRowAndCell("<hr/>");
103: //
104: startTable(3);
105: startRow();
106: startCell(3, alignCenter(null));
107: //
108: SubmitActionContext sacGoBack = SubmitActionContext
109: .newInstance(this );
110: sacGoBack.setGoToPage(ConsolePageParameters.SERVLET_CONSOLE);
111: sacGoBack.addAction(ConsoleParameterContext.FIRST_INPUT,
112: singleQuotes(SubmitActionParameters.RETURN));
113: sacGoBack.addAction(ConsoleParameterContext.SECOND_INPUT,
114: singleQuotes(SubmitActionParameters.EXECUTE_MACRO));
115: createButton(BUTTON__GO_BACK, "Go Back", 250,
116: submitActionCall(sacGoBack), null, null, null, null);
117: //
118: endCell();
119: endRow();
120: endTable();
121: //
122: //
123: //
124: //
125: //
126:
127: startAndEndStretchTableAndRowAndCell("<hr/>");
128: endEnclosingTableAndRowAndCell();
129:
130: endCommonPage();
131: }
132:
133: private void renderLoad() throws IOException {
134: //
135: ConsolePageSession localCps = getConsolePageSession();
136: //
137: startAndEndStretchTableAndRowAndCell("<hr/>");
138: //
139: //
140: //
141: String fileUpload = createFileUpload(INPUT_LOD_MAC_UPL,
142: new Integer(25));
143: String fileUploadId = localCps.getPreviousToggleLink();
144: //
145: //startAndEndStretchTableAndRowAndCell("<hr/>");
146: //
147:
148: startTable(3);
149: startRow();
150: startCell(1, alignCenter(null));
151:
152: SubmitActionContext sacLoad = SubmitActionContext
153: .newInstance(this );
154: //
155: //sacStartReplaying.setGoToPage(ConsolePageParameters.SERVLET_CONSOLE);
156: //
157: sacLoad.addAction(ConsoleParameterContext.FIRST_INPUT,
158: singleQuotes(SubmitActionParameters.LOAD));
159: //
160: sacLoad.addParameter(ConsoleParameterContext.FIRST_INPUT,
161: singleQuotes(fileUploadId));
162: //
163: createButton(BUTTON__LOAD, "Load", 150,
164: submitActionCall(sacLoad), null, null, null, null);
165:
166: endCell();
167: startCell(2);
168:
169: simpleAndPrint(fileUpload);
170:
171: endCell();
172: endRow();
173: endTable();
174: //
175: //
176: //
177: }
178:
179: private void renderCreatePetStoreOld() throws IOException {
180: //
181: ConsolePageSession localCps = getConsolePageSession();
182: //
183: startAndEndStretchTableAndRowAndCell("<hr/>");
184: //
185: //
186: //
187: //String fileUpload = createFileUpload(
188: // INPUT_LOD_MAC_UPL, new Integer(5));
189: //String fileUploadId = localCps.getPreviousToggleLink();
190: //
191: //startAndEndStretchTableAndRowAndCell("<hr/>");
192: //
193: ArrayList databaseLabels = new ArrayList();
194: ArrayList databaseValues = new ArrayList();
195: HashMap databaseStyles = new HashMap();
196: databaseStyles.put("width", getColumnWidth() + "");
197: PetStoreDatabase.getDatabases(databaseLabels, databaseValues);
198: //
199: //
200: //
201: String databaseDropDown = createDropDownBox(
202: DROP_DOWN__PET_STORE_DATABASE, databaseLabels,
203: databaseValues, null, databaseStyles, 0, null, null,
204: null);
205: String databaseId = localCps.getPreviousToggleLink();
206:
207: startTable(3);
208: //
209: //
210: //
211: startRow();
212: startCell(3, alignCenter(null));
213: //
214: SubmitActionContext sacCreatePetStore = SubmitActionContext
215: .newInstance(this );
216: //
217: sacCreatePetStore.addAction(
218: ConsoleParameterContext.FIRST_INPUT,
219: singleQuotes(SubmitActionParameters.CREATE_PET_STORE));
220: //
221: sacCreatePetStore.addParameter(
222: ConsoleParameterContext.FIRST_INPUT,
223: getPageComponentValue(databaseId));
224: //
225: createButton(BUTTON__CRE_PET_STO, "Create Pet Store", 250,
226: submitActionCall(sacCreatePetStore), null, null, null,
227: null);
228: //
229: endCell();
230: endRow();
231: //
232: //
233: //
234: startRow();
235: startAndEndCell(3, createHorizontalRow(2, new Integer(100)),
236: alignCenter(null));
237: endRow();
238: //
239: //
240: //
241: endTable();
242: //
243: //
244: //
245: startTable(3);
246: startRow();
247: //
248: //
249: startAndEndCell(1, "Use Database -", getFontStyle(12, ARIAL,
250: BLACK));
251: startAndEndCell(2, databaseDropDown);
252: //
253: //
254: endRow();
255: endTable();
256: }
257:
258: //
259: private final static String DROP_DOWN__START_AT = "DROP_DOWN__START_AT";
260: private final static String DROP_DOWN__END_AT = "DROP_DOWN__END_AT";
261: private final static String DROP_DOWN__SPEED = "DROP_DOWN__SPEED";
262:
263: //
264: private void renderStartReplaying() throws IOException {
265: //
266: ConsolePageSession localCps = getConsolePageSession();
267: ConsoleMacro localCm = localCps.getCurrentMacroAsMacro();
268: ArrayList localDesc = localCm.getPageDescriptions();
269: //
270: //
271: HashMap selectStyles = new HashMap();
272: selectStyles.put("width", (2 * getColumnWidth()) + "px");
273: //
274: //
275: ArrayList selectLabels = new ArrayList(localDesc);
276: ArrayList selectValues = new ArrayList(localDesc);
277: //
278: selectLabels.add(0, "(Start At Beginning)");
279: selectValues.add(0, "");
280: //
281: //
282: String startAtDropDown = createDropDownBox(DROP_DOWN__START_AT,
283: selectLabels, selectValues, null, selectStyles, 0,
284: null, null, null);
285: String startAtId = localCps.getPreviousToggleLink();
286: //
287: selectLabels.remove(0);
288: selectLabels.add(0, "(End After Last Step)");
289: String endAtDropDown = createDropDownBox(DROP_DOWN__END_AT,
290: selectLabels, selectValues, null, selectStyles, 0,
291: null, null, null);
292: String endAtId = localCps.getPreviousToggleLink();
293: //
294: //
295: //
296: String appTextBox = createTextBox(BUTTON__APP,
297: "SamplePetStore", null, selectStyles, null, null, null);
298: String appId = localCps.getPreviousToggleLink();
299: //
300: //
301: //
302: String appProgressUpload = createFileUpload(
303: FILE_UPLOAD__APP_PROGRESS, new Integer(25));
304: String appProgressId = localCps.getPreviousToggleLink();
305: //
306: //
307: //
308: //
309: ArrayList speedLabels = new ArrayList();
310: speedLabels.add("1000 ms");
311: speedLabels.add("500 ms");
312: speedLabels.add("200 ms");
313: speedLabels.add("100 ms");
314: speedLabels.add("50 ms");
315: speedLabels.add("10 ms");
316: speedLabels.add("1 ms");
317: ArrayList speedValues = new ArrayList();
318: speedValues.add("1000");
319: speedValues.add("500");
320: speedValues.add("200");
321: speedValues.add("100");
322: speedValues.add("50");
323: speedValues.add("10");
324: speedValues.add("1");
325: //
326: String speedDropDown = createDropDownBox(DROP_DOWN__SPEED,
327: speedLabels, speedValues, null, selectStyles, 5, null,
328: null, null);
329: String speedId = localCps.getPreviousToggleLink();
330: //
331: //
332: //
333: startAndEndStretchTableAndRowAndCell("<hr/>");
334: //
335: //
336: //
337: //String fileUpload = createFileUpload(
338: // INPUT_REP_MAC_UPL, new Integer(5));
339: //String fileUploadId = localCps.getPreviousToggleLink();
340: //
341: //startAndEndStretchTableAndRowAndCell("<hr/>");
342: //
343:
344: startTable(3);
345: startRow();
346: startCell(3, alignCenter(null));
347:
348: SubmitActionContext sacStartReplaying = SubmitActionContext
349: .newInstance(this );
350: //
351: sacStartReplaying
352: .setGoToPage(ConsolePageParameters.SERVLET_CONSOLE);
353: //
354: sacStartReplaying.addAction(
355: ConsoleParameterContext.FIRST_INPUT,
356: singleQuotes(SubmitActionParameters.START_REPLAYING));
357: //
358: sacStartReplaying.addParameter(
359: ConsoleParameterContext.FIRST_INPUT,
360: getPageComponentValue(startAtId));
361: sacStartReplaying.addParameter(
362: ConsoleParameterContext.SECOND_INPUT,
363: getPageComponentValue(endAtId));
364: sacStartReplaying.addParameter(
365: ConsoleParameterContext.THIRD_INPUT,
366: getPageComponentValue(appId));
367: sacStartReplaying.addParameter(
368: ConsoleParameterContext.FOURTH_INPUT,
369: getPageComponentValue(appProgressId));
370: sacStartReplaying.addParameter(
371: ConsoleParameterContext.FIFTH_INPUT,
372: getPageComponentValue(speedId));
373: //sacStartReplaying.addParameter(
374: // sacStartReplaying.FIRST_INPUT,
375: // singleQuotes(fileUploadId));
376: //
377: createButton(BUTTON__START_REP, "Start Replaying", 250,
378: submitActionCall(sacStartReplaying), null, null, null,
379: null);
380:
381: endCell();
382: //startCell(1);
383: //
384: //simpleAndPrint(fileUpload);
385: //
386: //endCell();
387: endRow();
388: endTable();
389: //
390: startTable(3);
391: startRow();
392: startCell(3, alignCenter(null));
393: simpleAndPrint(createHorizontalRow(2, new Integer(100)));
394: endCell();
395: endRow();
396: endTable();
397: //
398: //
399: //
400: startTable(3);
401: startRow();
402: startCell(1, getFontStyle(12, ARIAL, BLACK));
403: simpleAndPrint("Start Right At -");
404: endCell();
405: startCell(2);
406: simpleAndPrint(startAtDropDown);
407: endCell();
408: endRow();
409: endTable();
410: //
411: //
412: createHorizontalRow(1);
413: //
414: startTable(3);
415: startRow();
416: startCell(1, getFontStyle(12, ARIAL, BLACK));
417: simpleAndPrint("End Just Before -");
418: endCell();
419: startCell(2);
420: simpleAndPrint(endAtDropDown);
421: endCell();
422: endRow();
423: endTable();
424: //
425: //
426: createHorizontalRow(1);
427: //
428: startTable(3);
429: startRow();
430: startCell(1, getFontStyle(12, ARIAL, BLACK));
431: simpleAndPrint("Pre-Undeploy -");
432: endCell();
433: startCell(2);
434: simpleAndPrint(appTextBox);
435: endCell();
436: endRow();
437: endTable();
438: //
439: //
440: createHorizontalRow(1);
441: //
442: startTable(3);
443: startRow();
444: startCell(1, getFontStyle(12, ARIAL, BLACK));
445: simpleAndPrint("Application Progress -");
446: endCell();
447: startCell(2);
448: simpleAndPrint(appProgressUpload);
449: endCell();
450: endRow();
451: endTable();
452: //
453: //
454: createHorizontalRow(1);
455: //
456: startTable(3);
457: startRow();
458: startCell(1, getFontStyle(12, ARIAL, BLACK));
459: simpleAndPrint("Speed -");
460: endCell();
461: startCell(2);
462: simpleAndPrint(speedDropDown);
463: endCell();
464: endRow();
465: endTable();
466: }
467: }
|