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.Tree; 21 import info.magnolia.cms.gui.control.TreeColumn; 22 import info.magnolia.cms.i18n.Messages; 23 import info.magnolia.cms.i18n.MessagesManager; 24 import info.magnolia.module.admininterface.AdminTreeMVCHandler; 25 26 import javax.servlet.http.HttpServletRequest ; 27 import javax.servlet.http.HttpServletResponse ; 28 29 import org.apache.commons.lang.StringUtils; 30 31 32 37 public class AdminTreeRoles extends AdminTreeMVCHandler { 38 39 44 public AdminTreeRoles(String name, HttpServletRequest request, HttpServletResponse response) { 45 super(name, request, response); 46 } 47 48 protected void prepareTree(Tree tree, HttpServletRequest request) { 49 50 Messages msgs = MessagesManager.getMessages(request); 51 52 tree.setDrawShifter(false); 53 54 tree.setIconPage(Tree.ICONDOCROOT + "hat_white.gif"); if (Server.isAdmin()) { 56 tree.setIconOndblclick("mgnlTreeMenuOpenDialog(" + tree.getJavascriptTree() + ",'.magnolia/dialogs/roleedit.html');"); } 59 tree.addItemType(ItemType.CONTENT); 60 61 TreeColumn column0 = new TreeColumn(tree.getJavascriptTree(), request); 62 column0.setIsLabel(true); 63 if (Server.isAdmin()) { 64 column0.setHtmlEdit(); 65 } 66 column0.setWidth(2); 67 column0.setTitle(msgs.get("tree.roles.name")); TreeColumn column1 = new TreeColumn(tree.getJavascriptTree(), request); 69 column1.setName("title"); if (Server.isAdmin()) { 71 column1.setHtmlEdit(); 72 } 73 column1.setWidth(2); 74 column1.setTitle(msgs.get("tree.roles.fullname")); TreeColumn columnIcons = new TreeColumn(tree.getJavascriptTree(), request); 76 columnIcons.setCssClass(StringUtils.EMPTY); 77 columnIcons.setWidth(1); 78 columnIcons.setIsIcons(true); 79 columnIcons.setIconsActivation(true); 80 TreeColumn column2 = new TreeColumn(tree.getJavascriptTree(), request); 81 column2.setName(MetaData.CREATION_DATE); 82 column2.setIsMeta(true); 84 column2.setDateFormat("yyyy-MM-dd, HH:mm"); column2.setTitle(msgs.get("tree.roles.date")); column2.setWidth(2); 87 88 tree.addColumn(column0); 89 if (!this.isBrowseMode()) { 90 tree.addColumn(column1); 91 if (Server.isAdmin() || Subscriber.isSubscribersEnabled()) { 92 tree.addColumn(columnIcons); 93 } 94 tree.addColumn(column2); 95 } 96 97 } 98 99 104 protected void prepareContextMenu(Tree tree, HttpServletRequest request) { 105 Messages msgs = MessagesManager.getMessages(request); 106 107 ContextMenuItem menuOpen = new ContextMenuItem(); 108 menuOpen.setLabel(msgs.get("tree.roles.menu.edit")); menuOpen.setIcon(request.getContextPath() + "/admindocroot/icons/16/hat_white.gif"); menuOpen.setOnclick("mgnlTreeMenuOpenDialog(" + tree.getJavascriptTree() + ",'.magnolia/dialogs/roleedit.html');"); menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); ContextMenuItem menuNewPage = new ContextMenuItem(); 115 menuNewPage.setLabel(msgs.get("tree.roles.menu.new")); menuNewPage.setIcon(request.getContextPath() + "/admindocroot/icons/16/hat_white_add.gif"); menuNewPage.setOnclick(tree.getJavascriptTree() + ".createRootNode('" + ItemType.CONTENT.getSystemName() + "');"); ContextMenuItem menuDelete = new ContextMenuItem(); 120 menuDelete.setLabel(msgs.get("tree.roles.menu.delete")); menuDelete.setIcon(request.getContextPath() + "/admindocroot/icons/16/delete2.gif"); menuDelete.setOnclick(tree.getJavascriptTree() + ".deleteNode();"); menuDelete.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); ContextMenuItem menuMove = new ContextMenuItem(); 126 menuMove.setLabel(msgs.get("tree.roles.menu.move")); menuMove.setIcon(request.getContextPath() + "/admindocroot/icons/16/up_down.gif"); menuMove.setOnclick(tree.getJavascriptTree() + ".cutNode();"); menuMove.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); ContextMenuItem menuCopy = new ContextMenuItem(); 132 menuCopy.setLabel(msgs.get("tree.roles.menu.copy")); menuCopy.setIcon(request.getContextPath() + "/admindocroot/icons/16/copy.gif"); menuCopy.setOnclick(tree.getJavascriptTree() + ".copyNode();"); menuCopy.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); ContextMenuItem menuRefresh = new ContextMenuItem(); 138 menuRefresh.setLabel(msgs.get("tree.menu.refresh")); menuRefresh.setIcon(request.getContextPath() + "/admindocroot/icons/16/refresh.gif"); menuRefresh.setOnclick(tree.getJavascriptTree() + ".refresh();"); 142 ContextMenuItem menuActivateExcl = new ContextMenuItem(); 143 menuActivateExcl.setLabel(msgs.get("tree.roles.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() + ")"); ContextMenuItem menuDeActivate = new ContextMenuItem(); 149 menuDeActivate.setLabel(msgs.get("tree.roles.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() + ")"); 155 if (!Server.isAdmin()) { 156 menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); menuNewPage.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); } 159 160 if (!Subscriber.isSubscribersEnabled()) { 161 menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); menuDeActivate.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); } 164 165 if (!this.isBrowseMode()) { 166 tree.addMenuItem(menuOpen); 167 tree.addMenuItem(menuNewPage); 168 169 tree.addMenuItem(null); tree.addMenuItem(menuDelete); 171 172 tree.addMenuItem(null); tree.addMenuItem(menuActivateExcl); 174 tree.addMenuItem(menuDeActivate); 175 176 tree.addMenuItem(null); } 178 tree.addMenuItem(menuRefresh); 179 } 180 } | Popular Tags |