List of usage examples for java.util Locale equals
@Override public boolean equals(Object obj)
From source file:net.technicpack.launcher.ui.InstallerFrame.java
private void setupPortableMode(JPanel panel) { panel.setLayout(new GridBagLayout()); JLabel portableSpiel = new JLabel("<html><body align=\"left\" style='margin-right:10px;'>" + resources.getString("launcher.installer.portablespiel") + "</body></html>"); portableSpiel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16)); portableSpiel.setForeground(LauncherFrame.COLOR_WHITE_TEXT); portableSpiel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.add(portableSpiel, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(9, 8, 9, 3), 0, 0)); panel.add(Box.createGlue(), new GridBagConstraints(0, 1, 3, 1, 1.0, 0.7, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); JLabel installFolderLabel = new JLabel(resources.getString("launcher.installer.folder")); installFolderLabel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18)); installFolderLabel.setForeground(LauncherFrame.COLOR_WHITE_TEXT); panel.add(installFolderLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 24, 0, 8), 0, 0)); String installDir = ""; if (settings.isPortable()) installDir = settings.getTechnicRoot().getAbsolutePath(); portableInstallDir = new JTextField(installDir); portableInstallDir.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18)); portableInstallDir.setForeground(LauncherFrame.COLOR_BLUE); portableInstallDir.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL); portableInstallDir.setHighlighter(null); portableInstallDir.setEditable(false); portableInstallDir.setCursor(null);//from w w w . j ava2 s. co m portableInstallDir.setBorder(new RoundBorder(LauncherFrame.COLOR_BUTTON_BLUE, 1, 8)); panel.add(portableInstallDir, new GridBagConstraints(1, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0)); RoundedButton selectInstall = new RoundedButton(resources.getString("launcher.installer.select")); selectInstall.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18)); selectInstall.setContentAreaFilled(false); selectInstall.setForeground(LauncherFrame.COLOR_BUTTON_BLUE); selectInstall.setHoverForeground(LauncherFrame.COLOR_BLUE); selectInstall.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectPortable(); } }); panel.add(selectInstall, new GridBagConstraints(2, 2, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 0, 16), 0, 0)); panel.add(Box.createGlue(), new GridBagConstraints(0, 3, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); String defaultLocaleText = resources.getString("launcheroptions.language.default"); if (!resources.isDefaultLocaleSupported()) { defaultLocaleText = defaultLocaleText .concat(" (" + resources.getString("launcheroptions.language.unavailable") + ")"); } portableLanguages = new JComboBox(); portableLanguages.addItem(new LanguageItem(ResourceLoader.DEFAULT_LOCALE, defaultLocaleText, resources)); for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) { portableLanguages .addItem(new LanguageItem(resources.getCodeFromLocale(ResourceLoader.SUPPORTED_LOCALES[i]), ResourceLoader.SUPPORTED_LOCALES[i].getDisplayName(ResourceLoader.SUPPORTED_LOCALES[i]), resources.getVariant(ResourceLoader.SUPPORTED_LOCALES[i]))); } if (!settings.getLanguageCode().equalsIgnoreCase(ResourceLoader.DEFAULT_LOCALE)) { Locale loc = resources.getLocaleFromCode(settings.getLanguageCode()); for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) { if (loc.equals(ResourceLoader.SUPPORTED_LOCALES[i])) { portableLanguages.setSelectedIndex(i + 1); break; } } } portableLanguages.setBorder(new RoundBorder(LauncherFrame.COLOR_SCROLL_THUMB, 1, 10)); portableLanguages.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14)); portableLanguages.setUI(new LanguageCellUI(resources)); portableLanguages.setForeground(LauncherFrame.COLOR_WHITE_TEXT); portableLanguages.setBackground(LauncherFrame.COLOR_SELECTOR_BACK); portableLanguages.setRenderer(new LanguageCellRenderer(resources, "globe.png", LauncherFrame.COLOR_SELECTOR_BACK, LauncherFrame.COLOR_WHITE_TEXT)); portableLanguages.setEditable(false); portableLanguages.setFocusable(false); portableLanguages.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { portableLanguageChanged(); } }); panel.add(portableLanguages, new GridBagConstraints(0, 4, 1, 0, 0, 0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, 8, 8, 0), 0, 0)); portableInstallButton = new RoundedButton(resources.getString("launcher.installer.install")); portableInstallButton.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18)); portableInstallButton.setContentAreaFilled(false); portableInstallButton.setForeground(LauncherFrame.COLOR_GREY_TEXT); portableInstallButton.setHoverForeground(LauncherFrame.COLOR_BLUE); portableInstallButton.setBorder(BorderFactory.createEmptyBorder(8, 56, 8, 56)); portableInstallButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { portableInstall(); } }); portableInstallButton.setEnabled(false); if (!installDir.equals("")) { portableInstallButton.setForeground(LauncherFrame.COLOR_BUTTON_BLUE); portableInstallButton.setEnabled(true); } panel.add(portableInstallButton, new GridBagConstraints(1, 4, 2, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 8, 8), 0, 0)); }
From source file:org.apache.logging.log4j.core.util.datetime.FastDateParserTest.java
private Calendar getEraStart(int year, final TimeZone zone, final Locale locale) { final Calendar cal = Calendar.getInstance(zone, locale); cal.clear();// ww w. j a va 2 s. co m // http://docs.oracle.com/javase/6/docs/technotes/guides/intl/calendar.doc.html if (locale.equals(FastDateParser.JAPANESE_IMPERIAL)) { if (year < 1868) { cal.set(Calendar.ERA, 0); cal.set(Calendar.YEAR, 1868 - year); } } else { if (year < 0) { cal.set(Calendar.ERA, GregorianCalendar.BC); year = -year; } cal.set(Calendar.YEAR, year / 100 * 100); } return cal; }
From source file:com.haulmont.cuba.web.LoginWindow.java
protected Locale resolveLocale(App app) { if (globalConfig.getLocaleSelectVisible()) { String lastLocale = app.getCookieValue(COOKIE_LOCALE); if (lastLocale != null) { for (Locale locale : locales.values()) { if (locale.toLanguageTag().equals(lastLocale)) { return locale; }//from w ww.j av a2 s . c o m } } } for (Locale locale : locales.values()) { if (locale.equals(app.getLocale())) { return locale; } } // if not found and application locale contains country, try to match by language only if (!StringUtils.isEmpty(app.getLocale().getCountry())) { Locale appLocale = Locale.forLanguageTag(app.getLocale().getLanguage()); for (Locale locale : locales.values()) { if (Locale.forLanguageTag(locale.getLanguage()).equals(appLocale)) { return locale; } } } // return first locale set in the cuba.availableLocales app property return locales.values().iterator().next(); }
From source file:net.technicpack.launcher.ui.InstallerFrame.java
private void setupStandardInstall(JPanel panel) { panel.setLayout(new GridBagLayout()); JLabel standardSpiel = new JLabel("<html><body align=\"left\" style='margin-right:10px;'>" + resources.getString("launcher.installer.standardspiel") + "</body></html>"); standardSpiel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16)); standardSpiel.setForeground(LauncherFrame.COLOR_WHITE_TEXT); standardSpiel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.add(standardSpiel, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(9, 0, 0, 3), 0, 0)); panel.add(Box.createGlue(), new GridBagConstraints(0, 1, 3, 1, 1.0, 0.7, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); standardDefaultDirectory = new JCheckBox(resources.getString("launcher.installer.default")); standardDefaultDirectory.setOpaque(false); standardDefaultDirectory.setHorizontalAlignment(SwingConstants.RIGHT); standardDefaultDirectory.setBorder(BorderFactory.createEmptyBorder()); standardDefaultDirectory.setIconTextGap(0); standardDefaultDirectory.setSelectedIcon(resources.getIcon("checkbox_closed.png")); standardDefaultDirectory.setIcon(resources.getIcon("checkbox_open.png")); standardDefaultDirectory.setFocusPainted(false); standardDefaultDirectory.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16)); standardDefaultDirectory.setForeground(LauncherFrame.COLOR_WHITE_TEXT); standardDefaultDirectory.setIconTextGap(6); standardDefaultDirectory.setSelected(settings.isPortable() || settings.getTechnicRoot().getAbsolutePath() .equals(SettingsFactory.getTechnicHomeDir().getAbsolutePath())); standardDefaultDirectory.addActionListener(new ActionListener() { @Override/*from ww w. j a va 2 s . co m*/ public void actionPerformed(ActionEvent e) { useDefaultDirectoryChanged(); } }); panel.add(standardDefaultDirectory, new GridBagConstraints(0, 2, 3, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 24, 12, 0), 0, 0)); JLabel installFolderLabel = new JLabel(resources.getString("launcher.installer.folder")); installFolderLabel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18)); installFolderLabel.setForeground(LauncherFrame.COLOR_WHITE_TEXT); panel.add(installFolderLabel, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 24, 0, 8), 0, 0)); String installDir = SettingsFactory.getTechnicHomeDir().getAbsolutePath(); if (!settings.isPortable()) installDir = settings.getTechnicRoot().getAbsolutePath(); standardInstallDir = new JTextField(installDir); standardInstallDir.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18)); standardInstallDir.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL); standardInstallDir.setHighlighter(null); standardInstallDir.setEditable(false); standardInstallDir.setCursor(null); panel.add(standardInstallDir, new GridBagConstraints(1, 3, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0)); standardSelectButton = new RoundedButton(resources.getString("launcher.installer.select")); standardSelectButton.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18)); standardSelectButton.setContentAreaFilled(false); standardSelectButton.setHoverForeground(LauncherFrame.COLOR_BLUE); standardSelectButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectStandard(); } }); panel.add(standardSelectButton, new GridBagConstraints(2, 3, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 0, 16), 0, 0)); useDefaultDirectoryChanged(); panel.add(Box.createGlue(), new GridBagConstraints(0, 4, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); String defaultLocaleText = resources.getString("launcheroptions.language.default"); if (!resources.isDefaultLocaleSupported()) { defaultLocaleText = defaultLocaleText .concat(" (" + resources.getString("launcheroptions.language.unavailable") + ")"); } standardLanguages = new JComboBox(); standardLanguages.addItem(new LanguageItem(ResourceLoader.DEFAULT_LOCALE, defaultLocaleText, resources)); for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) { standardLanguages .addItem(new LanguageItem(resources.getCodeFromLocale(ResourceLoader.SUPPORTED_LOCALES[i]), ResourceLoader.SUPPORTED_LOCALES[i].getDisplayName(ResourceLoader.SUPPORTED_LOCALES[i]), resources.getVariant(ResourceLoader.SUPPORTED_LOCALES[i]))); } if (!settings.getLanguageCode().equalsIgnoreCase(ResourceLoader.DEFAULT_LOCALE)) { Locale loc = resources.getLocaleFromCode(settings.getLanguageCode()); for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) { if (loc.equals(ResourceLoader.SUPPORTED_LOCALES[i])) { standardLanguages.setSelectedIndex(i + 1); break; } } } standardLanguages.setBorder(new RoundBorder(LauncherFrame.COLOR_SCROLL_THUMB, 1, 10)); standardLanguages.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14)); standardLanguages.setUI(new LanguageCellUI(resources)); standardLanguages.setForeground(LauncherFrame.COLOR_WHITE_TEXT); standardLanguages.setBackground(LauncherFrame.COLOR_SELECTOR_BACK); standardLanguages.setRenderer(new LanguageCellRenderer(resources, "globe.png", LauncherFrame.COLOR_SELECTOR_BACK, LauncherFrame.COLOR_WHITE_TEXT)); standardLanguages.setEditable(false); standardLanguages.setFocusable(false); standardLanguages.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { standardLanguageChanged(); } }); panel.add(standardLanguages, new GridBagConstraints(0, 5, 1, 0, 0, 0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, 8, 8, 0), 0, 0)); RoundedButton install = new RoundedButton(resources.getString("launcher.installer.install")); install.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18)); install.setContentAreaFilled(false); install.setForeground(LauncherFrame.COLOR_BUTTON_BLUE); install.setHoverForeground(LauncherFrame.COLOR_BLUE); install.setBorder(BorderFactory.createEmptyBorder(8, 56, 8, 56)); install.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { standardInstall(); } }); panel.add(install, new GridBagConstraints(1, 5, 2, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 8, 8), 0, 0)); }
From source file:org.opencms.ui.sitemap.CmsLocaleComparePanel.java
/** * Initializes the locale comparison view.<p> * * @param id the structure id of the currrent sitemap root entry * @param initialComparisonLocale if not null, the initially selected ccomparison locale * * @throws CmsException if something goes wrong *///from w w w . j a v a2 s .c o m public void initialize(CmsUUID id, Locale initialComparisonLocale) throws CmsException { removeAllComponents(); CmsObject cms = A_CmsUI.getCmsObject(); CmsResource res = cms.readResource(id); m_currentRoot = res; CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(res.getRootPath()); Locale rootLocale = OpenCms.getLocaleManager().getDefaultLocale(cms, res); m_rootLocale = rootLocale; Locale mainLocale = site.getMainTranslationLocale(null); List<Locale> secondaryLocales = site.getSecondaryTranslationLocales(); List<Locale> possibleLocaleSelections = getMainLocaleSelectOptions(cms, res, mainLocale, secondaryLocales); m_rootLocaleSelector = new ComboBox(); m_rootLocaleSelector.addStyleName("o-sitemap-localeselect"); m_rootLocaleSelector.setNullSelectionAllowed(false); for (Locale selectableLocale : possibleLocaleSelections) { m_rootLocaleSelector.addItem(selectableLocale); m_rootLocaleSelector.setItemIcon(selectableLocale, FontOpenCms.SPACE); m_rootLocaleSelector.setItemCaption(selectableLocale, selectableLocale.getDisplayName(A_CmsUI.get().getLocale())); } m_rootLocaleSelector.setItemIcon(mainLocale, MAIN_LOCALE_ICON); m_rootLocaleSelector.setValue(m_rootLocale); m_rootLocaleSelector.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @SuppressWarnings("synthetic-access") public void valueChange(ValueChangeEvent event) { if (!m_handlingLocaleChange) { m_handlingLocaleChange = true; try { Locale newLocale = (Locale) (event.getProperty().getValue()); switchToLocale(newLocale); } catch (Exception e) { LOG.error(e.getLocalizedMessage(), e); CmsErrorDialog.showErrorDialog(e); } finally { m_handlingLocaleChange = false; } } } }); m_comparisonLocaleSelector = new ComboBox(); m_comparisonLocaleSelector.addStyleName("o-sitemap-localeselect"); m_comparisonLocaleSelector.setNullSelectionAllowed(false); List<Locale> comparisonLocales = getComparisonLocales(); Locale selectedComparisonLocale = null; for (Locale comparisonLocale : comparisonLocales) { m_comparisonLocaleSelector.addItem(comparisonLocale); m_comparisonLocaleSelector.setItemIcon(comparisonLocale, FontOpenCms.SPACE); m_comparisonLocaleSelector.setItemCaption(comparisonLocale, comparisonLocale.getDisplayName(A_CmsUI.get().getLocale())); if ((selectedComparisonLocale == null) && !comparisonLocale.equals(m_rootLocale)) { selectedComparisonLocale = comparisonLocale; } if ((initialComparisonLocale != null) && comparisonLocale.equals(initialComparisonLocale) && !comparisonLocale.equals(m_rootLocale)) { // if an initial comparison locale is given, it should have priority over the first comparison locale selectedComparisonLocale = comparisonLocale; } } m_comparisonLocale = selectedComparisonLocale; m_comparisonLocaleSelector.setValue(selectedComparisonLocale); m_comparisonLocaleSelector.setItemIcon(mainLocale, MAIN_LOCALE_ICON); m_comparisonLocaleSelector.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @SuppressWarnings("synthetic-access") public void valueChange(ValueChangeEvent event) { if (!m_handlingLocaleChange) { m_handlingLocaleChange = true; try { Locale locale = (Locale) (event.getProperty().getValue()); if (m_rootLocale.equals(locale)) { Locale oldComparisonLocale = m_comparisonLocale; if (getLocaleGroup().getResourcesByLocale().keySet().contains(oldComparisonLocale)) { m_comparisonLocale = locale; switchToLocale(oldComparisonLocale); updateLocaleWidgets(); } else { Notification.show(CmsVaadinUtils.getMessageText( Messages.GUI_LOCALECOMPARE_CANNOT_SWITCH_COMPARISON_LOCALE_0)); m_comparisonLocaleSelector.setValue(oldComparisonLocale); } } else { m_comparisonLocale = locale; updateLocaleWidgets(); initTree(m_currentRoot); } } catch (Exception e) { LOG.error(e.getLocalizedMessage(), e); CmsErrorDialog.showErrorDialog(e); } finally { m_handlingLocaleChange = false; } } } }); CssLayout localeSelectors = new CssLayout(); localeSelectors.addStyleName(OpenCmsTheme.SITEMAP_LOCALE_BAR); m_rootLocaleSelector.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_MAIN_LOCALE_0)); m_comparisonLocaleSelector .setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_COMPARISON_LOCALE_0)); localeSelectors.setWidth("100%"); localeSelectors.addComponent(m_rootLocaleSelector); localeSelectors.addComponent(m_comparisonLocaleSelector); // localeSelectors.setComponentAlignment(wrapper2, Alignment.MIDDLE_RIGHT); setSpacing(true); addComponent(localeSelectors); addComponent(m_treeContainer); m_treeContainer.setWidth("100%"); initTree(res); }
From source file:info.magnolia.cms.i18n.AbstractI18nContentSupport.java
/** * Extracts the language from the uri./*from ww w. j a va2 s . c o m*/ */ @Override public Locale determineLocale() { Locale locale; locale = onDetermineLocale(); // depending on the implementation the returned local can be null (not defined) if (locale == null) { locale = getDefaultLocale(); } // if we have a locale but it is not supported we try to get the closest locale if (!isLocaleSupported(locale)) { locale = getNextLocale(locale); } // instead of returning the content fallback language // we are going to return the default locale which might differ if (locale.equals(getFallbackLocale())) { locale = getDefaultLocale(); } return locale; }
From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java
/** * Generates a simple Time Axis.//from w w w .j a v a2 s . c om * * @return the generated Time Axis. */ private DateAxis generateTimeAxis() { DateAxis xAxis = new DateAxis(""); xAxis.setLowerMargin(0.05); xAxis.setUpperMargin(0.02); xAxis.setLabel(null); xAxis.setTickLabelsVisible(true); xAxis.setTickMarksVisible(true); xAxis.setAxisLineVisible(true); xAxis.setNegativeArrowVisible(false); xAxis.setPositiveArrowVisible(false); xAxis.setVisible(true); xAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); Locale locale = JiveGlobals.getLocale(); // If the tick units have not yet been setup or the locale has changed if (tickUnits == null || !locale.equals(oldLocale)) { tickUnits = createTickUnits(locale, JiveGlobals.getTimeZone()); oldLocale = locale; } xAxis.setStandardTickUnits(tickUnits); return xAxis; }
From source file:com.aurel.track.admin.user.profile.ProfileAction.java
/** * This saves the server configuration coming from the user interface to * the database. Some validation is performed when it cannot be directly * done at the user interface.// ww w . ja v a 2 s.c o m * * @return usually nothing, output is directly printed into response stream */ public String save() { LOGGER.debug("Processing ProfileAction save()"); if ((context == ProfileMainTO.CONTEXT.USERADMINADD || context == ProfileMainTO.CONTEXT.USERADMINEDIT) && (currentUser == null || !currentUser.isSys())) { JSONUtility.encodeJSONFailure(ServletActionContext.getResponse(), "No admin user", 1); return null; } boolean localeChange = false; Locale personLocale = locale; //If Preferred Language: browser => we need to set the locale to an empty string. //Track with Ext JS 4.x if the model contains empty string as id then submitted id will be empty string //Track with Ext JS 6.x if the model contains empty string as id then submitted id will be generated by framework. //For this reason here must be set the locale to an empty string instead of the dummy browser id. (Only for this item). if (mainTo.getLocale() != null && mainTo.getLocale().equals("browser")) { mainTo.setLocale(""); } if (context == ProfileMainTO.CONTEXT.PROFILEEDIT || context == ProfileMainTO.CONTEXT.SELFREGISTRATION) { Locale previousLocale = locale; //currentUser==null?null:currentUser.getLocale(); Locale actualLocale = null; if (mainTo.getLocale() != null && mainTo.getLocale().length() > 0) { actualLocale = LocaleHandler.getLocaleFromString(mainTo.getLocale()); } if (previousLocale == null) { localeChange = (actualLocale != null); } else { localeChange = !previousLocale.equals(actualLocale); } personLocale = actualLocale; } if (personLocale == null) { personLocale = Locale.getDefault(); } TPersonBean personBean = ProfileBL.getPersonByContext(currentUser, personId, context); List<LabelValueBean> errors = ProfileBL.validate(personBean, currentUser, personId, context, iconKey, iconName, mainTo, emailTo, otherTo, watchlistTo, personLocale); if (errors.isEmpty()) { if (context == ProfileMainTO.CONTEXT.USERADMINADD || context == ProfileMainTO.CONTEXT.SELFREGISTRATION) { String usersExceededMessage = PersonConfigBL.usersExceeded(null, locale, personBean.getUserLevel(), false); if (usersExceededMessage != null) { personBean.setDisabled(true); } } if (context == ProfileMainTO.CONTEXT.SELFREGISTRATION) { personBean.setDisabled(true); Date texpDate = new Date(new Date().getTime() + 4 * 3600 * 1000); // 4 hours personBean.setTokenExpDate(texpDate); String tokenPasswd = DigestUtils.md5Hex(Long.toString(texpDate.getTime())); personBean.setTokenPasswd(tokenPasswd); } if (context == ProfileMainTO.CONTEXT.USERADMINADD) { //create user by admin LOGGER.debug("Create user by admin, userNam= " + personBean.getUsername()); Date texpDate = new Date(new Date().getTime() + 4 * 3600 * 1000); // 4 hours personBean.setTokenExpDate(texpDate); String tokenPasswd = DigestUtils.md5Hex(Long.toString(texpDate.getTime())); personBean.setForgotPasswordKey(tokenPasswd); } Integer personID = ProfileBL.saveUserProfile(personBean, currentUser, context, isUser); String dpassword = mainTo.getPasswd(); if (context == ProfileMainTO.CONTEXT.SELFREGISTRATION) { TPersonBean newPerson = PersonBL.loadByPrimaryKey(personID); dpassword = newPerson.getTokenPasswd(); } boolean emailSend = ProfileBL.support(personBean, personBean, context, dpassword, session, personLocale, localeChange); String email = personBean.getEmail(); if (context == ProfileMainTO.CONTEXT.SELFREGISTRATION || context == ProfileMainTO.CONTEXT.USERADMINADD) { if (MobileBL.isMobileApp(session)) { ProjectConfigBL.createWorkspaceForNewUser(personBean, personLocale); } } JSONUtility.encodeJSON(servletResponse, ProfileJSON.encodeSaveProfileJSON(localeChange, emailSend, email)); } else { LOGGER.debug("Validation errors when saving the user profile"); StringBuilder sb = new StringBuilder(); sb.append("{"); JSONUtility.appendBooleanValue(sb, JSONUtility.JSON_FIELDS.SUCCESS, false); JSONUtility.appendStringValue(sb, "errorMessage", getText("admin.user.profile.err.errorSave")); JSONUtility.appendErrorsExtJS(sb, errors, true); sb.append("}"); JSONUtility.encodeJSON(ServletActionContext.getResponse(), sb.toString()); } return null; }
From source file:org.opencms.ui.editors.messagebundle.CmsMessageBundleEditor.java
/** * @see org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorTypes.I_OptionListener#handleLanguageChange(java.util.Locale) *///from ww w . j a v a2s. c o m public void handleLanguageChange(final Locale locale) { if (!locale.equals(m_model.getLocale())) { Object sortProperty = m_table.getSortContainerPropertyId(); boolean isAcending = m_table.isSortAscending(); Map<Object, Object> filters = getFilters(); m_table.clearFilters(); if (m_model.setLocale(locale)) { m_options.setEditedFilePath(m_model.getEditedFilePath()); m_table.sort(new Object[] { sortProperty }, new boolean[] { isAcending }); } else { String caption = m_messages .key(Messages.GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_LOCALE_SWITCHING_FAILED_CAPTION_0); String description = m_messages .key(Messages.GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_LOCALE_SWITCHING_FAILED_DESCRIPTION_0); Notification warning = new Notification(caption, description, Type.WARNING_MESSAGE, true); warning.setDelayMsec(-1); warning.show(UI.getCurrent().getPage()); m_options.setLanguage(m_model.getLocale()); } setFilters(filters); m_table.select(m_table.getCurrentPageFirstItemId()); } }
From source file:com.octo.captcha.engine.bufferedengine.manager.QuartzBufferedEngineManager.java
/** * @see com.octo.captcha.engine.bufferedengine.manager.BufferedEngineContainerManager#setLocaleRatio */// w w w .java2s .c o m public synchronized void setLocaleRatio(String localeName, double ratio) { Locale locale = getLocaleFromName(localeName); MapIterator it = config.getLocaleRatio().mapIterator(); boolean isSet = false; double coef = ratio; double oldValue = 0.0f; if (config.getLocaleRatio().containsKey(locale)) { oldValue = ((Double) config.getLocaleRatio().get(locale)).doubleValue(); coef = ratio - oldValue; } while (it.hasNext()) { Locale tempLocale = (Locale) it.next(); double value = ((Double) it.getValue()).doubleValue(); if (locale.equals(tempLocale)) { it.setValue(new Double(coef + value)); isSet = true; } else { if (coef < 0) { it.setValue(new Double(value - (coef * value / (1.0 - oldValue)))); } else { it.setValue(new Double(value - (value * coef))); } } } //if Locale is not register yet if (!isSet) { config.getLocaleRatio().put(locale, new Double(ratio)); } }