01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.responders.editing;
04:
05: import fitnesse.http.*;
06: import fitnesse.wiki.WikiPage;
07: import fitnesse.components.*;
08:
09: public class TableWizardResponder extends EditResponder {
10: private Request request;
11:
12: protected void initializeResponder(WikiPage root, Request request) {
13: this .root = root;
14: this .request = request;
15: }
16:
17: protected String createPageContent() throws Exception {
18: String textAreaContent = (String) request.getInput("text");
19: String fixtureName = (String) request.getInput("fixture");
20: String template = createFixtureTableTemplate(fixtureName);
21: if (!template.equals(""))
22: template = "\n" + template;
23: return textAreaContent + template;
24: }
25:
26: private String createFixtureTableTemplate(String fixtureName)
27: throws Exception {
28: String commandLine = createCommandLine(page, fixtureName);
29: CommandRunner runner = new CommandRunner(commandLine, null);
30: runner.run();
31: return runner.getOutput() + runner.getError();
32: }
33:
34: protected String createCommandLine(WikiPage page, String fixtureName)
35: throws Exception {
36: String classpath = new ClassPathBuilder().getClasspath(page);
37:
38: return "java -cp " + classpath
39: + " fitnesse.FixtureTemplateCreator " + fixtureName;
40: }
41: }
|