1 11 package org.eclipse.jdt.internal.debug.ui.launcher; 12 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 18 import org.eclipse.jdt.internal.debug.ui.jres.JREsLabelProvider; 19 import org.eclipse.jdt.launching.IVMInstall; 20 import org.eclipse.jdt.launching.IVMInstallType; 21 import org.eclipse.jdt.launching.JavaRuntime; 22 import org.eclipse.ui.IMarkerResolution; 23 import org.eclipse.ui.dialogs.ElementListSelectionDialog; 24 25 28 public abstract class JREResolution implements IMarkerResolution { 29 30 38 protected IVMInstall chooseVMInstall(String title, String message) { 39 ElementListSelectionDialog dialog = new ElementListSelectionDialog(JDIDebugUIPlugin.getActiveWorkbenchShell(), new JREsLabelProvider()); 40 dialog.setElements(getAllVMs()); 41 dialog.setTitle(title); 42 dialog.setMessage(message); 43 dialog.setMultipleSelection(false); 44 dialog.open(); 45 return (IVMInstall)dialog.getFirstResult(); 46 } 47 48 53 protected static IVMInstall[] getAllVMs() { 54 IVMInstallType[] types = JavaRuntime.getVMInstallTypes(); 55 List vms = new ArrayList (); 56 for (int i = 0; i < types.length; i++) { 57 IVMInstallType type = types[i]; 58 IVMInstall[] installs = type.getVMInstalls(); 59 for (int j = 0; j < installs.length; j++) { 60 vms.add(installs[j]); 61 } 62 } 63 return (IVMInstall[])vms.toArray(new IVMInstall[vms.size()]); 64 } 65 66 } 67 | Popular Tags |