1 /** 2 * This file Copyright (c) 2003-2011 Magnolia International 3 * Ltd. (http://www.magnolia-cms.com). All rights reserved. 4 * 5 * 6 * This file is dual-licensed under both the Magnolia 7 * Network Agreement and the GNU General Public License. 8 * You may elect to use one or the other of these licenses. 9 * 10 * This file is distributed in the hope that it will be 11 * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the 12 * implied warranty of MERCHANTABILITY or FITNESS FOR A 13 * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT. 14 * Redistribution, except as permitted by whichever of the GPL 15 * or MNA you select, is prohibited. 16 * 17 * 1. For the GPL license (GPL), you can redistribute and/or 18 * modify this file under the terms of the GNU General 19 * Public License, Version 3, as published by the Free Software 20 * Foundation. You should have received a copy of the GNU 21 * General Public License, Version 3 along with this program; 22 * if not, write to the Free Software Foundation, Inc., 51 23 * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 24 * 25 * 2. For the Magnolia Network Agreement (MNA), this file 26 * and the accompanying materials are made available under the 27 * terms of the MNA which accompanies this distribution, and 28 * is available at http://www.magnolia-cms.com/mna.html 29 * 30 * Any modifications to this file must keep this entire header 31 * intact. 32 * 33 */ 34 package info.magnolia.cms.gui.controlx.list; 35 36 import info.magnolia.cms.gui.controlx.impl.TemplatedRenderer; 37 38 39 /** 40 * Renders a list view. 41 * @author Philipp Bracher 42 * @version $Revision: 41135 $ ($Author: gjoseph $) 43 */ 44 public class ListControlRenderer extends TemplatedRenderer { 45 46 /** 47 * Default template used. 48 */ 49 public ListControlRenderer() { 50 super(); 51 } 52 53 /** 54 * Pass the template to use. 55 * @param templateName 56 */ 57 public ListControlRenderer(String templateName) { 58 super(templateName); 59 } 60 61 /** 62 * Return asc or desc. 63 * @param list 64 * @param field 65 * @return 66 */ 67 public String nextSortByOrder(ListControl list, String field) { 68 if (list.getSortBy().equals(field)) { 69 if (list.getSortByOrder().equals("asc")) { 70 return "desc"; 71 } 72 } 73 return "asc"; 74 } 75 76 /** 77 * Return asc or desc. 78 * @param list 79 * @param field 80 * @return 81 */ 82 public String nextGroupByOrder(ListControl list, String field) { 83 if (list.getGroupBy().equals(field)) { 84 if (list.getGroupByOrder().equals("asc")) { 85 return "desc"; 86 } 87 } 88 return "asc"; 89 } 90 91 /** 92 * Called onclick, dblclick, contextmenu 93 * @param list 94 * @return 95 */ 96 public String onSelect(ListControl list, Integer index) { 97 return ""; 98 } 99 100 /** 101 * Render the click event 102 * @param iter 103 * @return 104 */ 105 public String onClick(ListControl list, Integer index) { 106 return ""; 107 } 108 109 /** 110 * Render the double click event 111 * @param iter 112 * @return 113 */ 114 public String onDblClick(ListControl list, Integer index) { 115 return ""; 116 } 117 118 /** 119 * Render the double click event 120 * @param iter 121 * @return 122 */ 123 public String onRightClick(ListControl list, Integer index) { 124 return ""; 125 } 126 127 /** 128 * Used to get the css class for the grouplinks 129 * @param list 130 * @param field 131 * @return the css class as a string 132 */ 133 public String getGroupLinkCSSClass(ListControl list, String field) { 134 if (list.getGroupBy().equals(field)) { 135 return "mgnlListSortGroupLink" + list.getGroupByOrder().toUpperCase(); 136 } 137 return "mgnlListSortGroupLink"; 138 } 139 140 /** 141 * Used to get the css class for the sort links 142 * @param list 143 * @param field 144 * @return the css class as a string 145 */ 146 public String getSortLinkCSSClass(ListControl list, String field) { 147 if (list.getSortBy().equals(field)) { 148 return "mgnlListSortGroupLink" + list.getSortByOrder().toUpperCase(); 149 } 150 return "mgnlListSortGroupLink"; 151 } 152 153 }