|
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 |
|
18 package com.nokia.carbide.cpp.internal.pi.wizards.ui; |
|
19 |
|
20 import org.eclipse.swt.SWT; |
|
21 import org.eclipse.swt.events.SelectionEvent; |
|
22 import org.eclipse.swt.events.SelectionListener; |
|
23 import org.eclipse.swt.graphics.Image; |
|
24 import org.eclipse.swt.layout.GridData; |
|
25 import org.eclipse.swt.layout.GridLayout; |
|
26 import org.eclipse.swt.widgets.Button; |
|
27 import org.eclipse.swt.widgets.Composite; |
|
28 import org.eclipse.swt.widgets.Group; |
|
29 import org.eclipse.swt.widgets.Label; |
|
30 import org.eclipse.ui.PlatformUI; |
|
31 |
|
32 import com.nokia.carbide.cpp.internal.pi.wizards.ui.util.CarbidePiWizardHelpIds; |
|
33 import com.nokia.carbide.cpp.ui.CarbideUIPlugin; |
|
34 import com.nokia.carbide.cpp.ui.ICarbideSharedImages; |
|
35 |
|
36 |
|
37 public class NewPIWizardPageConfigSelectorTask |
|
38 extends NewPIWizardPage |
|
39 implements INewPIWizardSettings |
|
40 { |
|
41 |
|
42 // control |
|
43 private Composite composite = null; |
|
44 private Group optionGroup = null; |
|
45 private Composite appComposite = null; |
|
46 private Composite appLabelComposite = null; |
|
47 private Button buttonApp = null; |
|
48 private Label labelAppTitle = null; |
|
49 private Label labelApp2 = null; |
|
50 private Composite romAppComposite = null; |
|
51 private Composite romAppLabelComposite = null; |
|
52 private Button buttonRomApp = null; |
|
53 private Label labelRomAppTitle = null; |
|
54 private Label labelRomApp2 = null; |
|
55 private Label labelRomApp3 = null; |
|
56 private Composite romComposite = null; |
|
57 private Composite romLabelComposite = null; |
|
58 private Button buttonRom = null; |
|
59 private Label labelRomTitle = null; |
|
60 private Label labelRom2 = null; |
|
61 private Composite noneComposite = null; |
|
62 private Composite noneLabelComposite = null; |
|
63 private Button buttonNone = null; |
|
64 private Label labelNoneTitle = null; |
|
65 private Label labelNone2 = null; |
|
66 private Label labelNone3 = null; |
|
67 @SuppressWarnings("unused") //$NON-NLS-1$ |
|
68 private Group customTraceGroup = null; |
|
69 @SuppressWarnings("unused") //$NON-NLS-1$ |
|
70 private Button buttonCustomTrace = null; |
|
71 @SuppressWarnings("unused") //$NON-NLS-1$ |
|
72 private Label labelCustomTrace = null; |
|
73 |
|
74 private ICarbideSharedImages carbideImages = CarbideUIPlugin.getSharedImages(); |
|
75 private Image phonensisImage = carbideImages.getImage(ICarbideSharedImages.IMG_PI_IMPORT_ROM_AND_APP_100_42); |
|
76 private Image phoneImage = carbideImages.getImage(ICarbideSharedImages.IMG_PI_IMPORT_ROM_42_42); |
|
77 private Image sisImage = carbideImages.getImage(ICarbideSharedImages.IMG_PI_IMPORT_APP_42_42); |
|
78 private Image noneImage = carbideImages.getImage(ICarbideSharedImages.IMG_PI_IMPORT_NONE_100_42); |
|
79 private Image cusTraceImage = carbideImages.getImage(ICarbideSharedImages.IMG_CUSTOM_TRACE_BADGE_24_24); |
|
80 |
|
81 protected NewPIWizardPageConfigSelectorTask() { |
|
82 super(Messages.getString("NewPIWizardPageConfigSelectorTask.title")); //$NON-NLS-1$ |
|
83 setTitle(Messages.getString("NewPIWizardPageConfigSelectorTask.title")); //$NON-NLS-1$ |
|
84 setDescription(Messages.getString("NewPIWizardPageConfigSelectorTask.description")); //$NON-NLS-1$ |
|
85 } |
|
86 |
|
87 SelectionListener buttonListener = new SelectionListener () { |
|
88 // handle all buttons including radio behavior among toggle |
|
89 |
|
90 public void widgetDefaultSelected(SelectionEvent arg0) { |
|
91 } |
|
92 |
|
93 public void widgetSelected(SelectionEvent arg0) { |
|
94 buttonApp.setSelection(false); |
|
95 buttonRomApp.setSelection(false); |
|
96 buttonRom.setSelection(false); |
|
97 buttonNone.setSelection(false); |
|
98 ((Button)arg0.widget).setSelection(true); |
|
99 // write back to our status |
|
100 NewPIWizardSettings.getInstance().haveAppRom = false; |
|
101 NewPIWizardSettings.getInstance().haveAppOnly = false; |
|
102 NewPIWizardSettings.getInstance().haveRomOnly = false; |
|
103 NewPIWizardSettings.getInstance().haveNothing = false; |
|
104 if (((Button)arg0.widget) == buttonRomApp) { |
|
105 NewPIWizardSettings.getInstance().haveAppRom = true; |
|
106 } else if (((Button)arg0.widget) == buttonApp) { |
|
107 NewPIWizardSettings.getInstance().haveAppOnly = true; |
|
108 } else if (((Button)arg0.widget) == buttonRom) { |
|
109 NewPIWizardSettings.getInstance().haveRomOnly = true; |
|
110 } else if (((Button)arg0.widget) == buttonNone) { |
|
111 NewPIWizardSettings.getInstance().haveNothing = true; |
|
112 } |
|
113 validatePage(); |
|
114 } |
|
115 }; |
|
116 |
|
117 public void createControl(Composite parent) { |
|
118 super.createControl(parent); |
|
119 GridLayout gridLayout1 = new GridLayout(); |
|
120 gridLayout1.numColumns = 1; |
|
121 composite = new Composite (parent, SWT.NONE); |
|
122 composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
|
123 composite.setLayout(gridLayout1); |
|
124 GridLayout gridLayout2 = new GridLayout(); |
|
125 gridLayout2.numColumns = 1; |
|
126 optionGroup = new Group(composite, SWT.NONE); |
|
127 optionGroup.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, true)); |
|
128 optionGroup.setLayout(gridLayout2); |
|
129 optionGroup.setText(Messages.getString("NewPIWizardPageConfigSelectorTask.option.group")); //$NON-NLS-1$ |
|
130 labelAppTitle = new Label(optionGroup, SWT.NONE); |
|
131 labelAppTitle.setText(Messages.getString("NewPIWizardPageConfigSelectorTask.labelAppTitle")); //$NON-NLS-1$ |
|
132 createAppComposite(); |
|
133 labelRomAppTitle = new Label(optionGroup, SWT.NONE); |
|
134 labelRomAppTitle.setText(Messages.getString("NewPIWizardPageConfigSelectorTask.labelRomAppTitle")); //$NON-NLS-1$ |
|
135 createRomAppComposite(); |
|
136 labelRomTitle = new Label(optionGroup, SWT.NONE); |
|
137 labelRomTitle.setText(Messages.getString("NewPIWizardPageConfigSelectorTask.labelRomTitle")); //$NON-NLS-1$ |
|
138 createRomComposite(); |
|
139 labelNoneTitle = new Label(optionGroup, SWT.NONE); |
|
140 labelNoneTitle.setText(Messages.getString("NewPIWizardPageConfigSelectorTask.labelNoneTitle")); //$NON-NLS-1$ |
|
141 createNoneComposite(); |
|
142 // createCustomComposite(); |
|
143 |
|
144 GridData buttonWidthGridData = new GridData(); |
|
145 buttonWidthGridData.widthHint = Math.max(Math.max(Math.max(phonensisImage.getBounds().width, phoneImage.getBounds().width), sisImage.getBounds().width), noneImage.getBounds().width) + 30; |
|
146 buttonWidthGridData.heightHint = Math.max(Math.max(Math.max(phonensisImage.getBounds().height, phoneImage.getBounds().height), sisImage.getBounds().height), noneImage.getBounds().height) + 30; |
|
147 buttonRomApp.setLayoutData(buttonWidthGridData); |
|
148 buttonRom.setLayoutData(buttonWidthGridData); |
|
149 buttonApp.setLayoutData(buttonWidthGridData); |
|
150 buttonNone.setLayoutData(buttonWidthGridData); |
|
151 |
|
152 setControl(composite); |
|
153 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), CarbidePiWizardHelpIds.PI_IMPORT_WIZARD_CONFIG_SELECTOR); |
|
154 |
|
155 validatePage(); |
|
156 } |
|
157 |
|
158 void createAppComposite() { |
|
159 GridLayout gridLayout1 = new GridLayout(); |
|
160 gridLayout1.numColumns = 2; |
|
161 appComposite = new Composite (optionGroup, SWT.NONE); |
|
162 appComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, true)); |
|
163 appComposite.setLayout(gridLayout1); |
|
164 buttonApp = new Button(appComposite, SWT.TOGGLE); |
|
165 buttonApp.setImage(sisImage); |
|
166 buttonApp.addSelectionListener(buttonListener); |
|
167 GridLayout gridLayout2 = new GridLayout(); |
|
168 gridLayout2.numColumns = 1; |
|
169 appLabelComposite = new Composite (appComposite, SWT.NONE); |
|
170 appLabelComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, true)); |
|
171 appLabelComposite.setLayout(gridLayout2); |
|
172 labelApp2 = new Label(appLabelComposite, SWT.NONE); |
|
173 labelApp2.setText(Messages.getString("NewPIWizardPageConfigSelectorTask.labelApp2")); //$NON-NLS-1$ |
|
174 } |
|
175 |
|
176 void createRomAppComposite() { |
|
177 GridLayout gridLayout1 = new GridLayout(); |
|
178 gridLayout1.numColumns = 2; |
|
179 romAppComposite = new Composite (optionGroup, SWT.NONE); |
|
180 romAppComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, true)); |
|
181 romAppComposite.setLayout(gridLayout1); |
|
182 buttonRomApp = new Button(romAppComposite, SWT.TOGGLE); |
|
183 buttonRomApp.setImage(phonensisImage); |
|
184 buttonRomApp.addSelectionListener(buttonListener); |
|
185 GridLayout gridLayout2 = new GridLayout(); |
|
186 gridLayout2.numColumns = 1; |
|
187 romAppLabelComposite = new Composite (romAppComposite, SWT.NONE); |
|
188 romAppLabelComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, true)); |
|
189 romAppLabelComposite.setLayout(gridLayout2); |
|
190 labelRomApp2 = new Label(romAppLabelComposite, SWT.NONE); |
|
191 labelRomApp2.setText(Messages.getString("NewPIWizardPageConfigSelectorTask.labelRomApp2")); //$NON-NLS-1$ |
|
192 labelRomApp3 = new Label(romAppLabelComposite, SWT.NONE); |
|
193 labelRomApp3.setText(Messages.getString("NewPIWizardPageConfigSelectorTask.labelRomApp3")); //$NON-NLS-1$ |
|
194 } |
|
195 |
|
196 void createRomComposite() { |
|
197 GridLayout gridLayout1 = new GridLayout(); |
|
198 gridLayout1.numColumns = 2; |
|
199 romComposite = new Composite (optionGroup, SWT.NONE); |
|
200 romComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, true)); |
|
201 romComposite.setLayout(gridLayout1); |
|
202 buttonRom = new Button(romComposite, SWT.TOGGLE); |
|
203 buttonRom.setImage(phoneImage); |
|
204 buttonRom.addSelectionListener(buttonListener); |
|
205 GridLayout gridLayout2 = new GridLayout(); |
|
206 gridLayout2.numColumns = 1; |
|
207 romLabelComposite = new Composite (romComposite, SWT.NONE); |
|
208 romLabelComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, true)); |
|
209 romLabelComposite.setLayout(gridLayout2); |
|
210 labelRom2 = new Label(romLabelComposite, SWT.NONE); |
|
211 labelRom2.setText(Messages.getString("NewPIWizardPageConfigSelectorTask.labelRom2")); //$NON-NLS-1$ |
|
212 } |
|
213 |
|
214 void createNoneComposite() { |
|
215 GridLayout gridLayout1 = new GridLayout(); |
|
216 gridLayout1.numColumns = 2; |
|
217 noneComposite = new Composite (optionGroup, SWT.NONE); |
|
218 noneComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, true)); |
|
219 noneComposite.setLayout(gridLayout1); |
|
220 buttonNone = new Button(noneComposite, SWT.TOGGLE); |
|
221 buttonNone.setImage(noneImage); |
|
222 buttonNone.addSelectionListener(buttonListener); |
|
223 GridLayout gridLayout2 = new GridLayout(); |
|
224 gridLayout2.numColumns = 1; |
|
225 noneLabelComposite = new Composite (noneComposite, SWT.NONE); |
|
226 noneLabelComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, true)); |
|
227 noneLabelComposite.setLayout(gridLayout2); |
|
228 labelNone2 = new Label(noneLabelComposite, SWT.NONE); |
|
229 labelNone2.setText(Messages.getString("NewPIWizardPageConfigSelectorTask.labelNone2")); //$NON-NLS-1$ |
|
230 labelNone3 = new Label(noneLabelComposite, SWT.NONE); |
|
231 labelNone3.setText(Messages.getString("NewPIWizardPageConfigSelectorTask.labelNone3")); //$NON-NLS-1$ |
|
232 } |
|
233 |
|
234 void createCustomComposite() { |
|
235 GridLayout gridLayout3 = new GridLayout(); |
|
236 gridLayout3.numColumns = 2; |
|
237 customTraceGroup = new Group(composite, SWT.NONE); |
|
238 customTraceGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
|
239 customTraceGroup.setLayout(gridLayout3); |
|
240 buttonCustomTrace = new Button(customTraceGroup, SWT.CHECK); |
|
241 buttonCustomTrace.setImage(cusTraceImage); |
|
242 buttonCustomTrace.addSelectionListener(buttonListener); |
|
243 labelCustomTrace = new Label(customTraceGroup, SWT.WRAP); |
|
244 labelCustomTrace.setText(Messages.getString("NewPIWizardPageConfigSelectorTask.labelCustomTrace")); //$NON-NLS-1$ |
|
245 } |
|
246 |
|
247 public void validatePage() { |
|
248 if (buttonRomApp.getSelection() == false && |
|
249 buttonApp.getSelection() == false && |
|
250 buttonRom.getSelection() == false |
|
251 && |
|
252 buttonNone.getSelection() == false |
|
253 ) { |
|
254 setPageComplete(false); |
|
255 } else { |
|
256 setPageComplete(true); |
|
257 } |
|
258 setErrorMessage(null); |
|
259 } |
|
260 |
|
261 public void setupPageFromFromNewPIWizardSettings() { |
|
262 if (NewPIWizardSettings.getInstance().haveAppRom == true) { |
|
263 // buttonApp.setSelection(false); |
|
264 // buttonRomApp.setSelection(true); |
|
265 // buttonRom.setSelection(false); |
|
266 // set focus, and block them |
|
267 buttonRomApp.setFocus(); |
|
268 } else if (NewPIWizardSettings.getInstance().haveAppOnly == true) { |
|
269 // buttonApp.setSelection(true); |
|
270 // buttonRomApp.setSelection(false); |
|
271 // buttonRom.setSelection(false); |
|
272 // set focus, and block them |
|
273 buttonApp.setFocus(); |
|
274 } else if (NewPIWizardSettings.getInstance().haveRomOnly == true) { |
|
275 // buttonApp.setSelection(false); |
|
276 // buttonRomApp.setSelection(false); |
|
277 // buttonRom.setSelection(true); |
|
278 // set focus, and block them |
|
279 buttonRom.setFocus(); |
|
280 } else { |
|
281 buttonNone.setFocus(); |
|
282 } |
|
283 |
|
284 // buttonCustomTrace.setSelection(NewPIWizardSettings.getInstance().enableCust); |
|
285 |
|
286 validatePage(); |
|
287 } |
|
288 |
|
289 } |