List of usage examples for java.text MessageFormat MessageFormat
public MessageFormat(String pattern)
From source file:org.talend.dataprep.i18n.ActionsBundle.java
private String getMessage(Object action, Locale locale, String code, Object... args) { ResourceBundle bundle = findBundle(action, locale); // We can put some cache here if default internal caching it is not enough MessageFormat messageFormat;/*from www .j a v a 2 s . c om*/ if (bundle.containsKey(code)) { messageFormat = new MessageFormat(bundle.getString(code)); } else { try { messageFormat = new MessageFormat(actionToResourceBundle.get(fallBackKey).getString(code)); } catch (MissingResourceException e) { LOGGER.info("Unable to find key '{}' using context '{}'.", code, action, e); throw new TalendRuntimeException(BaseErrorCodes.MISSING_I18N, e); } } return messageFormat.format(args); }
From source file:com.taobao.tddl.common.DynamicLog.java
private void init() { if (appName == null || "".equals(appName)) { log.warn("appName"); return;/*from w ww. j av a2 s . co m*/ } String dataId = new MessageFormat(buryPointsDataId).format(new Object[] { appName }); Object first = ConfigServerHelper.subscribePersistentData(dataId, listener); if (first == null) { log.warn(dataId + "'s first data is null"); } }
From source file:umich.ms.batmass.projects.actions.newproject.NewProjectWizardAction.java
@Override public void actionPerformed(ActionEvent e) { List<WizardDescriptor.Panel<WizardDescriptor>> panels = new ArrayList<>(); panels.add(new NewProjectWizardPanel1()); panels.add(new NewProjectWizardPanel2()); String[] steps = new String[panels.size()]; for (int i = 0; i < panels.size(); i++) { Component c = panels.get(i).getComponent(); // Default step name to component name of panel. steps[i] = c.getName();// ww w . j a va 2s .com if (c instanceof JComponent) { // assume Swing components JComponent jc = (JComponent) c; jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i); jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps); jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true); jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true); jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true); } } WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator<>(panels)); // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName() wiz.setTitleFormat(new MessageFormat("{0}")); wiz.setTitle("Create a new project"); if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) { BMProjectFactory pf = (BMProjectFactory) wiz.getProperty(NewProjectWizardPanel1.PROP_PROJECT_FACTORY); String name = (String) wiz.getProperty(NewProjectWizardPanel2.PROP_PRROJECT_NAME); String location = (String) wiz.getProperty(NewProjectWizardPanel2.PROP_PRROJECT_LOCATION); DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( name + " @ " + location + "\ntype: " + pf.getClass().getSimpleName())); try { // now we have all input data to create a project // BMProjectFactory should know how to create a proper file structure pf.createProjectDirStructure(Paths.get(location), name); // and open the project, if it was created Path newProjectPath = Paths.get(location); FileObject projectToBeOpened = FileUtil.toFileObject(newProjectPath.toFile()); Project project = ProjectManager.getDefault().findProject(projectToBeOpened); Project[] projectsToOpen = { project }; OpenProjects.getDefault().open(projectsToOpen, false, true); } catch (IOException ex) { Exceptions.printStackTrace(ex); } catch (ConfigurationException ex) { Exceptions.printStackTrace(ex); } } }
From source file:com.taobao.tddl.common.ConfigServerHelper.java
/** * /*from w w w. j a v a 2s .c o m*/ */ public static Object subscribeAppDbWeight(String appName, DataListener listener) { if (appName == null || appName.length() == 0) { throw new IllegalStateException("appName"); } String dataId = new MessageFormat(DATA_ID_APP_DBWEIGHT).format(new Object[] { appName }); return ConfigServerHelper.subscribePersistentData(getCallerClassName(), dataId, listener); }
From source file:cherry.foundation.numbering.NumberingManagerImpl.java
@Transactional @Override/* w ww .j a va 2s .com*/ public String[] issueAsString(String numberName, int count) { checkArgument(numberName != null, "numberName must not be null"); checkArgument(count > 0, "count must be > 0"); NumberingDefinition def = getNumberingDefinition(numberName); MessageFormat fmt = new MessageFormat(def.getTemplate()); long current = numberingStore.loadAndLock(numberName); int offset = 0; try { String[] result = new String[count]; for (int i = 1; i <= count; i++) { long v = current + i; checkState(v >= def.getMinValue(), "%s must be >= %s", numberName, def.getMinValue()); checkState(v <= def.getMaxValue(), "%s must be <= %s", numberName, def.getMaxValue()); result[i - 1] = fmt.format(new Object[] { Long.valueOf(v) }); } offset = count; return result; } finally { numberingStore.saveAndUnlock(numberName, current + offset); } }
From source file:it.unibas.spicygui.controllo.mapping.ActionExportTranslatedInstancesSQL.java
@Override public void performAction() { insertBeanForBinding();//w w w .jav a 2 s. c om Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO); MappingTask mappingTask = scenario.getMappingTask(); WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels()); wizardDescriptor.setTitleFormat(new MessageFormat("{0}")); wizardDescriptor.setTitle("Database Configuration"); Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor); dialog.setVisible(true); dialog.toFront(); boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION; if (!cancelled) { try { RelationalConfigurationPM conf = (RelationalConfigurationPM) modello .getBean(Costanti.RELATIONAL_CONFIGURATION_SOURCE); String driver = conf.getDriver(); String uri = conf.getUri(); String userName = conf.getLogin(); String password = conf.getPassword(); DAOSql dao = new DAOSql(); dao.exportTranslatedSQLInstances(mappingTask, scenario.getNumber(), driver, uri, userName, password); DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.EXPORT_COMPLETED_OK))); } catch (DAOException ex) { logger.error(ex); DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.EXPORT_ERROR) + " : " + ex.getMessage(), DialogDescriptor.ERROR_MESSAGE)); } } }
From source file:it.unibas.spicygui.controllo.addtable.ActionAddSourceTable.java
public void performAction() { insertBeanForBinding();//from w w w . jav a 2 s . co m WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels()); wizardDescriptor.setTitleFormat(new MessageFormat("{0}")); wizardDescriptor.setTitle("Choose input"); Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor); dialog.setVisible(true); dialog.toFront(); boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION; if (!cancelled) { try { MappingTask mappingTask = (MappingTask) this.modello.getBean(Costanti.MAPPINGTASK_SHOWED); NewMappingTaskPM newMappingTaskPM = (NewMappingTaskPM) this.modello .getBean(Costanti.NEW_MAPPING_TASK_PM); IDataSourceProxy source = loadDataSource(newMappingTaskPM.getSourceElement(), true); mappingTask.addSource(source); updateScenario(mappingTask); enableActions(); actionViewSchema.performAction(); actionProjectTree.performAction(); } catch (Exception ex) { logger.error(ex); Scenarios.releaseNumber(); DialogDisplayer.getDefault() .notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.NEW_ERROR) + " : " + ex.getMessage(), DialogDescriptor.ERROR_MESSAGE)); } } }
From source file:org.languagetool.rules.patterns.FalseFriendRuleLoader.java
public final List<PatternRule> getRules(final InputStream file, final Language textLanguage, final Language motherTongue) throws ParserConfigurationException, SAXException, IOException { final FalseFriendRuleHandler handler = new FalseFriendRuleHandler(textLanguage, motherTongue); final SAXParserFactory factory = SAXParserFactory.newInstance(); final SAXParser saxParser = factory.newSAXParser(); saxParser.getXMLReader().setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);/*from w w w . j a va2s . c o m*/ saxParser.parse(file, handler); final List<PatternRule> rules = handler.getRules(); // Add suggestions to each rule: final ResourceBundle messages = ResourceBundle.getBundle(JLanguageTool.MESSAGE_BUNDLE, motherTongue.getLocale()); for (final PatternRule rule : rules) { final List<String> suggestionMap = handler.getSuggestionMap().get(rule.getId()); if (suggestionMap != null) { final MessageFormat msgFormat = new MessageFormat(messages.getString("false_friend_suggestion")); final Object[] msg = { formatSuggestions(suggestionMap) }; rule.setMessage(rule.getMessage() + " " + msgFormat.format(msg)); } } return rules; }
From source file:com.microsoft.sqlserver.jdbc.SQLServerColumnEncryptionAzureKeyVaultProvider.java
/** * Constructor that takes a callback function to authenticate to AAD. This is used by KeyVaultClient at runtime to authenticate to Azure Key * Vault.// w w w. j a va2s . c o m * * @param authenticationCallback * - Callback function used for authenticating to AAD. * @param executorService * - The ExecutorService used to create the keyVaultClient * @throws SQLServerException * when an error occurs */ public SQLServerColumnEncryptionAzureKeyVaultProvider( SQLServerKeyVaultAuthenticationCallback authenticationCallback, ExecutorService executorService) throws SQLServerException { if (null == authenticationCallback) { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue")); Object[] msgArgs1 = { "SQLServerKeyVaultAuthenticationCallback" }; throw new SQLServerException(form.format(msgArgs1), null); } credential = new KeyVaultCredential(authenticationCallback); HttpClientBuilder builder = HttpClientBuilder.create(); keyVaultClient = new KeyVaultClientImpl(builder, executorService, credential); }
From source file:it.unibas.spicygui.controllo.addtable.ActionAddTargetTable.java
public void performAction() { insertBeanForBinding();// www . j a v a2s . c o m WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels()); wizardDescriptor.setTitleFormat(new MessageFormat("{0}")); wizardDescriptor.setTitle("Choose input"); Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor); dialog.setVisible(true); dialog.toFront(); boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION; if (!cancelled) { try { MappingTask mappingTask = (MappingTask) this.modello.getBean(Costanti.MAPPINGTASK_SHOWED); NewMappingTaskPM newMappingTaskPM = (NewMappingTaskPM) this.modello .getBean(Costanti.NEW_MAPPING_TASK_PM); IDataSourceProxy target = loadDataSource(newMappingTaskPM.getTargetElement(), false); mappingTask.addTarget(target); updateScenario(mappingTask); enableActions(); actionViewSchema.performAction(); actionProjectTree.performAction(); } catch (Exception ex) { logger.error(ex); Scenarios.releaseNumber(); DialogDisplayer.getDefault() .notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.NEW_ERROR) + " : " + ex.getMessage(), DialogDescriptor.ERROR_MESSAGE)); } } }