public static String[] getVMInstallNames() { IVMInstall[] installs = getAllVMInstances(); String[] names = new String[installs.length]; for (int i = 0; i < installs.length; i++) { names[i] = installs[i].getName(); } return names; }
private void setJREComboSelection(String vmInstallName) { if (vmInstallName != null) { fJreCombo.setText(vmInstallName); } if (fJreCombo.getSelectionIndex() == -1) { fJreCombo.setText(VMUtil.getDefaultVMInstallName()); } }
private void setEECombo() { IExecutionEnvironment[] eeObjects = VMUtil.getExecutionEnvironments(); String[] ees = new String[eeObjects.length]; for (int i = 0; i < eeObjects.length; i++) { String vm; try { vm = VMUtil.getVMInstallName(eeObjects[i]); } catch (CoreException e) { vm = PDEUIMessages.BasicLauncherTab_unbound; } ees[i] = NLS.bind("{0} ({1})", new String[] {eeObjects[i].getId(), vm}); //$NON-NLS-1$ } fEeCombo.setItems(ees); }
private void createJREGroup(Composite container) { Group group = SWTFactory.createGroup(container, PDEUIMessages.EnvironmentBlock_jreTitle, 2, 1, GridData.FILL_HORIZONTAL); initializeJREValues(); SWTFactory.createWrapLabel(group, PDEUIMessages.JRESection_description, 2); fDefaultJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_defaultJRE, 2); fDefaultJREButton.addSelectionListener(widgetSelectedAdapter(e -> { updateJREWidgets(); getTargetDefinition().setJREContainer(JavaRuntime.newDefaultJREContainerPath()); })); fNamedJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_JREName); fNamedJREButton.addSelectionListener(widgetSelectedAdapter(e -> { updateJREWidgets(); getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText()))); })); fNamedJREsCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, VMUtil.getVMInstallNames()); fNamedJREsCombo.addModifyListener(e -> getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText())))); fExecEnvButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_ExecutionEnv); fExecEnvButton.addSelectionListener(widgetSelectedAdapter(e -> { updateJREWidgets(); getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText()))); })); fExecEnvsCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, fExecEnvChoices.toArray(new String[fExecEnvChoices.size()])); fExecEnvsCombo.addModifyListener(e -> getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText())))); }
IExecutionEnvironment[] exeEnvs = VMUtil.getExecutionEnvironments(); TreeSet<String> availableEEs = new TreeSet<>(); for (IExecutionEnvironment exeEnv : exeEnvs) { for (int i = 0; i < EEChoices.length; i++) { if (!EEChoices[i].equals(NO_EXECUTION_ENVIRONMENT)) { if (VMUtil.getExecutionEnvironment(EEChoices[i]).isStrictlyCompatible(defaultVM)) { fEEChoice.select(i); break;
@Override protected void validatePage() { String errorMessage = validateProperties(); if (errorMessage == null && fGenerateActivator.getSelection()) { IStatus status = JavaConventions.validateJavaTypeName(fClassText.getText().trim(), PDEJavaHelper.getJavaSourceLevel(null), PDEJavaHelper.getJavaComplianceLevel(null)); if (status.getSeverity() == IStatus.ERROR) { errorMessage = status.getMessage(); } else if (status.getSeverity() == IStatus.WARNING) { setMessage(status.getMessage(), IMessageProvider.WARNING); } } if (errorMessage == null) { String eeid = fEEChoice.getText(); if (fEEChoice.isEnabled()) { IExecutionEnvironment ee = VMUtil.getExecutionEnvironment(eeid); if (ee != null && ee.getCompatibleVMs().length == 0) { setMessage(PDEUIMessages.NewProjectCreationPage_invalidEE, IMessageProvider.WARNING); } } } setErrorMessage(errorMessage); setPageComplete(errorMessage == null); }
IVMInstall vmInstall = VMUtil.getVMInstall(vmName); if (vmInstall != null) { path = JavaRuntime.newJREContainerPath(vmInstall);
if (eeId != null) { IExecutionEnvironment ee = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(eeId); String vmName = VMUtil.getVMInstallName(ee); if (ee != null) { IVMInstall vm = getVMInstall(vmName);
private void setJRECombo() { String[] jres = VMUtil.getVMInstallNames(); Arrays.sort(jres, getComparator()); fJreCombo.setItems(jres); }
public static String getVMInstallName(IExecutionEnvironment ee) throws CoreException { IPath containerPath = JavaRuntime.newJREContainerPath(ee); IVMInstall vmi = JavaRuntime.getVMInstall(containerPath); if (vmi == null) throw new CoreException(createErrorStatus(NLS.bind(UtilMessages.VMHelper_noJreForExecEnv, ee.getId()))); return vmi.getName(); }
fEEsCombo.setLabelProvider(new EELabelProvider()); fEEsCombo.setComparator(new ViewerComparator()); fEEsCombo.setItems(VMUtil.getExecutionEnvironments()); fEEsCombo.addItem("", 0); //$NON-NLS-1$ fEEsCombo.addSelectionChangedListener(event -> {
updateWidgets(); if (!fBlockChanges) { getTarget().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getSelection()))); markDirty(); fNamedJREsCombo.createControl(client, toolkit, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); fNamedJREsCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); String[] installs = VMUtil.getVMInstallNames(); fNamedJREsCombo.setItems(installs); fNamedJREsCombo.setVisibleItemCount(30); fNamedJREsCombo.addModifyListener(e -> { if (!fBlockChanges) { getTarget().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getSelection()))); markDirty(); updateWidgets(); if (!fBlockChanges) { getTarget().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getSelection()))); markDirty(); fExecEnvsCombo.addModifyListener(e -> { if (!fBlockChanges) { getTarget().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getSelection()))); markDirty();
IExecutionEnvironment[] exeEnvs = VMUtil.getExecutionEnvironments(); TreeSet<String> availableEEs = new TreeSet<>(); for (IExecutionEnvironment exeEnv : exeEnvs) { for (int i = 0; i < EEChoices.length; i++) { if (!EEChoices[i].equals(NO_EXECUTION_ENVIRONMENT)) { if (VMUtil.getExecutionEnvironment(EEChoices[i]).isStrictlyCompatible(defaultVM)) { fEEChoice.select(i); break;
protected void saveJRESection(ILaunchConfigurationWorkingCopy config) { String javaCommand = fJavawButton.getSelection() ? null : "java"; //$NON-NLS-1$ config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JAVA_COMMAND, javaCommand); IPath jrePath = null; if (fJreButton.getSelection()) { if (fJreCombo.getSelectionIndex() != -1) { String jreName = fJreCombo.getText(); IVMInstall install = VMHelper.getVMInstall(jreName); // remove the name to make portable jrePath = JavaRuntime.newJREContainerPath(install); } } else { if (fEeCombo.getSelectionIndex() != -1) { IExecutionEnvironment environment = VMUtil.getExecutionEnvironment(parseEESelection(fEeCombo.getText())); if (environment != null) { jrePath = JavaRuntime.newJREContainerPath(environment); } } } String attr = null; if (jrePath != null) { attr = jrePath.toPortableString(); } config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, attr); }
* Opens a preference page and refreshes the combo choices when closed * @param pageID the preference page ID to open */ private void openPreferencePage(String pageID) { fBlockChanges = true; PreferencesUtil.createPreferenceDialogOn(fEditor.getEditorSite().getShell(), pageID, new String[] {pageID}, null).open(); // reset JRE select because either JDT preference page allows user to add/remove JREs fNamedJREsCombo.setItems(VMUtil.getVMInstallNames()); refresh(); fBlockChanges = false; } }
/** * Get the default VMInstall name using the available info in the config, * using the JavaProject if available. * * @param configuration * Launch configuration to check * @return name of the VMInstall * @throws CoreException * thrown if there's a problem getting the VM name */ public static String getDefaultVMInstallName(ILaunchConfiguration configuration) throws CoreException { IJavaProject javaProject = JavaRuntime.getJavaProject(configuration); IVMInstall vmInstall = null; if (javaProject != null) { vmInstall = JavaRuntime.getVMInstall(javaProject); } if (vmInstall != null) { return vmInstall.getName(); } return VMUtil.getDefaultVMInstallName(); }
public static IVMInstall getVMInstall(String name) { if (name != null) { IVMInstall[] installs = getAllVMInstances(); for (int i = 0; i < installs.length; i++) { if (installs[i].getName().equals(name)) return installs[i]; } } return JavaRuntime.getDefaultVMInstall(); }
IExecutionEnvironment[] exeEnvs = VMUtil.getExecutionEnvironments(); ArrayList<String> availableEEs = new ArrayList<>(); availableEEs.add(NO_EXECUTION_ENVIRONMENT); for (int i = 0; i < EEChoices.length; i++) { if (!EEChoices[i].equals(NO_EXECUTION_ENVIRONMENT)) { if (VMUtil.getExecutionEnvironment(EEChoices[i]).isStrictlyCompatible(defaultVM)) { fEEChoice.select(i); break;
String eeid = fEEChoice.getText(); if (fEEChoice.isEnabled()) { IExecutionEnvironment ee = VMUtil.getExecutionEnvironment(eeid); if (ee != null && ee.getCompatibleVMs().length == 0) { warningMessage = PDEUIMessages.NewProjectCreationPage_invalidEE;