author | dadubrow |
Wed, 10 Feb 2010 13:45:43 -0600 | |
branch | RCL_2_4 |
changeset 915 | 3b26c948790f |
parent 913 | f1dffcbe3e11 |
child 953 | 68b6a294ab01 |
permissions | -rw-r--r-- |
911 | 1 |
/* |
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
package com.nokia.cdt.internal.debug.launch.newwizard; |
|
19 |
||
20 |
import java.io.File; |
|
21 |
import java.text.MessageFormat; |
|
915
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
22 |
import java.util.List; |
911 | 23 |
|
24 |
import org.eclipse.cdt.core.model.CoreModel; |
|
25 |
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; |
|
26 |
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; |
|
27 |
import org.eclipse.core.resources.IProject; |
|
28 |
import org.eclipse.core.runtime.IPath; |
|
29 |
import org.eclipse.core.runtime.IStatus; |
|
30 |
import org.eclipse.core.runtime.Path; |
|
31 |
import org.eclipse.core.runtime.Status; |
|
32 |
import org.eclipse.jface.layout.GridDataFactory; |
|
33 |
import org.eclipse.jface.layout.GridLayoutFactory; |
|
34 |
import org.eclipse.jface.resource.JFaceResources; |
|
35 |
import org.eclipse.jface.viewers.ArrayContentProvider; |
|
36 |
import org.eclipse.jface.viewers.ComboViewer; |
|
37 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
|
38 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
39 |
import org.eclipse.jface.viewers.LabelProvider; |
|
40 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
|
41 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
42 |
import org.eclipse.swt.SWT; |
|
43 |
import org.eclipse.swt.events.ControlAdapter; |
|
44 |
import org.eclipse.swt.events.ControlEvent; |
|
45 |
import org.eclipse.swt.events.DisposeEvent; |
|
46 |
import org.eclipse.swt.events.DisposeListener; |
|
47 |
import org.eclipse.swt.events.ModifyEvent; |
|
48 |
import org.eclipse.swt.events.ModifyListener; |
|
49 |
import org.eclipse.swt.events.SelectionAdapter; |
|
50 |
import org.eclipse.swt.events.SelectionEvent; |
|
51 |
import org.eclipse.swt.layout.GridData; |
|
52 |
import org.eclipse.swt.widgets.Button; |
|
53 |
import org.eclipse.swt.widgets.Combo; |
|
54 |
import org.eclipse.swt.widgets.Composite; |
|
55 |
import org.eclipse.swt.widgets.Control; |
|
56 |
import org.eclipse.swt.widgets.FileDialog; |
|
57 |
import org.eclipse.swt.widgets.Label; |
|
58 |
import org.eclipse.swt.widgets.Link; |
|
59 |
import org.eclipse.swt.widgets.Shell; |
|
60 |
import org.eclipse.swt.widgets.Text; |
|
61 |
import org.eclipse.ui.dialogs.PreferencesUtil; |
|
62 |
||
63 |
import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; |
|
64 |
import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; |
|
65 |
import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; |
|
66 |
import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo; |
|
67 |
import com.nokia.cdt.internal.debug.launch.newwizard.LaunchOptionsData.EExeSelection; |
|
68 |
import com.nokia.cpp.internal.api.utils.core.PathUtils; |
|
69 |
import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils; |
|
70 |
||
71 |
/** |
|
72 |
* This dialog allows in-depth configuration of the debug/run process options. |
|
73 |
*/ |
|
74 |
public class DebugRunProcessDialog extends AbstractLaunchSettingsDialog implements ICProjectDescriptionListener { |
|
75 |
private ComboViewer projectExecutableViewer; |
|
76 |
private Text remoteProgramEntry; |
|
77 |
private Button projectExecutableRadioButton; |
|
78 |
private Button remoteExecutableRadioButton; |
|
79 |
private Button attachToProcessRadioButton; |
|
80 |
||
81 |
private Label packageInfoLabel; |
|
82 |
private Button installPackageCheckbox; |
|
83 |
private Combo sisFile; |
|
84 |
private Text sisEdit; |
|
85 |
private Button sisBrowse; |
|
86 |
private Composite installPackageUI; |
|
87 |
||
88 |
protected DebugRunProcessDialog(Shell shell, LaunchOptionsData data) { |
|
89 |
super(shell, data); |
|
90 |
} |
|
91 |
||
92 |
||
93 |
/* (non-Javadoc) |
|
94 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
|
95 |
*/ |
|
96 |
@Override |
|
97 |
protected Control createDialogArea(Composite parent) { |
|
98 |
Composite composite = initDialogArea(parent, |
|
99 |
MessageFormat.format("Change {0} Process", data.getModeLabel()), |
|
100 |
data.isDebug() ? LaunchWizardHelpIds.WIZARD_DIALOG_CHANGE_DEBUG_PROCESS : |
|
101 |
LaunchWizardHelpIds.WIZARD_DIALOG_CHANGE_RUN_PROCESS); |
|
102 |
||
103 |
||
104 |
createProcessSelector(composite); |
|
105 |
||
106 |
Label sep = new Label(composite, SWT.NONE); |
|
107 |
GridDataFactory.fillDefaults().applyTo(sep); |
|
108 |
||
109 |
createPackageConfiguration(composite); |
|
110 |
||
111 |
initUI(); |
|
112 |
||
113 |
validate(); |
|
114 |
||
115 |
return composite; |
|
116 |
} |
|
117 |
||
118 |
||
119 |
private void createProcessSelector(Composite composite) { |
|
120 |
Label label; |
|
121 |
||
122 |
label = new Label(composite, SWT.WRAP); |
|
123 |
label.setText(MessageFormat.format("{0} method:", data.getModeLabel())); |
|
124 |
label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); |
|
125 |
||
126 |
GridDataFactory.fillDefaults().grab(true, false).applyTo(composite); |
|
127 |
||
128 |
Composite radioGroup = new Composite(composite, SWT.NONE); |
|
129 |
GridDataFactory.fillDefaults().grab(true, false).applyTo(radioGroup); |
|
130 |
GridLayoutFactory.fillDefaults().extendedMargins(INDENT, 0, 0, 0).numColumns(2).applyTo(radioGroup); |
|
131 |
||
132 |
createProjectExecutableRadioButton(radioGroup); |
|
133 |
createRemoteExecutableRadioButton(radioGroup); |
|
134 |
||
135 |
label = new Label(radioGroup, SWT.SEPARATOR | SWT.HORIZONTAL); |
|
136 |
GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(label); |
|
137 |
||
138 |
createAttachToProcessRadioButton(radioGroup); |
|
139 |
||
140 |
String msg; |
|
141 |
if (data.isDebug()) |
|
142 |
msg = "Configure how to debug the program. The initial settings reflect the debug capabilities of the selected device and the SIS builder settings."; |
|
143 |
else |
|
144 |
msg = "Configure how to run the program."; |
|
145 |
setMessage(msg); |
|
146 |
||
147 |
switch (data.getExeSelection()) { |
|
148 |
case USE_PROJECT_EXECUTABLE: |
|
149 |
projectExecutableRadioButton.setSelection(true); |
|
150 |
break; |
|
151 |
case USE_REMOTE_EXECUTABLE: |
|
152 |
remoteExecutableRadioButton.setSelection(true); |
|
153 |
break; |
|
154 |
case ATTACH_TO_PROCESS: |
|
155 |
attachToProcessRadioButton.setSelection(true); |
|
156 |
break; |
|
157 |
} |
|
158 |
} |
|
159 |
||
160 |
private void createPackageConfiguration(Composite composite) { |
|
161 |
Label label; |
|
162 |
||
163 |
label = new Label(composite, SWT.WRAP); |
|
164 |
label.setText(MessageFormat.format("Deploy method:", data.getModeLabel())); |
|
165 |
label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); |
|
166 |
||
167 |
GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); |
|
168 |
||
169 |
packageInfoLabel = new Label(composite, SWT.WRAP); |
|
170 |
GridDataFactory.fillDefaults().grab(true, false).applyTo(packageInfoLabel); |
|
171 |
composite.addControlListener(new ControlAdapter() { |
|
172 |
@Override |
|
173 |
public void controlResized(ControlEvent e) { |
|
174 |
packageInfoLabel.pack(); |
|
175 |
} |
|
176 |
}); |
|
177 |
||
178 |
installPackageCheckbox = new Button(composite, SWT.CHECK); |
|
179 |
GridDataFactory.fillDefaults().applyTo(installPackageCheckbox); |
|
180 |
||
181 |
installPackageCheckbox.setText("Install package before launch"); |
|
182 |
installPackageUI = new Composite(composite, SWT.NONE); |
|
183 |
GridDataFactory.fillDefaults().indent(INDENT, 0).applyTo(installPackageUI); |
|
184 |
||
185 |
createSISContents(installPackageUI); |
|
186 |
||
187 |
||
188 |
installPackageCheckbox.addSelectionListener(new SelectionAdapter() { |
|
189 |
@Override |
|
190 |
public void widgetSelected(SelectionEvent e) { |
|
191 |
data.setInstallPackage(installPackageCheckbox.getSelection()); |
|
192 |
updatePackageUI(); |
|
193 |
} |
|
194 |
}); |
|
195 |
||
196 |
||
197 |
if (data.requiresInstallPackage()) { |
|
198 |
installPackageCheckbox.setSelection(true); |
|
199 |
} |
|
200 |
||
201 |
updateSisFile(); |
|
202 |
updatePackageUI(); |
|
203 |
} |
|
204 |
||
205 |
protected void createSISContents(Composite composite) { |
|
206 |
GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(composite); |
|
207 |
||
208 |
final IProject project = data.getProject(); |
|
209 |
ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project); |
|
210 |
if (cpi != null) { |
|
211 |
final Label sisLabel = new Label(composite, SWT.NONE); |
|
212 |
sisLabel.setText("SIS File to Install:"); |
|
213 |
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(1, 1).applyTo(sisLabel); |
|
214 |
sisLabel.setToolTipText("Specify which SIS file to install on the phone prior to launching"); |
|
215 |
sisLabel.setData(UID, "DebugRunProcessDialog.sisLabel"); |
|
216 |
||
217 |
sisFile = new Combo(composite, SWT.READ_ONLY); |
|
218 |
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false).applyTo(sisLabel); |
|
219 |
sisFile.setToolTipText("Specify which SIS file to install on the phone prior to launching"); |
|
220 |
sisFile.add("None"); //$NON-NLS-1$ |
|
221 |
sisFile.setData(UID, "DebugRunProcessDialog.sisFile"); |
|
222 |
||
223 |
sisFile.addSelectionListener(new SelectionAdapter() { |
|
224 |
@Override |
|
225 |
public void widgetSelected(SelectionEvent e) { |
|
226 |
updateSisFile(); |
|
227 |
} |
|
228 |
}); |
|
229 |
||
230 |
ICarbideBuildConfiguration config = cpi.getDefaultConfiguration(); |
|
231 |
for (ISISBuilderInfo info : config.getSISBuilderInfoList()) { |
|
232 |
IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath(); |
|
233 |
sisFile.add(sisPath.toOSString()); |
|
234 |
} |
|
235 |
||
236 |
// select the first sis file if any, otherwise select none |
|
237 |
if (sisFile.getItemCount() > 1) { |
|
238 |
sisFile.select(1); |
|
239 |
} else { |
|
240 |
sisFile.select(0); |
|
241 |
} |
|
242 |
||
243 |
// listen for events so we can detect if they click on the link below and add new sis info. |
|
244 |
CoreModel.getDefault().getProjectDescriptionManager().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED); |
|
245 |
||
246 |
composite.addDisposeListener(new DisposeListener() { |
|
247 |
||
248 |
public void widgetDisposed(DisposeEvent e) { |
|
249 |
CoreModel.getDefault().getProjectDescriptionManager().removeCProjectDescriptionListener(DebugRunProcessDialog.this); |
|
250 |
} |
|
251 |
}); |
|
252 |
||
253 |
Link link = new Link(composite, SWT.NONE); |
|
254 |
link.setText("<a>" + "Modify SIS builder settings for build configuration" + "...</a>"); |
|
255 |
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).grab(true, false).applyTo(link); |
|
256 |
link.addSelectionListener(new SelectionAdapter() { |
|
257 |
public void widgetSelected(SelectionEvent e) { |
|
258 |
PreferencesUtil.createPropertyDialogOn(getShell(), project, "com.nokia.carbide.cdt.internal.builder.ui.CarbideBuildConfigurationsPage", null, null).open(); |
|
259 |
} |
|
260 |
}); |
|
261 |
link.setData(UID, "DebugRunProcessDialog.link"); |
|
262 |
} else { |
|
263 |
// not a Carbide project, just an executable. show a browse/edit combo |
|
264 |
// to let them select a sis file if they want to. |
|
265 |
final Label sisLabel = new Label(composite, SWT.NONE); |
|
266 |
sisLabel.setText("SIS File to Install:"); //$NON-NLS-1$ |
|
267 |
GridDataFactory.swtDefaults().span(2, 1).applyTo(sisLabel); |
|
268 |
sisLabel.setToolTipText("Specify which SIS file to install on the phone prior to launching"); |
|
269 |
sisLabel.setData(UID, "DebugRunProcessDialog.sisLabel"); |
|
270 |
||
271 |
sisEdit = new Text(composite, SWT.BORDER); |
|
272 |
GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(sisEdit); |
|
273 |
sisEdit.setToolTipText("Specify which SIS file to install on the phone prior to launching"); |
|
274 |
sisEdit.addModifyListener(new ModifyListener() { |
|
275 |
public void modifyText(ModifyEvent e) { |
|
276 |
updateSisFile(); |
|
277 |
validate(); |
|
278 |
} |
|
279 |
}); |
|
280 |
sisEdit.setData(UID, "DebugRunProcessDialog.sisEdit"); |
|
281 |
||
282 |
sisBrowse = new Button(composite, SWT.NONE); |
|
283 |
sisBrowse.setText("Browse..."); |
|
284 |
sisBrowse.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); |
|
285 |
sisBrowse.addSelectionListener(new SelectionAdapter() { |
|
286 |
public void widgetSelected(SelectionEvent evt) { |
|
287 |
FileDialog dialog = new FileDialog(getShell(), SWT.NONE); |
|
288 |
||
289 |
dialog.setText("Select installation file"); |
|
290 |
dialog.setFilterExtensions(new String[] {"*.sis*", "*.*"}); |
|
291 |
dialog.setFilterNames(new String[] {"Installation Files", "All Files"}); |
|
292 |
||
293 |
BrowseDialogUtils.initializeFrom(dialog, sisEdit); |
|
294 |
||
295 |
String result = dialog.open(); |
|
296 |
if (result != null && new File(result).exists()) { |
|
297 |
sisEdit.setText(result); |
|
298 |
updateSisFile(); |
|
299 |
validate(); |
|
300 |
} |
|
301 |
} |
|
302 |
}); |
|
303 |
sisBrowse.setData(UID, "DebugRunProcessDialog.sisBrowse"); |
|
304 |
} |
|
305 |
} |
|
306 |
||
307 |
||
308 |
/** |
|
309 |
* |
|
310 |
*/ |
|
311 |
protected void updateSisFile() { |
|
312 |
String sisPath; |
|
313 |
if (sisFile != null) { |
|
314 |
sisPath = sisFile.getSelectionIndex() == 0 ? "" : sisFile.getText(); //$NON-NLS-1$ |
|
315 |
data.setSisPath(sisPath); |
|
316 |
} else if (sisEdit != null) { |
|
317 |
sisPath = sisEdit.getText(); |
|
318 |
data.setSisPath(sisPath); |
|
319 |
} |
|
320 |
} |
|
321 |
||
322 |
||
323 |
private void updatePackageUI() { |
|
324 |
installPackageUI.setEnabled(data.isInstallPackage()); |
|
325 |
for (Control kid : installPackageUI.getChildren()) |
|
326 |
kid.setEnabled(data.isInstallPackage()); |
|
327 |
} |
|
328 |
||
329 |
||
330 |
public void handleEvent(CProjectDescriptionEvent event) { |
|
915
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
331 |
Shell shell = getShell(); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
332 |
if (shell == null || shell.isDisposed()) { |
911 | 333 |
return; |
334 |
} |
|
335 |
||
336 |
IProject project = event.getProject() ; |
|
337 |
||
338 |
if (project != data.getProject()) { |
|
339 |
return; |
|
340 |
} |
|
341 |
||
342 |
if (sisFile != null) { |
|
343 |
ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project); |
|
344 |
if (cpi != null) { |
|
345 |
sisFile.removeAll(); |
|
346 |
||
347 |
sisFile.add("None"); |
|
348 |
||
349 |
ICarbideBuildConfiguration config = cpi.getDefaultConfiguration(); |
|
350 |
for (ISISBuilderInfo info : config.getSISBuilderInfoList()) { |
|
351 |
IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath(); |
|
352 |
sisFile.add(sisPath.toOSString()); |
|
353 |
} |
|
354 |
||
355 |
// select the first sis file if any, otherwise select none |
|
356 |
if (sisFile.getItemCount() > 1) { |
|
357 |
sisFile.select(1); |
|
358 |
} else { |
|
359 |
sisFile.select(0); |
|
360 |
} |
|
361 |
} |
|
362 |
} |
|
363 |
} |
|
364 |
||
365 |
protected void initUI() { |
|
915
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
366 |
List<IPath> exes = data.getExes(); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
367 |
projectExecutableViewer.setInput(exes); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
368 |
IPath exeSelectionPath = data.getExeSelectionPath(); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
369 |
if (exeSelectionPath.equals(Path.EMPTY) && !exes.isEmpty()) |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
370 |
exeSelectionPath = exes.get(0); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
371 |
projectExecutableViewer.setSelection(new StructuredSelection(exeSelectionPath)); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
372 |
IPath remotePath = createSuggestedRemotePath(exeSelectionPath); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
373 |
remoteProgramEntry.setText(PathUtils.convertPathToWindows(remotePath)); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
374 |
|
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
375 |
if (data.getExeSelection() == EExeSelection.USE_PROJECT_EXECUTABLE && exeSelectionPath != null) { |
911 | 376 |
projectExecutableRadioButton.forceFocus(); |
377 |
} |
|
378 |
||
915
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
379 |
if (data.getExeSelection() == EExeSelection.USE_REMOTE_EXECUTABLE && exeSelectionPath != null) { |
911 | 380 |
remoteExecutableRadioButton.forceFocus(); |
381 |
} |
|
382 |
||
383 |
if (data.getExeSelection() == EExeSelection.ATTACH_TO_PROCESS) { |
|
384 |
attachToProcessRadioButton.forceFocus(); |
|
385 |
} |
|
915
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
386 |
|
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
387 |
handleProjectExecutableRadioSelected(); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
388 |
handleRemoteExecutableRadioSelected(); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
389 |
handleAttachToProcessRadioSelected(); |
911 | 390 |
} |
391 |
||
392 |
||
393 |
private IPath createSuggestedRemotePath(IPath exeSelectionPath) { |
|
394 |
String filename = exeSelectionPath.lastSegment(); |
|
395 |
return PathUtils.createPath("C:/sys/bin").append(filename); |
|
396 |
} |
|
397 |
||
398 |
/** |
|
399 |
* Allow selecting an executable detected to be built by the program. |
|
400 |
* @param radioGroup |
|
401 |
*/ |
|
402 |
private void createProjectExecutableRadioButton(Composite radioGroup) { |
|
403 |
projectExecutableRadioButton = new Button(radioGroup, SWT.RADIO); |
|
404 |
GridDataFactory.fillDefaults().grab(false, false).applyTo(projectExecutableRadioButton); |
|
405 |
projectExecutableRadioButton.setText("Launch project &executable:"); |
|
406 |
projectExecutableRadioButton.setData(UID, "radio_project_executable"); |
|
407 |
||
408 |
projectExecutableViewer = new ComboViewer(radioGroup, SWT.READ_ONLY); |
|
409 |
GridDataFactory.fillDefaults().grab(true, false).applyTo(projectExecutableViewer.getControl()); |
|
410 |
projectExecutableViewer.getControl().setData(UID, "combo_project_executable"); |
|
411 |
||
412 |
projectExecutableViewer.setContentProvider(new ArrayContentProvider()); |
|
413 |
projectExecutableViewer.setLabelProvider(new LabelProvider() { |
|
414 |
@Override |
|
415 |
public String getText(Object element) { |
|
416 |
if (element instanceof IPath) |
|
417 |
return ((IPath) element).lastSegment(); |
|
418 |
return super.getText(element); |
|
419 |
} |
|
420 |
}); |
|
421 |
||
422 |
projectExecutableRadioButton.addSelectionListener(new SelectionAdapter() { |
|
423 |
@Override |
|
424 |
public void widgetSelected(SelectionEvent e) { |
|
913 | 425 |
handleProjectExecutableRadioSelected(); |
911 | 426 |
} |
913 | 427 |
|
911 | 428 |
}); |
429 |
||
430 |
projectExecutableViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
|
431 |
||
432 |
public void selectionChanged(SelectionChangedEvent event) { |
|
433 |
Object sel = ((IStructuredSelection) event.getSelection()).getFirstElement(); |
|
434 |
if (sel instanceof IPath) { |
|
435 |
data.setExeSelectionPath((IPath) sel); |
|
436 |
||
437 |
// track the default remote program from the executable, for easy editing |
|
438 |
if (remoteProgramEntry != null) { |
|
439 |
IPath exeSelectionPath = createSuggestedRemotePath(data.getExeSelectionPath()); |
|
440 |
remoteProgramEntry.setText(PathUtils.convertPathToWindows(exeSelectionPath)); |
|
441 |
} |
|
442 |
||
443 |
validate(); |
|
444 |
} |
|
445 |
} |
|
446 |
}); |
|
447 |
} |
|
448 |
||
913 | 449 |
private void handleProjectExecutableRadioSelected() { |
450 |
if (projectExecutableRadioButton.getSelection()) { |
|
451 |
projectExecutableViewer.getControl().setEnabled(true); |
|
452 |
data.setExeSelection(EExeSelection.USE_PROJECT_EXECUTABLE); |
|
915
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
453 |
IPath selectedPath = (IPath) ((IStructuredSelection) projectExecutableViewer.getSelection()).getFirstElement(); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
454 |
if (selectedPath != null) { |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
455 |
String symbianPath = PathUtils.convertPathToWindows(selectedPath); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
456 |
data.setExeSelectionPath(new Path(symbianPath)); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
457 |
} |
913 | 458 |
validate(); |
459 |
} else { |
|
460 |
projectExecutableViewer.getControl().setEnabled(false); |
|
461 |
// another button becomes active and sets the new launch process |
|
462 |
} |
|
463 |
} |
|
464 |
||
911 | 465 |
/** |
466 |
* Allow user to enter an executable path. |
|
467 |
* @param radioGroup |
|
468 |
*/ |
|
469 |
private void createRemoteExecutableRadioButton(Composite radioGroup) { |
|
470 |
remoteExecutableRadioButton = new Button(radioGroup, SWT.RADIO); |
|
471 |
GridDataFactory.fillDefaults().grab(false, false).applyTo(remoteExecutableRadioButton); |
|
472 |
remoteExecutableRadioButton.setText("Launch &remote program:"); |
|
473 |
||
474 |
remoteExecutableRadioButton.setData(UID, "radio_remote_program"); |
|
475 |
||
476 |
remoteProgramEntry = new Text(radioGroup, SWT.BORDER); |
|
477 |
GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteProgramEntry); |
|
478 |
||
479 |
remoteProgramEntry.setData(UID, "text_remote_program"); |
|
480 |
||
481 |
remoteExecutableRadioButton.addSelectionListener(new SelectionAdapter() { |
|
482 |
@Override |
|
483 |
public void widgetSelected(SelectionEvent e) { |
|
913 | 484 |
handleRemoteExecutableRadioSelected(); |
911 | 485 |
} |
913 | 486 |
|
911 | 487 |
}); |
488 |
||
915
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
489 |
remoteProgramEntry.addModifyListener(new ModifyListener() { |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
490 |
public void modifyText(ModifyEvent e) { |
911 | 491 |
data.setExeSelectionPath(new Path(remoteProgramEntry.getText().trim())); |
492 |
validate(); |
|
493 |
} |
|
494 |
}); |
|
495 |
} |
|
496 |
||
913 | 497 |
private void handleRemoteExecutableRadioSelected() { |
498 |
if (remoteExecutableRadioButton.getSelection()) { |
|
499 |
remoteProgramEntry.setEnabled(true); |
|
500 |
data.setExeSelection(EExeSelection.USE_REMOTE_EXECUTABLE); |
|
501 |
String symbianPath = PathUtils.convertPathToWindows(remoteProgramEntry.getText()); |
|
502 |
data.setExeSelectionPath(new Path(symbianPath)); |
|
503 |
validate(); |
|
504 |
} else { |
|
505 |
remoteProgramEntry.setEnabled(false); |
|
506 |
// another button becomes active and sets the new launch process |
|
507 |
} |
|
508 |
} |
|
509 |
||
911 | 510 |
/** |
511 |
* Allow user to attach to a process. |
|
512 |
* @param radioGroup |
|
513 |
*/ |
|
514 |
private void createAttachToProcessRadioButton(Composite radioGroup) { |
|
515 |
attachToProcessRadioButton = new Button(radioGroup, SWT.RADIO); |
|
516 |
GridDataFactory.fillDefaults().grab(false, false).applyTo(attachToProcessRadioButton); |
|
517 |
attachToProcessRadioButton.setText("&Attach to process:"); |
|
518 |
||
519 |
attachToProcessRadioButton.setData(UID, "radio_attach_to_process"); |
|
520 |
||
521 |
Label label = new Label(radioGroup, SWT.WRAP); |
|
522 |
GridDataFactory.fillDefaults().grab(false, false).align(SWT.LEFT, SWT.CENTER).applyTo(label); |
|
523 |
||
524 |
label.setText("(selected at launch time)"); |
|
525 |
||
526 |
attachToProcessRadioButton.addSelectionListener(new SelectionAdapter() { |
|
527 |
@Override |
|
528 |
public void widgetSelected(SelectionEvent e) { |
|
913 | 529 |
handleAttachToProcessRadioSelected(); |
911 | 530 |
} |
913 | 531 |
|
911 | 532 |
}); |
533 |
||
534 |
} |
|
535 |
||
913 | 536 |
private void handleAttachToProcessRadioSelected() { |
537 |
if (attachToProcessRadioButton.getSelection()) { |
|
538 |
data.setExeSelection(EExeSelection.ATTACH_TO_PROCESS); |
|
539 |
data.setExeSelectionPath(null); |
|
540 |
validate(); |
|
541 |
} else { |
|
542 |
// another button becomes active and sets the new launch process |
|
543 |
} |
|
544 |
} |
|
545 |
||
911 | 546 |
@Override |
547 |
protected void validate() { |
|
548 |
IStatus status = Status.OK_STATUS; |
|
549 |
||
550 |
// check launch method |
|
551 |
IPath exePath = data.getExeSelectionPath(); |
|
552 |
switch (data.getExeSelection()) { |
|
553 |
case USE_PROJECT_EXECUTABLE: |
|
554 |
if (exePath.isEmpty()) { |
|
555 |
status = error("The project builds no executables."); |
|
556 |
} |
|
557 |
break; |
|
558 |
case USE_REMOTE_EXECUTABLE: |
|
559 |
if (exePath.isEmpty()) { |
|
560 |
status = error("Enter a non-empty executable path."); |
|
561 |
} else { |
|
562 |
String exePathString = exePath.toString(); |
|
563 |
char drive = exePathString.charAt(0); |
|
564 |
char colon = exePathString.length() < 2 ? 0x0 : exePathString.charAt(1); |
|
565 |
char root = exePathString.length() < 3 ? 0x0 : exePathString.charAt(2); |
|
566 |
char lastChar = exePathString.charAt(exePathString.length() - 1); |
|
567 |
if (!Character.isLetter(drive) || colon != ':' || (root != '\\' && root != '/') || |
|
568 |
lastChar == '\\' || lastChar == '/' || lastChar == ':') { |
|
569 |
status = error("The executable path must be absolute."); |
|
570 |
} else if (exePath.getFileExtension() == null) { |
|
571 |
status = warning("The executable path should end in a filename."); |
|
572 |
} |
|
573 |
} |
|
574 |
break; |
|
575 |
case ATTACH_TO_PROCESS: |
|
576 |
break; |
|
577 |
} |
|
578 |
||
579 |
// check SIS selection |
|
580 |
if (data.isInstallPackage()) { |
|
581 |
if (sisEdit != null) { |
|
582 |
String text = sisEdit.getText().trim(); |
|
583 |
if (text.length() > 0) { |
|
584 |
// empty is allowed, but if they specify something, make sure |
|
585 |
// it exists |
|
586 |
File file = new File(text); |
|
587 |
if (!file.exists()) { |
|
588 |
status = error("The SIS file ''{0}'' does not exist.", text); |
|
589 |
} |
|
590 |
} |
|
591 |
} |
|
592 |
} |
|
593 |
||
594 |
updateStatus(status); |
|
595 |
} |
|
596 |
} |
|
597 |