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 RolesTreeConfiguration 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 48 tree.setIcon(ItemType.ROLE.getSystemName(), Tree.ICONDOCROOT + "hat_white.gif"); tree.setIconOndblclick("mgnlTreeMenuOpenDialog(" + tree.getJavascriptTree() 51 + ",'.magnolia/dialogs/roleedit.html');"); tree.addItemType(ItemType.ROLE); 53 54 TreeColumn column0 = new TreeColumn(tree.getJavascriptTree(), request); 55 column0.setIsLabel(true); 56 if (Server.isAdmin()) { 57 column0.setHtmlEdit(); 58 } 59 column0.setWidth(2); 60 column0.setTitle(msgs.get("tree.roles.name")); TreeColumn column1 = new TreeColumn(tree.getJavascriptTree(), request); 62 column1.setName("title"); if (Server.isAdmin() && !browseMode) { 64 column1.setHtmlEdit(); 65 } 66 column1.setWidth(2); 67 column1.setTitle(msgs.get("tree.roles.fullname")); TreeColumn columnIcons = new TreeColumn(tree.getJavascriptTree(), request); 69 columnIcons.setCssClass(StringUtils.EMPTY); 70 columnIcons.setWidth(1); 71 columnIcons.setIsIcons(true); 72 columnIcons.setIconsActivation(true); 73 TreeColumn column2 = new TreeColumn(tree.getJavascriptTree(), request); 74 column2.setName(MetaData.CREATION_DATE); 75 column2.setIsMeta(true); 77 column2.setDateFormat("yyyy-MM-dd, HH:mm"); column2.setTitle(msgs.get("tree.roles.date")); column2.setWidth(2); 80 81 tree.addColumn(column0); 82 if (!browseMode) { 83 tree.addColumn(column1); 84 if (Server.isAdmin() || Subscriber.isSubscribersEnabled()) { 85 tree.addColumn(columnIcons); 86 } 87 tree.addColumn(column2); 88 } 89 90 } 91 92 96 public void prepareContextMenu(Tree tree, boolean browseMode, HttpServletRequest request) { 97 Messages msgs = MessagesManager.getMessages(); 98 99 ContextMenuItem menuOpen = new ContextMenuItem("edit"); 100 menuOpen.setLabel(msgs.get("tree.roles.menu.edit")); menuOpen.setIcon(request.getContextPath() + "/.resources/icons/16/hat_white.gif"); menuOpen.setOnclick("mgnlTreeMenuOpenDialog(" + tree.getJavascriptTree() 104 + ",'.magnolia/dialogs/roleedit.html');"); menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() 107 + ")"); ContextMenuItem menuNewPage = new ContextMenuItem("new"); 109 menuNewPage.setLabel(msgs.get("tree.roles.menu.new")); menuNewPage.setIcon(request.getContextPath() + "/.resources/icons/16/hat_white_add.gif"); menuNewPage.setOnclick(tree.getJavascriptTree() + ".createRootNode('" + ItemType.ROLE.getSystemName() 113 + "');"); ContextMenuItem menuDelete = new ContextMenuItem("delete"); 115 menuDelete.setLabel(msgs.get("tree.roles.menu.delete")); menuDelete.setIcon(request.getContextPath() + "/.resources/icons/16/delete2.gif"); menuDelete.setOnclick(tree.getJavascriptTree() + ".deleteNode();"); menuDelete.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() 120 + ")"); ContextMenuItem menuMove = new ContextMenuItem("move"); 122 menuMove.setLabel(msgs.get("tree.roles.menu.move")); menuMove.setIcon(request.getContextPath() + "/.resources/icons/16/up_down.gif"); menuMove.setOnclick(tree.getJavascriptTree() + ".cutNode();"); menuMove.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() 127 + ")"); ContextMenuItem menuCopy = new ContextMenuItem("copy"); 129 menuCopy.setLabel(msgs.get("tree.roles.menu.copy")); menuCopy.setIcon(request.getContextPath() + "/.resources/icons/16/copy.gif"); menuCopy.setOnclick(tree.getJavascriptTree() + ".copyNode();"); menuCopy.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() 134 + ")"); 136 ContextMenuItem menuActivateExcl = new ContextMenuItem("activate"); 137 menuActivateExcl.setLabel(msgs.get("tree.roles.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() 142 + ")"); ContextMenuItem menuDeActivate = new ContextMenuItem("deactivate"); 144 menuDeActivate.setLabel(msgs.get("tree.roles.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() 149 + ")"); 151 if (!Subscriber.isSubscribersEnabled()) { 152 menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); menuDeActivate.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); } 155 156 if (!browseMode) { 157 tree.addMenuItem(menuOpen); 158 tree.addMenuItem(menuNewPage); 159 160 tree.addMenuItem(null); tree.addMenuItem(menuDelete); 162 163 tree.addMenuItem(null); tree.addMenuItem(menuActivateExcl); 165 tree.addMenuItem(menuDeActivate); 166 } 167 else { 168 ContextMenuItem menuRefresh = new ContextMenuItem("refresh"); 169 menuRefresh.setLabel(msgs.get("tree.menu.refresh")); menuRefresh.setIcon(request.getContextPath() + "/.resources/icons/16/refresh.gif"); menuRefresh.setOnclick(tree.getJavascriptTree() + ".refresh();"); tree.addMenuItem(menuRefresh); 173 } 174 } 175 176 180 public void prepareFunctionBar(Tree tree, boolean browseMode, HttpServletRequest request) { 181 Messages msgs = MessagesManager.getMessages(); 182 ContextMenu cm = tree.getMenu(); 183 ContextMenuItem cmItem = cm.getMenuItemByName("edit"); 184 if (cmItem != null) { 185 tree.addFunctionBarItem(new FunctionBarItem(cmItem)); 186 } 187 cmItem = cm.getMenuItemByName("new"); 188 if (cmItem != null) { 189 tree.addFunctionBarItem(new FunctionBarItem(cmItem)); 190 } 191 tree.addFunctionBarItem(null); 193 cmItem = cm.getMenuItemByName("activate"); 194 if (cmItem != null) { 195 tree.addFunctionBarItem(new FunctionBarItem(cmItem)); 196 } 197 cmItem = cm.getMenuItemByName("deactivate"); 198 if (cmItem != null) { 199 tree.addFunctionBarItem(new FunctionBarItem(cmItem)); 200 } 201 tree.addFunctionBarItem(null); 202 ContextMenuItem menuRefresh = new ContextMenuItem("refresh"); 203 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)); 207 } 208 209 } 210 | Popular Tags |