author | dadubrow |
Mon, 01 Mar 2010 14:30:07 -0600 | |
changeset 1045 | 7bd4eb5648d7 |
parent 969 | b0dd389735fb |
child 1090 | 02cf64aef519 |
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() { |
|
364 |
List<IPath> exes = data.getExes(); |
|
365 |
projectExecutableViewer.setInput(exes); |
|
366 |
IPath exeSelectionPath = data.getExeSelectionPath(); |
|
367 |
if (exeSelectionPath.equals(Path.EMPTY) && !exes.isEmpty()) |
|
368 |
exeSelectionPath = exes.get(0); |
|
369 |
projectExecutableViewer.setSelection(new StructuredSelection(exeSelectionPath)); |
|
370 |
IPath remotePath = createSuggestedRemotePath(exeSelectionPath); |
|
371 |
remoteProgramEntry.setText(PathUtils.convertPathToWindows(remotePath)); |
|
372 |
||
373 |
if (data.getExeSelection() == EExeSelection.USE_PROJECT_EXECUTABLE && exeSelectionPath != null) { |
|
374 |
projectExecutableRadioButton.forceFocus(); |
|
375 |
} |
|
376 |
||
377 |
if (data.getExeSelection() == EExeSelection.USE_REMOTE_EXECUTABLE && exeSelectionPath != null) { |
|
378 |
remoteExecutableRadioButton.forceFocus(); |
|
379 |
} |
|
380 |
||
381 |
if (data.getExeSelection() == EExeSelection.ATTACH_TO_PROCESS) { |
|
382 |
attachToProcessRadioButton.forceFocus(); |
|
383 |
} |
|
384 |
||
385 |
handleProjectExecutableRadioSelected(); |
|
386 |
handleRemoteExecutableRadioSelected(); |
|
387 |
handleAttachToProcessRadioSelected(); |
|
388 |
} |
|
389 |
||
390 |
||
391 |
private IPath createSuggestedRemotePath(IPath exeSelectionPath) { |
|
392 |
String filename = exeSelectionPath.lastSegment(); |
|
969 | 393 |
return PathUtils.createPath("C:/sys/bin").append(filename); //$NON-NLS-1$ |
956 | 394 |
} |
395 |
||
396 |
/** |
|
397 |
* Allow selecting an executable detected to be built by the program. |
|
398 |
* @param radioGroup |
|
399 |
*/ |
|
400 |
private void createProjectExecutableRadioButton(Composite radioGroup) { |
|
401 |
projectExecutableRadioButton = new Button(radioGroup, SWT.RADIO); |
|
402 |
GridDataFactory.fillDefaults().grab(false, false).applyTo(projectExecutableRadioButton); |
|
969 | 403 |
projectExecutableRadioButton.setText(Messages.getString("DebugRunProcessDialog.LaunchProjectExeLabel")); //$NON-NLS-1$ |
404 |
projectExecutableRadioButton.setData(UID, "radio_project_executable"); //$NON-NLS-1$ |
|
956 | 405 |
|
406 |
projectExecutableViewer = new ComboViewer(radioGroup, SWT.READ_ONLY); |
|
407 |
GridDataFactory.fillDefaults().grab(true, false).applyTo(projectExecutableViewer.getControl()); |
|
969 | 408 |
projectExecutableViewer.getControl().setData(UID, "combo_project_executable"); //$NON-NLS-1$ |
956 | 409 |
|
410 |
projectExecutableViewer.setContentProvider(new ArrayContentProvider()); |
|
411 |
projectExecutableViewer.setLabelProvider(new LabelProvider() { |
|
412 |
@Override |
|
413 |
public String getText(Object element) { |
|
414 |
if (element instanceof IPath) |
|
415 |
return ((IPath) element).lastSegment(); |
|
416 |
return super.getText(element); |
|
417 |
} |
|
418 |
}); |
|
419 |
||
420 |
projectExecutableRadioButton.addSelectionListener(new SelectionAdapter() { |
|
421 |
@Override |
|
422 |
public void widgetSelected(SelectionEvent e) { |
|
423 |
handleProjectExecutableRadioSelected(); |
|
424 |
} |
|
425 |
||
426 |
}); |
|
427 |
||
428 |
projectExecutableViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
|
429 |
||
430 |
public void selectionChanged(SelectionChangedEvent event) { |
|
431 |
Object sel = ((IStructuredSelection) event.getSelection()).getFirstElement(); |
|
432 |
if (sel instanceof IPath) { |
|
433 |
data.setExeSelectionPath((IPath) sel); |
|
434 |
||
435 |
// track the default remote program from the executable, for easy editing |
|
436 |
if (remoteProgramEntry != null) { |
|
437 |
IPath exeSelectionPath = createSuggestedRemotePath(data.getExeSelectionPath()); |
|
438 |
remoteProgramEntry.setText(PathUtils.convertPathToWindows(exeSelectionPath)); |
|
439 |
} |
|
440 |
||
441 |
validate(); |
|
442 |
} |
|
443 |
} |
|
444 |
}); |
|
445 |
} |
|
446 |
||
447 |
private void handleProjectExecutableRadioSelected() { |
|
448 |
if (projectExecutableRadioButton.getSelection()) { |
|
449 |
projectExecutableViewer.getControl().setEnabled(true); |
|
450 |
data.setExeSelection(EExeSelection.USE_PROJECT_EXECUTABLE); |
|
451 |
IPath selectedPath = (IPath) ((IStructuredSelection) projectExecutableViewer.getSelection()).getFirstElement(); |
|
452 |
if (selectedPath != null) { |
|
453 |
String symbianPath = PathUtils.convertPathToWindows(selectedPath); |
|
454 |
data.setExeSelectionPath(new Path(symbianPath)); |
|
455 |
} |
|
456 |
validate(); |
|
457 |
} else { |
|
458 |
projectExecutableViewer.getControl().setEnabled(false); |
|
459 |
// another button becomes active and sets the new launch process |
|
460 |
} |
|
461 |
} |
|
462 |
||
463 |
/** |
|
464 |
* Allow user to enter an executable path. |
|
465 |
* @param radioGroup |
|
466 |
*/ |
|
467 |
private void createRemoteExecutableRadioButton(Composite radioGroup) { |
|
468 |
remoteExecutableRadioButton = new Button(radioGroup, SWT.RADIO); |
|
469 |
GridDataFactory.fillDefaults().grab(false, false).applyTo(remoteExecutableRadioButton); |
|
969 | 470 |
remoteExecutableRadioButton.setText(Messages.getString("DebugRunProcessDialog.LaunchRemoteProgLabel")); //$NON-NLS-1$ |
956 | 471 |
|
969 | 472 |
remoteExecutableRadioButton.setData(UID, "radio_remote_program"); //$NON-NLS-1$ |
956 | 473 |
|
474 |
remoteProgramEntry = new Text(radioGroup, SWT.BORDER); |
|
475 |
GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteProgramEntry); |
|
476 |
||
969 | 477 |
remoteProgramEntry.setData(UID, "text_remote_program"); //$NON-NLS-1$ |
956 | 478 |
|
479 |
remoteExecutableRadioButton.addSelectionListener(new SelectionAdapter() { |
|
480 |
@Override |
|
481 |
public void widgetSelected(SelectionEvent e) { |
|
482 |
handleRemoteExecutableRadioSelected(); |
|
483 |
} |
|
484 |
||
485 |
}); |
|
486 |
||
487 |
remoteProgramEntry.addModifyListener(new ModifyListener() { |
|
488 |
public void modifyText(ModifyEvent e) { |
|
489 |
data.setExeSelectionPath(new Path(remoteProgramEntry.getText().trim())); |
|
490 |
validate(); |
|
491 |
} |
|
492 |
}); |
|
493 |
} |
|
494 |
||
495 |
private void handleRemoteExecutableRadioSelected() { |
|
496 |
if (remoteExecutableRadioButton.getSelection()) { |
|
497 |
remoteProgramEntry.setEnabled(true); |
|
498 |
data.setExeSelection(EExeSelection.USE_REMOTE_EXECUTABLE); |
|
499 |
String symbianPath = PathUtils.convertPathToWindows(remoteProgramEntry.getText()); |
|
500 |
data.setExeSelectionPath(new Path(symbianPath)); |
|
501 |
validate(); |
|
502 |
} else { |
|
503 |
remoteProgramEntry.setEnabled(false); |
|
504 |
// another button becomes active and sets the new launch process |
|
505 |
} |
|
506 |
} |
|
507 |
||
508 |
/** |
|
509 |
* Allow user to attach to a process. |
|
510 |
* @param radioGroup |
|
511 |
*/ |
|
512 |
private void createAttachToProcessRadioButton(Composite radioGroup) { |
|
513 |
attachToProcessRadioButton = new Button(radioGroup, SWT.RADIO); |
|
514 |
GridDataFactory.fillDefaults().grab(false, false).applyTo(attachToProcessRadioButton); |
|
969 | 515 |
attachToProcessRadioButton.setText(Messages.getString("DebugRunProcessDialog.AttachLabel")); //$NON-NLS-1$ |
956 | 516 |
|
969 | 517 |
attachToProcessRadioButton.setData(UID, "radio_attach_to_process"); //$NON-NLS-1$ |
956 | 518 |
|
519 |
Label label = new Label(radioGroup, SWT.WRAP); |
|
520 |
GridDataFactory.fillDefaults().grab(false, false).align(SWT.LEFT, SWT.CENTER).applyTo(label); |
|
521 |
||
969 | 522 |
label.setText(Messages.getString("DebugRunProcessDialog.AttachAddlMsg")); //$NON-NLS-1$ |
956 | 523 |
|
524 |
attachToProcessRadioButton.addSelectionListener(new SelectionAdapter() { |
|
525 |
@Override |
|
526 |
public void widgetSelected(SelectionEvent e) { |
|
527 |
handleAttachToProcessRadioSelected(); |
|
528 |
} |
|
529 |
||
530 |
}); |
|
531 |
||
532 |
} |
|
533 |
||
534 |
private void handleAttachToProcessRadioSelected() { |
|
535 |
if (attachToProcessRadioButton.getSelection()) { |
|
536 |
data.setExeSelection(EExeSelection.ATTACH_TO_PROCESS); |
|
537 |
data.setExeSelectionPath(null); |
|
538 |
validate(); |
|
539 |
} else { |
|
540 |
// another button becomes active and sets the new launch process |
|
541 |
} |
|
542 |
} |
|
543 |
||
544 |
@Override |
|
545 |
protected void validate() { |
|
546 |
IStatus status = Status.OK_STATUS; |
|
547 |
||
548 |
// check launch method |
|
549 |
IPath exePath = data.getExeSelectionPath(); |
|
550 |
switch (data.getExeSelection()) { |
|
551 |
case USE_PROJECT_EXECUTABLE: |
|
552 |
if (exePath.isEmpty()) { |
|
969 | 553 |
status = error(Messages.getString("DebugRunProcessDialog.NoExesError")); //$NON-NLS-1$ |
956 | 554 |
} |
555 |
break; |
|
556 |
case USE_REMOTE_EXECUTABLE: |
|
557 |
if (exePath.isEmpty()) { |
|
969 | 558 |
status = error(Messages.getString("DebugRunProcessDialog.EnterPathError")); //$NON-NLS-1$ |
956 | 559 |
} else { |
560 |
String exePathString = exePath.toString(); |
|
561 |
char drive = exePathString.charAt(0); |
|
562 |
char colon = exePathString.length() < 2 ? 0x0 : exePathString.charAt(1); |
|
563 |
char root = exePathString.length() < 3 ? 0x0 : exePathString.charAt(2); |
|
564 |
char lastChar = exePathString.charAt(exePathString.length() - 1); |
|
565 |
if (!Character.isLetter(drive) || colon != ':' || (root != '\\' && root != '/') || |
|
566 |
lastChar == '\\' || lastChar == '/' || lastChar == ':') { |
|
969 | 567 |
status = error(Messages.getString("DebugRunProcessDialog.AbsolutePathError")); //$NON-NLS-1$ |
956 | 568 |
} else if (exePath.getFileExtension() == null) { |
969 | 569 |
status = warning(Messages.getString("DebugRunProcessDialog.FilePathError")); //$NON-NLS-1$ |
956 | 570 |
} |
571 |
} |
|
572 |
break; |
|
573 |
case ATTACH_TO_PROCESS: |
|
574 |
break; |
|
575 |
} |
|
576 |
||
577 |
// check SIS selection |
|
578 |
if (data.isInstallPackage()) { |
|
579 |
if (sisEdit != null) { |
|
580 |
String text = sisEdit.getText().trim(); |
|
581 |
if (text.length() > 0) { |
|
582 |
// empty is allowed, but if they specify something, make sure |
|
583 |
// it exists |
|
584 |
File file = new File(text); |
|
585 |
if (!file.exists()) { |
|
969 | 586 |
status = error(Messages.getString("DebugRunProcessDialog.SISFileExistError"), text); //$NON-NLS-1$ |
956 | 587 |
} |
588 |
} |
|
589 |
} |
|
590 |
} |
|
591 |
||
592 |
updateStatus(status); |
|
593 |
} |
|
594 |
} |
|
595 |