1 20 21 package org.apache.directory.ldapstudio.schemas; 22 23 24 import org.apache.directory.ldapstudio.schemas.model.SchemaPool; 25 import org.apache.directory.ldapstudio.schemas.view.views.SchemaCodeScanner; 26 import org.apache.directory.ldapstudio.schemas.view.views.SchemaTextAttributeProvider; 27 import org.eclipse.jface.text.rules.ITokenScanner; 28 import org.eclipse.jface.util.IPropertyChangeListener; 29 import org.eclipse.jface.util.PropertyChangeEvent; 30 import org.eclipse.ui.plugin.AbstractUIPlugin; 31 import org.osgi.framework.BundleContext; 32 33 34 37 public class Activator extends AbstractUIPlugin 38 { 39 40 41 public static final String PLUGIN_ID = "org.apache.directory.ldapstudio.schemas"; 43 44 private static Activator plugin; 45 46 47 private static ITokenScanner schemaCodeScanner; 48 49 50 private static SchemaTextAttributeProvider schemaTextAttributeProvider; 51 52 53 private SchemaPool schemaPool; 54 55 56 59 public Activator() 60 { 61 plugin = this; 62 } 63 64 65 69 public void start( BundleContext context ) throws Exception 70 { 71 super.start( context ); 72 73 schemaPool = SchemaPool.getInstance(); 75 76 initPreferencesListener(); 78 79 } 80 81 82 86 public void stop( BundleContext context ) throws Exception 87 { 88 schemaPool.saveUserSchemasPaths(); 90 91 plugin = null; 92 super.stop( context ); 93 } 94 95 96 101 public static Activator getDefault() 102 { 103 return plugin; 104 } 105 106 107 113 public static ITokenScanner getSchemaCodeScanner() 114 { 115 if ( schemaCodeScanner == null ) 116 { 117 schemaCodeScanner = new SchemaCodeScanner( getSchemaTextAttributeProvider() ); 118 } 119 120 return schemaCodeScanner; 121 } 122 123 124 130 private static SchemaTextAttributeProvider getSchemaTextAttributeProvider() 131 { 132 if ( schemaTextAttributeProvider == null ) 133 { 134 schemaTextAttributeProvider = new SchemaTextAttributeProvider(); 135 } 136 137 return schemaTextAttributeProvider; 138 } 139 140 141 144 private void initPreferencesListener() 145 { 146 Activator.getDefault().getPreferenceStore().addPropertyChangeListener( new IPropertyChangeListener() 147 { 148 public void propertyChange( PropertyChangeEvent event ) 149 { 150 if ( PluginConstants.PREFS_SCHEMAS_EDITOR_SPECIFIC_CORE == event.getProperty() ) 151 { 152 schemaPool.reload(); 154 } 155 } 156 } ); 157 } 158 } 159 | Popular Tags |