KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > frontend > editor > NavigationPartEditor


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under 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.frontend.util.FormHelper;
22 import org.outerj.daisy.repository.Part;
23 import org.outerj.daisy.repository.Document;
24 import org.outerj.daisy.repository.Repository;
25 import org.outerj.daisy.repository.schema.PartTypeUse;
26
27 import java.util.Map JavaDoc;
28
29 public class NavigationPartEditor implements PartEditor {
30     private ServiceManager serviceManager;
31
32     private NavigationPartEditor(ServiceManager serviceManager) {
33         this.serviceManager = serviceManager;
34     }
35
36     public static class Factory implements PartEditorFactory {
37         public PartEditor getPartEditor(Map JavaDoc properties, ServiceManager serviceManager, Context context) {
38             return new NavigationPartEditor(serviceManager);
39         }
40     }
41
42     public Form getForm(PartTypeUse partTypeUse, DocumentEditorForm documentEditorForm, Repository repository) throws Exception JavaDoc {
43         Form form = FormHelper.createForm(serviceManager, "resources/form/parteditor_navigation_definition.xml");
44         form.getChild("navigation").addValidator(new PartRequiredValidator(documentEditorForm, partTypeUse.isRequired(), false));
45         return form;
46     }
47
48     public String JavaDoc getFormTemplate() {
49         return "resources/form/parteditor_navigation_template.xml";
50     }
51
52     public void load(Form form, Document document, Part part, Repository repository) throws Exception JavaDoc {
53         PartEditorHelper.load(form, part, "navigation");
54     }
55
56     public void save(Form form, Document document) throws Exception JavaDoc {
57         PartEditorHelper.save(form, document, "navigation", "text/xml");
58     }
59 }
60
Popular Tags