1 11 package org.eclipse.jdt.internal.debug.ui.launcher; 12 13 14 import java.lang.reflect.InvocationTargetException ; 15 16 import org.eclipse.core.resources.IMarker; 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IProgressMonitor; 19 import org.eclipse.core.runtime.IStatus; 20 import org.eclipse.core.runtime.Status; 21 import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants; 22 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 23 import org.eclipse.jdt.launching.IVMInstall; 24 import org.eclipse.jdt.launching.JavaRuntime; 25 import org.eclipse.jface.operation.IRunnableWithProgress; 26 import org.eclipse.ui.PlatformUI; 27 28 31 public class SelectDefaultSystemLibraryQuickFix extends JREResolution { 32 33 public SelectDefaultSystemLibraryQuickFix() { 34 super(); 35 } 36 37 40 public void run(IMarker marker) { 41 try { 42 String title = LauncherMessages.SelectDefaultSystemLibraryQuickFix_Select_Default_System_Library_1; 43 String message = LauncherMessages.SelectDefaultSystemLibraryQuickFix__Select_the_system_library_to_use_by_default_for_building_and_running_Java_projects__2; 44 45 final IVMInstall vm = chooseVMInstall(title, message); 46 if (vm == null) { 47 return; 48 } 49 50 IRunnableWithProgress runnable = new IRunnableWithProgress() { 51 public void run(IProgressMonitor monitor) throws InvocationTargetException { 52 try { 53 JavaRuntime.setDefaultVMInstall(vm, monitor); 54 } catch (CoreException e) { 55 throw new InvocationTargetException (e); 56 } 57 } 58 }; 59 60 try { 61 PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runnable); 62 } catch (InvocationTargetException e) { 63 if (e.getTargetException() instanceof CoreException) { 64 throw (CoreException)e.getTargetException(); 65 } 66 throw new CoreException(new Status(IStatus.ERROR, 67 JDIDebugUIPlugin.getUniqueIdentifier(), 68 IJavaDebugUIConstants.INTERNAL_ERROR, 69 LauncherMessages.SelectDefaultSystemLibraryQuickFix_An_exception_occurred_while_updating_the_default_system_library__3, e.getTargetException())); 70 } catch (InterruptedException e) { 71 } 73 } catch (CoreException e) { 74 JDIDebugUIPlugin.statusDialog(LauncherMessages.SelectDefaultSystemLibraryQuickFix_Unable_to_update_the_default_system_library__4, e.getStatus()); 75 } 76 } 77 78 81 public String getLabel() { 82 return LauncherMessages.SelectDefaultSystemLibraryQuickFix_Select_default_system_library_5; 83 } 84 85 } 86 | Popular Tags |