1 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 38 import java.util.Collections ; 39 import java.util.List ; 40 41 import org.dom4j.Document; 42 import org.dom4j.Node; 43 44 53 public class CmsXmlAddMultiContextMenu extends A_CmsSetupXmlUpdate { 54 55 56 private List m_xpaths; 57 58 61 public String getName() { 62 63 return "Add new explorer multi selection feature"; 64 } 65 66 69 public String getXmlFilename() { 70 71 return CmsWorkplaceConfiguration.DEFAULT_XML_FILE_NAME; 72 } 73 74 77 protected boolean executeUpdate(Document document, String xpath) { 78 79 Node node = document.selectSingleNode(xpath); 80 if (node == null) { 81 if (xpath.equals(getXPathsToUpdate().get(0))) { 82 setEntry(document, xpath, "explorer.context.lock", "commons/lock.jsp", "", "10"); 83 setEntry(document, xpath, "explorer.context.unlock", "commons/unlock.jsp", "", "20"); 84 CmsSetupXmlHelper.setValue(document, xpath 85 + "/" 86 + CmsWorkplaceConfiguration.N_SEPARATOR 87 + "[@" 88 + I_CmsXmlConfiguration.A_ORDER 89 + "='30']" 90 + "/@" 91 + I_CmsXmlConfiguration.A_ORDER, "30"); 92 setEntry(document, xpath, "explorer.context.publish", "commons/publishresource.jsp", "", "40"); 93 CmsSetupXmlHelper.setValue(document, xpath 94 + "/" 95 + CmsWorkplaceConfiguration.N_SEPARATOR 96 + "[@" 97 + I_CmsXmlConfiguration.A_ORDER 98 + "='50']" 99 + "/@" 100 + I_CmsXmlConfiguration.A_ORDER, "50"); 101 setEntry(document, xpath, "explorer.context.copy", "commons/copy.jsp", "", "60"); 102 setEntry(document, xpath, "explorer.context.move.multi", "commons/move.jsp", "", "70"); 103 setEntry(document, xpath, "explorer.context.delete", "commons/delete.jsp", "", "80"); 104 setEntry(document, xpath, "explorer.context.touch", "commons/touch.jsp", "", "90"); 105 setEntry(document, xpath, "explorer.context.availability", "commons/availability.jsp", "", "100"); 106 setEntry(document, xpath, "explorer.context.undochanges", "commons/undochanges.jsp", "", "110"); 107 setEntry(document, xpath, "explorer.context.undelete", "commons/undelete.jsp", "", "120"); 108 } 109 return true; 110 } 111 return false; 112 } 113 114 117 protected String getCommonPath() { 118 119 StringBuffer xp = new StringBuffer (256); 121 xp.append("/").append(CmsConfigurationManager.N_ROOT); 122 xp.append("/").append(CmsWorkplaceConfiguration.N_WORKPLACE); 123 xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPES); 124 return xp.toString(); 125 } 126 127 130 protected List getXPathsToUpdate() { 131 132 if (m_xpaths == null) { 133 StringBuffer xp = new StringBuffer (256); 135 xp.append("/").append(CmsConfigurationManager.N_ROOT); 136 xp.append("/").append(CmsWorkplaceConfiguration.N_WORKPLACE); 137 xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPES); 138 xp.append("/").append(CmsWorkplaceConfiguration.N_MULTICONTEXTMENU); 139 m_xpaths = Collections.singletonList(xp.toString()); 140 } 141 return m_xpaths; 142 } 143 144 154 private void setEntry(Document document, String xpath, String key, String uri, String rules, String order) { 155 156 String xp = xpath 157 + "/" 158 + CmsWorkplaceConfiguration.N_ENTRY 159 + "[@" 160 + I_CmsXmlConfiguration.A_URI 161 + "='" 162 + uri 163 + "']"; 164 CmsSetupXmlHelper.setValue(document, xp + "/@" + I_CmsXmlConfiguration.A_URI, uri); 165 CmsSetupXmlHelper.setValue(document, xp + "/@" + I_CmsXmlConfiguration.A_KEY, key); 166 CmsSetupXmlHelper.setValue(document, xp + "/@" + CmsWorkplaceConfiguration.A_RULES, rules); 167 CmsSetupXmlHelper.setValue(document, xp + "/@" + I_CmsXmlConfiguration.A_ORDER, order); 168 } 169 170 } | Popular Tags |