View | Details | Raw Unified | Return to bug 217908 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/ui/editor/product/JRESection.java (-10 / +26 lines)
Lines 7-23 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Cabe - bug 217908
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.product;
12
package org.eclipse.pde.internal.ui.editor.product;
12
13
13
import com.ibm.icu.text.MessageFormat;
14
import com.ibm.icu.text.MessageFormat;
14
import java.util.ArrayList;
15
import java.util.*;
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.Platform;
17
import org.eclipse.core.runtime.Platform;
17
import org.eclipse.jdt.launching.IVMInstall;
18
import org.eclipse.jdt.launching.IVMInstall;
18
import org.eclipse.jdt.launching.JavaRuntime;
19
import org.eclipse.jdt.launching.JavaRuntime;
19
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
20
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
20
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
21
import org.eclipse.jface.layout.GridDataFactory;
21
import org.eclipse.jface.layout.GridDataFactory;
22
import org.eclipse.pde.core.IModelChangedEvent;
22
import org.eclipse.pde.core.IModelChangedEvent;
23
import org.eclipse.pde.core.plugin.TargetPlatform;
23
import org.eclipse.pde.core.plugin.TargetPlatform;
Lines 179-186 Link Here
179
179
180
	private void initializeExecutionEnvironments() {
180
	private void initializeExecutionEnvironments() {
181
		fEEChoices = new ArrayList();
181
		fEEChoices = new ArrayList();
182
		IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
182
		IExecutionEnvironment[] envs = VMHelper.getExecutionEnvironments();
183
		IExecutionEnvironment[] envs = manager.getExecutionEnvironments();
184
		for (int i = 0; i < envs.length; i++) {
183
		for (int i = 0; i < envs.length; i++) {
185
			addToEECombo(envs[i]);
184
			addToEECombo(envs[i]);
186
		}
185
		}
Lines 189-206 Link Here
189
	/**
188
	/**
190
	 * Adds the given execution environment to the list of known EEs and
189
	 * Adds the given execution environment to the list of known EEs and
191
	 * adds an entry to the combo box "EE_ID (Associated_VM)".  The entries
190
	 * adds an entry to the combo box "EE_ID (Associated_VM)".  The entries
192
	 * will always be added to the end of the list/combo.
191
	 * will be added at the right position in the list/combo given the alphabetical order
192
	 * of "EE_ID (Associated_VM).
193
	 * @param env environment to add
193
	 * @param env environment to add
194
	 * @return the position the environment where inserted at into the list/combo
194
	 */
195
	 */
195
	private void addToEECombo(IExecutionEnvironment env) {
196
	private int addToEECombo(IExecutionEnvironment env) {
196
		IPath path = JavaRuntime.newJREContainerPath(env);
197
		IPath path = JavaRuntime.newJREContainerPath(env);
197
		IVMInstall install = JavaRuntime.getVMInstall(path);
198
		IVMInstall install = JavaRuntime.getVMInstall(path);
198
		fEEChoices.add(env);
199
		String eeItem;
199
		if (install != null) {
200
		if (install != null) {
200
			fEEsCombo.add(MessageFormat.format(PDEUIMessages.JRESection_eeBoundJRE, new String[] {env.getId(), install.getName()}));
201
			eeItem = MessageFormat.format(PDEUIMessages.JRESection_eeBoundJRE, new String[] {env.getId(), install.getName()});
201
		} else {
202
		} else {
202
			fEEsCombo.add(MessageFormat.format(PDEUIMessages.JRESection_eeUnboundJRE, new String[] {env.getId()}));
203
			eeItem = MessageFormat.format(PDEUIMessages.JRESection_eeUnboundJRE, new String[] {env.getId()});
203
		}
204
		}
205
		int insertionIndex = Arrays.binarySearch(fEEsCombo.getItems(), eeItem, getEEComparator());
206
		if (insertionIndex < 0)
207
			insertionIndex = (insertionIndex * -1) - 1;
208
		fEEsCombo.add(eeItem, insertionIndex);
209
		fEEChoices.add(insertionIndex, env);
210
211
		return insertionIndex;
212
	}
213
214
	private Comparator getEEComparator() {
215
		return new Comparator() {
216
			public int compare(Object arg0, Object arg1) {
217
				return arg0.toString().compareTo(arg1.toString());
218
			}
219
		};
204
	}
220
	}
205
221
206
	private IProductModel getProductModel() {
222
	private IProductModel getProductModel() {
Lines 248-254 Link Here
248
			if (env != null) {
264
			if (env != null) {
249
				if (!fEEChoices.contains(env))
265
				if (!fEEChoices.contains(env))
250
					addToEECombo(env);
266
					addToEECombo(env);
251
				fEEsCombo.select(fEEsCombo.getItemCount() - 1);
267
				fEEsCombo.select(fEEChoices.indexOf(env));
252
				fEERadioButton.setSelection(true);
268
				fEERadioButton.setSelection(true);
253
				fJRERadioButton.setSelection(false);
269
				fJRERadioButton.setSelection(false);
254
			} else {
270
			} else {

Return to bug 217908