author | Ed Swartz <ed.swartz@nokia.com> |
Fri, 23 Apr 2010 08:25:11 -0500 | |
changeset 1265 | f90f47d3882f |
parent 1067 | 856622c7b203 |
child 2160 | 3a82092877ea |
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 |
||
1067
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
20 |
import java.io.File; |
956 | 21 |
import java.text.MessageFormat; |
22 |
import java.util.ArrayList; |
|
23 |
||
24 |
import org.eclipse.core.runtime.IStatus; |
|
25 |
import org.eclipse.core.runtime.Status; |
|
26 |
import org.eclipse.jface.layout.GridDataFactory; |
|
27 |
import org.eclipse.jface.layout.GridLayoutFactory; |
|
28 |
import org.eclipse.jface.wizard.WizardPage; |
|
29 |
import org.eclipse.swt.SWT; |
|
30 |
import org.eclipse.swt.widgets.Composite; |
|
993 | 31 |
import org.eclipse.swt.widgets.Control; |
956 | 32 |
|
33 |
import com.nokia.cdt.internal.debug.launch.LaunchPlugin; |
|
34 |
import com.nokia.cdt.internal.debug.launch.newwizard.IWizardSection.ISectionChangeListener; |
|
1067
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
35 |
import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EExeSelection; |
1013 | 36 |
import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils; |
956 | 37 |
|
38 |
/** |
|
39 |
* This page presents three sections: |
|
40 |
* <p> |
|
41 |
* Connection to use: container for the Remote Connection selection UI, plus a label |
|
42 |
* explaining how to handle the case of no connections defined. |
|
43 |
* <p> |
|
44 |
* Debug process: section explaining how the launch will happen, with a combo |
|
45 |
* allowing selecting different process to launch, and a button allowing more |
|
46 |
* in-depth configuration. |
|
47 |
* <p> |
|
1265
f90f47d3882f
PlatSim-related launch wizard changes: (1) Remember last connection created and offer this by default in the Select Connection dialog; (2) Immediately open New Connection dialog if debugging and no connections exist; (3) Split out SelectConnectionDialog; (4) Fix some wording in Select Connection dialog since this is not always an error situation.
Ed Swartz <ed.swartz@nokia.com>
parents:
1067
diff
changeset
|
48 |
* Other settings: section with (currently only) the build-before-debug preference for this |
956 | 49 |
* launch configuration. |
1265
f90f47d3882f
PlatSim-related launch wizard changes: (1) Remember last connection created and offer this by default in the Select Connection dialog; (2) Immediately open New Connection dialog if debugging and no connections exist; (3) Split out SelectConnectionDialog; (4) Fix some wording in Select Connection dialog since this is not always an error situation.
Ed Swartz <ed.swartz@nokia.com>
parents:
1067
diff
changeset
|
50 |
* <p> |
f90f47d3882f
PlatSim-related launch wizard changes: (1) Remember last connection created and offer this by default in the Select Connection dialog; (2) Immediately open New Connection dialog if debugging and no connections exist; (3) Split out SelectConnectionDialog; (4) Fix some wording in Select Connection dialog since this is not always an error situation.
Ed Swartz <ed.swartz@nokia.com>
parents:
1067
diff
changeset
|
51 |
* Each section is validated separately and editable with its own dialog. Changes in |
f90f47d3882f
PlatSim-related launch wizard changes: (1) Remember last connection created and offer this by default in the Select Connection dialog; (2) Immediately open New Connection dialog if debugging and no connections exist; (3) Split out SelectConnectionDialog; (4) Fix some wording in Select Connection dialog since this is not always an error situation.
Ed Swartz <ed.swartz@nokia.com>
parents:
1067
diff
changeset
|
52 |
* the dialog are not applied until the dialog is accepted. |
956 | 53 |
*/ |
54 |
public class UnifiedLaunchOptionsPage extends WizardPage implements ISectionChangeListener { |
|
55 |
||
56 |
private final LaunchWizardData data; |
|
57 |
private ArrayList<IWizardSection> sections; |
|
58 |
||
59 |
||
60 |
/** |
|
61 |
* @param mmps |
|
62 |
* @param exes |
|
63 |
* @param defaultExecutable |
|
64 |
* @param project |
|
65 |
* @param configurationName |
|
66 |
*/ |
|
67 |
public UnifiedLaunchOptionsPage(LaunchWizardData data) { |
|
969 | 68 |
super(Messages.getString("UnifiedLaunchOptionsPage.Title")); //$NON-NLS-1$ |
956 | 69 |
|
969 | 70 |
setDescription(Messages.getString("UnifiedLaunchOptionsPage.Desc")); //$NON-NLS-1$ |
956 | 71 |
|
72 |
this.data = data; |
|
73 |
this.sections = new ArrayList<IWizardSection>(); |
|
74 |
||
75 |
||
76 |
IWizardSection section; |
|
77 |
||
78 |
section = new ConnectToDeviceSection(data, this); |
|
79 |
sections.add(section); |
|
80 |
||
960 | 81 |
section = new DebugRunProcessSection(data, this); |
956 | 82 |
sections.add(section); |
83 |
||
960 | 84 |
section = new OtherSettingsSection(data, this); |
956 | 85 |
sections.add(section); |
86 |
} |
|
87 |
||
88 |
/* (non-Javadoc) |
|
89 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |
|
90 |
*/ |
|
91 |
public void createControl(Composite parent) { |
|
92 |
Composite composite = new Composite(parent, SWT.NONE); |
|
93 |
||
94 |
GridLayoutFactory.fillDefaults().applyTo(composite); |
|
95 |
||
96 |
setPageComplete(false); |
|
97 |
||
98 |
for (IWizardSection section : sections) { |
|
99 |
section.createControl(composite); |
|
100 |
section.setChangeListener(this); |
|
101 |
GridDataFactory.fillDefaults().grab(true, true).applyTo(section.getControl()); |
|
102 |
} |
|
103 |
||
1013 | 104 |
WorkbenchUtils.setHelpContextId(composite, LaunchWizardHelpIds.WIZARD_DIALOG_LAUNCH_OPTIONS_PAGE); |
956 | 105 |
|
106 |
setControl(composite); |
|
107 |
} |
|
108 |
||
109 |
/** |
|
110 |
* @return |
|
111 |
*/ |
|
112 |
public void validatePage() { |
|
113 |
setMessage(null, INFORMATION); |
|
114 |
setErrorMessage(null); |
|
115 |
setPageComplete(true); |
|
116 |
||
117 |
IStatus pageStatus = null; |
|
118 |
||
119 |
// validate the subsections |
|
120 |
StringBuilder builder = new StringBuilder(); |
|
121 |
int severity = IStatus.OK; |
|
122 |
for (IWizardSection section : sections) { |
|
123 |
IStatus status = section.getStatus(); |
|
124 |
if (status.isOK()) |
|
125 |
continue; |
|
126 |
if (builder.length() > 0) |
|
969 | 127 |
builder.append("\n"); //$NON-NLS-1$ |
956 | 128 |
|
969 | 129 |
builder.append(MessageFormat.format("{0}: {1}", //$NON-NLS-1$ |
956 | 130 |
section.getSectionName(), |
131 |
status.getMessage())); |
|
132 |
severity = Math.max(severity, status.getSeverity()); |
|
133 |
} |
|
1067
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
134 |
if (severity == IStatus.OK) { |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
135 |
IStatus status = getStatus(); |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
136 |
if (!status.isOK()) { |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
137 |
builder.append(status.getMessage()); |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
138 |
severity = status.getSeverity(); |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
139 |
} |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
140 |
} |
956 | 141 |
if (severity != 0 || builder.length() > 0) { |
142 |
// error from one or more sections |
|
143 |
pageStatus = new Status(severity, LaunchPlugin.PLUGIN_ID, builder.toString()); |
|
144 |
} else { |
|
145 |
// sections are good; validate the page as a whole |
|
146 |
pageStatus = data.validate(); |
|
147 |
} |
|
148 |
||
969 | 149 |
setTitle(Messages.getString("UnifiedLaunchOptionsPage.TitleText")); //$NON-NLS-1$ |
956 | 150 |
|
151 |
if (pageStatus != null && !pageStatus.isOK()) { |
|
152 |
setMessage(pageStatus.getMessage(), severityToMsgType(pageStatus.getSeverity())); |
|
1067
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
153 |
setPageComplete(pageStatus.getSeverity() < IStatus.ERROR); |
956 | 154 |
} |
155 |
} |
|
156 |
||
157 |
private int severityToMsgType(int severity) { |
|
158 |
switch (severity) { |
|
159 |
case IStatus.OK: |
|
160 |
case IStatus.INFO: |
|
161 |
return INFORMATION; |
|
162 |
case IStatus.WARNING: |
|
163 |
return WARNING; |
|
164 |
case IStatus.ERROR: |
|
165 |
default: |
|
166 |
return ERROR; |
|
167 |
} |
|
168 |
} |
|
169 |
||
1067
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
170 |
protected IStatus getStatus() { |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
171 |
return checkBuildProducts(); |
956 | 172 |
} |
1067
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
173 |
|
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
174 |
private IStatus checkBuildProducts() { |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
175 |
if (!data.isCurrentBuildBeforeLaunch()) { |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
176 |
// check sis files |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
177 |
String sisPath = data.getSisPath(); |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
178 |
if (data.isInstallPackage() && |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
179 |
sisPath != null && !new File(sisPath).exists()) { |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
180 |
return new Status(IStatus.WARNING, LaunchPlugin.PLUGIN_ID, |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
181 |
Messages.getString("UnifiedLaunchOptionsPage.SISFileMissingWarning")); //$NON-NLS-1$ |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
182 |
} |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
183 |
// check launch file |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
184 |
if (data.getExeSelection().equals(EExeSelection.USE_PROJECT_EXECUTABLE) && |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
185 |
!data.getExePath().toFile().exists()) { |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
186 |
return new Status(IStatus.WARNING, LaunchPlugin.PLUGIN_ID, |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
187 |
Messages.getString("UnifiedLaunchOptionsPage.ExeFileMissingWarning")); //$NON-NLS-1$ |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
188 |
|
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
189 |
} |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
190 |
} |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
191 |
|
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
192 |
return Status.OK_STATUS; |
856622c7b203
10809 - generating warning for missing sis file or missing exe
dadubrow
parents:
1013
diff
changeset
|
193 |
} |
956 | 194 |
|
195 |
public void initializeSettings() { |
|
196 |
for (IWizardSection section : sections) { |
|
197 |
section.initializeSettings(); |
|
198 |
} |
|
199 |
validatePage(); |
|
200 |
} |
|
201 |
||
202 |
/* (non-Javadoc) |
|
203 |
* @see com.nokia.cdt.internal.debug.launch.wizard2.IWizardSection.ISectionChangeListener#changed() |
|
204 |
*/ |
|
205 |
public void changed() { |
|
206 |
validatePage(); |
|
993 | 207 |
Control control = getControl(); |
208 |
if (control != null && !control.isDisposed()) |
|
209 |
getWizard().getContainer().getShell().pack(); |
|
210 |
||
956 | 211 |
} |
212 |
} |