KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > tools > database > CmsHtmlImportBackoffice


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/database/CmsHtmlImportBackoffice.java,v $
3  * Date : $Date: 2006/03/27 14:52:49 $
4  * Version: $Revision: 1.7 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace.tools.database;
33
34 import org.opencms.file.CmsObject;
35 import org.opencms.main.CmsException;
36 import org.opencms.main.OpenCms;
37 import org.opencms.workplace.explorer.CmsNewResourceXmlPage;
38
39 import java.util.Iterator JavaDoc;
40 import java.util.Locale JavaDoc;
41 import java.util.TreeMap JavaDoc;
42
43 /**
44  * This class contains some utility methods for the HTMLImport Backoffice.<p>
45  *
46  * @author Michael Emmerich
47  *
48  * @version $Revision: 1.7 $
49  *
50  * @since 6.0.0
51  */

52 public final class CmsHtmlImportBackoffice {
53
54     /**
55      * Util class, not instanciable.<p>
56      */

57     private CmsHtmlImportBackoffice() {
58
59         // intentionally left blank
60
}
61
62     /**
63      * Returns a selectbox with all available locales.<p>
64      * @param selectedLocale the selected Locale
65      * @return a selectbox with all available locales
66      */

67     public static String JavaDoc getLocales(Locale JavaDoc selectedLocale) {
68
69         // the output buffer
70
StringBuffer JavaDoc output = new StringBuffer JavaDoc();
71         try {
72             Iterator JavaDoc i = OpenCms.getLocaleManager().getAvailableLocales().iterator();
73             // generate the HTML code for the selectbox
74
output.append("<select name=\"locale\" width=80 size=\"1\">");
75
76             // loop through all locales and build the entries
77
while (i.hasNext()) {
78                 Locale JavaDoc locale = (Locale JavaDoc)i.next();
79                 String JavaDoc language = locale.getLanguage();
80                 String JavaDoc displayLanguage = locale.getDisplayLanguage();
81                 output.append("<option ");
82                 if (selectedLocale.equals(locale)) {
83                     output.append("selected ");
84                 }
85                 output.append("value=\"");
86                 output.append(language);
87                 output.append("\">");
88                 output.append(displayLanguage);
89             }
90             output.append("</select>");
91         } catch (Exception JavaDoc e) {
92             System.err.println(e);
93         }
94
95         return new String JavaDoc(output);
96     }
97
98     /**
99      * Creates a selectbox with all available templates in the OpenCms system.<p>
100      *
101      * @param cms the current CmsObject
102      * @param selectedTemplate the preselcted template
103      * @return HTML-Code for the selectbox, containing all templates
104      */

105     public static String JavaDoc getTemplates(CmsObject cms, String JavaDoc selectedTemplate) {
106
107         // the output buffer
108
StringBuffer JavaDoc output = new StringBuffer JavaDoc();
109         TreeMap JavaDoc templates = null;
110
111         try {
112             templates = CmsNewResourceXmlPage.getTemplates(cms, null);
113
114             // generate the HTML code for the selectbox
115
output.append("<select name=\"template\" width=\"80\" size=\"1\">");
116
117             // loop through all templates and build the entries
118
Iterator JavaDoc i = templates.keySet().iterator();
119             while (i.hasNext()) {
120                 String JavaDoc title = (String JavaDoc)i.next();
121                 String JavaDoc path = (String JavaDoc)templates.get(title);
122                 output.append("<option ");
123                 if (selectedTemplate.equals(path)) {
124                     output.append("selected ");
125                 }
126                 output.append("value=\"");
127                 output.append(path);
128                 output.append("\">");
129                 output.append(title);
130             }
131             output.append("</select>");
132         } catch (CmsException e) {
133             System.err.println(e);
134         }
135
136         return new String JavaDoc(output);
137     }
138 }
139
Popular Tags