/** * Reads all extensions. * <p> * This method can be called more than once in order to reload * from a changed extension registry. * </p> */ public synchronized void reloadExtensions() { List descriptors= new ArrayList(); fDescriptorsMap= new HashMap(); fDefaultDescriptor= null; IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, SPELLING_ENGINE_EXTENSION_POINT); for (int i= 0; i < elements.length; i++) { SpellingEngineDescriptor descriptor= new SpellingEngineDescriptor(elements[i]); descriptors.add(descriptor); fDescriptorsMap.put(descriptor.getId(), descriptor); if (fDefaultDescriptor == null && descriptor.isDefault()) fDefaultDescriptor= descriptor; } fDescriptors= (SpellingEngineDescriptor[]) descriptors.toArray(new SpellingEngineDescriptor[descriptors.size()]); fLoaded= true; }
/** * Creates a spelling engine based on the value of the * <code>PREFERENCE_SPELLING_ENGINE</code> preference in the given * preferences. * * @param preferences the preferences * @return the created spelling engine or <code>null</code> if none * could be created * @throws CoreException if the creation failed * @see SpellingService#PREFERENCE_SPELLING_ENGINE */ private ISpellingEngine createEngine(IPreferenceStore preferences) throws CoreException { SpellingEngineDescriptor descriptor= getActiveSpellingEngineDescriptor(preferences); if (descriptor != null) return descriptor.createEngine(); return null; }
/** * Creates a spelling preferences block as described in the extension's xml. * * @return the created spelling preferences block * @throws CoreException if the creation failed */ public ISpellingPreferenceBlock createPreferences() throws CoreException { if (hasPreferences()) return (ISpellingPreferenceBlock) fConfiguration.createExecutableExtension(PREFERENCES_CLASS_ATTRIBUTE); return new EmptySpellingPreferenceBlock(); }
private Map<String, SpellingEngineDescriptor> createListModel() { SpellingEngineDescriptor[] descs= EditorsUI.getSpellingService().getSpellingEngineDescriptors(); Map<String, SpellingEngineDescriptor> map= new HashMap<>(); for (int i= 0; i < descs.length; i++) { map.put(descs[i].getId(), descs[i]); } return map; }
fCurrentBlock= new ErrorPreferences(message); } else { id= desc.getId(); fCurrentBlock= (ISpellingPreferenceBlock) fProviderPreferences.get(id); if (fCurrentBlock == null) { try { fCurrentBlock= desc.createPreferences(); fProviderPreferences.put(id, fCurrentBlock); } catch (CoreException e) {
@Override public String getText(Object element) { return ((SpellingEngineDescriptor) element).getLabel(); } });
private Map createListModel() { SpellingEngineDescriptor[] descs= EditorsUI.getSpellingService().getSpellingEngineDescriptors(); Map map= new HashMap(); for (int i= 0; i < descs.length; i++) { map.put(descs[i].getId(), descs[i]); } return map; }
fCurrentBlock= new ErrorPreferences(message); } else { id= desc.getId(); fCurrentBlock= fProviderPreferences.get(id); if (fCurrentBlock == null) { try { fCurrentBlock= desc.createPreferences(); fProviderPreferences.put(id, fCurrentBlock); } catch (CoreException e) {
public String getText(Object element) { return ((SpellingEngineDescriptor) element).getLabel(); } });
/** * Reads all extensions. * <p> * This method can be called more than once in order to reload * from a changed extension registry. * </p> */ public synchronized void reloadExtensions() { List<SpellingEngineDescriptor> descriptors= new ArrayList<>(); fDescriptorsMap= new HashMap<>(); fDefaultDescriptor= null; IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, SPELLING_ENGINE_EXTENSION_POINT); for (int i= 0; i < elements.length; i++) { SpellingEngineDescriptor descriptor= new SpellingEngineDescriptor(elements[i]); descriptors.add(descriptor); fDescriptorsMap.put(descriptor.getId(), descriptor); if (fDefaultDescriptor == null && descriptor.isDefault()) fDefaultDescriptor= descriptor; } fDescriptors= descriptors.toArray(new SpellingEngineDescriptor[descriptors.size()]); fLoaded= true; if (fDefaultDescriptor == null && fDescriptors.length > 0) fDefaultDescriptor= fDescriptors[0]; }
public boolean canPerformOk() { SpellingEngineDescriptor desc= EditorsUI.getSpellingService().getActiveSpellingEngineDescriptor(fStore); String id= desc != null ? desc.getId() : ""; //$NON-NLS-1$ final ISpellingPreferenceBlock block= (ISpellingPreferenceBlock) fProviderPreferences.get(id); if (block == null) return true; final Boolean[] result= new Boolean[] { Boolean.TRUE }; ISafeRunnable runnable= new ISafeRunnable() { public void run() throws Exception { result[0]= Boolean.valueOf(block.canPerformOk()); } public void handleException(Throwable x) { } }; SafeRunner.run(runnable); return result[0].booleanValue(); }
/** * Creates a spelling preferences block as described in the extension's xml. * * @return the created spelling preferences block * @throws CoreException if the creation failed */ public ISpellingPreferenceBlock createPreferences() throws CoreException { if (hasPreferences()) return (ISpellingPreferenceBlock) fConfiguration.createExecutableExtension(PREFERENCES_CLASS_ATTRIBUTE); return new EmptySpellingPreferenceBlock(); }
/** * Creates a spelling engine based on the value of the * <code>PREFERENCE_SPELLING_ENGINE</code> preference in the given * preferences. * * @param preferences the preferences * @return the created spelling engine or <code>null</code> if none * could be created * @throws CoreException if the creation failed * @see SpellingService#PREFERENCE_SPELLING_ENGINE */ private ISpellingEngine createEngine(IPreferenceStore preferences) throws CoreException { SpellingEngineDescriptor descriptor= getActiveSpellingEngineDescriptor(preferences); if (descriptor != null) return descriptor.createEngine(); return null; }
/** * Reads all extensions. * <p> * This method can be called more than once in order to reload * from a changed extension registry. * </p> */ public synchronized void reloadExtensions() { List<SpellingEngineDescriptor> descriptors= new ArrayList<>(); fDescriptorsMap= new HashMap<>(); fDefaultDescriptor= null; IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, SPELLING_ENGINE_EXTENSION_POINT); for (int i= 0; i < elements.length; i++) { SpellingEngineDescriptor descriptor= new SpellingEngineDescriptor(elements[i]); descriptors.add(descriptor); fDescriptorsMap.put(descriptor.getId(), descriptor); if (fDefaultDescriptor == null && descriptor.isDefault()) fDefaultDescriptor= descriptor; } fDescriptors= descriptors.toArray(new SpellingEngineDescriptor[descriptors.size()]); fLoaded= true; if (fDefaultDescriptor == null && fDescriptors.length > 0) fDefaultDescriptor= fDescriptors[0]; }
@Override public boolean canPerformOk() { SpellingEngineDescriptor desc= EditorsUI.getSpellingService().getActiveSpellingEngineDescriptor(fStore); String id= desc != null ? desc.getId() : ""; //$NON-NLS-1$ final ISpellingPreferenceBlock block= fProviderPreferences.get(id); if (block == null) return true; final Boolean[] result= new Boolean[] { Boolean.TRUE }; ISafeRunnable runnable= new ISafeRunnable() { @Override public void run() throws Exception { result[0]= Boolean.valueOf(block.canPerformOk()); } @Override public void handleException(Throwable x) { } }; SafeRunner.run(runnable); return result[0].booleanValue(); }
/** * Creates a spelling preferences block as described in the extension's xml. * * @return the created spelling preferences block * @throws CoreException if the creation failed */ public ISpellingPreferenceBlock createPreferences() throws CoreException { if (hasPreferences()) return (ISpellingPreferenceBlock) fConfiguration.createExecutableExtension(PREFERENCES_CLASS_ATTRIBUTE); return new EmptySpellingPreferenceBlock(); }
/** * Creates a spelling engine based on the value of the * <code>PREFERENCE_SPELLING_ENGINE</code> preference in the given * preferences. * * @param preferences the preferences * @return the created spelling engine or <code>null</code> if none * could be created * @throws CoreException if the creation failed * @see SpellingService#PREFERENCE_SPELLING_ENGINE */ private ISpellingEngine createEngine(IPreferenceStore preferences) throws CoreException { SpellingEngineDescriptor descriptor= getActiveSpellingEngineDescriptor(preferences); if (descriptor != null) return descriptor.createEngine(); return null; }
private void updateCheckboxDependencies() { final boolean enabled= fEnablementCheckbox.getSelection(); if (fComboGroup != null) setEnabled(fComboGroup, enabled); SpellingEngineDescriptor desc= EditorsUI.getSpellingService().getActiveSpellingEngineDescriptor(fStore); String id= desc != null ? desc.getId() : ""; //$NON-NLS-1$ final ISpellingPreferenceBlock preferenceBlock= (ISpellingPreferenceBlock) fProviderPreferences.get(id); if (preferenceBlock != null) { ISafeRunnable runnable= new ISafeRunnable() { public void run() throws Exception { preferenceBlock.setEnabled(enabled); } public void handleException(Throwable x) { } }; SafeRunner.run(runnable); } }
private void updateCheckboxDependencies() { final boolean enabled= fEnablementCheckbox.getSelection(); if (fComboGroup != null) setEnabled(fComboGroup, enabled); SpellingEngineDescriptor desc= EditorsUI.getSpellingService().getActiveSpellingEngineDescriptor(fStore); String id= desc != null ? desc.getId() : ""; //$NON-NLS-1$ final ISpellingPreferenceBlock preferenceBlock= fProviderPreferences.get(id); if (preferenceBlock != null) { ISafeRunnable runnable= new ISafeRunnable() { @Override public void run() throws Exception { preferenceBlock.setEnabled(enabled); } @Override public void handleException(Throwable x) { } }; SafeRunner.run(runnable); } }
public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel= (IStructuredSelection) event.getSelection(); if (sel.isEmpty()) return; if (fCurrentBlock != null && fStatusMonitor.getStatus() != null && fStatusMonitor.getStatus().matches(IStatus.ERROR)) if (isPerformRevert()) { ISafeRunnable runnable= new ISafeRunnable() { public void run() throws Exception { fCurrentBlock.performRevert(); } public void handleException(Throwable x) { } }; SafeRunner.run(runnable); } else { revertSelection(); return; } fStore.setValue(SpellingService.PREFERENCE_SPELLING_ENGINE, ((SpellingEngineDescriptor) sel.getFirstElement()).getId()); updateListDependencies(); }