@Test public void testGetMarkupLocales() throws Exception { undeploy(DEFAULT_MARKUP_PORTLET_WAR); String getLocalesPortletArchive = "test-getlocales-portlet.war"; deploy(getLocalesPortletArchive); V1GetMarkup getMarkup = createMarkupRequest(getPortletHandleFrom("Simple")); try { List<String> locales = getMarkup.getMarkupParams().getLocales(); locales.add("en"); locales.add("fr"); V1MarkupResponse response = producer.getMarkup(getMarkup); checkMarkupResponse(response, Locale.ENGLISH.getDisplayName()); locales.clear(); locales.add("fr"); locales.add("en"); response = producer.getMarkup(getMarkup); checkMarkupResponse(response, Locale.FRENCH.getDisplayName()); locales.clear(); locales.add("de"); locales.add("en"); response = producer.getMarkup(getMarkup); checkMarkupResponse(response, Locale.ENGLISH.getDisplayName()); } finally { undeploy(getLocalesPortletArchive); } }
@Test public void test_localized_string_to_json() throws Exception { LocalizedString string = new LocalizedString().forLanguageTag(null, "coucou").forEn("kewkew"); String json = objectMapper.writeValueAsString(string); log.debug(string.toString()); log.debug(json); assertThat(string.keySet().contains(Locale.ENGLISH.toLanguageTag())).isTrue(); assertThat(string.keySet().contains(Locale.forLanguageTag("und").toLanguageTag())).isTrue(); LocalizedString string2 = objectMapper.readValue(json, LocalizedString.class); log.debug(string2.toString()); assertThat(string2.keySet().contains(Locale.ENGLISH.toLanguageTag())).isTrue(); assertThat(string2.keySet().contains(Locale.forLanguageTag("und").toLanguageTag())).isTrue(); }
/** Returns true if the locale supports using first name and last name as bigrams. */ public static boolean useFirstLastBigramsForLocale(final Locale locale) { // TODO: Add firstname/lastname bigram rules for other languages. if (locale != null && locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) { return true; } return false; }
/** * @param locale locale * @return the windows LCID (Language Code Id) */ public static int getLcid(Locale locale) { String lang = locale.getLanguage(); if (Locale.GERMAN.getLanguage().equals(lang)) { return 0x0407; } if (Locale.ENGLISH.getLanguage().equals(lang)) { return 0x0409; } if (Locale.ITALIAN.getLanguage().equals(lang)) { return 0x0410; } if (Locale.FRENCH.getLanguage().equals(lang)) { return 0x040c; } if (Locale.JAPANESE.getLanguage().equals(lang)) { return 0x0411; } if (Locale.KOREAN.getLanguage().equals(lang)) { return 0x0412; } if (Locale.CHINESE.getLanguage().equals(lang)) { return 0x0804; } /** Spanish */ if ("es".equals(lang)) { // $NON-NLS-1$ return 0x040a; } return 0; }
/** @return the supported user language (fr or en) */ public static String getSupportedUserLocale() { if (getUserLanguage().equals(Locale.FRENCH.toString())) { return Locale.FRENCH.toString(); } else { return Locale.ENGLISH.toString(); // default } }
private void initSupportedLocales() { supportedLocales = new UserLocale[12]; defaultAppLocale = new UserLocale(Locale.ENGLISH.getLanguage(), null, "English"); supportedLocales[0] = defaultAppLocale; supportedLocales[1] = new UserLocale(Locale.FRENCH.getLanguage(), null, "Fran\347ais"); supportedLocales[2] = new UserLocale("es", null, "Espa\361ol"); supportedLocales[3] = new UserLocale("pt", null, "Portugu\352s"); supportedLocales[4] = new UserLocale(Locale.UK.getLanguage(), Locale.UK.getCountry(), "English-GB"); supportedLocales[5] = new UserLocale("sv", null, "Svenskt"); supportedLocales[6] = new UserLocale("nb", null, "Norske"); supportedLocales[7] = new UserLocale("da", null, "Dansk"); supportedLocales[8] = new UserLocale("fi", null, "Suomi"); supportedLocales[9] = new UserLocale("nl", null, "Nederlands"); supportedLocales[10] = new UserLocale(Locale.FRENCH.getLanguage(), Locale.CANADA.getCountry(), "Fran\347ais-CA"); supportedLocales[11] = new UserLocale(Locale.GERMAN.getLanguage(), null, "Deutsch"); UserLocale auserlocale[] = supportedLocales; int j = auserlocale.length; for (int i = 0; i < j; i++) { UserLocale userlocale = auserlocale[i]; Log.d("nf_loc", (new StringBuilder()).append("").append(userlocale).toString()); } }
@Override public Properties getMessages(String baseBundlename, Locale locale) throws IOException { if (messages.get(baseBundlename) == null || messages.get(baseBundlename).get(locale) == null) { Properties messages = new Properties(); if (!Locale.ENGLISH.equals(locale)) { messages.putAll(getMessages(baseBundlename, Locale.ENGLISH)); } ListIterator<Theme> itr = themes.listIterator(themes.size()); while (itr.hasPrevious()) { Properties m = itr.previous().getMessages(baseBundlename, locale); if (m != null) { messages.putAll(m); } } this.messages.putIfAbsent(baseBundlename, new ConcurrentHashMap<Locale, Properties>()); this.messages.get(baseBundlename).putIfAbsent(locale, messages); return messages; } else { return messages.get(baseBundlename).get(locale); } }
/** * CFML Supported LS Formats * * @param locale * @param tz * @param lenient * @return */ public static DateFormat[] getCFMLFormats(TimeZone tz, boolean lenient) { String id = "cfml-" + Locale.ENGLISH.hashCode() + "-" + tz.getID() + "-" + lenient; DateFormat[] df = (DateFormat[]) formats.get(id); if (df == null) { df = new SimpleDateFormat[] { new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH), new SimpleDateFormat("MMM dd, yyyy H:mm:ss a", Locale.ENGLISH), new SimpleDateFormat("MMMM dd, yyyy HH:mm:ss a zzz", Locale.ENGLISH), new SimpleDateFormat("MMMM d yyyy HH:mm:ss", Locale.ENGLISH), new SimpleDateFormat("MMMM d yyyy HH:mm", Locale.ENGLISH), new SimpleDateFormat("EEE, MMM dd, yyyy HH:mm:ss", Locale.ENGLISH), new SimpleDateFormat("EEEE, MMMM dd, yyyy h:mm:ss a zzz", Locale.ENGLISH), new SimpleDateFormat("dd-MMM-yy HH:mm a", Locale.ENGLISH), new SimpleDateFormat("dd-MMMM-yy HH:mm a", Locale.ENGLISH), new SimpleDateFormat("EE, dd MMM yyyy HH:mm:ss zz", Locale.ENGLISH), new SimpleDateFormat("EEE d, MMM yyyy HH:mm:ss zz", Locale.ENGLISH), new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH), new SimpleDateFormat("MMMM, dd yyyy hh:mm:ss", Locale.ENGLISH), new SimpleDateFormat("yyyy/MM/dd hh:mm:ss zz", Locale.ENGLISH) // ,new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss",Locale.ENGLISH) }; for (int i = 0; i < df.length; i++) { df[i].setLenient(lenient); df[i].setTimeZone(tz); } formats.put(id, df); } return df; }
@Override public AmountStyle getAmountStyle(Locale locale) { if (Locale.ENGLISH.equals(locale)) { return new AmountStyle.Builder(locale).setPattern("test").create(); } return null; }
public static String getHelpFile(final String sTopic) { String sPath = SextanteGUI.getHelpPath() + File.separator + Locale.getDefault().getLanguage(); final File dir = new File(sPath); if (!dir.exists()) { sPath = SextanteGUI.getHelpPath() + File.separator + Locale.ENGLISH.getLanguage(); } return sPath + File.separator + "general" + File.separator + sTopic + ".html"; }
/** * Get the Locale according the user request and to the supported languages in the Configuration. * If no valid local could be found, return English * * @return */ public static Locale getRequestedLocale() { Locale requestedLocale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale(); if (isSupported(requestedLocale.getLanguage())) { return requestedLocale; } else if (isSupported(Locale.ENGLISH.getLanguage())) { return Locale.ENGLISH; } else if (SUPPORTED_LANGUAGES.length > 0) { return new Locale(SUPPORTED_LANGUAGES[0]); } return Locale.ENGLISH; }
@Override protected void setUp() throws Exception { super.setUp(); final String language = Locale.ENGLISH.getLanguage(); mCodesSet.setLanguage(language); mTextsSet.setLanguage(language); mTextsSet.loadStringResources(getContext()); mCodeSettings = KeySpecParser.parseCode(CODE_SETTINGS, mCodesSet, CODE_UNSPECIFIED); mCodeActionNext = KeySpecParser.parseCode("!code/key_action_next", mCodesSet, CODE_UNSPECIFIED); mSettingsIconId = KeySpecParser.getIconId(ICON_SETTINGS); }
@Test public void testByServiceInfoServiceTracker() throws Exception { ServiceAgent serviceAgent = SLP.newServiceAgent(newSettings()); UserAgent userAgent = SLP.newUserAgent(newSettings()); final AtomicInteger counter = new AtomicInteger(); userAgent.addServiceNotificationListener( new ServiceNotificationListener() { public void serviceRegistered(ServiceNotificationEvent event) { counter.incrementAndGet(); } public void serviceDeregistered(ServiceNotificationEvent event) { counter.decrementAndGet(); } }); serviceAgent.start(); userAgent.start(); ByServiceInfoServiceTracker tracker = new ByServiceInfoServiceTracker(bundleContext, serviceAgent); tracker.open(); ServiceRegistration serviceRegistration = bundleContext.registerService( ServiceInfo.class.getName(), new ServiceInfo( new ServiceURL("service:printer:lpr://myprinter/myqueue"), Locale.ENGLISH.getLanguage(), Scopes.DEFAULT, Attributes.from("(printer-compression-supported=deflate, gzip)")), null); Thread.sleep(500); Assert.assertEquals(1, tracker.size()); Assert.assertEquals(1, counter.get()); serviceRegistration.unregister(); Thread.sleep(500); Assert.assertEquals(0, tracker.size()); Assert.assertEquals(0, counter.get()); tracker.close(); userAgent.stop(); serviceAgent.stop(); }
private void setPageLanguage(HttpServletRequest request) { Boolean inEnglish; String inEnglishParameter = request.getParameter("inEnglish"); if (inEnglishParameter == null) { inEnglish = (Boolean) request.getAttribute("inEnglish"); } else { inEnglish = new Boolean(inEnglishParameter); } if (inEnglish == null) { inEnglish = getLocale(request).getLanguage().equals(Locale.ENGLISH.getLanguage()); } request.setAttribute("inEnglish", inEnglish); }
/** * Builds the default path for Windows (i.e Program Files/...). * @return The Windows default installation path. */ private String buildWindowsDefaultPath() { StringBuffer dpath = new StringBuffer(""); try { // We load the properties Properties props = new Properties(); props.load(InstallerBase.class.getResourceAsStream( "/com/izforge/izpack/installer/win32-defaultpaths.properties")); // We look for the drive mapping String drive = System.getProperty("user.home"); if (drive.length() > 3) drive = drive.substring(0, 3); // Now we have it :-) dpath.append(drive); // Ensure that we have a trailing backslash (in case drive was something like "C:") if (drive.length() == 2) dpath.append("\\"); String language = Locale.getDefault().getLanguage(); String country = Locale.getDefault().getCountry(); String language_country = language + "_" + country; // Try the most specific combination first if (null != props.getProperty(language_country)) { dpath.append(props.getProperty(language_country)); } else if (null != props.getProperty(language)) { dpath.append(props.getProperty(language)); } else { dpath.append(props.getProperty(Locale.ENGLISH.getLanguage())); } dpath.append("\\"); } catch (Exception err) { dpath = new StringBuffer("C:\\Program Files\\"); } return dpath.toString(); }
/** * @return The message if it's found in message bundles, a generic message otherwise. * @since 7.1 */ public String getMessage(Locale locale) { // test whether there's a specific translation for for this field and this constraint // the expected key is // label.schema.constraint.violation.[constraintName].[schemaName].[field].[subField] List<String> pathTokens = new ArrayList<String>(); pathTokens.add(Constraint.MESSAGES_KEY); pathTokens.add(constraint.getDescription().getName()); pathTokens.add(schema.getName()); for (PathNode node : path) { String name = node.getField().getName().getLocalName(); pathTokens.add(name); } String key = StringUtils.join(pathTokens, '.'); String computedInvalidValue = "null"; if (invalidValue != null) { String invalidValueString = invalidValue.toString(); if (invalidValueString.length() > 20) { computedInvalidValue = invalidValueString.substring(0, 15) + "..."; } else { computedInvalidValue = invalidValueString; } } Object[] params = new Object[] {computedInvalidValue}; Locale computedLocale = locale != null ? locale : Constraint.MESSAGES_DEFAULT_LANG; String message = null; try { message = I18NUtils.getMessageString(Constraint.MESSAGES_BUNDLE, key, params, computedLocale); } catch (MissingResourceException e) { log.trace("No bundle found", e); message = null; } if (message != null && !message.trim().isEmpty() && !key.equals(message)) { // use the message if there's one return message; } else { if (locale != null && Locale.ENGLISH.getLanguage().equals(locale.getLanguage())) { // use the constraint message return constraint.getErrorMessage(invalidValue, locale); } else { return getMessage(Locale.ENGLISH); } } }
/** * Returns the serialized data for the core provider wrapped into a script tag. * * <p> * * @param iconCssClassPrefix the prefix for icon css class rules * @return the data * @throws Exception if something goes wrong */ public String export(String iconCssClassPrefix) throws Exception { // determine the workplace locale String wpLocale = OpenCms.getWorkplaceManager().getWorkplaceLocale(getCmsObject()).getLanguage(); if (CmsStringUtil.isEmptyOrWhitespaceOnly(wpLocale)) { // if no locale was found, take English as locale wpLocale = Locale.ENGLISH.getLanguage(); } StringBuffer sb = new StringBuffer(); String prefetchedData = serialize(I_CmsCoreService.class.getMethod("prefetch"), getCoreData()); sb.append(CmsCoreData.DICT_NAME).append("='").append(prefetchedData).append("';"); sb.append(ClientMessages.get().export(getRequest())); wrapScript(sb); sb.append("<style type=\"text/css\">\n @import url(\"") .append(iconCssLink(iconCssClassPrefix)) .append("\");\n</style>\n"); sb.append("<meta name=\"gwt:property\" content=\"locale=").append(wpLocale).append("\">\n"); return sb.toString(); }
/** * Returns the path where help files for a given algorithm are found * * @param alg the GeoAlgorithm * @param bForceCurrentLocale if true, returns the path to the current locale, even if it does not * exist. If false, it will return the path corresponding to the default locale (english) in * case the one corresponding to the current locale does not exist. * @return the help path for this algorithm */ public static String getHelpPath(final GeoAlgorithm alg, final boolean bForceLocale) { String sPackage = alg.getClass().getPackage().toString(); sPackage = sPackage.substring(8); String sPath = SextanteGUI.getHelpPath() + File.separator + Locale.getDefault().getLanguage() + File.separator + sPackage; final File dir = new File(sPath); if (!dir.exists() && !bForceLocale) { sPath = SextanteGUI.getHelpPath() + File.separator + Locale.ENGLISH.getLanguage() + File.separator + sPackage; } return sPath; }
public String getLang() { return lang == null ? Locale.ENGLISH.toString() : lang; }
@Test public void testServiceNotificationListenerWithFilterServiceTracker() throws Exception { UserAgent userAgent = SLP.newUserAgent(newSettings()); ServiceAgent serviceAgent = SLP.newServiceAgent(newSettings()); final AtomicInteger counter = new AtomicInteger(); userAgent.start(); serviceAgent.start(); ServiceNotificationListenerServiceTracker tracker = new ServiceNotificationListenerServiceTracker( bundleContext, bundleContext.createFilter("(&(foo=bar)(car=cdr))"), userAgent); tracker.open(); Dictionary<String, String> dictionary = new Hashtable<String, String>(); dictionary.put("foo", "bar"); dictionary.put("car", "cdr"); ServiceRegistration serviceRegistration = bundleContext.registerService( ServiceNotificationListener.class.getName(), new ServiceNotificationListener() { public void serviceRegistered(ServiceNotificationEvent event) { if ("service:jmx:rmi:///jndi/jmxrmi" .equals(event.getService().getServiceURL().getURL())) { counter.incrementAndGet(); } } public void serviceDeregistered(ServiceNotificationEvent event) { if ("service:jmx:rmi:///jndi/jmxrmi" .equals(event.getService().getServiceURL().getURL())) { counter.decrementAndGet(); } } }, dictionary); ServiceURL serviceURL = new ServiceURL("service:jmx:rmi:///jndi/jmxrmi"); ServiceInfo service = new ServiceInfo( serviceURL, Locale.ENGLISH.getLanguage(), Scopes.DEFAULT, Attributes.from("(a=1,2),(b=true),(c=string),(d=\\FF\\00),e")); serviceAgent.register(service); Thread.sleep(1000); Assert.assertEquals(1, tracker.size()); Assert.assertEquals(1, counter.get()); serviceAgent.deregister(service.getServiceURL(), service.getLanguage()); Thread.sleep(1000); Assert.assertEquals(1, tracker.size()); Assert.assertEquals(0, counter.get()); serviceRegistration.unregister(); Thread.sleep(500); Assert.assertEquals(0, tracker.size()); Assert.assertEquals(0, counter.get()); dictionary.put("foo", "bad-value"); serviceRegistration = bundleContext.registerService( ServiceNotificationListener.class.getName(), new ServiceNotificationListener() { public void serviceRegistered(ServiceNotificationEvent event) { if ("service:jmx:rmi:///jndi/jmxrmi" .equals(event.getService().getServiceURL().getURL())) { counter.incrementAndGet(); } } public void serviceDeregistered(ServiceNotificationEvent event) { if ("service:jmx:rmi:///jndi/jmxrmi" .equals(event.getService().getServiceURL().getURL())) { counter.decrementAndGet(); } } }, dictionary); serviceAgent.register(service); Thread.sleep(1000); Assert.assertEquals(0, tracker.size()); Assert.assertEquals(0, counter.get()); serviceAgent.deregister(service.getServiceURL(), service.getLanguage()); Thread.sleep(1000); Assert.assertEquals(0, tracker.size()); Assert.assertEquals(0, counter.get()); serviceRegistration.unregister(); Thread.sleep(500); Assert.assertEquals(0, tracker.size()); Assert.assertEquals(0, counter.get()); tracker.close(); serviceAgent.stop(); userAgent.stop(); }
public static String capitalize(String input) { return input.toUpperCase(new Locale(Locale.ENGLISH.getLanguage(), Locale.US.getCountry())); }
public void test_getDisplayName_easy() throws Exception { assertEquals("English", Locale.ENGLISH.getDisplayLanguage(Locale.ENGLISH)); assertEquals("German", Locale.GERMAN.getDisplayLanguage(Locale.ENGLISH)); assertEquals("Englisch", Locale.ENGLISH.getDisplayLanguage(Locale.GERMAN)); assertEquals("Deutsch", Locale.GERMAN.getDisplayLanguage(Locale.GERMAN)); }
public void testGetFormatDate() { Locale locale = new Locale(Locale.ENGLISH.getLanguage(), Locale.UK.getCountry()); Calendar calendar = Calendar.getInstance(); // set date time: 28/08/2011 at 15h 30m calendar.set(2011, 07, 28, 15, 30); assertEquals("", TimeConvertUtils.getFormatDate(null, "M-d-yyyy", locale)); assertEquals("", TimeConvertUtils.getFormatDate(calendar.getTime(), "", locale)); assertEquals( "8-28-2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "M-d-yyyy", locale)); assertEquals("8-28-11", TimeConvertUtils.getFormatDate(calendar.getTime(), "M-d-yy", locale)); assertEquals( "08-28-11", TimeConvertUtils.getFormatDate(calendar.getTime(), "MM-dd-yy", locale)); assertEquals( "08-28-2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "MM-dd-yyyy", locale)); assertEquals( "2011-08-28", TimeConvertUtils.getFormatDate(calendar.getTime(), "yyyy-MM-dd", locale)); assertEquals( "11-08-28", TimeConvertUtils.getFormatDate(calendar.getTime(), "yy-MM-dd", locale)); assertEquals( "28-08-2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "dd-MM-yyyy", locale)); assertEquals( "28-08-11", TimeConvertUtils.getFormatDate(calendar.getTime(), "dd-MM-yy", locale)); assertEquals( "8/28/2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "M/d/yyyy", locale)); assertEquals("8/28/11", TimeConvertUtils.getFormatDate(calendar.getTime(), "M/d/yy", locale)); assertEquals( "08/28/11", TimeConvertUtils.getFormatDate(calendar.getTime(), "MM/dd/yy", locale)); assertEquals( "08/28/2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "MM/dd/yyyy", locale)); assertEquals( "2011/08/28", TimeConvertUtils.getFormatDate(calendar.getTime(), "yyyy/MM/dd", locale)); assertEquals( "11/08/28", TimeConvertUtils.getFormatDate(calendar.getTime(), "yy/MM/dd", locale)); assertEquals( "28/08/2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "dd/MM/yyyy", locale)); assertEquals( "28/08/11", TimeConvertUtils.getFormatDate(calendar.getTime(), "dd/MM/yy", locale)); assertEquals( "Sun, August 28, 2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "EEE, MMMM dd, yyyy", locale)); assertEquals( "Sunday, August 28, 2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "EEEE, MMMM dd, yyyy", locale)); assertEquals( "Sunday, 28 August, 2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "EEEE, dd MMMM, yyyy", locale)); assertEquals( "Sun, Aug 28, 2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "EEE, MMM dd, yyyy", locale)); assertEquals( "Sunday, Aug 28, 2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "EEEE, MMM dd, yyyy", locale)); assertEquals( "Sunday, 28 Aug, 2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "EEEE, dd MMM, yyyy", locale)); assertEquals( "August 28, 2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "MMMM dd, yyyy", locale)); assertEquals( "28 August, 2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "dd MMMM, yyyy", locale)); assertEquals( "Aug 28, 2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "MMM dd, yyyy", locale)); assertEquals( "28 Aug, 2011", TimeConvertUtils.getFormatDate(calendar.getTime(), "dd MMM, yyyy", locale)); assertEquals( "28 Aug, 2011, 03:30 PM", TimeConvertUtils.getFormatDate(calendar.getTime(), "dd MMM, yyyy, hh:mm a", locale)); assertEquals( "28 Aug, 2011, 15:30", TimeConvertUtils.getFormatDate(calendar.getTime(), "dd MMM, yyyy, HH:mm", locale)); }
/** * Create contents of the dialog. * * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout gridLayout = (GridLayout) container.getLayout(); gridLayout.numColumns = 2; gridLayout.verticalSpacing = 5; gridLayout.horizontalSpacing = 5; gridLayout.marginHeight = 5; gridLayout.marginWidth = 5; Composite compositeLeftBtn = new Composite(container, SWT.NONE); compositeLeftBtn.setLayout(new GridLayout(1, false)); Button button = new Button(compositeLeftBtn, SWT.NONE); button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); button.setImage( ResourceManager.getPluginImage( BrowserActivator.ID, "resources/TadpoleOverView.png")); // $NON-NLS-1$ compositeLogin = new Composite(container, SWT.NONE); compositeLogin.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); compositeLogin.setLayout(new GridLayout(3, false)); lblEmail = new Label(compositeLogin, SWT.NONE); lblEmail.setText(Messages.get().LoginDialog_1); textEMail = new Text(compositeLogin, SWT.BORDER); textEMail.addKeyListener( new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.Selection) { if (!"".equals(textPasswd.getText())) okPressed(); // $NON-NLS-1$ else textPasswd.setFocus(); } } }); textEMail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); btnCheckButton = new Button(compositeLogin, SWT.CHECK); btnCheckButton.setText(Messages.get().LoginDialog_9); // $NON-NLS-1$ lblPassword = new Label(compositeLogin, SWT.NONE); lblPassword.setText(Messages.get().LoginDialog_4); textPasswd = new Text(compositeLogin, SWT.BORDER | SWT.PASSWORD); textPasswd.addKeyListener( new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.Selection) { okPressed(); } } }); textPasswd.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Button btnLogin = new Button(compositeLogin, SWT.NONE); btnLogin.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { okPressed(); } }); btnLogin.setText(Messages.get().LoginDialog_15); lblLanguage = new Label(compositeLogin, SWT.NONE); lblLanguage.setText(Messages.get().LoginDialog_lblLanguage_text); comboLanguage = new Combo(compositeLogin, SWT.READ_ONLY); comboLanguage.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { changeUILocale(); } }); comboLanguage.add(Locale.ENGLISH.getDisplayLanguage()); comboLanguage.add(Locale.KOREAN.getDisplayLanguage()); comboLanguage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); comboLanguage.setData(Locale.ENGLISH.getDisplayLanguage(), Locale.ENGLISH); comboLanguage.setData(Locale.KOREAN.getDisplayLanguage(), Locale.KOREAN); // comboLanguage.select(0); // --------------------- Registered database // ---------------------------------------------------- // try { // listDBMart = getDBMart(); // if(!listDBMart.isEmpty()) { // Group grpSponser = new Group(container, SWT.NONE); // GridLayout gl_grpSponser = new GridLayout(1, false); // gl_grpSponser.verticalSpacing = 0; // gl_grpSponser.horizontalSpacing = 0; // gl_grpSponser.marginHeight = 0; // gl_grpSponser.marginWidth = 0; // grpSponser.setLayout(gl_grpSponser); // grpSponser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); // grpSponser.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE)); // grpSponser.setText(Messages.get().LoginDialog_grpSponser_text); // // makeBarChart(grpSponser, listDBMart); // } // } catch(Exception e) { // logger.error("get initdata", e); //$NON-NLS-1$ // } compositeLetter = new Group(container, SWT.NONE); compositeLetter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); GridLayout gl_compositeLetter = new GridLayout(2, false); compositeLetter.setLayout(gl_compositeLetter); compositeLetter.setText(Messages.get().LoginDialog_grpShowInformation_text); lblSite = new Label(compositeLetter, SWT.NONE); lblSite.setText(Messages.get().LoginDialog_lblSite_text); Label lblNewLabel = new Label(compositeLetter, SWT.NONE); lblNewLabel.setText( "<a href='" + Messages.get().LoginDialog_lblNewLabel_text_1 + "' target='_blank'>" + Messages.get().LoginDialog_lblNewLabel_text_1 + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ lblNewLabel.setData(RWT.MARKUP_ENABLED, Boolean.TRUE); lblUserGuide = new Label(compositeLetter, SWT.NONE); lblUserGuide.setText(Messages.get().LoginDialog_lblUserGuide_text); Composite compositeUserGide = new Composite(compositeLetter, SWT.NONE); compositeUserGide.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); GridLayout gl_compositeUserGide = new GridLayout(3, false); gl_compositeUserGide.verticalSpacing = 1; gl_compositeUserGide.horizontalSpacing = 1; gl_compositeUserGide.marginHeight = 1; gl_compositeUserGide.marginWidth = 1; compositeUserGide.setLayout(gl_compositeUserGide); Label lblUserKor = new Label(compositeUserGide, SWT.NONE); lblUserKor.setText( "<a href='https://tadpoledbhub.atlassian.net/wiki/pages/viewpage.action?pageId=20578325' target='_blank'>(Korean)</a>"); //$NON-NLS-1$ //$NON-NLS-2$ lblUserKor.setData(RWT.MARKUP_ENABLED, Boolean.TRUE); Label lblUserEng = new Label(compositeUserGide, SWT.NONE); lblUserEng.setText( "<a href='https://github.com/hangum/TadpoleForDBTools/wiki/RDB-User-Guide-Eng' target='_blank'>(English)</a>"); //$NON-NLS-1$ //$NON-NLS-2$ lblUserEng.setData(RWT.MARKUP_ENABLED, Boolean.TRUE); Label lblUserIndonesia = new Label(compositeUserGide, SWT.NONE); lblUserIndonesia.setText( "<a href='https://github.com/hangum/TadpoleForDBTools/wiki/RDB-User-Guide-ID' target='_blank'>(Indonesia)</a>"); //$NON-NLS-1$ //$NON-NLS-2$ lblUserIndonesia.setData(RWT.MARKUP_ENABLED, Boolean.TRUE); // Label lblIssues = new Label(compositeLetter, SWT.NONE); // lblIssues.setText(Messages.get().LoginDialog_lblIssues_text); // // Label lblIssue = new Label(compositeLetter, SWT.NONE); // lblIssue.setText("<a href='https://github.com/hangum/TadpoleForDBTools/issues' // target='_blank'>https://github.com/hangum/TadpoleForDBTools/issues</a>"); //$NON-NLS-1$ // //$NON-NLS-2$ // lblIssue.setData(RWT.MARKUP_ENABLED, Boolean.TRUE); lblContact = new Label(compositeLetter, SWT.NONE); lblContact.setText(Messages.get().LoginDialog_lblContact_text_1); Label lblContactUrl = new Label(compositeLetter, SWT.NONE); try { UserDAO systemUserDao = TadpoleApplicationContextManager.getSystemAdmin(); lblContactUrl.setText( String.format( "<a href='mailto:%s'>%s(%s)</a>", systemUserDao.getEmail(), systemUserDao.getName(), systemUserDao.getEmail())); // $NON-NLS-1$ //$NON-NLS-2$ } catch (Exception e1) { lblContactUrl.setText( "<a href='mailto:[email protected]'>Admin([email protected])</a>"); //$NON-NLS-1$ // //$NON-NLS-2$ } lblContactUrl.setData(RWT.MARKUP_ENABLED, Boolean.TRUE); Label lblDonation = new Label(compositeLetter, SWT.NONE); // lblDonation.setText(Messages.get().LoginDialog_lblDonation_text); Browser browser = new Browser(compositeLetter, SWT.NONE); browser.setLayoutData(new GridData(SWT.FILL, SWT.RIGHT, false, false, 1, 1)); browser.setText(strPaypal); AnalyticCaller.track("login"); // $NON-NLS-1$ initUI(); return compositeLogin; }
@Override public final RuleMatch[] match(final AnalyzedSentence text) { final List<RuleMatch> ruleMatches = new ArrayList<RuleMatch>(); final AnalyzedTokenReadings[] tokens = text.getTokensWithoutWhitespace(); if (tokens.length < 2) { return toRuleMatchArray(ruleMatches); } int matchTokenPos = 1; // 0 = SENT_START final String firstToken = tokens[matchTokenPos].getToken(); String secondToken = null; String thirdToken = null; // ignore quote characters: if (tokens.length >= 3 && ("'".equals(firstToken) || "\"".equals(firstToken) || "„".equals(firstToken))) { matchTokenPos = 2; secondToken = tokens[matchTokenPos].getToken(); } final String firstDutchToken = dutchSpecialCase(firstToken, secondToken, tokens); if (firstDutchToken != null) { thirdToken = firstDutchToken; matchTokenPos = 3; } String checkToken = firstToken; if (thirdToken != null) { checkToken = thirdToken; } else if (secondToken != null) { checkToken = secondToken; } String lastToken = tokens[tokens.length - 1].getToken(); if (lastToken.matches("[ \"'„»«“]") && tokens.length >= 2) { // ignore trailing whitespace or quote lastToken = tokens[tokens.length - 2].getToken(); } boolean preventError = false; // TODO: why do only *these* languages have that special case? final String langCode = language.getShortName(); final boolean languageHasSpecialCases = langCode.equals("ru") || langCode.equals("pl") || langCode.equals("uk") || langCode.equals("be") || langCode.equals(Locale.ENGLISH.getLanguage()) || langCode.equals(Locale.ITALIAN.getLanguage()) || langCode.equals(Locale.GERMAN.getLanguage()); if (languageHasSpecialCases) { // fix for lists; note - this will not always work for the last point in OOo, // as OOo might serve paragraphs in any order. if (";".equals(lastParagraphString) || ";".equals(lastToken) || ",".equals(lastParagraphString) || ",".equals(lastToken)) { preventError = true; } // fix for words in table (not sentences); note - this will not always work for the last point // in OOo, // as OOo might serve paragraphs in any order. if (!lastToken.matches("[.?!…]")) { preventError = true; } } lastParagraphString = lastToken; if (checkToken.length() > 0) { final char firstChar = checkToken.charAt(0); if (!preventError && Character.isLowerCase(firstChar)) { final RuleMatch ruleMatch = new RuleMatch( this, tokens[matchTokenPos].getStartPos(), tokens[matchTokenPos].getStartPos() + tokens[matchTokenPos].getToken().length(), messages.getString("incorrect_case")); ruleMatch.setSuggestedReplacement(StringTools.uppercaseFirstChar(checkToken)); ruleMatches.add(ruleMatch); } } return toRuleMatchArray(ruleMatches); }
@Override public void setParameter(PreparedStatement arg0, int arg1, Locale arg2, JdbcType arg3) throws SQLException { arg0.setString(arg1, (null != arg2) ? arg2.toString() : Locale.ENGLISH.toString()); }