1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
8 **********************************************************************/
9 package net.sourceforge.phpeclipse;
12 import java.io.IOException;
13 import java.io.InputStream;
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.Enumeration;
17 import java.util.HashMap;
18 import java.util.HashSet;
19 import java.util.Iterator;
20 import java.util.List;
21 import java.util.PropertyResourceBundle;
24 import net.sourceforge.phpdt.core.IBuffer;
25 import net.sourceforge.phpdt.core.IBufferFactory;
26 import net.sourceforge.phpdt.core.ICompilationUnit;
27 import net.sourceforge.phpdt.core.IJavaElement;
28 import net.sourceforge.phpdt.core.JavaCore;
29 import net.sourceforge.phpdt.core.WorkingCopyOwner;
30 import net.sourceforge.phpdt.internal.core.BatchOperation;
31 import net.sourceforge.phpdt.internal.core.JavaModelManager;
32 import net.sourceforge.phpdt.internal.core.util.Util;
33 /*import net.sourceforge.phpdt.internal.corext.template.php.CodeTemplateContextType;
34 import net.sourceforge.phpdt.internal.corext.template.php.HTMLContextType;
35 import net.sourceforge.phpdt.internal.corext.template.php.JavaContextType;
36 import net.sourceforge.phpdt.internal.corext.template.php.JavaDocContextType;*/
37 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
38 /*import net.sourceforge.phpdt.internal.ui.IJavaStatusConstants;
39 import net.sourceforge.phpdt.internal.ui.JavaElementAdapterFactory;
40 import net.sourceforge.phpdt.internal.ui.ResourceAdapterFactory;
41 import net.sourceforge.phpdt.internal.ui.preferences.MembersOrderPreferenceCache;
42 import net.sourceforge.phpdt.internal.ui.preferences.MockupPreferenceStore;
43 import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter;
44 import net.sourceforge.phpdt.internal.ui.text.folding.JavaFoldingStructureProviderRegistry;
45 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
46 import net.sourceforge.phpdt.internal.ui.viewsupport.ImageDescriptorRegistry;
47 import net.sourceforge.phpdt.internal.ui.viewsupport.ProblemMarkerManager;
48 import net.sourceforge.phpdt.ui.IContextMenuConstants;
49 import net.sourceforge.phpdt.ui.IWorkingCopyManager;
50 import net.sourceforge.phpdt.ui.PreferenceConstants;
51 import net.sourceforge.phpdt.ui.text.JavaTextTools;*/
52 /*import net.sourceforge.phpeclipse.builder.ExternalEditorInput;
53 import net.sourceforge.phpeclipse.builder.ExternalStorageDocumentProvider;
54 import net.sourceforge.phpeclipse.builder.FileStorage;
55 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;*/
56 /*import net.sourceforge.phpeclipse.phpeditor.CustomBufferFactory;
57 import net.sourceforge.phpeclipse.phpeditor.DocumentAdapter;
58 import net.sourceforge.phpeclipse.phpeditor.ICompilationUnitDocumentProvider;
59 import net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider;
60 import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr;
61 import net.sourceforge.phpeclipse.phpeditor.WorkingCopyManager;
62 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;*/
64 import org.eclipse.core.resources.IFile;
65 import org.eclipse.core.resources.IProject;
66 import org.eclipse.core.resources.IResource;
67 import org.eclipse.core.resources.IResourceChangeEvent;
68 import org.eclipse.core.resources.ISavedState;
69 import org.eclipse.core.resources.IWorkspace;
70 import org.eclipse.core.resources.IWorkspaceRunnable;
71 import org.eclipse.core.resources.ResourcesPlugin;
72 import org.eclipse.core.resources.WorkspaceJob;
73 import org.eclipse.core.runtime.CoreException;
74 import org.eclipse.core.runtime.IAdapterManager;
75 import org.eclipse.core.runtime.IConfigurationElement;
76 import org.eclipse.core.runtime.IPath;
77 import org.eclipse.core.runtime.IProgressMonitor;
78 import org.eclipse.core.runtime.IStatus;
79 import org.eclipse.core.runtime.Path;
80 import org.eclipse.core.runtime.Platform;
81 import org.eclipse.core.runtime.Plugin;
82 import org.eclipse.core.runtime.Status;
83 import org.eclipse.core.runtime.jobs.ISchedulingRule;
84 import org.eclipse.core.runtime.jobs.Job;
85 import org.eclipse.jface.text.templates.ContextTypeRegistry;
86 import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
87 /*import org.eclipse.jface.action.GroupMarker;
88 import org.eclipse.jface.action.IMenuManager;
89 import org.eclipse.jface.action.Separator;
90 import org.eclipse.jface.preference.IPreferenceStore;
91 import org.eclipse.jface.preference.PreferenceConverter;
92 import org.eclipse.jface.resource.JFaceResources;*/
93 /*import org.eclipse.jface.text.BadLocationException;
94 import org.eclipse.jface.text.IDocument;
95 import org.eclipse.jface.text.templates.ContextTypeRegistry;
96 import org.eclipse.jface.text.templates.persistence.TemplateStore;
97 import org.eclipse.jface.util.IPropertyChangeListener;
98 import org.eclipse.jface.util.PropertyChangeEvent;
99 import org.eclipse.swt.graphics.RGB;
100 import org.eclipse.swt.widgets.Display;
101 import org.eclipse.swt.widgets.Shell;
102 import org.eclipse.ui.IEditorDescriptor;
103 import org.eclipse.ui.IEditorInput;
104 import org.eclipse.ui.IEditorPart;
105 import org.eclipse.ui.IEditorRegistry;
106 import org.eclipse.ui.IWorkbench;
107 import org.eclipse.ui.IWorkbenchPage;
108 import org.eclipse.ui.IWorkbenchWindow;
109 import org.eclipse.ui.PlatformUI;
110 import org.eclipse.ui.editors.text.EditorsUI;
111 import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
112 import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
113 import org.eclipse.ui.ide.IDE;
114 import org.eclipse.ui.plugin.AbstractUIPlugin;
115 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
116 import org.eclipse.ui.texteditor.ConfigurationElementSorter;
117 import org.eclipse.ui.texteditor.IDocumentProvider;
118 import org.eclipse.ui.texteditor.ITextEditor;
119 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;*/
120 import org.osgi.framework.BundleContext;
123 * The main plugin class to be used in the desktop.
125 public class PHPeclipsePlugin extends /*AbstractUIPlugin*/Plugin implements
126 IPreferenceConstants {
128 * The id of the PHP plugin (value <code>"net.sourceforge.phpeclipse"</code>).
130 public static final String PLUGIN_ID = "net.sourceforge.phpeclipse"; //$NON-NLS-1$
132 public static final String EDITOR_ID = PHPeclipsePlugin.PLUGIN_ID
135 //public static final String ID_PERSPECTIVE = "net.sourceforge.phpeclipse.PHPPerspective"; //$NON-NLS-1$
140 * id of builder - matches plugin.xml (concatenate pluginid.builderid)
142 public static final String BUILDER_PARSER_ID = PLUGIN_ID + ".parserbuilder";
144 // public static final String BUILDER_INDEX_ID = PLUGIN_ID +
146 /** General debug flag */
148 public static final boolean DEBUG = false;
151 * The maximum number of allowed proposals by category
153 public final static int MAX_PROPOSALS = 200;
156 * The key to store customized templates.
160 private static final String TEMPLATES_KEY = "net.sourceforge.phpdt.ui.text.custom_templates"; //$NON-NLS-1$
163 * The key to store customized code templates.
167 private static final String CODE_TEMPLATES_KEY = "net.sourceforge.phpdt.ui.text.custom_code_templates"; //$NON-NLS-1$
169 public static final String PHP_CODING_ACTION_SET_ID = PLUGIN_ID
170 + ".ui.CodingActionSet"; //$NON-NLS-1$
172 public final static String PHP_NATURE_ID = PLUGIN_ID + ".phpnature";
174 public static final String PHPPARSER_ORIGINAL = "net.sourceforge.phpdt.internal.compiler.parser.Parser";
176 public static final String PHPPARSER_NEW = "test.PHPParser";
178 /** Change this if you want to switch PHP Parser. */
179 public static final String PHPPARSER = PHPPARSER_ORIGINAL;
181 // The shared instance.
182 private static PHPeclipsePlugin plugin;
185 * The template context type registry for the java editor.
189 /*private ContextTypeRegistry fContextTypeRegistry;*/
192 * The code template context type registry for the java editor.
196 private ContextTypeRegistry fCodeTemplateContextTypeRegistry;
199 * The template store for the java editor.
203 /*private TemplateStore fTemplateStore;*/
206 * The coded template store for the java editor.
210 /*private TemplateStore fCodeTemplateStore;*/
213 private static final int WINDOWS_9x = 6;
216 private static final int WINDOWS_NT = 5;
218 /*private ImageDescriptorRegistry fImageDescriptorRegistry;*/
220 private HashMap fIndexManagerMap = new HashMap();
222 /*private IWorkingCopyManager fWorkingCopyManager;*/
224 private IBufferFactory fBufferFactory;
226 /*private ICompilationUnitDocumentProvider fCompilationUnitDocumentProvider;*/
228 /*private JavaTextTools fJavaTextTools;*/
230 /*private ProblemMarkerManager fProblemMarkerManager;*/
232 /*private MembersOrderPreferenceCache fMembersOrderPreferenceCache;*/
234 private IFile fLastEditorFile = null;
236 /* private JavaEditorTextHoverDescriptor[] fJavaEditorTextHoverDescriptors;*/
238 /*private JavaElementAdapterFactory fJavaElementAdapterFactory;*/
240 // private MarkerAdapterFactory fMarkerAdapterFactory;
241 // private EditorInputAdapterFactory fEditorInputAdapterFactory;
242 /*private ResourceAdapterFactory fResourceAdapterFactory;*/
244 // private LogicalPackageAdapterFactory fLogicalPackageAdapterFactory;
245 /*private IPropertyChangeListener fFontPropertyChangeListener;*/
248 * Property change listener on this plugin's preference store.
252 // private IPropertyChangeListener fPropertyChangeListener;
254 * The combined preference store.
258 /*private IPreferenceStore fCombinedPreferenceStore;*/
261 * The extension point registry for the
262 * <code>net.sourceforge.phpdt.ui.javaFoldingStructureProvider</code>
267 /*private JavaFoldingStructureProviderRegistry fFoldingStructureProviderRegistry;*/
270 * Mockup preference store for firing events and registering listeners on
271 * project setting changes. FIXME: Temporary solution.
275 /*private MockupPreferenceStore fMockupPreferenceStore;*/
280 public PHPeclipsePlugin() {
283 // externalTools = new ExternalToolsPlugin();
287 // ResourceBundle.getBundle("net.sourceforge.PHPeclipsePluginResources");
288 // } catch (MissingResourceException x) {
289 // resourceBundle = null;
294 // * Returns all Java editor text hovers contributed to the workbench.
296 // * @return an array of JavaEditorTextHoverDescriptor
299 // public JavaEditorTextHoverDescriptor[]
300 // getJavaEditorTextHoverDescriptors()
302 // if (fJavaEditorTextHoverDescriptors == null)
303 // fJavaEditorTextHoverDescriptors = JavaEditorTextHoverDescriptor
304 // .getContributedHovers();
305 // return fJavaEditorTextHoverDescriptors;
308 * Returns all Java editor text hovers contributed to the workbench.
310 * @return an array of JavaEditorTextHoverDescriptor
313 // public JavaEditorTextHoverDescriptor[] getJavaEditorTextHoverDescriptors() {
314 // if (fJavaEditorTextHoverDescriptors == null) {
315 // fJavaEditorTextHoverDescriptors = JavaEditorTextHoverDescriptor
316 // .getContributedHovers();
317 // ConfigurationElementSorter sorter = new ConfigurationElementSorter() {
319 // * @see org.eclipse.ui.texteditor.ConfigurationElementSorter#getConfigurationElement(java.lang.Object)
321 // public IConfigurationElement getConfigurationElement(
323 // return ((JavaEditorTextHoverDescriptor) object)
324 // .getConfigurationElement();
327 // sorter.sort(fJavaEditorTextHoverDescriptors);
329 // // The Problem hover has to be the first and the Annotation hover
331 // // be the last one in the JDT UI's hover list
332 // int length = fJavaEditorTextHoverDescriptors.length;
334 // int last = length - 1;
335 // int problemHoverIndex = -1;
336 // int annotationHoverIndex = -1;
337 // for (int i = 0; i < length; i++) {
338 // if (!fJavaEditorTextHoverDescriptors[i].getId().startsWith(
340 // if (problemHoverIndex == -1 || annotationHoverIndex == -1)
350 // if (fJavaEditorTextHoverDescriptors[i].getId().equals(
351 // "net.sourceforge.phpdt.ui.AnnotationHover")) { //$NON-NLS-1$
352 // annotationHoverIndex = i;
355 // if (fJavaEditorTextHoverDescriptors[i].getId().equals(
356 // "net.sourceforge.phpdt.ui.ProblemHover")) { //$NON-NLS-1$
357 // problemHoverIndex = i;
362 // JavaEditorTextHoverDescriptor hoverDescriptor = null;
364 // if (first > -1 && problemHoverIndex > -1
365 // && problemHoverIndex != first) {
366 // // move problem hover to beginning
367 // hoverDescriptor = fJavaEditorTextHoverDescriptors[first];
368 // fJavaEditorTextHoverDescriptors[first] = fJavaEditorTextHoverDescriptors[problemHoverIndex];
369 // fJavaEditorTextHoverDescriptors[problemHoverIndex] = hoverDescriptor;
371 // // update annotation hover index if needed
372 // if (annotationHoverIndex == first)
373 // annotationHoverIndex = problemHoverIndex;
376 // if (annotationHoverIndex > -1 && annotationHoverIndex != last) {
377 // // move annotation hover to end
378 // hoverDescriptor = fJavaEditorTextHoverDescriptors[last];
379 // fJavaEditorTextHoverDescriptors[last] = fJavaEditorTextHoverDescriptors[annotationHoverIndex];
380 // fJavaEditorTextHoverDescriptors[annotationHoverIndex] = hoverDescriptor;
383 // // Move Best Match hover to front
384 // for (int i = 0; i < fJavaEditorTextHoverDescriptors.length - 1; i++) {
385 // if (PreferenceConstants.ID_BESTMATCH_HOVER
386 // .equals(fJavaEditorTextHoverDescriptors[i].getId())) {
387 // hoverDescriptor = fJavaEditorTextHoverDescriptors[i];
388 // for (int j = i; j > 0; j--)
389 // fJavaEditorTextHoverDescriptors[j] = fJavaEditorTextHoverDescriptors[j - 1];
390 // fJavaEditorTextHoverDescriptors[0] = hoverDescriptor;
397 // return fJavaEditorTextHoverDescriptors;
401 * Resets the Java editor text hovers contributed to the workbench.
403 * This will force a rebuild of the descriptors the next time a client asks
407 * @return an array of JavaEditorTextHoverDescriptor
410 // public void resetJavaEditorTextHoverDescriptors() {
411 // fJavaEditorTextHoverDescriptors = null;
415 * Creates the PHP plugin standard groups in a context menu.
417 // public static void createStandardGroups(IMenuManager menu) {
418 // if (!menu.isEmpty())
420 // menu.add(new Separator(IContextMenuConstants.GROUP_NEW));
421 // menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO));
422 // menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
423 // menu.add(new GroupMarker(IContextMenuConstants.GROUP_SHOW));
424 // menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
425 // menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
426 // menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
427 // menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
428 // menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
429 // menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
430 // menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
433 // public static IWorkbenchPage getActivePage() {
434 // return getDefault().internalGetActivePage();
437 // public static Shell getActiveWorkbenchShell() {
438 // return getActiveWorkbenchWindow().getShell();
442 * Returns an array of all editors that have an unsaved content. If the
443 * identical content is presented in more than one editor, only one of those
444 * editor parts is part of the result.
446 * @return an array of all dirty editor parts.
448 // public static IEditorPart[] getDirtyEditors() {
449 // Set inputs = new HashSet();
450 // List result = new ArrayList(0);
451 // IWorkbench workbench = getDefault().getWorkbench();
452 // IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
453 // for (int i = 0; i < windows.length; i++) {
454 // IWorkbenchPage[] pages = windows[i].getPages();
455 // for (int x = 0; x < pages.length; x++) {
456 // IEditorPart[] editors = pages[x].getDirtyEditors();
457 // for (int z = 0; z < editors.length; z++) {
458 // IEditorPart ep = editors[z];
459 // IEditorInput input = ep.getEditorInput();
460 // if (!inputs.contains(input)) {
461 // inputs.add(input);
467 // return (IEditorPart[]) result.toArray(new IEditorPart[result.size()]);
470 // public static IWorkbenchWindow getActiveWorkbenchWindow() {
471 // return getDefault().getWorkbench().getActiveWorkbenchWindow();
475 * Returns the shared instance.
477 public static PHPeclipsePlugin getDefault() {
481 // public static ImageDescriptorRegistry getImageDescriptorRegistry() {
482 // return getDefault().internalGetImageDescriptorRegistry();
485 static IPath getInstallLocation() {
486 return new Path(getDefault().getBundle().getEntry("/").getFile());
489 // public static int getJVM() {
493 public static String getPluginId() {
494 return getDefault().getBundle().getSymbolicName();
498 * Returns the standard display to be used. The method first checks, if the
499 * thread calling this method has an associated display. If so, this display
500 * is returned. Otherwise the method returns the default display.
502 // public static Display getStandardDisplay() {
503 // Display display = Display.getCurrent();
504 // if (display == null) {
505 // display = Display.getDefault();
510 // public static ExternalToolsPlugin getExternalTools() {
511 // return externalTools;
514 * Returns the workspace instance.
516 public static IWorkspace getWorkspace() {
517 return ResourcesPlugin.getWorkspace();
520 public static boolean isDebug() {
521 return getDefault().isDebugging();
524 // public static void logErrorMessage(String message) {
525 // log(new Status(IStatus.ERROR, getPluginId(),
526 // JavaStatusConstants.INTERNAL_ERROR, message, null));
529 // public static void logErrorStatus(String message, IStatus status) {
530 // if (status == null) {
531 // logErrorMessage(message);
534 // MultiStatus multi= new MultiStatus(getPluginId(),
535 // JavaStatusConstants.INTERNAL_ERROR, message, null);
536 // multi.add(status);
540 // public static void log(Throwable e) {
541 // log(new Status(IStatus.ERROR, getPluginId(),
542 // JavaStatusConstants.INTERNAL_ERROR,
543 // JavaUIMessages.getString("JavaPlugin.internal_error"), e)); //$NON-NLS-1$
545 public static void log(int severity, String message) {
546 Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message,
551 public static void log(IStatus status) {
552 getDefault().getLog().log(status);
555 public static void log(Throwable t) {
559 public static void log(String message, Throwable t) {
560 log(error(message, t));
563 // public static void logErrorMessage(String message) {
564 // log(new Status(IStatus.ERROR, getPluginId(),
565 // IJavaStatusConstants.INTERNAL_ERROR, message, null));
568 public static IStatus error(Throwable t) {
569 return error("PHPeclipsePlugin.internalErrorOccurred", t); //$NON-NLS-1$
572 public static IStatus error(String message, Throwable t) {
573 return new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, t);
576 // private static void setJVM() {
577 // String osName = System.getProperty("os.name");
578 // if (osName.startsWith("Mac OS")) {
579 // String mrjVersion = System.getProperty("mrj.version");
580 // String majorMRJVersion = mrjVersion.substring(0, 3);
583 // double version = Double.valueOf(majorMRJVersion).doubleValue();
584 // if (version == 2) {
586 // } else if (version >= 2.1 && version < 3) {
588 // } else if (version == 3.0) {
590 // } else if (version >= 3.1) {
593 // } catch (NumberFormatException nfe) {
595 // } else if (osName.startsWith("Windows")) {
596 // if (osName.indexOf("9") != -1) {
604 // TODO: refactor this into a better method name !
605 // public synchronized ICompilationUnitDocumentProvider getCompilationUnitDocumentProvider() {
606 // if (fCompilationUnitDocumentProvider == null)
607 // fCompilationUnitDocumentProvider = new PHPDocumentProvider();
608 // return fCompilationUnitDocumentProvider;
612 * Get the identifier index manager for the given project
615 * the current project
618 public IdentifierIndexManager getIndexManager(IProject iProject) {
619 IPath path = iProject.getWorkingLocation(PHPeclipsePlugin.PLUGIN_ID);
620 path = path.append("project.index");
621 String indexFilename = path.toString();
623 // IdentDB db = IdentDB.getInstance();
624 // } catch (ClassNotFoundException e) {
625 // e.printStackTrace();
626 // } catch (SQLException e) {
627 // e.printStackTrace();
629 IdentifierIndexManager indexManager = (IdentifierIndexManager) fIndexManagerMap
631 if (indexManager == null) {
632 indexManager = new IdentifierIndexManager(indexFilename);
633 fIndexManagerMap.put(indexFilename, indexManager);
638 // public synchronized IWorkingCopyManager getWorkingCopyManager() {
639 // if (fWorkingCopyManager == null) {
640 // ICompilationUnitDocumentProvider provider = getCompilationUnitDocumentProvider();
641 // fWorkingCopyManager = new WorkingCopyManager(provider);
643 // return fWorkingCopyManager;
646 // public synchronized MembersOrderPreferenceCache getMemberOrderPreferenceCache() {
647 // if (fMembersOrderPreferenceCache == null)
648 // fMembersOrderPreferenceCache = new MembersOrderPreferenceCache();
649 // return fMembersOrderPreferenceCache;
653 // * Returns the mockup preference store for firing events and registering
654 // * listeners on project setting changes. Temporary solution.
656 // public MockupPreferenceStore getMockupPreferenceStore() {
657 // if (fMockupPreferenceStore == null)
658 // fMockupPreferenceStore = new MockupPreferenceStore();
660 // return fMockupPreferenceStore;
663 // public synchronized ProblemMarkerManager getProblemMarkerManager() {
664 // if (fProblemMarkerManager == null)
665 // fProblemMarkerManager = new ProblemMarkerManager();
666 // return fProblemMarkerManager;
669 // public synchronized JavaTextTools getJavaTextTools() {
670 // if (fJavaTextTools == null)
671 // fJavaTextTools = new JavaTextTools(getPreferenceStore());
672 // return fJavaTextTools;
674 // public synchronized JavaTextTools getJavaTextTools() {
675 // if (fJavaTextTools == null)
676 // fJavaTextTools = new JavaTextTools(getPreferenceStore(), JavaCore
677 // .getPlugin().getPluginPreferences());
678 // return fJavaTextTools;
681 public IFile getLastEditorFile() {
682 return fLastEditorFile;
686 * Returns the string from the plugin's resource bundle, or 'key' if not
689 // public static String getResourceString(String key) {
690 // ResourceBundle bundle =
691 // PHPeclipsePlugin.getDefault().getResourceBundle();
693 // return bundle.getString(key);
694 // } catch (MissingResourceException e) {
699 * Returns the plugin's resource bundle,
701 // public ResourceBundle getResourceBundle() {
702 // return resourceBundle;
704 // protected void initializeDefaultPreferences(IPreferenceStore store) {
705 // String operatingSystem = Platform.getOS();
706 // // maxosx, linux, solaris, win32,...
708 // InputStream is = getDefault()
710 // new Path("prefs/default_" + operatingSystem
711 // + ".properties"));
712 // PropertyResourceBundle resourceBundle = new PropertyResourceBundle(
714 // Enumeration e = resourceBundle.getKeys();
716 // while (e.hasMoreElements()) {
717 // key = (String) e.nextElement();
718 // store.setDefault(key, resourceBundle.getString(key));
720 // } catch (Exception e) {
721 // // no default properties found
722 // if (operatingSystem.equals(Platform.OS_WIN32)) {
723 // // store.setDefault(PHP_RUN_PREF, "c:\\apache\\php\\php.exe");
724 // // store.setDefault(EXTERNAL_PARSER_PREF, "c:\\apache\\php\\php
726 // // store.setDefault(MYSQL_RUN_PREF,
727 // // "c:\\apache\\mysql\\bin\\mysqld-nt.exe");
728 // // store.setDefault(APACHE_RUN_PREF, "c:\\apache\\apache.exe");
729 // // store.setDefault(XAMPP_START_PREF,
730 // // "c:\\xampp\\xampp_start.exe");
731 // // store.setDefault(XAMPP_STOP_PREF,
732 // // "c:\\xampp\\xampp_stop.exe");
733 // // store.setDefault(
734 // // ETC_HOSTS_PATH_PREF,
735 // // "c:\\windows\\system32\\drivers\\etc\\hosts");
737 // // store.setDefault(PHP_RUN_PREF, "/apache/php/php");
738 // // store.setDefault(EXTERNAL_PARSER_PREF, "/apache/php/php -l -f
740 // // store.setDefault(MYSQL_RUN_PREF, "/apache/mysql/bin/mysqld");
741 // // store.setDefault(APACHE_RUN_PREF, "/apache/apache");
742 // // store.setDefault(XAMPP_START_PREF, "xamp/xampp_start");
743 // // store.setDefault(XAMPP_STOP_PREF, "xampp/xampp_stop");
745 // // store.setDefault(MYSQL_PREF, "--standalone");
746 // // store.setDefault(APACHE_START_PREF, "-c \"DocumentRoot
748 // // store.setDefault(APACHE_STOP_PREF, "-k shutdown");
749 // // store.setDefault(APACHE_RESTART_PREF, "-k restart");
750 // // store.setDefault(MYSQL_START_BACKGROUND, "true");
751 // // store.setDefault(APACHE_START_BACKGROUND, "true");
752 // // store.setDefault(APACHE_STOP_BACKGROUND, "true");
753 // // store.setDefault(APACHE_RESTART_BACKGROUND, "true");
756 // // php syntax highlighting
757 // store.setDefault(PHP_USERDEF_XMLFILE, "");
758 // PreferenceConverter.setDefault(store, PHP_TAG, PHPColorProvider.TAG);
759 // PreferenceConverter.setDefault(store, PHP_KEYWORD,
760 // PHPColorProvider.KEYWORD);
761 // PreferenceConverter.setDefault(store, PHP_VARIABLE,
762 // PHPColorProvider.VARIABLE);
763 // PreferenceConverter.setDefault(store, PHP_VARIABLE_DOLLAR,
764 // PHPColorProvider.VARIABLE);
765 // PreferenceConverter.setDefault(store, PHP_FUNCTIONNAME,
766 // PHPColorProvider.FUNCTION_NAME);
767 // PreferenceConverter.setDefault(store, PHP_CONSTANT,
768 // PHPColorProvider.CONSTANT);
769 // PreferenceConverter.setDefault(store, PHP_TYPE, PHPColorProvider.TYPE);
770 // PreferenceConverter.setDefault(store, PHP_DEFAULT,
771 // PHPColorProvider.DEFAULT);
772 // PreferenceConverter.setDefault(store, PHPDOC_KEYWORD,
773 // PHPColorProvider.PHPDOC_KEYWORD);
774 // PreferenceConverter.setDefault(store, PHPDOC_TAG,
775 // PHPColorProvider.PHPDOC_TAG);
776 // PreferenceConverter.setDefault(store, PHPDOC_LINK,
777 // PHPColorProvider.PHPDOC_LINK);
778 // PreferenceConverter.setDefault(store, PHPDOC_DEFAULT,
779 // PHPColorProvider.PHPDOC_DEFAULT);
781 // PreferenceConverter.setDefault(store, EDITOR_PHP_KEYWORD_RETURN_COLOR,
782 // new RGB(127, 0, 85));
783 // store.setDefault(EDITOR_PHP_KEYWORD_RETURN_BOLD, true);
784 // store.setDefault(EDITOR_PHP_KEYWORD_RETURN_ITALIC, false);
786 // PreferenceConverter.setDefault(store, EDITOR_PHP_OPERATOR_COLOR,
787 // new RGB(0, 0, 0));
788 // store.setDefault(EDITOR_PHP_OPERATOR_BOLD, false);
789 // store.setDefault(EDITOR_PHP_OPERATOR_ITALIC, false);
791 // PreferenceConverter.setDefault(store, EDITOR_PHP_BRACE_OPERATOR_COLOR,
792 // new RGB(0, 0, 0));
793 // store.setDefault(EDITOR_PHP_BRACE_OPERATOR_BOLD, false);
794 // store.setDefault(EDITOR_PHP_BRACE_OPERATOR_ITALIC, false);
796 // // this will initialize the static fields in the syntaxrdr class
797 // new PHPSyntaxRdr();
798 // JavaCore.initializeDefaultPluginPreferences();
799 // PreferenceConstants.initializeDefaultValues(store);
800 // // externalTools.initializeDefaultPreferences(store);
801 // // MarkerAnnotationPreferences.initializeDefaultValues(store);
804 // private IWorkbenchPage internalGetActivePage() {
805 // IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow();
806 // if (window != null)
807 // return window.getActivePage();
811 // private ImageDescriptorRegistry internalGetImageDescriptorRegistry() {
812 // if (fImageDescriptorRegistry == null)
813 // fImageDescriptorRegistry = new ImageDescriptorRegistry();
814 // return fImageDescriptorRegistry;
818 * Open a file in the Workbench that may or may not exist in the workspace.
819 * Must be run on the UI thread.
822 * @throws CoreException
824 // public ITextEditor openFileInTextEditor(String filename)
825 // throws CoreException {
826 // // reject directories
827 // if (new File(filename).isDirectory())
829 // IWorkbench workbench = PlatformUI.getWorkbench();
830 // IWorkbenchWindow window = workbench.getWorkbenchWindows()[0];
831 // IWorkbenchPage page = window.getActivePage();
832 // IPath path = new Path(filename);
833 // // If the file exists in the workspace, open it
834 // IFile file = getWorkspace().getRoot().getFile(path);
835 // IEditorPart editor;
836 // ITextEditor textEditor;
837 // if (file != null && file.exists()) {
838 // editor = IDE.openEditor(page, file, true);
839 // textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
841 // // Otherwise open the stream directly
844 // FileStorage storage = new FileStorage(path);
845 // IEditorRegistry registry = getWorkbench().getEditorRegistry();
846 // IEditorDescriptor desc = registry.getDefaultEditor(filename);
847 // if (desc == null) {
849 // .findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
850 // // desc = registry.getDefaultEditor();
852 // IEditorInput input = new ExternalEditorInput(storage);
853 // editor = page.openEditor(input, desc.getId());
854 // textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
855 // // If the storage provider is not ours, we can't guarantee
857 // if (textEditor != null) {
858 // IDocumentProvider documentProvider = textEditor
859 // .getDocumentProvider();
860 // if (!(documentProvider instanceof ExternalStorageDocumentProvider)) {
861 // storage.setReadOnly();
865 // return textEditor;
869 * Open a file in the Workbench that may or may not exist in the workspace.
870 * Must be run on the UI thread.
874 * @throws CoreException
876 // public void openFileAndGotoLine(String filename, int line)
877 // throws CoreException {
878 // ITextEditor textEditor = openFileInTextEditor(filename);
879 // if (textEditor != null) {
880 // // If a line number was given, go to it
883 // line--; // document is 0 based
884 // IDocument document = textEditor.getDocumentProvider()
885 // .getDocument(textEditor.getEditorInput());
886 // textEditor.selectAndReveal(document.getLineOffset(line),
887 // document.getLineLength(line));
888 // } catch (BadLocationException e) {
889 // // invalid text position -> do nothing
896 * Open a file in the Workbench that may or may not exist in the workspace.
897 * Must be run on the UI thread.
901 * @throws CoreException
903 // public void openFileAndGotoOffset(String filename, int offset, int length)
904 // throws CoreException {
905 // ITextEditor textEditor = openFileInTextEditor(filename);
906 // if (textEditor != null) {
907 // // If a line number was given, go to it
908 // if (offset >= 0) {
909 // IDocument document = textEditor.getDocumentProvider()
910 // .getDocument(textEditor.getEditorInput());
911 // textEditor.selectAndReveal(offset, length);
916 // public void openFileAndFindString(String filename, String findString)
917 // throws CoreException {
918 // ITextEditor textEditor = openFileInTextEditor(filename);
919 // if (textEditor != null) {
920 // // If a string was given, go to it
921 // if (findString != null) {
923 // IDocument document = textEditor.getDocumentProvider()
924 // .getDocument(textEditor.getEditorInput());
925 // int offset = document.search(0, findString, true, false,
927 // textEditor.selectAndReveal(offset, findString.length());
928 // } catch (BadLocationException e) {
929 // // invalid text position -> do nothing
935 public void setLastEditorFile(IFile textEditor) {
936 this.fLastEditorFile = textEditor;
940 * @see org.eclipse.core.runtime.Plugin#stop
942 // public void stop(BundleContext context) throws Exception {
944 // // JavaCore.stop(this, context);
945 // plugin.savePluginPreferences();
946 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
947 // workspace.removeResourceChangeListener(JavaModelManager
948 // .getJavaModelManager().deltaState);
949 // workspace.removeSaveParticipant(plugin);
951 // JavaModelManager.getJavaModelManager().shutdown();
953 // // save the information from the php index files if necessary
954 // Collection collection = fIndexManagerMap.values();
955 // Iterator iterator = collection.iterator();
956 // IdentifierIndexManager indexManager = null;
957 // while (iterator.hasNext()) {
958 // indexManager = (IdentifierIndexManager) iterator.next();
959 // indexManager.writeFile();
961 // if (fImageDescriptorRegistry != null)
962 // fImageDescriptorRegistry.dispose();
964 // // AllTypesCache.terminate();
966 // if (fImageDescriptorRegistry != null)
967 // fImageDescriptorRegistry.dispose();
969 // unregisterAdapters();
971 // // if (fASTProvider != null) {
972 // // fASTProvider.dispose();
973 // // fASTProvider= null;
976 // if (fWorkingCopyManager != null) {
977 // fWorkingCopyManager.shutdown();
978 // fWorkingCopyManager = null;
981 // if (fCompilationUnitDocumentProvider != null) {
982 // fCompilationUnitDocumentProvider.shutdown();
983 // fCompilationUnitDocumentProvider = null;
986 // if (fJavaTextTools != null) {
987 // fJavaTextTools.dispose();
988 // fJavaTextTools = null;
990 // // JavaDocLocations.shutdownJavadocLocations();
992 // uninstallPreferenceStoreBackwardsCompatibility();
994 // // RefactoringCore.getUndoManager().shutdown();
996 // super.stop(context);
1001 * Installs backwards compatibility for the preference store.
1003 // private void installPreferenceStoreBackwardsCompatibility() {
1006 // * Installs backwards compatibility: propagate the Java editor font from
1007 // * a pre-2.1 plug-in to the Platform UI's preference store to preserve
1008 // * the Java editor font from a pre-2.1 workspace. This is done only
1011 // String fontPropagatedKey = "fontPropagated"; //$NON-NLS-1$
1012 // if (getPreferenceStore().contains(JFaceResources.TEXT_FONT)
1013 // && !getPreferenceStore().isDefault(JFaceResources.TEXT_FONT)) {
1014 // if (!getPreferenceStore().getBoolean(fontPropagatedKey))
1015 // PreferenceConverter
1016 // .setValue(PlatformUI.getWorkbench()
1017 // .getPreferenceStore(),
1018 // PreferenceConstants.EDITOR_TEXT_FONT,
1019 // PreferenceConverter.getFontDataArray(
1020 // getPreferenceStore(),
1021 // JFaceResources.TEXT_FONT));
1023 // getPreferenceStore().setValue(fontPropagatedKey, true);
1026 // * Backwards compatibility: set the Java editor font in this plug-in's
1027 // * preference store to let older versions access it. Since 2.1 the Java
1028 // * editor font is managed by the workbench font preference page.
1030 // PreferenceConverter.putValue(getPreferenceStore(),
1031 // JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry()
1032 // .getFontData(PreferenceConstants.EDITOR_TEXT_FONT));
1034 // fFontPropertyChangeListener = new IPropertyChangeListener() {
1035 // public void propertyChange(PropertyChangeEvent event) {
1036 // if (PreferenceConstants.EDITOR_TEXT_FONT.equals(event
1038 // PreferenceConverter.putValue(getPreferenceStore(),
1039 // JFaceResources.TEXT_FONT,
1040 // JFaceResources.getFontRegistry().getFontData(
1041 // PreferenceConstants.EDITOR_TEXT_FONT));
1044 // JFaceResources.getFontRegistry().addListener(
1045 // fFontPropertyChangeListener);
1049 * Uninstalls backwards compatibility for the preference store.
1051 // private void uninstallPreferenceStoreBackwardsCompatibility() {
1052 // JFaceResources.getFontRegistry().removeListener(
1053 // fFontPropertyChangeListener);
1054 // // getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
1058 * (non - Javadoc) Method declared in Plugin
1060 // public void start(BundleContext context) throws Exception {
1061 // super.start(context);
1063 // // JavaCore.start(this, context);
1064 // final JavaModelManager modelManager = JavaModelManager
1065 // .getJavaModelManager();
1067 // modelManager.configurePluginDebugOptions();
1069 // // request state folder creation (workaround 19885)
1070 // getStateLocation();
1071 // // retrieve variable values
1072 // PHPeclipsePlugin.getDefault().getPluginPreferences()
1073 // .addPropertyChangeListener(
1074 // new JavaModelManager.PluginPreferencesListener());
1075 // // manager.loadVariablesAndContainers();
1077 // final IWorkspace workspace = ResourcesPlugin.getWorkspace();
1078 // workspace.addResourceChangeListener(modelManager.deltaState,
1079 // IResourceChangeEvent.PRE_BUILD
1080 // | IResourceChangeEvent.POST_BUILD
1081 // | IResourceChangeEvent.POST_CHANGE
1082 // | IResourceChangeEvent.PRE_DELETE
1083 // | IResourceChangeEvent.PRE_CLOSE);
1085 // ISavedState savedState = workspace.addSaveParticipant(
1086 // PHPeclipsePlugin.this, modelManager);
1088 // // process deltas since last activated in indexer thread so that
1089 // // indexes are up-to-date.
1090 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658
1091 //// This causes timeout at EclipseLazyStarter
1092 //// Job processSavedState = new Job(Util.bind("savedState.jobName")) { //$NON-NLS-1$
1093 //// protected IStatus run(IProgressMonitor monitor) {
1095 //// // add save participant and process delta atomically
1097 //// // https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937
1098 //// workspace.run(new IWorkspaceRunnable() {
1099 //// public void run(IProgressMonitor progress)
1100 //// throws CoreException {
1101 //// ISavedState savedState = workspace
1102 //// .addSaveParticipant(
1103 //// PHPeclipsePlugin.this,
1105 //// if (savedState != null) {
1106 //// // the event type coming from the saved
1107 //// // state is always POST_AUTO_BUILD
1108 //// // force it to be POST_CHANGE so that the
1109 //// // delta processor can handle it
1110 //// modelManager.deltaState.getDeltaProcessor().overridenEventType = IResourceChangeEvent.POST_CHANGE;
1112 //// .processResourceChangeEvents(modelManager.deltaState);
1116 //// } catch (CoreException e) {
1117 //// return e.getStatus();
1119 //// return Status.OK_STATUS;
1122 //// Replace Job + IWorkspace.run() to WorkspaceJob
1123 // WorkspaceJob processSavedState = new WorkspaceJob(
1124 // Util.bind("savedState.jobName")) { //$NON-NLS-1$
1125 // public IStatus runInWorkspace(IProgressMonitor monitor)
1126 // throws CoreException {
1127 // ISavedState savedState = workspace.addSaveParticipant(
1128 // PHPeclipsePlugin.this, modelManager);
1129 // if (savedState != null) {
1130 // modelManager.deltaState.getDeltaProcessor().overridenEventType
1131 // = IResourceChangeEvent.POST_CHANGE;
1132 // savedState.processResourceChangeEvents(modelManager.deltaState);
1134 // return Status.OK_STATUS;
1137 // processSavedState.setSystem(true);
1138 // processSavedState.setPriority(Job.SHORT); // process asap
1139 // processSavedState.schedule();
1140 // } catch (RuntimeException e) {
1141 // modelManager.shutdown();
1145 // registerAdapters();
1147 // // if (USE_WORKING_COPY_OWNERS) {
1148 // WorkingCopyOwner.setPrimaryBufferProvider(new WorkingCopyOwner() {
1149 // public IBuffer createBuffer(ICompilationUnit workingCopy) {
1150 // ICompilationUnit original = workingCopy.getPrimary();
1151 // IResource resource = original.getResource();
1152 // if (resource instanceof IFile)
1153 // return new DocumentAdapter(workingCopy, (IFile) resource);
1154 // return DocumentAdapter.NULL;
1159 // installPreferenceStoreBackwardsCompatibility();
1163 // private void registerAdapters() {
1164 // fJavaElementAdapterFactory = new JavaElementAdapterFactory();
1165 // fResourceAdapterFactory = new ResourceAdapterFactory();
1167 // IAdapterManager manager = Platform.getAdapterManager();
1169 // .registerAdapters(fJavaElementAdapterFactory,
1170 // IJavaElement.class);
1171 // manager.registerAdapters(fResourceAdapterFactory, IResource.class);
1174 // private void unregisterAdapters() {
1175 // IAdapterManager manager = Platform.getAdapterManager();
1176 // manager.unregisterAdapters(fJavaElementAdapterFactory);
1177 // manager.unregisterAdapters(fResourceAdapterFactory);
1181 * Returns a combined preference store, this store is read-only.
1183 * @return the combined preference store
1187 // public IPreferenceStore getCombinedPreferenceStore() {
1188 // if (fCombinedPreferenceStore == null) {
1189 // IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
1190 // fCombinedPreferenceStore = new ChainedPreferenceStore(
1191 // new IPreferenceStore[] {
1192 // getPreferenceStore(),
1193 // new PreferencesAdapter(PHPeclipsePlugin
1194 // .getDefault().getPluginPreferences()),
1195 // generalTextStore });
1197 // return fCombinedPreferenceStore;
1200 public synchronized IBufferFactory getBufferFactory() {
1201 if (fBufferFactory == null)
1202 fBufferFactory = new CustomBufferFactory();
1203 return fBufferFactory;
1207 * Returns the registry of the extensions to the
1208 * <code>net.sourceforge.phpdt.ui.javaFoldingStructureProvider</code>
1211 * @return the registry of contributed
1212 * <code>IJavaFoldingStructureProvider</code>
1215 // public synchronized JavaFoldingStructureProviderRegistry getFoldingStructureProviderRegistry() {
1216 // if (fFoldingStructureProviderRegistry == null)
1217 // fFoldingStructureProviderRegistry = new JavaFoldingStructureProviderRegistry();
1218 // return fFoldingStructureProviderRegistry;
1222 * Runs the given action as an atomic Java model operation.
1224 * After running a method that modifies java elements, registered listeners
1225 * receive after-the-fact notification of what just transpired, in the form
1226 * of a element changed event. This method allows clients to call a number
1227 * of methods that modify java elements and only have element changed event
1228 * notifications reported at the end of the entire batch.
1231 * If this method is called outside the dynamic scope of another such call,
1232 * this method runs the action and then reports a single element changed
1233 * event describing the net effect of all changes done to java elements by
1237 * If this method is called in the dynamic scope of another such call, this
1238 * method simply runs the action.
1242 * the action to perform
1244 * a progress monitor, or <code>null</code> if progress
1245 * reporting and cancellation are not desired
1246 * @exception CoreException
1247 * if the operation failed.
1250 public static void run(IWorkspaceRunnable action, IProgressMonitor monitor)
1251 throws CoreException {
1252 run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor);
1256 * Runs the given action as an atomic Java model operation.
1258 * After running a method that modifies java elements, registered listeners
1259 * receive after-the-fact notification of what just transpired, in the form
1260 * of a element changed event. This method allows clients to call a number
1261 * of methods that modify java elements and only have element changed event
1262 * notifications reported at the end of the entire batch.
1265 * If this method is called outside the dynamic scope of another such call,
1266 * this method runs the action and then reports a single element changed
1267 * event describing the net effect of all changes done to java elements by
1271 * If this method is called in the dynamic scope of another such call, this
1272 * method simply runs the action.
1275 * The supplied scheduling rule is used to determine whether this operation
1276 * can be run simultaneously with workspace changes in other threads. See
1277 * <code>IWorkspace.run(...)</code> for more details.
1281 * the action to perform
1283 * the scheduling rule to use when running this operation, or
1284 * <code>null</code> if there are no scheduling restrictions
1285 * for this operation.
1287 * a progress monitor, or <code>null</code> if progress
1288 * reporting and cancellation are not desired
1289 * @exception CoreException
1290 * if the operation failed.
1293 public static void run(IWorkspaceRunnable action, ISchedulingRule rule,
1294 IProgressMonitor monitor) throws CoreException {
1295 IWorkspace workspace = ResourcesPlugin.getWorkspace();
1296 if (workspace.isTreeLocked()) {
1297 new BatchOperation(action).run(monitor);
1299 // use IWorkspace.run(...) to ensure that a build will be done in
1301 workspace.run(new BatchOperation(action), rule,
1302 IWorkspace.AVOID_UPDATE, monitor);
1307 * Returns the template context type registry for the java plugin.
1309 * @return the template context type registry for the java plugin
1312 // public ContextTypeRegistry getTemplateContextRegistry() {
1313 // if (fContextTypeRegistry == null) {
1314 // fContextTypeRegistry = new ContributionContextTypeRegistry();
1316 // fContextTypeRegistry.addContextType(new JavaContextType());
1317 // fContextTypeRegistry.addContextType(new JavaDocContextType());
1318 // fContextTypeRegistry.addContextType(new HTMLContextType());
1321 // return fContextTypeRegistry;
1325 * Returns the template store for the java editor templates.
1327 * @return the template store for the java editor templates
1330 // public TemplateStore getTemplateStore() {
1331 // if (fTemplateStore == null) {
1332 // fTemplateStore = new ContributionTemplateStore(
1333 // getTemplateContextRegistry(), getPreferenceStore(),
1336 // fTemplateStore.load();
1337 // } catch (IOException e) {
1342 // return fTemplateStore;
1346 * Returns the template context type registry for the code generation
1349 * @return the template context type registry for the code generation
1353 // public ContextTypeRegistry getCodeTemplateContextRegistry() {
1354 // if (fCodeTemplateContextTypeRegistry == null) {
1355 // fCodeTemplateContextTypeRegistry = new ContributionContextTypeRegistry();
1357 // CodeTemplateContextType
1358 // .registerContextTypes(fCodeTemplateContextTypeRegistry);
1361 // return fCodeTemplateContextTypeRegistry;
1365 * Returns the template store for the code generation templates.
1367 * @return the template store for the code generation templates
1370 // public TemplateStore getCodeTemplateStore() {
1371 // if (fCodeTemplateStore == null) {
1372 // fCodeTemplateStore = new ContributionTemplateStore(
1373 // getCodeTemplateContextRegistry(), getPreferenceStore(),
1374 // CODE_TEMPLATES_KEY);
1376 // fCodeTemplateStore.load();
1377 // } catch (IOException e) {
1382 // return fCodeTemplateStore;