Java Code Examples for org.eclipse.jdt.launching.IVMInstall#equals()

The following examples show how to use org.eclipse.jdt.launching.IVMInstall#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JVMConfigurator.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static boolean setDefaultEnvironmentVM(IVMInstall vm, String name) {
	IExecutionEnvironment environment = getExecutionEnvironment(name);
	if (environment != null) {
		if (Objects.equals(vm, environment.getDefaultVM())) {
			return true;
		}
		IVMInstall[] compatibleVMs = environment.getCompatibleVMs();
		for (IVMInstall compatibleVM : compatibleVMs) {
			if (compatibleVM.equals(vm)) {
				if (!environment.isStrictlyCompatible(vm)) {
					JavaLanguageServerPlugin.logInfo("Runtime at '" + vm.getInstallLocation().toString() + "' is not strictly compatible with the '" + name + "' environment");
				}
				JavaLanguageServerPlugin.logInfo("Setting " + compatibleVM.getInstallLocation() + " as '" + name + "' environment (id:" + compatibleVM.getId() + ")");
				environment.setDefaultVM(compatibleVM);
				return true;
			}
		}
	}
	return false;
}
 
Example 2
Source File: JDTUtils.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
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);
			}
		}
	}
}
 
Example 3
Source File: TestVMType.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static void setTestJREAsDefault(String vmId) throws CoreException {
	IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(VMTYPE_ID);
	IVMInstall testVMInstall = vmInstallType.findVMInstall(vmId);
	if (!testVMInstall.equals(JavaRuntime.getDefaultVMInstall())) {
		// set the 1.8 test JRE as the new default JRE
		JavaRuntime.setDefaultVMInstall(testVMInstall, new NullProgressMonitor());
		Hashtable<String, String> options = JavaCore.getOptions();
		JavaCore.setComplianceOptions(vmId, options);
		JavaCore.setOptions(options);
	}
	JDTUtils.setCompatibleVMs(VMTYPE_ID);
}
 
Example 4
Source File: ReorgCorrectionsSubProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object getAdditionalProposalInfo(IProgressMonitor monitor) {
	StringBuffer message= new StringBuffer();
	if (fChangeOnWorkspace) {
		message.append(Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_required_compliance_changeworkspace_description, fRequiredVersion));
	} else {
		message.append(Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_required_compliance_changeproject_description, fRequiredVersion));
	}

	try {
		IVMInstall install= JavaRuntime.getVMInstall(fProject); // can be null
		if (fChangeOnWorkspace) {
			IVMInstall vmInstall= findRequiredOrGreaterVMInstall();
			if (vmInstall != null) {
				IVMInstall defaultVM= JavaRuntime.getDefaultVMInstall(); // can be null
				if (defaultVM != null && !defaultVM.equals(install)) {
					message.append(CorrectionMessages.ReorgCorrectionsSubProcessor_50_compliance_changeProjectJREToDefault_description);
				}
				if (defaultVM == null || !isRequiredOrGreaterVMInstall(defaultVM)) {
					message.append(Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_50_compliance_changeWorkspaceJRE_description, vmInstall.getName()));
				}
			}
		} else {
			IExecutionEnvironment bestEE= findBestMatchingEE();
			if (bestEE != null) {
				if (install == null || !isEEOnClasspath(bestEE)) {
					message.append(Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_50_compliance_changeProjectJRE_description, bestEE.getId()));
				}
			}
		}
	} catch (CoreException e) {
		// ignore
	}
	return message.toString();
}