author | dadubrow |
Wed, 10 Mar 2010 15:25:49 -0600 | |
changeset 1090 | 02cf64aef519 |
parent 1045 | 7bd4eb5648d7 |
child 1185 | 02373fb1e121 |
permissions | -rw-r--r-- |
956 | 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; |
|
22 |
import java.util.List; |
|
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.LaunchWizardData.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, LaunchWizardData 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, |
|
969 | 99 |
MessageFormat.format(Messages.getString("DebugRunProcessDialog.ChangeProcessMsg"), data.getModeLabel()), //$NON-NLS-1$ |
956 | 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); |
|
969 | 123 |
label.setText(MessageFormat.format(Messages.getString("DebugRunProcessDialog.ModeLabel"), data.getModeLabel())); //$NON-NLS-1$ |
956 | 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()) |
|
969 | 142 |
msg = Messages.getString("DebugRunProcessDialog.DebugConfigureMsg"); //$NON-NLS-1$ |
956 | 143 |
else |
969 | 144 |
msg = Messages.getString("DebugRunProcessDialog.RunConfigureMsg"); //$NON-NLS-1$ |
956 | 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); |
|
969 | 164 |
label.setText(MessageFormat.format(Messages.getString("DebugRunProcessDialog.DeployLabel"), data.getModeLabel())); //$NON-NLS-1$ |
956 | 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 |
||
969 | 181 |
installPackageCheckbox.setText(Messages.getString("DebugRunProcessDialog.InstallBeforeLaunchLabel")); //$NON-NLS-1$ |
956 | 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.isInstallPackage()) { |
|
198 |
installPackageCheckbox.setSelection(true); |
|
199 |
updatePackageUI(); |
|
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); |
|
969 | 213 |
sisLabel.setText(Messages.getString("DebugRunProcessDialog.SISFileLabel")); //$NON-NLS-1$ |
956 | 214 |
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(1, 1).applyTo(sisLabel); |
969 | 215 |
sisLabel.setToolTipText(Messages.getString("DebugRunProcessDialog.SISQueryTip")); //$NON-NLS-1$ |
216 |
sisLabel.setData(UID, "DebugRunProcessDialog.sisLabel"); //$NON-NLS-1$ |
|
956 | 217 |
|
218 |
sisFile = new Combo(composite, SWT.READ_ONLY); |
|
1045
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
219 |
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false).applyTo(sisFile); |
969 | 220 |
sisFile.setToolTipText(Messages.getString("DebugRunProcessDialog.SISQueryTip")); //$NON-NLS-1$ |
221 |
sisFile.setData(UID, "DebugRunProcessDialog.sisFile"); //$NON-NLS-1$ |
|
956 | 222 |
|
223 |
sisFile.addSelectionListener(new SelectionAdapter() { |
|
224 |
@Override |
|
225 |
public void widgetSelected(SelectionEvent e) { |
|
226 |
updateSisFile(); |
|
227 |
} |
|
228 |
}); |
|
229 |
||
1045
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
230 |
updateSisFileCombo(cpi); |
956 | 231 |
|
232 |
// listen for events so we can detect if they click on the link below and add new sis info. |
|
233 |
CoreModel.getDefault().getProjectDescriptionManager().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED); |
|
234 |
||
235 |
composite.addDisposeListener(new DisposeListener() { |
|
236 |
||
237 |
public void widgetDisposed(DisposeEvent e) { |
|
238 |
CoreModel.getDefault().getProjectDescriptionManager().removeCProjectDescriptionListener(DebugRunProcessDialog.this); |
|
239 |
} |
|
240 |
}); |
|
241 |
||
242 |
Link link = new Link(composite, SWT.NONE); |
|
969 | 243 |
link.setText("<a>" + Messages.getString("DebugRunProcessDialog.SISConfigLinkText") + "...</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
956 | 244 |
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).grab(true, false).applyTo(link); |
245 |
link.addSelectionListener(new SelectionAdapter() { |
|
246 |
public void widgetSelected(SelectionEvent e) { |
|
969 | 247 |
PreferencesUtil.createPropertyDialogOn(getShell(), project, "com.nokia.carbide.cdt.internal.builder.ui.CarbideBuildConfigurationsPage", null, null).open(); //$NON-NLS-1$ |
956 | 248 |
} |
249 |
}); |
|
969 | 250 |
link.setData(UID, "DebugRunProcessDialog.link"); //$NON-NLS-1$ |
956 | 251 |
} else { |
252 |
// not a Carbide project, just an executable. show a browse/edit combo |
|
253 |
// to let them select a sis file if they want to. |
|
254 |
final Label sisLabel = new Label(composite, SWT.NONE); |
|
255 |
sisLabel.setText("SIS File to Install:"); //$NON-NLS-1$ |
|
256 |
GridDataFactory.swtDefaults().span(2, 1).applyTo(sisLabel); |
|
969 | 257 |
sisLabel.setToolTipText(Messages.getString("DebugRunProcessDialog.SISQueryTip")); //$NON-NLS-1$ |
258 |
sisLabel.setData(UID, "DebugRunProcessDialog.sisLabel"); //$NON-NLS-1$ |
|
956 | 259 |
|
260 |
sisEdit = new Text(composite, SWT.BORDER); |
|
261 |
GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(sisEdit); |
|
969 | 262 |
sisEdit.setToolTipText(Messages.getString("DebugRunProcessDialog.SISQueryTip")); //$NON-NLS-1$ |
956 | 263 |
sisEdit.addModifyListener(new ModifyListener() { |
264 |
public void modifyText(ModifyEvent e) { |
|
265 |
updateSisFile(); |
|
266 |
validate(); |
|
267 |
} |
|
268 |
}); |
|
1045
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
269 |
String sisPath = data.getSisPath(); |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
270 |
if (sisPath != null) |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
271 |
sisEdit.setText(sisPath); |
969 | 272 |
sisEdit.setData(UID, "DebugRunProcessDialog.sisEdit"); //$NON-NLS-1$ |
956 | 273 |
|
274 |
sisBrowse = new Button(composite, SWT.NONE); |
|
969 | 275 |
sisBrowse.setText(Messages.getString("DebugRunProcessDialog.BrowseLabel")); //$NON-NLS-1$ |
956 | 276 |
sisBrowse.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); |
277 |
sisBrowse.addSelectionListener(new SelectionAdapter() { |
|
278 |
public void widgetSelected(SelectionEvent evt) { |
|
279 |
FileDialog dialog = new FileDialog(getShell(), SWT.NONE); |
|
280 |
||
969 | 281 |
dialog.setText(Messages.getString("DebugRunProcessDialog.Title")); //$NON-NLS-1$ |
282 |
dialog.setFilterExtensions(new String[] {"*.sis*", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$ |
|
283 |
dialog.setFilterNames(new String[] {Messages.getString("DebugRunProcessDialog.InstallFilterName"), Messages.getString("DebugRunProcessDialog.AllFilterName")}); //$NON-NLS-1$ //$NON-NLS-2$ |
|
956 | 284 |
|
285 |
BrowseDialogUtils.initializeFrom(dialog, sisEdit); |
|
286 |
||
287 |
String result = dialog.open(); |
|
288 |
if (result != null && new File(result).exists()) { |
|
289 |
sisEdit.setText(result); |
|
290 |
updateSisFile(); |
|
291 |
validate(); |
|
292 |
} |
|
293 |
} |
|
294 |
}); |
|
969 | 295 |
sisBrowse.setData(UID, "DebugRunProcessDialog.sisBrowse"); //$NON-NLS-1$ |
956 | 296 |
} |
297 |
} |
|
1045
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
298 |
|
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
299 |
|
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
300 |
private void updateSisFileCombo(ICarbideProjectInfo cpi) { |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
301 |
sisFile.add(Messages.getString("DebugRunProcessDialog.NoneItem")); //$NON-NLS-1$ |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
302 |
|
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
303 |
ICarbideBuildConfiguration config = cpi.getDefaultConfiguration(); |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
304 |
for (ISISBuilderInfo info : config.getSISBuilderInfoList()) { |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
305 |
IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath(); |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
306 |
sisFile.add(sisPath.toOSString()); |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
307 |
} |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
308 |
|
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
309 |
// select the first sis file if any, otherwise select none |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
310 |
if (sisFile.getItemCount() > 1) { |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
311 |
sisFile.select(1); |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
312 |
} else { |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
313 |
sisFile.select(0); |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
314 |
} |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
315 |
updateSisFile(); |
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
316 |
} |
956 | 317 |
|
318 |
||
319 |
/** |
|
320 |
* |
|
321 |
*/ |
|
322 |
protected void updateSisFile() { |
|
323 |
String sisPath; |
|
324 |
if (sisFile != null) { |
|
325 |
sisPath = sisFile.getSelectionIndex() == 0 ? null : sisFile.getText(); //$NON-NLS-1$ |
|
326 |
data.setSisPath(sisPath); |
|
327 |
} else if (sisEdit != null) { |
|
328 |
sisPath = sisEdit.getText(); |
|
329 |
data.setSisPath(sisPath); |
|
330 |
} |
|
331 |
} |
|
332 |
||
333 |
||
334 |
private void updatePackageUI() { |
|
335 |
installPackageUI.setEnabled(data.isInstallPackage()); |
|
336 |
for (Control kid : installPackageUI.getChildren()) |
|
337 |
kid.setEnabled(data.isInstallPackage()); |
|
338 |
} |
|
339 |
||
340 |
||
341 |
public void handleEvent(CProjectDescriptionEvent event) { |
|
342 |
Shell shell = getShell(); |
|
343 |
if (shell == null || shell.isDisposed()) { |
|
344 |
return; |
|
345 |
} |
|
346 |
||
347 |
IProject project = event.getProject() ; |
|
348 |
||
349 |
if (project != data.getProject()) { |
|
350 |
return; |
|
351 |
} |
|
352 |
||
353 |
if (sisFile != null) { |
|
354 |
ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project); |
|
355 |
if (cpi != null) { |
|
356 |
sisFile.removeAll(); |
|
357 |
||
1045
7bd4eb5648d7
bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents:
969
diff
changeset
|
358 |
updateSisFileCombo(cpi); |
956 | 359 |
} |
360 |
} |
|
361 |
} |
|
362 |
||
363 |
protected void initUI() { |
|
1090 | 364 |
List<IPath> exes = data.getLaunchableExes(); |
956 | 365 |
projectExecutableViewer.setInput(exes); |
366 |
IPath exeSelectionPath = data.getExeSelectionPath(); |
|
367 |
if (exeSelectionPath.equals(Path.EMPTY) && !exes.isEmpty()) |
|
368 |
exeSelectionPath = exes.get(0); |
|
1090 | 369 |
if (!Path.EMPTY.equals(exeSelectionPath)) { |
370 |
projectExecutableViewer.setSelection(new StructuredSelection(exeSelectionPath)); |
|
371 |
IPath remotePath = createSuggestedRemotePath(exeSelectionPath); |
|
372 |
remoteProgramEntry.setText(PathUtils.convertPathToWindows(remotePath)); |
|
373 |
} |
|
374 |
||
956 | 375 |
if (data.getExeSelection() == EExeSelection.USE_PROJECT_EXECUTABLE && exeSelectionPath != null) { |
376 |
projectExecutableRadioButton.forceFocus(); |
|
377 |
} |
|
378 |
||
379 |
if (data.getExeSelection() == EExeSelection.USE_REMOTE_EXECUTABLE && exeSelectionPath != null) { |
|
380 |
remoteExecutableRadioButton.forceFocus(); |
|
381 |
} |
|
382 |
||
383 |
if (data.getExeSelection() == EExeSelection.ATTACH_TO_PROCESS) { |
|
384 |
attachToProcessRadioButton.forceFocus(); |
|
385 |
} |
|
386 |
||
387 |
handleProjectExecutableRadioSelected(); |
|
388 |
handleRemoteExecutableRadioSelected(); |
|
389 |
handleAttachToProcessRadioSelected(); |
|
390 |
} |
|
391 |
||
392 |
||
393 |
private IPath createSuggestedRemotePath(IPath exeSelectionPath) { |
|
394 |
String filename = exeSelectionPath.lastSegment(); |
|
969 | 395 |
return PathUtils.createPath("C:/sys/bin").append(filename); //$NON-NLS-1$ |
956 | 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); |
|
969 | 405 |
projectExecutableRadioButton.setText(Messages.getString("DebugRunProcessDialog.LaunchProjectExeLabel")); //$NON-NLS-1$ |
406 |
projectExecutableRadioButton.setData(UID, "radio_project_executable"); //$NON-NLS-1$ |
|
956 | 407 |
|
408 |
projectExecutableViewer = new ComboViewer(radioGroup, SWT.READ_ONLY); |
|
409 |
GridDataFactory.fillDefaults().grab(true, false).applyTo(projectExecutableViewer.getControl()); |
|
969 | 410 |
projectExecutableViewer.getControl().setData(UID, "combo_project_executable"); //$NON-NLS-1$ |
956 | 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) { |
|
425 |
handleProjectExecutableRadioSelected(); |
|
426 |
} |
|
427 |
||
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 |
||
449 |
private void handleProjectExecutableRadioSelected() { |
|
450 |
if (projectExecutableRadioButton.getSelection()) { |
|
451 |
projectExecutableViewer.getControl().setEnabled(true); |
|
452 |
data.setExeSelection(EExeSelection.USE_PROJECT_EXECUTABLE); |
|
453 |
IPath selectedPath = (IPath) ((IStructuredSelection) projectExecutableViewer.getSelection()).getFirstElement(); |
|
454 |
if (selectedPath != null) { |
|
455 |
String symbianPath = PathUtils.convertPathToWindows(selectedPath); |
|
456 |
data.setExeSelectionPath(new Path(symbianPath)); |
|
457 |
} |
|
458 |
validate(); |
|
459 |
} else { |
|
460 |
projectExecutableViewer.getControl().setEnabled(false); |
|
461 |
// another button becomes active and sets the new launch process |
|
462 |
} |
|
463 |
} |
|
464 |
||
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); |
|
969 | 472 |
remoteExecutableRadioButton.setText(Messages.getString("DebugRunProcessDialog.LaunchRemoteProgLabel")); //$NON-NLS-1$ |
956 | 473 |
|
969 | 474 |
remoteExecutableRadioButton.setData(UID, "radio_remote_program"); //$NON-NLS-1$ |
956 | 475 |
|
476 |
remoteProgramEntry = new Text(radioGroup, SWT.BORDER); |
|
477 |
GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteProgramEntry); |
|
478 |
||
969 | 479 |
remoteProgramEntry.setData(UID, "text_remote_program"); //$NON-NLS-1$ |
956 | 480 |
|
481 |
remoteExecutableRadioButton.addSelectionListener(new SelectionAdapter() { |
|
482 |
@Override |
|
483 |
public void widgetSelected(SelectionEvent e) { |
|
484 |
handleRemoteExecutableRadioSelected(); |
|
485 |
} |
|
486 |
||
487 |
}); |
|
488 |
||
489 |
remoteProgramEntry.addModifyListener(new ModifyListener() { |
|
490 |
public void modifyText(ModifyEvent e) { |
|
491 |
data.setExeSelectionPath(new Path(remoteProgramEntry.getText().trim())); |
|
492 |
validate(); |
|
493 |
} |
|
494 |
}); |
|
495 |
} |
|
496 |
||
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 |
||
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); |
|
969 | 517 |
attachToProcessRadioButton.setText(Messages.getString("DebugRunProcessDialog.AttachLabel")); //$NON-NLS-1$ |
956 | 518 |
|
969 | 519 |
attachToProcessRadioButton.setData(UID, "radio_attach_to_process"); //$NON-NLS-1$ |
956 | 520 |
|
521 |
Label label = new Label(radioGroup, SWT.WRAP); |
|
522 |
GridDataFactory.fillDefaults().grab(false, false).align(SWT.LEFT, SWT.CENTER).applyTo(label); |
|
523 |
||
969 | 524 |
label.setText(Messages.getString("DebugRunProcessDialog.AttachAddlMsg")); //$NON-NLS-1$ |
956 | 525 |
|
526 |
attachToProcessRadioButton.addSelectionListener(new SelectionAdapter() { |
|
527 |
@Override |
|
528 |
public void widgetSelected(SelectionEvent e) { |
|
529 |
handleAttachToProcessRadioSelected(); |
|
530 |
} |
|
531 |
||
532 |
}); |
|
533 |
||
534 |
} |
|
535 |
||
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 |
||
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()) { |
|
969 | 555 |
status = error(Messages.getString("DebugRunProcessDialog.NoExesError")); //$NON-NLS-1$ |
956 | 556 |
} |
557 |
break; |
|
558 |
case USE_REMOTE_EXECUTABLE: |
|
559 |
if (exePath.isEmpty()) { |
|
969 | 560 |
status = error(Messages.getString("DebugRunProcessDialog.EnterPathError")); //$NON-NLS-1$ |
956 | 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 == ':') { |
|
969 | 569 |
status = error(Messages.getString("DebugRunProcessDialog.AbsolutePathError")); //$NON-NLS-1$ |
956 | 570 |
} else if (exePath.getFileExtension() == null) { |
969 | 571 |
status = warning(Messages.getString("DebugRunProcessDialog.FilePathError")); //$NON-NLS-1$ |
956 | 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()) { |
|
969 | 588 |
status = error(Messages.getString("DebugRunProcessDialog.SISFileExistError"), text); //$NON-NLS-1$ |
956 | 589 |
} |
590 |
} |
|
591 |
} |
|
592 |
} |
|
593 |
||
594 |
updateStatus(status); |
|
595 |
} |
|
596 |
} |
|
597 |