1 11 package org.eclipse.ui.internal.texteditor.quickdiff; 12 13 import java.util.ArrayList ; 14 import java.util.Collections ; 15 import java.util.List ; 16 17 import org.eclipse.core.runtime.IConfigurationElement; 18 import org.eclipse.core.runtime.IExtensionRegistry; 19 import org.eclipse.core.runtime.Platform; 20 21 import org.eclipse.ui.internal.texteditor.TextEditorPlugin; 22 import org.eclipse.ui.texteditor.quickdiff.ReferenceProviderDescriptor; 23 24 29 public class QuickDiffExtensionsRegistry { 30 31 32 private ReferenceProviderDescriptor fDefaultDescriptor; 33 34 private List fDescriptors; 35 36 39 public QuickDiffExtensionsRegistry() { 40 } 41 42 47 public synchronized ReferenceProviderDescriptor getDefaultProvider() { 48 ensureRegistered(); 49 return fDefaultDescriptor; 50 } 51 52 58 public synchronized List getReferenceProviderDescriptors() { 59 ensureRegistered(); 60 return fDescriptors; 61 } 62 63 66 private void ensureRegistered() { 67 if (fDescriptors == null) 68 reloadExtensions(); 69 } 70 71 78 public synchronized void reloadExtensions() { 79 fDefaultDescriptor= null; 80 IExtensionRegistry registry= Platform.getExtensionRegistry(); 81 List list= new ArrayList (); 82 83 IConfigurationElement[] elements= registry.getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, TextEditorPlugin.REFERENCE_PROVIDER_EXTENSION_POINT); 84 for (int i= 0; i < elements.length; i++) { 85 ReferenceProviderDescriptor desc= new ReferenceProviderDescriptor(elements[i]); 86 if (desc.getId().equals("org.eclipse.ui.internal.editors.quickdiff.LastSaveReferenceProvider")) fDefaultDescriptor= desc; 88 list.add(desc); 89 } 90 91 if (fDefaultDescriptor != null) { 93 list.remove(fDefaultDescriptor); 94 list.add(0, fDefaultDescriptor); 95 } 96 97 fDescriptors= Collections.unmodifiableList(list); 98 } 99 } 100 | Popular Tags |