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 GroupsTreeConfiguration 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.GROUP.getSystemName(), Tree.ICONDOCROOT + "group.gif"); tree.setIconOndblclick("mgnlTreeMenuOpenDialog(" + tree.getJavascriptTree() 51 + ",'.magnolia/dialogs/groupedit.html');"); tree.addItemType(ItemType.GROUP); 53 54 TreeColumn column0 = new TreeColumn(tree.getJavascriptTree(), request); 55 column0.setIsLabel(true); 56 column0.setHtmlEdit(); 57 column0.setWidth(2); 58 column0.setTitle(msgs.get("tree.groups.name")); 60 TreeColumn column1 = new TreeColumn(tree.getJavascriptTree(), request); 61 column1.setName("title"); column1.setHtmlEdit(); 63 column1.setWidth(2); 64 column1.setTitle(msgs.get("tree.groups.fullname")); 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.CREATION_DATE); 74 column2.setIsMeta(true); 76 column2.setDateFormat("yyyy-MM-dd, HH:mm"); column2.setTitle(msgs.get("tree.groups.date")); column2.setWidth(2); 79 80 tree.addColumn(column0); 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.groups.menu.edit")); menuOpen.setIcon(request.getContextPath() + "/.resources/icons/16/group.gif"); menuOpen.setOnclick("mgnlTreeMenuOpenDialog(" + tree.getJavascriptTree() 102 + ",'.magnolia/dialogs/groupedit.html');"); menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" + tree.getJavascriptTree() 105 + ")"); 107 ContextMenuItem menuNewPage = new ContextMenuItem("new"); 108 menuNewPage.setLabel(msgs.get("tree.groups.menu.new")); menuNewPage.setIcon(request.getContextPath() + "/.resources/icons/16/group_add.gif"); menuNewPage.setOnclick(tree.getJavascriptTree() + ".createRootNode('" + ItemType.GROUP.getSystemName() 112 + "');"); 114 ContextMenuItem menuDelete = new ContextMenuItem("delete"); 115 menuDelete.setLabel(msgs.get("tree.groups.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.groups.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.groups.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.groups.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.groups.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(menuNewPage); 162 163 tree.addMenuItem(null); tree.addMenuItem(menuDelete); 165 166 tree.addMenuItem(null); tree.addMenuItem(menuActivateExcl); 168 tree.addMenuItem(menuDeActivate); 169 } 170 else { 171 ContextMenuItem menuRefresh = new ContextMenuItem("refresh"); 172 menuRefresh.setLabel(msgs.get("tree.menu.refresh")); menuRefresh.setIcon(request.getContextPath() + "/.resources/icons/16/refresh.gif"); menuRefresh.setOnclick(tree.getJavascriptTree() + ".refresh();"); tree.addMenuItem(menuRefresh); 176 } 177 } 178 179 183 public void prepareFunctionBar(Tree tree, boolean browseMode, HttpServletRequest request) { 184 ContextMenu cm = tree.getMenu(); 186 ContextMenuItem cmItem = cm.getMenuItemByName("edit"); 187 if (cmItem != null) { 188 tree.addFunctionBarItem(new FunctionBarItem(cmItem)); 189 } 190 cmItem = cm.getMenuItemByName("new"); 191 if (cmItem != null) { 192 tree.addFunctionBarItem(new FunctionBarItem(cmItem)); 193 } 194 tree.addFunctionBarItem(null); 196 cmItem = cm.getMenuItemByName("activate"); 197 if (cmItem != null) { 198 tree.addFunctionBarItem(new FunctionBarItem(cmItem)); 199 } 200 cmItem = cm.getMenuItemByName("deactivate"); 201 if (cmItem != null) { 202 tree.addFunctionBarItem(new FunctionBarItem(cmItem)); 203 } 204 tree.addFunctionBarItem(null); 205 ContextMenuItem menuRefresh = new ContextMenuItem("refresh"); 206 menuRefresh.setLabel("refresh"); menuRefresh.setIcon(request.getContextPath() + "/.resources/icons/16/refresh.gif"); menuRefresh.setOnclick(tree.getJavascriptTree() + ".refresh();"); tree.addFunctionBarItem(new FunctionBarItem(menuRefresh)); 210 } 211 212 } 213 | Popular Tags |