01: /*
02: * Copyright 2004 Outerthought bvba and Schaubroeck nv
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package org.outerj.daisy.frontend.editor;
17:
18: import org.apache.cocoon.forms.formmodel.Form;
19: import org.apache.avalon.framework.service.ServiceManager;
20: import org.apache.avalon.framework.context.Context;
21: import org.outerj.daisy.repository.schema.PartTypeUse;
22: import org.outerj.daisy.repository.Repository;
23: import org.outerj.daisy.repository.Document;
24: import org.outerj.daisy.repository.Part;
25: import org.outerj.daisy.frontend.util.FormHelper;
26:
27: import java.util.Map;
28:
29: public class LiteralHtmlPartEditor implements PartEditor {
30: private final ServiceManager serviceManager;
31:
32: private LiteralHtmlPartEditor(ServiceManager serviceManager) {
33: this .serviceManager = serviceManager;
34: }
35:
36: public static class Factory implements PartEditorFactory {
37: public PartEditor getPartEditor(Map properties,
38: ServiceManager serviceManager, Context context) {
39: return new LiteralHtmlPartEditor(serviceManager);
40: }
41: }
42:
43: public Form getForm(PartTypeUse partTypeUse,
44: DocumentEditorForm documentEditorForm, Repository repository)
45: throws Exception {
46: Form form = FormHelper.createForm(serviceManager,
47: "resources/form/parteditor_literalhtml_definition.xml");
48: return form;
49: }
50:
51: public String getFormTemplate() {
52: return "resources/form/parteditor_literalhtml_template.xml";
53: }
54:
55: public void load(Form form, Document document, Part part,
56: Repository repository) throws Exception {
57: PartEditorHelper.load(form, part, "literalhtmldata");
58: }
59:
60: public void save(Form form, Document document) throws Exception {
61: PartEditorHelper.save(form, document, "literalhtmldata",
62: "text/xml");
63: }
64: }
|