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.text.MessageFormat;
|
|
21 |
import java.util.ArrayList;
|
|
22 |
|
|
23 |
import org.eclipse.core.runtime.IStatus;
|
|
24 |
import org.eclipse.core.runtime.Status;
|
|
25 |
import org.eclipse.jface.layout.GridDataFactory;
|
|
26 |
import org.eclipse.jface.layout.GridLayoutFactory;
|
|
27 |
import org.eclipse.jface.wizard.WizardPage;
|
|
28 |
import org.eclipse.swt.SWT;
|
|
29 |
import org.eclipse.swt.widgets.Composite;
|
993
|
30 |
import org.eclipse.swt.widgets.Control;
|
956
|
31 |
|
|
32 |
import com.nokia.cdt.internal.debug.launch.LaunchPlugin;
|
|
33 |
import com.nokia.cdt.internal.debug.launch.newwizard.IWizardSection.ISectionChangeListener;
|
1013
|
34 |
import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
|
956
|
35 |
|
|
36 |
/**
|
|
37 |
* This page presents three sections:
|
|
38 |
* <p>
|
|
39 |
* Connection to use: container for the Remote Connection selection UI, plus a label
|
|
40 |
* explaining how to handle the case of no connections defined.
|
|
41 |
* <p>
|
|
42 |
* Debug process: section explaining how the launch will happen, with a combo
|
|
43 |
* allowing selecting different process to launch, and a button allowing more
|
|
44 |
* in-depth configuration.
|
|
45 |
* <p>
|
|
46 |
* Build before debug: section with the build-before-debug preference for this
|
|
47 |
* launch configuration.
|
|
48 |
*/
|
|
49 |
public class UnifiedLaunchOptionsPage extends WizardPage implements ISectionChangeListener {
|
|
50 |
|
|
51 |
private final LaunchWizardData data;
|
|
52 |
private ArrayList<IWizardSection> sections;
|
|
53 |
|
|
54 |
|
|
55 |
/**
|
|
56 |
* @param mmps
|
|
57 |
* @param exes
|
|
58 |
* @param defaultExecutable
|
|
59 |
* @param project
|
|
60 |
* @param configurationName
|
|
61 |
*/
|
|
62 |
public UnifiedLaunchOptionsPage(LaunchWizardData data) {
|
969
|
63 |
super(Messages.getString("UnifiedLaunchOptionsPage.Title")); //$NON-NLS-1$
|
956
|
64 |
|
969
|
65 |
setDescription(Messages.getString("UnifiedLaunchOptionsPage.Desc")); //$NON-NLS-1$
|
956
|
66 |
|
|
67 |
this.data = data;
|
|
68 |
this.sections = new ArrayList<IWizardSection>();
|
|
69 |
|
|
70 |
|
|
71 |
IWizardSection section;
|
|
72 |
|
|
73 |
section = new ConnectToDeviceSection(data, this);
|
|
74 |
sections.add(section);
|
|
75 |
|
960
|
76 |
section = new DebugRunProcessSection(data, this);
|
956
|
77 |
sections.add(section);
|
|
78 |
|
960
|
79 |
section = new OtherSettingsSection(data, this);
|
956
|
80 |
sections.add(section);
|
|
81 |
}
|
|
82 |
|
|
83 |
/* (non-Javadoc)
|
|
84 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
|
85 |
*/
|
|
86 |
public void createControl(Composite parent) {
|
|
87 |
Composite composite = new Composite(parent, SWT.NONE);
|
|
88 |
|
|
89 |
GridLayoutFactory.fillDefaults().applyTo(composite);
|
|
90 |
|
|
91 |
setPageComplete(false);
|
|
92 |
|
|
93 |
for (IWizardSection section : sections) {
|
|
94 |
section.createControl(composite);
|
|
95 |
section.setChangeListener(this);
|
|
96 |
GridDataFactory.fillDefaults().grab(true, true).applyTo(section.getControl());
|
|
97 |
}
|
|
98 |
|
1013
|
99 |
WorkbenchUtils.setHelpContextId(composite, LaunchWizardHelpIds.WIZARD_DIALOG_LAUNCH_OPTIONS_PAGE);
|
956
|
100 |
|
|
101 |
setControl(composite);
|
|
102 |
}
|
|
103 |
|
|
104 |
/**
|
|
105 |
* @return
|
|
106 |
*/
|
|
107 |
public void validatePage() {
|
|
108 |
setMessage(null, INFORMATION);
|
|
109 |
setErrorMessage(null);
|
|
110 |
setPageComplete(true);
|
|
111 |
|
|
112 |
IStatus pageStatus = null;
|
|
113 |
|
|
114 |
// validate the subsections
|
|
115 |
StringBuilder builder = new StringBuilder();
|
|
116 |
int severity = IStatus.OK;
|
|
117 |
for (IWizardSection section : sections) {
|
|
118 |
IStatus status = section.getStatus();
|
|
119 |
if (status.isOK())
|
|
120 |
continue;
|
|
121 |
if (builder.length() > 0)
|
969
|
122 |
builder.append("\n"); //$NON-NLS-1$
|
956
|
123 |
|
969
|
124 |
builder.append(MessageFormat.format("{0}: {1}", //$NON-NLS-1$
|
956
|
125 |
section.getSectionName(),
|
|
126 |
status.getMessage()));
|
|
127 |
severity = Math.max(severity, status.getSeverity());
|
|
128 |
}
|
|
129 |
if (severity != 0 || builder.length() > 0) {
|
|
130 |
// error from one or more sections
|
|
131 |
pageStatus = new Status(severity, LaunchPlugin.PLUGIN_ID, builder.toString());
|
|
132 |
} else {
|
|
133 |
// sections are good; validate the page as a whole
|
|
134 |
pageStatus = data.validate();
|
|
135 |
}
|
|
136 |
|
969
|
137 |
setTitle(Messages.getString("UnifiedLaunchOptionsPage.TitleText")); //$NON-NLS-1$
|
956
|
138 |
|
|
139 |
if (pageStatus != null && !pageStatus.isOK()) {
|
|
140 |
setMessage(pageStatus.getMessage(), severityToMsgType(pageStatus.getSeverity()));
|
|
141 |
setPageComplete(false);
|
|
142 |
}
|
|
143 |
}
|
|
144 |
|
|
145 |
private int severityToMsgType(int severity) {
|
|
146 |
switch (severity) {
|
|
147 |
case IStatus.OK:
|
|
148 |
case IStatus.INFO:
|
|
149 |
return INFORMATION;
|
|
150 |
case IStatus.WARNING:
|
|
151 |
return WARNING;
|
|
152 |
case IStatus.ERROR:
|
|
153 |
default:
|
|
154 |
return ERROR;
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
/*
|
|
159 |
private String getSeverityTag(int severity) {
|
|
160 |
if (severity == IStatus.OK || severity == IStatus.INFO || severity == IStatus.CANCEL)
|
|
161 |
return "";
|
|
162 |
if (severity == IStatus.WARNING)
|
|
163 |
return "warning";
|
|
164 |
return "error";
|
|
165 |
}
|
|
166 |
*/
|
|
167 |
|
|
168 |
public void initializeSettings() {
|
|
169 |
for (IWizardSection section : sections) {
|
|
170 |
section.initializeSettings();
|
|
171 |
}
|
|
172 |
validatePage();
|
|
173 |
}
|
|
174 |
|
|
175 |
/* (non-Javadoc)
|
|
176 |
* @see com.nokia.cdt.internal.debug.launch.wizard2.IWizardSection.ISectionChangeListener#changed()
|
|
177 |
*/
|
|
178 |
public void changed() {
|
|
179 |
validatePage();
|
993
|
180 |
Control control = getControl();
|
|
181 |
if (control != null && !control.isDisposed())
|
|
182 |
getWizard().getContainer().getShell().pack();
|
|
183 |
|
956
|
184 |
}
|
|
185 |
}
|