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

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/ui/wizards/target/TargetDefinitionContentPage.java (-115 / +699 lines)
Lines 1-115 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.wizards.target;
11
package org.eclipse.pde.internal.ui.wizards.target;
12
12
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
13
import java.util.*;
14
import org.eclipse.pde.internal.ui.PDEPluginImages;
14
import org.eclipse.core.runtime.*;
15
import org.eclipse.pde.internal.ui.PDEUIMessages;
15
import org.eclipse.debug.ui.StringVariableSelectionDialog;
16
import org.eclipse.pde.internal.ui.shared.target.BundleContainerTable;
16
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
17
import org.eclipse.swt.SWT;
17
import org.eclipse.jdt.launching.JavaRuntime;
18
import org.eclipse.swt.events.ModifyEvent;
18
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
19
import org.eclipse.swt.events.ModifyListener;
19
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
20
import org.eclipse.swt.layout.GridData;
20
import org.eclipse.jface.viewers.*;
21
import org.eclipse.swt.layout.GridLayout;
21
import org.eclipse.jface.window.Window;
22
import org.eclipse.swt.widgets.*;
22
import org.eclipse.osgi.service.resolver.BundleDescription;
23
23
import org.eclipse.pde.core.plugin.IPluginModelBase;
24
/**
24
import org.eclipse.pde.core.plugin.PluginRegistry;
25
 *
25
import org.eclipse.pde.internal.core.ICoreConstants;
26
 */
26
import org.eclipse.pde.internal.core.PDECore;
27
public class TargetDefinitionContentPage extends TargetDefinitionPage {
27
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
28
28
import org.eclipse.pde.internal.core.util.VMUtil;
29
	private Text fNameText;
29
import org.eclipse.pde.internal.ui.*;
30
	private Text fDescriptionText;
30
import org.eclipse.pde.internal.ui.elements.DefaultTableProvider;
31
	private BundleContainerTable fTable;
31
import org.eclipse.pde.internal.ui.shared.target.BundleContainerTable;
32
32
import org.eclipse.pde.internal.ui.util.LocaleUtil;
33
	/**
33
import org.eclipse.pde.internal.ui.util.SWTUtil;
34
	 * @param pageName
34
import org.eclipse.swt.SWT;
35
	 */
35
import org.eclipse.swt.events.*;
36
	public TargetDefinitionContentPage(ITargetDefinition target) {
36
import org.eclipse.swt.layout.GridData;
37
		super("targetContent", target); //$NON-NLS-1$
37
import org.eclipse.swt.layout.GridLayout;
38
		setTitle(PDEUIMessages.TargetDefinitionContentPage_1);
38
import org.eclipse.swt.widgets.*;
39
		setDescription(PDEUIMessages.TargetDefinitionContentPage_2);
39
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
40
		setImageDescriptor(PDEPluginImages.DESC_TARGET_WIZ);
40
41
	}
41
/**
42
42
 *
43
	/* (non-Javadoc)
43
 */
44
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
44
public class TargetDefinitionContentPage extends TargetDefinitionPage {
45
	 */
45
46
	public void createControl(Composite parent) {
46
	private Text fNameText;
47
		Composite comp = new Composite(parent, SWT.NONE);
47
	private Text fDescriptionText;
48
		comp.setLayout(new GridLayout(1, true));
48
	private BundleContainerTable fTable;
49
		comp.setLayoutData(new GridData(GridData.FILL_BOTH));
49
50
50
	// Environment pull-downs
51
		Group group = new Group(comp, SWT.NONE);
51
	private Combo fOSCombo;
52
		group.setText(PDEUIMessages.TargetDefinitionContentPage_3);
52
	private Combo fWSCombo;
53
		group.setLayout(new GridLayout(2, false));
53
	private Combo fArchCombo;
54
		group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
54
	private Combo fNLCombo;
55
55
56
		Label label = new Label(group, SWT.NONE);
56
	// Choices for each pull-down
57
		label.setText(PDEUIMessages.TargetDefinitionContentPage_4);
57
	private TreeSet fNLChoices;
58
		GridData gridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
58
	private TreeSet fOSChoices;
59
		label.setLayoutData(gridData);
59
	private TreeSet fWSChoices;
60
60
	private TreeSet fArchChoices;
61
		fNameText = new Text(group, SWT.BORDER);
61
62
		gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
62
	// JRE section
63
		fNameText.setLayoutData(gridData);
63
	private Button fDefaultJREButton;
64
		fNameText.addModifyListener(new ModifyListener() {
64
	private Button fNamedJREButton;
65
			public void modifyText(ModifyEvent e) {
65
	private Button fExecEnvButton;
66
				getTargetDefinition().setName(fNameText.getText().trim());
66
	private Combo fNamedJREsCombo;
67
			}
67
	private Combo fExecEnvsCombo;
68
		});
68
	private TreeSet fExecEnvChoices;
69
69
70
		label = new Label(group, SWT.NONE);
70
	// argument controls
71
		label.setText(PDEUIMessages.TargetDefinitionContentPage_5);
71
	private Text fProgramArgs;
72
		gridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
72
	private Text fVMArgs;
73
		label.setLayoutData(gridData);
73
	private Button fAppendLauncherArgs;
74
74
75
		fDescriptionText = new Text(group, SWT.BORDER);
75
	// implicit dependencies tab
76
		gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
76
	private TableViewer fElementViewer;
77
		fDescriptionText.setLayoutData(gridData);
77
	private Button fAddButton;
78
		fDescriptionText.addModifyListener(new ModifyListener() {
78
	private Button fRemoveButton;
79
			public void modifyText(ModifyEvent e) {
79
	private Button fRemoveAllButton;
80
				getTargetDefinition().setDescription(fDescriptionText.getText().trim());
80
81
			}
81
	/**
82
		});
82
	 * @param pageName
83
83
	 */
84
		Group content = new Group(comp, SWT.NONE);
84
	public TargetDefinitionContentPage(ITargetDefinition target) {
85
		content.setText(PDEUIMessages.TargetDefinitionContentPage_6);
85
		super("targetContent", target); //$NON-NLS-1$
86
		content.setLayout(new GridLayout(2, false));
86
		setTitle(PDEUIMessages.TargetDefinitionContentPage_1);
87
		gridData = new GridData(GridData.FILL_BOTH);
87
		setDescription(PDEUIMessages.TargetDefinitionContentPage_2);
88
		gridData.widthHint = 200;
88
		setImageDescriptor(PDEPluginImages.DESC_TARGET_WIZ);
89
		content.setLayoutData(gridData);
89
	}
90
90
91
		fTable = BundleContainerTable.createTableInDialog(content);
91
	/* (non-Javadoc)
92
		setControl(comp);
92
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
93
		targetChanged(getTargetDefinition());
93
	 */
94
	}
94
	public void createControl(Composite parent) {
95
95
		Composite comp = new Composite(parent, SWT.NONE);
96
	/* (non-Javadoc)
96
		comp.setLayout(new GridLayout(1, true));
97
	 * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
97
		comp.setLayoutData(new GridData(GridData.FILL_BOTH));
98
	 */
98
99
	protected void targetChanged(ITargetDefinition definition) {
99
		Group group = new Group(comp, SWT.NONE);
100
		super.targetChanged(definition);
100
		group.setText(PDEUIMessages.TargetDefinitionContentPage_3);
101
		if (definition != null) {
101
		group.setLayout(new GridLayout(2, false));
102
			String name = definition.getName();
102
		group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
103
			if (name == null) {
103
104
				name = ""; //$NON-NLS-1$
104
		Label label = new Label(group, SWT.NONE);
105
			}
105
		label.setText(PDEUIMessages.TargetDefinitionContentPage_4);
106
			fNameText.setText(name);
106
		GridData gridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
107
			String des = definition.getDescription();
107
		label.setLayoutData(gridData);
108
			if (des == null) {
108
109
				des = ""; //$NON-NLS-1$
109
		fNameText = new Text(group, SWT.BORDER);
110
			}
110
		gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
111
			fDescriptionText.setText(des);
111
		fNameText.setLayoutData(gridData);
112
			fTable.setInput(definition);
112
		fNameText.addModifyListener(new ModifyListener() {
113
		}
113
			public void modifyText(ModifyEvent e) {
114
	}
114
				getTargetDefinition().setName(fNameText.getText().trim());
115
}
115
			}
116
		});
117
118
		label = new Label(group, SWT.NONE);
119
		label.setText(PDEUIMessages.TargetDefinitionContentPage_5);
120
		gridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
121
		label.setLayoutData(gridData);
122
123
		fDescriptionText = new Text(group, SWT.BORDER);
124
		gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
125
		fDescriptionText.setLayoutData(gridData);
126
		fDescriptionText.addModifyListener(new ModifyListener() {
127
			public void modifyText(ModifyEvent e) {
128
				getTargetDefinition().setDescription(fDescriptionText.getText().trim());
129
			}
130
		});
131
132
		TabFolder tabs = new TabFolder(comp, SWT.NONE);
133
		tabs.setLayoutData(new GridData(GridData.FILL_BOTH));
134
		Composite container = new Composite(tabs, SWT.NONE);
135
		GridLayout layout = new GridLayout();
136
		layout.verticalSpacing = 15;
137
		container.setLayout(layout);
138
		container.setLayoutData(new GridData(GridData.FILL_BOTH));
139
140
		TabItem pluginsTab = new TabItem(tabs, SWT.NONE);
141
		pluginsTab.setText(PDEUIMessages.TargetDefinitionContentPage_6);
142
		Composite content = new Composite(tabs, SWT.NONE);
143
		GridLayout lo = new GridLayout(2, false);
144
		lo.marginWidth = 0;
145
		lo.marginHeight = 0;
146
		content.setLayout(lo);
147
		gridData = new GridData(GridData.FILL_BOTH);
148
		gridData.widthHint = 200;
149
		content.setLayoutData(gridData);
150
		fTable = BundleContainerTable.createTableInDialog(content);
151
		pluginsTab.setControl(content);
152
153
		TabItem envTab = new TabItem(tabs, SWT.NONE);
154
		envTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_3);
155
156
		createTargetEnvironmentGroup(container);
157
		createJREGroup(container);
158
		envTab.setControl(container);
159
160
		TabItem argsTab = new TabItem(tabs, SWT.NONE);
161
		argsTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_4);
162
		argsTab.setControl(createArgumentsGroup(tabs));
163
164
		TabItem depTab = new TabItem(tabs, SWT.NONE);
165
		depTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_5);
166
		depTab.setControl(createImplicitTabContents(tabs));
167
168
		setControl(comp);
169
		targetChanged(getTargetDefinition());
170
	}
171
172
	/* (non-Javadoc)
173
	 * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
174
	 */
175
	protected void targetChanged(ITargetDefinition definition) {
176
		super.targetChanged(definition);
177
		if (definition != null) {
178
			String name = definition.getName();
179
			if (name == null) {
180
				name = ""; //$NON-NLS-1$
181
			}
182
			fNameText.setText(name);
183
			String des = definition.getDescription();
184
			if (des == null) {
185
				des = ""; //$NON-NLS-1$
186
			}
187
			fDescriptionText.setText(des);
188
			fTable.setInput(definition);
189
190
			String presetValue = (definition.getOS() == null) ? "" : definition.getOS(); //$NON-NLS-1$
191
			fOSCombo.setText(presetValue);
192
			presetValue = (definition.getWS() == null) ? "" : definition.getWS(); //$NON-NLS-1$
193
			fWSCombo.setText(presetValue);
194
			presetValue = (definition.getArch() == null) ? "" : definition.getArch(); //$NON-NLS-1$
195
			fArchCombo.setText(presetValue);
196
			presetValue = (definition.getNL() == null) ? "" : LocaleUtil.expandLocaleName(definition.getNL()); //$NON-NLS-1$
197
			fNLCombo.setText(presetValue);
198
199
			IPath jrePath = definition.getJREContainer();
200
			if (jrePath == null || jrePath.equals(JavaRuntime.newDefaultJREContainerPath())) {
201
				fDefaultJREButton.setSelection(true);
202
			} else {
203
				String ee = JavaRuntime.getExecutionEnvironmentId(jrePath);
204
				if (ee != null) {
205
					fExecEnvButton.setSelection(true);
206
					fExecEnvsCombo.select(fExecEnvsCombo.indexOf(ee));
207
				} else {
208
					String vm = JavaRuntime.getVMInstallName(jrePath);
209
					if (vm != null) {
210
						fNamedJREButton.setSelection(true);
211
						fNamedJREsCombo.select(fNamedJREsCombo.indexOf(vm));
212
					}
213
				}
214
			}
215
216
			if (fExecEnvsCombo.getSelectionIndex() == -1)
217
				fExecEnvsCombo.setText(fExecEnvChoices.first().toString());
218
219
			if (fNamedJREsCombo.getSelectionIndex() == -1)
220
				fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName());
221
222
			updateJREWidgets();
223
224
			presetValue = (definition.getProgramArguments() == null) ? "" : definition.getProgramArguments(); //$NON-NLS-1$
225
			fProgramArgs.setText(presetValue);
226
			presetValue = (definition.getVMArguments() == null) ? "" : definition.getVMArguments(); //$NON-NLS-1$
227
			fVMArgs.setText(presetValue);
228
229
			fElementViewer.refresh();
230
		}
231
	}
232
233
	private void createTargetEnvironmentGroup(Composite container) {
234
		Group group = new Group(container, SWT.NULL);
235
		GridLayout layout = new GridLayout();
236
		layout.numColumns = 2;
237
		group.setLayout(layout);
238
		group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
239
		group.setText(PDEUIMessages.EnvironmentBlock_targetEnv);
240
241
		initializeChoices();
242
243
		Label label = new Label(group, SWT.NULL);
244
		label.setText(PDEUIMessages.Preferences_TargetEnvironmentPage_os);
245
246
		fOSCombo = new Combo(group, SWT.SINGLE | SWT.BORDER);
247
		fOSCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
248
		fOSCombo.setItems((String[]) fOSChoices.toArray(new String[fOSChoices.size()]));
249
		fOSCombo.addModifyListener(new ModifyListener() {
250
			public void modifyText(ModifyEvent e) {
251
				getTargetDefinition().setOS(getModelValue(fOSCombo.getText()));
252
			}
253
		});
254
255
		label = new Label(group, SWT.NULL);
256
		label.setText(PDEUIMessages.Preferences_TargetEnvironmentPage_ws);
257
258
		fWSCombo = new Combo(group, SWT.SINGLE | SWT.BORDER);
259
		fWSCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
260
		fWSCombo.setItems((String[]) fWSChoices.toArray(new String[fWSChoices.size()]));
261
		fWSCombo.addModifyListener(new ModifyListener() {
262
			public void modifyText(ModifyEvent e) {
263
				getTargetDefinition().setWS(getModelValue(fWSCombo.getText()));
264
			}
265
		});
266
267
		label = new Label(group, SWT.NULL);
268
		label.setText(PDEUIMessages.Preferences_TargetEnvironmentPage_arch);
269
270
		fArchCombo = new Combo(group, SWT.SINGLE | SWT.BORDER);
271
		fArchCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
272
		fArchCombo.setItems((String[]) fArchChoices.toArray(new String[fArchChoices.size()]));
273
		fArchCombo.addModifyListener(new ModifyListener() {
274
			public void modifyText(ModifyEvent e) {
275
				getTargetDefinition().setArch(getModelValue(fArchCombo.getText()));
276
			}
277
		});
278
279
		label = new Label(group, SWT.NULL);
280
		label.setText(PDEUIMessages.Preferences_TargetEnvironmentPage_nl);
281
282
		fNLCombo = new Combo(group, SWT.SINGLE | SWT.BORDER);
283
		fNLCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
284
		fNLCombo.setItems((String[]) fNLChoices.toArray(new String[fNLChoices.size()]));
285
		fNLCombo.addModifyListener(new ModifyListener() {
286
			public void modifyText(ModifyEvent e) {
287
				String value = fNLCombo.getText();
288
				int index = value.indexOf("-"); //$NON-NLS-1$
289
				if (index > 0)
290
					value = value.substring(0, index);
291
				getTargetDefinition().setNL(getModelValue(value));
292
			}
293
		});
294
295
	}
296
297
	/**
298
	 * Returns the given string or <code>null</code> if empty to set a value in the
299
	 * target definition.
300
	 * 
301
	 * @param value
302
	 * @return
303
	 */
304
	private String getModelValue(String value) {
305
		if (value != null) {
306
			value = value.trim();
307
			if (value.length() == 0) {
308
				return null;
309
			}
310
		}
311
		return value;
312
	}
313
314
	private void addExtraChoices(Set set, String preference) {
315
		StringTokenizer tokenizer = new StringTokenizer(preference, ","); //$NON-NLS-1$
316
		while (tokenizer.hasMoreTokens()) {
317
			set.add(tokenizer.nextToken().trim());
318
		}
319
	}
320
321
	private void initializeChoices() {
322
		Preferences preferences = PDECore.getDefault().getPluginPreferences();
323
324
		fOSChoices = new TreeSet();
325
		String[] os = Platform.knownOSValues();
326
		for (int i = 0; i < os.length; i++)
327
			fOSChoices.add(os[i]);
328
		addExtraChoices(fOSChoices, preferences.getString(ICoreConstants.OS_EXTRA));
329
330
		fWSChoices = new TreeSet();
331
		String[] ws = Platform.knownWSValues();
332
		for (int i = 0; i < ws.length; i++)
333
			fWSChoices.add(ws[i]);
334
		addExtraChoices(fWSChoices, preferences.getString(ICoreConstants.WS_EXTRA));
335
336
		fArchChoices = new TreeSet();
337
		String[] arch = Platform.knownOSArchValues();
338
		for (int i = 0; i < arch.length; i++)
339
			fArchChoices.add(arch[i]);
340
		addExtraChoices(fArchChoices, preferences.getString(ICoreConstants.ARCH_EXTRA));
341
342
		fNLChoices = new TreeSet();
343
		initializeAllLocales();
344
	}
345
346
	private void initializeAllLocales() {
347
		Preferences preferences = PDECore.getDefault().getPluginPreferences();
348
		String[] nl = LocaleUtil.getLocales();
349
		for (int i = 0; i < nl.length; i++)
350
			fNLChoices.add(nl[i]);
351
		addExtraChoices(fNLChoices, preferences.getString(ICoreConstants.NL_EXTRA));
352
	}
353
354
	private void createJREGroup(Composite container) {
355
		Group group = new Group(container, SWT.NULL);
356
		GridLayout layout = new GridLayout();
357
		layout.numColumns = 2;
358
		group.setLayout(layout);
359
		group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
360
		group.setText(PDEUIMessages.EnvironmentBlock_jreTitle);
361
362
		initializeJREValues();
363
364
		Label label = new Label(group, SWT.WRAP);
365
		label.setText(PDEUIMessages.JRESection_description);
366
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
367
		data.verticalAlignment = SWT.TOP;
368
		data.horizontalSpan = 2;
369
		label.setLayoutData(data);
370
371
		fDefaultJREButton = new Button(group, SWT.RADIO);
372
		fDefaultJREButton.setText(PDEUIMessages.JRESection_defaultJRE);
373
		GridData gd = new GridData();
374
		gd.horizontalSpan = 2;
375
		fDefaultJREButton.setLayoutData(gd);
376
		fDefaultJREButton.addSelectionListener(new SelectionAdapter() {
377
			public void widgetSelected(SelectionEvent e) {
378
				updateJREWidgets();
379
				getTargetDefinition().setJREContainer(JavaRuntime.newDefaultJREContainerPath());
380
			}
381
		});
382
383
		fNamedJREButton = new Button(group, SWT.RADIO);
384
		fNamedJREButton.setText(PDEUIMessages.JRESection_JREName);
385
		fNamedJREButton.addSelectionListener(new SelectionAdapter() {
386
			public void widgetSelected(SelectionEvent e) {
387
				updateJREWidgets();
388
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText())));
389
			}
390
		});
391
392
		fNamedJREsCombo = new Combo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
393
		fNamedJREsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
394
		String[] installs = VMUtil.getVMInstallNames();
395
		fNamedJREsCombo.setItems(installs);
396
		fNamedJREsCombo.addModifyListener(new ModifyListener() {
397
			public void modifyText(ModifyEvent e) {
398
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText())));
399
			}
400
		});
401
402
		fExecEnvButton = new Button(group, SWT.RADIO);
403
		fExecEnvButton.setText(PDEUIMessages.JRESection_ExecutionEnv);
404
		fExecEnvButton.addSelectionListener(new SelectionAdapter() {
405
			public void widgetSelected(SelectionEvent e) {
406
				updateJREWidgets();
407
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText())));
408
			}
409
		});
410
411
		fExecEnvsCombo = new Combo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
412
		fExecEnvsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
413
		fExecEnvsCombo.setItems((String[]) fExecEnvChoices.toArray(new String[fExecEnvChoices.size()]));
414
		fExecEnvsCombo.addModifyListener(new ModifyListener() {
415
			public void modifyText(ModifyEvent e) {
416
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText())));
417
			}
418
		});
419
420
	}
421
422
	/**
423
	 * Initializes the combo with possible execution enviroments
424
	 */
425
	protected void initializeJREValues() {
426
		fExecEnvChoices = new TreeSet();
427
		IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
428
		IExecutionEnvironment[] envs = manager.getExecutionEnvironments();
429
		for (int i = 0; i < envs.length; i++)
430
			fExecEnvChoices.add(envs[i].getId());
431
	}
432
433
	protected void updateJREWidgets() {
434
		fNamedJREsCombo.setEnabled(fNamedJREButton.getSelection());
435
		fExecEnvsCombo.setEnabled(fExecEnvButton.getSelection());
436
	}
437
438
	private Control createArgumentsGroup(Composite parent) {
439
		Composite container = new Composite(parent, SWT.NONE);
440
		container.setLayout(new GridLayout());
441
442
		Label description = new Label(container, SWT.WRAP);
443
		description.setText(PDEUIMessages.JavaArgumentsTab_description);
444
		GridData gd = new GridData();
445
		gd.widthHint = 200;
446
		description.setLayoutData(gd);
447
448
		Group programGroup = new Group(container, SWT.NONE);
449
		programGroup.setLayout(new GridLayout());
450
		programGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
451
		programGroup.setText(PDEUIMessages.JavaArgumentsTab_progamArgsGroup);
452
453
		fProgramArgs = new Text(programGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
454
		gd = new GridData(GridData.FILL_BOTH);
455
		gd.widthHint = 200;
456
		gd.heightHint = 60;
457
		fProgramArgs.setLayoutData(gd);
458
		fProgramArgs.addModifyListener(new ModifyListener() {
459
			public void modifyText(ModifyEvent e) {
460
				getTargetDefinition().setProgramArguments(fProgramArgs.getText().trim());
461
			}
462
		});
463
464
		Button programVars = new Button(programGroup, SWT.NONE);
465
		programVars.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
466
		programVars.setText(PDEUIMessages.JavaArgumentsTab_programVariables);
467
		programVars.addSelectionListener(getListener(fProgramArgs));
468
469
		Group vmGroup = new Group(container, SWT.NONE);
470
		vmGroup.setLayout(new GridLayout(2, false));
471
		vmGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
472
		vmGroup.setText(PDEUIMessages.JavaArgumentsTab_vmArgsGroup);
473
474
		fVMArgs = new Text(vmGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
475
		gd = new GridData(GridData.FILL_BOTH);
476
		gd.widthHint = 200;
477
		gd.heightHint = 60;
478
		gd.horizontalSpan = 2;
479
		fVMArgs.setLayoutData(gd);
480
		fVMArgs.addModifyListener(new ModifyListener() {
481
			public void modifyText(ModifyEvent e) {
482
				getTargetDefinition().setVMArguments(fVMArgs.getText().trim());
483
			}
484
		});
485
486
		fAppendLauncherArgs = new Button(vmGroup, SWT.CHECK);
487
		fAppendLauncherArgs.setText(PDEUIMessages.JavaArgumentsTab_appendLauncherIni);
488
489
		Button vmVars = new Button(vmGroup, SWT.NONE);
490
		vmVars.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
491
		vmVars.setText(PDEUIMessages.JavaArgumentsTab_vmVariables);
492
		vmVars.addSelectionListener(getListener(fVMArgs));
493
		return container;
494
	}
495
496
	protected SelectionListener getListener(final Text textControl) {
497
		return new SelectionListener() {
498
			public void widgetSelected(SelectionEvent e) {
499
				StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
500
				dialog.open();
501
				String variable = dialog.getVariableExpression();
502
				if (variable != null) {
503
					textControl.insert(variable);
504
				}
505
			}
506
507
			public void widgetDefaultSelected(SelectionEvent e) {
508
			}
509
		};
510
	}
511
512
	private Control createImplicitTabContents(Composite parent) {
513
		Composite container = new Composite(parent, SWT.NONE);
514
		GridLayout layout = new GridLayout(2, false);
515
		container.setLayout(layout);
516
		container.setLayoutData(new GridData(GridData.FILL_BOTH));
517
518
		createImpLabel(container);
519
		createImpTable(container);
520
		createImpButtons(container);
521
		// TODO: PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.IMPLICIT_PLUGINS_PREFERENCE_PAGE);
522
		return container;
523
	}
524
525
	private void createImpLabel(Composite container) {
526
		Label label = new Label(container, SWT.NONE);
527
		label.setText(PDEUIMessages.TargetImplicitPluginsTab_desc);
528
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
529
		gd.horizontalSpan = 2;
530
		label.setLayoutData(gd);
531
	}
532
533
	private void createImpTable(Composite container) {
534
		fElementViewer = new TableViewer(container, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
535
		GridData gd = new GridData(GridData.FILL_BOTH);
536
		fElementViewer.getControl().setLayoutData(gd);
537
		fElementViewer.setContentProvider(new DefaultTableProvider() {
538
			public Object[] getElements(Object inputElement) {
539
				ITargetDefinition target = getTargetDefinition();
540
				if (target != null) {
541
					BundleInfo[] bundles = target.getImplicitDependencies();
542
					if (bundles != null) {
543
						return bundles;
544
					}
545
				}
546
				return new BundleInfo[0];
547
			}
548
		});
549
		fElementViewer.setLabelProvider(new LabelProvider() {
550
			public String getText(Object element) {
551
				if (element instanceof BundleInfo) {
552
					return ((BundleInfo) element).getSymbolicName();
553
				}
554
				return super.getText(element);
555
			}
556
			// TODO: labels
557
		});
558
		fElementViewer.setInput(PDEPlugin.getDefault());
559
		fElementViewer.setComparator(new ViewerComparator() {
560
			public int compare(Viewer viewer, Object e1, Object e2) {
561
				BundleInfo bundle1 = (BundleInfo) e1;
562
				BundleInfo bundle2 = (BundleInfo) e2;
563
				return super.compare(viewer, bundle1.getSymbolicName(), bundle2.getSymbolicName());
564
			}
565
		});
566
		fElementViewer.addSelectionChangedListener(new ISelectionChangedListener() {
567
			public void selectionChanged(SelectionChangedEvent event) {
568
				updateImpButtons();
569
			}
570
		});
571
		fElementViewer.getTable().addKeyListener(new KeyAdapter() {
572
			public void keyPressed(KeyEvent e) {
573
				if (e.character == SWT.DEL && e.stateMask == 0) {
574
					handleRemove();
575
				}
576
			}
577
		});
578
579
	}
580
581
	private void createImpButtons(Composite container) {
582
		Composite buttonContainer = new Composite(container, SWT.NONE);
583
		GridLayout layout = new GridLayout();
584
		layout.marginWidth = layout.marginHeight = 0;
585
		buttonContainer.setLayout(layout);
586
		buttonContainer.setLayoutData(new GridData(GridData.FILL_VERTICAL));
587
588
		fAddButton = new Button(buttonContainer, SWT.PUSH);
589
		fAddButton.setText(PDEUIMessages.SourceBlock_add);
590
		fAddButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING));
591
		SWTUtil.setButtonDimensionHint(fAddButton);
592
		fAddButton.addSelectionListener(new SelectionAdapter() {
593
			public void widgetSelected(SelectionEvent e) {
594
				handleAdd();
595
			}
596
		});
597
598
		fRemoveButton = new Button(buttonContainer, SWT.PUSH);
599
		fRemoveButton.setText(PDEUIMessages.SourceBlock_remove);
600
		fRemoveButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING));
601
		SWTUtil.setButtonDimensionHint(fRemoveButton);
602
		fRemoveButton.addSelectionListener(new SelectionAdapter() {
603
			public void widgetSelected(SelectionEvent e) {
604
				handleRemove();
605
			}
606
		});
607
608
		fRemoveAllButton = new Button(buttonContainer, SWT.PUSH);
609
		fRemoveAllButton.setText(PDEUIMessages.TargetImplicitPluginsTab_removeAll3);
610
		fRemoveAllButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING));
611
		SWTUtil.setButtonDimensionHint(fRemoveAllButton);
612
		fRemoveAllButton.addSelectionListener(new SelectionAdapter() {
613
			public void widgetSelected(SelectionEvent e) {
614
				handleRemoveAll();
615
			}
616
		});
617
		updateImpButtons();
618
	}
619
620
	protected void handleAdd() {
621
		ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), PDEPlugin.getDefault().getLabelProvider());
622
623
		dialog.setElements(getValidBundles());
624
		dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title);
625
		dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message);
626
		dialog.setMultipleSelection(true);
627
		if (dialog.open() == Window.OK) {
628
			Object[] models = dialog.getResult();
629
			ArrayList pluginsToAdd = new ArrayList();
630
			for (int i = 0; i < models.length; i++) {
631
				BundleDescription desc = ((BundleDescription) models[i]);
632
				pluginsToAdd.add(new BundleInfo(desc.getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false));
633
			}
634
			Set allDependencies = new HashSet();
635
			allDependencies.addAll(pluginsToAdd);
636
			BundleInfo[] currentBundles = getTargetDefinition().getImplicitDependencies();
637
			if (currentBundles != null) {
638
				allDependencies.addAll(Arrays.asList(currentBundles));
639
			}
640
			getTargetDefinition().setImplicitDependencies((BundleInfo[]) allDependencies.toArray(new BundleInfo[allDependencies.size()]));
641
			fElementViewer.refresh();
642
			// update target
643
		}
644
	}
645
646
	/**
647
	 * Gets a list of all the bundles that can be added as implicit dependencies
648
	 * @return list of possible dependencies
649
	 */
650
	protected BundleDescription[] getValidBundles() {
651
		BundleInfo[] current = getTargetDefinition().getImplicitDependencies();
652
		Set currentBundles = new HashSet();
653
		if (current != null) {
654
			for (int i = 0; i < current.length; i++) {
655
				currentBundles.add(current[i].getSymbolicName());
656
			}
657
		}
658
659
		// TODO Do we want to get the possible models from the plugin registry?  Would be better to get the bundles from the editor's target definition?
660
		IPluginModelBase[] models = PluginRegistry.getActiveModels(false);
661
		Set result = new HashSet();
662
		for (int i = 0; i < models.length; i++) {
663
			BundleDescription desc = models[i].getBundleDescription();
664
			if (desc != null) {
665
				if (!currentBundles.contains(desc.getSymbolicName()))
666
					result.add(desc);
667
			}
668
		}
669
670
		return (BundleDescription[]) result.toArray((new BundleDescription[result.size()]));
671
	}
672
673
	private void handleRemove() {
674
		LinkedList bundles = new LinkedList();
675
		bundles.addAll(Arrays.asList(getTargetDefinition().getImplicitDependencies()));
676
		Object[] removeBundles = ((IStructuredSelection) fElementViewer.getSelection()).toArray();
677
		if (removeBundles.length > 0) {
678
			for (int i = 0; i < removeBundles.length; i++) {
679
				if (removeBundles[i] instanceof BundleInfo) {
680
					bundles.remove(removeBundles[i]);
681
				}
682
			}
683
			getTargetDefinition().setImplicitDependencies((BundleInfo[]) bundles.toArray((new BundleInfo[bundles.size()])));
684
			fElementViewer.refresh();
685
		}
686
	}
687
688
	private void handleRemoveAll() {
689
		getTargetDefinition().setImplicitDependencies(null);
690
		fElementViewer.refresh();
691
	}
692
693
	private void updateImpButtons() {
694
		boolean empty = fElementViewer.getSelection().isEmpty();
695
		fRemoveButton.setEnabled(!empty);
696
		boolean hasElements = fElementViewer.getTable().getItemCount() > 0;
697
		fRemoveAllButton.setEnabled(hasElements);
698
	}
699
}
(-)src/org/eclipse/pde/internal/ui/wizards/target/TargetDefinitionEnvironmentPage.java (-636 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.wizards.target;
12
13
import org.eclipse.pde.internal.ui.PDEUIMessages;
14
15
import java.util.*;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.debug.ui.StringVariableSelectionDialog;
18
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
19
import org.eclipse.jdt.launching.JavaRuntime;
20
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
21
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
22
import org.eclipse.jface.viewers.*;
23
import org.eclipse.jface.window.Window;
24
import org.eclipse.osgi.service.resolver.BundleDescription;
25
import org.eclipse.pde.core.plugin.IPluginModelBase;
26
import org.eclipse.pde.core.plugin.PluginRegistry;
27
import org.eclipse.pde.internal.core.ICoreConstants;
28
import org.eclipse.pde.internal.core.PDECore;
29
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
30
import org.eclipse.pde.internal.core.util.VMUtil;
31
import org.eclipse.pde.internal.ui.*;
32
import org.eclipse.pde.internal.ui.elements.DefaultTableProvider;
33
import org.eclipse.pde.internal.ui.util.LocaleUtil;
34
import org.eclipse.pde.internal.ui.util.SWTUtil;
35
import org.eclipse.swt.SWT;
36
import org.eclipse.swt.events.*;
37
import org.eclipse.swt.layout.GridData;
38
import org.eclipse.swt.layout.GridLayout;
39
import org.eclipse.swt.widgets.*;
40
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
41
42
/**
43
 * Page to edit environment and JRE settings for a target definition
44
 */
45
public class TargetDefinitionEnvironmentPage extends TargetDefinitionPage {
46
47
	// Environment pull-downs
48
	private Combo fOSCombo;
49
	private Combo fWSCombo;
50
	private Combo fArchCombo;
51
	private Combo fNLCombo;
52
53
	// Choices for each pull-down
54
	private TreeSet fNLChoices;
55
	private TreeSet fOSChoices;
56
	private TreeSet fWSChoices;
57
	private TreeSet fArchChoices;
58
59
	// JRE section
60
	private Button fDefaultJREButton;
61
	private Button fNamedJREButton;
62
	private Button fExecEnvButton;
63
	private Combo fNamedJREsCombo;
64
	private Combo fExecEnvsCombo;
65
	private TreeSet fExecEnvChoices;
66
67
	// argument controls
68
	private Text fProgramArgs;
69
	private Text fVMArgs;
70
	private Button fAppendLauncherArgs;
71
72
	// implicit dependencies tab
73
	private TableViewer fElementViewer;
74
	private Button fAddButton;
75
	private Button fRemoveButton;
76
	private Button fRemoveAllButton;
77
78
	/**
79
	 * 
80
	 * @param definition target definition to edit
81
	 */
82
	protected TargetDefinitionEnvironmentPage(ITargetDefinition definition) {
83
		super("targetEnvironment", definition); //$NON-NLS-1$
84
		setTitle(PDEUIMessages.TargetDefinitionEnvironmentPage_1);
85
		setDescription(PDEUIMessages.TargetDefinitionEnvironmentPage_2);
86
		setImageDescriptor(PDEPluginImages.DESC_TARGET_WIZ);
87
	}
88
89
	/* (non-Javadoc)
90
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
91
	 */
92
	public void createControl(Composite parent) {
93
		Composite comp = new Composite(parent, SWT.NONE);
94
		comp.setLayout(new GridLayout(1, true));
95
		comp.setLayoutData(new GridData(GridData.FILL_BOTH));
96
		setControl(comp);
97
		TabFolder tabs = new TabFolder(comp, SWT.NONE);
98
		tabs.setLayoutData(new GridData(GridData.FILL_BOTH));
99
100
		TabItem envTab = new TabItem(tabs, SWT.NONE);
101
		envTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_3);
102
103
		Composite container = new Composite(tabs, SWT.NONE);
104
		GridLayout layout = new GridLayout();
105
		layout.verticalSpacing = 15;
106
		container.setLayout(layout);
107
		container.setLayoutData(new GridData(GridData.FILL_BOTH));
108
109
		createTargetEnvironmentGroup(container);
110
		createJREGroup(container);
111
		envTab.setControl(container);
112
113
		TabItem argsTab = new TabItem(tabs, SWT.NONE);
114
		argsTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_4);
115
		argsTab.setControl(createArgumentsGroup(tabs));
116
117
		TabItem depTab = new TabItem(tabs, SWT.NONE);
118
		depTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_5);
119
		depTab.setControl(createImplicitTabContents(tabs));
120
121
		targetChanged(getTargetDefinition());
122
	}
123
124
	private void createTargetEnvironmentGroup(Composite container) {
125
		Group group = new Group(container, SWT.NULL);
126
		GridLayout layout = new GridLayout();
127
		layout.numColumns = 2;
128
		group.setLayout(layout);
129
		group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
130
		group.setText(PDEUIMessages.EnvironmentBlock_targetEnv);
131
132
		initializeChoices();
133
134
		Label label = new Label(group, SWT.NULL);
135
		label.setText(PDEUIMessages.Preferences_TargetEnvironmentPage_os);
136
137
		fOSCombo = new Combo(group, SWT.SINGLE | SWT.BORDER);
138
		fOSCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
139
		fOSCombo.setItems((String[]) fOSChoices.toArray(new String[fOSChoices.size()]));
140
		fOSCombo.addModifyListener(new ModifyListener() {
141
			public void modifyText(ModifyEvent e) {
142
				getTargetDefinition().setOS(getModelValue(fOSCombo.getText()));
143
			}
144
		});
145
146
		label = new Label(group, SWT.NULL);
147
		label.setText(PDEUIMessages.Preferences_TargetEnvironmentPage_ws);
148
149
		fWSCombo = new Combo(group, SWT.SINGLE | SWT.BORDER);
150
		fWSCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
151
		fWSCombo.setItems((String[]) fWSChoices.toArray(new String[fWSChoices.size()]));
152
		fWSCombo.addModifyListener(new ModifyListener() {
153
			public void modifyText(ModifyEvent e) {
154
				getTargetDefinition().setWS(getModelValue(fWSCombo.getText()));
155
			}
156
		});
157
158
		label = new Label(group, SWT.NULL);
159
		label.setText(PDEUIMessages.Preferences_TargetEnvironmentPage_arch);
160
161
		fArchCombo = new Combo(group, SWT.SINGLE | SWT.BORDER);
162
		fArchCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
163
		fArchCombo.setItems((String[]) fArchChoices.toArray(new String[fArchChoices.size()]));
164
		fArchCombo.addModifyListener(new ModifyListener() {
165
			public void modifyText(ModifyEvent e) {
166
				getTargetDefinition().setArch(getModelValue(fArchCombo.getText()));
167
			}
168
		});
169
170
		label = new Label(group, SWT.NULL);
171
		label.setText(PDEUIMessages.Preferences_TargetEnvironmentPage_nl);
172
173
		fNLCombo = new Combo(group, SWT.SINGLE | SWT.BORDER);
174
		fNLCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
175
		fNLCombo.setItems((String[]) fNLChoices.toArray(new String[fNLChoices.size()]));
176
		fNLCombo.addModifyListener(new ModifyListener() {
177
			public void modifyText(ModifyEvent e) {
178
				String value = fNLCombo.getText();
179
				int index = value.indexOf("-"); //$NON-NLS-1$
180
				if (index > 0)
181
					value = value.substring(0, index);
182
				getTargetDefinition().setNL(getModelValue(value));
183
			}
184
		});
185
186
	}
187
188
	/**
189
	 * Returns the given string or <code>null</code> if empty to set a value in the
190
	 * target definition.
191
	 * 
192
	 * @param value
193
	 * @return
194
	 */
195
	private String getModelValue(String value) {
196
		if (value != null) {
197
			value = value.trim();
198
			if (value.length() == 0) {
199
				return null;
200
			}
201
		}
202
		return value;
203
	}
204
205
	private void addExtraChoices(Set set, String preference) {
206
		StringTokenizer tokenizer = new StringTokenizer(preference, ","); //$NON-NLS-1$
207
		while (tokenizer.hasMoreTokens()) {
208
			set.add(tokenizer.nextToken().trim());
209
		}
210
	}
211
212
	private void initializeChoices() {
213
		Preferences preferences = PDECore.getDefault().getPluginPreferences();
214
215
		fOSChoices = new TreeSet();
216
		String[] os = Platform.knownOSValues();
217
		for (int i = 0; i < os.length; i++)
218
			fOSChoices.add(os[i]);
219
		addExtraChoices(fOSChoices, preferences.getString(ICoreConstants.OS_EXTRA));
220
221
		fWSChoices = new TreeSet();
222
		String[] ws = Platform.knownWSValues();
223
		for (int i = 0; i < ws.length; i++)
224
			fWSChoices.add(ws[i]);
225
		addExtraChoices(fWSChoices, preferences.getString(ICoreConstants.WS_EXTRA));
226
227
		fArchChoices = new TreeSet();
228
		String[] arch = Platform.knownOSArchValues();
229
		for (int i = 0; i < arch.length; i++)
230
			fArchChoices.add(arch[i]);
231
		addExtraChoices(fArchChoices, preferences.getString(ICoreConstants.ARCH_EXTRA));
232
233
		fNLChoices = new TreeSet();
234
		initializeAllLocales();
235
	}
236
237
	private void initializeAllLocales() {
238
		Preferences preferences = PDECore.getDefault().getPluginPreferences();
239
		String[] nl = LocaleUtil.getLocales();
240
		for (int i = 0; i < nl.length; i++)
241
			fNLChoices.add(nl[i]);
242
		addExtraChoices(fNLChoices, preferences.getString(ICoreConstants.NL_EXTRA));
243
	}
244
245
	private void createJREGroup(Composite container) {
246
		Group group = new Group(container, SWT.NULL);
247
		GridLayout layout = new GridLayout();
248
		layout.numColumns = 2;
249
		group.setLayout(layout);
250
		group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
251
		group.setText(PDEUIMessages.EnvironmentBlock_jreTitle);
252
253
		initializeJREValues();
254
255
		Label label = new Label(group, SWT.WRAP);
256
		label.setText(PDEUIMessages.JRESection_description);
257
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
258
		data.verticalAlignment = SWT.TOP;
259
		data.horizontalSpan = 2;
260
		label.setLayoutData(data);
261
262
		fDefaultJREButton = new Button(group, SWT.RADIO);
263
		fDefaultJREButton.setText(PDEUIMessages.JRESection_defaultJRE);
264
		GridData gd = new GridData();
265
		gd.horizontalSpan = 2;
266
		fDefaultJREButton.setLayoutData(gd);
267
		fDefaultJREButton.addSelectionListener(new SelectionAdapter() {
268
			public void widgetSelected(SelectionEvent e) {
269
				updateJREWidgets();
270
				getTargetDefinition().setJREContainer(JavaRuntime.newDefaultJREContainerPath());
271
			}
272
		});
273
274
		fNamedJREButton = new Button(group, SWT.RADIO);
275
		fNamedJREButton.setText(PDEUIMessages.JRESection_JREName);
276
		fNamedJREButton.addSelectionListener(new SelectionAdapter() {
277
			public void widgetSelected(SelectionEvent e) {
278
				updateJREWidgets();
279
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText())));
280
			}
281
		});
282
283
		fNamedJREsCombo = new Combo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
284
		fNamedJREsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
285
		String[] installs = VMUtil.getVMInstallNames();
286
		fNamedJREsCombo.setItems(installs);
287
		fNamedJREsCombo.addModifyListener(new ModifyListener() {
288
			public void modifyText(ModifyEvent e) {
289
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText())));
290
			}
291
		});
292
293
		fExecEnvButton = new Button(group, SWT.RADIO);
294
		fExecEnvButton.setText(PDEUIMessages.JRESection_ExecutionEnv);
295
		fExecEnvButton.addSelectionListener(new SelectionAdapter() {
296
			public void widgetSelected(SelectionEvent e) {
297
				updateJREWidgets();
298
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText())));
299
			}
300
		});
301
302
		fExecEnvsCombo = new Combo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
303
		fExecEnvsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
304
		fExecEnvsCombo.setItems((String[]) fExecEnvChoices.toArray(new String[fExecEnvChoices.size()]));
305
		fExecEnvsCombo.addModifyListener(new ModifyListener() {
306
			public void modifyText(ModifyEvent e) {
307
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText())));
308
			}
309
		});
310
311
	}
312
313
	/**
314
	 * Initializes the combo with possible execution enviroments
315
	 */
316
	protected void initializeJREValues() {
317
		fExecEnvChoices = new TreeSet();
318
		IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
319
		IExecutionEnvironment[] envs = manager.getExecutionEnvironments();
320
		for (int i = 0; i < envs.length; i++)
321
			fExecEnvChoices.add(envs[i].getId());
322
	}
323
324
	protected void updateJREWidgets() {
325
		fNamedJREsCombo.setEnabled(fNamedJREButton.getSelection());
326
		fExecEnvsCombo.setEnabled(fExecEnvButton.getSelection());
327
	}
328
329
	private Control createArgumentsGroup(Composite parent) {
330
		Composite container = new Composite(parent, SWT.NONE);
331
		container.setLayout(new GridLayout());
332
333
		Label description = new Label(container, SWT.WRAP);
334
		description.setText(PDEUIMessages.JavaArgumentsTab_description);
335
		GridData gd = new GridData();
336
		gd.widthHint = 450;
337
		description.setLayoutData(gd);
338
339
		Group programGroup = new Group(container, SWT.NONE);
340
		programGroup.setLayout(new GridLayout());
341
		programGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
342
		programGroup.setText(PDEUIMessages.JavaArgumentsTab_progamArgsGroup);
343
344
		fProgramArgs = new Text(programGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
345
		gd = new GridData(GridData.FILL_BOTH);
346
		gd.widthHint = 450;
347
		gd.heightHint = 60;
348
		fProgramArgs.setLayoutData(gd);
349
		fProgramArgs.addModifyListener(new ModifyListener() {
350
			public void modifyText(ModifyEvent e) {
351
				getTargetDefinition().setProgramArguments(fProgramArgs.getText().trim());
352
			}
353
		});
354
355
		Button programVars = new Button(programGroup, SWT.NONE);
356
		programVars.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
357
		programVars.setText(PDEUIMessages.JavaArgumentsTab_programVariables);
358
		programVars.addSelectionListener(getListener(fProgramArgs));
359
360
		Group vmGroup = new Group(container, SWT.NONE);
361
		vmGroup.setLayout(new GridLayout(2, false));
362
		vmGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
363
		vmGroup.setText(PDEUIMessages.JavaArgumentsTab_vmArgsGroup);
364
365
		fVMArgs = new Text(vmGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
366
		gd = new GridData(GridData.FILL_BOTH);
367
		gd.widthHint = 450;
368
		gd.heightHint = 60;
369
		gd.horizontalSpan = 2;
370
		fVMArgs.setLayoutData(gd);
371
		fVMArgs.addModifyListener(new ModifyListener() {
372
			public void modifyText(ModifyEvent e) {
373
				getTargetDefinition().setVMArguments(fVMArgs.getText().trim());
374
			}
375
		});
376
377
		fAppendLauncherArgs = new Button(vmGroup, SWT.CHECK);
378
		fAppendLauncherArgs.setText(PDEUIMessages.JavaArgumentsTab_appendLauncherIni);
379
380
		Button vmVars = new Button(vmGroup, SWT.NONE);
381
		vmVars.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
382
		vmVars.setText(PDEUIMessages.JavaArgumentsTab_vmVariables);
383
		vmVars.addSelectionListener(getListener(fVMArgs));
384
		return container;
385
	}
386
387
	protected SelectionListener getListener(final Text textControl) {
388
		return new SelectionListener() {
389
			public void widgetSelected(SelectionEvent e) {
390
				StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
391
				dialog.open();
392
				String variable = dialog.getVariableExpression();
393
				if (variable != null) {
394
					textControl.insert(variable);
395
				}
396
			}
397
398
			public void widgetDefaultSelected(SelectionEvent e) {
399
			}
400
		};
401
	}
402
403
	private Control createImplicitTabContents(Composite parent) {
404
		Composite container = new Composite(parent, SWT.NONE);
405
		GridLayout layout = new GridLayout(2, false);
406
		container.setLayout(layout);
407
		container.setLayoutData(new GridData(GridData.FILL_BOTH));
408
409
		createImpLabel(container);
410
		createImpTable(container);
411
		createImpButtons(container);
412
		// TODO: PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.IMPLICIT_PLUGINS_PREFERENCE_PAGE);
413
		return container;
414
	}
415
416
	private void createImpLabel(Composite container) {
417
		Label label = new Label(container, SWT.NONE);
418
		label.setText(PDEUIMessages.TargetImplicitPluginsTab_desc);
419
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
420
		gd.horizontalSpan = 2;
421
		label.setLayoutData(gd);
422
	}
423
424
	private void createImpTable(Composite container) {
425
		fElementViewer = new TableViewer(container, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
426
		GridData gd = new GridData(GridData.FILL_BOTH);
427
		fElementViewer.getControl().setLayoutData(gd);
428
		fElementViewer.setContentProvider(new DefaultTableProvider() {
429
			public Object[] getElements(Object inputElement) {
430
				BundleInfo[] bundles = getTargetDefinition().getImplicitDependencies();
431
				if (bundles == null) {
432
					return new BundleInfo[0];
433
				}
434
				return bundles;
435
			}
436
		});
437
		fElementViewer.setLabelProvider(new LabelProvider() {
438
			public String getText(Object element) {
439
				if (element instanceof BundleInfo) {
440
					return ((BundleInfo) element).getSymbolicName();
441
				}
442
				return super.getText(element);
443
			}
444
			// TODO: labels
445
		});
446
		fElementViewer.setInput(PDEPlugin.getDefault());
447
		fElementViewer.setComparator(new ViewerComparator() {
448
			public int compare(Viewer viewer, Object e1, Object e2) {
449
				BundleInfo bundle1 = (BundleInfo) e1;
450
				BundleInfo bundle2 = (BundleInfo) e2;
451
				return super.compare(viewer, bundle1.getSymbolicName(), bundle2.getSymbolicName());
452
			}
453
		});
454
		fElementViewer.addSelectionChangedListener(new ISelectionChangedListener() {
455
			public void selectionChanged(SelectionChangedEvent event) {
456
				updateImpButtons();
457
			}
458
		});
459
		fElementViewer.getTable().addKeyListener(new KeyAdapter() {
460
			public void keyPressed(KeyEvent e) {
461
				if (e.character == SWT.DEL && e.stateMask == 0) {
462
					handleRemove();
463
				}
464
			}
465
		});
466
467
	}
468
469
	private void createImpButtons(Composite container) {
470
		Composite buttonContainer = new Composite(container, SWT.NONE);
471
		GridLayout layout = new GridLayout();
472
		layout.marginWidth = layout.marginHeight = 0;
473
		buttonContainer.setLayout(layout);
474
		buttonContainer.setLayoutData(new GridData(GridData.FILL_VERTICAL));
475
476
		fAddButton = new Button(buttonContainer, SWT.PUSH);
477
		fAddButton.setText(PDEUIMessages.SourceBlock_add);
478
		fAddButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING));
479
		SWTUtil.setButtonDimensionHint(fAddButton);
480
		fAddButton.addSelectionListener(new SelectionAdapter() {
481
			public void widgetSelected(SelectionEvent e) {
482
				handleAdd();
483
			}
484
		});
485
486
		fRemoveButton = new Button(buttonContainer, SWT.PUSH);
487
		fRemoveButton.setText(PDEUIMessages.SourceBlock_remove);
488
		fRemoveButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING));
489
		SWTUtil.setButtonDimensionHint(fRemoveButton);
490
		fRemoveButton.addSelectionListener(new SelectionAdapter() {
491
			public void widgetSelected(SelectionEvent e) {
492
				handleRemove();
493
			}
494
		});
495
496
		fRemoveAllButton = new Button(buttonContainer, SWT.PUSH);
497
		fRemoveAllButton.setText(PDEUIMessages.TargetImplicitPluginsTab_removeAll3);
498
		fRemoveAllButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING));
499
		SWTUtil.setButtonDimensionHint(fRemoveAllButton);
500
		fRemoveAllButton.addSelectionListener(new SelectionAdapter() {
501
			public void widgetSelected(SelectionEvent e) {
502
				handleRemoveAll();
503
			}
504
		});
505
		updateImpButtons();
506
	}
507
508
	protected void handleAdd() {
509
		ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), PDEPlugin.getDefault().getLabelProvider());
510
511
		dialog.setElements(getValidBundles());
512
		dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title);
513
		dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message);
514
		dialog.setMultipleSelection(true);
515
		if (dialog.open() == Window.OK) {
516
			Object[] models = dialog.getResult();
517
			ArrayList pluginsToAdd = new ArrayList();
518
			for (int i = 0; i < models.length; i++) {
519
				BundleDescription desc = ((BundleDescription) models[i]);
520
				pluginsToAdd.add(new BundleInfo(desc.getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false));
521
			}
522
			Set allDependencies = new HashSet();
523
			allDependencies.addAll(pluginsToAdd);
524
			BundleInfo[] currentBundles = getTargetDefinition().getImplicitDependencies();
525
			if (currentBundles != null) {
526
				allDependencies.addAll(Arrays.asList(currentBundles));
527
			}
528
			getTargetDefinition().setImplicitDependencies((BundleInfo[]) allDependencies.toArray(new BundleInfo[allDependencies.size()]));
529
			fElementViewer.refresh();
530
			// update target
531
		}
532
	}
533
534
	/**
535
	 * Gets a list of all the bundles that can be added as implicit dependencies
536
	 * @return list of possible dependencies
537
	 */
538
	protected BundleDescription[] getValidBundles() {
539
		BundleInfo[] current = getTargetDefinition().getImplicitDependencies();
540
		Set currentBundles = new HashSet();
541
		if (current != null) {
542
			for (int i = 0; i < current.length; i++) {
543
				currentBundles.add(current[i].getSymbolicName());
544
			}
545
		}
546
547
		// TODO Do we want to get the possible models from the plugin registry?  Would be better to get the bundles from the editor's target definition?
548
		IPluginModelBase[] models = PluginRegistry.getActiveModels(false);
549
		Set result = new HashSet();
550
		for (int i = 0; i < models.length; i++) {
551
			BundleDescription desc = models[i].getBundleDescription();
552
			if (desc != null) {
553
				if (!currentBundles.contains(desc.getSymbolicName()))
554
					result.add(desc);
555
			}
556
		}
557
558
		return (BundleDescription[]) result.toArray((new BundleDescription[result.size()]));
559
	}
560
561
	private void handleRemove() {
562
		LinkedList bundles = new LinkedList();
563
		bundles.addAll(Arrays.asList(getTargetDefinition().getImplicitDependencies()));
564
		Object[] removeBundles = ((IStructuredSelection) fElementViewer.getSelection()).toArray();
565
		if (removeBundles.length > 0) {
566
			for (int i = 0; i < removeBundles.length; i++) {
567
				if (removeBundles[i] instanceof BundleInfo) {
568
					bundles.remove(removeBundles[i]);
569
				}
570
			}
571
			getTargetDefinition().setImplicitDependencies((BundleInfo[]) bundles.toArray((new BundleInfo[bundles.size()])));
572
			fElementViewer.refresh();
573
		}
574
	}
575
576
	private void handleRemoveAll() {
577
		getTargetDefinition().setImplicitDependencies(null);
578
		fElementViewer.refresh();
579
	}
580
581
	/* (non-Javadoc)
582
	 * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
583
	 */
584
	protected void targetChanged(ITargetDefinition definition) {
585
		super.targetChanged(definition);
586
		if (definition != null) {
587
			String presetValue = (definition.getOS() == null) ? "" : definition.getOS(); //$NON-NLS-1$
588
			fOSCombo.setText(presetValue);
589
			presetValue = (definition.getWS() == null) ? "" : definition.getWS(); //$NON-NLS-1$
590
			fWSCombo.setText(presetValue);
591
			presetValue = (definition.getArch() == null) ? "" : definition.getArch(); //$NON-NLS-1$
592
			fArchCombo.setText(presetValue);
593
			presetValue = (definition.getNL() == null) ? "" : LocaleUtil.expandLocaleName(definition.getNL()); //$NON-NLS-1$
594
			fNLCombo.setText(presetValue);
595
596
			IPath jrePath = definition.getJREContainer();
597
			if (jrePath == null || jrePath.equals(JavaRuntime.newDefaultJREContainerPath())) {
598
				fDefaultJREButton.setSelection(true);
599
			} else {
600
				String ee = JavaRuntime.getExecutionEnvironmentId(jrePath);
601
				if (ee != null) {
602
					fExecEnvButton.setSelection(true);
603
					fExecEnvsCombo.select(fExecEnvsCombo.indexOf(ee));
604
				} else {
605
					String vm = JavaRuntime.getVMInstallName(jrePath);
606
					if (vm != null) {
607
						fNamedJREButton.setSelection(true);
608
						fNamedJREsCombo.select(fNamedJREsCombo.indexOf(vm));
609
					}
610
				}
611
			}
612
613
			if (fExecEnvsCombo.getSelectionIndex() == -1)
614
				fExecEnvsCombo.setText(fExecEnvChoices.first().toString());
615
616
			if (fNamedJREsCombo.getSelectionIndex() == -1)
617
				fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName());
618
619
			updateJREWidgets();
620
621
			presetValue = (definition.getProgramArguments() == null) ? "" : definition.getProgramArguments(); //$NON-NLS-1$
622
			fProgramArgs.setText(presetValue);
623
			presetValue = (definition.getVMArguments() == null) ? "" : definition.getVMArguments(); //$NON-NLS-1$
624
			fVMArgs.setText(presetValue);
625
626
		}
627
	}
628
629
	private void updateImpButtons() {
630
		boolean empty = fElementViewer.getSelection().isEmpty();
631
		fRemoveButton.setEnabled(!empty);
632
		boolean hasElements = fElementViewer.getTable().getItemCount() > 0;
633
		fRemoveAllButton.setEnabled(hasElements);
634
	}
635
636
}
(-)src/org/eclipse/pde/internal/ui/wizards/target/EditTargetDefinitionWizard.java (-102 / +101 lines)
Lines 1-102 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.wizards.target;
11
package org.eclipse.pde.internal.ui.wizards.target;
12
12
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.jface.wizard.IWizardPage;
14
import org.eclipse.jface.wizard.IWizardPage;
15
import org.eclipse.jface.wizard.Wizard;
15
import org.eclipse.jface.wizard.Wizard;
16
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
16
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
17
import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService;
17
import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService;
18
import org.eclipse.pde.internal.ui.PDEPlugin;
18
import org.eclipse.pde.internal.ui.PDEPlugin;
19
19
20
/**
20
/**
21
 * Wizard to edit a target definition
21
 * Wizard to edit a target definition
22
 */
22
 */
23
public class EditTargetDefinitionWizard extends Wizard {
23
public class EditTargetDefinitionWizard extends Wizard {
24
24
25
	/**
25
	/**
26
	 * The target definition being edited - a copy of the original
26
	 * The target definition being edited - a copy of the original
27
	 */
27
	 */
28
	private ITargetDefinition fDefinition;
28
	private ITargetDefinition fDefinition;
29
29
30
	/**
30
	/**
31
	 * The original target definition that was to be edited. We create
31
	 * The original target definition that was to be edited. We create
32
	 * a copy in case the user cancels the operation.
32
	 * a copy in case the user cancels the operation.
33
	 */
33
	 */
34
	private ITargetDefinition fOriginal;
34
	private ITargetDefinition fOriginal;
35
35
36
	/* (non-Javadoc)
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
37
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
38
	 */
38
	 */
39
	public boolean performFinish() {
39
	public boolean performFinish() {
40
		// TODO check if any changes first
40
		// TODO check if any changes first
41
		ITargetPlatformService service = TargetDefinitionPage.getTargetService();
41
		ITargetPlatformService service = TargetDefinitionPage.getTargetService();
42
		if (service != null) {
42
		if (service != null) {
43
			try {
43
			try {
44
				service.copyTargetDefinition(fDefinition, fOriginal);
44
				service.copyTargetDefinition(fDefinition, fOriginal);
45
			} catch (CoreException e) {
45
			} catch (CoreException e) {
46
				// TODO set error message
46
				// TODO set error message
47
				return false;
47
				return false;
48
			}
48
			}
49
		}
49
		}
50
		return true;
50
		return true;
51
	}
51
	}
52
52
53
	/**
53
	/**
54
	 * Constructs a wizard to edit the given definition.
54
	 * Constructs a wizard to edit the given definition.
55
	 * 
55
	 * 
56
	 * @param definition
56
	 * @param definition
57
	 */
57
	 */
58
	public EditTargetDefinitionWizard(ITargetDefinition definition) {
58
	public EditTargetDefinitionWizard(ITargetDefinition definition) {
59
		setTargetDefinition(definition);
59
		setTargetDefinition(definition);
60
	}
60
	}
61
61
62
	/* (non-Javadoc)
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.jface.wizard.Wizard#addPages()
63
	 * @see org.eclipse.jface.wizard.Wizard#addPages()
64
	 */
64
	 */
65
	public void addPages() {
65
	public void addPages() {
66
		addPage(new TargetDefinitionContentPage(fDefinition));
66
		addPage(new TargetDefinitionContentPage(fDefinition));
67
		addPage(new TargetDefinitionEnvironmentPage(fDefinition));
67
	}
68
	}
68
69
69
	/**
70
	/**
70
	 * Sets the target definition to be edited. Will delegate to pages to
71
	 * Sets the target definition to be edited. Will delegate to pages to
71
	 * refresh controls if already created.
72
	 * refresh controls if already created.
72
	 * 
73
	 * 
73
	 * @param definition target definition
74
	 * @param definition target definition
74
	 */
75
	 */
75
	public void setTargetDefinition(ITargetDefinition definition) {
76
	public void setTargetDefinition(ITargetDefinition definition) {
76
		fOriginal = definition;
77
		fOriginal = definition;
77
		ITargetPlatformService service = TargetDefinitionPage.getTargetService();
78
		ITargetPlatformService service = TargetDefinitionPage.getTargetService();
78
		if (service != null) {
79
		if (service != null) {
79
			fDefinition = service.newTarget();
80
			fDefinition = service.newTarget();
80
			try {
81
			try {
81
				service.copyTargetDefinition(definition, fDefinition);
82
				service.copyTargetDefinition(definition, fDefinition);
82
				IWizardPage[] pages = getPages();
83
				IWizardPage[] pages = getPages();
83
				for (int i = 0; i < pages.length; i++) {
84
				for (int i = 0; i < pages.length; i++) {
84
					((TargetDefinitionPage) pages[i]).targetChanged(fDefinition);
85
					((TargetDefinitionPage) pages[i]).targetChanged(fDefinition);
85
				}
86
				}
86
			} catch (CoreException e) {
87
			} catch (CoreException e) {
87
				// TODO: show error message
88
				// TODO: show error message
88
				PDEPlugin.log(e);
89
				PDEPlugin.log(e);
89
			}
90
			}
90
		}
91
		}
91
	}
92
	}
92
93
93
	/**
94
	/**
94
	 * Returns the target definition being edited
95
	 * Returns the target definition being edited
95
	 * 
96
	 * 
96
	 * @return target definition
97
	 * @return target definition
97
	 */
98
	 */
98
	public ITargetDefinition getTargetDefinition() {
99
	public ITargetDefinition getTargetDefinition() {
99
		return fDefinition;
100
		return fDefinition;
100
	}
101
	}
101
}
102
}
(-)src/org/eclipse/pde/internal/ui/pderesources.properties (-4 / +4 lines)
Lines 1771-1782 Link Here
1771
TargetDefinitionContentPage_3=Identification:
1771
TargetDefinitionContentPage_3=Identification:
1772
TargetDefinitionContentPage_4=N&ame:
1772
TargetDefinitionContentPage_4=N&ame:
1773
TargetDefinitionContentPage_5=Descri&ption:
1773
TargetDefinitionContentPage_5=Descri&ption:
1774
TargetDefinitionContentPage_6=C&ontent:
1774
TargetDefinitionContentPage_6=&Plug-ins:
1775
TargetDefinitionEnvironmentPage_1=Target Settings
1775
TargetDefinitionEnvironmentPage_1=Target Settings
1776
TargetDefinitionEnvironmentPage_2=Edit the environment, arguments, and implicit dependencies for a target.
1776
TargetDefinitionEnvironmentPage_2=Edit the environment, arguments, and implicit dependencies for a target.
1777
TargetDefinitionEnvironmentPage_3=Environment
1777
TargetDefinitionEnvironmentPage_3=En&vironment
1778
TargetDefinitionEnvironmentPage_4=Arguments
1778
TargetDefinitionEnvironmentPage_4=Ar&guments
1779
TargetDefinitionEnvironmentPage_5=Implicit Dependencies
1779
TargetDefinitionEnvironmentPage_5=Implicit &Dependencies
1780
TargetDefinitionSection_title=Target Definition
1780
TargetDefinitionSection_title=Target Definition
1781
TargetDefinitionSection_targetLocation=Target Location:
1781
TargetDefinitionSection_targetLocation=Target Location:
1782
TargetDefinitionSection_sameAsHost=Use the same target location as the host (running) platform is using
1782
TargetDefinitionSection_sameAsHost=Use the same target location as the host (running) platform is using
(-)src/org/eclipse/pde/internal/ui/shared/target/BundleContainerTable.java (-2 / +4 lines)
Lines 132-144 Link Here
132
		Tree atree = new Tree(comp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
132
		Tree atree = new Tree(comp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
133
		atree.setLayout(new GridLayout());
133
		atree.setLayout(new GridLayout());
134
		GridData gd = new GridData(GridData.FILL_BOTH);
134
		GridData gd = new GridData(GridData.FILL_BOTH);
135
		gd.widthHint = 200;
135
		atree.setLayoutData(gd);
136
		atree.setLayoutData(gd);
136
137
137
		initializeTreeViewer(atree);
138
		initializeTreeViewer(atree);
138
139
139
		Composite buttonComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH);
140
		Composite buttonComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_BOTH);
140
		GridLayout layout = new GridLayout();
141
		GridLayout layout = new GridLayout();
141
		layout.marginWidth = layout.marginHeight = 0;
142
		layout.marginHeight = 0;
143
		layout.marginWidth = 0;
142
		buttonComp.setLayout(layout);
144
		buttonComp.setLayout(layout);
143
		buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
145
		buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
144
146

Return to bug 256910