Show
Ignore:
Timestamp:
05/10/08 07:21:52 (8 months ago)
Author:
sed
Message:

Merged branch/1.3.2 changes r611:626 into the trunk.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • org.cfeclipse.cfml/trunk/src/org/cfeclipse/cfml/CFMLPlugin.java

    r529 r654  
    5858import org.osgi.framework.BundleContext; 
    5959 
    60  
    6160/** 
    6261 *  
    63  * The CFEclipse plugin itself.  
     62 * The CFEclipse plugin itself. 
    6463 *  
    65  * Also see 'Simple plug-in example' in the Platform Plug-in Developer Guide  
     64 * Also see 'Simple plug-in example' in the Platform Plug-in Developer Guide 
    6665 * that comes with the SDK version of Eclipse. 
    6766 *  
     
    7170public class CFMLPlugin extends AbstractUIPlugin { 
    7271 
    73          
     72        public static final String PLUGIN_ID = "org.cfeclipse.cfml"; 
    7473 
    7574        /** Singleton instance so that everything can access the plugin */ 
    7675        private static CFMLPlugin plugin; 
    77          
     76 
    7877        /** The bundle of resources for the plugin */ 
    7978        private ResourceBundle resourceBundle; 
    80          
     79 
    8180        /** The preferences for the plugin. */ 
    82         private PreferenceStore propertyStore;  
    83            
     81        private PreferenceStore propertyStore; 
     82 
    8483        /** Content Assist Manager */ 
    8584        private CFEContentAssistManager camInstance; 
    86          
     85 
    8786        /** Last Encloser Manager */ 
    8887        private LastActionManager lastEncMgrInstance; 
    89          
    90         /** Unique ID of the CFENature */ 
    91         public static final String NATURE_ID = "org.cfeclipse.cfml.CFENature"; 
    92          
     88 
    9389        /** Storage for the Templates */ 
    94         private static final String CUSTOM_TEMPLATES_KEY= "org.cfeclipse.cfml.customtemplates"; //$NON-NLS-1$ 
     90        private static final String CUSTOM_TEMPLATES_KEY = "org.cfeclipse.cfml.customtemplates"; //$NON-NLS-1$ 
    9591        private TemplateStore fStore; 
    9692        private ContributionContextTypeRegistry fRegistry; 
    97          
     93 
    9894        /** 
    9995         * Returns the global Content Assist Manager. 
     
    10399         *  
    104100         */ 
    105         public CFEContentAssistManager getGlobalCAM() 
    106         { 
    107                  
    108                 if(this.camInstance == null) 
    109                 { 
    110                         throw new IllegalArgumentException("CFMLPlugin::getGlobalCAM() camInstance is null"); 
    111                 } 
    112             return this.camInstance; 
    113         } 
    114          
     101        public CFEContentAssistManager getGlobalCAM() { 
     102 
     103                if (this.camInstance == null) { 
     104                        throw new IllegalArgumentException( 
     105                                        "CFMLPlugin::getGlobalCAM() camInstance is null"); 
     106                } 
     107                return this.camInstance; 
     108        } 
     109 
    115110        /** 
    116111         * Returns the Last Encloser Manager. 
     
    120115         *  
    121116         */ 
    122         public LastActionManager getLastActionManager() 
    123         { 
    124                 if(this.camInstance == null) 
    125                 { 
    126                         throw new IllegalArgumentException("CFMLPlugin::getGlobalCAM() camInstance is null"); 
    127                 } 
    128             return this.lastEncMgrInstance; 
    129         } 
    130          
     117        public LastActionManager getLastActionManager() { 
     118                if (this.camInstance == null) { 
     119                        throw new IllegalArgumentException( 
     120                                        "CFMLPlugin::getGlobalCAM() camInstance is null"); 
     121                } 
     122                return this.lastEncMgrInstance; 
     123        } 
     124 
    131125        /** 
    132126         * create a new cfml plugin 
    133127         */ 
    134         public CFMLPlugin() 
    135         { 
     128        public CFMLPlugin() { 
    136129                super(); 
    137130                plugin = this; 
    138                 try  
    139                 { 
    140                         this.resourceBundle = ResourceBundle.getBundle("plugin");        
    141                 }  
    142                 catch (MissingResourceException x)  
    143                 { 
     131                try { 
     132                        this.resourceBundle = ResourceBundle.getBundle("plugin"); 
     133                } catch (MissingResourceException x) { 
    144134                        x.printStackTrace(System.err); 
    145135                        this.resourceBundle = null; 
    146136                } 
    147137        } 
    148          
    149         /** 
    150          * This method is called upon plug-in activation. Seems like most startup  
     138 
     139        /** 
     140         * This method is called upon plug-in activation. Seems like most startup 
    151141         * stuff should now go here. 
    152142         */ 
    153143        public void start(BundleContext context) throws Exception { 
    154144                super.start(context); 
    155                  
    156                 /*//System.out.println( 
    157                         "Property store file set to " +  
    158                         CFMLPlugin.getDefault().getStateLocation().toString() 
    159                         + "/properties.ini" 
    160                 ); */ 
    161                  
    162                 PropertyConfigurator.configure(CFMLPlugin.getDefault().getBundle().getEntry("/lib/log4j.properties")); 
    163                 this.propertyStore = new PreferenceStore( 
    164                         CFMLPlugin.getDefault().getStateLocation().toString() 
    165                         + "/properties.ini" 
    166                 ); 
    167                  
    168                 String defaultSnippetPath = CFMLPlugin.getDefault().getStateLocation().toString()+"/snippets"; 
    169                  
     145 
     146                /* 
     147                 * //System.out.println( "Property store file set to " + 
     148                 * CFMLPlugin.getDefault().getStateLocation().toString() + 
     149                 * "/properties.ini" ); 
     150                 */ 
     151 
     152                PropertyConfigurator.configure(CFMLPlugin.getDefault().getBundle() 
     153                                .getEntry("/lib/log4j.properties")); 
     154                this.propertyStore = new PreferenceStore(CFMLPlugin.getDefault() 
     155                                .getStateLocation().toString() 
     156                                + "/properties.ini"); 
     157 
     158                String defaultSnippetPath = CFMLPlugin.getDefault().getStateLocation() 
     159                                .toString() 
     160                                + "/snippets"; 
     161 
    170162                File f = new File(defaultSnippetPath); 
    171163                if (!f.exists()) { 
    172                     f.mkdir(); 
    173                 } 
    174                  
    175                 try 
    176                 { 
    177                         //load all the syntax dictionaries 
     164                        f.mkdir(); 
     165                } 
     166 
     167                try { 
     168                        // load all the syntax dictionaries 
    178169                        DictionaryManager.initDictionaries(); 
    179                          
    180                         //startup the image registry 
     170 
     171                        // startup the image registry 
    181172                        CFPluginImages.initCFPluginImages(); 
    182                          
     173 
    183174                        setupCAM(); 
    184175                        setupLastEncMgr(); 
    185                 } 
    186                 catch(Exception e) 
    187                 { 
    188                         //lots of bad things can happen... 
     176                } catch (Exception e) { 
     177                        // lots of bad things can happen... 
    189178                        e.printStackTrace(System.err); 
    190179                } 
    191                  
    192                  
     180 
    193181                EditorPartListener editorListener = new EditorPartListener(); 
    194                 this.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener(editorListener); 
    195                  
    196          
    197         } 
    198  
    199         /** 
    200      * Setups up the Content Assist Manager 
    201      *  
    202      */ 
    203     public void setupCAM() { 
    204         this.camInstance = new CFEContentAssistManager(); 
    205         CFMLTagAssist cfmlAssistor = new CFMLTagAssist(DictionaryManager.getDictionary(DictionaryManager.CFDIC)); 
    206         HTMLTagAssistContributor htmlAssistor = new HTMLTagAssistContributor(DictionaryManager.getDictionary(DictionaryManager.HTDIC)); 
    207  
    208         CFScriptCompletionProcessor cfscp = new CFScriptCompletionProcessor(); 
     182                this.getWorkbench().getActiveWorkbenchWindow().getPartService() 
     183                                .addPartListener(editorListener); 
     184 
     185        } 
     186 
     187        /** 
     188         * Setups up the Content Assist Manager 
     189         *  
     190         */ 
     191        public void setupCAM() { 
     192                this.camInstance = new CFEContentAssistManager(); 
     193                CFMLTagAssist cfmlAssistor = new CFMLTagAssist(DictionaryManager 
     194                                .getDictionary(DictionaryManager.CFDIC)); 
     195                HTMLTagAssistContributor htmlAssistor = new HTMLTagAssistContributor( 
     196                                DictionaryManager.getDictionary(DictionaryManager.HTDIC)); 
     197 
     198                CFScriptCompletionProcessor cfscp = new CFScriptCompletionProcessor(); 
    209199                cfscp.changeDictionary(DictionaryManager.JSDIC); 
    210          
     200 
    211201                this.camInstance.registerRootAssist(cfscp); 
    212         this.camInstance.registerRootAssist(new CFContentAssist()); 
    213         this.camInstance.registerRootAssist(new CFMLScopeAssist()); 
    214         this.camInstance.registerRootAssist(new CFMLFunctionAssist()); 
    215       //  this.camInstance.registerRootAssist(new CFMLComponentAssist()); //finds the components in a project, removed as we might use a new CFML Varscope parser 
    216         this.camInstance.registerRootAssist(new CFMLVariableAssist()); //finds the arguments in a cfc that you are talking about 
    217  
    218         this.camInstance.registerTagAssist(cfmlAssistor); 
    219         this.camInstance.registerAttributeAssist(cfmlAssistor); 
    220         this.camInstance.registerValueAssist(cfmlAssistor); 
    221  
    222         this.camInstance.registerTagAssist(htmlAssistor); 
    223         this.camInstance.registerAttributeAssist(htmlAssistor); 
    224         this.camInstance.registerValueAssist(htmlAssistor); 
    225          
    226          
    227          
    228         this.camInstance.registerTagAssist(new CFMLScopeAssist()); 
    229     } 
    230  
    231         /** 
    232      * Sets up the Last Encloser Manager 
    233      *  
    234      */ 
    235     private void setupLastEncMgr() { 
    236         this.lastEncMgrInstance = new LastActionManager(); 
    237         } 
    238  
    239     /** 
     202                this.camInstance.registerRootAssist(new CFContentAssist()); 
     203                this.camInstance.registerRootAssist(new CFMLScopeAssist()); 
     204                this.camInstance.registerRootAssist(new CFMLFunctionAssist()); 
     205                // this.camInstance.registerRootAssist(new CFMLComponentAssist()); 
     206                // //finds the components in a project, removed as we might use a new 
     207                // CFML Varscope parser 
     208                // finds the arguments in a cfc that you are talking about 
     209                this.camInstance.registerRootAssist(new CFMLVariableAssist()); 
     210 
     211                this.camInstance.registerTagAssist(cfmlAssistor); 
     212                this.camInstance.registerAttributeAssist(cfmlAssistor); 
     213                this.camInstance.registerValueAssist(cfmlAssistor); 
     214 
     215                this.camInstance.registerTagAssist(htmlAssistor); 
     216                this.camInstance.registerAttributeAssist(htmlAssistor); 
     217                this.camInstance.registerValueAssist(htmlAssistor); 
     218 
     219                this.camInstance.registerTagAssist(new CFMLScopeAssist()); 
     220        } 
     221 
     222        /** 
     223         * Sets up the Last Encloser Manager 
     224         *  
     225         */ 
     226        private void setupLastEncMgr() { 
     227                this.lastEncMgrInstance = new LastActionManager(); 
     228        } 
     229 
     230        /** 
    240231         * This method is called when the plug-in is stopped 
    241232         */ 
     
    243234                super.stop(context); 
    244235        } 
    245          
    246         protected void initializeDefaultPluginPreferences()  
    247         { 
    248              
    249         //super.initializeDefaultPluginPreferences(); 
    250         CFMLPreferenceManager preferenceManager = new CFMLPreferenceManager(); 
     236 
     237        protected void initializeDefaultPluginPreferences() { 
     238 
     239                // super.initializeDefaultPluginPreferences(); 
     240                CFMLPreferenceManager preferenceManager = new CFMLPreferenceManager(); 
    251241                preferenceManager.initializeDefaultValues(); 
    252                 TextEditorPreferenceConstants.initializeDefaultValues(getPreferenceStore()); 
     242                TextEditorPreferenceConstants 
     243                                .initializeDefaultValues(getPreferenceStore()); 
    253244                try { 
    254245                        CFMLPropertyManager propertyManager = new CFMLPropertyManager(); 
    255                 } 
    256                 catch (Exception e) { 
     246                } catch (Exception e) { 
    257247                        // do nothing 
    258248                } 
    259     } 
    260          
     249        } 
     250 
    261251        /** 
    262252         * Returns the shared instance. 
    263253         */ 
    264         public static CFMLPlugin getDefault()  
    265         { 
     254        public static CFMLPlugin getDefault() { 
    266255                return plugin; 
    267256        } 
    268          
     257 
    269258        public PreferenceStore getPropertyStore() { 
    270259                return this.propertyStore; 
    271260        } 
    272          
    273261 
    274262        /** 
    275263         * Returns the workspace instance. 
    276264         */ 
    277         public static IWorkspace getWorkspace()  
    278         { 
     265        public static IWorkspace getWorkspace() { 
    279266                return ResourcesPlugin.getWorkspace(); 
    280267        } 
    281268 
    282269        /** 
    283          * Returns the string from the plugin's resource bundle, 
    284          * or 'key' if not found. 
    285          */ 
    286         public static String getResourceString(String key)  
    287         { 
     270         * Returns the string from the plugin's resource bundle, or 'key' if not 
     271         * found. 
     272         */ 
     273        public static String getResourceString(String key) { 
    288274                ResourceBundle bundle = CFMLPlugin.getDefault().getResourceBundle(); 
    289                 try  
    290                 { 
    291                         return (bundle!=null ? bundle.getString(key) : key); 
    292                 }  
    293                 catch (MissingResourceException e)  
    294                 { 
     275                try { 
     276                        return (bundle != null ? bundle.getString(key) : key); 
     277                } catch (MissingResourceException e) { 
    295278                        return key; 
    296279                } 
     
    300283         * Returns the plugin's resource bundle, 
    301284         */ 
    302         public ResourceBundle getResourceBundle()  
    303         { 
     285        public ResourceBundle getResourceBundle() { 
    304286                return this.resourceBundle; 
    305287        } 
     
    307289        public TemplateStore getTemplateStore() { 
    308290                if (fStore == null) { 
    309                         fStore= new ContributionTemplateStore(null, CFMLPlugin.getDefault().getPreferenceStore(), CUSTOM_TEMPLATES_KEY); 
     291                        fStore = new ContributionTemplateStore(null, CFMLPlugin 
     292                                        .getDefault().getPreferenceStore(), CUSTOM_TEMPLATES_KEY); 
    310293                        try { 
    311294                                fStore.load(); 
     
    320303                if (fRegistry == null) { 
    321304                        // create an configure the contexts available in the template editor 
    322                         fRegistry= new ContributionContextTypeRegistry(); 
     305                        fRegistry = new ContributionContextTypeRegistry(); 
    323306                        fRegistry.addContextType(CFMContextType.CFM_CONTEXT_TYPE); 
    324307                }