1 11 package org.eclipse.jdt.internal.debug.ui.launcher; 12 13 14 import org.eclipse.core.resources.IMarker; 15 import org.eclipse.core.runtime.IPath; 16 import org.eclipse.core.runtime.Path; 17 import org.eclipse.jdt.core.CorrectionEngine; 18 import org.eclipse.jdt.core.IJavaModelMarker; 19 import org.eclipse.jdt.core.IJavaModelStatusConstants; 20 import org.eclipse.jdt.core.IJavaProject; 21 import org.eclipse.jdt.core.JavaCore; 22 import org.eclipse.jdt.launching.JavaRuntime; 23 import org.eclipse.ui.IMarkerResolution; 24 import org.eclipse.ui.IMarkerResolutionGenerator; 25 26 29 public class JreResolutionGenerator implements IMarkerResolutionGenerator { 30 31 private final static IMarkerResolution[] NO_RESOLUTION = new IMarkerResolution[0]; 32 33 36 public IMarkerResolution[] getResolutions(IMarker marker) { 37 int id = marker.getAttribute(IJavaModelMarker.ID, -1); 38 switch (id) { 39 case IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND : 41 String [] arguments = CorrectionEngine.getProblemArguments(marker); 42 IPath path = new Path(arguments[0]); 43 if (path.segment(0).equals(JavaRuntime.JRE_CONTAINER)) { 44 if (JREResolution.getAllVMs().length > 0) { 46 IJavaProject project = getJavaProject(marker); 47 return new IMarkerResolution[]{new SelectSystemLibraryQuickFix(path, project)}; 48 } 49 return new IMarkerResolution[]{new DefineSystemLibraryQuickFix()}; 51 } 52 break; 53 54 case IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND : 56 arguments = CorrectionEngine.getProblemArguments(marker); 57 path = new Path(arguments[0]); 58 if (path.segment(0).equals(JavaRuntime.JRELIB_VARIABLE)) { 59 if (JREResolution.getAllVMs().length > 0) { 61 return new IMarkerResolution[]{new SelectDefaultSystemLibraryQuickFix()}; 62 } 63 return new IMarkerResolution[]{new DefineSystemLibraryQuickFix()}; 65 } 66 break; 67 case IJavaModelStatusConstants.DEPRECATED_VARIABLE : 69 arguments = CorrectionEngine.getProblemArguments(marker); 70 path = new Path(arguments[0]); 71 if (path.segment(0).equals(JavaRuntime.JRELIB_VARIABLE) || 72 path.segment(0).equals(JavaRuntime.JRE_CONTAINER)) { 73 IJavaProject project = getJavaProject(marker); 74 return new IMarkerResolution[] {new SelectSystemLibraryQuickFix(path, project)}; 75 } 76 break; 77 } 78 return NO_RESOLUTION; 79 } 80 81 87 protected IJavaProject getJavaProject(IMarker marker) { 88 return JavaCore.create(marker.getResource().getProject()); 89 } 90 } 91 | Popular Tags |