author | dadubrow |
Tue, 16 Feb 2010 13:41:43 -0600 | |
branch | RCL_2_4 |
changeset 966 | 15c9cbbf6707 |
parent 953 | 68b6a294ab01 |
child 1044 | 698d7a6c6f6a |
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; |
|
953 | 67 |
import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EExeSelection; |
911 | 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 |
||
953 | 88 |
protected DebugRunProcessDialog(Shell shell, LaunchWizardData data) { |
911 | 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, |
|
966 | 99 |
MessageFormat.format(Messages.getString("DebugRunProcessDialog.ChangeProcessMsg"), data.getModeLabel()), //$NON-NLS-1$ |
911 | 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); |
|
966 | 123 |
label.setText(MessageFormat.format(Messages.getString("DebugRunProcessDialog.ModeLabel"), data.getModeLabel())); //$NON-NLS-1$ |
911 | 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()) |
|
966 | 142 |
msg = Messages.getString("DebugRunProcessDialog.DebugConfigureMsg"); //$NON-NLS-1$ |
911 | 143 |
else |
966 | 144 |
msg = Messages.getString("DebugRunProcessDialog.RunConfigureMsg"); //$NON-NLS-1$ |
911 | 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); |
|
966 | 164 |
label.setText(MessageFormat.format(Messages.getString("DebugRunProcessDialog.DeployLabel"), data.getModeLabel())); //$NON-NLS-1$ |
911 | 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 |
||
966 | 181 |
installPackageCheckbox.setText(Messages.getString("DebugRunProcessDialog.InstallBeforeLaunchLabel")); //$NON-NLS-1$ |
911 | 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 |
||
953 | 197 |
if (data.isInstallPackage()) { |
911 | 198 |
installPackageCheckbox.setSelection(true); |
953 | 199 |
updatePackageUI(); |
911 | 200 |
} |
201 |
||
202 |
updateSisFile(); |
|
203 |
updatePackageUI(); |
|
204 |
} |
|
205 |
||
206 |
protected void createSISContents(Composite composite) { |
|
207 |
GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(composite); |
|
208 |
||
209 |
final IProject project = data.getProject(); |
|
210 |
ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project); |
|
211 |
if (cpi != null) { |
|
212 |
final Label sisLabel = new Label(composite, SWT.NONE); |
|
966 | 213 |
sisLabel.setText(Messages.getString("DebugRunProcessDialog.SISFileLabel")); //$NON-NLS-1$ |
911 | 214 |
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(1, 1).applyTo(sisLabel); |
966 | 215 |
sisLabel.setToolTipText(Messages.getString("DebugRunProcessDialog.SISQueryTip")); //$NON-NLS-1$ |
216 |
sisLabel.setData(UID, "DebugRunProcessDialog.sisLabel"); //$NON-NLS-1$ |
|
911 | 217 |
|
218 |
sisFile = new Combo(composite, SWT.READ_ONLY); |
|
219 |
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false).applyTo(sisLabel); |
|
966 | 220 |
sisFile.setToolTipText(Messages.getString("DebugRunProcessDialog.SISQueryTip")); //$NON-NLS-1$ |
911 | 221 |
sisFile.add("None"); //$NON-NLS-1$ |
966 | 222 |
sisFile.setData(UID, "DebugRunProcessDialog.sisFile"); //$NON-NLS-1$ |
911 | 223 |
|
224 |
sisFile.addSelectionListener(new SelectionAdapter() { |
|
225 |
@Override |
|
226 |
public void widgetSelected(SelectionEvent e) { |
|
227 |
updateSisFile(); |
|
228 |
} |
|
229 |
}); |
|
230 |
||
231 |
ICarbideBuildConfiguration config = cpi.getDefaultConfiguration(); |
|
232 |
for (ISISBuilderInfo info : config.getSISBuilderInfoList()) { |
|
233 |
IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath(); |
|
234 |
sisFile.add(sisPath.toOSString()); |
|
235 |
} |
|
236 |
||
237 |
// select the first sis file if any, otherwise select none |
|
238 |
if (sisFile.getItemCount() > 1) { |
|
239 |
sisFile.select(1); |
|
240 |
} else { |
|
241 |
sisFile.select(0); |
|
242 |
} |
|
243 |
||
244 |
// listen for events so we can detect if they click on the link below and add new sis info. |
|
245 |
CoreModel.getDefault().getProjectDescriptionManager().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED); |
|
246 |
||
247 |
composite.addDisposeListener(new DisposeListener() { |
|
248 |
||
249 |
public void widgetDisposed(DisposeEvent e) { |
|
250 |
CoreModel.getDefault().getProjectDescriptionManager().removeCProjectDescriptionListener(DebugRunProcessDialog.this); |
|
251 |
} |
|
252 |
}); |
|
253 |
||
254 |
Link link = new Link(composite, SWT.NONE); |
|
966 | 255 |
link.setText("<a>" + Messages.getString("DebugRunProcessDialog.SISConfigLinkText") + "...</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
911 | 256 |
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).grab(true, false).applyTo(link); |
257 |
link.addSelectionListener(new SelectionAdapter() { |
|
258 |
public void widgetSelected(SelectionEvent e) { |
|
966 | 259 |
PreferencesUtil.createPropertyDialogOn(getShell(), project, "com.nokia.carbide.cdt.internal.builder.ui.CarbideBuildConfigurationsPage", null, null).open(); //$NON-NLS-1$ |
911 | 260 |
} |
261 |
}); |
|
966 | 262 |
link.setData(UID, "DebugRunProcessDialog.link"); //$NON-NLS-1$ |
911 | 263 |
} else { |
264 |
// not a Carbide project, just an executable. show a browse/edit combo |
|
265 |
// to let them select a sis file if they want to. |
|
266 |
final Label sisLabel = new Label(composite, SWT.NONE); |
|
267 |
sisLabel.setText("SIS File to Install:"); //$NON-NLS-1$ |
|
268 |
GridDataFactory.swtDefaults().span(2, 1).applyTo(sisLabel); |
|
966 | 269 |
sisLabel.setToolTipText(Messages.getString("DebugRunProcessDialog.SISQueryTip")); //$NON-NLS-1$ |
270 |
sisLabel.setData(UID, "DebugRunProcessDialog.sisLabel"); //$NON-NLS-1$ |
|
911 | 271 |
|
272 |
sisEdit = new Text(composite, SWT.BORDER); |
|
273 |
GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(sisEdit); |
|
966 | 274 |
sisEdit.setToolTipText(Messages.getString("DebugRunProcessDialog.SISQueryTip")); //$NON-NLS-1$ |
911 | 275 |
sisEdit.addModifyListener(new ModifyListener() { |
276 |
public void modifyText(ModifyEvent e) { |
|
277 |
updateSisFile(); |
|
278 |
validate(); |
|
279 |
} |
|
280 |
}); |
|
966 | 281 |
sisEdit.setData(UID, "DebugRunProcessDialog.sisEdit"); //$NON-NLS-1$ |
911 | 282 |
|
283 |
sisBrowse = new Button(composite, SWT.NONE); |
|
966 | 284 |
sisBrowse.setText(Messages.getString("DebugRunProcessDialog.BrowseLabel")); //$NON-NLS-1$ |
911 | 285 |
sisBrowse.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); |
286 |
sisBrowse.addSelectionListener(new SelectionAdapter() { |
|
287 |
public void widgetSelected(SelectionEvent evt) { |
|
288 |
FileDialog dialog = new FileDialog(getShell(), SWT.NONE); |
|
289 |
||
966 | 290 |
dialog.setText(Messages.getString("DebugRunProcessDialog.Title")); //$NON-NLS-1$ |
291 |
dialog.setFilterExtensions(new String[] {"*.sis*", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$ |
|
292 |
dialog.setFilterNames(new String[] {Messages.getString("DebugRunProcessDialog.InstallFilterName"), Messages.getString("DebugRunProcessDialog.AllFilterName")}); //$NON-NLS-1$ //$NON-NLS-2$ |
|
911 | 293 |
|
294 |
BrowseDialogUtils.initializeFrom(dialog, sisEdit); |
|
295 |
||
296 |
String result = dialog.open(); |
|
297 |
if (result != null && new File(result).exists()) { |
|
298 |
sisEdit.setText(result); |
|
299 |
updateSisFile(); |
|
300 |
validate(); |
|
301 |
} |
|
302 |
} |
|
303 |
}); |
|
966 | 304 |
sisBrowse.setData(UID, "DebugRunProcessDialog.sisBrowse"); //$NON-NLS-1$ |
911 | 305 |
} |
306 |
} |
|
307 |
||
308 |
||
309 |
/** |
|
310 |
* |
|
311 |
*/ |
|
312 |
protected void updateSisFile() { |
|
313 |
String sisPath; |
|
314 |
if (sisFile != null) { |
|
953 | 315 |
sisPath = sisFile.getSelectionIndex() == 0 ? null : sisFile.getText(); //$NON-NLS-1$ |
911 | 316 |
data.setSisPath(sisPath); |
317 |
} else if (sisEdit != null) { |
|
318 |
sisPath = sisEdit.getText(); |
|
319 |
data.setSisPath(sisPath); |
|
320 |
} |
|
321 |
} |
|
322 |
||
323 |
||
324 |
private void updatePackageUI() { |
|
325 |
installPackageUI.setEnabled(data.isInstallPackage()); |
|
326 |
for (Control kid : installPackageUI.getChildren()) |
|
327 |
kid.setEnabled(data.isInstallPackage()); |
|
328 |
} |
|
329 |
||
330 |
||
331 |
public void handleEvent(CProjectDescriptionEvent event) { |
|
915
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
332 |
Shell shell = getShell(); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
333 |
if (shell == null || shell.isDisposed()) { |
911 | 334 |
return; |
335 |
} |
|
336 |
||
337 |
IProject project = event.getProject() ; |
|
338 |
||
339 |
if (project != data.getProject()) { |
|
340 |
return; |
|
341 |
} |
|
342 |
||
343 |
if (sisFile != null) { |
|
344 |
ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project); |
|
345 |
if (cpi != null) { |
|
346 |
sisFile.removeAll(); |
|
347 |
||
966 | 348 |
sisFile.add(Messages.getString("DebugRunProcessDialog.NoneItem")); //$NON-NLS-1$ |
911 | 349 |
|
350 |
ICarbideBuildConfiguration config = cpi.getDefaultConfiguration(); |
|
351 |
for (ISISBuilderInfo info : config.getSISBuilderInfoList()) { |
|
352 |
IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath(); |
|
353 |
sisFile.add(sisPath.toOSString()); |
|
354 |
} |
|
355 |
||
356 |
// select the first sis file if any, otherwise select none |
|
357 |
if (sisFile.getItemCount() > 1) { |
|
358 |
sisFile.select(1); |
|
359 |
} else { |
|
360 |
sisFile.select(0); |
|
361 |
} |
|
362 |
} |
|
363 |
} |
|
364 |
} |
|
365 |
||
366 |
protected void initUI() { |
|
915
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
367 |
List<IPath> exes = data.getExes(); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
368 |
projectExecutableViewer.setInput(exes); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
369 |
IPath exeSelectionPath = data.getExeSelectionPath(); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
370 |
if (exeSelectionPath.equals(Path.EMPTY) && !exes.isEmpty()) |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
371 |
exeSelectionPath = exes.get(0); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
372 |
projectExecutableViewer.setSelection(new StructuredSelection(exeSelectionPath)); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
373 |
IPath remotePath = createSuggestedRemotePath(exeSelectionPath); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
374 |
remoteProgramEntry.setText(PathUtils.convertPathToWindows(remotePath)); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
375 |
|
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
376 |
if (data.getExeSelection() == EExeSelection.USE_PROJECT_EXECUTABLE && exeSelectionPath != null) { |
911 | 377 |
projectExecutableRadioButton.forceFocus(); |
378 |
} |
|
379 |
||
915
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
380 |
if (data.getExeSelection() == EExeSelection.USE_REMOTE_EXECUTABLE && exeSelectionPath != null) { |
911 | 381 |
remoteExecutableRadioButton.forceFocus(); |
382 |
} |
|
383 |
||
384 |
if (data.getExeSelection() == EExeSelection.ATTACH_TO_PROCESS) { |
|
385 |
attachToProcessRadioButton.forceFocus(); |
|
386 |
} |
|
915
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
387 |
|
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
388 |
handleProjectExecutableRadioSelected(); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
389 |
handleRemoteExecutableRadioSelected(); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
390 |
handleAttachToProcessRadioSelected(); |
911 | 391 |
} |
392 |
||
393 |
||
394 |
private IPath createSuggestedRemotePath(IPath exeSelectionPath) { |
|
395 |
String filename = exeSelectionPath.lastSegment(); |
|
966 | 396 |
return PathUtils.createPath("C:/sys/bin").append(filename); //$NON-NLS-1$ |
911 | 397 |
} |
398 |
||
399 |
/** |
|
400 |
* Allow selecting an executable detected to be built by the program. |
|
401 |
* @param radioGroup |
|
402 |
*/ |
|
403 |
private void createProjectExecutableRadioButton(Composite radioGroup) { |
|
404 |
projectExecutableRadioButton = new Button(radioGroup, SWT.RADIO); |
|
405 |
GridDataFactory.fillDefaults().grab(false, false).applyTo(projectExecutableRadioButton); |
|
966 | 406 |
projectExecutableRadioButton.setText(Messages.getString("DebugRunProcessDialog.LaunchProjectExeLabel")); //$NON-NLS-1$ |
407 |
projectExecutableRadioButton.setData(UID, "radio_project_executable"); //$NON-NLS-1$ |
|
911 | 408 |
|
409 |
projectExecutableViewer = new ComboViewer(radioGroup, SWT.READ_ONLY); |
|
410 |
GridDataFactory.fillDefaults().grab(true, false).applyTo(projectExecutableViewer.getControl()); |
|
966 | 411 |
projectExecutableViewer.getControl().setData(UID, "combo_project_executable"); //$NON-NLS-1$ |
911 | 412 |
|
413 |
projectExecutableViewer.setContentProvider(new ArrayContentProvider()); |
|
414 |
projectExecutableViewer.setLabelProvider(new LabelProvider() { |
|
415 |
@Override |
|
416 |
public String getText(Object element) { |
|
417 |
if (element instanceof IPath) |
|
418 |
return ((IPath) element).lastSegment(); |
|
419 |
return super.getText(element); |
|
420 |
} |
|
421 |
}); |
|
422 |
||
423 |
projectExecutableRadioButton.addSelectionListener(new SelectionAdapter() { |
|
424 |
@Override |
|
425 |
public void widgetSelected(SelectionEvent e) { |
|
913 | 426 |
handleProjectExecutableRadioSelected(); |
911 | 427 |
} |
913 | 428 |
|
911 | 429 |
}); |
430 |
||
431 |
projectExecutableViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
|
432 |
||
433 |
public void selectionChanged(SelectionChangedEvent event) { |
|
434 |
Object sel = ((IStructuredSelection) event.getSelection()).getFirstElement(); |
|
435 |
if (sel instanceof IPath) { |
|
436 |
data.setExeSelectionPath((IPath) sel); |
|
437 |
||
438 |
// track the default remote program from the executable, for easy editing |
|
439 |
if (remoteProgramEntry != null) { |
|
440 |
IPath exeSelectionPath = createSuggestedRemotePath(data.getExeSelectionPath()); |
|
441 |
remoteProgramEntry.setText(PathUtils.convertPathToWindows(exeSelectionPath)); |
|
442 |
} |
|
443 |
||
444 |
validate(); |
|
445 |
} |
|
446 |
} |
|
447 |
}); |
|
448 |
} |
|
449 |
||
913 | 450 |
private void handleProjectExecutableRadioSelected() { |
451 |
if (projectExecutableRadioButton.getSelection()) { |
|
452 |
projectExecutableViewer.getControl().setEnabled(true); |
|
453 |
data.setExeSelection(EExeSelection.USE_PROJECT_EXECUTABLE); |
|
915
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
454 |
IPath selectedPath = (IPath) ((IStructuredSelection) projectExecutableViewer.getSelection()).getFirstElement(); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
455 |
if (selectedPath != null) { |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
456 |
String symbianPath = PathUtils.convertPathToWindows(selectedPath); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
457 |
data.setExeSelectionPath(new Path(symbianPath)); |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
458 |
} |
913 | 459 |
validate(); |
460 |
} else { |
|
461 |
projectExecutableViewer.getControl().setEnabled(false); |
|
462 |
// another button becomes active and sets the new launch process |
|
463 |
} |
|
464 |
} |
|
465 |
||
911 | 466 |
/** |
467 |
* Allow user to enter an executable path. |
|
468 |
* @param radioGroup |
|
469 |
*/ |
|
470 |
private void createRemoteExecutableRadioButton(Composite radioGroup) { |
|
471 |
remoteExecutableRadioButton = new Button(radioGroup, SWT.RADIO); |
|
472 |
GridDataFactory.fillDefaults().grab(false, false).applyTo(remoteExecutableRadioButton); |
|
966 | 473 |
remoteExecutableRadioButton.setText(Messages.getString("DebugRunProcessDialog.LaunchRemoteProgLabel")); //$NON-NLS-1$ |
911 | 474 |
|
966 | 475 |
remoteExecutableRadioButton.setData(UID, "radio_remote_program"); //$NON-NLS-1$ |
911 | 476 |
|
477 |
remoteProgramEntry = new Text(radioGroup, SWT.BORDER); |
|
478 |
GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteProgramEntry); |
|
479 |
||
966 | 480 |
remoteProgramEntry.setData(UID, "text_remote_program"); //$NON-NLS-1$ |
911 | 481 |
|
482 |
remoteExecutableRadioButton.addSelectionListener(new SelectionAdapter() { |
|
483 |
@Override |
|
484 |
public void widgetSelected(SelectionEvent e) { |
|
913 | 485 |
handleRemoteExecutableRadioSelected(); |
911 | 486 |
} |
913 | 487 |
|
911 | 488 |
}); |
489 |
||
915
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
490 |
remoteProgramEntry.addModifyListener(new ModifyListener() { |
3b26c948790f
better initialization and validation in debugrunprocess dialog
dadubrow
parents:
913
diff
changeset
|
491 |
public void modifyText(ModifyEvent e) { |
911 | 492 |
data.setExeSelectionPath(new Path(remoteProgramEntry.getText().trim())); |
493 |
validate(); |
|
494 |
} |
|
495 |
}); |
|
496 |
} |
|
497 |
||
913 | 498 |
private void handleRemoteExecutableRadioSelected() { |
499 |
if (remoteExecutableRadioButton.getSelection()) { |
|
500 |
remoteProgramEntry.setEnabled(true); |
|
501 |
data.setExeSelection(EExeSelection.USE_REMOTE_EXECUTABLE); |
|
502 |
String symbianPath = PathUtils.convertPathToWindows(remoteProgramEntry.getText()); |
|
503 |
data.setExeSelectionPath(new Path(symbianPath)); |
|
504 |
validate(); |
|
505 |
} else { |
|
506 |
remoteProgramEntry.setEnabled(false); |
|
507 |
// another button becomes active and sets the new launch process |
|
508 |
} |
|
509 |
} |
|
510 |
||
911 | 511 |
/** |
512 |
* Allow user to attach to a process. |
|
513 |
* @param radioGroup |
|
514 |
*/ |
|
515 |
private void createAttachToProcessRadioButton(Composite radioGroup) { |
|
516 |
attachToProcessRadioButton = new Button(radioGroup, SWT.RADIO); |
|
517 |
GridDataFactory.fillDefaults().grab(false, false).applyTo(attachToProcessRadioButton); |
|
966 | 518 |
attachToProcessRadioButton.setText(Messages.getString("DebugRunProcessDialog.AttachLabel")); //$NON-NLS-1$ |
911 | 519 |
|
966 | 520 |
attachToProcessRadioButton.setData(UID, "radio_attach_to_process"); //$NON-NLS-1$ |
911 | 521 |
|
522 |
Label label = new Label(radioGroup, SWT.WRAP); |
|
523 |
GridDataFactory.fillDefaults().grab(false, false).align(SWT.LEFT, SWT.CENTER).applyTo(label); |
|
524 |
||
966 | 525 |
label.setText(Messages.getString("DebugRunProcessDialog.AttachAddlMsg")); //$NON-NLS-1$ |
911 | 526 |
|
527 |
attachToProcessRadioButton.addSelectionListener(new SelectionAdapter() { |
|
528 |
@Override |
|
529 |
public void widgetSelected(SelectionEvent e) { |
|
913 | 530 |
handleAttachToProcessRadioSelected(); |
911 | 531 |
} |
913 | 532 |
|
911 | 533 |
}); |
534 |
||
535 |
} |
|
536 |
||
913 | 537 |
private void handleAttachToProcessRadioSelected() { |
538 |
if (attachToProcessRadioButton.getSelection()) { |
|
539 |
data.setExeSelection(EExeSelection.ATTACH_TO_PROCESS); |
|
540 |
data.setExeSelectionPath(null); |
|
541 |
validate(); |
|
542 |
} else { |
|
543 |
// another button becomes active and sets the new launch process |
|
544 |
} |
|
545 |
} |
|
546 |
||
911 | 547 |
@Override |
548 |
protected void validate() { |
|
549 |
IStatus status = Status.OK_STATUS; |
|
550 |
||
551 |
// check launch method |
|
552 |
IPath exePath = data.getExeSelectionPath(); |
|
553 |
switch (data.getExeSelection()) { |
|
554 |
case USE_PROJECT_EXECUTABLE: |
|
555 |
if (exePath.isEmpty()) { |
|
966 | 556 |
status = error(Messages.getString("DebugRunProcessDialog.NoExesError")); //$NON-NLS-1$ |
911 | 557 |
} |
558 |
break; |
|
559 |
case USE_REMOTE_EXECUTABLE: |
|
560 |
if (exePath.isEmpty()) { |
|
966 | 561 |
status = error(Messages.getString("DebugRunProcessDialog.EnterPathError")); //$NON-NLS-1$ |
911 | 562 |
} else { |
563 |
String exePathString = exePath.toString(); |
|
564 |
char drive = exePathString.charAt(0); |
|
565 |
char colon = exePathString.length() < 2 ? 0x0 : exePathString.charAt(1); |
|
566 |
char root = exePathString.length() < 3 ? 0x0 : exePathString.charAt(2); |
|
567 |
char lastChar = exePathString.charAt(exePathString.length() - 1); |
|
568 |
if (!Character.isLetter(drive) || colon != ':' || (root != '\\' && root != '/') || |
|
569 |
lastChar == '\\' || lastChar == '/' || lastChar == ':') { |
|
966 | 570 |
status = error(Messages.getString("DebugRunProcessDialog.AbsolutePathError")); //$NON-NLS-1$ |
911 | 571 |
} else if (exePath.getFileExtension() == null) { |
966 | 572 |
status = warning(Messages.getString("DebugRunProcessDialog.FilePathError")); //$NON-NLS-1$ |
911 | 573 |
} |
574 |
} |
|
575 |
break; |
|
576 |
case ATTACH_TO_PROCESS: |
|
577 |
break; |
|
578 |
} |
|
579 |
||
580 |
// check SIS selection |
|
581 |
if (data.isInstallPackage()) { |
|
582 |
if (sisEdit != null) { |
|
583 |
String text = sisEdit.getText().trim(); |
|
584 |
if (text.length() > 0) { |
|
585 |
// empty is allowed, but if they specify something, make sure |
|
586 |
// it exists |
|
587 |
File file = new File(text); |
|
588 |
if (!file.exists()) { |
|
966 | 589 |
status = error(Messages.getString("DebugRunProcessDialog.SISFileExistError"), text); //$NON-NLS-1$ |
911 | 590 |
} |
591 |
} |
|
592 |
} |
|
593 |
} |
|
594 |
||
595 |
updateStatus(status); |
|
596 |
} |
|
597 |
} |
|
598 |