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
9 IBM Corporation - Initial implementation
10 Klaus Hartlage - www.eclipseproject.de
11 **********************************************************************/
12 package net.sourceforge.phpeclipse;
15 import java.util.ArrayList;
16 import java.util.Collection;
17 import java.util.HashMap;
18 import java.util.HashSet;
19 import java.util.Iterator;
20 import java.util.List;
23 import net.sourceforge.phpdt.core.IBuffer;
24 import net.sourceforge.phpdt.core.IBufferFactory;
25 import net.sourceforge.phpdt.core.ICompilationUnit;
26 import net.sourceforge.phpdt.core.IJavaElement;
27 import net.sourceforge.phpdt.core.JavaCore;
28 import net.sourceforge.phpdt.core.WorkingCopyOwner;
29 import net.sourceforge.phpdt.externaltools.internal.model.ColorManager;
30 import net.sourceforge.phpdt.externaltools.internal.model.ExternalToolsPlugin;
31 import net.sourceforge.phpdt.externaltools.internal.model.VariableContextManager;
32 import net.sourceforge.phpdt.internal.core.BatchOperation;
33 import net.sourceforge.phpdt.internal.core.JavaModelManager;
34 import net.sourceforge.phpdt.internal.core.util.Util;
35 import net.sourceforge.phpdt.internal.ui.IJavaStatusConstants;
36 import net.sourceforge.phpdt.internal.ui.JavaElementAdapterFactory;
37 import net.sourceforge.phpdt.internal.ui.ResourceAdapterFactory;
38 import net.sourceforge.phpdt.internal.ui.preferences.MembersOrderPreferenceCache;
39 import net.sourceforge.phpdt.internal.ui.preferences.MockupPreferenceStore;
40 import net.sourceforge.phpdt.internal.ui.preferences.TemplatePreferencePage;
41 import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter;
42 import net.sourceforge.phpdt.internal.ui.text.folding.JavaFoldingStructureProviderRegistry;
43 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
44 import net.sourceforge.phpdt.internal.ui.viewsupport.ImageDescriptorRegistry;
45 import net.sourceforge.phpdt.internal.ui.viewsupport.ProblemMarkerManager;
46 import net.sourceforge.phpdt.ui.IContextMenuConstants;
47 import net.sourceforge.phpdt.ui.IWorkingCopyManager;
48 import net.sourceforge.phpdt.ui.PreferenceConstants;
49 import net.sourceforge.phpdt.ui.text.JavaTextTools;
50 import net.sourceforge.phpeclipse.builder.ExternalEditorInput;
51 import net.sourceforge.phpeclipse.builder.ExternalStorageDocumentProvider;
52 import net.sourceforge.phpeclipse.builder.FileStorage;
53 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
54 import net.sourceforge.phpeclipse.phpeditor.CustomBufferFactory;
55 import net.sourceforge.phpeclipse.phpeditor.DocumentAdapter;
56 import net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider;
57 import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr;
58 import net.sourceforge.phpeclipse.phpeditor.WorkingCopyManager;
59 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
61 import org.eclipse.core.resources.IFile;
62 import org.eclipse.core.resources.IProject;
63 import org.eclipse.core.resources.IResource;
64 import org.eclipse.core.resources.IResourceChangeEvent;
65 import org.eclipse.core.resources.ISavedState;
66 import org.eclipse.core.resources.IWorkspace;
67 import org.eclipse.core.resources.IWorkspaceRunnable;
68 import org.eclipse.core.resources.ResourcesPlugin;
69 import org.eclipse.core.runtime.CoreException;
70 import org.eclipse.core.runtime.IAdapterManager;
71 import org.eclipse.core.runtime.IConfigurationElement;
72 import org.eclipse.core.runtime.IPath;
73 import org.eclipse.core.runtime.IPluginDescriptor;
74 import org.eclipse.core.runtime.IProgressMonitor;
75 import org.eclipse.core.runtime.IStatus;
76 import org.eclipse.core.runtime.Path;
77 import org.eclipse.core.runtime.Platform;
78 import org.eclipse.core.runtime.Status;
79 import org.eclipse.core.runtime.jobs.ISchedulingRule;
80 import org.eclipse.core.runtime.jobs.Job;
81 import org.eclipse.jface.action.GroupMarker;
82 import org.eclipse.jface.action.IMenuManager;
83 import org.eclipse.jface.action.Separator;
84 import org.eclipse.jface.preference.IPreferenceStore;
85 import org.eclipse.jface.preference.PreferenceConverter;
86 import org.eclipse.jface.resource.JFaceResources;
87 import org.eclipse.jface.text.BadLocationException;
88 import org.eclipse.jface.text.IDocument;
89 import org.eclipse.jface.util.IPropertyChangeListener;
90 import org.eclipse.jface.util.PropertyChangeEvent;
91 import org.eclipse.swt.graphics.RGB;
92 import org.eclipse.swt.widgets.Display;
93 import org.eclipse.swt.widgets.Shell;
94 import org.eclipse.ui.IEditorDescriptor;
95 import org.eclipse.ui.IEditorInput;
96 import org.eclipse.ui.IEditorPart;
97 import org.eclipse.ui.IEditorRegistry;
98 import org.eclipse.ui.IWorkbench;
99 import org.eclipse.ui.IWorkbenchPage;
100 import org.eclipse.ui.IWorkbenchWindow;
101 import org.eclipse.ui.PlatformUI;
102 import org.eclipse.ui.editors.text.EditorsUI;
103 import org.eclipse.ui.ide.IDE;
104 import org.eclipse.ui.plugin.AbstractUIPlugin;
105 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
106 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
107 import org.eclipse.ui.texteditor.ConfigurationElementSorter;
108 import org.eclipse.ui.texteditor.IDocumentProvider;
109 import org.eclipse.ui.texteditor.ITextEditor;
110 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
111 import org.osgi.framework.BundleContext;
114 * The main plugin class to be used in the desktop.
116 public class PHPeclipsePlugin extends AbstractUIPlugin implements
117 IPreferenceConstants {
119 * The id of the PHP plugin (value <code>"net.sourceforge.phpeclipse"</code>).
121 public static final String PLUGIN_ID = "net.sourceforge.phpeclipse"; //$NON-NLS-1$
124 * id of builder - matches plugin.xml (concatenate pluginid.builderid)
126 public static final String BUILDER_PARSER_ID = PLUGIN_ID + ".parserbuilder";
128 //public static final String BUILDER_INDEX_ID = PLUGIN_ID + ".indexbuilder";
129 /** General debug flag */
130 public static final boolean DEBUG = false;
133 * The maximum number of allowed proposals by category
135 public final static int MAX_PROPOSALS = 200;
137 private static ExternalToolsPlugin externalTools;
140 * The Java virtual machine that we are running on.
142 private static int jvm;
145 private static final int MRJ_2_0 = 0;
147 /** MRJ 2.1 or later */
148 private static final int MRJ_2_1 = 1;
150 /** Java on Mac OS X 10.0 (MRJ 3.0) */
151 private static final int MRJ_3_0 = 3;
154 private static final int MRJ_3_1 = 4;
156 /** JVM constant for any other platform */
157 private static final int OTHER = -1;
159 // public static final String PHP_RESOURCES_VIEW_ID = PLUGIN_ID +
160 // ".resourcesview.ViewPHPResources"; //$NON-NLS-1$
161 public static final String PHP_CODING_ACTION_SET_ID = PLUGIN_ID
162 + ".ui.CodingActionSet"; //$NON-NLS-1$
164 public final static String PHP_NATURE_ID = PLUGIN_ID + ".phpnature";
166 public static final String PHPPARSER_ORIGINAL = "net.sourceforge.phpdt.internal.compiler.parser.Parser";
168 public static final String PHPPARSER_NEW = "test.PHPParser";
170 /** Change this if you want to switch PHP Parser. */
171 public static final String PHPPARSER = PHPPARSER_ORIGINAL;
173 //The shared instance.
174 private static PHPeclipsePlugin plugin;
177 private static final int WINDOWS_9x = 6;
180 private static final int WINDOWS_NT = 5;
182 private ImageDescriptorRegistry fImageDescriptorRegistry;
184 private HashMap fIndexManagerMap = new HashMap();
186 private IWorkingCopyManager fWorkingCopyManager;
188 private IBufferFactory fBufferFactory;
190 private PHPDocumentProvider fCompilationUnitDocumentProvider;
192 private JavaTextTools fJavaTextTools;
194 private ProblemMarkerManager fProblemMarkerManager;
196 private MembersOrderPreferenceCache fMembersOrderPreferenceCache;
198 private IFile fLastEditorFile = null;
200 private JavaEditorTextHoverDescriptor[] fJavaEditorTextHoverDescriptors;
202 private JavaElementAdapterFactory fJavaElementAdapterFactory;
204 // private MarkerAdapterFactory fMarkerAdapterFactory;
205 // private EditorInputAdapterFactory fEditorInputAdapterFactory;
206 private ResourceAdapterFactory fResourceAdapterFactory;
208 // private LogicalPackageAdapterFactory fLogicalPackageAdapterFactory;
209 private IPropertyChangeListener fFontPropertyChangeListener;
212 * Property change listener on this plugin's preference store.
216 private IPropertyChangeListener fPropertyChangeListener;
219 * The combined preference store.
223 private IPreferenceStore fCombinedPreferenceStore;
226 * The extension point registry for the
227 * <code>org.eclipse.jdt.ui.javaFoldingStructureProvider</code> extension
232 private JavaFoldingStructureProviderRegistry fFoldingStructureProviderRegistry;
235 * Mockup preference store for firing events and registering listeners on
236 * project setting changes. FIXME: Temporary solution.
240 private MockupPreferenceStore fMockupPreferenceStore;
245 public PHPeclipsePlugin(IPluginDescriptor descriptor) {
249 externalTools = new ExternalToolsPlugin();
252 // ResourceBundle.getBundle("net.sourceforge.PHPeclipsePluginResources");
253 // } catch (MissingResourceException x) {
254 // resourceBundle = null;
259 // * Returns all Java editor text hovers contributed to the workbench.
261 // * @return an array of JavaEditorTextHoverDescriptor
264 // public JavaEditorTextHoverDescriptor[] getJavaEditorTextHoverDescriptors()
266 // if (fJavaEditorTextHoverDescriptors == null)
267 // fJavaEditorTextHoverDescriptors = JavaEditorTextHoverDescriptor
268 // .getContributedHovers();
269 // return fJavaEditorTextHoverDescriptors;
272 * Returns all Java editor text hovers contributed to the workbench.
274 * @return an array of JavaEditorTextHoverDescriptor
277 public JavaEditorTextHoverDescriptor[] getJavaEditorTextHoverDescriptors() {
278 if (fJavaEditorTextHoverDescriptors == null) {
279 fJavaEditorTextHoverDescriptors = JavaEditorTextHoverDescriptor
280 .getContributedHovers();
281 ConfigurationElementSorter sorter = new ConfigurationElementSorter() {
283 * @see org.eclipse.ui.texteditor.ConfigurationElementSorter#getConfigurationElement(java.lang.Object)
285 public IConfigurationElement getConfigurationElement(Object object) {
286 return ((JavaEditorTextHoverDescriptor) object)
287 .getConfigurationElement();
290 sorter.sort(fJavaEditorTextHoverDescriptors);
292 // The Problem hover has to be the first and the Annotation hover has to
293 // be the last one in the JDT UI's hover list
294 int length = fJavaEditorTextHoverDescriptors.length;
296 int last = length - 1;
297 int problemHoverIndex = -1;
298 int annotationHoverIndex = -1;
299 for (int i = 0; i < length; i++) {
300 if (!fJavaEditorTextHoverDescriptors[i].getId().startsWith(PLUGIN_ID)) {
301 if (problemHoverIndex == -1 || annotationHoverIndex == -1)
311 if (fJavaEditorTextHoverDescriptors[i].getId().equals(
312 "net.sourceforge.phpdt.ui.AnnotationHover")) { //$NON-NLS-1$
313 annotationHoverIndex = i;
316 if (fJavaEditorTextHoverDescriptors[i].getId().equals(
317 "net.sourceforge.phpdt.ui.ProblemHover")) { //$NON-NLS-1$
318 problemHoverIndex = i;
323 JavaEditorTextHoverDescriptor hoverDescriptor = null;
325 if (first > -1 && problemHoverIndex > -1 && problemHoverIndex != first) {
326 // move problem hover to beginning
327 hoverDescriptor = fJavaEditorTextHoverDescriptors[first];
328 fJavaEditorTextHoverDescriptors[first] = fJavaEditorTextHoverDescriptors[problemHoverIndex];
329 fJavaEditorTextHoverDescriptors[problemHoverIndex] = hoverDescriptor;
331 // update annotation hover index if needed
332 if (annotationHoverIndex == first)
333 annotationHoverIndex = problemHoverIndex;
336 if (annotationHoverIndex > -1 && annotationHoverIndex != last) {
337 // move annotation hover to end
338 hoverDescriptor = fJavaEditorTextHoverDescriptors[last];
339 fJavaEditorTextHoverDescriptors[last] = fJavaEditorTextHoverDescriptors[annotationHoverIndex];
340 fJavaEditorTextHoverDescriptors[annotationHoverIndex] = hoverDescriptor;
343 // Move Best Match hover to front
344 for (int i = 0; i < fJavaEditorTextHoverDescriptors.length - 1; i++) {
345 if (PreferenceConstants.ID_BESTMATCH_HOVER
346 .equals(fJavaEditorTextHoverDescriptors[i].getId())) {
347 hoverDescriptor = fJavaEditorTextHoverDescriptors[i];
348 for (int j = i; j > 0; j--)
349 fJavaEditorTextHoverDescriptors[j] = fJavaEditorTextHoverDescriptors[j - 1];
350 fJavaEditorTextHoverDescriptors[0] = hoverDescriptor;
357 return fJavaEditorTextHoverDescriptors;
361 * Resets the Java editor text hovers contributed to the workbench.
363 * This will force a rebuild of the descriptors the next time a client asks
367 * @return an array of JavaEditorTextHoverDescriptor
370 public void resetJavaEditorTextHoverDescriptors() {
371 fJavaEditorTextHoverDescriptors = null;
375 * Creates the PHP plugin standard groups in a context menu.
377 public static void createStandardGroups(IMenuManager menu) {
380 menu.add(new Separator(IContextMenuConstants.GROUP_NEW));
381 menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO));
382 menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
383 menu.add(new GroupMarker(IContextMenuConstants.GROUP_SHOW));
384 menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
385 menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
386 menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
387 menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
388 menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
389 menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
390 menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
393 public static IWorkbenchPage getActivePage() {
394 return getDefault().internalGetActivePage();
397 public static Shell getActiveWorkbenchShell() {
398 return getActiveWorkbenchWindow().getShell();
402 * Returns an array of all editors that have an unsaved content. If the
403 * identical content is presented in more than one editor, only one of those
404 * editor parts is part of the result.
406 * @return an array of all dirty editor parts.
408 public static IEditorPart[] getDirtyEditors() {
409 Set inputs = new HashSet();
410 List result = new ArrayList(0);
411 IWorkbench workbench = getDefault().getWorkbench();
412 IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
413 for (int i = 0; i < windows.length; i++) {
414 IWorkbenchPage[] pages = windows[i].getPages();
415 for (int x = 0; x < pages.length; x++) {
416 IEditorPart[] editors = pages[x].getDirtyEditors();
417 for (int z = 0; z < editors.length; z++) {
418 IEditorPart ep = editors[z];
419 IEditorInput input = ep.getEditorInput();
420 if (!inputs.contains(input)) {
427 return (IEditorPart[]) result.toArray(new IEditorPart[result.size()]);
430 public static IWorkbenchWindow getActiveWorkbenchWindow() {
431 return getDefault().getWorkbench().getActiveWorkbenchWindow();
435 * Returns the shared instance.
437 public static PHPeclipsePlugin getDefault() {
441 public static ImageDescriptorRegistry getImageDescriptorRegistry() {
442 return getDefault().internalGetImageDescriptorRegistry();
445 static IPath getInstallLocation() {
446 return new Path(getDefault().getDescriptor().getInstallURL().getFile());
449 public static int getJVM() {
453 public static String getPluginId() {
454 return getDefault().getDescriptor().getUniqueIdentifier();
458 * Returns the standard display to be used. The method first checks, if the
459 * thread calling this method has an associated display. If so, this display
460 * is returned. Otherwise the method returns the default display.
462 public static Display getStandardDisplay() {
463 Display display = Display.getCurrent();
464 if (display == null) {
465 display = Display.getDefault();
470 // public static ExternalToolsPlugin getExternalTools() {
471 // return externalTools;
474 * Returns the workspace instance.
476 public static IWorkspace getWorkspace() {
477 return ResourcesPlugin.getWorkspace();
480 public static boolean isDebug() {
481 return getDefault().isDebugging();
484 // public static void logErrorMessage(String message) {
485 // log(new Status(IStatus.ERROR, getPluginId(),
486 // JavaStatusConstants.INTERNAL_ERROR, message, null));
489 // public static void logErrorStatus(String message, IStatus status) {
490 // if (status == null) {
491 // logErrorMessage(message);
494 // MultiStatus multi= new MultiStatus(getPluginId(),
495 // JavaStatusConstants.INTERNAL_ERROR, message, null);
496 // multi.add(status);
500 // public static void log(Throwable e) {
501 // log(new Status(IStatus.ERROR, getPluginId(),
502 // JavaStatusConstants.INTERNAL_ERROR,
503 // JavaUIMessages.getString("JavaPlugin.internal_error"), e)); //$NON-NLS-1$
505 public static void log(int severity, String message) {
506 Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message, null);
510 public static void log(IStatus status) {
511 getDefault().getLog().log(status);
514 public static void log(Throwable e) {
515 log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR,
516 "PHPeclipsePlugin.internalErrorOccurred", e)); //$NON-NLS-1$
519 public static void logErrorMessage(String message) {
520 log(new Status(IStatus.ERROR, getPluginId(),
521 IJavaStatusConstants.INTERNAL_ERROR, message, null));
524 private static void setJVM() {
525 String osName = System.getProperty("os.name");
526 if (osName.startsWith("Mac OS")) {
527 String mrjVersion = System.getProperty("mrj.version");
528 String majorMRJVersion = mrjVersion.substring(0, 3);
531 double version = Double.valueOf(majorMRJVersion).doubleValue();
534 } else if (version >= 2.1 && version < 3) {
536 } else if (version == 3.0) {
538 } else if (version >= 3.1) {
541 } catch (NumberFormatException nfe) {
543 } else if (osName.startsWith("Windows")) {
544 if (osName.indexOf("9") != -1) {
552 // TODO: refactor this into a better method name !
553 public synchronized PHPDocumentProvider getCompilationUnitDocumentProvider() {
554 if (fCompilationUnitDocumentProvider == null)
555 fCompilationUnitDocumentProvider = new PHPDocumentProvider();
556 return fCompilationUnitDocumentProvider;
560 * Get the identifier index manager for the given project
563 * the current project
566 public IdentifierIndexManager getIndexManager(IProject iProject) {
567 String indexFilename = iProject.getLocation() + File.separator
569 IdentifierIndexManager indexManager = (IdentifierIndexManager) fIndexManagerMap
571 if (indexManager == null) {
572 indexManager = new IdentifierIndexManager(indexFilename);
573 fIndexManagerMap.put(indexFilename, indexManager);
578 public synchronized IWorkingCopyManager getWorkingCopyManager() {
579 if (fWorkingCopyManager == null) {
580 PHPDocumentProvider provider = getCompilationUnitDocumentProvider();
581 fWorkingCopyManager = new WorkingCopyManager(provider);
583 return fWorkingCopyManager;
586 public synchronized MembersOrderPreferenceCache getMemberOrderPreferenceCache() {
587 if (fMembersOrderPreferenceCache == null)
588 fMembersOrderPreferenceCache = new MembersOrderPreferenceCache();
589 return fMembersOrderPreferenceCache;
593 * Returns the mockup preference store for firing events and registering
594 * listeners on project setting changes. Temporary solution.
596 public MockupPreferenceStore getMockupPreferenceStore() {
597 if (fMockupPreferenceStore == null)
598 fMockupPreferenceStore = new MockupPreferenceStore();
600 return fMockupPreferenceStore;
603 public synchronized ProblemMarkerManager getProblemMarkerManager() {
604 if (fProblemMarkerManager == null)
605 fProblemMarkerManager = new ProblemMarkerManager();
606 return fProblemMarkerManager;
609 public synchronized JavaTextTools getJavaTextTools() {
610 if (fJavaTextTools == null)
611 fJavaTextTools = new JavaTextTools(getPreferenceStore());
612 return fJavaTextTools;
615 public IFile getLastEditorFile() {
616 return fLastEditorFile;
620 * Returns the string from the plugin's resource bundle, or 'key' if not
623 // public static String getResourceString(String key) {
624 // ResourceBundle bundle = PHPeclipsePlugin.getDefault().getResourceBundle();
626 // return bundle.getString(key);
627 // } catch (MissingResourceException e) {
632 * Returns the plugin's resource bundle,
634 // public ResourceBundle getResourceBundle() {
635 // return resourceBundle;
637 protected void initializeDefaultPreferences(IPreferenceStore store) {
638 // windows preferences:
639 store.setDefault(LOCALHOST_PREF, "http://localhost");
640 // store.setDefault(SHOW_EXTERNAL_PREVIEW_PREF, "true");
641 store.setDefault(USE_EXTERNAL_BROWSER_PREF, "false");
642 store.setDefault(SHOW_OUTPUT_IN_CONSOLE, "true");
643 store.setDefault(PHP_OBFUSCATOR_DEFAULT, "c:\\temp");
644 store.setDefault(PHP_BOOKMARK_DEFAULT, "");
646 store.setDefault(PHP_AUTO_PREVIEW_DEFAULT, "true");
647 store.setDefault(PHP_BRING_TO_TOP_PREVIEW_DEFAULT, "true");
648 store.setDefault(PHP_SHOW_HTML_FILES_LOCAL, "true");
650 String windowsSystem = Platform.getWS();
651 if (jvm == WINDOWS_9x) {
652 store.setDefault(EXTERNAL_BROWSER_PREF,
653 "command.com /c start iexplore {0}");
654 } else if (windowsSystem.equals(Platform.WS_WIN32)) {
655 store.setDefault(EXTERNAL_BROWSER_PREF,
656 "rundll32 url.dll,FileProtocolHandler {0}");
657 } else if (windowsSystem.equals(Platform.WS_CARBON)) {
658 // TODO How do we start Safari on Mac OS X ?
659 store.setDefault(EXTERNAL_BROWSER_PREF, "netscape {0}");
661 store.setDefault(PHP_OBFUSCATOR_DEFAULT, "/tmp");
662 store.setDefault(EXTERNAL_BROWSER_PREF, "netscape {0}");
664 store.setDefault(DOCUMENTROOT_PREF, getWorkspace().getRoot().getLocation()
666 // if ((jvm == WINDOWS_9x) || (jvm == WINDOWS_NT)) {
668 if (windowsSystem.equals(Platform.WS_WIN32)) {
669 store.setDefault(PHP_RUN_PREF, "c:\\apache\\php\\php.exe");
670 store.setDefault(EXTERNAL_PARSER_PREF, "c:\\apache\\php\\php -l -f {0}");
671 store.setDefault(MYSQL_RUN_PREF, "c:\\apache\\mysql\\bin\\mysqld-nt.exe");
672 store.setDefault(APACHE_RUN_PREF, "c:\\apache\\apache.exe");
674 store.setDefault(PHP_RUN_PREF, "/apache/php/php");
675 store.setDefault(EXTERNAL_PARSER_PREF, "/apache/php/php -l -f {0}");
676 store.setDefault(MYSQL_RUN_PREF, "/apache/mysql/bin/mysqld");
677 store.setDefault(APACHE_RUN_PREF, "/apache/apache");
679 store.setDefault(MYSQL_PREF, "--standalone");
680 store.setDefault(APACHE_START_PREF, "-c \"DocumentRoot \"{0}\"\"");
681 store.setDefault(APACHE_STOP_PREF, "-k shutdown");
682 store.setDefault(APACHE_RESTART_PREF, "-k restart");
683 store.setDefault(MYSQL_START_BACKGROUND, "true");
684 store.setDefault(APACHE_START_BACKGROUND, "true");
685 store.setDefault(APACHE_STOP_BACKGROUND, "true");
686 store.setDefault(APACHE_RESTART_BACKGROUND, "true");
687 // store.setDefault(PHP_PARSER_DEFAULT, PHP_EXTERNAL_PARSER);
688 // store.setDefault(PHP_INTERNAL_PARSER, "false");
689 // store.setDefault(PHP_EXTERNAL_PARSER, "true");
690 // store.setDefault(PHP_PARSE_ON_SAVE, "true");
691 // show line numbers:
692 // store.setDefault(LINE_NUMBER_RULER, "false");
693 // store.setDefault(FORMATTER_TAB_SIZE, "4");
694 // php syntax highlighting
695 store.setDefault(PHP_USERDEF_XMLFILE, "");
696 //assume there is none chooA
697 PreferenceConverter.setDefault(store, PHP_MULTILINE_COMMENT,
698 PHPColorProvider.MULTI_LINE_COMMENT);
699 PreferenceConverter.setDefault(store, PHP_SINGLELINE_COMMENT,
700 PHPColorProvider.SINGLE_LINE_COMMENT);
701 PreferenceConverter.setDefault(store, PHP_TAG, PHPColorProvider.TAG);
703 .setDefault(store, PHP_KEYWORD, PHPColorProvider.KEYWORD);
704 PreferenceConverter.setDefault(store, PHP_VARIABLE,
705 PHPColorProvider.VARIABLE);
706 PreferenceConverter.setDefault(store, PHP_FUNCTIONNAME,
707 PHPColorProvider.FUNCTION_NAME);
708 PreferenceConverter.setDefault(store, PHP_CONSTANT,
709 PHPColorProvider.CONSTANT);
710 PreferenceConverter.setDefault(store, PHP_TYPE, PHPColorProvider.TYPE);
711 PreferenceConverter.setDefault(store, PHP_STRING, PHPColorProvider.STRING);
713 .setDefault(store, PHP_DEFAULT, PHPColorProvider.DEFAULT);
714 PreferenceConverter.setDefault(store, PHPDOC_KEYWORD,
715 PHPColorProvider.PHPDOC_KEYWORD);
716 PreferenceConverter.setDefault(store, PHPDOC_TAG,
717 PHPColorProvider.PHPDOC_TAG);
718 PreferenceConverter.setDefault(store, PHPDOC_LINK,
719 PHPColorProvider.PHPDOC_LINK);
720 PreferenceConverter.setDefault(store, PHPDOC_DEFAULT,
721 PHPColorProvider.PHPDOC_DEFAULT);
723 PreferenceConverter.setDefault(store, EDITOR_PHP_KEYWORD_RETURN_COLOR,
724 new RGB(127, 0, 85));
725 store.setDefault(EDITOR_PHP_KEYWORD_RETURN_BOLD, true);
726 store.setDefault(EDITOR_PHP_KEYWORD_RETURN_ITALIC, false);
728 PreferenceConverter.setDefault(store, EDITOR_PHP_OPERATOR_COLOR, new RGB(0,
730 store.setDefault(EDITOR_PHP_OPERATOR_BOLD, false);
731 store.setDefault(EDITOR_PHP_OPERATOR_ITALIC, false);
733 // PreferenceConverter.setDefault(
735 // PHP_EDITOR_BACKGROUND,
736 // PHPColorProvider.BACKGROUND);
737 // PreferenceConverter.setDefault(
739 // LINKED_POSITION_COLOR,
740 // PHPColorProvider.LINKED_POSITION_COLOR);
741 // PreferenceConverter.setDefault(
743 // LINE_NUMBER_COLOR,
744 // PHPColorProvider.LINE_NUMBER_COLOR);
745 // // set default PHPDoc colors:
746 // PreferenceConverter.setDefault(
749 // PHPColorProvider.PHPDOC_KEYWORD);
750 // PreferenceConverter.setDefault(
753 // PHPColorProvider.PHPDOC_LINK);
754 // PreferenceConverter.setDefault(
757 // PHPColorProvider.PHPDOC_DEFAULT);
758 // PreferenceConverter.setDefault(
761 // PHPColorProvider.PHPDOC_TAG);
762 // store.setDefault(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, "true");
763 // PreferenceConverter.setDefault(
765 // PREFERENCE_COLOR_BACKGROUND,
766 // PHPColorProvider.BACKGROUND_COLOR);
768 // store.setDefault(RESOURCE_BUNDLE, LANGUAGE_DEFAULT);
769 // store.setDefault(RESOURCE_BUNDLE_EN_GB, "true");
770 // store.setDefault(RESOURCE_BUNDLE_DE, "false");
771 // store.setDefault(RESOURCE_BUNDLE_FR, "false");
772 // store.setDefault(RESOURCE_BUNDLE_ES, "false");
773 TemplatePreferencePage.initDefaults(store);
774 //this will initialize the static fields in the syntaxrdr class
776 JavaCore.initializeDefaultPluginPreferences();
777 PreferenceConstants.initializeDefaultValues(store);
778 externalTools.initializeDefaultPreferences(store);
779 MarkerAnnotationPreferences.initializeDefaultValues(store);
782 private IWorkbenchPage internalGetActivePage() {
783 IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow();
785 return window.getActivePage();
789 private ImageDescriptorRegistry internalGetImageDescriptorRegistry() {
790 if (fImageDescriptorRegistry == null)
791 fImageDescriptorRegistry = new ImageDescriptorRegistry();
792 return fImageDescriptorRegistry;
796 * Open a file in the Workbench that may or may not exist in the workspace.
797 * Must be run on the UI thread.
800 * @throws CoreException
802 public ITextEditor openFileInTextEditor(String filename) throws CoreException {
803 // reject directories
804 if (new File(filename).isDirectory())
806 IWorkbench workbench = PlatformUI.getWorkbench();
807 IWorkbenchWindow window = workbench.getWorkbenchWindows()[0];
808 IWorkbenchPage page = window.getActivePage();
809 IPath path = new Path(filename);
810 // If the file exists in the workspace, open it
811 IFile file = getWorkspace().getRoot().getFileForLocation(path);
813 ITextEditor textEditor;
814 if (file != null && file.exists()) {
815 editor = IDE.openEditor(page, file, true);
816 textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
818 // Otherwise open the stream directly
821 FileStorage storage = new FileStorage(path);
822 IEditorRegistry registry = getWorkbench().getEditorRegistry();
823 IEditorDescriptor desc = registry.getDefaultEditor(filename);
825 desc = registry.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
826 // desc = registry.getDefaultEditor();
828 IEditorInput input = new ExternalEditorInput(storage);
829 editor = page.openEditor(input, desc.getId());
830 textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
831 // If the storage provider is not ours, we can't guarantee read/write.
832 if (textEditor != null) {
833 IDocumentProvider documentProvider = textEditor.getDocumentProvider();
834 if (!(documentProvider instanceof ExternalStorageDocumentProvider)) {
835 storage.setReadOnly();
843 * Open a file in the Workbench that may or may not exist in the workspace.
844 * Must be run on the UI thread.
848 * @throws CoreException
850 public void openFileAndGotoLine(String filename, int line)
851 throws CoreException {
852 ITextEditor textEditor = openFileInTextEditor(filename);
853 if (textEditor != null) {
854 // If a line number was given, go to it
857 line--; // document is 0 based
858 IDocument document = textEditor.getDocumentProvider().getDocument(
859 textEditor.getEditorInput());
860 textEditor.selectAndReveal(document.getLineOffset(line), document
861 .getLineLength(line));
862 } catch (BadLocationException e) {
863 // invalid text position -> do nothing
870 * Open a file in the Workbench that may or may not exist in the workspace.
871 * Must be run on the UI thread.
875 * @throws CoreException
877 public void openFileAndGotoOffset(String filename, int offset, int length)
878 throws CoreException {
879 ITextEditor textEditor = openFileInTextEditor(filename);
880 if (textEditor != null) {
881 // If a line number was given, go to it
883 IDocument document = textEditor.getDocumentProvider().getDocument(
884 textEditor.getEditorInput());
885 textEditor.selectAndReveal(offset, length);
890 public void openFileAndFindString(String filename, String findString)
891 throws CoreException {
892 ITextEditor textEditor = openFileInTextEditor(filename);
893 if (textEditor != null) {
894 // If a string was given, go to it
895 if (findString != null) {
897 IDocument document = textEditor.getDocumentProvider().getDocument(
898 textEditor.getEditorInput());
899 int offset = document.search(0, findString, true, false, true);
900 textEditor.selectAndReveal(offset, findString.length());
901 } catch (BadLocationException e) {
902 // invalid text position -> do nothing
908 public void setLastEditorFile(IFile textEditor) {
909 this.fLastEditorFile = textEditor;
913 * @see org.eclipse.core.runtime.Plugin#stop
915 public void stop(BundleContext context) throws Exception {
917 // JavaCore.stop(this, context);
918 plugin.savePluginPreferences();
919 IWorkspace workspace = ResourcesPlugin.getWorkspace();
920 workspace.removeResourceChangeListener(JavaModelManager
921 .getJavaModelManager().deltaState);
922 workspace.removeSaveParticipant(plugin);
924 JavaModelManager.getJavaModelManager().shutdown();
926 ColorManager.getDefault().dispose();
927 // save the information from the php index files if necessary
928 Collection collection = fIndexManagerMap.values();
929 Iterator iterator = collection.iterator();
930 IdentifierIndexManager indexManager = null;
931 while (iterator.hasNext()) {
932 indexManager = (IdentifierIndexManager) iterator.next();
933 indexManager.writeFile();
935 if (fImageDescriptorRegistry != null)
936 fImageDescriptorRegistry.dispose();
938 // AllTypesCache.terminate();
940 if (fImageDescriptorRegistry != null)
941 fImageDescriptorRegistry.dispose();
943 unregisterAdapters();
945 // if (fASTProvider != null) {
946 // fASTProvider.dispose();
947 // fASTProvider= null;
950 if (fWorkingCopyManager != null) {
951 fWorkingCopyManager.shutdown();
952 fWorkingCopyManager = null;
955 if (fCompilationUnitDocumentProvider != null) {
956 fCompilationUnitDocumentProvider.shutdown();
957 fCompilationUnitDocumentProvider = null;
960 if (fJavaTextTools != null) {
961 fJavaTextTools.dispose();
962 fJavaTextTools = null;
964 // JavaDocLocations.shutdownJavadocLocations();
966 uninstallPreferenceStoreBackwardsCompatibility();
968 // RefactoringCore.getUndoManager().shutdown();
975 * @see org.eclipse.ui.plugin.AbstractUIPlugin#shutdown()
977 // public void shutdown() throws CoreException {
978 // // moved down (see below):
979 // // super.shutdown();
980 // // externalTools.shutDown();
981 // ColorManager.getDefault().dispose();
982 // // save the information from the php index files if necessary
983 // Collection collection = fIndexManagerMap.values();
984 // Iterator iterator = collection.iterator();
985 // IdentifierIndexManager indexManager = null;
986 // while (iterator.hasNext()) {
987 // indexManager = (IdentifierIndexManager) iterator.next();
988 // indexManager.writeFile();
990 // if (fImageDescriptorRegistry != null)
991 // fImageDescriptorRegistry.dispose();
992 // // unregisterAdapters();
994 // if (fWorkingCopyManager != null) {
995 // fWorkingCopyManager.shutdown();
996 // fWorkingCopyManager = null;
998 // if (fCompilationUnitDocumentProvider != null) {
999 // fCompilationUnitDocumentProvider.shutdown();
1000 // fCompilationUnitDocumentProvider = null;
1002 // if (fJavaTextTools != null) {
1003 // fJavaTextTools.dispose();
1004 // fJavaTextTools = null;
1006 // // JavaDocLocations.shutdownJavadocLocations();
1009 // JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener);
1010 // // begin JavaCore#shutdown()
1011 // //savePluginPreferences();
1012 // savePluginPreferences();
1013 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
1014 // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaState);
1015 // workspace.removeSaveParticipant(this);
1016 // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
1017 // // end JavaCore#shutdown()
1020 * Installs backwards compatibility for the preference store.
1022 private void installPreferenceStoreBackwardsCompatibility() {
1025 * Installs backwards compatibility: propagate the Java editor font from a
1026 * pre-2.1 plug-in to the Platform UI's preference store to preserve the
1027 * Java editor font from a pre-2.1 workspace. This is done only once.
1029 String fontPropagatedKey = "fontPropagated"; //$NON-NLS-1$
1030 if (getPreferenceStore().contains(JFaceResources.TEXT_FONT)
1031 && !getPreferenceStore().isDefault(JFaceResources.TEXT_FONT)) {
1032 if (!getPreferenceStore().getBoolean(fontPropagatedKey))
1033 PreferenceConverter.setValue(PlatformUI.getWorkbench()
1034 .getPreferenceStore(), PreferenceConstants.EDITOR_TEXT_FONT,
1035 PreferenceConverter.getFontDataArray(getPreferenceStore(),
1036 JFaceResources.TEXT_FONT));
1038 getPreferenceStore().setValue(fontPropagatedKey, true);
1041 * Backwards compatibility: set the Java editor font in this plug-in's
1042 * preference store to let older versions access it. Since 2.1 the Java
1043 * editor font is managed by the workbench font preference page.
1045 PreferenceConverter.putValue(getPreferenceStore(),
1046 JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry().getFontData(
1047 PreferenceConstants.EDITOR_TEXT_FONT));
1049 fFontPropertyChangeListener = new IPropertyChangeListener() {
1050 public void propertyChange(PropertyChangeEvent event) {
1051 if (PreferenceConstants.EDITOR_TEXT_FONT.equals(event.getProperty()))
1052 PreferenceConverter.putValue(getPreferenceStore(),
1053 JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry()
1054 .getFontData(PreferenceConstants.EDITOR_TEXT_FONT));
1057 JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener);
1060 * Backwards compatibility: propagate the Java editor tab width from a
1061 * pre-3.0 plug-in to the new preference key. This is done only once.
1063 final String oldTabWidthKey = PreferenceConstants.EDITOR_TAB_WIDTH;
1064 final String newTabWidthKey = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH;
1065 String tabWidthPropagatedKey = "tabWidthPropagated"; //$NON-NLS-1$
1066 if (getPreferenceStore().contains(oldTabWidthKey)
1067 && !getPreferenceStore().isDefault(oldTabWidthKey)) {
1068 if (!getPreferenceStore().getBoolean(tabWidthPropagatedKey))
1069 getPreferenceStore().setValue(newTabWidthKey,
1070 getPreferenceStore().getInt(oldTabWidthKey));
1072 getPreferenceStore().setValue(tabWidthPropagatedKey, true);
1075 * Backwards compatibility: set the Java editor tab width in this plug-in's
1076 * preference store with the old key to let older versions access it. Since
1077 * 3.0 the tab width is managed by the extended texteditor and uses a new
1080 getPreferenceStore().putValue(oldTabWidthKey,
1081 getPreferenceStore().getString(newTabWidthKey));
1083 fPropertyChangeListener = new IPropertyChangeListener() {
1084 public void propertyChange(PropertyChangeEvent event) {
1085 if (newTabWidthKey.equals(event.getProperty()))
1086 getPreferenceStore().putValue(oldTabWidthKey,
1087 getPreferenceStore().getString(newTabWidthKey));
1090 getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
1093 * Backward compatibility for the refactoring preference key.
1095 // getPreferenceStore().setValue(
1096 // PreferenceConstants.REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD,
1097 // RefactoringCore.getConditionCheckingFailedSeverity());
1101 * Uninstalls backwards compatibility for the preference store.
1103 private void uninstallPreferenceStoreBackwardsCompatibility() {
1104 JFaceResources.getFontRegistry()
1105 .removeListener(fFontPropertyChangeListener);
1106 getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
1110 * (non - Javadoc) Method declared in Plugin
1112 public void start(BundleContext context) throws Exception {
1113 super.start(context);
1115 // JavaCore.start(this, context);
1116 final JavaModelManager manager = JavaModelManager.getJavaModelManager();
1118 manager.configurePluginDebugOptions();
1120 // request state folder creation (workaround 19885)
1121 // JavaCore.getPlugin().getStateLocation();
1123 // retrieve variable values
1124 //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
1125 // JavaModelManager.PluginPreferencesListener());
1126 // manager.loadVariablesAndContainers();
1128 final IWorkspace workspace = ResourcesPlugin.getWorkspace();
1129 workspace.addResourceChangeListener(manager.deltaState,
1130 IResourceChangeEvent.PRE_BUILD | IResourceChangeEvent.POST_BUILD
1131 | IResourceChangeEvent.POST_CHANGE
1132 | IResourceChangeEvent.PRE_DELETE
1133 | IResourceChangeEvent.PRE_CLOSE);
1137 // process deltas since last activated in indexer thread so that indexes
1139 // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658
1140 Job processSavedState = new Job(Util.bind("savedState.jobName")) { //$NON-NLS-1$
1141 protected IStatus run(IProgressMonitor monitor) {
1143 // add save participant and process delta atomically
1144 // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937
1145 workspace.run(new IWorkspaceRunnable() {
1146 public void run(IProgressMonitor progress) throws CoreException {
1147 ISavedState savedState = workspace.addSaveParticipant(
1148 PHPeclipsePlugin.this, manager);
1149 if (savedState != null) {
1150 // the event type coming from the saved state is always
1152 // force it to be POST_CHANGE so that the delta processor can
1154 manager.deltaState.getDeltaProcessor().overridenEventType = IResourceChangeEvent.POST_CHANGE;
1155 savedState.processResourceChangeEvents(manager.deltaState);
1159 } catch (CoreException e) {
1160 return e.getStatus();
1162 return Status.OK_STATUS;
1165 processSavedState.setSystem(true);
1166 processSavedState.setPriority(Job.SHORT); // process asap
1167 processSavedState.schedule();
1169 } catch (RuntimeException e) {
1176 // if (USE_WORKING_COPY_OWNERS) {
1177 WorkingCopyOwner.setPrimaryBufferProvider(new WorkingCopyOwner() {
1178 public IBuffer createBuffer(ICompilationUnit workingCopy) {
1179 ICompilationUnit original = workingCopy.getPrimary();
1180 IResource resource = original.getResource();
1181 if (resource instanceof IFile)
1182 return new DocumentAdapter(workingCopy, (IFile) resource);
1183 return DocumentAdapter.NULL;
1188 installPreferenceStoreBackwardsCompatibility();
1192 // registerAdapters();
1194 // // externalTools.startUp();
1195 // getStandardDisplay().asyncExec(new Runnable() {
1196 // public void run() {
1197 // //initialize the variable context manager
1198 // VariableContextManager.getDefault();
1202 // // if (USE_WORKING_COPY_OWNERS) {
1203 // WorkingCopyOwner.setPrimaryBufferProvider(new WorkingCopyOwner() {
1204 // public IBuffer createBuffer(ICompilationUnit workingCopy) {
1205 // ICompilationUnit original = workingCopy.getPrimary();
1206 // IResource resource = original.getResource();
1207 // if (resource instanceof IFile)
1208 // return new DocumentAdapter(workingCopy, (IFile) resource);
1209 // return DocumentAdapter.NULL;
1214 // installPreferenceStoreBackwardsCompatibility();
1216 // AllTypesCache.initialize();
1218 // Initialize AST provider
1219 // getASTProvider();
1222 // public void startup() throws CoreException {
1224 // // begin JavaCore.startup();
1225 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
1227 // manager.configurePluginDebugOptions();
1228 // // request state folder creation (workaround 19885)
1229 // // JavaCore.getPlugin().getStateLocation();
1230 // getStateLocation();
1231 // // retrieve variable values
1233 // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
1234 // // JavaModelManager.PluginPreferencesListener());
1235 // getPluginPreferences().addPropertyChangeListener(
1236 // new JavaModelManager.PluginPreferencesListener());
1237 // // TODO khartlage temp-del
1238 // // manager.loadVariablesAndContainers();
1239 // final IWorkspace workspace = ResourcesPlugin.getWorkspace();
1240 // workspace.addResourceChangeListener(
1241 // manager.deltaState,
1242 // IResourceChangeEvent.PRE_BUILD
1243 // | IResourceChangeEvent.POST_BUILD
1244 // | IResourceChangeEvent.POST_CHANGE
1245 // | IResourceChangeEvent.PRE_DELETE
1246 // | IResourceChangeEvent.PRE_CLOSE);
1247 // // startIndexing();
1248 // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
1249 // } catch (CoreException e) {
1250 // } catch (RuntimeException e) {
1251 // manager.shutdown();
1254 // // end JavaCore.startup();
1255 // IAdapterManager platformManager = Platform.getAdapterManager();
1256 // platformManager.registerAdapters(new PHPElementAdapterFactory(),
1257 // PHPElement.class);
1258 // platformManager.registerAdapters(new ResourceAdapterFactory(),
1259 // IResource.class);
1260 // // externalTools.startUp();
1261 // getStandardDisplay().asyncExec(new Runnable() {
1262 // public void run() {
1263 // //initialize the variable context manager
1264 // VariableContextManager.getDefault();
1269 private void registerAdapters() {
1270 fJavaElementAdapterFactory = new JavaElementAdapterFactory();
1271 // fMarkerAdapterFactory= new MarkerAdapterFactory();
1272 // fEditorInputAdapterFactory= new EditorInputAdapterFactory();
1273 fResourceAdapterFactory = new ResourceAdapterFactory();
1274 // fLogicalPackageAdapterFactory= new LogicalPackageAdapterFactory();
1276 IAdapterManager manager = Platform.getAdapterManager();
1277 manager.registerAdapters(fJavaElementAdapterFactory, IJavaElement.class);
1278 // manager.registerAdapters(fMarkerAdapterFactory, IMarker.class);
1279 // manager.registerAdapters(fEditorInputAdapterFactory, IEditorInput.class);
1280 manager.registerAdapters(fResourceAdapterFactory, IResource.class);
1281 // manager.registerAdapters(fLogicalPackageAdapterFactory,
1282 // LogicalPackage.class);
1285 private void unregisterAdapters() {
1286 IAdapterManager manager = Platform.getAdapterManager();
1287 manager.unregisterAdapters(fJavaElementAdapterFactory);
1288 // manager.unregisterAdapters(fMarkerAdapterFactory);
1289 // manager.unregisterAdapters(fEditorInputAdapterFactory);
1290 manager.unregisterAdapters(fResourceAdapterFactory);
1291 // manager.unregisterAdapters(fLogicalPackageAdapterFactory);
1295 * Returns a combined preference store, this store is read-only.
1297 * @return the combined preference store
1301 public IPreferenceStore getCombinedPreferenceStore() {
1302 if (fCombinedPreferenceStore == null) {
1303 IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
1304 fCombinedPreferenceStore = new ChainedPreferenceStore(
1305 new IPreferenceStore[] {
1306 getPreferenceStore(),
1307 new PreferencesAdapter(PHPeclipsePlugin.getDefault()
1308 .getPluginPreferences()), generalTextStore });
1310 return fCombinedPreferenceStore;
1313 public synchronized IBufferFactory getBufferFactory() {
1314 if (fBufferFactory == null)
1315 fBufferFactory = new CustomBufferFactory();
1316 return fBufferFactory;
1320 * Returns the registry of the extensions to the
1321 * <code>org.eclipse.jdt.ui.javaFoldingStructureProvider</code> extension
1324 * @return the registry of contributed
1325 * <code>IJavaFoldingStructureProvider</code>
1328 public synchronized JavaFoldingStructureProviderRegistry getFoldingStructureProviderRegistry() {
1329 if (fFoldingStructureProviderRegistry == null)
1330 fFoldingStructureProviderRegistry = new JavaFoldingStructureProviderRegistry();
1331 return fFoldingStructureProviderRegistry;
1335 * Runs the given action as an atomic Java model operation.
1337 * After running a method that modifies java elements, registered listeners
1338 * receive after-the-fact notification of what just transpired, in the form of
1339 * a element changed event. This method allows clients to call a number of
1340 * methods that modify java elements and only have element changed event
1341 * notifications reported at the end of the entire batch.
1344 * If this method is called outside the dynamic scope of another such call,
1345 * this method runs the action and then reports a single element changed event
1346 * describing the net effect of all changes done to java elements by the
1350 * If this method is called in the dynamic scope of another such call, this
1351 * method simply runs the action.
1355 * the action to perform
1357 * a progress monitor, or <code>null</code> if progress reporting
1358 * and cancellation are not desired
1359 * @exception CoreException
1360 * if the operation failed.
1363 public static void run(IWorkspaceRunnable action, IProgressMonitor monitor)
1364 throws CoreException {
1365 run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor);
1369 * Runs the given action as an atomic Java model operation.
1371 * After running a method that modifies java elements, registered listeners
1372 * receive after-the-fact notification of what just transpired, in the form of
1373 * a element changed event. This method allows clients to call a number of
1374 * methods that modify java elements and only have element changed event
1375 * notifications reported at the end of the entire batch.
1378 * If this method is called outside the dynamic scope of another such call,
1379 * this method runs the action and then reports a single element changed event
1380 * describing the net effect of all changes done to java elements by the
1384 * If this method is called in the dynamic scope of another such call, this
1385 * method simply runs the action.
1388 * The supplied scheduling rule is used to determine whether this operation
1389 * can be run simultaneously with workspace changes in other threads. See
1390 * <code>IWorkspace.run(...)</code> for more details.
1394 * the action to perform
1396 * the scheduling rule to use when running this operation, or
1397 * <code>null</code> if there are no scheduling restrictions for
1400 * a progress monitor, or <code>null</code> if progress reporting
1401 * and cancellation are not desired
1402 * @exception CoreException
1403 * if the operation failed.
1406 public static void run(IWorkspaceRunnable action, ISchedulingRule rule,
1407 IProgressMonitor monitor) throws CoreException {
1408 IWorkspace workspace = ResourcesPlugin.getWorkspace();
1409 if (workspace.isTreeLocked()) {
1410 new BatchOperation(action).run(monitor);
1412 // use IWorkspace.run(...) to ensure that a build will be done in
1414 workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE,