/** Loads combo choices fromt he platform and from PDE core preferences */ private void initializeChoices() { IEclipsePreferences node = new InstanceScope().getNode(PDECore.PLUGIN_ID); fOSChoices = new TreeSet<String>(); String[] os = Platform.knownOSValues(); for (int i = 0; i < os.length; i++) { fOSChoices.add(os[i]); } String pref = node.get(ICoreConstants.OS_EXTRA, EMPTY_STRING); if (!EMPTY_STRING.equals(pref)) { addExtraChoices(fOSChoices, pref); } fWSChoices = new TreeSet<String>(); String[] ws = Platform.knownWSValues(); for (int i = 0; i < ws.length; i++) { fWSChoices.add(ws[i]); } pref = node.get(ICoreConstants.WS_EXTRA, EMPTY_STRING); if (!EMPTY_STRING.equals(pref)) { addExtraChoices(fWSChoices, pref); } fArchChoices = new TreeSet<String>(); String[] arch = Platform.knownOSArchValues(); for (int i = 0; i < arch.length; i++) { fArchChoices.add(arch[i]); } pref = node.get(ICoreConstants.ARCH_EXTRA, EMPTY_STRING); if (!EMPTY_STRING.equals(pref)) { addExtraChoices(fArchChoices, pref); } fNLChoices = new TreeSet<String>(); String[] nl = LocaleUtil.getLocales(); for (int i = 0; i < nl.length; i++) { fNLChoices.add(nl[i]); } pref = node.get(ICoreConstants.NL_EXTRA, EMPTY_STRING); if (!EMPTY_STRING.equals(pref)) { addExtraChoices(fNLChoices, pref); } }
/** Initializes the combo with possible execution environments */ protected void initializeJREValues() { fExecEnvChoices = new TreeSet<String>(); IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); IExecutionEnvironment[] envs = manager.getExecutionEnvironments(); for (int i = 0; i < envs.length; i++) fExecEnvChoices.add(envs[i].getId()); }
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( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateJREWidgets(); getTargetDefinition().setJREContainer(JavaRuntime.newDefaultJREContainerPath()); } }); fNamedJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_JREName); fNamedJREButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent 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( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getVMInstall(fNamedJREsCombo.getText()))); } }); fExecEnvButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_ExecutionEnv); fExecEnvButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent 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( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText()))); } }); }
private void createTargetEnvironmentGroup(Composite container) { Group group = SWTFactory.createGroup( container, PDEUIMessages.EnvironmentBlock_targetEnv, 2, 1, GridData.FILL_HORIZONTAL); initializeChoices(); SWTFactory.createWrapLabel(group, PDEUIMessages.EnvironmentSection_description, 2); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_os, 1); fOSCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fOSChoices.toArray(new String[fOSChoices.size()])); fOSCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition().setOS(getModelValue(fOSCombo.getText())); } }); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_ws, 1); fWSCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fWSChoices.toArray(new String[fWSChoices.size()])); fWSCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition().setWS(getModelValue(fWSCombo.getText())); } }); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_arch, 1); fArchCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fArchChoices.toArray(new String[fArchChoices.size()])); fArchCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition().setArch(getModelValue(fArchCombo.getText())); } }); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_nl, 1); fNLCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fNLChoices.toArray(new String[fNLChoices.size()])); fNLCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { String value = fNLCombo.getText(); int index = value.indexOf("-"); // $NON-NLS-1$ if (index > 0) value = value.substring(0, index); getTargetDefinition().setNL(getModelValue(value)); } }); }
/* (non-Javadoc) * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged() */ protected void targetChanged(ITargetDefinition definition) { super.targetChanged(definition); if (definition != null) { // When If the page isn't open yet, try running a UI job so the dialog has time to finish // opening new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) { public IStatus runInUIThread(IProgressMonitor monitor) { ITargetDefinition definition = getTargetDefinition(); if (!definition.isResolved()) { try { getContainer() .run( true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { getTargetDefinition().resolve(new ResolutionProgressMonitor(monitor)); if (monitor.isCanceled()) { throw new InterruptedException(); } } }); } catch (InvocationTargetException e) { PDECore.log(e); } catch (InterruptedException e) { fContentTree.setCancelled(); return Status.CANCEL_STATUS; } } fContentTree.setInput(definition); fLocationTree.setInput(definition); if (definition.isResolved() && definition.getStatus().getSeverity() == IStatus.ERROR) { fLocationTab.setImage( PlatformUI.getWorkbench() .getSharedImages() .getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); } else { fLocationTab.setImage(null); } return Status.OK_STATUS; } }.schedule(); String name = definition.getName(); if (name == null) { name = EMPTY_STRING; } if (name.trim().length() > 0) fNameText.setText(name); else setMessage(PDEUIMessages.TargetDefinitionContentPage_8); fLocationTree.setInput(definition); fContentTree.setInput(definition); String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS(); fOSCombo.setText(presetValue); presetValue = (definition.getWS() == null) ? EMPTY_STRING : definition.getWS(); fWSCombo.setText(presetValue); presetValue = (definition.getArch() == null) ? EMPTY_STRING : definition.getArch(); fArchCombo.setText(presetValue); presetValue = (definition.getNL() == null) ? EMPTY_STRING : LocaleUtil.expandLocaleName(definition.getNL()); fNLCombo.setText(presetValue); IPath jrePath = definition.getJREContainer(); if (jrePath == null || jrePath.equals(JavaRuntime.newDefaultJREContainerPath())) { fDefaultJREButton.setSelection(true); } else { String ee = JavaRuntime.getExecutionEnvironmentId(jrePath); if (ee != null) { fExecEnvButton.setSelection(true); fExecEnvsCombo.select(fExecEnvsCombo.indexOf(ee)); } else { String vm = JavaRuntime.getVMInstallName(jrePath); if (vm != null) { fNamedJREButton.setSelection(true); fNamedJREsCombo.select(fNamedJREsCombo.indexOf(vm)); } } } if (fExecEnvsCombo.getSelectionIndex() == -1) fExecEnvsCombo.setText(fExecEnvChoices.first().toString()); if (fNamedJREsCombo.getSelectionIndex() == -1) fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName()); updateJREWidgets(); presetValue = (definition.getProgramArguments() == null) ? EMPTY_STRING : definition.getProgramArguments(); fProgramArgs.setText(presetValue); presetValue = (definition.getVMArguments() == null) ? EMPTY_STRING : definition.getVMArguments(); fVMArgs.setText(presetValue); fElementViewer.refresh(); } }