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.files;
04:
05: import fitnesse.*;
06: import fitnesse.authentication.*;
07: import fitnesse.responders.SecureResponder;
08: import fitnesse.html.*;
09: import fitnesse.http.*;
10:
11: public class RenameFileConfirmationResponder implements SecureResponder {
12: private String resource;
13:
14: public Response makeResponse(FitNesseContext context,
15: Request request) throws Exception {
16: SimpleResponse response = new SimpleResponse();
17: resource = request.getResource();
18: String filename = (String) request.getInput("filename");
19: response.setContent(makePageContent(filename, context));
20: return response;
21: }
22:
23: private String makePageContent(String filename,
24: FitNesseContext context) throws Exception {
25: HtmlPage page = context.htmlPageFactory.newPage();
26: page.title.use("Rename " + filename);
27: page.header.use(HtmlUtil.makeBreadCrumbsWithPageType(resource
28: + filename, "/", "Rename File"));
29: page.main.use(makeRenameFormHTML(filename));
30:
31: return page.html();
32: }
33:
34: private HtmlTag makeRenameFormHTML(String filename)
35: throws Exception {
36: HtmlTag form = HtmlUtil.makeFormTag("get", "/" + resource);
37: form.add(HtmlUtil.makeInputTag("hidden", "responder",
38: "renameFile"));
39:
40: form.add("Rename " + HtmlUtil.makeBold(filename).html()
41: + " to ");
42: form.add(HtmlUtil.BR);
43: form.add(HtmlUtil.BR);
44: form.add(HtmlUtil.BR);
45: form.add(HtmlUtil.makeInputTag("text", "newName", filename));
46: form.add(HtmlUtil
47: .makeInputTag("submit", "renameFile", "Rename"));
48: form.add(HtmlUtil.makeInputTag("hidden", "filename", filename));
49:
50: return form;
51: }
52:
53: public SecureOperation getSecureOperation() {
54: return new AlwaysSecureOperation();
55: }
56: }
|