📄 columntagutils.java
字号:
/* * Copyright 2004 original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.extremecomponents.table.tag;import org.apache.commons.lang.StringUtils;import org.extremecomponents.table.bean.Column;import org.extremecomponents.table.core.BaseModel;import org.extremecomponents.table.core.BaseProperties;import org.extremecomponents.table.core.TableModelUtils;import org.extremecomponents.table.core.TableResourceBundle;import org.extremecomponents.util.ExtremeUtils;/** * Pull all the values for the ColumnTag. Because the default values could be * coming from the properties or resource bundle this class will abstract that * out. * * A very useful helper class, that should be called from any custom tags. * * @author Jeff Johnston */public final class ColumnTagUtils { public static String getProperty(BaseModel model, String property) { return property; } public static String getTitle(BaseModel model, String title, String property) { if (StringUtils.isEmpty(title)) { return ExtremeUtils.camelCaseToWord(property); } if (TableModelUtils.isResourceBundleProperty(title)) { String resourceValue = model.getResourceBundle().getResource(title); if (resourceValue != null) { return resourceValue; } } return title; } public static String getStyleClass(BaseModel model, String styleClass) { return styleClass; } public static String getHeaderClass(BaseModel model, String headerClass) { if (StringUtils.isEmpty(headerClass)) { return model.getProperties().getProperty(BaseProperties.HEADER_CLASS); } return headerClass; } public static String getHeaderStyle(BaseModel model, String headerStyle) { return headerStyle; } public static String getFilterClass(BaseModel model, String filterClass) { return filterClass; } public static String getFilterStyle(BaseModel model, String filterStyle) { return filterStyle; } public static String getCell(BaseModel model, String cell) { if (StringUtils.isBlank(cell)) { return model.getProperties().getProperty(BaseProperties.CELL); } return cell; } public static String getFilterCell(BaseModel model, String filterCell) { if (StringUtils.isBlank(filterCell)) { return model.getProperties().getProperty(BaseProperties.FILTER_CELL); } return filterCell; } public static String getHeaderCell(BaseModel model, String headerCell) { if (StringUtils.isBlank(headerCell)) { return model.getProperties().getProperty(BaseProperties.HEADER_CELL); } return headerCell; } /** * If this is a named format then it should be in the resource bundle. For * backwards compatibility check the properties file also. * * Be sure to call the getCell() method before calling this method. */ public static String getFormat(BaseModel model, String format, String cell) { String result = getFormatInResourceBundle(model, format, cell); if (StringUtils.isBlank(result)) { result = getFormatInProperties(model, format, cell); } if (StringUtils.isNotBlank(result)) { return result; } return format; } private static String getFormatInResourceBundle(BaseModel model, String format, String cell) { if (StringUtils.isNotBlank(format) && isNamedFormat(format)) { return model.getResourceBundle().getResource(TableResourceBundle.FORMAT + format); } if (StringUtils.isBlank(format)) { if (cell.equals(Column.CURRENCY)) { return model.getResourceBundle().getResource(TableResourceBundle.FORMAT + Column.CURRENCY); } else if (cell.equals(Column.DATE)) { return model.getResourceBundle().getResource(TableResourceBundle.FORMAT + Column.DATE); } } return null; } private static String getFormatInProperties(BaseModel model, String format, String cell) { if (StringUtils.isNotBlank(format) && isNamedFormat(format)) { return model.getProperties().getProperty(BaseProperties.FORMAT + format); } if (StringUtils.isBlank(format)) { if (cell.equals(Column.CURRENCY)) { return model.getProperties().getProperty(BaseProperties.FORMAT + Column.CURRENCY); } else if (cell.equals(Column.DATE)) { return model.getProperties().getProperty(BaseProperties.FORMAT + Column.DATE); } } return null; } /** * If the format contains any of these formats then it is custom format * doing inline. */ private static boolean isNamedFormat(String format) { char args[] = { '#', '/', '-' }; if (StringUtils.containsNone(format, args)) { return true; } return false; } /** * Be sure to call the getCell() method before calling this method. */ public static String getParse(BaseModel model, String parse, String cell) { if (StringUtils.isNotBlank(parse)) { return parse; } if (cell.equals(Column.DATE)) { return model.getProperties().getProperty(BaseProperties.PARSE + Column.DATE); } return parse; } public static String getFilterable(BaseModel model, String filterable) { if (StringUtils.isEmpty(filterable)) { return String.valueOf(model.getTableHandler().getTable().isFilterable()); } return filterable; } public static String getSortable(BaseModel model, String sortable) { if (StringUtils.isEmpty(sortable)) { return String.valueOf(model.getTableHandler().getTable().isSortable()); } return sortable; } public static String getWidth(BaseModel model, String width) { return width; } public static String getStyle(BaseModel model, String style) { return style; } public static String getShowTotal(BaseModel model, String showTotal) { return showTotal; } public static String getViewsAllowed(BaseModel model, String viewsAllowed) { return viewsAllowed; } public static String getViewsDenied(BaseModel model, String viewsDenied) { return viewsDenied; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -