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.ContextMenu; 20 import info.magnolia.cms.gui.control.ContextMenuItem; 21 import info.magnolia.cms.gui.control.FunctionBarItem; 22 import info.magnolia.cms.gui.control.Tree; 23 import info.magnolia.cms.gui.control.TreeColumn; 24 import info.magnolia.cms.i18n.Messages; 25 import info.magnolia.cms.i18n.MessagesManager; 26 import info.magnolia.module.admininterface.AdminTreeConfiguration; 27 28 import javax.servlet.http.HttpServletRequest ; 29 30 import org.apache.commons.lang.StringUtils; 31 32 33 37 public class UsersTreeConfiguration implements AdminTreeConfiguration { 38 39 43 public void prepareTree(Tree tree, boolean browseMode, HttpServletRequest request) { 44 Messages msgs = MessagesManager.getMessages(); 45 46 tree.setDrawShifter(false); 47 tree.setIcon(ItemType.USER.getSystemName(), Tree.ICONDOCROOT + "pawn_glass_yellow.gif"); tree.setIconOndblclick("mgnlTreeMenuOpenDialog(" + tree.getJavascriptTree() + ",'.magnolia/dialogs/useredit.html');"); tree.addItemType(ItemType.USER); 53 54 TreeColumn column0 = new TreeColumn(tree.getJavascriptTree(), request); 55 column0.setIsLabel(true); 56 column0.setHtmlEdit(); 57 column0.setTitle(msgs.get("tree.users.name")); column0.setWidth(2); 59 60 TreeColumn column1 = new TreeColumn(tree.getJavascriptTree(), request); 61 column1.setName("title"); column1.setHtmlEdit(); 63 column1.setTitle(msgs.get("tree.users.fullname")); column1.setWidth(2); 65 66 TreeColumn columnIcons = new TreeColumn(tree.getJavascriptTree(), request); 67 columnIcons.setCssClass(StringUtils.EMPTY); 68 columnIcons.setWidth(1); 69 columnIcons.setIsIcons(true); 70 columnIcons.setIconsActivation(true); 71 72 TreeColumn column2 = new TreeColumn(tree.getJavascriptTree(), request); 73 column2.setName(MetaData.LAST_MODIFIED); 74 column2.setIsMeta(true); 75 column2.setDateFormat("yyyy-MM-dd, HH:mm"); column2.setTitle(msgs.get("tree.users.date")); column2.setWidth(2); 78 79 tree.addColumn(column0); 80 81 if (!browseMode) { 82 tree.addColumn(column1); 83 if (Server.isAdmin() || Subscriber.isSubscribersEnabled()) { 84 tree.addColumn(columnIcons); 85 } 86 tree.addColumn(column2); 87 } 88 } 89 90 94 public void prepareContextMenu(Tree tree, boolean browseMode, HttpServletRequest request) { 95 Messages msgs = MessagesManager.getMessages(); 96 97 ContextMenuItem menuOpen = new ContextMenuItem("edit"); 98 menuOpen.setLabel(msgs.get("tree.users.menu.edit")); menuOpen.setIcon(request.getContextPath() + "/.resources/icons/16/pawn_glass_yellow.gif"); menuOpen.setOnclick("mgnlTreeMenuOpenDialog(" + tree.getJavascriptTree() 102 + ",'.magnolia/dialogs/useredit.html');"); menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() 105 + ")"); 107 ContextMenuItem menuNew = new ContextMenuItem("new"); 108 menuNew.setLabel(msgs.get("tree.users.menu.new")); menuNew.setIcon(request.getContextPath() + "/.resources/icons/16/pawn_glass_yellow_add.gif"); menuNew.setOnclick(tree.getJavascriptTree() + ".createRootNode('" + ItemType.USER.getSystemName() 112 + "');"); 114 ContextMenuItem menuDelete = new ContextMenuItem("delete"); 115 menuDelete.setLabel(msgs.get("tree.users.menu.delete")); menuDelete.setIcon(request.getContextPath() + "/.resources/icons/16/delete2.gif"); menuDelete.setOnclick(tree.getJavascriptTree() + ".deleteNode();"); menuDelete.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() 120 + ")"); 122 ContextMenuItem menuMove = new ContextMenuItem("move"); 123 menuMove.setLabel(msgs.get("tree.users.menu.move")); menuMove.setIcon(request.getContextPath() + "/.resources/icons/16/up_down.gif"); menuMove.setOnclick(tree.getJavascriptTree() + ".cutNode();"); menuMove.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() 128 + ")"); 130 ContextMenuItem menuCopy = new ContextMenuItem("copy"); 131 menuCopy.setLabel(msgs.get("tree.users.menu.copy")); menuCopy.setIcon(request.getContextPath() + "/.resources/icons/16/copy.gif"); menuCopy.setOnclick(tree.getJavascriptTree() + ".copyNode();"); menuCopy.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() 136 + ")"); 138 ContextMenuItem menuActivateExcl = new ContextMenuItem("activate"); 139 menuActivateExcl.setLabel(msgs.get("tree.users.menu.activate")); menuActivateExcl.setIcon(request.getContextPath() + "/.resources/icons/16/arrow_right_green.gif"); menuActivateExcl.setOnclick(tree.getJavascriptTree() + ".activateNode(" + Tree.ACTION_ACTIVATE + ",false);"); menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() 144 + ")"); 146 ContextMenuItem menuDeActivate = new ContextMenuItem("deactivate"); 147 menuDeActivate.setLabel(msgs.get("tree.users.menu.deactivate")); menuDeActivate.setIcon(request.getContextPath() + "/.resources/icons/16/arrow_left_red.gif"); menuDeActivate.setOnclick(tree.getJavascriptTree() + ".deActivateNode(" + Tree.ACTION_DEACTIVATE + ");"); menuDeActivate.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() 152 + ")"); 154 if (!Subscriber.isSubscribersEnabled()) { 155 menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); menuDeActivate.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); } 158 159 if (!browseMode) { 160 tree.addMenuItem(menuOpen); 161 tree.addMenuItem(menuNew); 162 tree.addMenuItem(null); tree.addMenuItem(menuDelete); 164 165 tree.addMenuItem(null); tree.addMenuItem(menuActivateExcl); 167 tree.addMenuItem(menuDeActivate); 168 } 169 else { 170 ContextMenuItem menuRefresh = new ContextMenuItem("refresh"); 171 menuRefresh.setLabel(msgs.get("tree.menu.refresh")); menuRefresh.setIcon(request.getContextPath() + "/.resources/icons/16/refresh.gif"); menuRefresh.setOnclick(tree.getJavascriptTree() + ".refresh();"); tree.addMenuItem(menuRefresh); 175 } 176 } 177 178 182 public void prepareFunctionBar(Tree tree, boolean browseMode, HttpServletRequest request) { 183 Messages msgs = MessagesManager.getMessages(); 184 ContextMenu cm = tree.getMenu(); 185 ContextMenuItem cmItem = cm.getMenuItemByName("edit"); 186 if (cmItem != null) { 187 tree.addFunctionBarItem(new FunctionBarItem(cmItem)); 188 } 189 cmItem = cm.getMenuItemByName("new"); 190 if (cmItem != null) { 191 tree.addFunctionBarItem(new FunctionBarItem(cmItem)); 192 } 193 tree.addFunctionBarItem(null); 195 cmItem = cm.getMenuItemByName("activate"); 196 if (cmItem != null) { 197 tree.addFunctionBarItem(new FunctionBarItem(cmItem)); 198 } 199 cmItem = cm.getMenuItemByName("deactivate"); 200 if (cmItem != null) { 201 tree.addFunctionBarItem(new FunctionBarItem(cmItem)); 202 } 203 tree.addFunctionBarItem(null); 204 ContextMenuItem menuRefresh = new ContextMenuItem("refresh"); 205 menuRefresh.setLabel(msgs.get("tree.menu.refresh")); menuRefresh.setIcon(request.getContextPath() + "/.resources/icons/16/refresh.gif"); menuRefresh.setOnclick(tree.getJavascriptTree() + ".refresh();"); tree.addFunctionBarItem(new FunctionBarItem(menuRefresh)); 209 } 210 211 } 212 | Popular Tags |