1 /* |
|
2 * Copyright (c) 2009 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 package com.nokia.cdt.internal.debug.launch.wizard; |
|
18 |
|
19 import java.io.File; |
|
20 import java.text.MessageFormat; |
|
21 |
|
22 import org.eclipse.cdt.utils.ui.controls.ControlFactory; |
|
23 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
|
24 import org.eclipse.jface.dialogs.Dialog; |
|
25 import org.eclipse.jface.wizard.WizardPage; |
|
26 import org.eclipse.swt.SWT; |
|
27 import org.eclipse.swt.events.SelectionAdapter; |
|
28 import org.eclipse.swt.events.SelectionEvent; |
|
29 import org.eclipse.swt.layout.GridData; |
|
30 import org.eclipse.swt.layout.GridLayout; |
|
31 import org.eclipse.swt.widgets.Button; |
|
32 import org.eclipse.swt.widgets.Combo; |
|
33 import org.eclipse.swt.widgets.Composite; |
|
34 import org.eclipse.swt.widgets.FileDialog; |
|
35 import org.eclipse.swt.widgets.Label; |
|
36 import org.eclipse.swt.widgets.Text; |
|
37 import org.eclipse.ui.PlatformUI; |
|
38 |
|
39 import com.nokia.cdt.debug.cw.symbian.SettingsData; |
|
40 import com.nokia.cpp.internal.api.utils.core.Check; |
|
41 |
|
42 import cwdbg.PreferenceConstants; |
|
43 |
|
44 public class SophiaWizardPage extends WizardPage { |
|
45 |
|
46 private boolean isDisposed = false; |
|
47 |
|
48 private Label sophiaSTIDLLLabel; |
|
49 private Text sophiaSTIDLLPath; |
|
50 private Button sophiaSTIDLLBrowse; |
|
51 private String sophiaSTIDLL; |
|
52 |
|
53 private Label targetInitFileLabel; |
|
54 private Text targetInitFilePath; |
|
55 private Button targetInitFileBrowse; |
|
56 private String targetInitFile; |
|
57 |
|
58 private Combo processorsList; |
|
59 private int selectedProcIndex; |
|
60 |
|
61 private final ISummaryTextItemContainer summaryTextItemContainer; |
|
62 |
|
63 public SophiaWizardPage(ISummaryTextItemContainer summaryTextItemContainer) { |
|
64 super(Messages.getString("SophiaWizardPage.0")); //$NON-NLS-1$ |
|
65 Check.checkArg(summaryTextItemContainer); |
|
66 this.summaryTextItemContainer = summaryTextItemContainer; |
|
67 setPageComplete(false); |
|
68 setTitle(Messages.getString("SophiaWizardPage.0")); //$NON-NLS-1$ |
|
69 setDescription(Messages.getString("SophiaWizardPage.1")); //$NON-NLS-1$ |
|
70 } |
|
71 public void dispose() { |
|
72 isDisposed = true; |
|
73 sophiaSTIDLL = sophiaSTIDLLPath.getText().trim(); |
|
74 targetInitFile = targetInitFilePath.getText().trim(); |
|
75 selectedProcIndex = processorsList.getSelectionIndex(); |
|
76 super.dispose(); |
|
77 } |
|
78 |
|
79 |
|
80 /* |
|
81 * @see IDialogPage#createControl(Composite) |
|
82 */ |
|
83 public void createControl(Composite parent) { |
|
84 Composite composite = new Composite(parent, SWT.NULL); |
|
85 GridLayout layout = new GridLayout(); |
|
86 layout.numColumns = 3; |
|
87 composite.setLayout(layout); |
|
88 |
|
89 GridData data = new GridData(); |
|
90 composite.setLayoutData(data); |
|
91 |
|
92 sophiaSTIDLLLabel = new Label(composite, SWT.NONE); |
|
93 sophiaSTIDLLLabel.setText(Messages.getString("SophiaWizardPage.2")); //$NON-NLS-1$ |
|
94 data = new GridData(); |
|
95 data.horizontalSpan = 3; |
|
96 sophiaSTIDLLLabel.setLayoutData(data); |
|
97 sophiaSTIDLLLabel.setToolTipText(Messages.getString("SophiaWizardPage.3")); //$NON-NLS-1$ |
|
98 sophiaSTIDLLLabel.setData(".uid", "SophiaWizardPage.sophiaSTIDLLLabel"); |
|
99 |
|
100 sophiaSTIDLLPath = new Text(composite, SWT.BORDER); |
|
101 data = new GridData(GridData.FILL_HORIZONTAL); |
|
102 data.horizontalSpan = 2; |
|
103 sophiaSTIDLLPath.setLayoutData(data); |
|
104 sophiaSTIDLLPath.setToolTipText(Messages.getString("SophiaWizardPage.3")); //$NON-NLS-1$ |
|
105 sophiaSTIDLLPath.setData(".uid", "SophiaWizardPage.sophiaSTIDLLPath"); |
|
106 |
|
107 sophiaSTIDLLBrowse = ControlFactory.createPushButton(composite, Messages.getString("SophiaWizardPage.13")); //$NON-NLS-1$ |
|
108 sophiaSTIDLLBrowse.addSelectionListener(new SelectionAdapter() { |
|
109 public void widgetSelected(SelectionEvent evt) { |
|
110 FileDialog dialog = new FileDialog(getShell(), SWT.NONE); |
|
111 |
|
112 dialog.setText(Messages.getString("SophiaWizardPage.4")); //$NON-NLS-1$ |
|
113 dialog.setFilterExtensions(new String[] {"*.dll*", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$ |
|
114 dialog.setFilterNames(new String[] {Messages.getString("SophiaWizardPage.5"), Messages.getString("SophiaWizardPage.6")}); //$NON-NLS-1$ //$NON-NLS-2$ |
|
115 |
|
116 String result = dialog.open(); |
|
117 if (result != null && new File(result).exists()) { |
|
118 sophiaSTIDLLPath.setText(result); |
|
119 } |
|
120 } |
|
121 }); |
|
122 sophiaSTIDLLBrowse.setData(".uid", "SophiaWizardPage.sophiaSTIDLLBrowse"); |
|
123 |
|
124 targetInitFileLabel = new Label(composite, SWT.NONE); |
|
125 targetInitFileLabel.setText(Messages.getString("SophiaWizardPage.7")); //$NON-NLS-1$ |
|
126 data = new GridData(); |
|
127 data.horizontalSpan = 3; |
|
128 targetInitFileLabel.setLayoutData(data); |
|
129 targetInitFileLabel.setToolTipText(Messages.getString("SophiaWizardPage.8")); //$NON-NLS-1$ |
|
130 targetInitFileLabel.setData(".uid", "SophiaWizardPage.targetInitFileLabel"); |
|
131 |
|
132 targetInitFilePath = new Text(composite, SWT.BORDER); |
|
133 data = new GridData(GridData.FILL_HORIZONTAL); |
|
134 data.horizontalSpan = 2; |
|
135 targetInitFilePath.setLayoutData(data); |
|
136 targetInitFilePath.setToolTipText(Messages.getString("SophiaWizardPage.8")); //$NON-NLS-1$ |
|
137 targetInitFilePath.setData(".uid", "SophiaWizardPage.targetInitFilePath"); |
|
138 |
|
139 targetInitFileBrowse = ControlFactory.createPushButton(composite, Messages.getString("SophiaWizardPage.13")); //$NON-NLS-1$ |
|
140 targetInitFileBrowse.addSelectionListener(new SelectionAdapter() { |
|
141 public void widgetSelected(SelectionEvent evt) { |
|
142 FileDialog dialog = new FileDialog(getShell(), SWT.NONE); |
|
143 |
|
144 dialog.setText(Messages.getString("SophiaWizardPage.9")); //$NON-NLS-1$ |
|
145 dialog.setFilterExtensions(new String[] {"*.cfg*", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$ |
|
146 dialog.setFilterNames(new String[] {Messages.getString("SophiaWizardPage.10"), Messages.getString("SophiaWizardPage.6")}); //$NON-NLS-1$ //$NON-NLS-2$ |
|
147 |
|
148 String result = dialog.open(); |
|
149 if (result != null && new File(result).exists()) { |
|
150 targetInitFilePath.setText(result); |
|
151 } |
|
152 } |
|
153 }); |
|
154 targetInitFileBrowse.setData(".uid", "SophiaWizardPage.targetInitFileBrowse"); |
|
155 |
|
156 final Label processorsLabel = new Label(composite, SWT.NONE); |
|
157 processorsLabel.setText(Messages.getString("SophiaWizardPage.11")); //$NON-NLS-1$ |
|
158 data = new GridData(); |
|
159 data.horizontalSpan = 3; |
|
160 processorsLabel.setLayoutData(data); |
|
161 processorsLabel.setToolTipText(Messages.getString("SophiaWizardPage.12")); //$NON-NLS-1$ |
|
162 processorsLabel.setData(".uid", "SophiaWizardPage.processorsLabel"); |
|
163 |
|
164 processorsList = new Combo(composite, SWT.READ_ONLY); |
|
165 processorsList.setItems(new String[] { "ARM920T", "ARM926TEJ", "ARM1136EJ-S", "OMAP3xx", "OMAP15xx", "OMAP16xx", "OMAP24xx", "OMAP34xx", "Generic" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ |
|
166 processorsList.select(8); //by default, select the generic |
|
167 data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
|
168 data.horizontalSpan = 3; |
|
169 processorsList.setLayoutData(data); |
|
170 processorsList.setToolTipText(Messages.getString("SophiaWizardPage.12")); //$NON-NLS-1$ |
|
171 processorsList.setData(".uid", "SophiaWizardPage.processorsList"); |
|
172 |
|
173 setControl(composite); |
|
174 Dialog.applyDialogFont(parent); |
|
175 setPageComplete(true); |
|
176 } |
|
177 |
|
178 void updateConfiguration(ILaunchConfigurationWorkingCopy config) { |
|
179 if (isDisposed) { |
|
180 if (sophiaSTIDLL.length()>0 && new File(sophiaSTIDLL).exists()) { |
|
181 config.setAttribute(SettingsData.spn_SophiaSTIConn_DllPath, sophiaSTIDLL); |
|
182 } |
|
183 |
|
184 if (targetInitFile.length()>0 && new File(targetInitFile).exists()) { |
|
185 config.setAttribute(PreferenceConstants.J_PN_TargetInitFilePath, targetInitFile); |
|
186 config.setAttribute(PreferenceConstants.J_PN_RunTargetInitFile, true); |
|
187 } |
|
188 |
|
189 config.setAttribute(PreferenceConstants.J_PN_TargetProcessor, selectedProcIndex); |
|
190 } else { |
|
191 if ((sophiaSTIDLLPath.getText().trim().length()>0) && (new File(sophiaSTIDLLPath.getText().trim()).exists())) { |
|
192 config.setAttribute(SettingsData.spn_SophiaSTIConn_DllPath, sophiaSTIDLLPath.getText()); |
|
193 } |
|
194 |
|
195 if (targetInitFilePath.getText().trim().length()>0 && new File(targetInitFilePath.getText().trim()).exists()) { |
|
196 config.setAttribute(PreferenceConstants.J_PN_TargetInitFilePath, targetInitFilePath.getText().trim()); |
|
197 config.setAttribute(PreferenceConstants.J_PN_RunTargetInitFile, true); |
|
198 } |
|
199 |
|
200 config.setAttribute( PreferenceConstants.J_PN_TargetProcessor, processorsList.getSelectionIndex()); |
|
201 } |
|
202 } |
|
203 |
|
204 public void setVisible(boolean visible) { |
|
205 super.setVisible(visible); |
|
206 if (!visible) { |
|
207 summaryTextItemContainer.putSummaryTextItem("SophiaTargetInterface", //$NON-NLS-1$ |
|
208 MessageFormat.format("{0} {1}", new Object[] { //$NON-NLS-1$ |
|
209 Messages.getString("SophiaWizardPage.2"), //$NON-NLS-1$ |
|
210 sophiaSTIDLLPath.getText() } )); |
|
211 summaryTextItemContainer.putSummaryTextItem("TargetInitFile", //$NON-NLS-1$ |
|
212 MessageFormat.format("{0} {1}", new Object[] { //$NON-NLS-1$ |
|
213 Messages.getString("SophiaWizardPage.7"), //$NON-NLS-1$ |
|
214 targetInitFilePath.getText() } )); |
|
215 summaryTextItemContainer.putSummaryTextItem("TargetProcessor", //$NON-NLS-1$ |
|
216 MessageFormat.format("{0} {1}", new Object[] { //$NON-NLS-1$ |
|
217 Messages.getString("SophiaWizardPage.11"), //$NON-NLS-1$ |
|
218 processorsList.getItem(processorsList.getSelectionIndex()) } )); |
|
219 } |
|
220 } |
|
221 |
|
222 @Override |
|
223 public void performHelp() { |
|
224 PlatformUI.getWorkbench().getHelpSystem().displayHelp(LaunchWizardHelpIds.WIZARD_SOPHIA_PAGE); |
|
225 } |
|
226 } |
|