1    /*
2     * Copyright 2007 :torweg free software group
3     * 
4     * This program is free software: you can redistribute it and/or modify
5     * it under the terms of the GNU General Public License as published by
6     * the Free Software Foundation, either version 3 of the License, or
7     * (at your option) any later version.
8     * 
9     * This program is distributed in the hope that it will be useful,
10    * but WITHOUT ANY WARRANTY; without even the implied warranty of
11    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    * GNU General Public License for more details.
13    * 
14    * You should have received a copy of the GNU General Public License
15    * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16    *
17    */
18   package org.torweg.pulse.site.content.admin;
19   
20   import java.io.File;
21   
22   import org.jdom.Element;
23   import org.torweg.pulse.configuration.AbstractConfigBean;
24   import org.torweg.pulse.configuration.PoorMansCache;
25   import org.torweg.pulse.util.xml.transform.XSLHandle;
26   
27   /**
28    * the configuration for {@code AbstractBasicContentEditor}.
29    * 
30    * @author Daniel Dietz
31    * @version $Revision: 1425 $
32    */
33   public class AbstractBasicContentEditorConfig extends AbstractConfigBean {
34   
35       /**
36        * The serialVersionUID.
37        */
38       private static final long serialVersionUID = -4703299920231190162L;
39   
40       /**
41        * The AJAX XSL, that builds the Editor.
42        */
43       private File ajaxXSLFile;
44   
45       /**
46        * the AJAX XSL, that builds the FCK-Editor.
47        */
48       private File ajaxFCKXSLFile;
49   
50       /**
51        * the AJAX XSL file used for summary reloads.
52        */
53       private File ajaxSummaryXSLFile;
54   
55       /**
56        * the AJAX XSL, that builds the ContentLocalizationMap-Editor.
57        */
58       private File ajaxContentLocalizationMapXSLFile;
59   
60       /**
61        * the AJAX XSL, that builds the file-browser-panel for the
62        * attachments-editor.
63        */
64       private File ajaxAttachmentsXSLFile;
65   
66       /**
67        * the AJAX XSL, that builds the reference duration editor panel.
68        */
69       private File ajaxReferenceDurationXSLFile;
70   
71       /**
72        * returns the XSLHandle for AJAX responses.
73        * 
74        * @return the XSLHandle for AJAX responses
75        */
76       public final XSLHandle getAjaxXSL() {
77           return PoorMansCache.getXSLHandle(this.ajaxXSLFile);
78       }
79   
80       /**
81        * returns the XSLHandle for AJAX responses.
82        * 
83        * @return the XSLHandle for AJAX responses
84        */
85       public final XSLHandle getFCKAjaxXSL() {
86           return PoorMansCache.getXSLHandle(this.ajaxFCKXSLFile);
87       }
88   
89       /**
90        * returns the XSLHandle for AJAX responses.
91        * 
92        * @return the XSLHandle for AJAX responses
93        */
94       public final XSLHandle getAjaxSummaryXSL() {
95           return PoorMansCache.getXSLHandle(this.ajaxSummaryXSLFile);
96       }
97   
98       /**
99        * returns the XSLHandle for AJAX responses.
100       * 
101       * @return the XSLHandle for AJAX responses
102       */
103      public final XSLHandle getAjaxContentLocalizationMapXSL() {
104          return PoorMansCache
105                  .getXSLHandle(this.ajaxContentLocalizationMapXSLFile);
106      }
107  
108      /**
109       * returns the XSLHandle for AJAX responses.
110       * 
111       * @return the XSLHandle for AJAX responses
112       */
113      public final XSLHandle getAttachmentsAjaxXSL() {
114          return PoorMansCache.getXSLHandle(this.ajaxAttachmentsXSLFile);
115      }
116  
117      /**
118       * returns the XSLHandle for AJAX responses.
119       * 
120       * @return the XSLHandle for AJAX responses
121       */
122      public final XSLHandle getAjaxReferenceDurationEditorXSL() {
123          return PoorMansCache.getXSLHandle(this.ajaxReferenceDurationXSLFile);
124      }
125  
126      /**
127       * initialises the {@code ConfigBean}.
128       * 
129       * @param conf
130       *            the configuration XML
131       * @see org.torweg.pulse.configuration.ConfigBean#init(org.jdom.Element)
132       */
133      public void init(final Element conf) {
134          if (conf.getChildren().size() > 0) {
135              if (conf.getChild("ajax") != null) {
136                  this.ajaxXSLFile = new File(conf.getChild("ajax")
137                          .getAttributeValue("xsl"));
138              }
139              if (conf.getChild("ajaxFCK") != null) {
140                  this.ajaxFCKXSLFile = new File(conf.getChild("ajaxFCK")
141                          .getAttributeValue("xsl"));
142              }
143              if (conf.getChild("ajaxSummary") != null) {
144                  this.ajaxSummaryXSLFile = new File(conf.getChild("ajaxSummary")
145                          .getAttributeValue("xsl"));
146              }
147              if (conf.getChild("ajaxContentLocalizationMap") != null) {
148                  this.ajaxContentLocalizationMapXSLFile = new File(conf
149                          .getChild("ajaxContentLocalizationMap")
150                          .getAttributeValue("xsl"));
151              }
152              if (conf.getChild("ajaxAttachments") != null) {
153                  this.ajaxAttachmentsXSLFile = new File(conf.getChild(
154                          "ajaxAttachments").getAttributeValue("xsl"));
155              }
156              if (conf.getChild("ajaxReferenceDuration") != null) {
157                  this.ajaxReferenceDurationXSLFile = new File(conf.getChild(
158                          "ajaxReferenceDuration").getAttributeValue("xsl"));
159              }
160          }
161      }
162  
163  }
164