# HG changeset patch # User stechong # Date 1275517085 18000 # Node ID efad5bbb7534e72f9170486936a1a1c627d65f9e # Parent 587da7cb64b710cb6eada6d0fb04aeed99bc96a7# Parent 9dfc6e3dc4b959f6587ab74e3e19f0f8ebd6d9a7 Merge commit. diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.sdk.core/META-INF/MANIFEST.MF --- a/core/com.nokia.carbide.cpp.sdk.core/META-INF/MANIFEST.MF Wed Jun 02 16:06:56 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/META-INF/MANIFEST.MF Wed Jun 02 17:18:05 2010 -0500 @@ -17,13 +17,13 @@ com.nokia.cpp.utils.ui Bundle-ActivationPolicy: lazy Export-Package: com.nokia.carbide.cpp.internal.api.sdk, - com.nokia.carbide.cpp.internal.sdk.core.model;x-friends:="com.nokia.carbide.cpp.sdk.core.test", - com.nokia.carbide.cpp.internal.sdk.core.xml;x-friends:="com.nokia.carbide.cpp.sdk.core.test", - com.nokia.carbide.cpp.sdk.core, com.nokia.carbide.cpp.internal.sdk.core.gen.Devices;x-friends:="com.nokia.carbide.cpp.sdk.core.test,com.nokia.carbide.cpp.sdk.ui", com.nokia.carbide.cpp.internal.sdk.core.gen.Devices.impl;x-friends:="com.nokia.carbide.cpp.sdk.core.test", com.nokia.carbide.cpp.internal.sdk.core.gen.Devices.util;x-friends:="com.nokia.carbide.cpp.sdk.core.test", com.nokia.carbide.cpp.internal.sdk.core.gen.SymbianMacroStore;x-friends:="com.nokia.carbide.cpp.sdk.core.test", com.nokia.carbide.cpp.internal.sdk.core.gen.SymbianMacroStore.impl;x-friends:="com.nokia.carbide.cpp.sdk.core.test", - com.nokia.carbide.cpp.internal.sdk.core.gen.SymbianMacroStore.util;x-friends:="com.nokia.carbide.cpp.sdk.core.test" + com.nokia.carbide.cpp.internal.sdk.core.gen.SymbianMacroStore.util;x-friends:="com.nokia.carbide.cpp.sdk.core.test", + com.nokia.carbide.cpp.internal.sdk.core.model;x-friends:="com.nokia.carbide.cpp.sdk.core.test,com.nokia.carbide.cpp.sdk.ui", + com.nokia.carbide.cpp.internal.sdk.core.xml;x-friends:="com.nokia.carbide.cpp.sdk.core.test", + com.nokia.carbide.cpp.sdk.core Bundle-ClassPath: sdkCorePlugin.jar diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/AbstractSDKManager.java --- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/AbstractSDKManager.java Wed Jun 02 16:06:56 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/AbstractSDKManager.java Wed Jun 02 17:18:05 2010 -0500 @@ -16,8 +16,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStreamReader; -import java.net.MalformedURLException; -import java.net.URL; import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; @@ -41,10 +39,12 @@ import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; -import org.eclipse.osgi.service.datalocation.Location; +import org.eclipse.core.runtime.jobs.IJobChangeListener; +import org.eclipse.core.runtime.jobs.Job; import org.osgi.framework.Version; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; @@ -61,11 +61,11 @@ import com.nokia.carbide.cpp.internal.api.sdk.SymbianBuildContextDataCache; import com.nokia.carbide.cpp.internal.api.sdk.SymbianMacroStore; import com.nokia.carbide.cpp.sdk.core.ICarbideInstalledSDKChangeListener; +import com.nokia.carbide.cpp.sdk.core.ICarbideInstalledSDKChangeListener.SDKChangeEventType; import com.nokia.carbide.cpp.sdk.core.IRVCTToolChainInfo; import com.nokia.carbide.cpp.sdk.core.ISDKManager; import com.nokia.carbide.cpp.sdk.core.ISymbianSDK; import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin; -import com.nokia.carbide.cpp.sdk.core.ICarbideInstalledSDKChangeListener.SDKChangeEventType; import com.nokia.cpp.internal.api.utils.core.FileUtils; import com.nokia.cpp.internal.api.utils.core.ListenerList; import com.nokia.cpp.internal.api.utils.core.Logging; @@ -77,6 +77,7 @@ protected static List sdkList = new ArrayList(); protected HashMap missingSdkMap = new HashMap(); + protected Job scanJob; protected static final String CARBIDE_SDK_CACHE_FILE_NAME = "carbideSDKCache.xml"; protected static final String SDK_CACHE_ID_ATTRIB = "id"; @@ -125,6 +126,67 @@ public AbstractSDKManager() { macroStore = SymbianMacroStore.getInstance(); + scanJob = new Job ("Scan System Drives") { + @Override + protected IStatus run(IProgressMonitor monitor) { + synchronized (sdkList) + { + ArrayList oldSDKList = new ArrayList(sdkList); + + getSBSv2Version(true); + + if (sdkList != null){ + sdkList.clear(); + } + + if (!doScanSDKs(monitor)) + return Status.OK_STATUS;; + + // now these SDK's are newly added, remove from internal list + for (ISymbianSDK sdk : sdkList) { + if (SDKManagerInternalAPI.getMissingSdk(sdk.getUniqueId()) != null) { + SDKManagerInternalAPI.removeMissingSdk(sdk + .getUniqueId()); + } + } + + // now these SDK's are removed from the old list, add to + // internal list + for (ISymbianSDK oldSdk : oldSDKList) { + boolean found = false; + for (ISymbianSDK sdk : sdkList) { + if (sdk.getUniqueId().equals(oldSdk.getUniqueId())) { + found = true; + break; + } + } + if (found == false) { + SDKManagerInternalAPI.addMissingSdk(oldSdk + .getUniqueId()); + // flush cache + SymbianBuildContextDataCache.refreshForSDKs(new ISymbianSDK[] { oldSdk }); + } + } + } + + // make sure we don't rescan over and over again + hasScannedSDKs = true; + + // tell others about it + fireInstalledSdkChanged(SDKChangeEventType.eSDKScanned); + scanCarbideSDKCache(); + + // Notify any plugins that want to know if the SDKManager has scanned plugins. + if (!sdkHookExtenstionsNotified) { + notifySDKManagerLoaded(); + sdkHookExtenstionsNotified = true; + } + if (monitor.isCanceled()) { + return Status.CANCEL_STATUS; + } + return Status.OK_STATUS; + } + }; } public SymbianMacroStore getSymbianMacroStore(){ @@ -132,61 +194,8 @@ } public void scanSDKs() { - synchronized (sdkList) - { - ArrayList oldSDKList = new ArrayList(sdkList); - - getSBSv2Version(true); - - if (sdkList != null){ - sdkList.clear(); - } - - if (!doScanSDKs()) - return; - - // now these SDK's are newly added, remove from internal list - for (ISymbianSDK sdk : sdkList) { - if (SDKManagerInternalAPI.getMissingSdk(sdk.getUniqueId()) != null) { - SDKManagerInternalAPI.removeMissingSdk(sdk - .getUniqueId()); - } - } - - // now these SDK's are removed from the old list, add to - // internal list - for (ISymbianSDK oldSdk : oldSDKList) { - boolean found = false; - for (ISymbianSDK sdk : sdkList) { - if (sdk.getUniqueId().equals(oldSdk.getUniqueId())) { - found = true; - break; - } - } - if (found == false) { - SDKManagerInternalAPI.addMissingSdk(oldSdk - .getUniqueId()); - // flush cache - SymbianBuildContextDataCache.refreshForSDKs(new ISymbianSDK[] { oldSdk }); - } - } - - - } - - // make sure we don't rescan over and over again - hasScannedSDKs = true; - - // tell others about it - fireInstalledSdkChanged(SDKChangeEventType.eSDKScanned); - scanCarbideSDKCache(); - - // Notify any plugins that want to know if the SDKManager has scanned plugins. - if (!sdkHookExtenstionsNotified) { - notifySDKManagerLoaded(); - sdkHookExtenstionsNotified = true; - } - + scanJob.setSystem(true); + scanJob.schedule(); } /** @@ -195,8 +204,19 @@ * when SDKs are newly missing * @return true if scan succeeded */ - abstract protected boolean doScanSDKs(); + abstract protected boolean doScanSDKs(IProgressMonitor monitor); + public void addScanJobListner(IJobChangeListener listener) { + if (scanJob != null) { + scanJob.addJobChangeListener(listener); + } + } + + public void removeScanJobLisner(IJobChangeListener listener) { + if (scanJob != null) { + scanJob.removeJobChangeListener(listener); + } + } protected void ensureScannedSDKs() { if (!hasScannedSDKs) { @@ -291,17 +311,8 @@ throw new RuntimeException(e); } - // NOTE: If debugging runtime workbench and you clear your configuraiton at each launch - // the data in the configuration location will be lost - Location configurationLocation = Platform.getConfigurationLocation(); try { - URL url = new URL(configurationLocation.getURL(), SDKCorePlugin.PLUGIN_ID); - File configFolder = new File(url.getFile()); - if (!configFolder.exists()) { - configFolder.mkdirs(); - } - - File carbideSDKCacheFile = new File(configFolder, CARBIDE_SDK_CACHE_FILE_NAME); + File carbideSDKCacheFile = new File(System.getProperty("user.home"), CARBIDE_SDK_CACHE_FILE_NAME); if (!carbideSDKCacheFile.exists()){ try { FileUtils.writeFileContents(carbideSDKCacheFile, EMPTY_STRING.toCharArray(), null); @@ -413,84 +424,72 @@ return; } - Location configurationLocation = Platform.getConfigurationLocation(); - try { - - URL url = new URL(configurationLocation.getURL(), SDKCorePlugin.PLUGIN_ID); - File configFolder = new File(url.getFile()); - if (!configFolder.exists()) { - configFolder.mkdirs(); + File carbideSDKCacheFile = new File(System.getProperty("user.home"), CARBIDE_SDK_CACHE_FILE_NAME); + if (!carbideSDKCacheFile.exists()){ + try { + FileUtils.writeFileContents(carbideSDKCacheFile, EMPTY_STRING.toCharArray(), null); + } catch (CoreException e){ + e.printStackTrace(); } + } + + Document d = docBuilder.newDocument(); + Node sdks = d.appendChild(d.createElement("sdks")); - File carbideSDKCacheFile = new File(configFolder, CARBIDE_SDK_CACHE_FILE_NAME); - if (!carbideSDKCacheFile.exists()){ - try { - FileUtils.writeFileContents(carbideSDKCacheFile, EMPTY_STRING.toCharArray(), null); - } catch (CoreException e){ - e.printStackTrace(); - } - } - - Document d = docBuilder.newDocument(); - Node sdks = d.appendChild(d.createElement("sdks")); + synchronized(sdkList) + { + for (ISymbianSDK currSDK: sdkList) { + Node sdk = sdks.appendChild(d.createElement("sdk")); + NamedNodeMap attribs = sdk.getAttributes(); + Node idNode = d.createAttribute(SDK_CACHE_ID_ATTRIB); + idNode.setNodeValue(currSDK.getUniqueId()); + attribs.setNamedItem(idNode); + + // Hide the build config from view in the build config list? + Node enabledNode = d.createAttribute(SDK_CACHE_ENABLED_ATTRIB); + if (true == currSDK.isEnabled()) { + enabledNode.setNodeValue("true"); + } else { + enabledNode.setNodeValue("false"); + } + attribs.setNamedItem(enabledNode); - synchronized(sdkList) - { - for (ISymbianSDK currSDK: sdkList) { - Node sdk = sdks.appendChild(d.createElement("sdk")); - NamedNodeMap attribs = sdk.getAttributes(); - Node idNode = d.createAttribute(SDK_CACHE_ID_ATTRIB); - idNode.setNodeValue(currSDK.getUniqueId()); - attribs.setNamedItem(idNode); - - // Hide the build config from view in the build config list? - Node enabledNode = d.createAttribute(SDK_CACHE_ENABLED_ATTRIB); - if (true == currSDK.isEnabled()) { - enabledNode.setNodeValue("true"); - } else { - enabledNode.setNodeValue("false"); - } - attribs.setNamedItem(enabledNode); - - Node wasScannedNode = d.createAttribute(SDK_SCANNED_FOR_PLUGINS); - if (true == currSDK.isPreviouslyScanned()) { - wasScannedNode.setNodeValue("true"); - } else { - wasScannedNode.setNodeValue("false"); - } - attribs.setNamedItem(wasScannedNode); - - Node osVerNode = d.createAttribute(SDK_CACHE_OS_VERSION_ATTRIB); - osVerNode.setNodeValue(currSDK.getOSVersion().toString()); - attribs.setNamedItem(osVerNode); - - Node osBranchNode = d.createAttribute(SDK_CACHE_OS_BRANCH_ATTRIB); - osBranchNode.setNodeValue(currSDK.getSDKOSBranch()); - attribs.setNamedItem(osBranchNode); - - Node sdkVerNode = d.createAttribute(SDK_CACHE_SDK_VERSION_ATTRIB); - sdkVerNode.setNodeValue(currSDK.getSDKVersion().toString()); - attribs.setNamedItem(sdkVerNode); - - if (!isEPOCRootFixed()) { - Node sdkEpocRootNode = d.createAttribute(SDK_CACHE_EPOCROOT_ATTRIB); - sdkEpocRootNode.setNodeValue(currSDK.getEPOCROOT()); - attribs.setNamedItem(sdkEpocRootNode); - } + Node wasScannedNode = d.createAttribute(SDK_SCANNED_FOR_PLUGINS); + if (true == currSDK.isPreviouslyScanned()) { + wasScannedNode.setNodeValue("true"); + } else { + wasScannedNode.setNodeValue("false"); + } + attribs.setNamedItem(wasScannedNode); + + Node osVerNode = d.createAttribute(SDK_CACHE_OS_VERSION_ATTRIB); + osVerNode.setNodeValue(currSDK.getOSVersion().toString()); + attribs.setNamedItem(osVerNode); + + Node osBranchNode = d.createAttribute(SDK_CACHE_OS_BRANCH_ATTRIB); + osBranchNode.setNodeValue(currSDK.getSDKOSBranch()); + attribs.setNamedItem(osBranchNode); + + Node sdkVerNode = d.createAttribute(SDK_CACHE_SDK_VERSION_ATTRIB); + sdkVerNode.setNodeValue(currSDK.getSDKVersion().toString()); + attribs.setNamedItem(sdkVerNode); + + if (!isEPOCRootFixed()) { + Node sdkEpocRootNode = d.createAttribute(SDK_CACHE_EPOCROOT_ATTRIB); + sdkEpocRootNode.setNodeValue(currSDK.getEPOCROOT()); + attribs.setNamedItem(sdkEpocRootNode); } } - DOMSource domSource = new DOMSource(d); - TransformerFactory transFactory = TransformerFactory.newInstance(); - Result fileResult = new StreamResult(carbideSDKCacheFile); - try { - transFactory.newTransformer().transform(domSource, fileResult); - } catch (TransformerConfigurationException e) { - ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, SDKCorePlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e)); - } catch (TransformerException e) { - ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, SDKCorePlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e)); - } - } catch (MalformedURLException e){ - + } + DOMSource domSource = new DOMSource(d); + TransformerFactory transFactory = TransformerFactory.newInstance(); + Result fileResult = new StreamResult(carbideSDKCacheFile); + try { + transFactory.newTransformer().transform(domSource, fileResult); + } catch (TransformerConfigurationException e) { + ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, SDKCorePlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e)); + } catch (TransformerException e) { + ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, SDKCorePlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e)); } } diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SDKManager.java --- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SDKManager.java Wed Jun 02 16:06:56 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SDKManager.java Wed Jun 02 17:18:05 2010 -0500 @@ -27,6 +27,7 @@ import org.eclipse.cdt.utils.WindowsRegistry; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; @@ -36,7 +37,9 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; +import com.nokia.carbide.cpp.internal.sdk.core.gen.Devices.DefaultType; import com.nokia.carbide.cpp.internal.sdk.core.gen.Devices.DeviceType; +import com.nokia.carbide.cpp.internal.sdk.core.gen.Devices.DevicesFactory; import com.nokia.carbide.cpp.internal.sdk.core.gen.Devices.DevicesType; import com.nokia.carbide.cpp.internal.sdk.core.xml.DevicesLoader; import com.nokia.carbide.cpp.sdk.core.ISymbianSDK; @@ -54,7 +57,12 @@ private static final String WINDOWS_SYSTEM_ROOT_KEY = "SystemRoot"; private static final String EMPTY_DEVICES_XML_CONTENT = ""; - + + private static final String QMAKE_FILE = "epoc32/tools/qt/qmake" + HostOS.EXE_EXT; //$NON-NLS-1$ + private static final String MIFCONV_FILE = "epoc32/tools/mifconv" + HostOS.EXE_EXT; //$NON-NLS-1$ + private static final String ABLD_FILE = "epoc32/tools/abld.pl"; //$NON-NLS-1$ + private static final long VALID_ABLD_SIZE = 1024; + static boolean hasPromptedForDevicesXML = false; // make sure we only ask once at startup if devices.xml does not exist long devicesXLMLastModified; @@ -71,11 +79,10 @@ public SDKManager() { super(); checkPerlInstallation(); - } - protected boolean doScanSDKs() { - + protected boolean doScanSDKs(IProgressMonitor monitor) { + boolean result = true; DevicesType devicesType; try { File devicesFile = getDevicesXMLFile(); @@ -87,25 +94,25 @@ hasPromptedForDevicesXML = true; doAsynchPromptCreateDevicesXML(); } - return false; // no devices.xml file.. + result = false; // no devices.xml file.. + } else { + devicesXLMLastModified = devicesFile.lastModified(); + devicesType = DevicesLoader.loadDevices(devicesFile.toURL()); + EList devices = devicesType.getDevice(); + for (Iterator iter = devices.iterator(); iter.hasNext();) { + SymbianSDK sdk = new SymbianSDK((DeviceType) iter.next()); + sdkList.add(sdk); + } } + } catch (Exception e) { + logError("Failed to scan devices.xml", e); + result = false; + } - devicesXLMLastModified = devicesFile.lastModified(); - devicesType = DevicesLoader.loadDevices(devicesFile.toURL()); - EList devices = devicesType.getDevice(); - for (Iterator iter = devices.iterator(); iter.hasNext();) { - SymbianSDK sdk = new SymbianSDK((DeviceType) iter.next()); - sdkList.add(sdk); - } - - return true; - } catch (Exception e) { - logError("Failed to scan SDKs", e); - return false; - } + doScanDrives(monitor); + return result; } - public void updateSDK(ISymbianSDK sdk) { try { File devicesFile = getDevicesXMLFile(); @@ -416,4 +423,101 @@ protected boolean isEPOCRootFixed() { return true; } + + /** + * Scan system drives for installed SDKs + */ + protected void doScanDrives(IProgressMonitor monitor) { + File[] drives = getSystemDrives(); + monitor.beginTask("Scanning system drives for installed SDKs", drives.length); + for (File drive : drives) { + if (!isEPOCRoot(drive)) { + continue; + } + + DeviceType deviceType = DevicesFactory.eINSTANCE.createDeviceType(); + deviceType.setAlias(drive.toString()); + deviceType.setDefault(DefaultType.NO_LITERAL); + deviceType.setEpocroot(drive.getAbsolutePath()); + deviceType.setId(drive.toString().charAt(0) + "_SDK"); + deviceType.setName("com.nokia.s60"); + deviceType.setToolsroot(drive.getAbsolutePath()); + deviceType.setUserdeletable("false"); + deviceType.setUserdeletetable("false"); + ISymbianSDK sdk = new SymbianSDK(deviceType); + if (!isSupportedSDK(sdk)) { + continue; + } + if (isInSDKList(sdk)) { + continue; + } + + sdkList.add(sdk); + monitor.worked(1); + if (monitor.isCanceled()) { + monitor.done(); + return; + } + } + monitor.done(); + } + + private File[] getSystemDrives() { + if (HostOS.IS_WIN32) { + return File.listRoots(); + } + return new File[0]; + } + + private boolean hasAbldSupport(ISymbianSDK sdk) { + File abld = new File(sdk.getEPOCROOT(), ABLD_FILE); + if (abld.exists()) { + long size = abld.length(); + if (size >= VALID_ABLD_SIZE) + return true; + } + return false; + } + + private boolean hasQmake(ISymbianSDK sdk) { + File qmake = new File(sdk.getEPOCROOT(), QMAKE_FILE); + if (qmake.exists()) { + return true; + } + return false; + } + + private boolean hasRaptor(ISymbianSDK sdk) { + File mifconv = new File(sdk.getEPOCROOT(), MIFCONV_FILE); + if (mifconv.exists()) { + return true; + } + return false; + } + + private boolean isEPOCRoot(File drive) { + File epocRoot = new File(drive, "epoc32"); + if (epocRoot.exists()) { + return true; + } else { + return false; + } + } + + private boolean isInSDKList(ISymbianSDK sdk) { + for (ISymbianSDK entry : sdkList) { + if (entry.getEPOCROOT().equalsIgnoreCase(sdk.getEPOCROOT())) { + return true; + } + } + return false; + } + + private boolean isSupportedSDK(ISymbianSDK sdk) { + if (!hasAbldSupport(sdk) || hasQmake(sdk) || hasRaptor(sdk)) { + return true; + } + return false; + } + } diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SDKManagerRaptorOnly.java --- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SDKManagerRaptorOnly.java Wed Jun 02 16:06:56 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SDKManagerRaptorOnly.java Wed Jun 02 17:18:05 2010 -0500 @@ -19,6 +19,7 @@ import java.io.File; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Display; @@ -39,7 +40,7 @@ * @see com.nokia.carbide.cpp.internal.sdk.core.model.AbstractSDKManager#doScanSDKs() */ @Override - protected boolean doScanSDKs() { + protected boolean doScanSDKs(IProgressMonitor monitor) { String message = SBSv2Utils.scanSBSv2(); if (message != null) { diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.sdk.ui/META-INF/MANIFEST.MF --- a/core/com.nokia.carbide.cpp.sdk.ui/META-INF/MANIFEST.MF Wed Jun 02 16:06:56 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.ui/META-INF/MANIFEST.MF Wed Jun 02 17:18:05 2010 -0500 @@ -10,6 +10,7 @@ org.eclipse.core.runtime, org.eclipse.core.resources, com.nokia.carbide.cpp.sdk.core, + com.nokia.carbide.cpp.ui, com.nokia.carbide.templatewizard, com.nokia.cpp.utils.core, com.nokia.cpp.utils.ui diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.sdk.ui/plugin.properties --- a/core/com.nokia.carbide.cpp.sdk.ui/plugin.properties Wed Jun 02 16:06:56 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.ui/plugin.properties Wed Jun 02 17:18:05 2010 -0500 @@ -1,6 +1,6 @@ // Copyright 2007 Nokia, Inc. -SDKUIPlugin.SDK_Preferences=SDK Preferences +SDKUIPlugin.SDK_Preferences=Symbian SDKs SDKUIPlugin.Platform_Filtering_Preferences=Platform Filtering Preferences #Keywords for Carbide preferences diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKPreferencePage.java --- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKPreferencePage.java Wed Jun 02 16:06:56 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKPreferencePage.java Wed Jun 02 17:18:05 2010 -0500 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -16,198 +16,281 @@ */ package com.nokia.carbide.cpp.internal.sdk.ui; -import java.io.*; -import java.util.*; +import java.io.File; +import java.text.MessageFormat; +import java.util.Iterator; import java.util.List; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.IJobChangeListener; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.viewers.*; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ColumnViewer; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.*; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.PlatformUI; import com.nokia.carbide.cpp.internal.api.sdk.SymbianBuildContextDataCache; import com.nokia.carbide.cpp.internal.sdk.core.model.SDKManager; -import com.nokia.carbide.cpp.sdk.core.*; +import com.nokia.carbide.cpp.sdk.core.ISDKManager; +import com.nokia.carbide.cpp.sdk.core.ISymbianSDK; +import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin; import com.nokia.carbide.cpp.sdk.ui.SDKUIPlugin; import com.nokia.carbide.cpp.sdk.ui.shared.AddSDKDialog; +import com.nokia.carbide.cpp.ui.TextAndDialogCellEditor; +import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils; public class SDKPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - ISDKManager sdkMgr; + private class SDKLabelProvider extends LabelProvider implements ITableLabelProvider { + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + public String getColumnText(Object element, int columnIndex) { + ISymbianSDK sdk = (ISymbianSDK) element; + switch (columnIndex) { + case 1: + return sdk.getUniqueId(); + case 2: + return sdk.getEPOCROOT(); + default: + return ""; + } + } + } + + private class IdEditingSupport extends EditingSupport { + private TextCellEditor editor; + + public IdEditingSupport(ColumnViewer viewer) { + super(viewer); + editor = new TextCellEditor((Composite) viewer.getControl()); + } + + @Override + protected boolean canEdit(Object element) { + if (element instanceof ISymbianSDK) { + return true; + } + return false; + } + + @Override + protected CellEditor getCellEditor(Object element) { + return editor; + } + + @Override + protected Object getValue(Object element) { + ISymbianSDK sdk = (ISymbianSDK) element; + return sdk.getUniqueId(); + } + + @Override + protected void setValue(Object element, Object value) { + ISymbianSDK sdk = (ISymbianSDK) element; + sdk.setUniqueID(value.toString()); + SDKCorePlugin.getSDKManager().updateSDK(sdk); + getViewer().refresh(); + } + } + + private class LocationEditingSupport extends EditingSupport { + private LocationCellEditor editor; + + public LocationEditingSupport(ColumnViewer viewer) { + super(viewer); + editor = new LocationCellEditor((Composite) viewer.getControl()); + } + + @Override + protected boolean canEdit(Object element) { + if (element instanceof ISymbianSDK) { + return true; + } + return false; + } + + @Override + protected CellEditor getCellEditor(Object element) { + return editor; + } + + @Override + protected Object getValue(Object element) { + ISymbianSDK sdk = (ISymbianSDK) element; + return sdk.getEPOCROOT(); + } + + @Override + protected void setValue(Object element, Object value) { + ISymbianSDK sdk = (ISymbianSDK) element; + sdk.setEPOCROOT(value.toString()); + SDKCorePlugin.getSDKManager().updateSDK(sdk); + getViewer().refresh(); + } + } + + private class LocationCellEditor extends TextAndDialogCellEditor { + private Button button; + private Text text; + + public LocationCellEditor(Composite parent) { + super(parent); + } + + @Override + protected Control createContents(Composite parent) { + text = (Text) super.createContents(parent); + return text; + } + + @Override + protected Control createControl(Composite parent) { + Control control = super.createControl(parent); + button = getButton(); + button.setText(Messages.getString("SDKPreferencePage.Browse_Location_Label")); //$NON-NLS-1$ + return control; + } + + @Override + protected Object openDialogBox(Control cellEditorWindow) { + DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN); + BrowseDialogUtils.initializeFrom(dialog, text); + return dialog.open(); + } + } + + private class ScanJobListener implements IJobChangeListener { + public void done(IJobChangeEvent event) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + rescanSDKs(); + } + }); + } + + public void aboutToRun(IJobChangeEvent event) {} + public void awake(IJobChangeEvent event) {} + public void running(IJobChangeEvent event) {} + public void scheduled(IJobChangeEvent event) {} + public void sleeping(IJobChangeEvent event) {} + + } + + private IPreferenceStore prefsStore; + private ISDKManager sdkMgr; + private List sdkList; + private ScanJobListener scanJobListner; + private boolean scanForNewPlugins; private CheckboxTableViewer sdkListTableViewer; - private List sdkList; - private Button sdkpropertiesButton; - private Button removeSdkButton; - private Button addNewSdkButton; - private Button rescanNowButton; - - private Label epocrootLabel; - private Label availablePlatformsLabel; - private Label osVersionLabel; - private Label diagnosticCheckLabel; - - private Button listenForDevicesXMLChangeButton; - - private static final String EPOCROOT_LABEL = "EPOCROOT: "; //$NON-NLS-1$ - private static final String PLATFORMS_LABEL = "Available Platforms: "; //$NON-NLS-1$ - private static final String DIAGNOSTIC_CHECK_LABEL = "Diagnostic Check: "; //$NON-NLS-1$ - private static final String OS_VERSION_LABEL = "OS Version: "; //$NON-NLS-1$ - - private Color RED; - private Color BLACK; - private Color GRAY; - Shell shell; - + private Button addButton; + private Button deleteButton; + private Button propertiesButton; + private Button scanForNewPluginsButton; + private Button rescanButton; + private Label iconLabel; + private Label statusLabel; + + private Color red; + private Color black; + private Color gray; + + /** + * Constructor. + */ public SDKPreferencePage() { super(); - - } - - @Override - protected Control createContents(Composite parent) { - return null; + scanJobListner = new ScanJobListener(); } - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + /* + * (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite) */ - public void init(IWorkbench workbench) { - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - - IPreferenceStore prefsStore = SDKUIPlugin.getDefault().getPreferenceStore(); + public void createControl(Composite parent){ + prefsStore = SDKUIPlugin.getDefault().getPreferenceStore(); sdkMgr = SDKCorePlugin.getSDKManager(); if (sdkMgr == null){ return; } - - shell = parent.getShell(); sdkList = sdkMgr.getSDKList(); - RED = shell.getDisplay().getSystemColor(SWT.COLOR_RED); - BLACK = shell.getDisplay().getSystemColor(SWT.COLOR_BLACK); - GRAY = shell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); - - // check that devices.xml actually exists - if (sdkMgr instanceof SDKManager) - ((SDKManager) sdkMgr).checkDevicesXMLExistAndCreate(); - - Composite content = new Composite(parent, SWT.NONE); - setControl(content); - final GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - content.setLayout(gridLayout); - - final Group availableSymbianOsGroup = new Group(content, SWT.NONE); - availableSymbianOsGroup.setToolTipText(Messages.getString("SDKPreferencePage.OS_Group_ToolTip")); //$NON-NLS-1$ - final GridData availableSymbianOsGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); - availableSymbianOsGridData.widthHint = 350; - availableSymbianOsGroup.setText(Messages.getString("SDKPreferencePage.Available_SDKs_Label")); //$NON-NLS-1$ - availableSymbianOsGroup.setLayoutData(availableSymbianOsGridData); - availableSymbianOsGroup.setLayout(new GridLayout()); - - sdkListTableViewer = CheckboxTableViewer.newCheckList(availableSymbianOsGroup, SWT.BORDER); - sdkListTableViewer.getTable().setLayoutData(availableSymbianOsGridData); - - final Composite composite = new Composite(content, SWT.NONE); - composite.setLayoutData(new GridData()); - final GridLayout gridLayout_1 = new GridLayout(); - gridLayout_1.makeColumnsEqualWidth = true; - composite.setLayout(gridLayout_1); + if (sdkMgr instanceof SDKManager) { + SDKManager mgr = (SDKManager) sdkMgr; + mgr.addScanJobListner(scanJobListner); + } - removeSdkButton = new Button(composite, SWT.NONE); - removeSdkButton.setToolTipText(Messages.getString("SDKPreferencePage.Delete_SDK_ToolTip")); //$NON-NLS-1$ - final GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, false); - removeSdkButton.setLayoutData(gridData); - removeSdkButton.setText(Messages.getString("SDKPreferencePage.Remove_SDK_Label")); //$NON-NLS-1$ - addButtonListener(removeSdkButton); - - addNewSdkButton = new Button(composite, SWT.NONE); - addNewSdkButton.setToolTipText(Messages.getString("SDKPreferencePage.Add_New_SDK_ToolTip")); //$NON-NLS-1$ - addNewSdkButton.setLayoutData(gridData); - addNewSdkButton.setText(Messages.getString("SDKPreferencePage.Add_New_SDK_Label")); //$NON-NLS-1$ - addButtonListener(addNewSdkButton); - - sdkpropertiesButton = new Button(composite, SWT.NONE); - sdkpropertiesButton.setToolTipText(Messages.getString("SDKPreferencePage.SDK_Props_Button_ToolTip")); //$NON-NLS-1$ - sdkpropertiesButton.setLayoutData(gridData); - sdkpropertiesButton.setText(Messages.getString("SDKPreferencePage.SDK_Props_Button_Label")); //$NON-NLS-1$ - addButtonListener(sdkpropertiesButton); - - final Group sdkInformationGroup = new Group(content, SWT.NONE); - sdkInformationGroup.setToolTipText(Messages.getString("SDKPreferencePage.SDK_Info_ToolTip")); //$NON-NLS-1$ - final GridData sdkInfoGridData = new GridData(SWT.FILL, SWT.FILL, true, true); - sdkInfoGridData.widthHint = 350; - sdkInformationGroup.setText(Messages.getString("SDKPreferencePage.SDK_Info_Label")); //$NON-NLS-1$ - sdkInformationGroup.setLayoutData(sdkInfoGridData); - sdkInformationGroup.setLayout(new GridLayout()); - - epocrootLabel = new Label(sdkInformationGroup, SWT.WRAP); - epocrootLabel.setToolTipText(Messages.getString("SDKPreferencePage.EPOC32_Loc_ToolTip")); //$NON-NLS-1$ - epocrootLabel.setLayoutData(new GridData(300, SWT.DEFAULT)); - epocrootLabel.setText("EPOCROOT:"); //$NON-NLS-1$ + super.createControl(parent); - osVersionLabel = new Label(sdkInformationGroup, SWT.WRAP); - osVersionLabel.setToolTipText(Messages.getString("SDKPreferencePage.OSVesions_ToolTip")); //$NON-NLS-1$ - osVersionLabel.setLayoutData(new GridData(300, SWT.DEFAULT)); - osVersionLabel.setText(Messages.getString("SDKPreferencePage.OSVersion_Label")); //$NON-NLS-1$ - - availablePlatformsLabel = new Label(sdkInformationGroup, SWT.WRAP); - availablePlatformsLabel.setToolTipText(Messages.getString("SDKPreferencePage.Platforms_ToolTip")); //$NON-NLS-1$ - availablePlatformsLabel.setLayoutData(new GridData(300, SWT.DEFAULT)); - availablePlatformsLabel.setText(Messages.getString("SDKPreferencePage.Available_Platforms")); //$NON-NLS-1$ - - diagnosticCheckLabel = new Label(sdkInformationGroup, SWT.WRAP); - diagnosticCheckLabel.setToolTipText(Messages.getString("SDKPreferencePage.Diagnostic_Check_ToolTip")); //$NON-NLS-1$ - diagnosticCheckLabel.setLayoutData(sdkInfoGridData); - diagnosticCheckLabel.setText(Messages.getString("SDKPreferencePage.Diagnostic_Check_Label")); //$NON-NLS-1$ - new Label(content, SWT.NONE); + // Hide "Restore Defaults" button + getDefaultsButton().setVisible(false); - listenForDevicesXMLChangeButton = new Button(content, SWT.CHECK); - listenForDevicesXMLChangeButton.setText(Messages.getString("SDKPreferencePage.listerForDevicesXML")); - listenForDevicesXMLChangeButton.setToolTipText(Messages.getString("SDKPreferencePage.listerForDevicesXML_Tooltip")); //$NON-NLS-1$ - listenForDevicesXMLChangeButton.setSelection(prefsStore.getBoolean(SDKUIPreferenceConstants.LISTEN_FOR_DEVICES_XML_CHANGE)); - - new Label(content, SWT.WRAP); // filler - - rescanNowButton = new Button(content, SWT.NONE); - rescanNowButton.setToolTipText(Messages.getString("SDKPreferencePage.Rescan_Button_ToolTip")); //$NON-NLS-1$ - rescanNowButton.setLayoutData(new GridData()); - rescanNowButton.setText(Messages.getString("SDKPreferencePage.Rescan_Button_Label")); //$NON-NLS-1$ - addButtonListener(rescanNowButton); - new Label(content, SWT.NONE); - - // Build the checked table of SDKs - addSDKComponentTableItems(); - - ISymbianSDK sdk = (ISymbianSDK)sdkListTableViewer.getElementAt(0); - if (sdk != null){ - sdkListTableViewer.setSelection(new StructuredSelection(sdk), true); - setSelectedSDKInfoText(sdk); - } - - PlatformUI.getWorkbench().getHelpSystem().setHelp(super.getControl(), SDKUIHelpIds.SDK_PREFERENCES_PAGE); } - + + /* + * (non-Javadoc) + * @see org.eclipse.jface.dialogs.DialogPage#dispose() + */ + public void dispose() { + if (sdkMgr != null && sdkMgr instanceof SDKManager){ + SDKManager mgr = (SDKManager) sdkMgr; + mgr.removeScanJobLisner(scanJobListner); + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench arg0) { + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#performOk() + */ public boolean performOk() { - - IPreferenceStore prefsStore = SDKUIPlugin.getDefault().getPreferenceStore(); - prefsStore.setValue(SDKUIPreferenceConstants.LISTEN_FOR_DEVICES_XML_CHANGE, listenForDevicesXMLChangeButton.getSelection()); - + // Save preference page specific values; + prefsStore.setValue(SDKUIPreferenceConstants.SCAN_FOR_NEW_PLUGINS, scanForNewPluginsButton.getSelection()); + + // Remember which SDK is enabled for (ISymbianSDK sdk : sdkMgr.getSDKList()){ sdk.setEnabled(false); } @@ -218,341 +301,329 @@ sdk.setEnabled(true); } } - - ISDKManager sdkMgr =SDKCorePlugin.getSDKManager(); + + // Update cached SDK info sdkMgr.updateCarbideSDKCache(); - return super.performOk(); } - - private void addSDKComponentTableItems() { - sdkListTableViewer.setContentProvider(new SDKTableComponentsContentProvider()); - sdkListTableViewer.setLabelProvider(new SDKTableComponentsLabelProvider()); - Table lTable = sdkListTableViewer.getTable(); - - sdkList = SDKCorePlugin.getSDKManager().getSDKList(); - sdkListTableViewer.setInput(sdkList); - lTable.setToolTipText(Messages.getString("SDKPreferencePage.List_of_Available_SDKs_ToolTip")); //$NON-NLS-1$ - lTable.setVisible(true); - addSDKTableViewerSelectionListener(); - //lTable.setLayoutData(grid); - if (sdkList == null || sdkList.size() == 0){ - diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + Messages.getString("SDKPreferencePage.No_SDKs_Available")); //$NON-NLS-1$ - diagnosticCheckLabel.setForeground(RED); - diagnosticCheckLabel.setBackground(GRAY); - } else { - setCheckBoxes(sdkList); - } - } - - /** - * Sets the checkbox state for enabled SDKs. + + /* + * (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) */ - private void setCheckBoxes(List sdkList) { - List sdkListCopy = new ArrayList(); - for (ISymbianSDK sdkCheck : sdkList){ - if (sdkCheck.isEnabled()){ - sdkListCopy.add(sdkCheck); - } - } - sdkListTableViewer.setCheckedElements(sdkListCopy.toArray(new ISymbianSDK[sdkListCopy.size()])); - } - - /** - * Extends LabelProvider with the default implementation - * and implementsITableLabelProvider with the methods - * to provide the text and/or image for each column of a given element. - * Used by table viewers. - */ - - static class SDKTableComponentsLabelProvider extends LabelProvider implements ITableLabelProvider, ITableColorProvider { + @Override + protected Control createContents(Composite parent) { + // Set up colors used in this preference page + Shell shell = parent.getShell(); + red = shell.getDisplay().getSystemColor(SWT.COLOR_RED); + black = shell.getDisplay().getSystemColor(SWT.COLOR_BLACK); + gray = shell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); + + Composite content = new Composite(parent, SWT.NONE); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + content.setLayout(gridLayout); + + // SDK table + sdkListTableViewer = CheckboxTableViewer.newCheckList(content, + SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); + createSDKTable(); - /** - * Returns the label image for the given column of the given element. - * The default implementation returns null. - * - * @return image object - */ - public Image getColumnImage(Object element, int columnIndex) { - return null; - } + // Buttons composite + Composite composite1 = new Composite(content, SWT.NONE); + composite1.setLayoutData(new GridData()); + gridLayout = new GridLayout(); + gridLayout.makeColumnsEqualWidth = true; + composite1.setLayout(gridLayout); + GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, false); - /** - * Returns the label text for the given column of the given element. - * - * @return string is the label text for the given column. - */ - public String getColumnText(Object arg0, int column) { - if (arg0 instanceof ISymbianSDK){ - ISymbianSDK sdk = (ISymbianSDK)arg0; - return sdk.getUniqueId(); - } - - return ""; //$NON-NLS-1$ - } + // Add button + addButton = new Button(composite1, SWT.NONE); + addButton.setLayoutData(gridData); + addButton.setText(Messages.getString("SDKPreferencePage.Add_Button_Label")); //$NON-NLS-1$ + addButton.setToolTipText(Messages.getString("SDKPreferencePage.Add_Button_ToolTip")); //$NON-NLS-1$ + addButtonListener(addButton); + + // Delete button + deleteButton = new Button(composite1, SWT.NONE); + deleteButton.setLayoutData(gridData); + deleteButton.setText(Messages.getString("SDKPreferencePage.Delete_Button_Label")); //$NON-NLS-1$ + deleteButton.setToolTipText(Messages.getString("SDKPreferencePage.Delete_Button_ToolTip")); //$NON-NLS-1$ + addButtonListener(deleteButton); + + // Properties button + propertiesButton = new Button(composite1, SWT.NONE); + propertiesButton.setLayoutData(gridData); + propertiesButton.setText(Messages.getString("SDKPreferencePage.Properties_Button_Label")); //$NON-NLS-1$ + propertiesButton.setToolTipText(Messages.getString("SDKPreferencePage.Properties_Button_ToolTip")); //$NON-NLS-1$ + addButtonListener(propertiesButton); - private Color lBlack = Display.getDefault().getSystemColor(SWT.COLOR_BLACK); - private Color lRed = Display.getDefault().getSystemColor(SWT.COLOR_RED); + // Status and Rescan composite + Composite composite2 = new Composite(content, SWT.NONE); + gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + gridData.widthHint = 350; + gridData.heightHint = 50; + composite2.setLayoutData(gridData); + gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + composite2.setLayout(gridLayout); + + // IStatus icon label + iconLabel = new Label(composite2, SWT.NONE); + // IStatus text label + statusLabel = new Label(composite2, SWT.WRAP); + gridData = new GridData(SWT.LEFT, SWT.TOP, true, false); + gridData.verticalSpan = 2; + statusLabel.setLayoutData(gridData); + + new Label(content, SWT.WRAP); // filler - public Color getForeground(Object obj, int index) { - if (obj instanceof ISymbianSDK) { - ISymbianSDK sdk = (ISymbianSDK)obj; - File epocRootTest = new File(sdk.getEPOCROOT()); - if ((sdk.getAvailablePlatforms().size() <= 0) || !epocRootTest.exists()) { - // There are no build configs and/or no epocroot exists - return lRed; - } else { - return lBlack; - } - } - return null; - } - - public Color getBackground(Object element, int columnIndex) { - return null; - } - } - - /** - * This implementation of IStructuredContentProvider handles - * the case where the viewer input is an unchanging array or collection of elements. - * - */ - static class SDKTableComponentsContentProvider implements IStructuredContentProvider { - + // Scan SDK checkbox + scanForNewPluginsButton = new Button(content, SWT.CHECK); + scanForNewPluginsButton.setText(Messages.getString("SDKPreferencePage.ScanForNewPlugins_Button_Label")); //$NON-NLS-1$ + scanForNewPluginsButton.setSelection(prefsStore.getBoolean(SDKUIPreferenceConstants.SCAN_FOR_NEW_PLUGINS)); + addButtonListener(scanForNewPluginsButton); + - /** - * Returns the elements in the input - * - * @return array of objects. - */ - public Object[] getElements(Object arg0) { - if (arg0 instanceof ArrayList) { - return ((ArrayList)arg0).toArray(); - } - return new Object[0]; - } + new Label(content, SWT.WRAP); // filler + + // Rescan button + rescanButton = new Button(content, SWT.NONE); + rescanButton.setToolTipText(Messages.getString("SDKPreferencePage.Rescan_Button_ToolTip")); //$NON-NLS-1$ + rescanButton.setText(Messages.getString("SDKPreferencePage.Rescan_Button_Label")); //$NON-NLS-1$ + addButtonListener(rescanButton); - public void dispose() { - } + // Populate SDK table + addSDKComponentTableItems(); + selectSDKEntry(0); - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - //do nothing - } + return content; } - - /** - * Sets the listener event to a button. - * - * @param aButton - */ - private void addButtonListener( final Button aButton ) { + + private void addButtonListener(final Button aButton) { SelectionListener listener = new SelectionAdapter() { - public void widgetSelected( SelectionEvent e ) { - if (e.getSource().equals(sdkpropertiesButton)) { - sdkpropertiesButtonAction(); - } else if (e.getSource().equals(addNewSdkButton)) { - addNewSdkButtonAction(); - } else if (e.getSource().equals(removeSdkButton)) { - removeSdkButtonAction(); - } else if (e.getSource().equals(rescanNowButton)) { - rescanNowButtonAction(); + public void widgetSelected(SelectionEvent e) { + if (e.getSource().equals(addButton)) { + handleAddButton(); + } else if (e.getSource().equals(deleteButton)) { + handleDeleteButton(); + } else if (e.getSource().equals(propertiesButton)) { + handlePropertiesButton(); + } else if (e.getSource().equals(scanForNewPluginsButton)) { + handleScanForNewPluginsButton(); + } else if (e.getSource().equals(rescanButton)) { + handleRescanButton(); } - } }; aButton.addSelectionListener(listener); } - - private void sdkpropertiesButtonAction(){ + + private void addSDKComponentTableItems() { + sdkListTableViewer.setLabelProvider(new SDKLabelProvider()); + sdkListTableViewer.setContentProvider(new ArrayContentProvider()); + sdkList = sdkMgr.getSDKList(); + sdkListTableViewer.setInput(sdkList.toArray()); + sdkListTableViewer.getTable().setToolTipText(Messages.getString("SDKPreferencePage.List_of_Available_SDKs_ToolTip")); //$NON-NLS-1$ + setCheckedElements(); + addSDKTableViewerListeners(); + if (sdkList == null || sdkList.size() == 0){ + statusError(Messages.getString("SDKPreferencePage.No_SDKs_Available_Message")); //$NON-NLS-1$ + } + } + + private void addSDKTableViewerListeners(){ + sdkListTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + if(event.getSelection() instanceof IStructuredSelection) { + IStructuredSelection selection = (IStructuredSelection)event.getSelection(); + if (selection.size() == 1){ + ISymbianSDK sdk = (ISymbianSDK)selection.getFirstElement(); + deleteButton.setEnabled(true); + propertiesButton.setEnabled(true); + updateSDKStatus(sdk); + } + else { + deleteButton.setEnabled(false); + propertiesButton.setEnabled(false); + } + } + } + }); + } + + private void createSDKTable() { + final Table table = sdkListTableViewer.getTable(); + GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + gridData.widthHint = 350; + gridData.heightHint = table.getItemHeight() * 6; + table.setLayoutData(gridData); + table.setHeaderVisible(true); + table.setLinesVisible(false); + + TableViewerColumn enabledCol = new TableViewerColumn(sdkListTableViewer, SWT.LEFT); + enabledCol.getColumn().setText(Messages.getString("SDKPreferencePage.SDK_Table_Enabled_Column_Label")); //$NON-NLS-1$ + enabledCol.getColumn().setWidth(50); + + TableViewerColumn idCol = new TableViewerColumn(sdkListTableViewer, SWT.LEFT); + idCol.setEditingSupport(new IdEditingSupport(sdkListTableViewer)); //$NON-NLS-1$ + idCol.getColumn().setText(Messages.getString("SDKPreferencePage.SDK_Table_ID_Column_Label")); + idCol.getColumn().setWidth(160); + + TableViewerColumn locationCol = new TableViewerColumn(sdkListTableViewer, SWT.LEFT); + locationCol.setEditingSupport(new LocationEditingSupport(sdkListTableViewer)); + locationCol.getColumn().setText(Messages.getString("SDKPreferencePage.SDK_Table_Location_Column_Label")); //$NON-NLS-1$ + locationCol.getColumn().setWidth(170); + } + + private void handleAddButton() { + AddSDKDialog dialog = new AddSDKDialog(getShell()); + if (dialog.open() == AddSDKDialog.OK){ + sdkList = sdkMgr.getSDKList(); + sdkListTableViewer.setInput(sdkList.toArray()); + setCheckedElements(); + sdkListTableViewer.refresh(); + selectSDKEntry(sdkList.size() - 1); + } + } + + private void handleDeleteButton() { + ISymbianSDK sdk = (ISymbianSDK)((IStructuredSelection)sdkListTableViewer.getSelection()).getFirstElement(); + int index = sdkListTableViewer.getTable().getSelectionIndex(); + if (sdk != null){ + if (sdkMgr.removeSDK(sdk.getUniqueId())){ + sdkList = sdkMgr.getSDKList(); + sdkListTableViewer.setInput(sdkList.toArray()); + if (index > 0) { + selectSDKEntry(index - 1); + } else { + selectSDKEntry(index); + } + sdkListTableViewer.refresh(); + } + } + } + + private void handlePropertiesButton() { ISymbianSDK sdk = (ISymbianSDK)((IStructuredSelection)sdkListTableViewer.getSelection()).getFirstElement(); if (sdk != null){ - SDKPropertiesDialog sdkPropDlg = new SDKPropertiesDialog(getShell(), this, sdk); + SDKPropertiesDialog sdkPropDlg = new SDKPropertiesDialog(getShell(), sdk); if (sdkPropDlg.open() == SDKPropertiesDialog.OK){ sdkListTableViewer.refresh(); - setSelectedSDKInfoText(sdk); + updateSDKStatus(sdk); // forcible rescan; dump cache SymbianBuildContextDataCache.refreshForSDKs(new ISymbianSDK[] { sdk }); - rescanSDKs(false); + sdkMgr.scanSDKs(); } } else { MessageDialog.openError(getShell(), Messages.getString("SDKPreferencePage.No_SDK_Selected"), Messages.getString("SDKPreferencePage.No_selected_SDK_detected")); //$NON-NLS-1$ //$NON-NLS-2$ } - } - - private void removeSdkButtonAction(){ - ISymbianSDK sdk = (ISymbianSDK)((IStructuredSelection)sdkListTableViewer.getSelection()).getFirstElement(); - if (sdk != null){ - if (MessageDialog.openConfirm(getShell(), Messages.getString("SDKPreferencePage.Confirm_Delete") + sdk.getUniqueId() , Messages.getString("SDKPreferencePage.Confirm_Delete_Msg"))){ //$NON-NLS-1$ //$NON-NLS-2$ - if (sdkMgr.removeSDK(sdk.getUniqueId())){ - sdkList.remove(sdk); - sdkListTableViewer.refresh(); - sdk = (ISymbianSDK)sdkListTableViewer.getElementAt(0); - if (sdk != null){ - sdkListTableViewer.setSelection(new StructuredSelection(sdk), true); - setSelectedSDKInfoText(sdk); - } - } - } - } + + private void handleScanForNewPluginsButton() { + scanForNewPlugins = scanForNewPluginsButton.getSelection(); } - - private void addNewSdkButtonAction(){ - - AddSDKDialog dialog = new AddSDKDialog(getShell()); - if (dialog.open() == AddSDKDialog.OK){ - addSDKComponentTableItems(); - sdkListTableViewer.refresh(); - } - } - - private void rescanNowButtonAction(){ + + private void handleRescanButton() { // forcible rescan; dump cache SymbianBuildContextDataCache.refreshForSDKs(null); - rescanSDKs(true); + sdkMgr.scanSDKs(); } - - private void rescanSDKs(boolean scanForNewPlugins){ + + private void rescanSDKs(){ sdkListTableViewer.getTable().clearAll(); sdkListTableViewer.refresh(); sdkList.clear(); - ISDKManager sdkMgr = SDKCorePlugin.getSDKManager(); - sdkMgr.scanSDKs(); sdkList = sdkMgr.getSDKList(); addSDKComponentTableItems(); sdkListTableViewer.refresh(); - - ISymbianSDK sdk = (ISymbianSDK)sdkListTableViewer.getElementAt(0); - if (sdk != null){ - sdkListTableViewer.setSelection(new StructuredSelection(sdk), true); - setSelectedSDKInfoText(sdk); - } - + selectSDKEntry(0); + if (scanForNewPlugins){ NewPluginChecker.checkForNewlyInstalledPlugins(SDKUIPlugin.getDefault().getWorkbench()); } } - - /** - * Sets the selection listener action event to the CheckboxTableViewer. - * - * @param sdkTable - */ - private void addSDKTableViewerSelectionListener(){ - sdkListTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - if(event.getSelection() instanceof IStructuredSelection) { - IStructuredSelection selection = (IStructuredSelection)event.getSelection(); - if (selection.size() == 1){ - ISymbianSDK sdk = (ISymbianSDK)selection.getFirstElement(); - sdkpropertiesButton.setEnabled(true); - removeSdkButton.setEnabled(true); - setSelectedSDKInfoText(sdk); - - }else { - sdkpropertiesButton.setEnabled(false); - removeSdkButton.setEnabled(false); - } - } - } - } ); + private void selectSDKEntry(int index) { + ISymbianSDK sdk = (ISymbianSDK)sdkListTableViewer.getElementAt(index); + if (sdk != null){ + sdkListTableViewer.setSelection(new StructuredSelection(sdk), true); + sdkListTableViewer.getTable().setFocus(); + } + updateSDKStatus(sdk); } - - private void setSelectedSDKInfoText(ISymbianSDK sdk){ - boolean sdkHasError = false; - String epocRootStr = sdk.getEPOCROOT(); - File epocRootTest = new File(epocRootStr); - if (!epocRootTest.exists()) { - sdkHasError = true; - epocrootLabel.setText(EPOCROOT_LABEL + epocRootStr + Messages.getString("SDKPreferencePage.Path_Does_Not_Exist")); //$NON-NLS-1$ - epocrootLabel.setForeground(RED); - epocrootLabel.setBackground(GRAY); - } - else { - epocrootLabel.setText(EPOCROOT_LABEL + epocRootStr); - epocrootLabel.setForeground(BLACK); - epocrootLabel.setBackground(GRAY); - } - - // Set platforms - if (sdk.getAvailablePlatforms().size() == 0) { - sdkHasError = true; - availablePlatformsLabel.setText(PLATFORMS_LABEL + Messages.getString("SDKPreferencePage.Platforms_cannot_be_determined")); //$NON-NLS-1$ - availablePlatformsLabel.setForeground(RED); - availablePlatformsLabel.setBackground(GRAY); - } - else { - availablePlatformsLabel.setText(PLATFORMS_LABEL + sdk.getAvailablePlatforms().toString()); - availablePlatformsLabel.setForeground(BLACK); - availablePlatformsLabel.setBackground(GRAY); + + private void setCheckedElements() { + Iterator iterator = sdkList.iterator(); + while (iterator.hasNext()) { + ISymbianSDK sdk = iterator.next(); + sdkListTableViewer.setChecked(sdk, sdk.isEnabled()); } - - // Set OS Version - if (sdk.getOSVersion().getMajor() == 0) { - sdkHasError = true; - osVersionLabel.setText(OS_VERSION_LABEL + Messages.getString("SDKPreferencePage.OS_Version_Cannot_Be_Determined")); //$NON-NLS-1$ - osVersionLabel.setForeground(RED); - osVersionLabel.setBackground(GRAY); - } - else if (!SDKCorePlugin.SUPPORTS_SBSV1_BUILDER && - (sdk.getOSVersion().getMajor() < 9 || - (sdk.getOSVersion().getMajor() == 9 && sdk.getOSVersion().getMinor() <= 4))){ - sdkHasError = true; - osVersionLabel.setText(OS_VERSION_LABEL + "This OS version is not supported: " + sdk.getOSVersion()); - osVersionLabel.setForeground(RED); - osVersionLabel.setBackground(GRAY); - + } + + private void statusClear() { + iconLabel.setImage(null); + statusLabel.setText(""); + } + + private void statusError(String msg) { + String errorMsg = "Error : " + msg; + iconLabel.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); + statusLabel.setText(errorMsg); + statusLabel.setForeground(red); + statusLabel.setBackground(gray); + statusLabel.update(); + statusLabel.getParent().layout(true); + } + + private void statusWarning(String msg) { + String warningMsg = "Warning : " + msg; //$NON-NLS-1$ + iconLabel.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK)); + statusLabel.setText(warningMsg); + statusLabel.setForeground(black); + statusLabel.setBackground(gray); + statusLabel.update(); + statusLabel.getParent().layout(true); + } + + private void statusInfo(String msg) { + String infoMsg = "Info : " + msg; //$NON-NLS-1$ + iconLabel.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK)); + statusLabel.setText(infoMsg); + statusLabel.setForeground(black); + statusLabel.setBackground(gray); + statusLabel.update(); + statusLabel.getParent().layout(true); + } + + private void updateSDKStatus(ISymbianSDK sdk){ + // No SDK selected + if (sdk == null) { + statusWarning(Messages.getString("SDKPreferencePage.No_SDKs_Available_Message")); //$NON-NLS-1$ + return; } else { - if (sdk.getSDKOSBranch().length() > 0) { - osVersionLabel.setText(OS_VERSION_LABEL + sdk.getOSVersion().toString() + " (Branch = \"" + sdk.getSDKOSBranch() + "\")"); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - osVersionLabel.setText(OS_VERSION_LABEL + sdk.getOSVersion().toString()); + // Check SDK EPOCROOT + String epocRootStr = sdk.getEPOCROOT(); + IPath epocRoot = new Path(epocRootStr); + epocRoot = epocRoot.append("epoc32"); + File epocRootFile = epocRoot.toFile(); + if (!epocRootFile.exists()) { + statusError(Messages.getString("SDKPreferencePage.Invalid_Location_Message")); //$NON-NLS-1$ + return; } - osVersionLabel.setForeground(BLACK); - osVersionLabel.setBackground(GRAY); - } - - // Get diagnostic check - //if (lsdk.getSomeError().size() <= 0) { - if (sdkHasError){ - diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + Messages.getString("SDKPreferencePage.SDK_Cannot_Be_Used")); //$NON-NLS-1$ - diagnosticCheckLabel.setForeground(RED); - diagnosticCheckLabel.setBackground(GRAY); + + // Check SDK OS Version + if ((sdk.getOSVersion().getMajor() < 9 || + (sdk.getOSVersion().getMajor() == 9 && sdk.getOSVersion().getMinor() < 5))) { + statusError(MessageFormat.format( + Messages.getString("SDKPreferencePage.Invalid_SDK_Message"), //$NON-NLS-1$ + sdk.getOSVersion().toString())); //$NON-NLS-1$ + return; + } + + // No error + statusClear(); } - else { - // check for other types of errors: - if (!sdk.getToolsPath().toFile().exists()){ - diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + Messages.getString("SDKPreferencePage.No_Tools_Path") + " " + sdk.getToolsPath().toOSString()); //$NON-NLS-1$ - diagnosticCheckLabel.setForeground(RED); - diagnosticCheckLabel.setBackground(GRAY); - } else if (!sdk.getIncludePath().toFile().exists()){ - diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + Messages.getString("SDKPreferencePage.No_Include_Path") + " " + sdk.getIncludePath().toOSString()); //$NON-NLS-1$ - diagnosticCheckLabel.setForeground(RED); - diagnosticCheckLabel.setBackground(GRAY); - } else if ( ((sdk.getPrefixFile() == null) || (!sdk.getPrefixFile().exists())) && (sdk.getOSVersion().getMajor() >= 9)){ - diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + Messages.getString("SDKPreferencePage.No_HRH_File")); //$NON-NLS-1$ - diagnosticCheckLabel.setForeground(RED); - diagnosticCheckLabel.setBackground(GRAY); - } else if ( ((sdk.isS60()) && sdk.getSDKVersion().getMajor() == 0)){ - diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + Messages.getString("SDKPreferencePage.No_SDK_Version")); //$NON-NLS-1$ - diagnosticCheckLabel.setForeground(RED); - diagnosticCheckLabel.setBackground(GRAY); - } else { - // Everything is OK.... - diagnosticCheckLabel.setText(DIAGNOSTIC_CHECK_LABEL + "OK\r\n "); //$NON-NLS-1$ - diagnosticCheckLabel.setForeground(BLACK); - diagnosticCheckLabel.setBackground(GRAY); - } - } - } - - protected List getSDKList(){ - return sdkList; } - - protected ISDKManager getSDKManager(){ - return sdkMgr; - } + } \ No newline at end of file diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKPropertiesDialog.java --- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKPropertiesDialog.java Wed Jun 02 16:06:56 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKPropertiesDialog.java Wed Jun 02 17:18:05 2010 -0500 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -50,7 +50,6 @@ public class SDKPropertiesDialog extends TrayDialog { - SDKPreferencePage sdkPrefs; ISymbianSDK sdk; private CCombo osVersionCombo; private CCombo sdkVersionCombo; @@ -68,13 +67,12 @@ * Create the dialog * @param parentShell */ - public SDKPropertiesDialog(Shell parentShell, SDKPreferencePage sdkPrefs, ISymbianSDK sdk) { + public SDKPropertiesDialog(Shell parentShell, ISymbianSDK sdk) { super(parentShell); - this.sdkPrefs = sdkPrefs; this.sdk = sdk; setShellStyle(getShellStyle() | SWT.RESIZE); } - + /* (non-Javadoc) * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) */ diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKUIPreferenceConstants.java --- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKUIPreferenceConstants.java Wed Jun 02 16:06:56 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKUIPreferenceConstants.java Wed Jun 02 17:18:05 2010 -0500 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -27,4 +27,5 @@ public final static String PLAT_EKA2_ARMV5_ABIV1 = "platEKA2_ARMV5_ABIV1"; //$NON-NLS-1$ public final static String LISTEN_FOR_DEVICES_XML_CHANGE = "listenForDevicesXMLChange"; //$NON-NLS-1$ + public final static String SCAN_FOR_NEW_PLUGINS = "scanForNewPlugins"; //$NON-NLS-1$ } diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKUIPreferenceInitializer.java --- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKUIPreferenceInitializer.java Wed Jun 02 16:06:56 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKUIPreferenceInitializer.java Wed Jun 02 17:18:05 2010 -0500 @@ -34,6 +34,7 @@ IPreferenceStore store = SDKUIPlugin.getDefault().getPreferenceStore(); store.setDefault(SDKUIPreferenceConstants.ENABLE_BSF_SCANNER, false); store.setDefault(SDKUIPreferenceConstants.LISTEN_FOR_DEVICES_XML_CHANGE, true); + store.setDefault(SDKUIPreferenceConstants.SCAN_FOR_NEW_PLUGINS, false); store.setDefault(SDKUIPreferenceConstants.PLAT_EKA2_WINSCW, true); store.setDefault(SDKUIPreferenceConstants.PLAT_EKA2_GCCE, true); diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/messages.properties --- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/messages.properties Wed Jun 02 16:06:56 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/messages.properties Wed Jun 02 17:18:05 2010 -0500 @@ -1,5 +1,4 @@ SDKPropertiesDialog.SDK_Properties_For=SDK Properties for -SDKPreferencePage.Available_SDKs_Label=Available Symbian OS SDKs SDKPropertiesDialog.Available_SDK_Properties=Available SDK properties: SDKPropertiesDialog.Property=Property SDKPropertiesDialog.Value=Value @@ -17,50 +16,38 @@ SDKPropertiesDialog.Illegal_Verion_Title=Illegal Version Format Exception SDKPropertiesDialog.Illegal_SDKVerion_Msg=The SDK version is improperly formatted. Make sure it is of format major.minor[.increment]. SDKPropertiesDialog.Publisher_Name=Publisher Name -SDKPreferencePage.OS_Group_ToolTip=List of the SDKs found from devices.xml. Checkboxes indicate which SDKs you want to be available for Carbide.c++ use. SDKs in red are not configured properly. -SDKPreferencePage.Remove_SDK_Label=Remove SDK -SDKPreferencePage.SDK_Info_ToolTip=Displays information for the selected SDK. SDKPropertiesDialog.SDK_Description=SDK Description SDKPropertiesDialog.Duplicate_ID=Duplicate ID -SDKPreferencePage.SDK_Info_Label=SDK Information -SDKPreferencePage.Confirm_Delete=Confirm Delete SDKPropertiesDialog.Duplicate_ID_Message=The SDK ID you have chosen is not unique. Please enter a unique SDK ID. -SDKPreferencePage.SDK_Props_Button_Label=SDK Properties -SDKPreferencePage.Diagnostic_Check_Label=Diagnostic Check: SDKPropertiesDialog.Zero_Len_ID=Zero Length ID SDKPropertiesDialog.Zero_Len_ID_Msg=Please enter a unique SDK ID -SDKPreferencePage.Add_New_SDK_Label=Add New SDK -SDKPreferencePage.OSVesions_ToolTip=The Symbian OS version (and branch) the selected OS is based on. -SDKPreferencePage.Platforms_ToolTip=Platforms that are available in the SDK. -SDKPreferencePage.No_SDKs_Available=No SDKs are available. SDKPropertiesDialog.Zero_Len_Name=Zero Length Name -SDKPreferencePage.OSVersion_Label=OS Version: -SDKPreferencePage.No_SDK_Selected=No SDK Selected SDKPropertiesDialog.Zero_Len_Name_Msg=Please enter an SDK name or choose one from the pop-up menu. SDKPropertiesDialog.EPOCROOT_No_Exist=EPOCROOT does not exist. SDKPropertiesDialog.EPOCROOT_No_Exist_Msg=Do you want to add an EPOCROOT value that does not exist? SDKPropertiesDialog.Zero_Len_EPOCROOT=Zero Length EPOCROOT -SDKPreferencePage.Delete_SDK_ToolTip=Deletes an SDK from Carbide.c++ and devices.xml. -SDKPreferencePage.Add_New_SDK_ToolTip=Adds a new SDK for use in Carbide.c++ and devices.xml. -SDKPreferencePage.EPOC32_Loc_ToolTip=Location of the 'epoc32' folder. -SDKPreferencePage.Available_Platforms=Available Platforms: -SDKPreferencePage.Rescan_Button_Label=Rescan All SDKs -SDKPreferencePage.Confirm_Delete_Msg=Are you sure you want to delete this SDK?\n\nThis entry will be removed from your devices.xml. -SDKPreferencePage.Path_Does_Not_Exist=\ <- Path does not exist. -SDKPreferencePage.SDK_Cannot_Be_Used=SDK cannot be used in Carbide.c++. Make sure your EPOCROOT is valid and the OS version is properly set. SDKPropertiesDialog.Zero_Len_EPOCROOT_Msg=Please enter an EPOCROOT. SDKPropertiesDialog.Invalid_Name_Attrib=Invalid 'name' attribute. +SDKPropertiesDialog.Invalid_Name_Attrib_Msg=The SDK name must be of the format com.. + +SDKPreferencePage.Browse_Location_Label=... +SDKPreferencePage.Add_Button_Label=Add +SDKPreferencePage.Add_Button_ToolTip=Adds a new SDK for use in Carbide.c++. +SDKPreferencePage.Delete_Button_Label=Delete +SDKPreferencePage.Delete_Button_ToolTip=Delete an SDK from Carbide.c++. +SDKPreferencePage.Properties_Button_Label=Properties +SDKPreferencePage.Properties_Button_ToolTip=Show properties of the selected SDK. +SDKPreferencePage.ScanForNewPlugins_Button_Label=Scan SDKs for installable Eclipse plugins +SDKPreferencePage.Rescan_Button_Label=Rescan All SDKs SDKPreferencePage.Rescan_Button_ToolTip=Rebuilds all SDK entries (same as restarting the IDE). -SDKPropertiesDialog.Invalid_Name_Attrib_Msg=The SDK name must be of the format com.. -SDKPreferencePage.SDK_Props_Button_ToolTip=Shows editable and non-editable extended SDK properties for the selected SDK. -SDKPreferencePage.Diagnostic_Check_ToolTip=Displays miscellaneous errors and warnings that may indicate problems with an SDK installation. +SDKPreferencePage.No_SDKs_Available_Message=No SDKs are available. SDKPreferencePage.No_selected_SDK_detected=No selected SDK detected. -SDKPreferencePage.No_Tools_Path=WARNING: Tools path does not exist: -SDKPreferencePage.No_Include_Path=WARNING: Include path does not exist: -SDKPreferencePage.No_HRH_File=WARNING: Cannot find pre-include (HRH) file from \\epoc32\\tools\\variant\\variant.cfg." -SDKPreferencePage.No_SDK_Version=WARNING: SDK version is not set. Some functionality may not work for this SDK. -SDKPreferencePage.listerForDevicesXML=Listen for devices.xml changes outside of Carbide -SDKPreferencePage.listerForDevicesXML_Tooltip=When enabled, Carbide will check for changes in the devices.xml file outside of Carbide and alert you when it has changed. +SDKPreferencePage.List_of_Available_SDKs_ToolTip=List of available SDKs. +SDKPreferencePage.SDK_Table_Enabled_Column_Label=Enabled +SDKPreferencePage.SDK_Table_ID_Column_Label=SDK ID +SDKPreferencePage.SDK_Table_Location_Column_Label=Location +SDKPreferencePage.Invalid_Location_Message=Invalid location. '\\epoc32\\' does not exist at specified location. +SDKPreferencePage.Invalid_SDK_Message=Invalid SDK. OS version {0} no supported. Must be verison 9.5 or higher. BuildPlatformFilterPage.Select_Platforms_Help=Select which platforms are visible when creating projects or new build configurations. BuildPlatformFilterPage.Specify_Platforms_Help=Specifies platforms to be displayed for OS 9.x and 8.1b @@ -69,9 +56,6 @@ BuildPlatformFilterPage.EKA1_Platforms_Label=EKA1 Platforms BuildPlatformFilterPage.BSF_Help=Scans for .bsf and/or .var files under \\epoc32\\tools for platform variants. BuildPlatformFilterPage.BSF_Label=Discover customization (.bsf) and Symbian Binary Variant (.var) platforms dynamically -SDKPreferencePage.List_of_Available_SDKs_ToolTip=List of available SDKs from devices.xml. -SDKPreferencePage.Platforms_cannot_be_determined=Platforms cannot be determined -SDKPreferencePage.OS_Version_Cannot_Be_Determined=OS version cannot be determined NewPluginChecker.New_Plugins_Installed=New plugins have been installed from an SDK. NewPluginChecker.Restart_Msg=\n\nPress "Restart" to restart Carbide.c++ now or "Later" to apply changes next time you restart Carbide.c++. NewPluginChecker.Restart_Error=New plugins were installed into Carbide.c++ from an SDK. However, an error in the workbench prevented a Restart dialog from being displayed. You will need to restart Carbide in order to pick up the latest changes. @@ -79,8 +63,6 @@ RestartIDEDialog.Later=Later RestartIDEDialog.New_Plugin_Installed=New Plugins Installed AddSDKDialog.Add_New_SDK=Add New SDK -AddSDKDialog.Missing_Vendor_Name=Missing Vendor/Name -AddSDKDialog.Enter_Vendor_Name=Please enter an SDK vendor/name. AddSDKDialog.Missing_SDK_ID=Missing SDK ID. AddSDKDialog.Enter_SDK_ID=Please enter an SDK ID. AddSDKDialog.Malformed_EPOCROOT=Malformed EPOCROOT @@ -96,21 +78,11 @@ AddSDKDialog.SDK_ID_No_Spaces=SDK ID attribute cannot contain spaces. AddSDKDialog.Duplicate_ID=Duplicate device 'id' AddSDKDialog.Duplicate_ID_Msg=The SDK ID you have chosen already exists. Please choose another. -AddSDKDialog.Invalid_name_attrib=Invalid 'name' attribute. -AddSDKDialog.Invalid_name_attrib_msg=The SDK name must be of the format com.. AddSDKDialog.Enter_unique_id_for_sdk=Enter a unique identifier for the SDK you want to add. AddSDKDialog.SDK_ID=SDK ID: AddSDKDialog.Enter_location_where_epoc32_folder=Enter the location where the 'epoc32' folder exists. AddSDKDialog.Choose_folder_where_epoc32_exists=Choose the folder where 'epoc32' exists. AddSDKDialog.Browse=Browse... -AddSDKDialog.Enter_name_of_sdk=Enter the name of the sdk. Format is com.. -AddSDKDialog.Vendor=Vendor: -AddSDKDialog.default_label_tooltip=Defines the default SDK for command-line builds. Has no impact on Carbide.c++ builds. -AddSDKDialog.is_default=Is Default: -AddSDKDialog.os_version_tooltip=Select the OS version. This will determine the available platforms you can build for. -AddSDKDialog.os_version=OS Version: -AddSDKDialog.select_sdk_tooltip=Select the SDK version (optional). -AddSDKDialog.sdk_version=SDK Version: AddSDKDialog.Choose_location_for_EPOCROOT=Choose location for EPOCROOT. BuildTargetsPage.BuildTargetsTitle=Build Targets BuildTargetsPage.SymbianSDKS=Symbian OS SDKs diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/SDKUIPlugin.java --- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/SDKUIPlugin.java Wed Jun 02 16:06:56 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/SDKUIPlugin.java Wed Jun 02 17:18:05 2010 -0500 @@ -27,11 +27,11 @@ import com.nokia.carbide.cpp.internal.api.sdk.ICarbideDevicesXMLChangeListener; import com.nokia.carbide.cpp.internal.api.sdk.ISDKManagerInternal; import com.nokia.carbide.cpp.internal.api.sdk.ui.SBSv1PlatformFilterComposite; -import com.nokia.carbide.cpp.internal.sdk.ui.NewPluginChecker; import com.nokia.carbide.cpp.internal.sdk.ui.SDKUIPreferenceConstants; -import com.nokia.carbide.cpp.sdk.core.*; +import com.nokia.carbide.cpp.sdk.core.ISDKManager; +import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin; +import com.nokia.cpp.internal.api.utils.ui.QueryWithTristatePrefDialog; import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils; -import com.nokia.cpp.internal.api.utils.ui.QueryWithTristatePrefDialog; /** * The activator class controls the plug-in life cycle @@ -58,7 +58,6 @@ */ public void start(BundleContext context) throws Exception { super.start(context); - NewPluginChecker.checkForNewlyInstalledPlugins(getWorkbench()); ISDKManager sdkMgr = SDKCorePlugin.getSDKManager(); sdkMgr.setPlatformList(SBSv1PlatformFilterComposite.getPlatFilterPrefsStore()); diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/AddSDKDialog.java --- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/AddSDKDialog.java Wed Jun 02 16:06:56 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/AddSDKDialog.java Wed Jun 02 17:18:05 2010 -0500 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -18,7 +18,6 @@ package com.nokia.carbide.cpp.sdk.ui.shared; import java.io.File; -import java.util.ArrayList; import java.util.List; import org.eclipse.jface.dialogs.IDialogConstants; @@ -32,7 +31,6 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.DirectoryDialog; @@ -44,7 +42,6 @@ import com.nokia.carbide.cpp.internal.sdk.ui.Messages; import com.nokia.carbide.cpp.internal.sdk.ui.SDKUIHelpIds; -import com.nokia.carbide.cpp.sdk.core.ISDKManager; import com.nokia.carbide.cpp.sdk.core.ISymbianSDK; import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin; import com.nokia.carbide.cpp.sdk.core.SymbianSDKFactory; @@ -57,18 +54,10 @@ */ public class AddSDKDialog extends TrayDialog { - private Combo sdkVersionCombo; - private Combo osVersionCombo; - private Combo isDefaultCombo; - private Combo vendorCombo; private Text deviceIDtext; private Text epocRootText; private Button browseEPOCROOTButton; - - public static final String DEFAULT_YES = "yes"; //$NON-NLS-1$ - public static final String DEFAULT_NO = "no"; //$NON-NLS-1$ - public static final String AUTO_DETECT = "(Auto-Detect)"; //$NON-NLS-1$ - + /** * Create the dialog * @param parentShell @@ -76,155 +65,17 @@ public AddSDKDialog(Shell parentShell) { super(parentShell); } - - /* (non-Javadoc) - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) + + /** + * Create contents of the button bar + * @param parent */ - protected void configureShell(Shell shell) { - super.configureShell(shell); - shell.setText(Messages.getString("AddSDKDialog.Add_New_SDK")); //$NON-NLS-1$ - } - @Override - protected void okPressed() { - - if (deviceIDtext.getText().length() > 0){ - if (!isValidIDName(deviceIDtext.getText())){ - return; - } - - if (vendorCombo.getText().length() > 0){ - if (!isValidVendorName(vendorCombo.getText())){ - return; - } - } else { - MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Missing_Vendor_Name"), Messages.getString("AddSDKDialog.Enter_Vendor_Name")); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - } else { - MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Missing_SDK_ID"), Messages.getString("AddSDKDialog.Enter_SDK_ID")); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - - if (epocRootText.getText().length() > 1){ - if (HostOS.IS_WIN32 && epocRootText.getText().charAt(1) != ':'){ - MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Malformed_EPOCROOT"), Messages.getString("AddSDKDialog.EPOCROOT_drive_spec")); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - - if (epocRootText.getText().toUpperCase().endsWith("EPOC32") || epocRootText.getText().toUpperCase().endsWith("EPOC32\\")){ //$NON-NLS-1$ //$NON-NLS-2$ - if (!MessageDialog.openConfirm(getShell(), Messages.getString("AddSDKDialog.Possible_wrong_epocroot"), Messages.getString("AddSDKDialog.EPOCROOT_Should_Point"))){ //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - } else { - File epocRootFile = new File(epocRootText.getText()); - if (!epocRootFile.exists()){ - if (!MessageDialog.openConfirm(getShell(), Messages.getString("AddSDKDialog.EPOCROOT_does_not_exist"), Messages.getString("AddSDKDialog.EPOCROOT_does_not_exist_msg"))){ //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - } - if (epocRootFile.toString().indexOf(" ") != -1){ - // Paths should not have spaces... - MessageDialog.openError(getShell(), "EPOC Root Contains Spaces", Messages.getString("AddSDKDialog.EPOCROOT_contains_spaces")); //$NON-NLS-1$ //$NON-NLS-2$ - return; - - } - } - } else { - if (epocRootText.getText().length() == 1 && epocRootText.getText().charAt(0) == '\\'){ - // OK - Currently accept only a '\'. May need to reconsider side-effects - } else { - MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Missing_EPOCROOT"), Messages.getString("AddSDKDialog.Please_enter_an_EPOCROOT")); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - } - - // No objections raised, write the new device entry - String osVersionText = osVersionCombo.getText(); - Version osVersion; - String osBranch = ""; //$NON-NLS-1$ - if (osVersionText.equals(AUTO_DETECT)){ - osVersion = new Version("0.0"); //$NON-NLS-1$ - } else { - int len = osVersionText.length(); - if (Character.isLetter(osVersionText.charAt(len-1))){ - osBranch = osVersionText.substring(len-1); - osVersionText = osVersionText.substring(0, len-1); - osVersion = new Version(osVersionText); - } else { - osVersion = new Version(osVersionText); - } - } - - Version sdkVersion = new Version("0.0"); //$NON-NLS-1$ - if (!sdkVersionCombo.getText().equals(AUTO_DETECT)){ - sdkVersion = new Version(sdkVersionCombo.getText()); - } - - ISymbianSDK sdk = SymbianSDKFactory.createInstance(deviceIDtext.getText(), - epocRootText.getText(), - vendorCombo.getText(), - osVersion, - osBranch, - sdkVersion, - false); - - SDKCorePlugin.getSDKManager().addSDK(sdk); - - List sdkList = SDKCorePlugin.getSDKManager().getSDKList(); - if (sdkList != null){ - sdkList.add(sdk); - } - - if (isDefaultCombo.getText().equals(DEFAULT_YES)){ - sdk.setIsDefaultSDK(true); - SDKCorePlugin.getSDKManager().setDefaultSDK(sdk); - } else { - sdk.setIsDefaultSDK(false); - } - - super.okPressed(); - } - - private boolean isValidIDName(String sdkID){ - boolean isValid = true; - - - // check for spaces in ID - if (sdkID.contains(" ")){ //$NON-NLS-1$ - MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Invalid_SDK_ID"), Messages.getString("AddSDKDialog.SDK_ID_No_Spaces")); //$NON-NLS-1$ //$NON-NLS-2$ - return false; - } - - // check that the ID is unique... - for (ISymbianSDK sdk : SDKCorePlugin.getSDKManager().getSDKList()){ - if (sdk.getUniqueId().equalsIgnoreCase(sdkID)){ - // id already exists, choose a different one... - MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Duplicate_ID"), Messages.getString("AddSDKDialog.Duplicate_ID_Msg")); //$NON-NLS-1$ //$NON-NLS-2$ - return false; - } - } - - return isValid; - } - - private boolean isValidVendorName(String vendor){ - boolean isValid = true; - - String[] vendorSplit = vendor.split("[.]"); //$NON-NLS-1$ - if (vendorSplit.length == 3){ - if (!vendorSplit[0].toLowerCase().startsWith("com")){ //$NON-NLS-1$ - isValid = false; - } - } else { - isValid = false; - } - - if (isValid == false){ - MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Invalid_name_attrib"), Messages.getString("AddSDKDialog.Invalid_name_attrib_msg")); //$NON-NLS-1$ //$NON-NLS-2$ - } - - return isValid; + protected void createButtonsForButtonBar(Composite parent) { + createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, + true); + createButton(parent, IDialogConstants.CANCEL_ID, + IDialogConstants.CANCEL_LABEL, false); } /** @@ -257,81 +108,17 @@ browseEPOCROOTButton.setToolTipText(Messages.getString("AddSDKDialog.Choose_folder_where_epoc32_exists")); //$NON-NLS-1$ browseEPOCROOTButton.setText(Messages.getString("AddSDKDialog.Browse")); //$NON-NLS-1$ addButtonListener(browseEPOCROOTButton); - - final Label vendorLabel = new Label(container, SWT.NONE); - vendorLabel.setToolTipText(Messages.getString("AddSDKDialog.Enter_name_of_sdk")); //$NON-NLS-1$ - vendorLabel.setText(Messages.getString("AddSDKDialog.Vendor")); //$NON-NLS-1$ - vendorCombo = new Combo(container, SWT.NONE); - vendorCombo.setLayoutData(new GridData(250, SWT.DEFAULT)); - new Label(container, SWT.NONE); - vendorCombo.add(ISymbianSDK.S60_SDK_NAME); - vendorCombo.add(ISymbianSDK.S80_SDK_NAME); - vendorCombo.add(ISymbianSDK.UIQ_SDK_NAME); - vendorCombo.add(ISymbianSDK.TECHVIEW_SDK_NAME); - - final Label isDefaultLabel = new Label(container, SWT.NONE); - isDefaultLabel.setToolTipText(Messages.getString("AddSDKDialog.default_label_tooltip")); //$NON-NLS-1$ - isDefaultLabel.setText(Messages.getString("AddSDKDialog.is_default")); //$NON-NLS-1$ - - isDefaultCombo = new Combo(container, SWT.READ_ONLY); - isDefaultCombo.setLayoutData(new GridData(250, SWT.DEFAULT)); - new Label(container, SWT.NONE); - isDefaultCombo.add(DEFAULT_YES); - isDefaultCombo.add(DEFAULT_NO); - isDefaultCombo.select(1); - - final Label osVersionLabel = new Label(container, SWT.NONE); - osVersionLabel.setToolTipText(Messages.getString("AddSDKDialog.os_version_tooltip")); //$NON-NLS-1$ - osVersionLabel.setText(Messages.getString("AddSDKDialog.os_version")); //$NON-NLS-1$ - //ISymbianMacroStore sms = - List osVersions = new ArrayList(); - ISDKManager sdkMgr = SDKCorePlugin.getSDKManager(); - osVersions = sdkMgr.getSymbianMacroStore().getSupportedOSVersions(); - - osVersionCombo = new Combo(container, SWT.READ_ONLY); - osVersionCombo.setLayoutData(new GridData(250, SWT.DEFAULT)); - new Label(container, SWT.NONE); - osVersionCombo.add(AUTO_DETECT); - - for (String currVer : osVersions){ - osVersionCombo.add(currVer); - } - osVersionCombo.select(0); - - final Label sdkVersionLabel = new Label(container, SWT.NONE); - sdkVersionLabel.setToolTipText(Messages.getString("AddSDKDialog.select_sdk_tooltip")); //$NON-NLS-1$ - sdkVersionLabel.setText(Messages.getString("AddSDKDialog.sdk_version")); //$NON-NLS-1$ - - sdkVersionCombo = new Combo(container, SWT.READ_ONLY); - sdkVersionCombo.setLayoutData(new GridData(250, SWT.DEFAULT)); - sdkVersionCombo.add(AUTO_DETECT); - sdkVersionCombo.select(0); - - List sdkVerList = new ArrayList(); - sdkVerList = sdkMgr.getSymbianMacroStore().getSDKVersions(); - for (String currVer : sdkVerList){ - sdkVersionCombo.add(currVer); - } - - new Label(container, SWT.NONE); - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, SDKUIHelpIds.SDK_ADD_DIALOG); - - return container; } - /** - * Create contents of the button bar - * @param parent + /* (non-Javadoc) + * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) */ - @Override - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, - true); - createButton(parent, IDialogConstants.CANCEL_ID, - IDialogConstants.CANCEL_LABEL, false); + protected void configureShell(Shell shell) { + super.configureShell(shell); + shell.setText(Messages.getString("AddSDKDialog.Add_New_SDK")); //$NON-NLS-1$ } /** @@ -342,15 +129,84 @@ //return new Point(428, 256); return super.getInitialSize(); } - + + /* + * (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + @Override + protected void okPressed() { + + if (deviceIDtext.getText().length() > 0){ + if (!isValidIDName(deviceIDtext.getText())){ + return; + } + } else { + MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Missing_SDK_ID"), Messages.getString("AddSDKDialog.Enter_SDK_ID")); //$NON-NLS-1$ //$NON-NLS-2$ + return; + } + + if (epocRootText.getText().length() > 1){ + if (HostOS.IS_WIN32 && epocRootText.getText().charAt(1) != ':'){ + MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Malformed_EPOCROOT"), Messages.getString("AddSDKDialog.EPOCROOT_drive_spec")); //$NON-NLS-1$ //$NON-NLS-2$ + return; + } + if (epocRootText.getText().toUpperCase().endsWith("EPOC32") || epocRootText.getText().toUpperCase().endsWith("EPOC32\\")){ //$NON-NLS-1$ //$NON-NLS-2$ + if (!MessageDialog.openConfirm(getShell(), Messages.getString("AddSDKDialog.Possible_wrong_epocroot"), Messages.getString("AddSDKDialog.EPOCROOT_Should_Point"))){ //$NON-NLS-1$ //$NON-NLS-2$ + return; + } + } else { + File epocRootFile = new File(epocRootText.getText()); + if (!epocRootFile.exists()){ + if (!MessageDialog.openConfirm(getShell(), Messages.getString("AddSDKDialog.EPOCROOT_does_not_exist"), Messages.getString("AddSDKDialog.EPOCROOT_does_not_exist_msg"))){ //$NON-NLS-1$ //$NON-NLS-2$ + return; + } + } + if (epocRootFile.toString().indexOf(" ") != -1){ + // Paths should not have spaces... + MessageDialog.openError(getShell(), "EPOC Root Contains Spaces", Messages.getString("AddSDKDialog.EPOCROOT_contains_spaces")); //$NON-NLS-1$ //$NON-NLS-2$ + return; + } + } + } else { + if (epocRootText.getText().length() == 1 && epocRootText.getText().charAt(0) == '\\'){ + // OK - Currently accept only a '\'. May need to reconsider side-effects + } else { + MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Missing_EPOCROOT"), Messages.getString("AddSDKDialog.Please_enter_an_EPOCROOT")); //$NON-NLS-1$ //$NON-NLS-2$ + return; + } + } + + // No objections raised, write the new device entry + String vendorName = ISymbianSDK.S60_SDK_NAME; + Version osVersion = new Version("9.4.0"); //$NON-NLS-1$ + String osBranch = ""; //$NON-NLS-1$ + Version sdkVersion = new Version("0.0"); //$NON-NLS-1$ + ISymbianSDK sdk = SymbianSDKFactory.createInstance(deviceIDtext.getText(), + epocRootText.getText(), + vendorName, + osVersion, + osBranch, + sdkVersion, + false); + sdk.setEnabled(true); + SDKCorePlugin.getSDKManager().addSDK(sdk); + List sdkList = SDKCorePlugin.getSDKManager().getSDKList(); + if (sdkList != null){ + sdkList.add(sdk); + } + sdk.setIsDefaultSDK(false); + super.okPressed(); + } + /** * Sets the listener event to a button. * * @param aButton */ - private void addButtonListener( final Button aButton ) { + private void addButtonListener(final Button aButton) { SelectionListener listener = new SelectionAdapter() { - public void widgetSelected( SelectionEvent e ) { + public void widgetSelected(SelectionEvent e) { if (e.getSource().equals(browseEPOCROOTButton)) { browseEPOCROOT(); } @@ -358,7 +214,7 @@ }; aButton.addSelectionListener(listener); } - + private void browseEPOCROOT(){ DirectoryDialog browseDir = new DirectoryDialog(getShell(), SWT.OPEN); browseDir.setMessage(Messages.getString("AddSDKDialog.Choose_location_for_EPOCROOT")); //$NON-NLS-1$ @@ -369,4 +225,25 @@ } } + private boolean isValidIDName(String sdkID){ + boolean isValid = true; + + // check for spaces in ID + if (sdkID.contains(" ")){ //$NON-NLS-1$ + MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Invalid_SDK_ID"), Messages.getString("AddSDKDialog.SDK_ID_No_Spaces")); //$NON-NLS-1$ //$NON-NLS-2$ + return false; + } + + // check that the ID is unique... + for (ISymbianSDK sdk : SDKCorePlugin.getSDKManager().getSDKList()){ + if (sdk.getUniqueId().equalsIgnoreCase(sdkID)){ + // id already exists, choose a different one... + MessageDialog.openError(getShell(), Messages.getString("AddSDKDialog.Duplicate_ID"), Messages.getString("AddSDKDialog.Duplicate_ID_Msg")); //$NON-NLS-1$ //$NON-NLS-2$ + return false; + } + } + + return isValid; + } + } diff -r 9dfc6e3dc4b9 -r efad5bbb7534 core/com.nokia.carbide.cpp.ui/src/com/nokia/carbide/cpp/ui/TextAndDialogCellEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/com.nokia.carbide.cpp.ui/src/com/nokia/carbide/cpp/ui/TextAndDialogCellEditor.java Wed Jun 02 17:18:05 2010 -0500 @@ -0,0 +1,221 @@ +/******************************************************************************* + * Copyright (c) 2010 Nokia Corporation + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ + +package com.nokia.carbide.cpp.ui; + +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.*; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.widgets.*; + +/** + * This class allows a CellEditor to provide editable text as well + * as a button which will launch a dialog to edit the data in a different way. + * @author dpodwall + * @author ddubrow + * @author eswartz + */ +public abstract class TextAndDialogCellEditor extends DialogCellEditor { + + private TextAndDialogCellEditor.CustomTextCellEditor textCellEditor; + private Text text; + private Button dialogButton; + + public TextAndDialogCellEditor(Composite parent) { + super(parent); + } + + @Override + protected Control createContents(Composite parent) { + textCellEditor = new CustomTextCellEditor(parent); + text = (Text) textCellEditor.getControl(); + + // Forward all events from the TextCellEditor to + // this cell editor's listener + textCellEditor.addListener(new ICellEditorListener() { + + public void applyEditorValue() { + // Ignore + } + + public void cancelEditor() { + fireCancelEditor(); + } + + public void editorValueChanged(boolean oldValidState, boolean newValidState) { + fireEditorValueChanged(oldValidState, newValidState); + } + }); + + textCellEditor.addPropertyChangeListener(new IPropertyChangeListener() { + + public void propertyChange(PropertyChangeEvent event) { + // text cell editor uses fireEnablementChanged + fireEnablementChanged(event.getProperty()); + } + + }); + + return text; + } + + @Override + protected Button createButton(Composite parent) { + dialogButton = super.createButton(parent); + return dialogButton; + } + + protected Button getButton() { + return dialogButton; + } + + void applyEditorValueAndDeactivate() { + String newValue = (String)getValue(); + + doSetValue(newValue); + markDirty(); + setValueValid(true); + fireApplyEditorValue(); + deactivate(); + } + + protected void keyReleaseOccured(KeyEvent keyEvent) { + if (keyEvent.character == '\r') { // Enter character + applyEditorValueAndDeactivate(); + } + else if (keyEvent.character == '\u001b') { // Escape character + fireCancelEditor(); + } + else if (keyEvent.character == '\t') { // tab key + applyEditorValueAndDeactivate(); + } + } + + @Override + protected void updateContents(Object value) { + textCellEditor.setValue(value != null ? value : ""); //$NON-NLS-1$ + } + + @Override + protected void doSetFocus() { + text.setVisible(true); + textCellEditor.setFocus(); + } + + @Override + protected Object doGetValue() { + String result = (String) textCellEditor.getValue(); + return result; + } + + @Override + protected void doSetValue(Object value) { + textCellEditor.setValue(value); + } + + @Override + protected void focusLost() { + super.focusLost(); + } + + public boolean isCopyEnabled() { + return textCellEditor.isCopyEnabled(); + } + + public boolean isCutEnabled() { + return textCellEditor.isCutEnabled(); + } + + public boolean isDeleteEnabled() { + return textCellEditor.isDeleteEnabled(); + } + + public boolean isFindEnabled() { + return textCellEditor.isFindEnabled(); + } + + public boolean isPasteEnabled() { + return textCellEditor.isPasteEnabled(); + } + + public boolean isRedoEnabled() { + return textCellEditor.isRedoEnabled(); + } + + public boolean isSaveAllEnabled() { + return textCellEditor.isSaveAllEnabled(); + } + + public boolean isSelectAllEnabled() { + return textCellEditor.isSelectAllEnabled(); + } + + public boolean isUndoEnabled() { + return textCellEditor.isUndoEnabled(); + } + + public boolean isValueValid() { + return textCellEditor.isValueValid(); + } + + public void performCopy() { + textCellEditor.performCopy(); + } + + public void performCut() { + textCellEditor.performCut(); + } + + public void performDelete() { + textCellEditor.performDelete(); + } + + public void performFind() { + textCellEditor.performFind(); + } + + public void performPaste() { + textCellEditor.performPaste(); + } + + public void performRedo() { + textCellEditor.performRedo(); + } + + public void performSelectAll() { + textCellEditor.performSelectAll(); + } + + public void performUndo() { + textCellEditor.performUndo(); + } + + static class CustomTextCellEditor extends TextCellEditor { + + public CustomTextCellEditor(Composite parent) { + super(parent); + } + + @Override + protected void focusLost() { + // don't deactivate everything when focus is lost, + // it will be handled in the outer cell editor + if (isActivated()) { + fireApplyEditorValue(); + } + } + } + +} + + +