⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tableresourcebundle.java

📁 exTreme taglib的使用
💻 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.core;import java.text.MessageFormat;import java.util.Locale;import java.util.MissingResourceException;import java.util.ResourceBundle;import org.apache.commons.lang.StringUtils;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;/** * Load up the resource bundle that will be used by the Model. *  * @author Jeff Johnston */public class TableResourceBundle {    private static Log logger = LogFactory.getLog(TableResourceBundle.class);    public final static String EXTREMETABLE_RESOURCE_BUNDLE = "org.extremecomponents.table.core.extremetableResourceBundle";    public final static String IMAGE_PATH = "table.imagePath";    public final static String FORMAT = "table.format_";    public final static String STATUSBAR_RESULTS_FOUND = "table.statusbar.resultsFound";    public final static String STATUSBAR_NO_RESULTS_FOUND = "table.statusbar.noResultsFound";    public final static String TOOLBAR_FIRST_PAGE_TOOLTIP = "table.toolbar.firstPageTooltip";    public final static String TOOLBAR_LAST_PAGE_TOOLTIP = "table.toolbar.lastPageTooltip";    public final static String TOOLBAR_PREV_PAGE_TOOLTIP = "table.toolbar.prevPageTooltip";    public final static String TOOLBAR_NEXT_PAGE_TOOLTIP = "table.toolbar.nextPageTooltip";    public final static String STATUSBAR_SEARCH_TOOLTIP = "table.statusbar.searchTooltip";    public final static String STATUSBAR_CLEAR_TOOLTIP = "table.statusbar.clearTooltip";    public final static String HEADERCELL_SORT_TOOLTIP = "table.headercell.sortTooltip";    private ResourceBundle customResourceBundle;    private ResourceBundle defaultResourceBundle;    private BaseModel model;    public TableResourceBundle(BaseModel model) {        this.model = model;    }    public void init() {        Locale locale = model.getTableHandler().getTable().getLocale();        defaultResourceBundle = findResourceBundle(EXTREMETABLE_RESOURCE_BUNDLE, locale);        String resourceBundleLocation = model.getTableHandler().getTable().getResourceBundleLocation();        if (StringUtils.isNotBlank(resourceBundleLocation)) {            customResourceBundle = findResourceBundle(resourceBundleLocation, locale);        }    }    private ResourceBundle findResourceBundle(String resourceBundleLocation, Locale locale) {        try {            return customResourceBundle = ResourceBundle.getBundle(resourceBundleLocation, locale, getClass()                    .getClassLoader());        } catch (MissingResourceException e) {            logger.info("The resource bundle [ " + resourceBundleLocation                    + "] was not found. Make sure the path and resource name is correct.");        }        return null;    }    /**     * Get the resource property.     */    public String getResource(String key) {        return getResource(key, null);    }    /**     * Get the resource property.     */    public String getResource(String key, Object[] messageArguments) {        String result = findResource(customResourceBundle, key);        if (result == null) {            result = findResource(defaultResourceBundle, key);        }        if (result != null && messageArguments != null) {            MessageFormat formatter = new MessageFormat("");            formatter.setLocale(model.getTableHandler().getTable().getLocale());            formatter.applyPattern(result);            result = formatter.format(messageArguments);        }        return result;    }    private String findResource(ResourceBundle resourceBundle, String key) {        String result = null;        if (resourceBundle == null) {            return result;        }        try {            result = resourceBundle.getString(key);        } catch (MissingResourceException e) {            // nothing we can do so eat the message        }        return result;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -