KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > JDIDebugUIPlugin


1 /*******************************************************************************
2  * Copyright (c) 2000, 20076 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.ui;
12
13  
14 import java.lang.reflect.InvocationTargetException JavaDoc;
15 import java.util.ArrayList JavaDoc;
16 import java.util.HashMap JavaDoc;
17 import java.util.HashSet JavaDoc;
18 import java.util.List JavaDoc;
19 import java.util.Map JavaDoc;
20 import java.util.Set JavaDoc;
21
22 import org.eclipse.core.resources.ISaveContext;
23 import org.eclipse.core.resources.ISaveParticipant;
24 import org.eclipse.core.resources.IWorkspaceRoot;
25 import org.eclipse.core.resources.ResourcesPlugin;
26 import org.eclipse.core.runtime.CoreException;
27 import org.eclipse.core.runtime.IAdapterFactory;
28 import org.eclipse.core.runtime.IAdapterManager;
29 import org.eclipse.core.runtime.IConfigurationElement;
30 import org.eclipse.core.runtime.IExtensionPoint;
31 import org.eclipse.core.runtime.IProgressMonitor;
32 import org.eclipse.core.runtime.IStatus;
33 import org.eclipse.core.runtime.Platform;
34 import org.eclipse.core.runtime.Status;
35 import org.eclipse.debug.ui.DebugUITools;
36 import org.eclipse.debug.ui.IDebugModelPresentation;
37 import org.eclipse.debug.ui.ILaunchConfigurationTab;
38 import org.eclipse.jdt.core.IJavaModel;
39 import org.eclipse.jdt.core.IJavaProject;
40 import org.eclipse.jdt.core.IMember;
41 import org.eclipse.jdt.core.IPackageFragment;
42 import org.eclipse.jdt.core.JavaCore;
43 import org.eclipse.jdt.core.JavaModelException;
44 import org.eclipse.jdt.debug.core.IJavaBreakpoint;
45 import org.eclipse.jdt.debug.core.IJavaDebugTarget;
46 import org.eclipse.jdt.debug.core.IJavaHotCodeReplaceListener;
47 import org.eclipse.jdt.debug.core.IJavaStackFrame;
48 import org.eclipse.jdt.debug.core.IJavaThread;
49 import org.eclipse.jdt.debug.core.IJavaThreadGroup;
50 import org.eclipse.jdt.debug.core.IJavaVariable;
51 import org.eclipse.jdt.debug.core.JDIDebugModel;
52 import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
53 import org.eclipse.jdt.internal.debug.ui.breakpoints.ExceptionInspector;
54 import org.eclipse.jdt.internal.debug.ui.breakpoints.JavaBreakpointTypeAdapterFactory;
55 import org.eclipse.jdt.internal.debug.ui.classpath.ClasspathEntryAdapterFactory;
56 import org.eclipse.jdt.internal.debug.ui.display.JavaInspectExpression;
57 import org.eclipse.jdt.internal.debug.ui.monitors.JavaContendedMonitor;
58 import org.eclipse.jdt.internal.debug.ui.monitors.JavaOwnedMonitor;
59 import org.eclipse.jdt.internal.debug.ui.monitors.JavaOwningThread;
60 import org.eclipse.jdt.internal.debug.ui.monitors.JavaWaitingThread;
61 import org.eclipse.jdt.internal.debug.ui.monitors.MonitorsAdapterFactory;
62 import org.eclipse.jdt.internal.debug.ui.snippeteditor.SnippetFileDocumentProvider;
63 import org.eclipse.jdt.internal.debug.ui.sourcelookup.JavaDebugShowInAdapterFactory;
64 import org.eclipse.jdt.internal.debug.ui.threadgroups.TargetAdapterFactory;
65 import org.eclipse.jdt.internal.debug.ui.threadgroups.ThreadGroupAdapterFactory;
66 import org.eclipse.jdt.internal.debug.ui.variables.ColumnPresentationAdapterFactory;
67 import org.eclipse.jdt.internal.debug.ui.variables.JavaDebugElementAdapterFactory;
68 import org.eclipse.jdt.internal.launching.DefaultProjectClasspathEntry;
69 import org.eclipse.jdt.launching.sourcelookup.IJavaSourceLocation;
70 import org.eclipse.jdt.ui.JavaElementLabelProvider;
71 import org.eclipse.jdt.ui.PreferenceConstants;
72 import org.eclipse.jdt.ui.text.JavaTextTools;
73 import org.eclipse.jface.dialogs.ErrorDialog;
74 import org.eclipse.jface.dialogs.MessageDialog;
75 import org.eclipse.jface.operation.IRunnableWithProgress;
76 import org.eclipse.jface.preference.IPreferenceNode;
77 import org.eclipse.jface.preference.IPreferencePage;
78 import org.eclipse.jface.preference.PreferenceDialog;
79 import org.eclipse.jface.preference.PreferenceManager;
80 import org.eclipse.jface.preference.PreferenceNode;
81 import org.eclipse.jface.resource.ImageRegistry;
82 import org.eclipse.jface.window.Window;
83 import org.eclipse.swt.custom.BusyIndicator;
84 import org.eclipse.swt.widgets.Display;
85 import org.eclipse.swt.widgets.Shell;
86 import org.eclipse.ui.IWorkbenchPage;
87 import org.eclipse.ui.IWorkbenchWindow;
88 import org.eclipse.ui.PlatformUI;
89 import org.eclipse.ui.dialogs.ElementListSelectionDialog;
90 import org.eclipse.ui.dialogs.PreferencesUtil;
91 import org.eclipse.ui.plugin.AbstractUIPlugin;
92 import org.eclipse.ui.texteditor.IDocumentProvider;
93 import org.osgi.framework.Bundle;
94 import org.osgi.framework.BundleContext;
95
96 /**
97  * Plug-in class for the org.eclipse.jdt.debug.ui plug-in.
98  */

99 public class JDIDebugUIPlugin extends AbstractUIPlugin {
100
101     /**
102      * Unique identifier constant (value <code>"org.eclipse.jdt.debug.ui"</code>)
103      * for the JDI Debug plug-in.
104      */

105     private static final String JavaDoc PI_JDI_DEBUG = "org.eclipse.jdt.debug.ui"; //$NON-NLS-1$
106

107     /**
108      * Id for inspect command.
109      *
110      * @since 3.3
111      */

112     public static final String JavaDoc COMMAND_INSPECT = "org.eclipse.jdt.debug.ui.commands.Inspect"; //$NON-NLS-1$
113

114     /**
115      * Java Debug UI plug-in instance
116      */

117     private static JDIDebugUIPlugin fgPlugin;
118     
119     private IDocumentProvider fSnippetDocumentProvider;
120     
121     private ImageDescriptorRegistry fImageDescriptorRegistry;
122     
123     private ActionFilterAdapterFactory fActionFilterAdapterFactory;
124     private JavaSourceLocationWorkbenchAdapterFactory fSourceLocationAdapterFactory;
125     private JavaBreakpointWorkbenchAdapterFactory fBreakpointAdapterFactory;
126     
127     private IDebugModelPresentation fUtilPresentation;
128     
129     /**
130      * Java Debug UI listeners
131      */

132     private IJavaHotCodeReplaceListener fHCRListener;
133     
134     // Map of VMInstallTypeIDs to IConfigurationElements
135
protected Map JavaDoc fVmInstallTypePageMap;
136     
137     /**
138      * Whether this plugin is in the process of shutting
139      * down.
140      */

141     private boolean fShuttingDown= false;
142
143     /**
144      * Singleton text tools for debug plug-in.
145      */

146     private JavaTextTools fTextTools = null;
147     
148     /**
149      * @see Plugin()
150      */

151     public JDIDebugUIPlugin() {
152         super();
153         setDefault(this);
154     }
155     
156     /**
157      * Sets the Java Debug UI plug-in instance
158      *
159      * @param plugin the plugin instance
160      */

161     private static void setDefault(JDIDebugUIPlugin plugin) {
162         fgPlugin = plugin;
163     }
164     
165     /**
166      * Returns the Java Debug UI plug-in instance
167      *
168      * @return the Java Debug UI plug-in instance
169      */

170     public static JDIDebugUIPlugin getDefault() {
171         return fgPlugin;
172     }
173     
174     /**
175      * Convenience method which returns the unique identifier of this plugin.
176      */

177     public static String JavaDoc getUniqueIdentifier() {
178         return PI_JDI_DEBUG;
179     }
180     
181     /**
182      * Logs the specified status with this plug-in's log.
183      *
184      * @param status status to log
185      */

186     public static void log(IStatus status) {
187         getDefault().getLog().log(status);
188     }
189     
190     /**
191      * Logs an internal error with the specified message.
192      *
193      * @param message the error message to log
194      */

195     public static void logErrorMessage(String JavaDoc message) {
196         log(new Status(IStatus.ERROR, getUniqueIdentifier(), IJavaDebugUIConstants.INTERNAL_ERROR, message, null));
197     }
198
199     /**
200      * Logs an internal error with the specified throwable
201      *
202      * @param e the exception to be logged
203      */

204     public static void log(Throwable JavaDoc e) {
205         if (e instanceof CoreException) {
206             log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e.getCause()));
207         } else {
208             log(new Status(IStatus.ERROR, getUniqueIdentifier(), IJavaDebugUIConstants.INTERNAL_ERROR, "Internal Error", e)); //$NON-NLS-1$
209
}
210     }
211     
212     /**
213      * Returns the active workbench window
214      *
215      * @return the active workbench window
216      */

217     public static IWorkbenchWindow getActiveWorkbenchWindow() {
218         return getDefault().getWorkbench().getActiveWorkbenchWindow();
219     }
220     
221     public static IWorkbenchPage getActivePage() {
222         IWorkbenchWindow w = getActiveWorkbenchWindow();
223         if (w != null) {
224             return w.getActivePage();
225         }
226         return null;
227     }
228     
229     
230     /**
231      * Returns the active workbench shell or <code>null</code> if none
232      *
233      * @return the active workbench shell or <code>null</code> if none
234      */

235     public static Shell getActiveWorkbenchShell() {
236         IWorkbenchWindow window = getActiveWorkbenchWindow();
237         if (window != null) {
238             return window.getShell();
239         }
240         return null;
241     }
242     
243     /* (non-Javadoc)
244      * @see org.eclipse.ui.plugin.AbstractUIPlugin#createImageRegistry()
245      */

246     protected ImageRegistry createImageRegistry() {
247         return JavaDebugImages.getImageRegistry();
248     }
249     
250     public IDocumentProvider getSnippetDocumentProvider() {
251         if (fSnippetDocumentProvider == null) {
252             fSnippetDocumentProvider= new SnippetFileDocumentProvider();
253         }
254         return fSnippetDocumentProvider;
255     }
256     
257     public static void statusDialog(IStatus status) {
258         switch (status.getSeverity()) {
259         case IStatus.ERROR:
260             statusDialog(DebugUIMessages.JDIDebugUIPlugin_Error_1, status);
261             break;
262         case IStatus.WARNING:
263             statusDialog(DebugUIMessages.JDIDebugUIPlugin_0, status);
264             break;
265         case IStatus.INFO:
266             statusDialog(DebugUIMessages.JDIDebugUIPlugin_4, status);
267             break;
268         }
269     }
270     public static void statusDialog(String JavaDoc title, IStatus status) {
271         Shell shell = getActiveWorkbenchShell();
272         if (shell != null) {
273             switch (status.getSeverity()) {
274             case IStatus.ERROR:
275                 ErrorDialog.openError(shell, title, null, status);
276                 break;
277             case IStatus.WARNING:
278                 MessageDialog.openWarning(shell, title, status.getMessage());
279                 break;
280             case IStatus.INFO:
281                 MessageDialog.openInformation(shell, title, status.getMessage());
282                 break;
283             }
284         }
285     }
286         
287     /**
288      * Utility method with conventions
289      */

290     public static void errorDialog(String JavaDoc message, Throwable JavaDoc t) {
291         IStatus status= new Status(IStatus.ERROR, getUniqueIdentifier(), IJavaDebugUIConstants.INTERNAL_ERROR, message, t);
292         statusDialog(status);
293     }
294     
295     /**
296      * Creates an extension. If the extension plugin has not
297      * been loaded a busy cursor will be activated during the duration of
298      * the load.
299      *
300      * @param element the config element defining the extension
301      * @param classAttribute the name of the attribute carrying the class
302      * @return the extension object
303      */

304     public static Object JavaDoc createExtension(final IConfigurationElement element, final String JavaDoc classAttribute) throws CoreException {
305         // If plugin has been loaded create extension.
306
// Otherwise, show busy cursor then create extension.
307
Bundle bundle = Platform.getBundle(element.getContributor().getName());
308         if (bundle.getState() == Bundle.ACTIVE) {
309             return element.createExecutableExtension(classAttribute);
310         }
311         
312         final Object JavaDoc [] ret = new Object JavaDoc[1];
313         final CoreException [] exc = new CoreException[1];
314         BusyIndicator.showWhile(null, new Runnable JavaDoc() {
315             public void run() {
316                 try {
317                     ret[0] = element.createExecutableExtension(classAttribute);
318                 } catch (CoreException e) {
319                     exc[0] = e;
320                 }
321             }
322         });
323         if (exc[0] != null) {
324             throw exc[0];
325         }
326         return ret[0];
327     }
328     
329     /* (non-Javadoc)
330      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
331      */

332     public void start(BundleContext context) throws Exception JavaDoc {
333         super.start(context);
334         JavaDebugOptionsManager.getDefault().startup();
335         ResourcesPlugin.getWorkspace().addSaveParticipant(this, new ISaveParticipant() {
336             public void doneSaving(ISaveContext context) {}
337             public void prepareToSave(ISaveContext context) throws CoreException {}
338             public void rollback(ISaveContext context) {}
339             public void saving(ISaveContext context) throws CoreException {
340                 savePluginPreferences();
341             }
342         });
343         IAdapterManager manager= Platform.getAdapterManager();
344         fActionFilterAdapterFactory= new ActionFilterAdapterFactory();
345         manager.registerAdapters(fActionFilterAdapterFactory, IMember.class);
346         manager.registerAdapters(fActionFilterAdapterFactory, IJavaVariable.class);
347         manager.registerAdapters(fActionFilterAdapterFactory, IJavaStackFrame.class);
348         manager.registerAdapters(fActionFilterAdapterFactory, IJavaThread.class);
349         manager.registerAdapters(fActionFilterAdapterFactory, JavaInspectExpression.class);
350         fSourceLocationAdapterFactory = new JavaSourceLocationWorkbenchAdapterFactory();
351         manager.registerAdapters(fSourceLocationAdapterFactory, IJavaSourceLocation.class);
352         fBreakpointAdapterFactory= new JavaBreakpointWorkbenchAdapterFactory();
353         manager.registerAdapters(fBreakpointAdapterFactory, IJavaBreakpoint.class);
354         IAdapterFactory typeFactory = new JavaBreakpointTypeAdapterFactory();
355         manager.registerAdapters(typeFactory, IJavaBreakpoint.class);
356         
357         IAdapterFactory monitorFactory = new MonitorsAdapterFactory();
358         manager.registerAdapters(monitorFactory, IJavaThread.class);
359         manager.registerAdapters(monitorFactory, JavaContendedMonitor.class);
360         manager.registerAdapters(monitorFactory, JavaOwnedMonitor.class);
361         manager.registerAdapters(monitorFactory, JavaOwningThread.class);
362         manager.registerAdapters(monitorFactory, JavaWaitingThread.class);
363         manager.registerAdapters(monitorFactory, IJavaStackFrame.class);
364         
365         IAdapterFactory targetFactory = new TargetAdapterFactory();
366         manager.registerAdapters(targetFactory, IJavaDebugTarget.class);
367              
368         IAdapterFactory groupFactory = new ThreadGroupAdapterFactory();
369         manager.registerAdapters(groupFactory, IJavaThreadGroup.class);
370         
371         IAdapterFactory showInFactory = new JavaDebugShowInAdapterFactory();
372         manager.registerAdapters(showInFactory, IJavaStackFrame.class);
373         
374         IAdapterFactory columnFactory = new ColumnPresentationAdapterFactory();
375         manager.registerAdapters(columnFactory, IJavaVariable.class);
376         manager.registerAdapters(columnFactory, IJavaStackFrame.class);
377         
378         IAdapterFactory entryFactory = new ClasspathEntryAdapterFactory();
379         manager.registerAdapters(entryFactory, DefaultProjectClasspathEntry.class);
380         
381         IAdapterFactory variableFactory = new JavaDebugElementAdapterFactory();
382         manager.registerAdapters(variableFactory, IJavaVariable.class);
383         manager.registerAdapters(variableFactory, JavaInspectExpression.class);
384         
385         fHCRListener= new JavaHotCodeReplaceListener();
386         JDIDebugModel.addHotCodeReplaceListener(fHCRListener);
387         
388         
389         // initialize exception inspector handler
390
new ExceptionInspector();
391     }
392     
393     /* (non-Javadoc)
394      * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
395      */

396     public void stop(BundleContext context) throws Exception JavaDoc {
397         try {
398             setShuttingDown(true);
399             JDIDebugModel.removeHotCodeReplaceListener(fHCRListener);
400             JavaDebugOptionsManager.getDefault().shutdown();
401             if (fImageDescriptorRegistry != null) {
402                 fImageDescriptorRegistry.dispose();
403             }
404             IAdapterManager manager= Platform.getAdapterManager();
405             manager.unregisterAdapters(fActionFilterAdapterFactory);
406             manager.unregisterAdapters(fSourceLocationAdapterFactory);
407             manager.unregisterAdapters(fBreakpointAdapterFactory);
408             if (fUtilPresentation != null) {
409                 fUtilPresentation.dispose();
410             }
411             if (fTextTools != null) {
412                 fTextTools.dispose();
413             }
414             ResourcesPlugin.getWorkspace().removeSaveParticipant(this);
415         } finally {
416             super.stop(context);
417         }
418     }
419     
420     /**
421      * Returns whether this plug-in is in the process of
422      * being shutdown.
423      *
424      * @return whether this plug-in is in the process of
425      * being shutdown
426      */

427     protected boolean isShuttingDown() {
428         return fShuttingDown;
429     }
430
431     /**
432      * Sets whether this plug-in is in the process of
433      * being shutdown.
434      *
435      * @param value whether this plug-in is in the process of
436      * being shutdown
437      */

438     private void setShuttingDown(boolean value) {
439         fShuttingDown = value;
440     }
441     
442     /**
443      * Returns the image descriptor registry used for this plugin.
444      */

445     public static ImageDescriptorRegistry getImageDescriptorRegistry() {
446         if (getDefault().fImageDescriptorRegistry == null) {
447             getDefault().fImageDescriptorRegistry = new ImageDescriptorRegistry();
448         }
449         return getDefault().fImageDescriptorRegistry;
450     }
451     
452     /**
453      * Returns the standard display to be used. The method first checks, if
454      * the thread calling this method has an associated display. If so, this
455      * display is returned. Otherwise the method returns the default display.
456      */

457     public static Display getStandardDisplay() {
458         Display display;
459         display= Display.getCurrent();
460         if (display == null)
461             display= Display.getDefault();
462         return display;
463     }
464     
465     /**
466      * Returns the currently active workbench window shell or <code>null</code>
467      * if none.
468      *
469      * @return the currently active workbench window shell or <code>null</code>
470      */

471     public static Shell getShell() {
472         IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
473         if (window == null) {
474             IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
475             if (windows.length > 0) {
476                 return windows[0].getShell();
477             }
478         }
479         else {
480             return window.getShell();
481         }
482         return null;
483     }
484     
485     /**
486      * Utility method to create and return a selection dialog that allows
487      * selection of a specific Java package. Empty packages are not returned.
488      * If Java Projects are provided, only packages found within those projects
489      * are included. If no Java projects are provided, all Java projects in the
490      * workspace are considered.
491      */

492     public static ElementListSelectionDialog createAllPackagesDialog(Shell shell, IJavaProject[] originals, final boolean includeDefaultPackage) throws JavaModelException{
493         final List JavaDoc packageList = new ArrayList JavaDoc();
494         if (originals == null) {
495             IWorkspaceRoot wsroot= ResourcesPlugin.getWorkspace().getRoot();
496             IJavaModel model= JavaCore.create(wsroot);
497             originals= model.getJavaProjects();
498         }
499         final IJavaProject[] projects= originals;
500         final JavaModelException[] exception= new JavaModelException[1];
501         final boolean[] monitorCanceled = new boolean[] {false};
502         IRunnableWithProgress r= new IRunnableWithProgress() {
503             public void run(IProgressMonitor monitor) {
504                 try {
505                     Set JavaDoc packageNameSet= new HashSet JavaDoc();
506                     monitor.beginTask(DebugUIMessages.JDIDebugUIPlugin_Searching_1, projects.length);
507                     for (int i = 0; i < projects.length; i++) {
508                         IPackageFragment[] pkgs= projects[i].getPackageFragments();
509                         for (int j = 0; j < pkgs.length; j++) {
510                             if (monitor.isCanceled()) {
511                                 monitorCanceled[0] = true;
512                                 return;
513                             }
514                             IPackageFragment pkg = pkgs[j];
515                             if (!pkg.hasChildren() && (pkg.getNonJavaResources().length > 0)) {
516                                 continue;
517                             }
518                             String JavaDoc pkgName= pkg.getElementName();
519                             if (!includeDefaultPackage && pkgName.length() == 0) {
520                                 continue;
521                             }
522                             if (packageNameSet.add(pkgName)) {
523                                 packageList.add(pkg);
524                             }
525                         }
526                         monitor.worked(1);
527                     }
528                     monitor.done();
529                 } catch (JavaModelException jme) {
530                     exception[0]= jme;
531                 }
532             }
533         };
534         try {
535             PlatformUI.getWorkbench().getProgressService().busyCursorWhile(r);
536         } catch (InvocationTargetException JavaDoc e) {
537             JDIDebugUIPlugin.log(e);
538         } catch (InterruptedException JavaDoc e) {
539             JDIDebugUIPlugin.log(e);
540         }
541         if (exception[0] != null) {
542             throw exception[0];
543         }
544         if (monitorCanceled[0]) {
545             return null;
546         }
547         
548         int flags= JavaElementLabelProvider.SHOW_DEFAULT;
549         PackageSelectionDialog dialog= new PackageSelectionDialog(shell, new JavaElementLabelProvider(flags));
550         dialog.setIgnoreCase(false);
551         dialog.setElements(packageList.toArray()); // XXX inefficient
552
return dialog;
553     }
554     
555     /**
556      * Return an object that implements <code>ILaunchConfigurationTab</code> for the
557      * specified vm install type ID.
558      */

559     public ILaunchConfigurationTab getVMInstallTypePage(String JavaDoc vmInstallTypeID) {
560         if (fVmInstallTypePageMap == null) {
561             initializeVMInstallTypePageMap();
562         }
563         IConfigurationElement configElement = (IConfigurationElement) fVmInstallTypePageMap.get(vmInstallTypeID);
564         ILaunchConfigurationTab tab = null;
565         if (configElement != null) {
566             try {
567                 tab = (ILaunchConfigurationTab) configElement.createExecutableExtension("class"); //$NON-NLS-1$
568
} catch(CoreException ce) {
569                 log(new Status(IStatus.ERROR, getUniqueIdentifier(), IJavaDebugUIConstants.INTERNAL_ERROR, "An error occurred retrieving a VMInstallType page.", ce)); //$NON-NLS-1$
570
}
571         }
572         return tab;
573     }
574     
575     protected void initializeVMInstallTypePageMap() {
576         fVmInstallTypePageMap = new HashMap JavaDoc(10);
577
578         IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(getUniqueIdentifier(), IJavaDebugUIConstants.EXTENSION_POINT_VM_INSTALL_TYPE_PAGE);
579         IConfigurationElement[] infos= extensionPoint.getConfigurationElements();
580         for (int i = 0; i < infos.length; i++) {
581             String JavaDoc id = infos[i].getAttribute("vmInstallTypeID"); //$NON-NLS-1$
582
fVmInstallTypePageMap.put(id, infos[i]);
583         }
584     }
585     
586     /**
587      * Returns a shared utility Java debug model presentation. Clients should not
588      * dispose the presentation.
589      *
590      * @return a Java debug model presentation
591      */

592     public IDebugModelPresentation getModelPresentation() {
593         if (fUtilPresentation == null) {
594             fUtilPresentation = DebugUITools.newDebugModelPresentation(JDIDebugModel.getPluginIdentifier());
595         }
596         return fUtilPresentation;
597     }
598     
599     /**
600      * Displays the given preference page.
601      *
602      * @param id pref page id
603      * @param page pref page
604      * @deprecated use <code>JDIDebugUIPlugin#showPreferencePage(String pageId)</code>, which uses the <code>PreferenceUtils</code> framework for opening pages.
605      */

606     public static void showPreferencePage(String JavaDoc id, IPreferencePage page) {
607         final IPreferenceNode targetNode = new PreferenceNode(id, page);
608         
609         PreferenceManager manager = new PreferenceManager();
610         manager.addToRoot(targetNode);
611         final PreferenceDialog dialog = new PreferenceDialog(JDIDebugUIPlugin.getActiveWorkbenchShell(), manager);
612         final boolean [] result = new boolean[] { false };
613         BusyIndicator.showWhile(JDIDebugUIPlugin.getStandardDisplay(), new Runnable JavaDoc() {
614             public void run() {
615                 dialog.create();
616                 dialog.setMessage(targetNode.getLabelText());
617                 result[0]= (dialog.open() == Window.OK);
618             }
619         });
620     }
621     
622     /**
623      * Displays the given preference page
624      * @param pageId the fully qualified id of the preference page, e.g. <code>org.eclipse.jdt.debug.ui.preferences.VMPreferencePage</code>
625      *
626      * @since 3.3
627      */

628     public static void showPreferencePage(String JavaDoc pageId) {
629         PreferencesUtil.createPreferenceDialogOn(getShell(), pageId, new String JavaDoc[] { pageId }, null).open();
630     }
631     
632     /**
633      * Returns the text tools used by this plug-in
634      *
635      * @return
636      */

637     public JavaTextTools getJavaTextTools() {
638         if (fTextTools == null) {
639             fTextTools = new JavaTextTools(PreferenceConstants.getPreferenceStore());
640         }
641         return fTextTools;
642     }
643 }
644
645
Popular Tags