1 11 package org.eclipse.jdt.internal.ui.text.folding; 12 13 import org.eclipse.core.runtime.Assert; 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.core.runtime.IConfigurationElement; 16 17 18 import org.eclipse.jdt.ui.text.folding.IJavaFoldingPreferenceBlock; 19 import org.eclipse.jdt.ui.text.folding.IJavaFoldingStructureProvider; 20 21 26 public final class JavaFoldingStructureProviderDescriptor { 27 28 29 30 private static final String PREFERENCES_CLASS= "preferencesClass"; private static final String CLASS= "class"; private static final String NAME= "name"; private static final String ID= "id"; 35 36 private String fId; 37 38 private String fName; 39 40 private String fClass; 41 45 private boolean fHasPreferences; 46 47 private IConfigurationElement fElement; 48 49 54 JavaFoldingStructureProviderDescriptor(IConfigurationElement element) { 55 fElement= element; 56 fId= element.getAttribute(ID); 57 Assert.isLegal(fId != null); 58 59 fName= element.getAttribute(NAME); 60 if (fName == null) 61 fName= fId; 62 63 fClass= element.getAttribute(CLASS); 64 Assert.isLegal(fClass != null); 65 66 if (element.getAttribute(PREFERENCES_CLASS) == null) 67 fHasPreferences= false; 68 else 69 fHasPreferences= true; 70 } 71 72 79 public IJavaFoldingStructureProvider createProvider() throws CoreException { 80 IJavaFoldingStructureProvider prov= (IJavaFoldingStructureProvider) fElement.createExecutableExtension(CLASS); 81 return prov; 82 } 83 84 91 public IJavaFoldingPreferenceBlock createPreferences() throws CoreException { 92 if (fHasPreferences) { 93 IJavaFoldingPreferenceBlock prefs= (IJavaFoldingPreferenceBlock) fElement.createExecutableExtension(PREFERENCES_CLASS); 94 return prefs; 95 } else { 96 return new EmptyJavaFoldingPreferenceBlock(); 97 } 98 } 99 100 105 public String getId() { 106 return fId; 107 } 108 109 114 public String getName() { 115 return fName; 116 } 117 } 118 | Popular Tags |