1 13 package info.magnolia.module.admininterface.trees; 14 15 import info.magnolia.cms.beans.config.Server; 16 import info.magnolia.cms.beans.config.Subscriber; 17 import info.magnolia.cms.core.ItemType; 18 import info.magnolia.cms.core.MetaData; 19 import info.magnolia.cms.gui.control.ContextMenuItem; 20 import info.magnolia.cms.gui.control.Select; 21 import info.magnolia.cms.gui.control.Tree; 22 import info.magnolia.cms.gui.control.TreeColumn; 23 import info.magnolia.cms.gui.misc.Icon; 24 import info.magnolia.cms.i18n.Messages; 25 import info.magnolia.cms.i18n.MessagesManager; 26 import info.magnolia.module.admininterface.AdminTreeMVCHandler; 27 28 import javax.jcr.PropertyType; 29 import javax.servlet.http.HttpServletRequest ; 30 import javax.servlet.http.HttpServletResponse ; 31 32 import org.apache.commons.lang.StringUtils; 33 34 35 40 public class AdminTreeConfig extends AdminTreeMVCHandler { 41 42 47 public AdminTreeConfig(String name, HttpServletRequest request, HttpServletResponse response) { 48 super(name, request, response); 49 } 50 51 protected void prepareTree(Tree tree, HttpServletRequest request) { 52 Messages msgs = MessagesManager.getMessages(request); 53 54 tree.setIconPage(Tree.ICONDOCROOT + "folder_cubes.gif"); 56 tree.addItemType(ItemType.CONTENT.getSystemName()); 57 tree.addItemType(ItemType.CONTENTNODE.getSystemName()); 58 tree.addItemType(ItemType.NT_NODEDATA); 59 TreeColumn column0 = new TreeColumn(tree.getJavascriptTree(), request); 60 column0.setWidth(1); 61 column0.setHtmlEdit(); 62 column0.setIsLabel(true); 63 column0.setWidth(3); 64 TreeColumn column1 = new TreeColumn(tree.getJavascriptTree(), request); 65 column1.setName(StringUtils.EMPTY); 66 column1.setTitle(msgs.get("tree.config.value")); column1.setIsNodeDataValue(true); 68 column1.setWidth(2); 69 column1.setHtmlEdit(); 70 TreeColumn column2 = new TreeColumn(tree.getJavascriptTree(), request); 71 column2.setName(StringUtils.EMPTY); 72 column2.setTitle(msgs.get("tree.config.type")); column2.setIsNodeDataType(true); 74 column2.setWidth(2); 75 Select typeSelect = new Select(); 76 typeSelect.setName(tree.getJavascriptTree() + TreeColumn.EDIT_NAMEADDITION); 77 typeSelect.setSaveInfo(false); 78 typeSelect.setCssClass(TreeColumn.EDIT_CSSCLASS_SELECT); 79 typeSelect.setEvent("onblur", tree.getJavascriptTree() + TreeColumn.EDIT_JSSAVE); typeSelect.setOptions(PropertyType.TYPENAME_STRING, Integer.toString(PropertyType.STRING)); 81 typeSelect.setOptions(PropertyType.TYPENAME_BOOLEAN, Integer.toString(PropertyType.BOOLEAN)); 82 typeSelect.setOptions(PropertyType.TYPENAME_LONG, Integer.toString(PropertyType.LONG)); 83 typeSelect.setOptions(PropertyType.TYPENAME_DOUBLE, Integer.toString(PropertyType.DOUBLE)); 84 column2.setHtmlEdit(typeSelect.getHtml()); 86 TreeColumn columnIcons = new TreeColumn(tree.getJavascriptTree(), request); 87 columnIcons.setCssClass(StringUtils.EMPTY); 88 columnIcons.setWidth(1); 89 columnIcons.setIsIcons(true); 90 columnIcons.setIconsActivation(true); 91 columnIcons.setIconsPermission(true); 92 TreeColumn column4 = new TreeColumn(tree.getJavascriptTree(), request); 93 column4.setName(MetaData.LAST_MODIFIED); 94 column4.setIsMeta(true); 95 column4.setDateFormat("yy-MM-dd, HH:mm"); column4.setWidth(2); 97 column4.setTitle(msgs.get("tree.config.date")); 99 tree.addColumn(column0); 100 101 if (!this.isBrowseMode()) { 102 tree.addColumn(column1); 103 tree.addColumn(column2); 104 if (Server.isAdmin() || Subscriber.isSubscribersEnabled()) { 105 tree.addColumn(columnIcons); 106 } 107 tree.addColumn(column4); 108 } 109 } 110 111 116 protected void prepareContextMenu(Tree tree, HttpServletRequest request) { 117 Messages msgs = MessagesManager.getMessages(request); 118 119 ContextMenuItem menuNewPage = new ContextMenuItem(); 120 menuNewPage.setLabel("<img SRC=\"" + request.getContextPath() 122 + new Icon().getSrc(Icon.PAGE, Icon.SIZE_SMALL) 123 + "\"> <span style=\"position:relative;top:-3px;\">" + msgs.get("tree.config.menu.newFolder") + "</span>"); menuNewPage.setOnclick(tree.getJavascriptTree() + ".createNode('" + ItemType.CONTENT.getSystemName() + "');"); menuNewPage.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotNodeData(" + tree.getJavascriptTree() + ")"); menuNewPage.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotContentNode(" + tree.getJavascriptTree() + ")"); 132 ContextMenuItem menuNewContentNode = new ContextMenuItem(); 133 menuNewContentNode.setLabel("<img SRC=\"" + request.getContextPath() 135 + new Icon().getSrc(Icon.CONTENTNODE, Icon.SIZE_SMALL) 136 + "\"> <span style=\"position:relative;top:-3px\">" + msgs.get("tree.config.menu.newNode") + "</span>"); menuNewContentNode.setOnclick(tree.getJavascriptTree() + ".createNode('" + ItemType.CONTENTNODE.getSystemName() + "');"); menuNewContentNode.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotNodeData(" + tree.getJavascriptTree() + ")"); 144 ContextMenuItem menuNewNodeData = new ContextMenuItem(); 145 menuNewNodeData.setLabel("<img SRC=\"" + request.getContextPath() 147 + new Icon().getSrc(Icon.NODEDATA, Icon.SIZE_SMALL) 148 + "\"> <span style=\"position:relative;top:-3px;\">" + msgs.get("tree.config.menu.newNodeData") + "</span>"); menuNewNodeData.setOnclick(tree.getJavascriptTree() + ".createNode('" + ItemType.NT_NODEDATA + "');"); menuNewNodeData.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotNodeData(" + tree.getJavascriptTree() + ")"); 155 ContextMenuItem menuDelete = new ContextMenuItem(); 156 menuDelete.setLabel(msgs.get("tree.config.menu.delete")); menuDelete.setIcon(request.getContextPath() + "/admindocroot/icons/16/delete2.gif"); menuDelete.setOnclick(tree.getJavascriptTree() + ".deleteNode();"); menuDelete.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); 162 ContextMenuItem menuCopy = new ContextMenuItem(); 163 menuCopy.setLabel(msgs.get("tree.config.menu.copy")); menuCopy.setIcon(request.getContextPath() + "/admindocroot/icons/16/copy.gif"); menuCopy.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); menuCopy.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotNodeData(" + tree.getJavascriptTree() + ")"); menuCopy.setOnclick(tree.getJavascriptTree() + ".copyNode();"); 171 ContextMenuItem menuCut = new ContextMenuItem(); 172 menuCut.setLabel(msgs.get("tree.config.menu.move")); menuCut.setIcon(request.getContextPath() + "/admindocroot/icons/16/up_down.gif"); menuCut 175 .addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); menuCut.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotNodeData(" + tree.getJavascriptTree() + ")"); menuCut.setOnclick(tree.getJavascriptTree() + ".cutNode();"); 180 ContextMenuItem menuActivateExcl = new ContextMenuItem(); 181 menuActivateExcl.setLabel(msgs.get("tree.config.menu.activate")); menuActivateExcl.setIcon(request.getContextPath() + "/admindocroot/icons/16/arrow_right_green.gif"); menuActivateExcl.setOnclick(tree.getJavascriptTree() + ".activateNode(" + Tree.ACTION_ACTIVATE + ",false);"); menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotNodeData(" + tree.getJavascriptTree() + ")"); 189 ContextMenuItem menuActivateIncl = new ContextMenuItem(); 190 menuActivateIncl.setLabel(msgs.get("tree.config.menu.activateInclSubs")); menuActivateIncl.setIcon(request.getContextPath() + "/admindocroot/icons/16/arrow_right_green.gif"); menuActivateIncl.setOnclick(tree.getJavascriptTree() + ".activateNode(" + Tree.ACTION_ACTIVATE + ",true);"); menuActivateIncl.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); menuActivateIncl.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotNodeData(" + tree.getJavascriptTree() + ")"); 198 ContextMenuItem menuDeActivate = new ContextMenuItem(); 199 menuDeActivate.setLabel(msgs.get("tree.config.menu.deactivate")); menuDeActivate.setIcon(request.getContextPath() + "/admindocroot/icons/16/arrow_left_red.gif"); menuDeActivate.setOnclick(tree.getJavascriptTree() + ".deActivateNode(" + Tree.ACTION_DEACTIVATE + ");"); menuDeActivate.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); menuDeActivate.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotNodeData(" + tree.getJavascriptTree() + ")"); 207 ContextMenuItem menuRefresh = new ContextMenuItem(); 208 menuRefresh.setLabel(msgs.get("tree.menu.refresh")); menuRefresh.setIcon(request.getContextPath() + "/admindocroot/icons/16/refresh.gif"); menuRefresh.setOnclick(tree.getJavascriptTree() + ".refresh();"); 212 ContextMenuItem menuExport = new ContextMenuItem(); 213 menuExport.setLabel(msgs.get("tree.menu.export")); menuExport.setIcon(request.getContextPath() + "/admindocroot/icons/16/export.gif"); menuExport.setOnclick(tree.getJavascriptTree() + ".exportNode();"); menuExport.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); menuExport.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotNodeData(" + tree.getJavascriptTree() + ")"); 221 ContextMenuItem menuImport = new ContextMenuItem(); 222 menuImport.setLabel(msgs.get("tree.menu.import")); menuImport.setIcon(request.getContextPath() + "/admindocroot/icons/16/import1.gif"); menuImport.setOnclick(tree.getJavascriptTree() + ".importNode(this);"); menuImport.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); menuImport.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotNodeData(" + tree.getJavascriptTree() + ")"); 230 if (!Subscriber.isSubscribersEnabled()) { 232 menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); menuActivateIncl.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); menuDeActivate.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); } 236 237 menuImport.addJavascriptCondition("new mgnlTreeMenuItemConditionPermissionWrite(" + tree.getJavascriptTree() + ")"); 240 menuExport.addJavascriptCondition("new mgnlTreeMenuItemConditionPermissionWrite(" + tree.getJavascriptTree() + ")"); 243 if (!this.isBrowseMode()) { 244 tree.addMenuItem(menuNewPage); 245 tree.addMenuItem(menuNewContentNode); 246 tree.addMenuItem(menuNewNodeData); 247 248 tree.addSeparator(); 249 tree.addMenuItem(menuDelete); 250 251 tree.addSeparator(); 252 tree.addMenuItem(menuCut); 253 tree.addMenuItem(menuCopy); 254 255 tree.addSeparator(); 256 tree.addMenuItem(menuActivateExcl); 257 tree.addMenuItem(menuActivateIncl); 258 tree.addMenuItem(menuDeActivate); 259 260 tree.addSeparator(); 261 tree.addMenuItem(menuExport); 262 tree.addMenuItem(menuImport); 263 264 tree.addSeparator(); 265 } 266 tree.addMenuItem(menuRefresh); 267 } 268 269 } | Popular Tags |