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 AdminTreeUsers extends AdminTreeMVCHandler { 38 39 44 public AdminTreeUsers(String name, HttpServletRequest request, HttpServletResponse response) { 45 super(name, request, response); 46 } 47 48 53 protected void prepareTree(Tree tree, HttpServletRequest request) { 54 Messages msgs = MessagesManager.getMessages(request); 55 56 tree.setDrawShifter(false); 57 tree.setIconPage(Tree.ICONDOCROOT + "pawn_glass_yellow.gif"); if (Server.isAdmin()) { 60 tree.setIconOndblclick("mgnlTreeMenuOpenDialog(" + tree.getJavascriptTree() + ",'.magnolia/dialogs/useredit.html');"); } 64 tree.addItemType(ItemType.CONTENT); 65 66 TreeColumn column0 = new TreeColumn(tree.getJavascriptTree(), request); 67 column0.setIsLabel(true); 68 if (Server.isAdmin()) { 69 column0.setHtmlEdit(); 70 } 71 column0.setTitle(msgs.get("tree.users.name")); column0.setWidth(2); 73 TreeColumn column1 = new TreeColumn(tree.getJavascriptTree(), request); 74 column1.setName("title"); if (Server.isAdmin()) { 76 column1.setHtmlEdit(); 77 } 78 column1.setTitle(msgs.get("tree.users.fullname")); column1.setWidth(2); 80 TreeColumn columnIcons = new TreeColumn(tree.getJavascriptTree(), request); 81 columnIcons.setCssClass(StringUtils.EMPTY); 82 columnIcons.setWidth(1); 83 columnIcons.setIsIcons(true); 84 columnIcons.setIconsActivation(true); 85 TreeColumn column2 = new TreeColumn(tree.getJavascriptTree(), request); 86 column2.setName(MetaData.LAST_MODIFIED); 87 column2.setIsMeta(true); 88 column2.setDateFormat("yyyy-MM-dd, HH:mm"); column2.setTitle(msgs.get("tree.users.date")); column2.setWidth(2); 91 92 tree.addColumn(column0); 93 94 if(!this.isBrowseMode()){ 95 tree.addColumn(column1); 96 if (Server.isAdmin() || Subscriber.isSubscribersEnabled()) { 97 tree.addColumn(columnIcons); 98 } 99 tree.addColumn(column2); 100 } 101 } 102 103 108 protected void prepareContextMenu(Tree tree, HttpServletRequest request) { 109 Messages msgs = MessagesManager.getMessages(request); 110 ContextMenuItem menuOpen = new ContextMenuItem(); 111 menuOpen.setLabel(msgs.get("tree.users.menu.edit")); menuOpen.setIcon(request.getContextPath() + "/admindocroot/icons/16/pawn_glass_yellow.gif"); menuOpen.setOnclick("mgnlTreeMenuOpenDialog(" + tree.getJavascriptTree() + ",'.magnolia/dialogs/useredit.html');"); menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); ContextMenuItem menuNewPage = new ContextMenuItem(); 118 menuNewPage.setLabel(msgs.get("tree.users.menu.new")); menuNewPage.setIcon(request.getContextPath() + "/admindocroot/icons/16/pawn_glass_yellow_add.gif"); menuNewPage.setOnclick(tree.getJavascriptTree() + ".createRootNode('" + ItemType.CONTENT.getSystemName() + "');"); ContextMenuItem menuDelete = new ContextMenuItem(); 123 menuDelete.setLabel(msgs.get("tree.users.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(); 129 menuMove.setLabel(msgs.get("tree.users.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(); 135 menuCopy.setLabel(msgs.get("tree.users.menu.copy")); menuCopy.setIcon(request.getContextPath() + "/admindocroot/icons/16/copy.gif"); menuCopy.setOnclick(tree.getJavascriptTree() + ".copyNode();"); menuCopy.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() + ")"); ContextMenuItem menuActivateExcl = new ContextMenuItem(); 141 menuActivateExcl.setLabel(msgs.get("tree.users.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(); 147 menuDeActivate.setLabel(msgs.get("tree.users.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() + ")"); ContextMenuItem menuRefresh = new ContextMenuItem(); 153 menuRefresh.setLabel(msgs.get("tree.menu.refresh")); menuRefresh.setIcon(request.getContextPath() + "/admindocroot/icons/16/refresh.gif"); menuRefresh.setOnclick(tree.getJavascriptTree() + ".refresh();"); 157 if (!Server.isAdmin()) { 158 menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); menuNewPage.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); } 161 162 if (!Subscriber.isSubscribersEnabled()) { 163 menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); menuDeActivate.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); } 166 167 if (!this.isBrowseMode()) { 168 tree.addMenuItem(menuOpen); 169 tree.addMenuItem(menuNewPage); 170 171 tree.addMenuItem(null); tree.addMenuItem(menuDelete); 173 174 tree.addMenuItem(null); tree.addMenuItem(menuActivateExcl); 176 tree.addMenuItem(menuDeActivate); 177 178 tree.addMenuItem(null); } 180 tree.addMenuItem(menuRefresh); 181 } 182 } | Popular Tags |