List of usage examples for java.text MessageFormat format
public final String format(Object obj)
From source file:de.acosix.alfresco.mtsupport.repo.auth.ldap.EnhancedLDAPUserRegistry.java
/** * * {@inheritDoc}//from ww w . java 2 s . com */ @Override public Collection<NodeDescription> getGroups(final Date modifiedSince) { // Work out whether the user and group trees are disjoint. This may allow us to optimize reverse DN // resolution. final LdapName groupDistinguishedNamePrefix = this.resolveDistinguishedNamePrefix(this.groupSearchBase); final LdapName userDistinguishedNamePrefix = this.resolveDistinguishedNamePrefix(this.userSearchBase); final boolean disjoint = !groupDistinguishedNamePrefix.startsWith(userDistinguishedNamePrefix) && !userDistinguishedNamePrefix.startsWith(groupDistinguishedNamePrefix); final String query; if (modifiedSince == null) { query = this.groupQuery; } else { final MessageFormat mf = new MessageFormat(this.groupDifferentialQuery, Locale.ENGLISH); query = mf.format(new Object[] { this.timestampFormat.format(modifiedSince) }); } // find duplicate gid in advance final Set<String> groupNames = new HashSet<>(); final Map<String, AtomicInteger> groupNameCounts = new HashMap<>(); this.processQuery((result) -> { final Attribute nameAttribute = result.getAttributes().get(this.groupIdAttributeName); if (nameAttribute == null) { if (this.errorOnMissingUID) { final Object[] params = { result.getNameInNamespace(), this.groupIdAttributeName }; throw new AlfrescoRuntimeException("synchronization.err.ldap.get.group.id.missing", params); } else { LOGGER.warn("Missing GID on {}", result.getNameInNamespace()); } } else { final Collection<String> attributeValues = this.mapAttribute(nameAttribute, String.class); final String groupName = attributeValues.iterator().next(); LOGGER.debug("Group DN recognized: {}", groupName); if (groupNames.contains(groupName)) { if (this.errorOnDuplicateGID) { throw new AlfrescoRuntimeException("Duplicate group id found: " + groupName); } LOGGER.warn("Duplicate gid found for {} -> merging definitions", groupName); groupNameCounts.computeIfAbsent(groupName, (x) -> { return new AtomicInteger(1); }).getAndIncrement(); } else { groupNames.add(groupName); } } }, this.groupSearchBase, this.groupQuery, new String[] { this.groupIdAttributeName }); final Supplier<InitialDirContext> contextSupplier = this.buildContextSupplier(); final Function<InitialDirContext, Boolean> nextPageChecker = this.buildNextPageChecker(); final Function<InitialDirContext, NamingEnumeration<SearchResult>> groupSearcher = this .buildGroupSearcher(query); final NodeMapper groupMapper = this.buildGroupMapper(disjoint, groupDistinguishedNamePrefix, userDistinguishedNamePrefix); return new PersonCollection(contextSupplier, nextPageChecker, groupSearcher, groupMapper, this.queryBatchSize, groupNames.size()); }
From source file:it.cnr.icar.eric.client.ui.swing.RegistryObjectsTable.java
public TableCellRenderer getCellRenderer(int row, int column) { if (cachedTableCellRenderers[column] != null) { return cachedTableCellRenderers[column]; }// w w w . j av a 2s . co m TableCellRenderer renderer = null; Class<?> clazz = null; try { clazz = tableModel.getColumnClass(column); renderer = super.getCellRenderer(row, column); if (renderer == null) { Object[] unsupportedColumnClassArgs = { tableModel.getColumnName(column), clazz }; MessageFormat form = new MessageFormat(resourceBundle.getString("error.unsupportedColumnClass")); RegistryBrowser.displayError(form.format(unsupportedColumnClassArgs)); } } catch (Exception e) { Object[] unsupportedColumnClassArgs = { tableModel.getColumnName(column), clazz }; MessageFormat form = new MessageFormat(resourceBundle.getString("error.unsupportedColumnClass")); RegistryBrowser.displayError(form.format(unsupportedColumnClassArgs), e); } if (renderer instanceof JLabel) { ((JLabel) renderer).setHorizontalAlignment(SwingConstants.LEFT); } cachedTableCellRenderers[column] = renderer; return renderer; }
From source file:com.jkoolcloud.tnt4j.streams.fields.ActivityInfo.java
private static String formatArrayPattern(String pattern, Object[] vArray) { MessageFormat mf = new MessageFormat(pattern); try {/* ww w . ja v a 2 s.c o m*/ Field f = mf.getClass().getDeclaredField("maxOffset"); f.setAccessible(true); int maxOffset = f.getInt(mf); if (maxOffset >= 0) { f = mf.getClass().getDeclaredField("argumentNumbers"); f.setAccessible(true); int[] ana = (int[]) f.get(mf); int maxIndex = ana[maxOffset]; if (maxIndex >= vArray.length) { LOGGER.log(OpLevel.WARNING, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityInfo.formatting.arguments.mismatch"), pattern, maxIndex, ArrayUtils.getLength(vArray)); } } } catch (Exception exc) { } return mf.format(vArray); }
From source file:it.cnr.icar.eric.client.ui.swing.RegistryObjectsTable.java
/** * Class Constructor.//from www . j ava2s.com * * @param model * * @see */ public RegistryObjectsTable(TableModel model) { // Gives a TableColumnModel so that AutoCreateColumnsFromModel will be false. super(model, new DefaultTableColumnModel()); this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); if (model instanceof RegistryObjectsTableModel) { tableModel = (RegistryObjectsTableModel) model; } else if (model instanceof TableSorter) { tableModel = (RegistryObjectsTableModel) (((TableSorter) model).getModel()); } else { Object[] unexpectedTableModelArgs = { model }; MessageFormat form = new MessageFormat(resourceBundle.getString("error.unexpectedTableModel")); throw new IllegalArgumentException(form.format(unexpectedTableModelArgs)); } setToolTipText(resourceBundle.getString("tip.registryObjectsTable")); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); ListSelectionModel rowSM = getSelectionModel(); stdRowHeight = getRowHeight(); setRowHeight(stdRowHeight * 3); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (!lsm.isSelectionEmpty()) { setSelectedRow(lsm.getMinSelectionIndex()); } else { setSelectedRow(-1); } } }); createPopup(); addRenderers(); // Add listener to self so that I can bring up popup menus on right mouse click popupListener = new PopupListener(); addMouseListener(popupListener); //add listener for 'authenticated' bound property RegistryBrowser.getInstance().addPropertyChangeListener(RegistryBrowser.PROPERTY_AUTHENTICATED, this); //add listener for 'locale' bound property RegistryBrowser.getInstance().addPropertyChangeListener(RegistryBrowser.PROPERTY_LOCALE, this); }
From source file:freemind.controller.Controller.java
/** * Set the Frame title with mode and file if exist *///from ww w . j a v a2 s.co m public void setTitle() { Object[] messageArguments = { getMode().toLocalizedString() }; MessageFormat formatter = new MessageFormat(getResourceString("mode_title")); String title = formatter.format(messageArguments); String rawTitle = ""; MindMap model = null; MapModule mapModule = getMapModule(); if (mapModule != null) { model = mapModule.getModel(); rawTitle = mapModule.toString(); title = rawTitle + (model.isSaved() ? "" : "*") + " - " + title + (model.isReadOnly() ? " (" + getResourceString("read_only") + ")" : ""); File file = model.getFile(); if (file != null) { title += " " + file.getAbsolutePath(); } } getFrame().setTitle(title); for (Iterator iterator = mMapTitleChangeListenerSet.iterator(); iterator.hasNext();) { MapModuleManager.MapTitleChangeListener listener = (MapModuleManager.MapTitleChangeListener) iterator .next(); listener.setMapTitle(rawTitle, mapModule, model); } }
From source file:freemind.controller.Controller.java
/** Creates a new mode (controller), activates the toolbars, title and deactivates all * actions.//from w ww .ja v a 2 s .c o m * Does nothing, if the mode is identical to the current mode. * * @return false if the change was not successful. */ public boolean createNewMode(String mode) { if (getMode() != null && mode.equals(getMode().toString())) { return true; } //Check if the mode is available and create ModeController. Mode newMode = mModescreator.getMode(mode); if (newMode == null) { errorMessage(getResourceString("mode_na") + ": " + mode); return false; } // change the map module to get changed toolbars etc.: getMapModuleManager().setMapModule(null, newMode); setTitle(); getMode().activate(); Object[] messageArguments = { getMode().toLocalizedString() }; MessageFormat formatter = new MessageFormat(getResourceString("mode_status")); getFrame().out(formatter.format(messageArguments)); return true; }