1 13 package info.magnolia.module.admininterface.lists; 14 15 import info.magnolia.cms.core.Path; 16 import info.magnolia.cms.gui.control.ContextMenu; 17 import info.magnolia.cms.gui.control.FunctionBar; 18 import info.magnolia.cms.gui.controlx.RenderKit; 19 import info.magnolia.cms.gui.controlx.RenderKitFactory; 20 import info.magnolia.cms.gui.controlx.list.ListControl; 21 import info.magnolia.cms.gui.controlx.list.ListModel; 22 import info.magnolia.cms.util.FreeMarkerUtil; 23 import info.magnolia.context.MgnlContext; 24 import info.magnolia.context.WebContext; 25 import info.magnolia.module.admininterface.TemplatedMVCHandler; 26 27 import javax.servlet.http.HttpServletRequest ; 28 import javax.servlet.http.HttpServletResponse ; 29 30 31 35 public abstract class AbstractList extends TemplatedMVCHandler { 36 37 private String sortBy = ""; 38 39 private String sortByOrder = "asc"; 40 41 private String groupBy = ""; 42 43 private String groupByOrder = "asc"; 44 45 48 private ListControl list; 49 50 53 private FunctionBar functionBar; 54 55 private ContextMenu contextMenu; 56 57 62 public AbstractList(String name, HttpServletRequest request, HttpServletResponse response) { 63 super(name, request, response); 64 } 65 66 69 protected String getTemplateName(String viewName) { 70 return FreeMarkerUtil.createTemplateName(AbstractList.class, "html"); 71 } 72 73 76 public String show() { 77 String view = super.show(); 78 ListControl list = this.getList(); 79 initList(list); 80 configureList(list); 81 return view; 82 } 83 84 87 public abstract void configureList(ListControl list); 88 89 92 public void initList(ListControl list) { 93 list.setName("list"); 94 list.setRenderKit(this.getRenderKit()); 95 list.setContextMenu(this.getContextMenu()); 96 list.setModel(this.getModel()); 97 list.setSortBy(this.getSortBy()); 98 list.setSortByOrder(this.getSortByOrder()); 99 list.setGroupBy(this.getGroupBy()); 100 list.setGroupByOrder(this.getGroupByOrder()); 101 } 102 103 106 public abstract ListModel getModel(); 107 108 111 public void setList(ListControl list) { 112 this.list = list; 113 } 114 115 118 public ListControl getList() { 119 if (list == null) { 120 list = new ListControl(); 121 } 122 return list; 123 } 124 125 public ContextMenu getContextMenu() { 126 if (this.contextMenu == null) { 127 this.contextMenu = new ContextMenu("contextMenu"); 128 configureContextMenu(this.contextMenu); 129 } 130 return this.contextMenu; 131 } 132 133 136 protected void configureContextMenu(ContextMenu menu) { 137 } 138 139 142 protected RenderKit getRenderKit() { 143 return RenderKitFactory.getRenderKit(RenderKitFactory.ADMIN_INTERFACE_RENDER_KIT); 144 } 145 146 149 public FunctionBar getFunctionBar() { 150 if (this.functionBar == null) { 151 this.functionBar = new FunctionBar("functionBar"); 152 configureFunctionBar(this.functionBar); 153 } 154 return this.functionBar; 155 } 156 157 160 protected void configureFunctionBar(FunctionBar bar) { 161 } 162 163 166 public void setFunctionBar(FunctionBar functionBar) { 167 this.functionBar = functionBar; 168 } 169 170 173 public String getGroupBy() { 174 return this.groupBy; 175 } 176 177 180 public void setGroupBy(String groupBy) { 181 this.groupBy = groupBy; 182 } 183 184 187 public String getGroupByOrder() { 188 return this.groupByOrder; 189 } 190 191 194 public void setGroupByOrder(String groupByOrder) { 195 this.groupByOrder = groupByOrder; 196 } 197 198 201 public String getSortBy() { 202 return this.sortBy; 203 } 204 205 208 public void setSortBy(String sortBy) { 209 this.sortBy = sortBy; 210 } 211 212 215 public String getSortByOrder() { 216 return this.sortByOrder; 217 } 218 219 222 public void setSortByOrder(String sortByOrder) { 223 this.sortByOrder = sortByOrder; 224 } 225 226 229 public String onRender() { 230 return ""; 231 } 232 233 public String getURI() { 234 String uri = (String ) MgnlContext.getAttribute(Path.MGNL_REQUEST_URI_DECODED); 235 return uri; 236 } 237 238 } 239 | Popular Tags |