private static String generateUniqueVMId(IVMInstallType type) { // return a unique id for the VM int counter = 1; String vmId = VM_ID_PREFIX + counter; while (type.findVMInstall(vmId) != null) { counter++; vmId = VM_ID_PREFIX + counter; } return vmId; }
/** * Creates a unique name for the VMInstallType * @param vmType the vm install type * @return a unique name */ private String createUniqueId(IVMInstallType vmType) { String id = null; do { id = String.valueOf(System.currentTimeMillis()); } while (vmType.findVMInstall(id) != null); return id; }
/** * Find a unique VM id. Check existing 'real' VMs, as well as the last id used for * a VMStandin. */ private String createUniqueId(IVMInstallType vmType) { String id= null; do { id= String.valueOf(System.currentTimeMillis()); } while (vmType.findVMInstall(id) != null || id.equals(fgLastUsedID)); fgLastUsedID = id; return id; }
while (vmTypes[i].findVMInstall(String.valueOf(unique)) != null) { unique++; while (vmType.findVMInstall(String.valueOf(unique)) != null) { unique++;
while (vmTypes[i].findVMInstall(String.valueOf(unique)) != null) { unique++; while (vmType.findVMInstall(String.valueOf(unique)) != null) { unique++;
public boolean configureVM() throws CoreException { String javaHome = preferenceManager.getPreferences().getJavaHome(); if (javaHome != null) { File jvmHome = new File(javaHome); if (jvmHome.isDirectory()) { IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall(); File location = defaultVM.getInstallLocation(); if (!location.equals(jvmHome)) { IVMInstall vm = findVM(jvmHome); if (vm == null) { IVMInstallType installType = JavaRuntime.getVMInstallType(StandardVMType.ID_STANDARD_VM_TYPE); long unique = System.currentTimeMillis(); while (installType.findVMInstall(String.valueOf(unique)) != null) { unique++; } String vmId = String.valueOf(unique); VMStandin vmStandin = new VMStandin(installType, vmId); String name = StringUtils.defaultIfBlank(jvmHome.getName(), "JRE"); vmStandin.setName(name); vmStandin.setInstallLocation(jvmHome); vm = vmStandin.convertToRealVM(); } JavaRuntime.setDefaultVMInstall(vm, new NullProgressMonitor()); JDTUtils.setCompatibleVMs(vm.getId()); return true; } } } return false; }
/** * Return the VM corresponding to the specified composite Id. The id uniquely * identifies a VM across all VM types. * * @param idString the composite id that specifies an instance of IVMInstall * @return the VM corresponding to the specified composite Id. * * @since 2.1 */ public static IVMInstall getVMFromCompositeId(String idString) { if (idString == null || idString.length() == 0) { return null; } CompositeId id= CompositeId.fromString(idString); if (id.getPartCount() == 2) { IVMInstallType vmType= getVMInstallType(id.get(0)); if (vmType != null) { return vmType.findVMInstall(id.get(1)); } } return null; }
/** * Return the VM corresponding to the specified composite Id. The id uniquely * identifies a VM across all VM types. * * @param idString the composite id that specifies an instance of IVMInstall * @return the VM corresponding to the specified composite Id. * * @since 2.1 */ public static IVMInstall getVMFromCompositeId(String idString) { if (idString == null || idString.length() == 0) { return null; } CompositeId id= CompositeId.fromString(idString); if (id.getPartCount() == 2) { IVMInstallType vmType= getVMInstallType(id.get(0)); if (vmType != null) { return vmType.findVMInstall(id.get(1)); } } return null; }
public static void setCompatibleVMs(String id) { // update all environments compatible to use the test JRE IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); IExecutionEnvironment[] environments = manager.getExecutionEnvironments(); for (IExecutionEnvironment environment : environments) { IVMInstall[] compatibleVMs = environment.getCompatibleVMs(); for (IVMInstall compatibleVM : compatibleVMs) { if (id.equals(compatibleVM.getVMInstallType().getId()) && compatibleVM.getVMInstallType().findVMInstall(compatibleVM.getId()) != null && !compatibleVM.equals(environment.getDefaultVM()) // Fugly way to ensure the lowest VM version is set: && (environment.getDefaultVM() == null || compatibleVM.getId().compareTo(environment.getDefaultVM().getId()) < 0)) { environment.setDefaultVM(compatibleVM); } } } } }
new String[]{id, element.getContributor().getName(), vmType}), null); IVMInstall install = installType.findVMInstall(id); if (install == null) {
new String[]{id, element.getContributor().getName(), vmType}), null); IVMInstall install = installType.findVMInstall(id); if (install == null) {
public IVMInstall convertToRealVM() { IVMInstallType vmType= getVMInstallType(); IVMInstall realVM= vmType.findVMInstall(getId()); boolean notify = true;
public IVMInstall convertToRealVM() { IVMInstallType vmType= getVMInstallType(); IVMInstall realVM= vmType.findVMInstall(getId()); boolean notify = true;