|
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.carbide.cpp.internal.sdk.ui; |
|
18 |
|
19 import java.io.*; |
|
20 import java.util.*; |
|
21 import java.util.List; |
|
22 |
|
23 import org.eclipse.jface.dialogs.MessageDialog; |
|
24 import org.eclipse.jface.preference.IPreferenceStore; |
|
25 import org.eclipse.jface.preference.PreferencePage; |
|
26 import org.eclipse.jface.viewers.*; |
|
27 import org.eclipse.swt.SWT; |
|
28 import org.eclipse.swt.events.*; |
|
29 import org.eclipse.swt.graphics.Color; |
|
30 import org.eclipse.swt.graphics.Image; |
|
31 import org.eclipse.swt.layout.GridData; |
|
32 import org.eclipse.swt.layout.GridLayout; |
|
33 import org.eclipse.swt.widgets.*; |
|
34 import org.eclipse.ui.*; |
|
35 |
|
36 import com.nokia.carbide.cpp.sdk.core.*; |
|
37 import com.nokia.carbide.cpp.sdk.ui.SDKUIPlugin; |
|
38 import com.nokia.carbide.cpp.sdk.ui.shared.AddSDKDialog; |
|
39 |
|
40 public class SDKPreferencePage |
|
41 extends PreferencePage |
|
42 implements IWorkbenchPreferencePage { |
|
43 |
|
44 ISDKManager sdkMgr; |
|
45 private CheckboxTableViewer sdkListTableViewer; |
|
46 private List<ISymbianSDK> sdkList; |
|
47 private Button sdkpropertiesButton; |
|
48 private Button removeSdkButton; |
|
49 private Button addNewSdkButton; |
|
50 private Button rescanNowButton; |
|
51 |
|
52 private Label epocrootLabel; |
|
53 private Label availablePlatformsLabel; |
|
54 private Label osVersionLabel; |
|
55 private Label diagnosticCheckLabel; |
|
56 |
|
57 private Button listenForDevicesXMLChangeButton; |
|
58 |
|
59 private static final String EPOCROOT_LABEL = "EPOCROOT: "; //$NON-NLS-1$ |
|
60 private static final String PLATFORMS_LABEL = "Available Platforms: "; //$NON-NLS-1$ |
|
61 private static final String DIAGNOSTIC_CHECK_LABEL = "Diagnostic Check: "; //$NON-NLS-1$ |
|
62 private static final String OS_VERSION_LABEL = "OS Version: "; //$NON-NLS-1$ |
|
63 |
|
64 private Color RED; |
|
65 private Color BLACK; |
|
66 private Color GRAY; |
|
67 Shell shell; |
|
68 |
|
69 public SDKPreferencePage() { |
|
70 super(); |
|
71 |
|
72 } |
|
73 |
|
74 @Override |
|
75 protected Control createContents(Composite parent) { |
|
76 return null; |
|
77 } |
|
78 |
|
79 /* (non-Javadoc) |
|
80 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) |
|
81 */ |
|
82 public void init(IWorkbench workbench) { |
|
83 } |
|
84 |
|
85 /* (non-Javadoc) |
|
86 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |
|
87 */ |
|
88 public void createControl(Composite parent) { |
|
89 |
|
90 IPreferenceStore prefsStore = SDKUIPlugin.getDefault().getPreferenceStore(); |
|
91 sdkMgr = SDKCorePlugin.getSDKManager(); |
|
92 if (sdkMgr == null){ |
|
93 return; |
|
94 } |
|
95 |
|
96 shell = parent.getShell(); |
|
97 sdkList = sdkMgr.getSDKList(); |
|
98 RED = shell.getDisplay().getSystemColor(SWT.COLOR_RED); |
|
99 BLACK = shell.getDisplay().getSystemColor(SWT.COLOR_BLACK); |
|
100 GRAY = shell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); |
|
101 |
|
102 // check that devices.xml actually exists |
|
103 checkDevicesXMLExist(); |
|
104 |
|
105 Composite content = new Composite(parent, SWT.NONE); |
|
106 setControl(content); |
|
107 final GridLayout gridLayout = new GridLayout(); |
|
108 gridLayout.numColumns = 2; |
|
109 content.setLayout(gridLayout); |
|
110 |
|
111 final Group availableSymbianOsGroup = new Group(content, SWT.NONE); |
|
112 availableSymbianOsGroup.setToolTipText(Messages.getString("SDKPreferencePage.OS_Group_ToolTip")); //$NON-NLS-1$ |
|
113 final GridData availableSymbianOsGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); |
|
114 availableSymbianOsGridData.widthHint = 350; |
|
115 availableSymbianOsGroup.setText(Messages.getString("SDKPreferencePage.Available_SDKs_Label")); //$NON-NLS-1$ |
|
116 availableSymbianOsGroup.setLayoutData(availableSymbianOsGridData); |
|
117 availableSymbianOsGroup.setLayout(new GridLayout()); |
|
118 |
|
119 sdkListTableViewer = CheckboxTableViewer.newCheckList(availableSymbianOsGroup, SWT.BORDER); |
|
120 sdkListTableViewer.getTable().setLayoutData(availableSymbianOsGridData); |
|
121 |
|
122 final Composite composite = new Composite(content, SWT.NONE); |
|
123 composite.setLayoutData(new GridData()); |
|
124 final GridLayout gridLayout_1 = new GridLayout(); |
|
125 gridLayout_1.makeColumnsEqualWidth = true; |
|
126 composite.setLayout(gridLayout_1); |
|
127 |
|
128 removeSdkButton = new Button(composite, SWT.NONE); |
|
129 removeSdkButton.setToolTipText(Messages.getString("SDKPreferencePage.Delete_SDK_ToolTip")); //$NON-NLS-1$ |
|
130 final GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, false); |
|
131 removeSdkButton.setLayoutData(gridData); |
|
132 removeSdkButton.setText(Messages.getString("SDKPreferencePage.Remove_SDK_Label")); //$NON-NLS-1$ |
|
133 addButtonListener(removeSdkButton); |
|
134 |
|
135 addNewSdkButton = new Button(composite, SWT.NONE); |
|
136 addNewSdkButton.setToolTipText(Messages.getString("SDKPreferencePage.Add_New_SDK_ToolTip")); //$NON-NLS-1$ |
|
137 addNewSdkButton.setLayoutData(gridData); |
|
138 addNewSdkButton.setText(Messages.getString("SDKPreferencePage.Add_New_SDK_Label")); //$NON-NLS-1$ |
|
139 addButtonListener(addNewSdkButton); |
|
140 |
|
141 sdkpropertiesButton = new Button(composite, SWT.NONE); |
|
142 sdkpropertiesButton.setToolTipText(Messages.getString("SDKPreferencePage.SDK_Props_Button_ToolTip")); //$NON-NLS-1$ |
|
143 sdkpropertiesButton.setLayoutData(gridData); |
|
144 sdkpropertiesButton.setText(Messages.getString("SDKPreferencePage.SDK_Props_Button_Label")); //$NON-NLS-1$ |
|
145 addButtonListener(sdkpropertiesButton); |
|
146 |
|
147 final Group sdkInformationGroup = new Group(content, SWT.NONE); |
|
148 sdkInformationGroup.setToolTipText(Messages.getString("SDKPreferencePage.SDK_Info_ToolTip")); //$NON-NLS-1$ |
|
149 final GridData sdkInfoGridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
|
150 sdkInfoGridData.widthHint = 350; |
|
151 sdkInformationGroup.setText(Messages.getString("SDKPreferencePage.SDK_Info_Label")); //$NON-NLS-1$ |
|
152 sdkInformationGroup.setLayoutData(sdkInfoGridData); |
|
153 sdkInformationGroup.setLayout(new GridLayout()); |
|
154 |
|
155 epocrootLabel = new Label(sdkInformationGroup, SWT.WRAP); |
|
156 epocrootLabel.setToolTipText(Messages.getString("SDKPreferencePage.EPOC32_Loc_ToolTip")); //$NON-NLS-1$ |
|
157 epocrootLabel.setLayoutData(new GridData(300, SWT.DEFAULT)); |
|
158 epocrootLabel.setText("EPOCROOT:"); //$NON-NLS-1$ |
|
159 |
|
160 osVersionLabel = new Label(sdkInformationGroup, SWT.WRAP); |
|
161 osVersionLabel.setToolTipText(Messages.getString("SDKPreferencePage.OSVesions_ToolTip")); //$NON-NLS-1$ |
|
162 osVersionLabel.setLayoutData(new GridData(300, SWT.DEFAULT)); |
|
163 osVersionLabel.setText(Messages.getString("SDKPreferencePage.OSVersion_Label")); //$NON-NLS-1$ |
|
164 |
|
165 availablePlatformsLabel = new Label(sdkInformationGroup, SWT.WRAP); |
|
166 availablePlatformsLabel.setToolTipText(Messages.getString("SDKPreferencePage.Platforms_ToolTip")); //$NON-NLS-1$ |
|
167 availablePlatformsLabel.setLayoutData(new GridData(300, SWT.DEFAULT)); |
|
168 availablePlatformsLabel.setText(Messages.getString("SDKPreferencePage.Available_Platforms")); //$NON-NLS-1$ |
|
169 |
|
170 diagnosticCheckLabel = new Label(sdkInformationGroup, SWT.WRAP); |
|
171 diagnosticCheckLabel.setToolTipText(Messages.getString("SDKPreferencePage.Diagnostic_Check_ToolTip")); //$NON-NLS-1$ |
|
172 diagnosticCheckLabel.setLayoutData(sdkInfoGridData); |
|
173 diagnosticCheckLabel.setText(Messages.getString("SDKPreferencePage.Diagnostic_Check_Label")); //$NON-NLS-1$ |
|
174 new Label(content, SWT.NONE); |
|
175 |
|
176 listenForDevicesXMLChangeButton = new Button(content, SWT.CHECK); |
|
177 listenForDevicesXMLChangeButton.setText(Messages.getString("SDKPreferencePage.listerForDevicesXML")); |
|
178 listenForDevicesXMLChangeButton.setToolTipText(Messages.getString("SDKPreferencePage.listerForDevicesXML_Tooltip")); //$NON-NLS-1$ |
|
179 listenForDevicesXMLChangeButton.setSelection(prefsStore.getBoolean(SDKUIPreferenceConstants.LISTEN_FOR_DEVICES_XML_CHANGE)); |
|
180 |
|
181 new Label(content, SWT.WRAP); // filler |
|
182 |
|
183 rescanNowButton = new Button(content, SWT.NONE); |
|
184 rescanNowButton.setToolTipText(Messages.getString("SDKPreferencePage.Rescan_Button_ToolTip")); //$NON-NLS-1$ |
|
185 rescanNowButton.setLayoutData(new GridData()); |
|
186 rescanNowButton.setText(Messages.getString("SDKPreferencePage.Rescan_Button_Label")); //$NON-NLS-1$ |
|
187 addButtonListener(rescanNowButton); |
|
188 new Label(content, SWT.NONE); |
|
189 |
|
190 // Build the checked table of SDKs |
|
191 addSDKComponentTableItems(); |
|
192 |
|
193 ISymbianSDK sdk = (ISymbianSDK)sdkListTableViewer.getElementAt(0); |
|
194 if (sdk != null){ |
|
195 sdkListTableViewer.setSelection(new StructuredSelection(sdk), true); |
|
196 setSelectedSDKInfoText(sdk); |
|
197 } |
|
198 |
|
199 |
|
200 PlatformUI.getWorkbench().getHelpSystem().setHelp(super.getControl(), SDKUIHelpIds.SDK_PREFERENCES_PAGE); |
|
201 } |
|
202 |
|
203 public boolean performOk() { |
|
204 |
|
205 IPreferenceStore prefsStore = SDKUIPlugin.getDefault().getPreferenceStore(); |
|
206 prefsStore.setValue(SDKUIPreferenceConstants.LISTEN_FOR_DEVICES_XML_CHANGE, listenForDevicesXMLChangeButton.getSelection()); |
|
207 |
|
208 for (ISymbianSDK sdk : sdkMgr.getSDKList()){ |
|
209 sdk.setEnabled(false); |
|
210 } |
|
211 Object[] sdkObjects = sdkListTableViewer.getCheckedElements(); |
|
212 for (Object currObj : sdkObjects){ |
|
213 if (currObj instanceof ISymbianSDK){ |
|
214 ISymbianSDK sdk = (ISymbianSDK)currObj; |
|
215 sdk.setEnabled(true); |
|
216 } |
|
217 } |
|
218 |
|
219 ISDKManager sdkMgr =SDKCorePlugin.getSDKManager(); |
|
220 sdkMgr.updateCarbideSDKCache(); |
|
221 |
|
222 return super.performOk(); |
|
223 } |
|
224 |
|
225 private void addSDKComponentTableItems() { |
|
226 sdkListTableViewer.setContentProvider(new SDKTableComponentsContentProvider()); |
|
227 sdkListTableViewer.setLabelProvider(new SDKTableComponentsLabelProvider()); |
|
228 Table lTable = sdkListTableViewer.getTable(); |
|
229 |
|
230 sdkList = SDKCorePlugin.getSDKManager().getSDKList(); |
|
231 sdkListTableViewer.setInput(sdkList); |
|
232 lTable.setToolTipText(Messages.getString("SDKPreferencePage.List_of_Available_SDKs_ToolTip")); //$NON-NLS-1$ |
|
233 lTable.setVisible(true); |
|
234 addSDKTableViewerSelectionListener(); |
|
235 //lTable.setLayoutData(grid); |
|
236 if (sdkList == null || sdkList.size() == 0){ |
|
237 diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + Messages.getString("SDKPreferencePage.No_SDKs_Available")); //$NON-NLS-1$ |
|
238 diagnosticCheckLabel.setForeground(RED); |
|
239 diagnosticCheckLabel.setBackground(GRAY); |
|
240 } else { |
|
241 setCheckBoxes(sdkList); |
|
242 } |
|
243 } |
|
244 |
|
245 /** |
|
246 * Sets the checkbox state for enabled SDKs. |
|
247 */ |
|
248 private void setCheckBoxes(List<ISymbianSDK> sdkList) { |
|
249 List<ISymbianSDK> sdkListCopy = new ArrayList<ISymbianSDK>(); |
|
250 for (ISymbianSDK sdkCheck : sdkList){ |
|
251 if (sdkCheck.isEnabled()){ |
|
252 sdkListCopy.add(sdkCheck); |
|
253 } |
|
254 } |
|
255 sdkListTableViewer.setCheckedElements(sdkListCopy.toArray(new ISymbianSDK[sdkListCopy.size()])); |
|
256 } |
|
257 |
|
258 /** |
|
259 * Extends <code>LabelProvider</code> with the default implementation |
|
260 * and implements<code>ITableLabelProvider</code> with the methods |
|
261 * to provide the text and/or image for each column of a given element. |
|
262 * Used by table viewers. |
|
263 */ |
|
264 |
|
265 static class SDKTableComponentsLabelProvider extends LabelProvider implements ITableLabelProvider, ITableColorProvider { |
|
266 |
|
267 /** |
|
268 * Returns the label image for the given column of the given element. |
|
269 * The default implementation returns null. |
|
270 * |
|
271 * @return image object |
|
272 */ |
|
273 public Image getColumnImage(Object element, int columnIndex) { |
|
274 return null; |
|
275 } |
|
276 |
|
277 /** |
|
278 * Returns the label text for the given column of the given element. |
|
279 * |
|
280 * @return string is the label text for the given column. |
|
281 */ |
|
282 public String getColumnText(Object arg0, int column) { |
|
283 if (arg0 instanceof ISymbianSDK){ |
|
284 ISymbianSDK sdk = (ISymbianSDK)arg0; |
|
285 return sdk.getUniqueId(); |
|
286 } |
|
287 |
|
288 return ""; //$NON-NLS-1$ |
|
289 } |
|
290 |
|
291 private Color lBlack = Display.getDefault().getSystemColor(SWT.COLOR_BLACK); |
|
292 private Color lRed = Display.getDefault().getSystemColor(SWT.COLOR_RED); |
|
293 |
|
294 public Color getForeground(Object obj, int index) { |
|
295 if (obj instanceof ISymbianSDK) { |
|
296 ISymbianSDK sdk = (ISymbianSDK)obj; |
|
297 File epocRootTest = new File(sdk.getEPOCROOT()); |
|
298 if ((sdk.getAvailablePlatforms().size() <= 0) || !epocRootTest.exists()) { |
|
299 // There are no build configs and/or no epocroot exists |
|
300 return lRed; |
|
301 } else { |
|
302 return lBlack; |
|
303 } |
|
304 } |
|
305 return null; |
|
306 } |
|
307 |
|
308 public Color getBackground(Object element, int columnIndex) { |
|
309 return null; |
|
310 } |
|
311 } |
|
312 |
|
313 /** |
|
314 * This implementation of <code>IStructuredContentProvider</code> handles |
|
315 * the case where the viewer input is an unchanging array or collection of elements. |
|
316 * |
|
317 */ |
|
318 static class SDKTableComponentsContentProvider implements IStructuredContentProvider { |
|
319 |
|
320 |
|
321 /** |
|
322 * Returns the elements in the input |
|
323 * |
|
324 * @return array of objects. |
|
325 */ |
|
326 public Object[] getElements(Object arg0) { |
|
327 if (arg0 instanceof ArrayList) { |
|
328 return ((ArrayList<?>)arg0).toArray(); |
|
329 } |
|
330 return new Object[0]; |
|
331 } |
|
332 |
|
333 public void dispose() { |
|
334 } |
|
335 |
|
336 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
|
337 //do nothing |
|
338 } |
|
339 } |
|
340 |
|
341 /** |
|
342 * Sets the listener event to a button. |
|
343 * |
|
344 * @param aButton |
|
345 */ |
|
346 private void addButtonListener( final Button aButton ) { |
|
347 SelectionListener listener = new SelectionAdapter() { |
|
348 public void widgetSelected( SelectionEvent e ) { |
|
349 if (e.getSource().equals(sdkpropertiesButton)) { |
|
350 sdkpropertiesButtonAction(); |
|
351 } else if (e.getSource().equals(addNewSdkButton)) { |
|
352 addNewSdkButtonAction(); |
|
353 } else if (e.getSource().equals(removeSdkButton)) { |
|
354 removeSdkButtonAction(); |
|
355 } else if (e.getSource().equals(rescanNowButton)) { |
|
356 rescanNowButtonAction(); |
|
357 } |
|
358 |
|
359 } |
|
360 }; |
|
361 aButton.addSelectionListener(listener); |
|
362 } |
|
363 |
|
364 private void sdkpropertiesButtonAction(){ |
|
365 ISymbianSDK sdk = (ISymbianSDK)((IStructuredSelection)sdkListTableViewer.getSelection()).getFirstElement(); |
|
366 if (sdk != null){ |
|
367 SDKPropertiesDialog sdkPropDlg = new SDKPropertiesDialog(getShell(), this, sdk); |
|
368 if (sdkPropDlg.open() == SDKPropertiesDialog.OK){ |
|
369 sdkListTableViewer.refresh(); |
|
370 setSelectedSDKInfoText(sdk); |
|
371 } |
|
372 } else { |
|
373 MessageDialog.openError(getShell(), Messages.getString("SDKPreferencePage.No_SDK_Selected"), Messages.getString("SDKPreferencePage.No_selected_SDK_detected")); //$NON-NLS-1$ //$NON-NLS-2$ |
|
374 } |
|
375 |
|
376 } |
|
377 |
|
378 private void removeSdkButtonAction(){ |
|
379 ISymbianSDK sdk = (ISymbianSDK)((IStructuredSelection)sdkListTableViewer.getSelection()).getFirstElement(); |
|
380 if (sdk != null){ |
|
381 if (MessageDialog.openConfirm(getShell(), Messages.getString("SDKPreferencePage.Confirm_Delete") + sdk.getUniqueId() , Messages.getString("SDKPreferencePage.Confirm_Delete_Msg"))){ //$NON-NLS-1$ //$NON-NLS-2$ |
|
382 if (sdkMgr.removeSDK(sdk.getUniqueId())){ |
|
383 sdkList.remove(sdk); |
|
384 sdkListTableViewer.refresh(); |
|
385 sdk = (ISymbianSDK)sdkListTableViewer.getElementAt(0); |
|
386 if (sdk != null){ |
|
387 sdkListTableViewer.setSelection(new StructuredSelection(sdk), true); |
|
388 setSelectedSDKInfoText(sdk); |
|
389 } |
|
390 } |
|
391 } |
|
392 } |
|
393 } |
|
394 |
|
395 private void addNewSdkButtonAction(){ |
|
396 |
|
397 AddSDKDialog dialog = new AddSDKDialog(getShell()); |
|
398 if (dialog.open() == AddSDKDialog.OK){ |
|
399 addSDKComponentTableItems(); |
|
400 sdkListTableViewer.refresh(); |
|
401 } |
|
402 } |
|
403 |
|
404 private void rescanNowButtonAction(){ |
|
405 sdkListTableViewer.getTable().clearAll(); |
|
406 sdkListTableViewer.refresh(); |
|
407 sdkList.clear(); |
|
408 ISDKManager sdkMgr = SDKCorePlugin.getSDKManager(); |
|
409 sdkMgr.scanSDKs(); |
|
410 sdkList = sdkMgr.getSDKList(); |
|
411 addSDKComponentTableItems(); |
|
412 sdkListTableViewer.refresh(); |
|
413 |
|
414 ISymbianSDK sdk = (ISymbianSDK)sdkListTableViewer.getElementAt(0); |
|
415 if (sdk != null){ |
|
416 sdkListTableViewer.setSelection(new StructuredSelection(sdk), true); |
|
417 setSelectedSDKInfoText(sdk); |
|
418 } |
|
419 |
|
420 NewPluginChecker.checkForNewlyInstalledPlugins(SDKUIPlugin.getDefault().getWorkbench()); |
|
421 } |
|
422 |
|
423 /** |
|
424 * Sets the selection listener action event to the CheckboxTableViewer. |
|
425 * |
|
426 * @param sdkTable |
|
427 */ |
|
428 private void addSDKTableViewerSelectionListener(){ |
|
429 sdkListTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
|
430 public void selectionChanged(SelectionChangedEvent event) { |
|
431 |
|
432 if(event.getSelection() instanceof IStructuredSelection) { |
|
433 IStructuredSelection selection = (IStructuredSelection)event.getSelection(); |
|
434 if (selection.size() == 1){ |
|
435 ISymbianSDK sdk = (ISymbianSDK)selection.getFirstElement(); |
|
436 sdkpropertiesButton.setEnabled(true); |
|
437 removeSdkButton.setEnabled(true); |
|
438 setSelectedSDKInfoText(sdk); |
|
439 |
|
440 }else { |
|
441 sdkpropertiesButton.setEnabled(false); |
|
442 removeSdkButton.setEnabled(false); |
|
443 } |
|
444 } |
|
445 } |
|
446 } ); |
|
447 } |
|
448 |
|
449 private void setSelectedSDKInfoText(ISymbianSDK sdk){ |
|
450 boolean sdkHasError = false; |
|
451 String epocRootStr = sdk.getEPOCROOT(); |
|
452 File epocRootTest = new File(epocRootStr); |
|
453 if (!epocRootTest.exists()) { |
|
454 sdkHasError = true; |
|
455 epocrootLabel.setText(EPOCROOT_LABEL + epocRootStr + Messages.getString("SDKPreferencePage.Path_Does_Not_Exist")); //$NON-NLS-1$ |
|
456 epocrootLabel.setForeground(RED); |
|
457 epocrootLabel.setBackground(GRAY); |
|
458 } |
|
459 else { |
|
460 epocrootLabel.setText(EPOCROOT_LABEL + epocRootStr); |
|
461 epocrootLabel.setForeground(BLACK); |
|
462 epocrootLabel.setBackground(GRAY); |
|
463 } |
|
464 |
|
465 // Set platforms |
|
466 if (sdk.getAvailablePlatforms().size() == 0) { |
|
467 sdkHasError = true; |
|
468 availablePlatformsLabel.setText(PLATFORMS_LABEL + Messages.getString("SDKPreferencePage.Platforms_cannot_be_determined")); //$NON-NLS-1$ |
|
469 availablePlatformsLabel.setForeground(RED); |
|
470 availablePlatformsLabel.setBackground(GRAY); |
|
471 } |
|
472 else { |
|
473 availablePlatformsLabel.setText(PLATFORMS_LABEL + sdk.getAvailablePlatforms().toString()); |
|
474 availablePlatformsLabel.setForeground(BLACK); |
|
475 availablePlatformsLabel.setBackground(GRAY); |
|
476 } |
|
477 |
|
478 // Set OS Version |
|
479 if (sdk.getOSVersion().getMajor() == 0) { |
|
480 sdkHasError = true; |
|
481 osVersionLabel.setText(OS_VERSION_LABEL + Messages.getString("SDKPreferencePage.OS_Version_Cannot_Be_Determined")); //$NON-NLS-1$ |
|
482 osVersionLabel.setForeground(RED); |
|
483 osVersionLabel.setBackground(GRAY); |
|
484 } |
|
485 else { |
|
486 if (sdk.getSDKOSBranch().length() > 0) { |
|
487 osVersionLabel.setText(OS_VERSION_LABEL + sdk.getOSVersion().toString() + " (Branch = \"" + sdk.getSDKOSBranch() + "\")"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
488 } else { |
|
489 osVersionLabel.setText(OS_VERSION_LABEL + sdk.getOSVersion().toString()); |
|
490 } |
|
491 osVersionLabel.setForeground(BLACK); |
|
492 osVersionLabel.setBackground(GRAY); |
|
493 } |
|
494 |
|
495 // Get diagnostic check |
|
496 //if (lsdk.getSomeError().size() <= 0) { |
|
497 if (sdkHasError){ |
|
498 diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + Messages.getString("SDKPreferencePage.SDK_Cannot_Be_Used")); //$NON-NLS-1$ |
|
499 diagnosticCheckLabel.setForeground(RED); |
|
500 diagnosticCheckLabel.setBackground(GRAY); |
|
501 } |
|
502 else { |
|
503 // check for other types of errors: |
|
504 if (!sdk.getToolsPath().toFile().exists()){ |
|
505 diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + Messages.getString("SDKPreferencePage.No_Tools_Path") + " " + sdk.getToolsPath().toOSString()); //$NON-NLS-1$ |
|
506 diagnosticCheckLabel.setForeground(RED); |
|
507 diagnosticCheckLabel.setBackground(GRAY); |
|
508 } else if (!sdk.getIncludePath().toFile().exists()){ |
|
509 diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + Messages.getString("SDKPreferencePage.No_Include_Path") + " " + sdk.getIncludePath().toOSString()); //$NON-NLS-1$ |
|
510 diagnosticCheckLabel.setForeground(RED); |
|
511 diagnosticCheckLabel.setBackground(GRAY); |
|
512 } else if ( ((sdk.getPrefixFile() == null) || (!sdk.getPrefixFile().exists())) && (sdk.getOSVersion().getMajor() >= 9)){ |
|
513 diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + Messages.getString("SDKPreferencePage.No_HRH_File")); //$NON-NLS-1$ |
|
514 diagnosticCheckLabel.setForeground(RED); |
|
515 diagnosticCheckLabel.setBackground(GRAY); |
|
516 } else if ( ((sdk.isS60()) && sdk.getSDKVersion().getMajor() == 0)){ |
|
517 diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + Messages.getString("SDKPreferencePage.No_SDK_Version")); //$NON-NLS-1$ |
|
518 diagnosticCheckLabel.setForeground(RED); |
|
519 diagnosticCheckLabel.setBackground(GRAY); |
|
520 } else { |
|
521 // Everything is OK.... |
|
522 diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + "OK\r\n "); //$NON-NLS-1$ |
|
523 diagnosticCheckLabel.setForeground(BLACK); |
|
524 diagnosticCheckLabel.setBackground(GRAY); |
|
525 } |
|
526 } |
|
527 } |
|
528 |
|
529 protected List<ISymbianSDK> getSDKList(){ |
|
530 return sdkList; |
|
531 } |
|
532 |
|
533 protected ISDKManager getSDKManager(){ |
|
534 return sdkMgr; |
|
535 } |
|
536 |
|
537 private void checkDevicesXMLExist(){ |
|
538 if (sdkMgr == null){ |
|
539 return; |
|
540 } |
|
541 |
|
542 File devicesFile = sdkMgr.getDevicesXMLFile(); |
|
543 if (!devicesFile.exists()){ |
|
544 if (true == MessageDialog.openQuestion(shell, "Cannot find devices.xml.", "Devices.xml is required for Carbide.c++ use. Do you want to create this file?\n\n" + ISDKManager.DEFAULT_DEVICES_XML_DIR + ISDKManager.DEVICES_FILE_NAME)){ |
|
545 try { |
|
546 //First check to make sure the directory exists.... |
|
547 File devicesPath = new File(ISDKManager.DEFAULT_DEVICES_XML_DIR); |
|
548 if (!devicesPath.exists()){ |
|
549 devicesPath.mkdirs(); |
|
550 } |
|
551 |
|
552 devicesFile = new File(ISDKManager.DEFAULT_DEVICES_XML_DIR + ISDKManager.DEVICES_FILE_NAME); |
|
553 devicesFile.createNewFile(); |
|
554 FileWriter fw = new FileWriter(devicesFile); |
|
555 fw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?><devices version=\"1.0\"></devices>"); |
|
556 fw.close(); |
|
557 } catch (IOException e){ |
|
558 MessageDialog.openError(shell, "Cannot create file.", "Could not create file: " + devicesFile.toString()); |
|
559 e.printStackTrace(); |
|
560 } |
|
561 } else { |
|
562 MessageDialog.openError(shell, "File not created.", "File not created. You will be unable to create project in Carbide.c++."); |
|
563 } |
|
564 |
|
565 } |
|
566 } |
|
567 |
|
568 } |