Lines 17-22
Link Here
|
17 |
import org.eclipse.debug.core.ILaunchConfiguration; |
17 |
import org.eclipse.debug.core.ILaunchConfiguration; |
18 |
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
18 |
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
19 |
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; |
19 |
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; |
|
|
20 |
import org.eclipse.jdt.launching.environments.IExecutionEnvironment; |
21 |
import org.eclipse.osgi.util.NLS; |
20 |
import org.eclipse.pde.internal.ui.PDEUIMessages; |
22 |
import org.eclipse.pde.internal.ui.PDEUIMessages; |
21 |
import org.eclipse.pde.internal.ui.preferences.PDEPreferencesUtil; |
23 |
import org.eclipse.pde.internal.ui.preferences.PDEPreferencesUtil; |
22 |
import org.eclipse.pde.internal.ui.util.SWTUtil; |
24 |
import org.eclipse.pde.internal.ui.util.SWTUtil; |
Lines 42-53
Link Here
|
42 |
private Listener fListener = new Listener(); |
44 |
private Listener fListener = new Listener(); |
43 |
private Button fJavawButton; |
45 |
private Button fJavawButton; |
44 |
private Button fJavaButton; |
46 |
private Button fJavaButton; |
|
|
47 |
private Button fJreButton; |
48 |
private Button fEeButton; |
49 |
private Button fJrePrefButton; |
50 |
private Button fEePrefButton; |
45 |
private Combo fJreCombo; |
51 |
private Combo fJreCombo; |
|
|
52 |
private Combo fEeCombo; |
46 |
private Text fBootstrap; |
53 |
private Text fBootstrap; |
47 |
|
54 |
|
48 |
class Listener extends SelectionAdapter implements ModifyListener { |
55 |
class Listener extends SelectionAdapter implements ModifyListener { |
49 |
public void widgetSelected(SelectionEvent e) { |
56 |
public void widgetSelected(SelectionEvent e) { |
50 |
fTab.updateLaunchConfigurationDialog(); |
57 |
fTab.updateLaunchConfigurationDialog(); |
|
|
58 |
updateJREEnablement(); |
51 |
} |
59 |
} |
52 |
public void modifyText(ModifyEvent e) { |
60 |
public void modifyText(ModifyEvent e) { |
53 |
fTab.updateLaunchConfigurationDialog(); |
61 |
fTab.updateLaunchConfigurationDialog(); |
Lines 62-68
Link Here
|
62 |
Group group = new Group(parent, SWT.NONE); |
70 |
Group group = new Group(parent, SWT.NONE); |
63 |
group.setText(PDEUIMessages.MainTab_jreSection); |
71 |
group.setText(PDEUIMessages.MainTab_jreSection); |
64 |
GridLayout layout = new GridLayout(); |
72 |
GridLayout layout = new GridLayout(); |
65 |
layout.numColumns = 2; |
73 |
layout.numColumns = 3; |
66 |
group.setLayout(layout); |
74 |
group.setLayout(layout); |
67 |
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
75 |
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
68 |
|
76 |
|
Lines 72-96
Link Here
|
72 |
} |
80 |
} |
73 |
|
81 |
|
74 |
protected void createJRESection(Composite parent) { |
82 |
protected void createJRESection(Composite parent) { |
75 |
Label label = new Label(parent, SWT.NONE); |
83 |
fJreButton = new Button(parent, SWT.RADIO); |
76 |
label.setText(PDEUIMessages.BasicLauncherTab_jre); |
84 |
fJreButton.setText(PDEUIMessages.BasicLauncherTab_jre); |
77 |
|
85 |
fJreButton.addSelectionListener(fListener); |
78 |
Composite composite = new Composite(parent, SWT.NONE); |
|
|
79 |
GridLayout layout = new GridLayout(); |
80 |
layout.numColumns = 2; |
81 |
layout.marginHeight = layout.marginWidth = 0; |
82 |
composite.setLayout(layout); |
83 |
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
84 |
|
86 |
|
85 |
fJreCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY); |
87 |
fJreCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY); |
86 |
fJreCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
88 |
fJreCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); |
87 |
fJreCombo.addSelectionListener(fListener); |
89 |
fJreCombo.addSelectionListener(fListener); |
88 |
|
90 |
|
89 |
Button button = new Button(composite, SWT.PUSH); |
91 |
fJrePrefButton = new Button(parent, SWT.PUSH); |
90 |
button.setText(PDEUIMessages.BasicLauncherTab_installedJREs); |
92 |
fJrePrefButton.setText(PDEUIMessages.BasicLauncherTab_installedJREs); |
91 |
button.addSelectionListener(new SelectionAdapter() { |
93 |
fJrePrefButton.addSelectionListener(new SelectionAdapter() { |
92 |
public void widgetSelected(SelectionEvent e) { |
94 |
public void widgetSelected(SelectionEvent e) { |
93 |
String currentVM = fJreCombo.getText(); |
95 |
String currentVM = fJreCombo.getText(); |
|
|
96 |
String currentEE = parseEESelection(fEeCombo.getText()); |
94 |
boolean useDefault = VMHelper.getDefaultVMInstallName().equals(currentVM); |
97 |
boolean useDefault = VMHelper.getDefaultVMInstallName().equals(currentVM); |
95 |
String[] pageIDs = new String[] {"org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"}; //$NON-NLS-1$ |
98 |
String[] pageIDs = new String[] {"org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"}; //$NON-NLS-1$ |
96 |
if (PDEPreferencesUtil.showPreferencePage(pageIDs, fTab.getControl().getShell())) { |
99 |
if (PDEPreferencesUtil.showPreferencePage(pageIDs, fTab.getControl().getShell())) { |
Lines 99-109
Link Here
|
99 |
fJreCombo.setText(VMHelper.getDefaultVMInstallName()); |
102 |
fJreCombo.setText(VMHelper.getDefaultVMInstallName()); |
100 |
else |
103 |
else |
101 |
fJreCombo.setText(currentVM); |
104 |
fJreCombo.setText(currentVM); |
|
|
105 |
setEECombo(); |
106 |
setEEComboSelection(currentEE); |
102 |
} |
107 |
} |
103 |
} |
108 |
} |
104 |
}); |
109 |
}); |
105 |
button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); |
110 |
fJrePrefButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); |
106 |
SWTUtil.setButtonDimensionHint(button); |
111 |
SWTUtil.setButtonDimensionHint(fJrePrefButton); |
|
|
112 |
|
113 |
fEeButton = new Button(parent, SWT.RADIO); |
114 |
fEeButton.setText(PDEUIMessages.BasicLauncherTab_ee); |
115 |
fEeButton.addSelectionListener(fListener); |
116 |
|
117 |
fEeCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY); |
118 |
fEeCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); |
119 |
fEeCombo.addSelectionListener(fListener); |
120 |
|
121 |
fEePrefButton = new Button(parent, SWT.PUSH); |
122 |
fEePrefButton.setText(PDEUIMessages.BasicLauncherTab_environments); |
123 |
fEePrefButton.addSelectionListener(new SelectionAdapter() { |
124 |
public void widgetSelected(SelectionEvent e) { |
125 |
String currentEE = parseEESelection(fEeCombo.getText()); |
126 |
String[] pageIDs = new String[] {"org.eclipse.jdt.debug.ui.jreProfiles"}; //$NON-NLS-1$ |
127 |
if (PDEPreferencesUtil.showPreferencePage(pageIDs, fTab.getControl().getShell())) { |
128 |
setEECombo(); |
129 |
setEEComboSelection(currentEE); |
130 |
} |
131 |
} |
132 |
}); |
133 |
fEePrefButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); |
134 |
SWTUtil.setButtonDimensionHint(fEePrefButton); |
107 |
} |
135 |
} |
108 |
|
136 |
|
109 |
protected void createJavaExecutableSection(Composite parent) { |
137 |
protected void createJavaExecutableSection(Composite parent) { |
Lines 116-122
Link Here
|
116 |
layout.marginHeight = layout.marginWidth = 0; |
144 |
layout.marginHeight = layout.marginWidth = 0; |
117 |
layout.horizontalSpacing = 20; |
145 |
layout.horizontalSpacing = 20; |
118 |
composite.setLayout(layout); |
146 |
composite.setLayout(layout); |
119 |
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
147 |
GridData gd = new GridData(GridData.FILL_HORIZONTAL); |
|
|
148 |
gd.horizontalSpan = 2; |
149 |
composite.setLayoutData(gd); |
120 |
|
150 |
|
121 |
fJavawButton = new Button(composite, SWT.RADIO); |
151 |
fJavawButton = new Button(composite, SWT.RADIO); |
122 |
fJavawButton.setText(PDEUIMessages.BasicLauncherTab_javaExecDefault); // |
152 |
fJavawButton.setText(PDEUIMessages.BasicLauncherTab_javaExecDefault); // |
Lines 134-139
Link Here
|
134 |
fBootstrap = new Text(parent, SWT.BORDER); |
164 |
fBootstrap = new Text(parent, SWT.BORDER); |
135 |
GridData gd = new GridData(GridData.FILL_HORIZONTAL); |
165 |
GridData gd = new GridData(GridData.FILL_HORIZONTAL); |
136 |
gd.widthHint = 300; |
166 |
gd.widthHint = 300; |
|
|
167 |
gd.horizontalSpan = 2; |
137 |
fBootstrap.setLayoutData(gd); |
168 |
fBootstrap.setLayoutData(gd); |
138 |
fBootstrap.addModifyListener(fListener); |
169 |
fBootstrap.addModifyListener(fListener); |
139 |
} |
170 |
} |
Lines 142-159
Link Here
|
142 |
initializeJRESection(config); |
173 |
initializeJRESection(config); |
143 |
initializeBootstrapEntriesSection(config); |
174 |
initializeBootstrapEntriesSection(config); |
144 |
} |
175 |
} |
145 |
|
176 |
|
146 |
private void initializeJRESection(ILaunchConfiguration config) throws CoreException { |
177 |
private void initializeJRESection(ILaunchConfiguration config) throws CoreException { |
147 |
String javaCommand = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_JAVA_COMMAND, "javaw"); //$NON-NLS-1$ |
178 |
String javaCommand = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_JAVA_COMMAND, "javaw"); //$NON-NLS-1$ |
148 |
fJavawButton.setSelection(javaCommand.equals("javaw")); //$NON-NLS-1$ |
179 |
fJavawButton.setSelection(javaCommand.equals("javaw")); //$NON-NLS-1$ |
149 |
fJavaButton.setSelection(!fJavawButton.getSelection()); |
180 |
fJavaButton.setSelection(!fJavawButton.getSelection()); |
150 |
|
181 |
|
|
|
182 |
String vmEe = config.getAttribute(IPDELauncherConstants.VM_OR_EE, "vm"); //$NON-NLS-1$ |
183 |
fJreButton.setSelection(vmEe.equals("vm")); //$NON-NLS-1$ |
184 |
fEeButton.setSelection(!fJreButton.getSelection()); |
185 |
|
151 |
setJRECombo(); |
186 |
setJRECombo(); |
152 |
String vmInstallName = |
187 |
String vmInstallName = |
153 |
config.getAttribute(IPDELauncherConstants.VMINSTALL, VMHelper.getDefaultVMInstallName()); |
188 |
config.getAttribute(IPDELauncherConstants.VMINSTALL, VMHelper.getDefaultVMInstallName()); |
154 |
fJreCombo.setText(vmInstallName); |
189 |
fJreCombo.setText(vmInstallName); |
155 |
if (fJreCombo.getSelectionIndex() == -1) |
190 |
if (fJreCombo.getSelectionIndex() == -1) |
156 |
fJreCombo.setText(VMHelper.getDefaultVMInstallName()); |
191 |
fJreCombo.setText(VMHelper.getDefaultVMInstallName()); |
|
|
192 |
|
193 |
setEECombo(); |
194 |
String eeId = |
195 |
config.getAttribute(IPDELauncherConstants.EXECUTION_ENVIRONMENT, (String) null); |
196 |
setEEComboSelection(eeId); |
197 |
|
198 |
updateJREEnablement(); |
199 |
} |
200 |
|
201 |
private void setEEComboSelection (String eeId) { |
202 |
if (eeId != null) { |
203 |
String[] items = fEeCombo.getItems(); |
204 |
for (int i = 0; i < items.length; i++) { |
205 |
if (parseEESelection(items[i]).equals(eeId)) { |
206 |
fEeCombo.select(i); |
207 |
break; |
208 |
} |
209 |
} |
210 |
} |
211 |
if (fEeCombo.getItemCount() > 0 && fEeCombo.getSelectionIndex() == -1) |
212 |
fEeCombo.select(0); |
213 |
} |
214 |
|
215 |
private void updateJREEnablement() { |
216 |
fJreCombo.setEnabled(fJreButton.getSelection()); |
217 |
fJrePrefButton.setEnabled(fJreButton.getSelection()); |
218 |
fEeCombo.setEnabled(fEeButton.getSelection()); |
219 |
fEePrefButton.setEnabled(fEeButton.getSelection()); |
157 |
} |
220 |
} |
158 |
|
221 |
|
159 |
private void initializeBootstrapEntriesSection(ILaunchConfiguration config) throws CoreException { |
222 |
private void initializeBootstrapEntriesSection(ILaunchConfiguration config) throws CoreException { |
Lines 170-185
Link Here
|
170 |
String javaCommand = fJavawButton.getSelection() ? null : "java"; //$NON-NLS-1$ |
233 |
String javaCommand = fJavawButton.getSelection() ? null : "java"; //$NON-NLS-1$ |
171 |
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JAVA_COMMAND, javaCommand); |
234 |
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JAVA_COMMAND, javaCommand); |
172 |
|
235 |
|
173 |
if (fJreCombo.getSelectionIndex() == -1) |
236 |
String vmEe = fJreButton.getSelection() ? "vm" : "ee"; //$NON-NLS-1$ //$NON-NLS-2$ |
174 |
return; |
237 |
config.setAttribute(IPDELauncherConstants.VM_OR_EE, vmEe); |
175 |
|
238 |
if (fJreButton.getSelection()) { |
176 |
String jre = fJreCombo.getText(); |
239 |
if (fJreCombo.getSelectionIndex() == -1) |
177 |
if (config.getAttribute(IPDELauncherConstants.VMINSTALL, (String) null) != null) { |
240 |
return; |
178 |
config.setAttribute(IPDELauncherConstants.VMINSTALL, jre); |
241 |
|
|
|
242 |
String jre = fJreCombo.getText(); |
243 |
if (config.getAttribute(IPDELauncherConstants.VMINSTALL, (String) null) != null) { |
244 |
config.setAttribute(IPDELauncherConstants.VMINSTALL, jre); |
245 |
} else { |
246 |
config.setAttribute( |
247 |
IPDELauncherConstants.VMINSTALL, |
248 |
jre.equals(VMHelper.getDefaultVMInstallName()) ? null : jre); |
249 |
} |
179 |
} else { |
250 |
} else { |
180 |
config.setAttribute( |
251 |
if (fEeCombo.getSelectionIndex() == -1) |
181 |
IPDELauncherConstants.VMINSTALL, |
252 |
return; |
182 |
jre.equals(VMHelper.getDefaultVMInstallName()) ? null : jre); |
253 |
|
|
|
254 |
config.setAttribute(IPDELauncherConstants.EXECUTION_ENVIRONMENT, parseEESelection(fEeCombo.getText())); |
183 |
} |
255 |
} |
184 |
} catch (CoreException e) { |
256 |
} catch (CoreException e) { |
185 |
} |
257 |
} |
Lines 195-205
Link Here
|
195 |
|
267 |
|
196 |
private void setJRECombo() { |
268 |
private void setJRECombo() { |
197 |
String[] jres = VMHelper.getVMInstallNames(); |
269 |
String[] jres = VMHelper.getVMInstallNames(); |
198 |
Arrays.sort(jres, new Comparator() { |
270 |
Arrays.sort(jres, getComparator()); |
|
|
271 |
fJreCombo.setItems(jres); |
272 |
} |
273 |
|
274 |
private void setEECombo() { |
275 |
IExecutionEnvironment[] eeObjects = VMHelper.getExecutionEnvironments(); |
276 |
String[] ees = new String[eeObjects.length]; |
277 |
for (int i = 0; i < eeObjects.length; i++) { |
278 |
String vm; |
279 |
try { |
280 |
vm = VMHelper.getVMInstallName(eeObjects[i]); |
281 |
} catch (CoreException e) { |
282 |
vm = PDEUIMessages.BasicLauncherTab_unbound; |
283 |
} |
284 |
ees[i] = NLS.bind(PDEUIMessages.BasicLauncherTab_2, new String[] { eeObjects[i].getId(), vm }); |
285 |
} |
286 |
Arrays.sort(ees, getComparator()); |
287 |
fEeCombo.setItems(ees); |
288 |
} |
289 |
|
290 |
private Comparator getComparator() { |
291 |
return new Comparator() { |
199 |
public int compare(Object arg0, Object arg1) { |
292 |
public int compare(Object arg0, Object arg1) { |
200 |
return arg0.toString().compareTo(arg1.toString()); |
293 |
return arg0.toString().compareTo(arg1.toString()); |
201 |
} |
294 |
} |
202 |
}); |
295 |
}; |
203 |
fJreCombo.setItems(jres); |
296 |
} |
|
|
297 |
|
298 |
public String validate() { |
299 |
if (fEeButton.getSelection() && fEeCombo.getText().indexOf(PDEUIMessages.BasicLauncherTab_unbound) != -1) |
300 |
return NLS.bind(PDEUIMessages.BasicLauncherTab_noJreForEeMessage, parseEESelection(fEeCombo.getText())); |
301 |
return null; |
302 |
} |
303 |
|
304 |
private String parseEESelection (String selection) { |
305 |
int index = selection.indexOf(" ("); //$NON-NLS-1$ |
306 |
if (index == -1) |
307 |
return selection; |
308 |
return selection.substring(0, index); |
204 |
} |
309 |
} |
205 |
} |
310 |
} |