KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/setup/xml/CmsXmlUpdateHistoryContextMenu.java,v $
3  * Date : $Date: 2006/04/28 15:20:52 $
4  * Version: $Revision: 1.5 $
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.types.CmsResourceTypeBinary;
38 import org.opencms.file.types.CmsResourceTypeImage;
39 import org.opencms.file.types.CmsResourceTypeJsp;
40 import org.opencms.file.types.CmsResourceTypePlain;
41 import org.opencms.file.types.CmsResourceTypePointer;
42 import org.opencms.file.types.CmsResourceTypeXmlPage;
43 import org.opencms.util.CmsStringUtil;
44
45 import java.util.ArrayList JavaDoc;
46 import java.util.List JavaDoc;
47
48 import org.dom4j.Document;
49 import org.dom4j.Node;
50
51 /**
52  * Modifies the history context menu.<p>
53  *
54  * @author Michael Moossen
55  *
56  * @version $Revision: 1.5 $
57  *
58  * @since 6.1.8
59  */

60 public class CmsXmlUpdateHistoryContextMenu extends A_CmsSetupXmlUpdate {
61
62     /** List of xpaths to update. */
63     private List JavaDoc m_xpaths;
64
65     /**
66      * @see org.opencms.setup.xml.I_CmsSetupXmlUpdate#getName()
67      */

68     public String JavaDoc getName() {
69
70         return "Modify the History context menu";
71     }
72
73     /**
74      * @see org.opencms.setup.xml.I_CmsSetupXmlUpdate#getXmlFilename()
75      */

76     public String JavaDoc getXmlFilename() {
77
78         return CmsWorkplaceConfiguration.DEFAULT_XML_FILE_NAME;
79     }
80
81     /**
82      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#executeUpdate(org.dom4j.Document, java.lang.String)
83      */

84     protected boolean executeUpdate(Document document, String JavaDoc xpath) {
85
86         Node node = document.selectSingleNode(xpath);
87         if (xpath.indexOf(CmsWorkplaceConfiguration.N_TOOLMANAGER) < 0) {
88             if (node != null) {
89                 CmsSetupXmlHelper.setValue(
90                     document,
91                     xpath + "/@" + I_CmsXmlConfiguration.A_URI,
92                     "views/admin/admin-main.jsp?root=explorer&amp;path=%2Fhistory");
93
94                 return true;
95             }
96         } else {
97             if (node == null) {
98                 String JavaDoc xp = xpath
99                     + "/"
100                     + CmsWorkplaceConfiguration.N_ROOTS
101                     + "/"
102                     + CmsWorkplaceConfiguration.N_ROOT
103                     + "["
104                     + CmsWorkplaceConfiguration.N_KEY
105                     + "='admin']";
106
107                 CmsSetupXmlHelper.setValue(document, xp + "/" + CmsWorkplaceConfiguration.N_KEY, "admin");
108                 CmsSetupXmlHelper.setValue(
109                     document,
110                     xp + "/" + CmsWorkplaceConfiguration.N_URI,
111                     "/system/workplace/admin/");
112                 CmsSetupXmlHelper.setValue(
113                     document,
114                     xp + "/" + I_CmsXmlConfiguration.N_NAME,
115                     "${key.GUI_ADMIN_VIEW_ROOT_NAME_0}");
116                 CmsSetupXmlHelper.setValue(
117                     document,
118                     xp + "/" + CmsWorkplaceConfiguration.N_HELPTEXT,
119                     "${key.GUI_ADMIN_VIEW_ROOT_HELP_0}");
120
121                 xp = CmsStringUtil.substitute(xp, "admin", "explorer");
122                 CmsSetupXmlHelper.setValue(document, xp + "/" + CmsWorkplaceConfiguration.N_KEY, "explorer");
123                 CmsSetupXmlHelper.setValue(
124                     document,
125                     xp + "/" + CmsWorkplaceConfiguration.N_URI,
126                     "/system/workplace/explorer/");
127                 CmsSetupXmlHelper.setValue(
128                     document,
129                     xp + "/" + I_CmsXmlConfiguration.N_NAME,
130                     "${key.GUI_EXPLORER_VIEW_ROOT_NAME_0}");
131                 CmsSetupXmlHelper.setValue(
132                     document,
133                     xp + "/" + CmsWorkplaceConfiguration.N_HELPTEXT,
134                     "${key.GUI_EXPLORER_VIEW_ROOT_HELP_0}");
135
136                 return true;
137             }
138         }
139         return false;
140     }
141
142     /**
143      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getCommonPath()
144      */

145     protected String JavaDoc getCommonPath() {
146
147         // /opencms/workplace
148
return new StringBuffer JavaDoc("/").append(CmsConfigurationManager.N_ROOT).append("/").append(
149             CmsWorkplaceConfiguration.N_WORKPLACE).toString();
150     }
151
152     /**
153      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getXPathsToUpdate()
154      */

155     protected List JavaDoc getXPathsToUpdate() {
156
157         if (m_xpaths == null) {
158             // /opencms/workplace/explorertypes/explorertype[@name='${etype}']/editoptions/contextmenu/entry[@uri='commons/history.jsp']
159
StringBuffer JavaDoc xp = new StringBuffer JavaDoc(256);
160             xp.append("/").append(CmsConfigurationManager.N_ROOT);
161             xp.append("/").append(CmsWorkplaceConfiguration.N_WORKPLACE);
162             xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPES);
163             xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPE);
164             xp.append("[@").append(I_CmsXmlConfiguration.N_NAME);
165             xp.append("='${etype}']/");
166             xp.append(CmsWorkplaceConfiguration.N_EDITOPTIONS);
167             xp.append("/").append(CmsWorkplaceConfiguration.N_CONTEXTMENU);
168             xp.append("/").append(CmsWorkplaceConfiguration.N_ENTRY);
169             xp.append("[@").append(I_CmsXmlConfiguration.A_URI);
170             xp.append("='commons/history.jsp']");
171             m_xpaths = new ArrayList JavaDoc();
172             // ???: xmlcontent, xmlpage, plain, image, jsp, binary, pointer, XMLTemplate
173
m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "xmlcontent"));
174             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeXmlPage.getStaticTypeName()));
175             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypePlain.getStaticTypeName()));
176             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeImage.getStaticTypeName()));
177             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeJsp.getStaticTypeName()));
178             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeBinary.getStaticTypeName()));
179             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypePointer.getStaticTypeName()));
180             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "XMLTemplate"));
181             // /opencms/workplace/tool-manager
182
xp = new StringBuffer JavaDoc(256);
183             xp.append("/").append(CmsConfigurationManager.N_ROOT);
184             xp.append("/").append(CmsWorkplaceConfiguration.N_WORKPLACE);
185             xp.append("/").append(CmsWorkplaceConfiguration.N_TOOLMANAGER);
186             m_xpaths.add(xp.toString());
187         }
188         return m_xpaths;
189     }
190
191 }
Popular Tags