core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKPreferencePage.java
equal
deleted
inserted
replaced
31 import org.eclipse.swt.layout.GridData; |
31 import org.eclipse.swt.layout.GridData; |
32 import org.eclipse.swt.layout.GridLayout; |
32 import org.eclipse.swt.layout.GridLayout; |
33 import org.eclipse.swt.widgets.*; |
33 import org.eclipse.swt.widgets.*; |
34 import org.eclipse.ui.*; |
34 import org.eclipse.ui.*; |
35 |
35 |
|
36 import com.nokia.carbide.cpp.internal.sdk.core.model.SDKManager; |
36 import com.nokia.carbide.cpp.sdk.core.*; |
37 import com.nokia.carbide.cpp.sdk.core.*; |
37 import com.nokia.carbide.cpp.sdk.ui.SDKUIPlugin; |
38 import com.nokia.carbide.cpp.sdk.ui.SDKUIPlugin; |
38 import com.nokia.carbide.cpp.sdk.ui.shared.AddSDKDialog; |
39 import com.nokia.carbide.cpp.sdk.ui.shared.AddSDKDialog; |
39 |
40 |
40 public class SDKPreferencePage |
41 public class SDKPreferencePage |
98 RED = shell.getDisplay().getSystemColor(SWT.COLOR_RED); |
99 RED = shell.getDisplay().getSystemColor(SWT.COLOR_RED); |
99 BLACK = shell.getDisplay().getSystemColor(SWT.COLOR_BLACK); |
100 BLACK = shell.getDisplay().getSystemColor(SWT.COLOR_BLACK); |
100 GRAY = shell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); |
101 GRAY = shell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); |
101 |
102 |
102 // check that devices.xml actually exists |
103 // check that devices.xml actually exists |
103 checkDevicesXMLExist(); |
104 ((SDKManager) sdkMgr).checkDevicesXMLExistAndCreate(); |
104 |
105 |
105 Composite content = new Composite(parent, SWT.NONE); |
106 Composite content = new Composite(parent, SWT.NONE); |
106 setControl(content); |
107 setControl(content); |
107 final GridLayout gridLayout = new GridLayout(); |
108 final GridLayout gridLayout = new GridLayout(); |
108 gridLayout.numColumns = 2; |
109 gridLayout.numColumns = 2; |
531 } |
532 } |
532 |
533 |
533 protected ISDKManager getSDKManager(){ |
534 protected ISDKManager getSDKManager(){ |
534 return sdkMgr; |
535 return sdkMgr; |
535 } |
536 } |
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 } |
537 } |