List of usage examples for java.util Locale equals
@Override public boolean equals(Object obj)
From source file:com.haulmont.cuba.core.sys.AbstractMessages.java
protected String searchOnePack(String pack, String key, Locale locale, Locale truncatedLocale, Set<String> passedPacks) { String cacheKey = makeCacheKey(pack, key, locale, truncatedLocale); String msg = strCache.get(cacheKey); if (msg != null) return msg; msg = searchFiles(pack, key, locale, truncatedLocale, passedPacks); if (msg == null) { msg = searchClasspath(pack, key, locale, truncatedLocale, passedPacks); }// w w w .j a v a2 s .c o m if (msg == null && locale.equals(truncatedLocale)) { msg = searchRemotely(pack, key, locale); if (msg != null) { cache(cacheKey, msg); } } return msg; }
From source file:com.appsimobile.appsii.timezonepicker.TimeZoneData.java
private String getCountryNames(String lang, String countryCode) { final Locale defaultLocale = Locale.getDefault(); String countryDisplayName;//from w w w .j a v a 2 s.co m if (PALESTINE_COUNTRY_CODE.equalsIgnoreCase(countryCode)) { countryDisplayName = mPalestineDisplayName; } else { countryDisplayName = new Locale(lang, countryCode).getDisplayCountry(defaultLocale); } if (!countryCode.equals(countryDisplayName)) { return countryDisplayName; } if (mBackupCountryCodes == null || !defaultLocale.equals(mBackupCountryLocale)) { mBackupCountryLocale = defaultLocale; mBackupCountryCodes = mContext.getResources().getStringArray(R.array.backup_country_codes); mBackupCountryNames = mContext.getResources().getStringArray(R.array.backup_country_names); } int length = Math.min(mBackupCountryCodes.length, mBackupCountryNames.length); for (int i = 0; i < length; i++) { if (mBackupCountryCodes[i].equals(countryCode)) { return mBackupCountryNames[i]; } } return countryCode; }
From source file:com.projity.contrib.calendar.JXXMonthView.java
public static boolean isChinese() { Locale locale = Locale.getDefault(); return locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE); }
From source file:org.tinymediamanager.ui.settings.GeneralSettingsPanel.java
/** * Instantiates a new general settings panel. *///w w w. j av a2s. c o m public GeneralSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("left:max(200px;min):grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(200px;default):grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelUI = new JPanel(); panelUI.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.ui"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelUI, "2, 2, 3, 1, fill, fill"); panelUI.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); LocaleComboBox actualLocale = null; // cbLanguage = new JComboBox(Utils.getLanguages().toArray()); Locale settingsLang = Utils.getLocaleFromLanguage(Globals.settings.getLanguage()); for (Locale l : Utils.getLanguages()) { LocaleComboBox localeComboBox = new LocaleComboBox(l); locales.add(localeComboBox); if (l.equals(settingsLang)) { actualLocale = localeComboBox; } } JLabel lblUiLanguage = new JLabel(BUNDLE.getString("Settings.language")); panelUI.add(lblUiLanguage, "2, 2"); cbLanguage = new JComboBox(locales.toArray()); panelUI.add(cbLanguage, "4, 2"); if (actualLocale != null) { cbLanguage.setSelectedItem(actualLocale); } JSeparator separator = new JSeparator(); separator.setOrientation(SwingConstants.VERTICAL); panelUI.add(separator, "8, 2, 1, 7"); JLabel lblFontFamily = new JLabel(BUNDLE.getString("Settings.fontfamily")); //$NON-NLS-1$ panelUI.add(lblFontFamily, "10, 2, right, default"); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); cbFontFamily = new JComboBox(env.getAvailableFontFamilyNames()); cbFontFamily.setSelectedItem(Globals.settings.getFontFamily()); int index = cbFontFamily.getSelectedIndex(); if (index < 0) { cbFontFamily.setSelectedItem("Dialog"); index = cbFontFamily.getSelectedIndex(); } if (index < 0) { cbFontFamily.setSelectedIndex(0); } panelUI.add(cbFontFamily, "12, 2, fill, default"); JLabel lblFontSize = new JLabel(BUNDLE.getString("Settings.fontsize")); //$NON-NLS-1$ panelUI.add(lblFontSize, "10, 4, right, default"); cbFontSize = new JComboBox(DEFAULT_FONT_SIZES); cbFontSize.setSelectedItem(Globals.settings.getFontSize()); index = cbFontSize.getSelectedIndex(); if (index < 0) { cbFontSize.setSelectedIndex(0); } panelUI.add(cbFontSize, "12, 4, fill, default"); JPanel panel = new JPanel(); panelUI.add(panel, "2, 6, 5, 1, fill, fill"); panel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JLabel lblMissingTranslation = new JLabel(BUNDLE.getString("tmm.helptranslate")); panel.add(lblMissingTranslation, "1, 1, 5, 1"); lblLinkTransifex = new LinkLabel("https://www.transifex.com/projects/p/tinymediamanager/"); panel.add(lblLinkTransifex, "1, 3, 5, 1"); lblLinkTransifex.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { TmmUIHelper.browseUrl(lblLinkTransifex.getNormalText()); } catch (Exception e) { LOGGER.error(e.getMessage()); MessageManager.instance .pushMessage(new Message(MessageLevel.ERROR, lblLinkTransifex.getNormalText(), "message.erroropenurl", new String[] { ":", e.getLocalizedMessage() }));//$NON-NLS-2$ } } }); tpFontHint = new JTextPane(); tpFontHint.setOpaque(false); TmmFontHelper.changeFont(tpFontHint, 0.833); tpFontHint.setText(BUNDLE.getString("Settings.fonts.hint")); //$NON-NLS-1$ panelUI.add(tpFontHint, "10, 6, 5, 1"); lblLanguageHint = new JLabel(""); TmmFontHelper.changeFont(lblLanguageHint, Font.BOLD); panelUI.add(lblLanguageHint, "2, 8, 5, 1"); lblFontChangeHint = new JLabel(""); TmmFontHelper.changeFont(lblFontChangeHint, Font.BOLD); panelUI.add(lblFontChangeHint, "10, 8, 5, 1"); JPanel panelMemory = new JPanel(); panelMemory.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.memoryborder"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMemory, "2, 4, fill, fill"); panelMemory.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow(4)"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(20dlu;default)"), ColumnSpec.decode("left:default:grow(5)"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblMemoryT = new JLabel(BUNDLE.getString("Settings.memory")); //$NON-NLS-1$ panelMemory.add(lblMemoryT, "2, 1"); sliderMemory = new JSlider(); sliderMemory.setPaintLabels(true); sliderMemory.setPaintTicks(true); sliderMemory.setSnapToTicks(true); sliderMemory.setMajorTickSpacing(512); sliderMemory.setMinorTickSpacing(128); sliderMemory.setMinimum(256); sliderMemory.setMaximum(1536); sliderMemory.setValue(512); panelMemory.add(sliderMemory, "4, 1, fill, default"); lblMemory = new JLabel("512"); //$NON-NLS-1$ panelMemory.add(lblMemory, "6, 1, right, default"); JLabel lblMb = new JLabel("MB"); panelMemory.add(lblMb, "7, 1, left, default"); tpMemoryHint = new JTextPane(); tpMemoryHint.setOpaque(false); tpMemoryHint.setText(BUNDLE.getString("Settings.memory.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(tpMemoryHint, 0.833); panelMemory.add(tpMemoryHint, "2, 3, 6, 1, fill, fill"); JPanel panelProxySettings = new JPanel(); panelProxySettings.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.proxy"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelProxySettings, "4, 4, fill, fill"); panelProxySettings.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblProxyHost = new JLabel(BUNDLE.getString("Settings.proxyhost")); //$NON-NLS-1$ panelProxySettings.add(lblProxyHost, "2, 2, right, default"); tfProxyHost = new JTextField(); lblProxyHost.setLabelFor(tfProxyHost); panelProxySettings.add(tfProxyHost, "4, 2, fill, default"); tfProxyHost.setColumns(10); JLabel lblProxyPort = new JLabel(BUNDLE.getString("Settings.proxyport")); //$NON-NLS-1$ panelProxySettings.add(lblProxyPort, "2, 4, right, default"); tfProxyPort = new JTextField(); lblProxyPort.setLabelFor(tfProxyPort); panelProxySettings.add(tfProxyPort, "4, 4, fill, default"); tfProxyPort.setColumns(10); JLabel lblProxyUser = new JLabel(BUNDLE.getString("Settings.proxyuser")); //$NON-NLS-1$ panelProxySettings.add(lblProxyUser, "2, 6, right, default"); tfProxyUsername = new JTextField(); lblProxyUser.setLabelFor(tfProxyUsername); panelProxySettings.add(tfProxyUsername, "4, 6, fill, default"); tfProxyUsername.setColumns(10); JLabel lblProxyPassword = new JLabel(BUNDLE.getString("Settings.proxypass")); //$NON-NLS-1$ panelProxySettings.add(lblProxyPassword, "2, 8, right, default"); tfProxyPassword = new JPasswordField(); lblProxyPassword.setLabelFor(tfProxyPassword); panelProxySettings.add(tfProxyPassword, "4, 8, fill, default"); JPanel panelMediaPlayer = new JPanel(); panelMediaPlayer.setBorder( new TitledBorder(null, "MediaPlayer", TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMediaPlayer, "2, 6, fill, fill"); panelMediaPlayer.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); tpMediaPlayer = new JTextPane(); tpMediaPlayer.setOpaque(false); TmmFontHelper.changeFont(tpMediaPlayer, 0.833); tpMediaPlayer.setText(BUNDLE.getString("Settings.mediaplayer.hint")); //$NON-NLS-1$ panelMediaPlayer.add(tpMediaPlayer, "2, 2, 3, 1, fill, fill"); tfMediaPlayer = new JTextField(); panelMediaPlayer.add(tfMediaPlayer, "2, 4, fill, default"); tfMediaPlayer.setColumns(10); btnSearchMediaPlayer = new JButton(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$ btnSearchMediaPlayer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper.selectFile(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$ if (file != null && Utils.isRegularFile(file) || Platform.isMac()) { tfMediaPlayer.setText(file.toAbsolutePath().toString()); } } }); panelMediaPlayer.add(btnSearchMediaPlayer, "4, 4"); JPanel panelCache = new JPanel(); panelCache.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.cache"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelCache, "4, 6, fill, fill"); panelCache.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); chckbxImageCache = new JCheckBox(BUNDLE.getString("Settings.imagecache"));//$NON-NLS-1$ panelCache.add(chckbxImageCache, "2, 2, 3, 1"); JLabel lblImageCacheQuality = new JLabel(BUNDLE.getString("Settings.imagecachetype"));//$NON-NLS-1$ panelCache.add(lblImageCacheQuality, "2, 4, right, default"); cbImageCacheQuality = new JComboBox(ImageCache.CacheType.values()); panelCache.add(cbImageCacheQuality, "4, 4, fill, default"); JPanel panelAnalytics = new JPanel(); panelAnalytics.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.analytics.border"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelAnalytics, "2, 8, fill, fill"); panelAnalytics.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, })); chckbxAnalytics = new JCheckBox(BUNDLE.getString("Settings.analytics"));//$NON-NLS-1$ panelAnalytics.add(chckbxAnalytics, "2, 2"); JTextPane tpAnalyticsDescription = new JTextPane(); tpAnalyticsDescription.setText(BUNDLE.getString("Settings.analytics.desc"));//$NON-NLS-1$ tpAnalyticsDescription.setOpaque(false); panelAnalytics.add(tpAnalyticsDescription, "2, 4, fill, fill"); JPanel panelMisc = new JPanel(); panelMisc.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.misc"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelMisc, "4, 8, fill, fill"); panelMisc.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, })); chckbxDeleteTrash = new JCheckBox(BUNDLE.getString("Settings.deletetrash")); panelMisc.add(chckbxDeleteTrash, "2, 2, 3, 1"); initDataBindings(); initMemorySlider(); // listen to changes of the combo box ItemListener listener = new ItemListener() { public void itemStateChanged(ItemEvent e) { checkChanges(); } }; cbLanguage.addItemListener(listener); cbFontSize.addItemListener(listener); cbFontFamily.addItemListener(listener); }
From source file:org.opencms.workplace.tools.accounts.A_CmsEditUserDialog.java
/** * Returns a list of options for the locale selector.<p> * /*from www. j ava 2s .c o m*/ * @return a list of options for the locale selector */ private List<CmsSelectWidgetOption> getLanguages() { List<CmsSelectWidgetOption> locales = new ArrayList<CmsSelectWidgetOption>(); Locale defLocale = null; if ((m_user != null) && CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_user.getName())) { defLocale = new CmsUserSettings(m_user).getLocale(); } if (defLocale == null) { defLocale = getCms().getRequestContext().getLocale(); } Iterator<Locale> itLocales = OpenCms.getLocaleManager().getAvailableLocales().iterator(); while (itLocales.hasNext()) { Locale locale = itLocales.next(); boolean selected = locale.equals(defLocale); locales.add(new CmsSelectWidgetOption(locale.toString(), selected, locale.getDisplayName(getLocale()), null)); } return locales; }
From source file:org.springframework.integration.expression.ReloadableResourceBundleExpressionSource.java
/** * Calculate all filenames for the given bundle basename and Locale. * Will calculate filenames for the given Locale, the system Locale * (if applicable), and the default file. * @param basename the basename of the bundle * @param locale the locale/*from w w w . ja v a2 s . com*/ * @return the List of filenames to check * @see #setFallbackToSystemLocale * @see #calculateFilenamesForLocale */ private List<String> calculateAllFilenames(String basename, Locale locale) { synchronized (this.cachedFilenames) { Map<Locale, List<String>> localeMap = this.cachedFilenames.get(basename); if (localeMap != null) { List<String> filenames = localeMap.get(locale); if (filenames != null) { return filenames; } } List<String> filenames = new ArrayList<String>(7); filenames.addAll(calculateFilenamesForLocale(basename, locale)); if (this.fallbackToSystemLocale && !locale.equals(Locale.getDefault())) { List<String> fallbackFilenames = calculateFilenamesForLocale(basename, Locale.getDefault()); for (String fallbackFilename : fallbackFilenames) { if (!filenames.contains(fallbackFilename)) { // Entry for fallback locale that isn't already in filenames list. filenames.add(fallbackFilename); } } } filenames.add(basename); if (localeMap != null) { localeMap.put(locale, filenames); } else { localeMap = new HashMap<Locale, List<String>>(); localeMap.put(locale, filenames); this.cachedFilenames.put(basename, localeMap); } return filenames; } }
From source file:com.flexive.shared.exceptions.FxExceptionMessage.java
/** * Returns the resource bundle, which is cached within the request. * * @param key resource key/*from w ww . j a va 2 s . c o m*/ * @param locale the requested locale * @return the resource bundle value */ public String getResource(String key, Locale locale) { if (!initialized) { initialize(); } final FxSharedUtils.MessageKey messageKey = new FxSharedUtils.MessageKey(locale, key); String cachedMessage = cachedMessages.get(messageKey); if (cachedMessage != null) { return cachedMessage; } for (FxSharedUtils.BundleReference bundleReference : resourceBundles) { try { final ResourceBundle bundle = getResources(bundleReference, locale); final String message = bundle.getString(key); cachedMessage = cachedMessages.putIfAbsent(messageKey, message); return cachedMessage != null ? cachedMessage : message; } catch (MissingResourceException e) { // continue with next bundle } } if (!locale.equals(Locale.ENGLISH)) { //try to find the locale in english as last resort //this is a fix for using PropertyResourceBundles which can only handle one locale (have to use them thanks to JBoss 5...) for (FxSharedUtils.BundleReference bundleReference : resourceBundles) { try { final ResourceBundle bundle = getResources(bundleReference, Locale.ENGLISH); final String message = bundle.getString(key); cachedMessage = cachedMessages.putIfAbsent(messageKey, message); return cachedMessage != null ? cachedMessage : message; } catch (MissingResourceException e) { // continue with next bundle } } } throw new MissingResourceException("Resource not found", FxExceptionMessage.class.getCanonicalName(), key); }
From source file:dhbw.clippinggorilla.userinterface.windows.NewSourceWindow.java
public void validateSecondStage(Source s, String id, String title, String url, String description, Category category, Locale language, Locale country, String imageUrl) { String errors = ""; if (id == null || id.isEmpty()) { errors += "Empty Id<br>"; }/*from w ww . j a v a 2 s . co m*/ if (title == null || title.isEmpty()) { errors += "Empty Name<br>"; } if (!isURL(url)) { errors += "Empty or invalid URL<br>"; } if (description == null || description.isEmpty()) { errors += "Empty Description<br>"; } if (category == null) { errors += "Empty Category<br>"; } if (language == null || language.equals(Locale.ROOT)) { errors += "Empty Language<br>"; } if (country == null || country.equals(Locale.ROOT)) { errors += "Empty Country<br>"; } if (!isURL(imageUrl)) { errors += "Empty or invalid ImageURL"; } if (!errors.isEmpty()) { VaadinUtils.errorNotification("Errors during Source setup<br>" + errors); } else { s.setName(title); s.setUrl(url); s.setDescription(description); s.setCategory(category.name());//Ignore possible null pointer, cant happen s.setLanguageAndCountry(language.getLanguage(), country.getCountry());//Ignore possible null pointer, cant happen s.setLogo(imageUrl); setContent(getThirdStage(s)); center(); } }
From source file:com.github.peholmst.springsecuritydemo.servlet.SpringApplicationServlet.java
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { /*//from w w w.j ava 2s . c om * Resolve the locale from the request */ final Locale locale = localeResolver.resolveLocale(request); if (logger.isDebugEnabled()) { logger.debug("Resolved locale [" + locale + "]"); } /* * Store the locale in the LocaleContextHolder, making it available to * Spring. */ LocaleContextHolder.setLocale(locale); ServletRequestAttributes requestAttributes = new ServletRequestAttributes(request); RequestContextHolder.setRequestAttributes(requestAttributes); try { /* * We need to override the request to return the locale resolved by * Spring. */ super.service(new HttpServletRequestWrapper(request) { @Override public Locale getLocale() { return locale; } }, response); } finally { if (!locale.equals(LocaleContextHolder.getLocale())) { /* * The locale in LocaleContextHolder was changed during the * request, so we have to update the resolver. */ if (logger.isDebugEnabled()) { logger.debug("Locale changed, updating locale resolver"); } localeResolver.setLocale(request, response, LocaleContextHolder.getLocale()); } LocaleContextHolder.resetLocaleContext(); RequestContextHolder.resetRequestAttributes(); } }
From source file:org.opencms.workplace.editors.CmsDialogCopyLanguage.java
/** * Builds the html String for a form list of all possible page elements.<p> * /*from w w w . j a va 2 s . co m*/ * @return the html String for a form list */ public String buildLanguageList() { try { StringBuffer retValue = new StringBuffer(512); retValue.append("<table border=\"0\">\n"); // get locale for current element Locale elLocale = getElementLocale(); // get locale names based on properties and global settings List localeList = OpenCms.getLocaleManager().getAvailableLocales(getCms(), getParamTempfile()); // read xml content for checking locale availability CmsFile file = getCms().readFile(getParamTempfile(), CmsResourceFilter.IGNORE_EXPIRATION); CmsXmlContent content = CmsXmlContentFactory.unmarshal(getCms(), file); // show all possible elements Iterator i = localeList.iterator(); while (i.hasNext()) { // get the current list element Locale curLocale = (Locale) i.next(); // skip locale of current element if (elLocale.equals(curLocale)) { continue; } // build an element row retValue.append("<tr>\n"); retValue.append("\t<td class=\"textcenter\" unselectable=\"on\"><input type=\"checkbox\" name=\""); retValue.append(PARAM_LANGUAGE); retValue.append("\" value=\""); retValue.append(curLocale.toString()); retValue.append("\">"); retValue.append("</td>\n"); retValue.append("\t<td style=\"white-space: nowrap;\" unselectable=\"on\">"); retValue.append(curLocale.getDisplayName(getLocale())); retValue.append(!content.hasLocale(curLocale) ? " [-]" : ""); retValue.append("</td>\n"); retValue.append("\t<td style=\"white-space: nowrap;\" unselectable=\"on\">"); retValue.append(!content.hasLocale(curLocale) ? Messages.get().getBundle(getLocale()).key(Messages.GUI_EDITOR_DIALOG_COPYLANGUAGE_NEW_0) : ""); retValue.append("</td>\n"); retValue.append("</tr>\n"); } retValue.append("</table>\n"); return retValue.toString(); } catch (Throwable e) { // should usually never happen if (LOG.isInfoEnabled()) { LOG.info(e); } return ""; } }