private synchronized void ensureSortersRead() { if (fSorters != null) { return; } Map<String, ProposalSorterHandle> sorters = new LinkedHashMap<String, ProposalSorterHandle>(); IExtensionRegistry registry = Platform.getExtensionRegistry(); List<IConfigurationElement> elements = new ArrayList<IConfigurationElement>( Arrays.asList( registry.getConfigurationElementsFor( DartToolsPlugin.getPluginId(), EXTENSION_POINT))); for (Iterator<IConfigurationElement> iter = elements.iterator(); iter.hasNext(); ) { IConfigurationElement element = iter.next(); try { ProposalSorterHandle handle = new ProposalSorterHandle(element); final String id = handle.getId(); sorters.put(id, handle); if (DEFAULT_ID.equals(id)) { fDefaultSorter = handle; } } catch (InvalidRegistryObjectException x) { /* * Element is not valid any longer as the contributing plug-in was unloaded or for some * other reason. Do not include the extension in the list and inform the user about it. */ Object[] args = {element.toString()}; String message = Messages.format( DartTextMessages.CompletionProposalComputerRegistry_invalid_message, args); IStatus status = new Status(IStatus.WARNING, DartToolsPlugin.getPluginId(), IStatus.OK, message, x); informUser(status); } } fSorters = sorters; }
public void select(ProposalSorterHandle handle) { Assert.isTrue(handle != null); String id = handle.getId(); fPreferenceStore.setValue(fKey, id); }