Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Evoy2004-05-04 15:06:54 +0000
committerSean Evoy2004-05-04 15:06:54 +0000
commitf971a5046cfd7059e61440a36fa9cb536cc86ba9 (patch)
tree884076612bd2010ac3ecc7c927897f2672e20ab2 /build/org.eclipse.cdt.managedbuilder.ui/src
parent43e38ae75cd87a8e57eb862214c1cadbb06f00d1 (diff)
downloadorg.eclipse.cdt-f971a5046cfd7059e61440a36fa9cb536cc86ba9.tar.gz
org.eclipse.cdt-f971a5046cfd7059e61440a36fa9cb536cc86ba9.tar.xz
org.eclipse.cdt-f971a5046cfd7059e61440a36fa9cb536cc86ba9.zip
Changed the toolchain specification for Gnu tools to add a generic set of target definitions for POSIX targets. There is also a redefined set of tools and options. There is also a conversion routine that runs on workspace startup to convert older projects into the newer format.
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.ui/src')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIPlugin.java88
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedMakeStartup.java52
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties17
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/UpdateManagedProjectAction.java577
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java28
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java5
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java160
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java3
8 files changed, 881 insertions, 49 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIPlugin.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIPlugin.java
index 93a6d5a22a..287f55e453 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIPlugin.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIPlugin.java
@@ -11,22 +11,25 @@ package org.eclipse.cdt.managedbuilder.internal.ui;
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
-import java.text.MessageFormat;
import java.lang.reflect.InvocationTargetException;
+import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
-public class ManagedBuilderUIPlugin extends Plugin {
+public class ManagedBuilderUIPlugin extends AbstractUIPlugin {
//The shared instance.
private static ManagedBuilderUIPlugin plugin;
//Resource bundle.
@@ -45,6 +48,21 @@ public class ManagedBuilderUIPlugin extends Plugin {
}
}
+ public static Shell getActiveWorkbenchShell() {
+ IWorkbenchWindow window = getActiveWorkbenchWindow();
+ if (window != null) {
+ return window.getShell();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the active workbench window or <code>null</code> if none
+ */
+ public static IWorkbenchWindow getActiveWorkbenchWindow() {
+ return getDefault().getWorkbench().getActiveWorkbenchWindow();
+ }
+
/**
* Returns the shared instance.
*/
@@ -62,6 +80,20 @@ public class ManagedBuilderUIPlugin extends Plugin {
}
}
+ /**
+ * Answers the <code>Shell</code> associated with the active workbench, or
+ * one of the windows associated with the workbench.
+ * @return
+ */
+ public Shell getShell() {
+ if (getActiveWorkbenchShell() != null) {
+ return getActiveWorkbenchShell();
+ } else {
+ IWorkbenchWindow[] windows = getDefault().getWorkbench().getWorkbenchWindows();
+ return windows[0].getShell();
+ }
+ }
+
public static String getFormattedString(String key, String arg) {
return MessageFormat.format(getResourceString(key), new String[] { arg });
}
@@ -117,4 +149,52 @@ public class ManagedBuilderUIPlugin extends Plugin {
ErrorDialog.openError(shell, title, message, status);
}
+ /**
+ * Convenience method to log an exception without displaying a
+ * message dialog
+ * @param e
+ */
+ public static void logException(Throwable e) {
+ logException(e, null, null);
+ }
+
+ /**
+ * @param exception
+ * @param string
+ * @param string2
+ */
+ public static void logException(Throwable exception, final String title, String message) {
+ if (exception instanceof InvocationTargetException) {
+ exception = ((InvocationTargetException) exception).getTargetException();
+ }
+ IStatus status = null;
+ if (exception instanceof CoreException)
+ status = ((CoreException) exception).getStatus();
+ else {
+ if (message == null)
+ message = exception.getMessage();
+ if (message == null)
+ message = exception.toString();
+ status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, message, exception);
+ }
+ ResourcesPlugin.getPlugin().getLog().log(status);
+ Display display;
+ display = Display.getCurrent();
+ if (display == null)
+ display = Display.getDefault();
+ final IStatus fstatus = status;
+ display.asyncExec(new Runnable() {
+ public void run() {
+ ErrorDialog.openError(null, title, null, fstatus);
+ }
+ });
+ }
+
+ /**
+ * @return
+ */
+ public static IWorkspace getWorkspace() {
+ return ResourcesPlugin.getWorkspace();
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedMakeStartup.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedMakeStartup.java
new file mode 100644
index 0000000000..620d8f44b8
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedMakeStartup.java
@@ -0,0 +1,52 @@
+/**********************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.ui;
+
+import org.eclipse.cdt.managedbuilder.ui.actions.UpdateManagedProjectAction;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IStartup;
+
+/**
+ *
+ */
+public class ManagedMakeStartup implements IStartup {
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IStartup#earlyStartup()
+ */
+ public void earlyStartup() {
+ // Get any 1.2 projects from the workspace
+ final IProject[] projects = UpdateManagedProjectAction.getVersion12Projects();
+ if (projects.length > 0) {
+ Display.getDefault().asyncExec(new Runnable() {
+ // Start the process that will update the 1.2 projects
+ public void run() {
+ Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
+ for (int index = projects.length - 1; index >= 0; --index) {
+ IProject project = projects[index];
+ boolean shouldUpdate = MessageDialog.openQuestion(shell,
+ ManagedBuilderUIPlugin.getResourceString("ManagedBuilderStartup.update.12x.title"), //$NON-NLS-1$
+ ManagedBuilderUIPlugin.getFormattedString("ManagedBuilderStartup.update.12x.message", new String[]{project.getName()})); //$NON-NLS-1$
+ // Go for it
+ if (shouldUpdate) {
+ ProgressMonitorDialog pd = new ProgressMonitorDialog(shell);
+ UpdateManagedProjectAction.run(false, pd, project);
+ }
+ }
+
+ }
+ });
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
index 808c14d2fd..7ccd15f1aa 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
@@ -3,8 +3,18 @@
# All Rights Reserved.
#########################################
-# ------- NewProjectCreationPluginPage-------
+# ------- 1.2 Project Update Messages -------
+ManagedBuilderStartup.update.12x.title=Update Managed Builder Project
+ManagedBuilderStartup.update.12x.message=The project {0} has been detected in your workspace.\n Its build settings are stored in a format that is no longer supported.\n Would you like to convert them now?
+ManagedBuilderStartup.update.exception.error=Error
+ManagedBuilderStartup.update.exception.message=Error updating project {0}
+ManagedBuildConvert.12x.monitor.message.project=Updating build settings for project {0}
+ManagedBuildConvert.12x.monitor.message.backup=Backing up the settings file for {0}
+ManagedBuildConvert.12x.warning.title=Backup File Already Exists
+ManagedBuildConvert.12x.warning.message=A backup file already exists for the project {0}.\n Shall I try to convert the project anyway?
+ManagedBuildConvert.12x.cancelled.message=The update operation has been cancelled.\n The build system will not be able to read the project settings until you update the project.
+# ------- NewProjectCreationPluginPage-------
MngMakeProjectWizard.op_error=Managed Make Error
MngMakeProjectWizard.title=Managed Make Project
MngMakeProjectWizard.description=Create a new Managed Make project.
@@ -28,8 +38,10 @@ MngCCWizardSettings.description=Define the Managed Make C++ build settings.
# -- Strings for the platform selection page --
MngMakeProjectWizard.config.title=Select a Target
MngMakeProjectWizard.config.desc=Select the platform and configurations you wish to deploy on
-PlatformBlock.label.platform=Platform:
+PlatformBlock.tip.platform=Select the target of the build goal
+PlatformBlock.label.platform=Build Target:
PlatformBlock.label.configs=Configurations:
+PlatformBlock.label.showall=Show All Targets
# -- Strings for the additional options tab
MngMakeProjectWizard.options.title=Additional Project Settings
@@ -50,6 +62,7 @@ BuildPropertyPage.tip.addconf=Add configurations for the platform
BuildPropertyPage.tip.remconf=Remove configurations for the platform
BuildPropertyPage.manage.title=Manage
BuildPropertyPage.error.Unknown_tree_element=Unknown type of element in tree of type {0}
+BuildPropertyPage.error.version_low=The project settings are stored in an earlier format.\nYou must upgrade the project before the settings can be upgraded.
# ----------- Entry Dialog -----------
BrowseEntryDialog.error.Folder_name_invalid = Folder name invalid
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/UpdateManagedProjectAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/UpdateManagedProjectAction.java
new file mode 100644
index 0000000000..adcf777035
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/UpdateManagedProjectAction.java
@@ -0,0 +1,577 @@
+/**********************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.actions;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Random;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolReference;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * @since 2.0
+ */
+public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegate {
+
+
+ private static final String ID_CYGWIN = "cygwin"; //$NON-NLS-1$
+ private static final String ID_DEBUG = "debug"; //$NON-NLS-1$
+ private static final String ID_DIRS = "dirs"; //$NON-NLS-1$
+ private static final String ID_EXE = "exe"; //$NON-NLS-1$
+ private static final String ID_EXEC = "exec"; //$NON-NLS-1$
+ private static final String ID_GENERAL = "general"; //$NON-NLS-1$
+ private static final String ID_GNU = "gnu"; //$NON-NLS-1$
+ private static final String ID_INCPATHS = "incpaths"; //$NON-NLS-1$
+ private static final String ID_INCLUDE = "include"; //$NON-NLS-1$
+ private static final String ID_LINUX = "linux"; //$NON-NLS-1$
+ private static final String ID_OPTION = "option"; //$NON-NLS-1$
+ private static final String ID_OPTIONS = "options"; //$NON-NLS-1$
+ private static final String ID_PATHS = "paths"; //$NON-NLS-1$
+ private static final String ID_PREPROC = "preprocessor"; //$NON-NLS-1$
+ private static final String ID_RELEASE = "release"; //$NON-NLS-1$
+ private static final String ID_SEPARATOR = "."; //$NON-NLS-1$
+ private static final String ID_SHARED = "so"; //$NON-NLS-1$
+ private static final String ID_SOLARIS = "solaris"; //$NON-NLS-1$
+ private static final String ID_STATIC = "lib"; //$NON-NLS-1$
+ private static final String NEW_CONFIG_ROOT = "cdt.managedbuild.config.gnu"; //$NON-NLS-1$
+ private static final String NEW_CYGWIN_TARGET_ROOT = "cdt.managedbuild.target.gnu.cygwin"; //$NON-NLS-1$
+ private static final String NEW_POSIX_TARGET_ROOT = "cdt.managedbuild.target.gnu"; //$NON-NLS-1$
+ private static final String NEW_TOOL_ROOT = "cdt.managedbuild.tool.gnu"; //$NON-NLS-1$
+ private static final String TOOL_LANG_BOTH = "both"; //$NON-NLS-1$
+ private static final String TOOL_LANG_C = "c"; //$NON-NLS-1$
+ private static final String TOOL_LANG_CPP = "cpp"; //$NON-NLS-1$
+ private static final String TOOL_NAME_AR = "ar"; //$NON-NLS-1$
+ private static final String TOOL_NAME_ARCHIVER = "archiver"; //$NON-NLS-1$
+ private static final String TOOL_NAME_COMPILER = "compiler"; //$NON-NLS-1$
+ private static final String TOOL_NAME_LIB = "lib"; //$NON-NLS-1$
+ private static final String TOOL_NAME_LINK = "link"; //$NON-NLS-1$
+ private static final String TOOL_NAME_LINKER = "linker"; //$NON-NLS-1$
+ private static final String TOOL_NAME_SOLINK = "solink"; //$NON-NLS-1$
+ private static final int TOOL_TYPE_COMPILER = 0;
+ private static final int TOOL_TYPE_LINKER = 1;
+ private static final int TOOL_TYPE_ARCHIVER = 2;
+ private static final int TYPE_EXE = 0;
+ private static final int TYPE_SHARED = 1;
+ private static final int TYPE_STATIC = 2;
+
+ /* (non-Javadoc)
+ * Create a back-up file containing the pre-2.0 project settings.
+ *
+ * @param settingsFile
+ * @param monitor
+ * @param project
+ * @throws CoreException
+ */
+ protected static void backupFile(IFile settingsFile, IProgressMonitor monitor, IProject project) throws CoreException {
+ // Make a back-up of the settings file
+ String newName = settingsFile.getName() + "_12backup"; //$NON-NLS-1$
+ IContainer destFolder = (IContainer)project;
+ IFile backupFile = destFolder.getFile(new Path(newName));
+ if (backupFile.exists()) {
+ Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
+ boolean shouldUpdate = MessageDialog.openQuestion(shell,
+ ManagedBuilderUIPlugin.getResourceString("ManagedBuildConvert.12x.warning.title"), //$NON-NLS-1$
+ ManagedBuilderUIPlugin.getFormattedString("ManagedBuildConvert.12x.warning.message", new String[]{project.getName()})); //$NON-NLS-1$
+ if (shouldUpdate) {
+ backupFile.delete(true, monitor);
+ } else {
+ monitor.setCanceled(true);
+ throw new OperationCanceledException(ManagedBuilderUIPlugin.getFormattedString("ManagedBuildConvert.12x.cancelled.message", new String[]{project.getName()}));
+ }
+ }
+ settingsFile.copy(backupFile.getFullPath(), true, monitor); //$NON-NLS-1$
+ }
+
+ protected static void convertConfiguration(ITarget newTarget, ITarget newParent, Element oldConfig, IProgressMonitor monitor) {
+ IConfiguration newParentConfig = null;
+ IConfiguration newConfig = null;
+ boolean cygwin = false;
+ boolean debug = false;
+ int type = -1;
+
+ // Figure out what the original parent of the config is
+ String parentId = oldConfig.getAttribute(IConfiguration.PARENT);
+ StringTokenizer idTokens = new StringTokenizer(parentId, ID_SEPARATOR);
+ while (idTokens.hasMoreTokens()) {
+ String id = idTokens.nextToken();
+ if (id.equalsIgnoreCase(ID_CYGWIN)) {
+ cygwin = true;
+ } else if(id.equalsIgnoreCase(ID_EXEC)) {
+ type = TYPE_EXE;
+ } else if(id.equalsIgnoreCase(ID_SHARED)) {
+ type = TYPE_SHARED;
+ } else if (id.equalsIgnoreCase(ID_STATIC)) {
+ type = TYPE_STATIC;
+ } else if (id.equalsIgnoreCase(ID_DEBUG)) {
+ debug = true;
+ }
+ }
+ String defId = NEW_CONFIG_ROOT + ID_SEPARATOR;
+ if (cygwin) defId += ID_CYGWIN + ID_SEPARATOR;
+ switch (type) {
+ case TYPE_EXE:
+ defId += ID_EXE;
+ break;
+ case TYPE_SHARED :
+ defId += ID_SHARED;
+ break;
+ case TYPE_STATIC :
+ defId += ID_STATIC;
+ break;
+ }
+ defId += ID_SEPARATOR + (debug ? "debug" : "release");
+ newParentConfig = newParent.getConfiguration(defId);
+ if (newParentConfig == null) {
+ // Create a default gnu exe release or debug
+ }
+ // Generate a random number for the new config id
+ Random rand = new Random();
+ rand.setSeed(System.currentTimeMillis());
+ int randomElement = rand.nextInt();
+ if (randomElement < 0) {
+ randomElement *= -1;
+ }
+ // Create the new configuration
+ newConfig = newTarget.createConfiguration(newParentConfig, defId + ID_SEPARATOR + randomElement);
+
+ // Convert the tool references
+ NodeList toolRefNodes = oldConfig.getElementsByTagName(IConfiguration.TOOLREF_ELEMENT_NAME);
+ for (int refIndex = 0; refIndex < toolRefNodes.getLength(); ++refIndex) {
+ convertToolRef(newConfig, (Element) toolRefNodes.item(refIndex), monitor);
+ }
+ monitor.worked(1);
+ }
+
+ protected static void convertOptionRef(IConfiguration newConfig, ITool newTool, Element optRef) {
+ String optId = optRef.getAttribute(IOption.ID);
+ if (optId == null) return;
+ String[] idTokens = optId.split("\\."); //$NON-NLS-1$
+
+ // New ID will be in for gnu.[compiler|link|lib].[c|c++|both].option.{1.2_component}
+ Vector newIdVector = new Vector(idTokens.length + 2);
+
+ // We can ignore the first element of the old IDs since it is just [cygwin|linux|solaris]
+ for (int index = 1; index < idTokens.length; ++index) {
+ newIdVector.add(idTokens[index]);
+ }
+
+ // In the case of some Cygwin C++ tools, the old ID will be missing gnu
+ if (!((String)newIdVector.firstElement()).equals(ID_GNU)) {
+ newIdVector.add(0, ID_GNU);
+ }
+
+ // In some old IDs the language specifier is missing for librarian and C++ options
+ String langToken = (String)newIdVector.get(1);
+ if(!langToken.equals(TOOL_LANG_C)) {
+ // In the case of the librarian the language must b set to both
+ if (langToken.equals(TOOL_NAME_LIB) || langToken.equals(TOOL_NAME_AR)) {
+ newIdVector.add(1, TOOL_LANG_BOTH);
+ } else {
+ newIdVector.add(1, TOOL_LANG_CPP);
+ }
+ }
+
+ // Standardize the next token to compiler, link, or lib
+ String toolToken = (String)newIdVector.get(2);
+ if (toolToken.equals(ID_PREPROC)) {
+ // Some compiler preprocessor options are missing this
+ newIdVector.add(2, TOOL_NAME_COMPILER);
+ } else if (toolToken.equals(TOOL_NAME_LINKER) || toolToken.equals(TOOL_NAME_SOLINK)) {
+ // Some linker options have linker or solink as the toolname
+ newIdVector.remove(2);
+ newIdVector.add(2, TOOL_NAME_LINK);
+ } else if (toolToken.equals(TOOL_NAME_AR)) {
+ // The cygwin librarian uses ar
+ newIdVector.remove(2);
+ newIdVector.add(2, TOOL_NAME_LIB);
+ }
+
+ // Add in the option tag
+ String optionToken = (String)newIdVector.get(3);
+ if (optionToken.equals(ID_OPTIONS)) {
+ // Some old-style options had "options" in the id
+ newIdVector.remove(3);
+ }
+ newIdVector.add(3, ID_OPTION);
+
+ // Convert any lingering "incpaths" to "include.paths"
+ String badToken = (String) newIdVector.lastElement();
+ if (badToken.equals(ID_INCPATHS)) {
+ newIdVector.addElement(ID_INCLUDE);
+ newIdVector.addElement(ID_PATHS);
+ }
+
+ // Edit out the "general" or "dirs" categories that may be in some older IDs
+ int generalIndex = newIdVector.indexOf(ID_GENERAL);
+ if (generalIndex != -1) {
+ newIdVector.remove(generalIndex);
+ }
+ int dirIndex = newIdVector.indexOf(ID_DIRS);
+ if (dirIndex != -1) {
+ newIdVector.remove(dirIndex);
+ }
+
+ // Construct the new ID
+ String newOptionId = new String();
+ for (int rebuildIndex = 0; rebuildIndex < newIdVector.size(); ++ rebuildIndex) {
+ String token = (String) newIdVector.get(rebuildIndex);
+ newOptionId += token;
+ if (rebuildIndex < newIdVector.size() - 1) {
+ newOptionId += ID_SEPARATOR;
+ }
+ }
+
+ // Get the option from the new tool
+ IOption newOpt = newTool.getOptionById(newOptionId);
+ if (newOpt == null) {
+ // TODO flag warning condition to user
+ return;
+ }
+ try {
+ switch (newOpt.getValueType()) {
+ case IOption.BOOLEAN:
+ Boolean bool = new Boolean(optRef.getAttribute(IOption.DEFAULT_VALUE));
+ newConfig.setOption(newOpt, bool.booleanValue());
+ break;
+ case IOption.STRING:
+ case IOption.ENUMERATED:
+ // This is going to be the human readable form of the enumerated value
+ String name = (String) optRef.getAttribute(IOption.DEFAULT_VALUE);
+ // Convert it to the ID
+ String idValue = newOpt.getEnumeratedId(name);
+ newConfig.setOption(newOpt, idValue != null ? idValue : name);
+ break;
+ case IOption.STRING_LIST:
+ case IOption.INCLUDE_PATH:
+ case IOption.PREPROCESSOR_SYMBOLS:
+ case IOption.LIBRARIES:
+ case IOption.OBJECTS:
+ Vector values = new Vector();
+ NodeList nodes = optRef.getElementsByTagName(IOption.LIST_VALUE);
+ for (int i = 0; i < nodes.getLength(); ++i) {
+ Node node = nodes.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN));
+ if (!isBuiltIn.booleanValue()) {
+ values.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
+ }
+ }
+ }
+ newConfig.setOption(newOpt, (String[])values.toArray(new String[values.size()]));
+ break;
+ }
+ } catch (BuildException e) {
+ // TODO flag error to user
+ return;
+ }
+
+ }
+ protected static ITarget convertTarget(IProject project, Element oldTarget, IProgressMonitor monitor) {
+ // What we want to create
+ ITarget newTarget = null;
+ ITarget newParent = null;
+ // The type of target we are converting from/to
+ int type = -1;
+ // Use the Cygwin or generic target form
+ boolean posix = false;
+
+ // Get the parent
+ String id = oldTarget.getAttribute(ITarget.PARENT);
+
+ // Figure out the new target definition to use for that type
+ StringTokenizer idTokens = new StringTokenizer(id, ID_SEPARATOR);
+ while (idTokens.hasMoreTokens()) {
+ String token = idTokens.nextToken();
+ if (token.equals(ID_LINUX) || token.equals(ID_SOLARIS)) {
+ posix = true;
+ } else if (token.equalsIgnoreCase(ID_EXEC)){
+ type = TYPE_EXE;
+ } else if (token.equalsIgnoreCase(ID_SHARED)){
+ type = TYPE_SHARED;
+ } else if (token.equalsIgnoreCase(ID_SHARED)){
+ type = TYPE_SHARED;
+ }
+ }
+ // Create a target based on the new target type
+ String defID = (posix ? NEW_POSIX_TARGET_ROOT : NEW_CYGWIN_TARGET_ROOT) + ID_SEPARATOR;
+ switch (type) {
+ case TYPE_EXE :
+ defID += ID_EXE;
+ break;
+ case TYPE_SHARED :
+ defID += ID_SHARED;
+ break;
+ case TYPE_STATIC :
+ defID += ID_STATIC;
+ break;
+ }
+
+ // Get the new target definitions we need for the conversion
+ newParent = ManagedBuildManager.getTarget(project, defID);
+ if (newParent == null) {
+ // Return null and let the caller deal with the error reporting
+ return null;
+ }
+
+ try {
+ // Create a new target based on the new parent
+ newTarget = ManagedBuildManager.createTarget(project, newParent);
+
+ // Create new configurations
+ NodeList configNodes = oldTarget.getElementsByTagName(IConfiguration.CONFIGURATION_ELEMENT_NAME);
+ for (int configIndex = 0; configIndex < configNodes.getLength(); ++configIndex) {
+ convertConfiguration(newTarget, newParent, (Element) configNodes.item(configIndex), monitor);
+ }
+ } catch (BuildException e) {
+ ManagedBuilderUIPlugin.logException(e);
+ }
+
+ monitor.worked(1);
+ return newTarget;
+ }
+
+ protected static void convertToolRef(IConfiguration newConfig, Element oldToolRef, IProgressMonitor monitor) {
+ String oldToolId = oldToolRef.getAttribute(IToolReference.ID);
+ // All known tools have id NEW_TOOL_ROOT.[c|cpp].[compiler|linker|archiver]
+ String newToolId = NEW_TOOL_ROOT;
+ boolean cppFlag = true;
+ int toolType = -1;
+
+ // Figure out what kind of tool the ref pointed to
+ StringTokenizer idTokens = new StringTokenizer(oldToolId, ID_SEPARATOR);
+ while (idTokens.hasMoreTokens()) {
+ String token = idTokens.nextToken();
+ if(token.equals(TOOL_LANG_C)) {
+ cppFlag = false;
+ } else if (token.equalsIgnoreCase(TOOL_NAME_COMPILER)) {
+ toolType = TOOL_TYPE_COMPILER;
+ } else if (token.equalsIgnoreCase(TOOL_NAME_AR)) {
+ toolType = TOOL_TYPE_ARCHIVER;
+ } else if (token.equalsIgnoreCase(TOOL_NAME_LIB)) {
+ toolType = TOOL_TYPE_ARCHIVER;
+ } else if (token.equalsIgnoreCase(TOOL_NAME_LINK)) {
+ toolType = TOOL_TYPE_LINKER;
+ } else if (token.equalsIgnoreCase(TOOL_NAME_SOLINK)) {
+ toolType = TOOL_TYPE_LINKER;
+ }
+ }
+
+ // Now complete the new tool id
+ newToolId += ID_SEPARATOR + (cppFlag ? "cpp" : "c") + ID_SEPARATOR;
+ switch (toolType) {
+ case TOOL_TYPE_COMPILER:
+ newToolId += TOOL_NAME_COMPILER;
+ break;
+ case TOOL_TYPE_LINKER:
+ newToolId += TOOL_NAME_LINKER;
+ break;
+ case TOOL_TYPE_ARCHIVER:
+ newToolId += TOOL_NAME_ARCHIVER;
+ break;
+ }
+
+ // Get the new tool out of the configuration
+ ITool newTool = newConfig.getToolById(newToolId);
+ // Check that this is not null
+
+ // The ref may or may not contain overridden options
+ NodeList optRefs = oldToolRef.getElementsByTagName(ITool.OPTION_REF);
+ for (int refIndex = optRefs.getLength() - 1; refIndex >= 0; --refIndex) {
+ convertOptionRef(newConfig, newTool, (Element) optRefs.item(refIndex));
+ }
+ monitor.worked(1);
+ }
+
+ /**
+ * @param monitor the monitor to allow users to cancel the long-running operation
+ * @param project the <code>IProject</code> that needs to be upgraded
+ * @throws CoreException
+ */
+ protected static void doProjectUpdate(IProgressMonitor monitor, IProject project) throws CoreException {
+ String[] projectName = new String[]{project.getName()};
+ IFile settingsFile = project.getFile(ManagedBuildManager.SETTINGS_FILE_NAME);
+ if (!settingsFile.exists()) {
+ monitor.done();
+ return;
+ }
+
+ // Backup the file
+ monitor.beginTask(ManagedBuilderUIPlugin.getFormattedString("ManagedBuildConvert.12x.monitor.message.backup", projectName), 1); //$NON-NLS-1$
+ backupFile(settingsFile, monitor, project);
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+
+ //Now convert each target to the new format
+ try {
+ // Load the old build file
+ InputStream stream = settingsFile.getContents();
+ DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document document = parser.parse(stream);
+
+ // Clone the target based on the proper target definition
+ NodeList targetNodes = document.getElementsByTagName(ITarget.TARGET_ELEMENT_NAME);
+ // This is a guess, but typically the project has 1 target, 2 configs, and 6 tool defs
+ int listSize = targetNodes.getLength();
+ monitor.beginTask(ManagedBuilderUIPlugin.getFormattedString("ManagedBuildConvert.12x.monitor.message.project", projectName), listSize * 9); //$NON-NLS-1$
+ for (int targIndex = 0; targIndex < listSize; ++targIndex) {
+ Element oldTarget = (Element) targetNodes.item(targIndex);
+ String oldTargetId = oldTarget.getAttribute(ITarget.ID);
+ ITarget newTarget = convertTarget(project, oldTarget, monitor);
+
+ // Remove the old target
+ if (newTarget != null) {
+ info.removeTarget(oldTargetId);
+ monitor.worked(9);
+ }
+ }
+ // Upgrade the version
+ ((ManagedBuildInfo)info).setVersion(ManagedBuildManager.getBuildInfoVersion().toString());
+ } catch (ParserConfigurationException e) {
+ ManagedBuilderUIPlugin.log(e);
+ } catch (FactoryConfigurationError e) {
+ ManagedBuilderUIPlugin.log(e);
+ } catch (SAXException e) {
+ ManagedBuilderUIPlugin.log(e);
+ } catch (IOException e) {
+ ManagedBuilderUIPlugin.log(e);
+ } finally {
+ ManagedBuildManager.saveBuildInfo(project, false);
+ monitor.done();
+ }
+ }
+
+ /**
+ * Determines which projects in the workspace are still using
+ * the settings format defined in CDT 1.2.x.
+ *
+ * @return an array of <code>IProject</code> that need to have their
+ * project settings updated to the CDT 2.0 format
+ */
+ public static IProject[] getVersion12Projects() {
+ IProject[] projects = ManagedBuilderUIPlugin.getWorkspace().getRoot().getProjects();
+ Vector result = new Vector();
+ for (int index = projects.length - 1; index >=0 ; --index) {
+ IProjectDescription description;
+ try {
+ description = projects[index].getDescription();
+ } catch (CoreException e) {
+ ManagedBuilderUIPlugin.log(e);
+ continue;
+ }
+ // Make sure it has a managed nature
+ if (description == null || !description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
+ continue;
+ }
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(projects[index]);
+ if (info != null && info.getVersion()== null) {
+ // This is a pre-2.0 file (no version info)
+ result.add(projects[index]);
+ }
+ }
+
+ return (IProject[]) result.toArray(new IProject[result.size()]);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+ */
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void init(IWorkbenchWindow window) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ // TODO Auto-generated method stub
+
+ }
+
+ static public void run(boolean fork, IRunnableContext context, final IProject project) {
+ try {
+ context.run(fork, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ doProjectUpdate(monitor, project);
+ }
+ };
+ ManagedBuilderUIPlugin.getWorkspace().run(runnable, monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } catch (OperationCanceledException e) {
+ throw new InterruptedException(e.getMessage());
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ return;
+ } catch (InvocationTargetException e) {
+ ManagedBuilderUIPlugin.logException(e,
+ ManagedBuilderUIPlugin.getResourceString("ManagedBuilderStartup.update.exception.error"), //$NON-NLS-1$
+ ManagedBuilderUIPlugin.getFormattedString("ManagedBuilderStartup.update.exception.message", new String[]{project.getName()})); //$NON-NLS-2$
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
index 7b9e69d8f2..ba898ada06 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
@@ -169,14 +169,25 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
}
protected Control createContents(Composite parent) {
+ // Create the container we return to the property page editor
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+ composite.setLayout(new GridLayout(1, true));
+ GridData gd;
+
// Initialize the key data
- targets = ManagedBuildManager.getTargets(getProject());
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject(), true);
+ if (info.getVersion() == null) {
+ // Display a message page instead of the properties control
+ final Label invalidInfo = new Label(composite, SWT.LEFT);
+ invalidInfo.setFont(composite.getFont());
+ invalidInfo.setText(ManagedBuilderUIPlugin.getResourceString("BuildPropertyPage.error.version_low")); //$NON-NLS-1$
+ invalidInfo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_CENTER, true, true));
+ return composite;
+ }
+ targets = ManagedBuildManager.getTargets(getProject());
ITarget defaultTarget = info.getDefaultTarget();
- // Create the container we return to the property page editor
- Composite composite = ControlFactory.createComposite(parent, 1);
- GridData gd;
// Add a config selection area
Group configGroup = ControlFactory.createGroup(composite, ManagedBuilderUIPlugin.getResourceString(ACTIVE_LABEL), 1);
@@ -456,6 +467,10 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
* @return
*/
private List getPagesForConfig() {
+ // Make sure that something was selected
+ if (selectedConfiguration == null) {
+ return null;
+ }
List pages = (List) configToPageListMap.get(selectedConfiguration.getId());
if (pages == null) {
pages = new ArrayList();
@@ -858,6 +873,11 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
public boolean performOk() {
// Force each settings page to update
List pages = getPagesForConfig();
+ // Make sure we have something to work on
+ if (pages == null) {
+ // Nothing to do
+ return true;
+ }
ListIterator iter = pages.listIterator();
while (iter.hasNext()) {
BuildSettingsPage page = (BuildSettingsPage) iter.next();
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java
index 012b7c7a23..47d4857d6e 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java
@@ -75,6 +75,7 @@ public class FileListControl {
super.createButtonsForButtonBar(parent);
if (type != IOption.BROWSE_NONE) {
final Button browse = createButton(parent, 3, ManagedBuilderUIPlugin.getResourceString(BROWSE), true);
+ getOkButton().setFocus();
browse.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent ev) {
String currentName;
@@ -89,6 +90,8 @@ public class FileListControl {
result = dialog.open();
if(result != null) {
getText().setText(result);
+ // Give the OK button focus
+ getOkButton().setFocus();
}
break;
case IOption.BROWSE_FILE:
@@ -100,6 +103,8 @@ public class FileListControl {
result = browseDialog.open();
if (result != null) {
getText().setText(result);
+ // Give the OK button focus
+ getOkButton().setFocus();
}
break;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
index 29e9384a7e..d46d2f98c4 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
@@ -21,16 +21,21 @@ import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
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.Event;
@@ -38,7 +43,6 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
public class CProjectPlatformPage extends WizardPage {
/*
@@ -55,12 +59,14 @@ public class CProjectPlatformPage extends WizardPage {
*/
protected Combo platformSelection;
protected CheckboxTableViewer tableViewer;
+ protected Button showAll;
private static final String PREFIX = "PlatformBlock"; //$NON-NLS-1$
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
- private static final String PLATFORM_TIP = TIP + ".platform"; //$NON-NLS-1$
- private static final String PLATFORM_LABEL = LABEL + ".platform"; //$NON-NLS-1$
+ private static final String TARGET_TIP = TIP + ".platform"; //$NON-NLS-1$
+ private static final String TARGET_LABEL = LABEL + ".platform"; //$NON-NLS-1$
private static final String CONFIG_LABEL = LABEL + ".configs"; //$NON-NLS-1$
+ private static final String SHOWALL_LABEL = LABEL + ".showall"; //$NON-NLS-1$
/**
* Constructor.
@@ -70,7 +76,6 @@ public class CProjectPlatformPage extends WizardPage {
public CProjectPlatformPage(String pageName, NewManagedProjectWizard parentWizard) {
super(pageName);
setPageComplete(false);
- populateTargets();
selectedTarget = null;
selectedConfigurations = new ArrayList(0);
this.parentWizard = parentWizard;
@@ -83,36 +88,21 @@ public class CProjectPlatformPage extends WizardPage {
return validatePage();
}
- /**
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- // Create the composite control for the tab
- Composite composite = ControlFactory.createComposite(parent, 6);
-
- // Create the platform selection label and combo widgets
- Label platformLabel = ControlFactory.createLabel(composite, ManagedBuilderUIPlugin.getResourceString(PLATFORM_LABEL));
- platformLabel.setLayoutData(new GridData());
-
- platformSelection = ControlFactory.createSelectCombo(composite, targetNames, null);
-// platformSelection.setToolTipText(ManagedBuilderUIPlugin.getResourceString(PLATFORM_TIP));
- platformSelection.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- handleTargetSelection();
- }
- });
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 5;
- platformSelection.setLayoutData(gd);
+ private void createConfigSelectionGroup (Composite parent) {
+ // Create the group composite
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
// Create a check box table of valid configurations
- Label configLabel = ControlFactory.createLabel(composite, ManagedBuilderUIPlugin.getResourceString(CONFIG_LABEL));
- configLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ final Label configLabel = new Label(composite, SWT.LEFT);
+ configLabel.setFont(composite.getFont());
+ configLabel.setText(ManagedBuilderUIPlugin.getResourceString(CONFIG_LABEL));
+
Table table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.MULTI
| SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
- gd = new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan = 6;
- table.setLayoutData(gd);
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
table.setHeaderVisible(true);
table.setLinesVisible(false);
@@ -131,12 +121,31 @@ public class CProjectPlatformPage extends WizardPage {
handleConfigurationSelectionChange();
}
});
-
- // Select the first target in the list
- handleTargetSelection();
-
+
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ // Create the composite control for the tab
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
// Setup the help information
WorkbenchHelp.setHelp(composite, ManagedBuilderHelpContextIds.MAN_PROJ_PLATFORM_HELP);
+
+ // Create the widgets
+ createTargetSelectGroup(composite);
+ createConfigSelectionGroup(composite);
+ createShowAllGroup(composite);
+
+ // Select the first target in the list
+ populateTargets();
+ platformSelection.select(0);
+ handleTargetSelection();
// Do the nasty
setErrorMessage(null);
@@ -144,6 +153,65 @@ public class CProjectPlatformPage extends WizardPage {
setControl(composite);
}
+ private void createShowAllGroup(Composite parent) {
+ // Create the group composite
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ showAll = new Button(composite, SWT.CHECK | SWT.LEFT);
+ showAll.setFont(composite.getFont());
+ showAll.setText(ManagedBuilderUIPlugin.getResourceString(SHOWALL_LABEL));
+ showAll.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ populateTargets();
+ platformSelection.select(0);
+ handleTargetSelection();
+ }
+ });
+ showAll.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent event) {
+ showAll = null;
+ }
+ });
+ }
+
+ private void createTargetSelectGroup(Composite parent) {
+ // Create the group composite
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+ composite.setLayout(new GridLayout(2, false));
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Create the platform selection label and combo widgets
+ final Label platformLabel = new Label(composite, SWT.LEFT);
+ platformLabel.setFont(composite.getFont());
+ platformLabel.setText(ManagedBuilderUIPlugin.getResourceString(TARGET_LABEL));
+
+ platformSelection = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
+ platformSelection.setFont(composite.getFont());
+ platformSelection.setToolTipText(ManagedBuilderUIPlugin.getResourceString(TARGET_TIP));
+ platformSelection.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ handleTargetSelection();
+ }
+ });
+ platformSelection.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ platformSelection = null;
+ }
+ });
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ // Make this the same as NewCProjectWizardPage.SIZING_TEXT_FIELD_WIDTH
+ gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH + 50;
+ platformSelection.setLayoutData(gd);
+ }
+
+ /**
+ * @return
+ */
public IConfiguration[] getSelectedConfigurations() {
return (IConfiguration[]) selectedConfigurations.toArray(new IConfiguration[selectedConfigurations.size()]);
}
@@ -198,6 +266,10 @@ public class CProjectPlatformPage extends WizardPage {
handleConfigurationSelectionChange();
}
+ /* (non-Javadoc)
+ * Extracts the names from the targets that are valid for the wizard
+ * session and populates the combo widget with them.
+ */
private void populateTargetNames() {
targetNames = new String[targets.size()];
ListIterator iter = targets.listIterator();
@@ -205,8 +277,15 @@ public class CProjectPlatformPage extends WizardPage {
while (iter.hasNext()) {
targetNames[index++] = ((ITarget) iter.next()).getName();
}
+
+ // Now setup the combo
+ platformSelection.removeAll();
+ platformSelection.setItems(targetNames);
}
+ /* (non-Javadoc)
+ * Collects all the valid targets for the platform Eclipse is running on
+ */
private void populateTargets() {
// Get a list of platforms defined by plugins
ITarget[] allTargets = ManagedBuildManager.getDefinedTargets(null);
@@ -216,9 +295,14 @@ public class CProjectPlatformPage extends WizardPage {
for (int index = 0; index < allTargets.length; ++index) {
ITarget target = allTargets[index];
if (!target.isAbstract() && !target.isTestTarget()) {
- List targetOSList = Arrays.asList(target.getTargetOSList());
- if (targetOSList.contains(os)) {
+ // If the check box is selected show all the targets
+ if (showAll != null && showAll.getSelection() == true) {
targets.add(target);
+ } else {
+ List targetOSList = Arrays.asList(target.getTargetOSList());
+ if (targetOSList.contains("all") || targetOSList.contains(os)) { //$NON-NLS-1$
+ targets.add(target);
+ }
}
}
}
@@ -230,7 +314,7 @@ public class CProjectPlatformPage extends WizardPage {
* @return
*/
private boolean validatePage() {
- // TODO Auto-generated method stub
+ // TODO some validation ... maybe
return true;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
index 37fde58738..24276948fc 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
@@ -129,6 +129,7 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
ManagedBuildManager.setDefaultConfiguration(newProject, newConfigs[0]);
}
ManagedBuildManager.setSelectedTarget(newProject, newTarget);
+ ManagedBuildManager.setNewProjectVersion(newProject);
}
} catch (BuildException e) {
// TODO Flag the error to the user
@@ -141,7 +142,7 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
desc.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
- // org.eclipse.cdt.core.ELF or "org.eclipse.cdt.core.PE"
+ // org.eclipse.cdt.core.ELF or org.eclipse.cdt.core.PE
desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, newTarget.getBinaryParserId());
} catch (CoreException e) {
// TODO Flag the error to the user

Back to the top