KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > setup > xml > CmsXmlAddImgGalleryContextMenues


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/setup/xml/CmsXmlAddImgGalleryContextMenues.java,v $
3  * Date : $Date: 2006/03/27 14:52:44 $
4  * Version: $Revision: 1.2 $
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.setup.xml;
33
34 import org.opencms.configuration.CmsConfigurationManager;
35 import org.opencms.configuration.CmsWorkplaceConfiguration;
36 import org.opencms.configuration.I_CmsXmlConfiguration;
37 import org.opencms.file.CmsPropertyDefinition;
38 import org.opencms.util.CmsStringUtil;
39 import org.opencms.xml.CmsXmlUtils;
40
41 import java.util.ArrayList JavaDoc;
42 import java.util.List JavaDoc;
43
44 import org.dom4j.Document;
45 import org.dom4j.Node;
46
47 /**
48  * Adds the new rename and comment context menues for image galleries.<p>
49  *
50  * @author Michael Moossen
51  *
52  * @version $Revision: 1.2 $
53  *
54  * @since 6.1.8
55  */

56 public class CmsXmlAddImgGalleryContextMenues extends A_CmsXmlWorkplace {
57
58     /** List of xpaths to update. */
59     private List JavaDoc m_xpaths;
60
61     /**
62      * @see org.opencms.setup.xml.I_CmsSetupXmlUpdate#getName()
63      */

64     public String JavaDoc getName() {
65
66         return "Add new Rename and Comment context menues for Image Galleries";
67     }
68
69     /**
70      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#executeUpdate(org.dom4j.Document, java.lang.String)
71      */

72     protected boolean executeUpdate(Document document, String JavaDoc xpath) {
73
74         Node node = document.selectSingleNode(xpath);
75         if (xpath.indexOf(CmsWorkplaceConfiguration.N_ENTRY) > 0) {
76             if (node == null) {
77                 String JavaDoc xp = CmsXmlUtils.removeLastComplexXpathElement(xpath);
78                 setMenuEntry(
79                     document,
80                     xp,
81                     "explorer.context.renameimages",
82                     "commons/renameimages.jsp",
83                     "d d iiii aaai dddd",
84                     "85");
85                 setMenuEntry(
86                     document,
87                     xp,
88                     "explorer.context.commentimages",
89                     "commons/commentimages.jsp",
90                     "d d iiii aaai dddd",
91                     "90");
92                 return true;
93             }
94         } else if (xpath.indexOf(CmsWorkplaceConfiguration.A_REFERENCE + "=") > 0) {
95             if (node != null) {
96                 CmsSetupXmlHelper.setValue(
97                     document,
98                     xpath + "/@" + CmsWorkplaceConfiguration.A_REFERENCE,
99                     "downloadgallery");
100                 return true;
101             }
102         } else if (xpath.indexOf(CmsWorkplaceConfiguration.A_REFERENCE) > 0) {
103             if (node != null) {
104                 CmsSetupXmlHelper.setValue(document, xpath, null);
105                 return true;
106             }
107         } else {
108             if (node == null) {
109                 CmsSetupXmlHelper.setValue(document, xpath
110                     + "/"
111                     + CmsWorkplaceConfiguration.N_DEFAULTPROPERTIES
112                     + "/@"
113                     + I_CmsXmlConfiguration.A_ENABLED, Boolean.TRUE.toString());
114                 CmsSetupXmlHelper.setValue(document, xpath
115                     + "/"
116                     + CmsWorkplaceConfiguration.N_DEFAULTPROPERTIES
117                     + "/@"
118                     + CmsWorkplaceConfiguration.A_SHOWNAVIGATION, Boolean.TRUE.toString());
119                 CmsSetupXmlHelper.setValue(document, xpath
120                     + "/"
121                     + CmsWorkplaceConfiguration.N_DEFAULTPROPERTIES
122                     + "[1]/"
123                     + I_CmsXmlConfiguration.N_PROPERTY
124                     + "/@"
125                     + I_CmsXmlConfiguration.A_NAME, CmsPropertyDefinition.PROPERTY_TITLE);
126
127                 xpath += "/" + CmsWorkplaceConfiguration.N_CONTEXTMENU;
128                 setMenuEntry(document, xpath, "explorer.context.lock", "commons/lock.jsp", "d d aaaa dddd dddd", "10");
129                 setMenuEntry(
130                     document,
131                     xpath,
132                     "explorer.context.overridelock",
133                     "commons/lockchange.jsp",
134                     "d d dddd dddd aaaa",
135                     "20");
136                 setMenuEntry(
137                     document,
138                     xpath,
139                     "explorer.context.unlock",
140                     "commons/unlock.jsp",
141                     "d d dddd aaaa dddd",
142                     "30");
143                 CmsSetupXmlHelper.setValue(document, xpath
144                     + "/"
145                     + CmsWorkplaceConfiguration.N_SEPARATOR
146                     + "[@"
147                     + I_CmsXmlConfiguration.A_ORDER
148                     + "='40']"
149                     + "/@"
150                     + I_CmsXmlConfiguration.A_ORDER, "40");
151                 setMenuEntry(
152                     document,
153                     xpath,
154                     "explorer.context.copytoproject",
155                     "commons/copytoproject.jsp",
156                     "d a dddd dddd dddd",
157                     "50");
158                 setMenuEntry(
159                     document,
160                     xpath,
161                     "explorer.context.publish",
162                     "commons/publishresource.jsp",
163                     "d d aaaa aaaa dddd",
164                     "60");
165                 CmsSetupXmlHelper.setValue(document, xpath
166                     + "/"
167                     + CmsWorkplaceConfiguration.N_SEPARATOR
168                     + "[@"
169                     + I_CmsXmlConfiguration.A_ORDER
170                     + "='70']"
171                     + "/@"
172                     + I_CmsXmlConfiguration.A_ORDER, "70");
173                 setMenuEntry(
174                     document,
175                     xpath,
176                     "explorer.context.opengallery",
177                     "commons/opengallery.jsp",
178                     "d d iiii aaai dddd",
179                     "80");
180                 CmsSetupXmlHelper.setValue(document, xpath
181                     + "/"
182                     + CmsWorkplaceConfiguration.N_SEPARATOR
183                     + "[@"
184                     + I_CmsXmlConfiguration.A_ORDER
185                     + "='100']"
186                     + "/@"
187                     + I_CmsXmlConfiguration.A_ORDER, "100");
188                 setMenuEntry(document, xpath, "explorer.context.copy", "commons/copy.jsp", "d d iiii aaai dddd", "150");
189                 setMenuEntry(document, xpath, "explorer.context.move", "commons/move.jsp", "d d iiii aaai dddd", "170");
190                 setMenuEntry(
191                     document,
192                     xpath,
193                     "explorer.context.delete",
194                     "commons/delete.jsp",
195                     "d d iiii aaai dddd",
196                     "180");
197                 setMenuEntry(
198                     document,
199                     xpath,
200                     "explorer.context.touch",
201                     "commons/touch.jsp",
202                     "d d iiii aaai dddd",
203                     "190");
204                 setMenuEntry(
205                     document,
206                     xpath,
207                     "explorer.context.availability",
208                     "commons/availability.jsp",
209                     "d d iiii aaai dddd",
210                     "200");
211                 setMenuEntry(
212                     document,
213                     xpath,
214                     "explorer.context.undochanges",
215                     "commons/undochanges.jsp",
216                     "d d iiid aaid dddd",
217                     "210");
218                 setMenuEntry(
219                     document,
220                     xpath,
221                     "explorer.context.undelete",
222                     "commons/undelete.jsp",
223                     "d d ddda ddda dddd",
224                     "220");
225                 CmsSetupXmlHelper.setValue(document, xpath
226                     + "/"
227                     + CmsWorkplaceConfiguration.N_SEPARATOR
228                     + "[@"
229                     + I_CmsXmlConfiguration.A_ORDER
230                     + "='240']"
231                     + "/@"
232                     + I_CmsXmlConfiguration.A_ORDER, "240");
233                 setMenuEntry(
234                     document,
235                     xpath,
236                     "explorer.context.access",
237                     "commons/chacc.jsp",
238                     "a a iiii aaai dddd",
239                     "300");
240                 setMenuEntry(
241                     document,
242                     xpath,
243                     "explorer.context.secure",
244                     "commons/secure.jsp",
245                     "d d iiii aaai dddd",
246                     "302");
247                 setMenuEntry(
248                     document,
249                     xpath,
250                     "explorer.context.type",
251                     "commons/chtype.jsp",
252                     "d d iiii aaai dddd",
253                     "305");
254                 setMenuEntry(
255                     document,
256                     xpath,
257                     "explorer.context.chnav",
258                     "commons/chnav.jsp",
259                     "d d iiii aaai dddd",
260                     "310");
261                 CmsSetupXmlHelper.setValue(document, xpath
262                     + "/"
263                     + CmsWorkplaceConfiguration.N_SEPARATOR
264                     + "[@"
265                     + I_CmsXmlConfiguration.A_ORDER
266                     + "='340']"
267                     + "/@"
268                     + I_CmsXmlConfiguration.A_ORDER, "340");
269                 setMenuEntry(document, xpath, "explorer.context.property", "commons/property.jsp", "", "360");
270                 return true;
271             }
272         }
273         return false;
274     }
275
276     /**
277      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getCommonPath()
278      */

279     protected String JavaDoc getCommonPath() {
280
281         // /opencms/workplace/explorertypes
282
return new StringBuffer JavaDoc("/").append(CmsConfigurationManager.N_ROOT).append("/").append(
283             CmsWorkplaceConfiguration.N_WORKPLACE).append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPES).toString();
284     }
285
286     /**
287      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getXPathsToUpdate()
288      */

289     protected List JavaDoc getXPathsToUpdate() {
290
291         if (m_xpaths == null) {
292             // /opencms/workplace/explorertypes/explorertype[@name='imagegallery']/editoptions/contextmenu/entry[@uri='commons/${res}images.jsp']
293
StringBuffer JavaDoc xp = new StringBuffer JavaDoc(256);
294             xp.append("/").append(CmsConfigurationManager.N_ROOT);
295             xp.append("/").append(CmsWorkplaceConfiguration.N_WORKPLACE);
296             xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPES);
297             xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPE);
298             xp.append("[@").append(I_CmsXmlConfiguration.N_NAME);
299             xp.append("='").append("imagegallery");
300             xp.append("']/").append(CmsWorkplaceConfiguration.N_EDITOPTIONS);
301             xp.append("/").append(CmsWorkplaceConfiguration.N_CONTEXTMENU);
302             xp.append("/").append(CmsWorkplaceConfiguration.N_ENTRY);
303             xp.append("[@").append(I_CmsXmlConfiguration.A_URI);
304             xp.append("='commons/${res}images.jsp']");
305             m_xpaths = new ArrayList JavaDoc();
306             // ${res}: rename, comment
307
m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${res}", "rename"));
308             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${res}", "comment"));
309             // /opencms/workplace/explorertypes/explorertype[@name='${etype}' and @reference='imagegallery']
310
xp = new StringBuffer JavaDoc(256);
311             xp.append("/").append(CmsConfigurationManager.N_ROOT);
312             xp.append("/").append(CmsWorkplaceConfiguration.N_WORKPLACE);
313             xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPES);
314             xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPE);
315             xp.append("[@").append(I_CmsXmlConfiguration.N_NAME);
316             xp.append("='").append("${etype}");
317             xp.append("' and @").append(CmsWorkplaceConfiguration.A_REFERENCE);
318             xp.append("='").append("imagegallery");
319             xp.append("']");
320             // ???: linkgallery, htmlgallery, tablegallery
321
m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "linkgallery"));
322             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "htmlgallery"));
323             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "tablegallery"));
324
325             xp = new StringBuffer JavaDoc(256);
326             xp.append("/").append(CmsConfigurationManager.N_ROOT);
327             xp.append("/").append(CmsWorkplaceConfiguration.N_WORKPLACE);
328             xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPES);
329             xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPE);
330             xp.append("[@").append(I_CmsXmlConfiguration.N_NAME);
331             xp.append("='").append("downloadgallery");
332             xp.append("']/");
333             // /opencms/workplace/explorertypes/explorertype[@name='downloadgallery']/editoptions
334
m_xpaths.add(xp.toString() + CmsWorkplaceConfiguration.N_EDITOPTIONS);
335             // /opencms/workplace/explorertypes/explorertype[@name='downloadgallery']/@reference
336
xp = new StringBuffer JavaDoc(256);
337             xp.append("/");
338             xp.append(CmsConfigurationManager.N_ROOT);
339             xp.append("/");
340             xp.append(CmsWorkplaceConfiguration.N_WORKPLACE);
341             xp.append("/");
342             xp.append(CmsWorkplaceConfiguration.N_EXPLORERTYPES);
343             xp.append("/");
344             xp.append(CmsWorkplaceConfiguration.N_EXPLORERTYPE);
345             xp.append("[@");
346             xp.append(I_CmsXmlConfiguration.N_NAME);
347             xp.append("='");
348             xp.append("downloadgallery");
349             xp.append("']/@");
350             xp.append(CmsWorkplaceConfiguration.A_REFERENCE);
351             m_xpaths.add(xp.toString());
352         }
353         return m_xpaths;
354     }
355 }
Popular Tags