core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/AddSDKDialog.java
branchC3_BUILDER_WORK
changeset 1421 587da7cb64b7
parent 740 ba87a4b50604
child 1434 79471fd1fd69
equal deleted inserted replaced
1419:ab555eecf681 1421:587da7cb64b7
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    16 */
    16 */
    17 
    17 
    18 package com.nokia.carbide.cpp.sdk.ui.shared;
    18 package com.nokia.carbide.cpp.sdk.ui.shared;
    19 
    19 
    20 import java.io.File;
    20 import java.io.File;
    21 import java.util.ArrayList;
       
    22 import java.util.List;
    21 import java.util.List;
    23 
    22 
    24 import org.eclipse.jface.dialogs.IDialogConstants;
    23 import org.eclipse.jface.dialogs.IDialogConstants;
    25 import org.eclipse.jface.dialogs.MessageDialog;
    24 import org.eclipse.jface.dialogs.MessageDialog;
    26 import org.eclipse.jface.dialogs.TrayDialog;
    25 import org.eclipse.jface.dialogs.TrayDialog;
    30 import org.eclipse.swt.events.SelectionListener;
    29 import org.eclipse.swt.events.SelectionListener;
    31 import org.eclipse.swt.graphics.Point;
    30 import org.eclipse.swt.graphics.Point;
    32 import org.eclipse.swt.layout.GridData;
    31 import org.eclipse.swt.layout.GridData;
    33 import org.eclipse.swt.layout.GridLayout;
    32 import org.eclipse.swt.layout.GridLayout;
    34 import org.eclipse.swt.widgets.Button;
    33 import org.eclipse.swt.widgets.Button;
    35 import org.eclipse.swt.widgets.Combo;
       
    36 import org.eclipse.swt.widgets.Composite;
    34 import org.eclipse.swt.widgets.Composite;
    37 import org.eclipse.swt.widgets.Control;
    35 import org.eclipse.swt.widgets.Control;
    38 import org.eclipse.swt.widgets.DirectoryDialog;
    36 import org.eclipse.swt.widgets.DirectoryDialog;
    39 import org.eclipse.swt.widgets.Label;
    37 import org.eclipse.swt.widgets.Label;
    40 import org.eclipse.swt.widgets.Shell;
    38 import org.eclipse.swt.widgets.Shell;
    42 import org.eclipse.ui.PlatformUI;
    40 import org.eclipse.ui.PlatformUI;
    43 import org.osgi.framework.Version;
    41 import org.osgi.framework.Version;
    44 
    42 
    45 import com.nokia.carbide.cpp.internal.sdk.ui.Messages;
    43 import com.nokia.carbide.cpp.internal.sdk.ui.Messages;
    46 import com.nokia.carbide.cpp.internal.sdk.ui.SDKUIHelpIds;
    44 import com.nokia.carbide.cpp.internal.sdk.ui.SDKUIHelpIds;
    47 import com.nokia.carbide.cpp.sdk.core.ISDKManager;
       
    48 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
    45 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
    49 import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
    46 import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
    50 import com.nokia.carbide.cpp.sdk.core.SymbianSDKFactory;
    47 import com.nokia.carbide.cpp.sdk.core.SymbianSDKFactory;
    51 import com.nokia.cpp.internal.api.utils.core.HostOS;
    48 import com.nokia.cpp.internal.api.utils.core.HostOS;
    52 import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils;
    49 import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils;
    55  * Dialog that allows the user to add a new Symbian OS SDK or custkit
    52  * Dialog that allows the user to add a new Symbian OS SDK or custkit
    56  * to the devices.xml file.
    53  * to the devices.xml file.
    57  */
    54  */
    58 public class AddSDKDialog extends TrayDialog {
    55 public class AddSDKDialog extends TrayDialog {
    59 
    56 
    60 	private Combo sdkVersionCombo;
       
    61 	private Combo osVersionCombo;
       
    62 	private Combo isDefaultCombo;
       
    63 	private Combo vendorCombo;
       
    64 	private Text deviceIDtext;
    57 	private Text deviceIDtext;
    65 	private Text epocRootText;
    58 	private Text epocRootText;
    66 	private Button browseEPOCROOTButton;
    59 	private Button browseEPOCROOTButton;
    67 	
    60 
    68 	public static final String DEFAULT_YES = "yes"; //$NON-NLS-1$
       
    69 	public static final String DEFAULT_NO  = "no"; //$NON-NLS-1$
       
    70 	public static final String AUTO_DETECT  = "(Auto-Detect)"; //$NON-NLS-1$
       
    71 	
       
    72 	/**
    61 	/**
    73 	 * Create the dialog
    62 	 * Create the dialog
    74 	 * @param parentShell
    63 	 * @param parentShell
    75 	 */
    64 	 */
    76 	public AddSDKDialog(Shell parentShell) {
    65 	public AddSDKDialog(Shell parentShell) {
    77 		super(parentShell);
    66 		super(parentShell);
    78 	}
    67 	}
    79 	
    68 
       
    69 	/**
       
    70 	 * Create contents of the button bar
       
    71 	 * @param parent
       
    72 	 */
       
    73 	@Override
       
    74 	protected void createButtonsForButtonBar(Composite parent) {
       
    75 		createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
       
    76 				true);
       
    77 		createButton(parent, IDialogConstants.CANCEL_ID,
       
    78 				IDialogConstants.CANCEL_LABEL, false);
       
    79 	}
       
    80 
       
    81 	/**
       
    82 	 * Create contents of the dialog
       
    83 	 * @param parent
       
    84 	 */
       
    85 	@Override
       
    86 	protected Control createDialogArea(Composite parent) {
       
    87 		Composite container = (Composite) super.createDialogArea(parent);
       
    88 		final GridLayout gridLayout = new GridLayout();
       
    89 		gridLayout.numColumns = 3;
       
    90 		container.setLayout(gridLayout);
       
    91 
       
    92 		final Label deviceIdLabel = new Label(container, SWT.NONE);
       
    93 		deviceIdLabel.setToolTipText(Messages.getString("AddSDKDialog.Enter_unique_id_for_sdk")); //$NON-NLS-1$
       
    94 		deviceIdLabel.setText(Messages.getString("AddSDKDialog.SDK_ID")); //$NON-NLS-1$
       
    95 
       
    96 		deviceIDtext = new Text(container, SWT.BORDER);
       
    97 		deviceIDtext.setLayoutData(new GridData(263, SWT.DEFAULT));
       
    98 		new Label(container, SWT.NONE);
       
    99 
       
   100 		final Label epocrootLabel = new Label(container, SWT.NONE);
       
   101 		epocrootLabel.setToolTipText(Messages.getString("AddSDKDialog.Enter_location_where_epoc32_folder")); //$NON-NLS-1$
       
   102 		epocrootLabel.setText("EPOCROOT:"); //$NON-NLS-1$
       
   103 
       
   104 		epocRootText = new Text(container, SWT.BORDER);
       
   105 		epocRootText.setLayoutData(new GridData(263, SWT.DEFAULT));
       
   106 
       
   107 		browseEPOCROOTButton = new Button(container, SWT.NONE);
       
   108 		browseEPOCROOTButton.setToolTipText(Messages.getString("AddSDKDialog.Choose_folder_where_epoc32_exists")); //$NON-NLS-1$
       
   109 		browseEPOCROOTButton.setText(Messages.getString("AddSDKDialog.Browse")); //$NON-NLS-1$
       
   110 		addButtonListener(browseEPOCROOTButton);
       
   111 
       
   112 		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, SDKUIHelpIds.SDK_ADD_DIALOG);
       
   113 		return container;
       
   114 	}
       
   115 
    80 	/* (non-Javadoc)
   116 	/* (non-Javadoc)
    81 	 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
   117 	 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
    82 	 */
   118 	 */
    83 	protected void configureShell(Shell shell) {
   119 	protected void configureShell(Shell shell) {
    84 		super.configureShell(shell);
   120 		super.configureShell(shell);
    85 		shell.setText(Messages.getString("AddSDKDialog.Add_New_SDK")); //$NON-NLS-1$
   121 		shell.setText(Messages.getString("AddSDKDialog.Add_New_SDK")); //$NON-NLS-1$
    86 	}
   122 	}
    87 	
   123 
       
   124 	/**
       
   125 	 * Return the initial size of the dialog
       
   126 	 */
       
   127 	@Override
       
   128 	protected Point getInitialSize() {
       
   129 		//return new Point(428, 256);
       
   130 		return super.getInitialSize();
       
   131 	}
       
   132 
       
   133 	/*
       
   134 	 * (non-Javadoc)
       
   135 	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
       
   136 	 */
    88 	@Override
   137 	@Override
    89 	protected void okPressed() {
   138 	protected void okPressed() {
    90 		
   139 		
    91 		if (deviceIDtext.getText().length() > 0){
   140 		if (deviceIDtext.getText().length() > 0){
    92 			if (!isValidIDName(deviceIDtext.getText())){
   141 			if (!isValidIDName(deviceIDtext.getText())){
    93 				return;
   142 				return;
    94 			}
   143 			}
    95 			
       
    96 			if (vendorCombo.getText().length() > 0){
       
    97 				if (!isValidVendorName(vendorCombo.getText())){
       
    98 					return;
       
    99 				}
       
   100 			} else {
       
   101 				MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Missing_Vendor_Name"), Messages.getString("AddSDKDialog.Enter_Vendor_Name")); //$NON-NLS-1$ //$NON-NLS-2$
       
   102 				return;
       
   103 			}
       
   104 		} else {
   144 		} else {
   105 			MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Missing_SDK_ID"), Messages.getString("AddSDKDialog.Enter_SDK_ID")); //$NON-NLS-1$ //$NON-NLS-2$
   145 			MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Missing_SDK_ID"), Messages.getString("AddSDKDialog.Enter_SDK_ID")); //$NON-NLS-1$ //$NON-NLS-2$
   106 			return;
   146 			return;
   107 		}
   147 		}
   108 		
   148 
   109 		if (epocRootText.getText().length() > 1){
   149 		if (epocRootText.getText().length() > 1){
   110 			if (HostOS.IS_WIN32 && epocRootText.getText().charAt(1) != ':'){
   150 			if (HostOS.IS_WIN32 && epocRootText.getText().charAt(1) != ':'){
   111 				MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Malformed_EPOCROOT"), Messages.getString("AddSDKDialog.EPOCROOT_drive_spec")); //$NON-NLS-1$ //$NON-NLS-2$
   151 				MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Malformed_EPOCROOT"), Messages.getString("AddSDKDialog.EPOCROOT_drive_spec")); //$NON-NLS-1$ //$NON-NLS-2$
   112 				return;
   152 				return;
   113 			}
   153 			}
   114 			
       
   115 			if (epocRootText.getText().toUpperCase().endsWith("EPOC32") || epocRootText.getText().toUpperCase().endsWith("EPOC32\\")){ //$NON-NLS-1$ //$NON-NLS-2$
   154 			if (epocRootText.getText().toUpperCase().endsWith("EPOC32") || epocRootText.getText().toUpperCase().endsWith("EPOC32\\")){ //$NON-NLS-1$ //$NON-NLS-2$
   116 				if (!MessageDialog.openConfirm(getShell(), Messages.getString("AddSDKDialog.Possible_wrong_epocroot"), Messages.getString("AddSDKDialog.EPOCROOT_Should_Point"))){ //$NON-NLS-1$ //$NON-NLS-2$
   155 				if (!MessageDialog.openConfirm(getShell(), Messages.getString("AddSDKDialog.Possible_wrong_epocroot"), Messages.getString("AddSDKDialog.EPOCROOT_Should_Point"))){ //$NON-NLS-1$ //$NON-NLS-2$
   117 					return;
   156 					return;
   118 				}
   157 				}
   119 			} else {
   158 			} else {
   125 				}
   164 				}
   126 				if (epocRootFile.toString().indexOf(" ") != -1){
   165 				if (epocRootFile.toString().indexOf(" ") != -1){
   127 					// Paths should not have spaces...
   166 					// Paths should not have spaces...
   128 					MessageDialog.openError(getShell(), "EPOC Root Contains Spaces", Messages.getString("AddSDKDialog.EPOCROOT_contains_spaces")); //$NON-NLS-1$ //$NON-NLS-2$
   167 					MessageDialog.openError(getShell(), "EPOC Root Contains Spaces", Messages.getString("AddSDKDialog.EPOCROOT_contains_spaces")); //$NON-NLS-1$ //$NON-NLS-2$
   129 					return;
   168 					return;
   130 					
       
   131 				}
   169 				}
   132 			}
   170 			}
   133 		} else {
   171 		} else {
   134 			if (epocRootText.getText().length() == 1 && epocRootText.getText().charAt(0) == '\\'){
   172 			if (epocRootText.getText().length() == 1 && epocRootText.getText().charAt(0) == '\\'){
   135 				// OK - Currently accept only a '\'. May need to reconsider side-effects
   173 				// OK - Currently accept only a '\'. May need to reconsider side-effects
   136 			} else {
   174 			} else {
   137 				MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Missing_EPOCROOT"), Messages.getString("AddSDKDialog.Please_enter_an_EPOCROOT")); //$NON-NLS-1$ //$NON-NLS-2$
   175 				MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Missing_EPOCROOT"), Messages.getString("AddSDKDialog.Please_enter_an_EPOCROOT")); //$NON-NLS-1$ //$NON-NLS-2$
   138 				return;
   176 				return;
   139 			}
   177 			}
   140 		}
   178 		}
   141 		
   179 
   142 		// No objections raised, write the new device entry
   180 		// No objections raised, write the new device entry
   143 		String osVersionText = osVersionCombo.getText();
   181 		String vendorName = ISymbianSDK.S60_SDK_NAME;
   144 		Version osVersion;
   182 		Version osVersion = new Version("9.4.0"); //$NON-NLS-1$
   145 		String osBranch = ""; //$NON-NLS-1$
   183 		String osBranch = ""; //$NON-NLS-1$
   146 		if (osVersionText.equals(AUTO_DETECT)){
       
   147 			osVersion = new Version("0.0"); //$NON-NLS-1$
       
   148 		} else {
       
   149 			int len = osVersionText.length();
       
   150 			if (Character.isLetter(osVersionText.charAt(len-1))){
       
   151 				osBranch = osVersionText.substring(len-1);
       
   152 				osVersionText = osVersionText.substring(0, len-1);
       
   153 				osVersion = new Version(osVersionText);
       
   154 			} else {
       
   155 				osVersion = new Version(osVersionText);
       
   156 			}
       
   157 		}
       
   158 		
       
   159 		Version sdkVersion = new Version("0.0"); //$NON-NLS-1$
   184 		Version sdkVersion = new Version("0.0"); //$NON-NLS-1$
   160 		if (!sdkVersionCombo.getText().equals(AUTO_DETECT)){
       
   161 			sdkVersion = new Version(sdkVersionCombo.getText());
       
   162 		}
       
   163 		
       
   164 		ISymbianSDK sdk = SymbianSDKFactory.createInstance(deviceIDtext.getText(), 
   185 		ISymbianSDK sdk = SymbianSDKFactory.createInstance(deviceIDtext.getText(), 
   165 														   epocRootText.getText(), 
   186 														   epocRootText.getText(), 
   166 														   vendorCombo.getText(), 
   187 														   vendorName, 
   167 														   osVersion,
   188 														   osVersion,
   168 														   osBranch,
   189 														   osBranch,
   169 														   sdkVersion, 
   190 														   sdkVersion, 
   170 														   false);
   191 														   false);
   171 		
   192 		sdk.setEnabled(true);
   172 		SDKCorePlugin.getSDKManager().addSDK(sdk);
   193 		SDKCorePlugin.getSDKManager().addSDK(sdk);
   173 		
       
   174 		List<ISymbianSDK> sdkList = SDKCorePlugin.getSDKManager().getSDKList();
   194 		List<ISymbianSDK> sdkList = SDKCorePlugin.getSDKManager().getSDKList();
   175 		if (sdkList != null){
   195 		if (sdkList != null){
   176 			sdkList.add(sdk);
   196 			sdkList.add(sdk);
   177 		}
   197 		}
   178 		
   198 		sdk.setIsDefaultSDK(false);
   179 		if (isDefaultCombo.getText().equals(DEFAULT_YES)){
       
   180 			sdk.setIsDefaultSDK(true);
       
   181 			SDKCorePlugin.getSDKManager().setDefaultSDK(sdk);
       
   182 		} else {
       
   183 			sdk.setIsDefaultSDK(false);
       
   184 		}
       
   185 		
       
   186 		super.okPressed();
   199 		super.okPressed();
   187 	}
   200 	}
   188 	
   201 
   189 	private boolean isValidIDName(String sdkID){
       
   190 		boolean isValid = true;
       
   191 		
       
   192 		
       
   193 		// check for spaces in ID
       
   194 		if (sdkID.contains(" ")){ //$NON-NLS-1$
       
   195 			MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Invalid_SDK_ID"), Messages.getString("AddSDKDialog.SDK_ID_No_Spaces")); //$NON-NLS-1$ //$NON-NLS-2$
       
   196 			return false;
       
   197 		}
       
   198 		
       
   199 		// check that the ID is unique...
       
   200 		for (ISymbianSDK sdk : SDKCorePlugin.getSDKManager().getSDKList()){
       
   201 			if (sdk.getUniqueId().equalsIgnoreCase(sdkID)){
       
   202 				// id already exists, choose a different one...
       
   203 				MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Duplicate_ID"), Messages.getString("AddSDKDialog.Duplicate_ID_Msg")); //$NON-NLS-1$ //$NON-NLS-2$
       
   204 				return false;
       
   205 			}
       
   206 		}
       
   207 		
       
   208 		return isValid;
       
   209 	}
       
   210 	
       
   211 	private boolean isValidVendorName(String vendor){
       
   212 		boolean isValid = true;
       
   213 		
       
   214 		String[] vendorSplit = vendor.split("[.]"); //$NON-NLS-1$
       
   215 		if (vendorSplit.length == 3){ 
       
   216 			if (!vendorSplit[0].toLowerCase().startsWith("com")){ //$NON-NLS-1$
       
   217 			isValid = false;
       
   218 			}
       
   219 		} else {
       
   220 			isValid = false;
       
   221 		}
       
   222 		
       
   223 		if (isValid == false){
       
   224 			MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Invalid_name_attrib"), Messages.getString("AddSDKDialog.Invalid_name_attrib_msg")); //$NON-NLS-1$ //$NON-NLS-2$
       
   225 		}
       
   226 			
       
   227 		return isValid;
       
   228 	}
       
   229 
       
   230 	/**
       
   231 	 * Create contents of the dialog
       
   232 	 * @param parent
       
   233 	 */
       
   234 	@Override
       
   235 	protected Control createDialogArea(Composite parent) {
       
   236 		Composite container = (Composite) super.createDialogArea(parent);
       
   237 		final GridLayout gridLayout = new GridLayout();
       
   238 		gridLayout.numColumns = 3;
       
   239 		container.setLayout(gridLayout);
       
   240 
       
   241 		final Label deviceIdLabel = new Label(container, SWT.NONE);
       
   242 		deviceIdLabel.setToolTipText(Messages.getString("AddSDKDialog.Enter_unique_id_for_sdk")); //$NON-NLS-1$
       
   243 		deviceIdLabel.setText(Messages.getString("AddSDKDialog.SDK_ID")); //$NON-NLS-1$
       
   244 
       
   245 		deviceIDtext = new Text(container, SWT.BORDER);
       
   246 		deviceIDtext.setLayoutData(new GridData(263, SWT.DEFAULT));
       
   247 		new Label(container, SWT.NONE);
       
   248 
       
   249 		final Label epocrootLabel = new Label(container, SWT.NONE);
       
   250 		epocrootLabel.setToolTipText(Messages.getString("AddSDKDialog.Enter_location_where_epoc32_folder")); //$NON-NLS-1$
       
   251 		epocrootLabel.setText("EPOCROOT:"); //$NON-NLS-1$
       
   252 
       
   253 		epocRootText = new Text(container, SWT.BORDER);
       
   254 		epocRootText.setLayoutData(new GridData(263, SWT.DEFAULT));
       
   255 
       
   256 		browseEPOCROOTButton = new Button(container, SWT.NONE);
       
   257 		browseEPOCROOTButton.setToolTipText(Messages.getString("AddSDKDialog.Choose_folder_where_epoc32_exists")); //$NON-NLS-1$
       
   258 		browseEPOCROOTButton.setText(Messages.getString("AddSDKDialog.Browse")); //$NON-NLS-1$
       
   259 		addButtonListener(browseEPOCROOTButton);
       
   260 		
       
   261 		final Label vendorLabel = new Label(container, SWT.NONE);
       
   262 		vendorLabel.setToolTipText(Messages.getString("AddSDKDialog.Enter_name_of_sdk")); //$NON-NLS-1$
       
   263 		vendorLabel.setText(Messages.getString("AddSDKDialog.Vendor")); //$NON-NLS-1$
       
   264 
       
   265 		vendorCombo = new Combo(container, SWT.NONE);
       
   266 		vendorCombo.setLayoutData(new GridData(250, SWT.DEFAULT));
       
   267 		new Label(container, SWT.NONE);
       
   268 		vendorCombo.add(ISymbianSDK.S60_SDK_NAME);
       
   269 		vendorCombo.add(ISymbianSDK.S80_SDK_NAME);
       
   270 		vendorCombo.add(ISymbianSDK.UIQ_SDK_NAME);
       
   271 		vendorCombo.add(ISymbianSDK.TECHVIEW_SDK_NAME);
       
   272 
       
   273 		final Label isDefaultLabel = new Label(container, SWT.NONE);
       
   274 		isDefaultLabel.setToolTipText(Messages.getString("AddSDKDialog.default_label_tooltip")); //$NON-NLS-1$
       
   275 		isDefaultLabel.setText(Messages.getString("AddSDKDialog.is_default")); //$NON-NLS-1$
       
   276 
       
   277 		isDefaultCombo = new Combo(container, SWT.READ_ONLY);
       
   278 		isDefaultCombo.setLayoutData(new GridData(250, SWT.DEFAULT));
       
   279 		new Label(container, SWT.NONE);
       
   280 		isDefaultCombo.add(DEFAULT_YES);
       
   281 		isDefaultCombo.add(DEFAULT_NO);
       
   282 		isDefaultCombo.select(1);
       
   283 
       
   284 		final Label osVersionLabel = new Label(container, SWT.NONE);
       
   285 		osVersionLabel.setToolTipText(Messages.getString("AddSDKDialog.os_version_tooltip")); //$NON-NLS-1$
       
   286 		osVersionLabel.setText(Messages.getString("AddSDKDialog.os_version")); //$NON-NLS-1$
       
   287 		//ISymbianMacroStore sms = 
       
   288 		List<String> osVersions = new ArrayList<String>();
       
   289 		ISDKManager sdkMgr = SDKCorePlugin.getSDKManager();
       
   290 		osVersions = sdkMgr.getSymbianMacroStore().getSupportedOSVersions();
       
   291 
       
   292 		osVersionCombo = new Combo(container, SWT.READ_ONLY);
       
   293 		osVersionCombo.setLayoutData(new GridData(250, SWT.DEFAULT));
       
   294 		new Label(container, SWT.NONE);
       
   295 		osVersionCombo.add(AUTO_DETECT);
       
   296 		
       
   297 		for (String currVer : osVersions){
       
   298 			osVersionCombo.add(currVer);
       
   299 		}
       
   300 		osVersionCombo.select(0);
       
   301 
       
   302 		final Label sdkVersionLabel = new Label(container, SWT.NONE);
       
   303 		sdkVersionLabel.setToolTipText(Messages.getString("AddSDKDialog.select_sdk_tooltip")); //$NON-NLS-1$
       
   304 		sdkVersionLabel.setText(Messages.getString("AddSDKDialog.sdk_version")); //$NON-NLS-1$
       
   305 
       
   306 		sdkVersionCombo = new Combo(container, SWT.READ_ONLY);
       
   307 		sdkVersionCombo.setLayoutData(new GridData(250, SWT.DEFAULT));
       
   308 		sdkVersionCombo.add(AUTO_DETECT);
       
   309 		sdkVersionCombo.select(0);
       
   310 		
       
   311 		List<String> sdkVerList = new ArrayList<String>();
       
   312 		sdkVerList = sdkMgr.getSymbianMacroStore().getSDKVersions();
       
   313 		for (String currVer : sdkVerList){
       
   314 			sdkVersionCombo.add(currVer);
       
   315 		}
       
   316 		
       
   317 		new Label(container, SWT.NONE);
       
   318 		
       
   319 		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, SDKUIHelpIds.SDK_ADD_DIALOG);
       
   320 
       
   321 		
       
   322 		return container;
       
   323 	}
       
   324 
       
   325 	/**
       
   326 	 * Create contents of the button bar
       
   327 	 * @param parent
       
   328 	 */
       
   329 	@Override
       
   330 	protected void createButtonsForButtonBar(Composite parent) {
       
   331 		createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
       
   332 				true);
       
   333 		createButton(parent, IDialogConstants.CANCEL_ID,
       
   334 				IDialogConstants.CANCEL_LABEL, false);
       
   335 	}
       
   336 
       
   337 	/**
       
   338 	 * Return the initial size of the dialog
       
   339 	 */
       
   340 	@Override
       
   341 	protected Point getInitialSize() {
       
   342 		//return new Point(428, 256);
       
   343 		return super.getInitialSize();
       
   344 	}
       
   345 	
       
   346 	/**
   202 	/**
   347 	 * Sets the listener event to a button.
   203 	 * Sets the listener event to a button.
   348 	 * 
   204 	 * 
   349 	 * @param aButton
   205 	 * @param aButton
   350 	 */
   206 	 */
   351 	private void addButtonListener( final Button aButton ) {
   207 	private void addButtonListener(final Button aButton) {
   352 		SelectionListener listener = new SelectionAdapter() {
   208 		SelectionListener listener = new SelectionAdapter() {
   353 			public void widgetSelected( SelectionEvent e )  {
   209 			public void widgetSelected(SelectionEvent e)  {
   354 				if (e.getSource().equals(browseEPOCROOTButton)) {
   210 				if (e.getSource().equals(browseEPOCROOTButton)) {
   355 					browseEPOCROOT();
   211 					browseEPOCROOT();
   356 				}
   212 				}
   357 			}
   213 			}
   358 		};
   214 		};
   359 		aButton.addSelectionListener(listener);
   215 		aButton.addSelectionListener(listener);
   360 	}
   216 	}
   361 	
   217 
   362 	private void browseEPOCROOT(){
   218 	private void browseEPOCROOT(){
   363         DirectoryDialog browseDir = new DirectoryDialog(getShell(), SWT.OPEN);
   219         DirectoryDialog browseDir = new DirectoryDialog(getShell(), SWT.OPEN);
   364         browseDir.setMessage(Messages.getString("AddSDKDialog.Choose_location_for_EPOCROOT")); //$NON-NLS-1$
   220         browseDir.setMessage(Messages.getString("AddSDKDialog.Choose_location_for_EPOCROOT")); //$NON-NLS-1$
   365         BrowseDialogUtils.initializeFrom(browseDir, HostOS.IS_WIN32 ? "C:/Symbian/" : null); //$NON-NLS-1$
   221         BrowseDialogUtils.initializeFrom(browseDir, HostOS.IS_WIN32 ? "C:/Symbian/" : null); //$NON-NLS-1$
   366         String dirText = browseDir.open();
   222         String dirText = browseDir.open();
   367         if (dirText != null){
   223         if (dirText != null){
   368         	epocRootText.setText(dirText);
   224         	epocRootText.setText(dirText);
   369         }
   225         }
   370 	}
   226 	}
   371 
   227 
       
   228 	private boolean isValidIDName(String sdkID){
       
   229 		boolean isValid = true;
       
   230 
       
   231 		// check for spaces in ID
       
   232 		if (sdkID.contains(" ")){ //$NON-NLS-1$
       
   233 			MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Invalid_SDK_ID"), Messages.getString("AddSDKDialog.SDK_ID_No_Spaces")); //$NON-NLS-1$ //$NON-NLS-2$
       
   234 			return false;
       
   235 		}
       
   236 
       
   237 		// check that the ID is unique...
       
   238 		for (ISymbianSDK sdk : SDKCorePlugin.getSDKManager().getSDKList()){
       
   239 			if (sdk.getUniqueId().equalsIgnoreCase(sdkID)){
       
   240 				// id already exists, choose a different one...
       
   241 				MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Duplicate_ID"), Messages.getString("AddSDKDialog.Duplicate_ID_Msg")); //$NON-NLS-1$ //$NON-NLS-2$
       
   242 				return false;
       
   243 			}
       
   244 		}
       
   245 
       
   246 		return isValid;
       
   247 	}
       
   248 
   372 }
   249 }