1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 17:35:35 +02:00

Add Description attribute to Configuration.

Redo Manage Configurations dialog box and add UI for renaming a configuration
This commit is contained in:
Leo Treggiari 2005-05-02 19:44:51 +00:00
parent c69bab5a9f
commit 1e5fda4a2c
23 changed files with 1430 additions and 248 deletions

View file

@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (c) 2004 Intel Corporation and others.
* Copyright (c) 2004, 2005 Intel 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
@ -29,6 +29,10 @@ public interface IBuilder extends IBuildObject {
public static final String BUILDFILEGEN_ID ="buildfileGenerator"; //$NON-NLS-1$
public static final String COMMAND = "command"; //$NON-NLS-1$
public static final String VERSIONS_SUPPORTED = "versionsSupported"; //$NON-NLS-1$
public static final String CONVERT_TO_ID = "convertToId"; //$NON-NLS-1$
/**
* Returns the command line arguments to pass to the build/make utility used
* to build a configuration.
@ -156,5 +160,36 @@ public interface IBuilder extends IBuildObject {
* @param b
*/
public void setIsAbstract(boolean b);
/**
* Returns the 'versionsSupported' of this builder
*
* @return String
*/
public String getVersionsSupported();
/**
* Returns the 'convertToId' of this builder
*
* @return String
*/
public String getConvertToId();
/**
* Sets the 'versionsSupported' attribute of the builder.
*
* @param versionsSupported
*/
public void setVersionsSupported(String versionsSupported);
/**
* Sets the 'convertToId' attribute of the builder.
*
* @param convertToId
*/
public void setConvertToId(String convertToId);
}

View file

@ -38,6 +38,24 @@ public interface IConfiguration extends IBuildObject {
public static final String ERROR_PARSERS = "errorParsers"; //$NON-NLS-1$
public static final String EXTENSION = "artifactExtension"; //$NON-NLS-1$
public static final String PARENT = "parent"; //$NON-NLS-1$
public static final String DESCRIPTION = "description"; //$NON-NLS-1$
/**
* Returns the description of the configuration.
*
* @return String
*/
public String getDescription();
/**
* Sets the description of the receiver to the value specified in the argument
*
* @param description
*/
public void setDescription(String description);
/**
* Creates a child resource configuration corresponding to the passed in file.

View file

@ -0,0 +1,24 @@
/**********************************************************************
* Copyright (c) 2005 Intel 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:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.managedbuilder.core;
public interface IConfigurationNameProvider {
/*
* Returns the new unique configuration name based on the 'configuration'
* object and the list of configuration names already in use in the project.
*
*/
String getNewConfigurationName(IConfiguration configuration, String [] usedConfigurationNames );
}

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.managedbuilder.core;
import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier;
import org.eclipse.core.runtime.IConfigurationElement;
/**
* This class represents project-types in the managed build system.
@ -47,6 +46,7 @@ public interface IProjectType extends IBuildObject {
public static final String IS_ABSTRACT = "isAbstract"; //$NON-NLS-1$
public static final String UNUSED_CHILDREN = "unusedChildren"; //$NON-NLS-1$
public static final String IS_TEST = "isTest"; //$NON-NLS-1$
public static final String CONFIGURATION_NAME_PROVIDER = "configurationNameProvider"; //$NON-NLS-1$
public static final String PROJECT_ENVIRONMENT_SUPPLIER = "projectEnvironmentSupplier"; //$NON-NLS-1$
/**
@ -140,6 +140,13 @@ public interface IProjectType extends IBuildObject {
*/
public boolean isSupported();
/**
* Returns the configurationNameProvider.
*
* @return IConfigurationNameProvider
*/
public IConfigurationNameProvider getConfigurationNameProvider();
/**
* Returns the tool-integrator provided implementation of the project environment variable supplier
* or <code>null</code> if none.

View file

@ -45,6 +45,9 @@ public interface ITool extends IBuildObject {
public static final String TOOL_ELEMENT_NAME = "tool"; //$NON-NLS-1$
public static final String WHITE_SPACE = " "; //$NON-NLS-1$
public static final String VERSIONS_SUPPORTED = "versionsSupported"; //$NON-NLS-1$
public static final String CONVERT_TO_ID = "convertToId"; //$NON-NLS-1$
public static final int FILTER_C = 0;
public static final int FILTER_CC = 1;
public static final int FILTER_BOTH = 2;
@ -689,6 +692,34 @@ public interface ITool extends IBuildObject {
*/
public boolean isExtensionElement();
/**
* Returns the 'versionsSupported' of this tool
*
* @return String
*/
public String getVersionsSupported();
/**
* Returns the 'convertToId' of this tool
*
* @return String
*/
public String getConvertToId();
/**
* Sets the 'versionsSupported' attribute of the tool.
*
* @param versionsSupported
*/
public void setVersionsSupported(String versionsSupported);
/**
* Sets the 'convertToId' attribute of the tool.
*
* @param convertToId
*/
public void setConvertToId(String convertToId);
/**
* Returns an array of the Environment Build Path variable descriptors
*

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.managedbuilder.core;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
import org.eclipse.core.runtime.IConfigurationElement;
/**
@ -35,6 +34,8 @@ public interface IToolChain extends IBuildObject {
public static final String OS_LIST = "osList"; //$NON-NLS-1$
public static final String ARCH_LIST = "archList"; //$NON-NLS-1$
public static final String ERROR_PARSERS = "errorParsers"; //$NON-NLS-1$
public static final String VERSIONS_SUPPORTED = "versionsSupported"; //$NON-NLS-1$
public static final String CONVERT_TO_ID = "convertToId"; //$NON-NLS-1$
public static final String TARGET_TOOL = "targetTool"; //$NON-NLS-1$
public static final String SECONDARY_OUTPUTS = "secondaryOutputs"; //$NON-NLS-1$
public static final String IS_TOOL_CHAIN_SUPPORTED = "isToolChainSupported"; //$NON-NLS-1$
@ -75,6 +76,36 @@ public interface IToolChain extends IBuildObject {
*/
public void removeLocalTargetPlatform();
/**
* Returns the 'versionsSupported' of this tool-chain
*
* @return String
*/
public String getVersionsSupported();
/**
* Returns the 'convertToId' of this tool-chain
*
* @return String
*/
public String getConvertToId();
/**
* Sets the 'versionsSupported' attribute of the tool-chain.
*
* @param versionsSupported
*/
public void setVersionsSupported(String versionsSupported);
/**
* Sets the 'convertToId' attribute of the tool-chain.
*
* @param convertToId
*/
public void setConvertToId(String convertToId);
/**
* Creates the <code>Builder</code> child of this tool-chain.
*

View file

@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (c) 2004 TimeSys Corporation and others.
* Copyright (c) 2004, 2005 TimeSys 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

View file

@ -40,6 +40,9 @@ public class Builder extends BuildObject implements IBuilder {
private String command;
private String args;
private IConfigurationElement buildFileGeneratorElement;
private String versionsSupported;
private String convertToId;
// Miscellaneous
private boolean isExtensionBuilder = false;
private boolean isDirty = false;
@ -177,6 +180,12 @@ public class Builder extends BuildObject implements IBuilder {
// Get the unused children, if any
unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
// Get the 'versionsSupported' attribute
versionsSupported = element.getAttribute(VERSIONS_SUPPORTED);
// Get the 'convertToId' attribute
convertToId = element.getAttribute(CONVERT_TO_ID);
// isAbstract
String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
if (isAbs != null){
@ -224,6 +233,16 @@ public class Builder extends BuildObject implements IBuilder {
}
}
// Get the 'versionSupported' attribute
if (element.hasAttribute(VERSIONS_SUPPORTED)) {
versionsSupported = element.getAttribute(VERSIONS_SUPPORTED);
}
// Get the 'convertToId' id
if (element.hasAttribute(CONVERT_TO_ID)) {
convertToId = element.getAttribute(CONVERT_TO_ID);
}
// Get the unused children, if any
if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
@ -283,6 +302,16 @@ public class Builder extends BuildObject implements IBuilder {
element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
}
// versionsSupported
if (versionsSupported != null) {
element.setAttribute(VERSIONS_SUPPORTED, versionsSupported);
}
// convertToId
if (convertToId != null) {
element.setAttribute(CONVERT_TO_ID, convertToId);
}
if (errorParserIds != null) {
element.setAttribute(IToolChain.ERROR_PARSERS, errorParserIds);
}
@ -533,5 +562,60 @@ public class Builder extends BuildObject implements IBuilder {
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuilder#getConvertToId()
*/
public String getConvertToId() {
if (convertToId == null) {
// If I have a superClass, ask it
if (superClass != null) {
return superClass.getConvertToId();
} else {
return EMPTY_STRING;
}
}
return convertToId;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuilder#setConvertToId(String)
*/
public void setConvertToId(String convertToId) {
if (convertToId == null && this.convertToId == null) return;
if (convertToId == null || this.convertToId == null || !convertToId.equals(this.convertToId)) {
this.convertToId = convertToId;
setDirty(true);
}
return;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuilder#getVersionsSupported()
*/
public String getVersionsSupported() {
if (versionsSupported == null) {
// If I have a superClass, ask it
if (superClass != null) {
return superClass.getVersionsSupported();
} else {
return EMPTY_STRING;
}
}
return versionsSupported;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuilder#setVersionsSupported(String)
*/
public void setVersionsSupported(String versionsSupported) {
if (versionsSupported == null && this.versionsSupported == null) return;
if (versionsSupported == null || this.versionsSupported == null || !versionsSupported.equals(this.versionsSupported)) {
this.versionsSupported = versionsSupported;
setDirty(true);
}
return;
}
}

View file

@ -72,6 +72,36 @@ public class Configuration extends BuildObject implements IConfiguration {
private boolean rebuildNeeded = false;
private boolean resolved = true;
private String description;
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getDescription()
*/
public String getDescription() {
if (description == null) {
// If I have a parent, ask it
if (parent != null) {
return parent.getDescription();
} else {
// I'm it
return EMPTY_STRING;
}
} else {
return description;
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setDescription(java.lang.String)
*/
public void setDescription(String description) {
if (description == null && this.description == null) return;
if (this.description == null || description == null || !description.equals(this.description)) {
this.description = description;
isDirty = true;
}
}
/*
* C O N S T R U C T O R S
*/
@ -316,6 +346,9 @@ public class Configuration extends BuildObject implements IConfiguration {
// name
name = element.getAttribute(IConfiguration.NAME);
// description
description = element.getAttribute(IConfiguration.DESCRIPTION);
// parent
String parentID = element.getAttribute(IConfiguration.PARENT);
if (parentID != null) {
@ -359,6 +392,10 @@ public class Configuration extends BuildObject implements IConfiguration {
if (element.hasAttribute(IConfiguration.NAME))
setName(element.getAttribute(IConfiguration.NAME));
// description
if (element.hasAttribute(IConfiguration.DESCRIPTION))
setDescription(element.getAttribute(IConfiguration.DESCRIPTION));
if (element.hasAttribute(IConfiguration.PARENT)) {
// See if the parent belongs to the same project
parent = managedProject.getConfiguration(element.getAttribute(IConfiguration.PARENT));
@ -421,6 +458,9 @@ public class Configuration extends BuildObject implements IConfiguration {
if (name != null)
element.setAttribute(IConfiguration.NAME, name);
if (description != null)
element.setAttribute(IConfiguration.DESCRIPTION, description);
if (parent != null)
element.setAttribute(IConfiguration.PARENT, parent.getId());

View file

@ -0,0 +1,39 @@
/**********************************************************************
* Copyright (c) 2005 Intel 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:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IConfigurationNameProvider;
public class ConfigurationNameProvider implements IConfigurationNameProvider {
private static ConfigurationNameProvider configurationNameProvider;
protected ConfigurationNameProvider() {
configurationNameProvider = null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfigurationNameProvider#getUniqueConfigurationName(org.eclipse.cdt.managedbuilder.core.IConfiguration, java.lang.String[])
*/
public String getNewConfigurationName(IConfiguration configuration,
String[] usedConfigurationNames) {
// TODO Auto-generated method stub
return null;
}
public static ConfigurationNameProvider getConfigurationNameProvider() {
if( configurationNameProvider == null)
configurationNameProvider = new ConfigurationNameProvider();
return configurationNameProvider;
}
}

View file

@ -14,11 +14,9 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Vector;
import org.eclipse.cdt.core.CCorePlugin;

View file

@ -0,0 +1,28 @@
/**********************************************************************
* Copyright (c) 2005 Intel 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:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IConfigurationNameProvider;
public class GnuConfigurationNameProvider implements IConfigurationNameProvider {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfigurationNameProvider#getUniqueConfigurationName(org.eclipse.cdt.managedbuilder.core.IConfiguration, java.lang.String[])
*/
public String getNewConfigurationName(IConfiguration configuration,
String[] usedConfigurationNames) {
// TODO Auto-generated method stub
return null;
}
}

View file

@ -16,13 +16,14 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.managedbuilder.core.IConfigurationNameProvider;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier;
public class ProjectType extends BuildObject implements IProjectType {
@ -39,6 +40,10 @@ public class ProjectType extends BuildObject implements IProjectType {
private Boolean isAbstract;
private Boolean isTest;
private String unusedChildren;
private IConfigurationElement configurationNameProviderElement = null;
private IConfigurationNameProvider configurationNameProvider = null;
private IConfigurationElement environmentVariableSupplierElement = null;
private IProjectEnvironmentVariableSupplier environmentVariableSupplier = null;
@ -66,8 +71,23 @@ public class ProjectType extends BuildObject implements IProjectType {
// Load the configuration children
IManagedConfigElement[] configs = element.getChildren(IConfiguration.CONFIGURATION_ELEMENT_NAME);
for (int n = 0; n < configs.length; ++n) {
Configuration config = new Configuration(this, configs[n]);
String [] usedConfigNames = new String[0];
IConfigurationNameProvider configurationNameProvder = getConfigurationNameProvider();
if ( configurationNameProvder != null ) {
// Tool Integrator provided 'ConfigurationNameProvider' class
// to get configuration names dynamically based architecture, os, toolchain version etc.
for (int n = 0; n < configs.length; ++n) {
Configuration config = new Configuration(this, configs[n]);
String newConfigName = configurationNameProvder.getNewConfigurationName(config, usedConfigNames);
config.setName(newConfigName);
usedConfigNames[n] = newConfigName;
}
} else {
for (int n = 0; n < configs.length; ++n) {
Configuration config = new Configuration(this, configs[n]);
}
}
}
@ -129,12 +149,16 @@ public class ProjectType extends BuildObject implements IProjectType {
isTest = new Boolean("true".equals(isTestStr)); //$NON-NLS-1$
}
// Store the configuration element IFF there is a configuration name provider defined
if (element.getAttribute(CONFIGURATION_NAME_PROVIDER) != null && element instanceof DefaultManagedConfigElement) {
configurationNameProviderElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
}
// Get the environmentVariableSupplier configuration element
String environmentVariableSupplier = element.getAttribute(PROJECT_ENVIRONMENT_SUPPLIER);
if(environmentVariableSupplier != null && element instanceof DefaultManagedConfigElement){
environmentVariableSupplierElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
}
}
/*
@ -364,6 +388,48 @@ public class ProjectType extends BuildObject implements IProjectType {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IProjectType#getConfigurationNameProviderElement()
*/
public IConfigurationElement getConfigurationNameProviderElement() {
if(configurationNameProviderElement == null){
if(superClass != null) {
ProjectType tmpSuperClass = (ProjectType)superClass;
return tmpSuperClass.getConfigurationNameProviderElement();
}
}
return configurationNameProviderElement;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IProjectType#setConfigurationNameProviderElement(IConfigurationElement)
*/
public void setConfigurationNameProviderElement(IConfigurationElement configurationElement) {
configurationNameProviderElement = configurationElement;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IProjectType#getConfigurationNameProvider()
*/
public IConfigurationNameProvider getConfigurationNameProvider() {
if (configurationNameProvider != null) {
return configurationNameProvider;
}
IConfigurationElement element = getConfigurationNameProviderElement();
if (element != null) {
try {
if (element.getAttribute(CONFIGURATION_NAME_PROVIDER) != null) {
configurationNameProvider = (IConfigurationNameProvider) element.createExecutableExtension(CONFIGURATION_NAME_PROVIDER);
return configurationNameProvider;
}
} catch (CoreException e) {}
}
return null;
}
/**
* Returns the plugin.xml element of the projectEnvironmentSupplier extension or <code>null</code> if none.
*

View file

@ -87,6 +87,8 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
private String outputPrefix;
private String errorParserIds;
private String commandLinePattern;
private String versionsSupported;
private String convertToId;
private Boolean advancedInputCategory;
private Boolean customBuildStep;
private String announcement;
@ -403,6 +405,12 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
// Get the unused children, if any
unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
// Get the 'versionsSupported' attribute
versionsSupported =element.getAttribute(VERSIONS_SUPPORTED);
// Get the 'convertToId' attribute
convertToId = element.getAttribute(CONVERT_TO_ID);
// isAbstract
String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
if (isAbs != null){
@ -530,6 +538,16 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
}
}
// Get the 'versionSupported' attribute
if (element.hasAttribute(VERSIONS_SUPPORTED)) {
versionsSupported = element.getAttribute(VERSIONS_SUPPORTED);
}
// Get the 'convertToId' id
if (element.hasAttribute(CONVERT_TO_ID)) {
convertToId = element.getAttribute(CONVERT_TO_ID);
}
// Get the semicolon separated list of IDs of the error parsers
if (element.hasAttribute(IToolChain.ERROR_PARSERS)) {
errorParserIds = element.getAttribute(IToolChain.ERROR_PARSERS);
@ -649,6 +667,16 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
}
// versionsSupported
if (versionsSupported != null) {
element.setAttribute(VERSIONS_SUPPORTED, versionsSupported);
}
// convertToId
if (convertToId != null) {
element.setAttribute(CONVERT_TO_ID, convertToId);
}
// error parsers
if (errorParserIds != null) {
element.setAttribute(IToolChain.ERROR_PARSERS, errorParserIds);
@ -2323,6 +2351,60 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getConvertToId()
*/
public String getConvertToId() {
if (convertToId == null) {
// If I have a superClass, ask it
if (superClass != null) {
return superClass.getConvertToId();
} else {
return EMPTY_STRING;
}
}
return convertToId;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#setConvertToId(String)
*/
public void setConvertToId(String convertToId) {
if (convertToId == null && this.convertToId == null) return;
if (convertToId == null || this.convertToId == null || !convertToId.equals(this.convertToId)) {
this.convertToId = convertToId;
setDirty(true);
}
return;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getVersionsSupported()
*/
public String getVersionsSupported() {
if (versionsSupported == null) {
// If I have a superClass, ask it
if (superClass != null) {
return superClass.getVersionsSupported();
} else {
return EMPTY_STRING;
}
}
return versionsSupported;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#setVersionsSupported(String)
*/
public void setVersionsSupported(String versionsSupported) {
if (versionsSupported == null && this.versionsSupported == null) return;
if (versionsSupported == null || this.versionsSupported == null || !versionsSupported.equals(this.versionsSupported)) {
this.versionsSupported = versionsSupported;
setDirty(true);
}
return;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getEnvVarBuildPaths()
*/
@ -2345,5 +2427,4 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
envVarBuildPathList.add(path);
}
}

View file

@ -58,6 +58,8 @@ public class ToolChain extends BuildObject implements IToolChain {
private String secondaryOutputIds;
private Boolean isAbstract;
private String scannerConfigDiscoveryProfileId;
private String versionsSupported;
private String convertToId;
private IConfigurationElement managedIsToolChainSupportedElement = null;
private IManagedIsToolChainSupported managedIsToolChainSupported = null;
private IConfigurationElement environmentVariableSupplierElement = null;
@ -324,6 +326,12 @@ public class ToolChain extends BuildObject implements IToolChain {
// Get the scanner config discovery profile id
scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
// Get the 'versionsSupported' attribute
versionsSupported =element.getAttribute(VERSIONS_SUPPORTED);
// Get the 'convertToId' attribute
convertToId = element.getAttribute(CONVERT_TO_ID);
// Get the comma-separated list of valid OS
String os = element.getAttribute(OS_LIST);
if (os != null) {
@ -415,6 +423,16 @@ public class ToolChain extends BuildObject implements IToolChain {
scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
}
// Get the 'versionSupported' attribute
if (element.hasAttribute(VERSIONS_SUPPORTED)) {
versionsSupported = element.getAttribute(VERSIONS_SUPPORTED);
}
// Get the 'convertToId' id
if (element.hasAttribute(CONVERT_TO_ID)) {
convertToId = element.getAttribute(CONVERT_TO_ID);
}
// Get the comma-separated list of valid OS
if (element.hasAttribute(OS_LIST)) {
String os = element.getAttribute(OS_LIST);
@ -480,6 +498,16 @@ public class ToolChain extends BuildObject implements IToolChain {
element.setAttribute(SCANNER_CONFIG_PROFILE_ID, scannerConfigDiscoveryProfileId);
}
// versionsSupported
if (versionsSupported != null) {
element.setAttribute(VERSIONS_SUPPORTED, versionsSupported);
}
// convertToId
if (convertToId != null) {
element.setAttribute(CONVERT_TO_ID, convertToId);
}
if (osList != null) {
Iterator osIter = osList.listIterator();
String listValue = EMPTY_STRING;
@ -1114,6 +1142,60 @@ public class ToolChain extends BuildObject implements IToolChain {
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getConvertToId()
*/
public String getConvertToId() {
if (convertToId == null) {
// If I have a superClass, ask it
if (superClass != null) {
return superClass.getConvertToId();
} else {
return EMPTY_STRING;
}
}
return convertToId;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setConvertToId(String)
*/
public void setConvertToId(String convertToId) {
if (convertToId == null && this.convertToId == null) return;
if (convertToId == null || this.convertToId == null || !convertToId.equals(this.convertToId)) {
this.convertToId = convertToId;
setDirty(true);
}
return;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getVersionsSupported()
*/
public String getVersionsSupported() {
if (versionsSupported == null) {
// If I have a superClass, ask it
if (superClass != null) {
return superClass.getVersionsSupported();
} else {
return EMPTY_STRING;
}
}
return versionsSupported;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setVersionsSupported(String)
*/
public void setVersionsSupported(String versionsSupported) {
if (versionsSupported == null && this.versionsSupported == null) return;
if (versionsSupported == null || this.versionsSupported == null || !versionsSupported.equals(this.versionsSupported)) {
this.versionsSupported = versionsSupported;
setDirty(true);
}
return;
}
private IManagedIsToolChainSupported getIsToolChainSupported(){
if(managedIsToolChainSupported == null && managedIsToolChainSupportedElement != null){
try{

View file

@ -48,6 +48,8 @@ public class ToolReference implements IToolReference {
private String outputPrefix;
protected ITool parent;
private boolean resolved = true;
private String versionsSupported;
private String convertToId;
/**
* Create a new tool reference based on information contained in
@ -1092,6 +1094,60 @@ public class ToolReference implements IToolReference {
public String getRawToolCommand() {
return command;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getConvertToId()
*/
public String getConvertToId() {
if (convertToId == null) {
// If I have a superClass, ask it
if (parent != null) {
return parent.getConvertToId();
} else {
return new String();
}
}
return convertToId;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#setConvertToId(String)
*/
public void setConvertToId(String convertToId) {
if (convertToId == null && this.convertToId == null) return;
if (convertToId == null || this.convertToId == null || !convertToId.equals(this.convertToId)) {
this.convertToId = convertToId;
setDirty(true);
}
return;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getVersionsSupported()
*/
public String getVersionsSupported() {
if (versionsSupported == null) {
// If I have a superClass, ask it
if (parent != null) {
return parent.getVersionsSupported();
} else {
return new String();
}
}
return versionsSupported;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#setVersionsSupported(String)
*/
public void setVersionsSupported(String versionsSupported) {
if (versionsSupported == null && this.versionsSupported == null) return;
if (versionsSupported == null || this.versionsSupported == null || !versionsSupported.equals(this.versionsSupported)) {
this.versionsSupported = versionsSupported;
setDirty(true);
}
return;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getEnvVarBuildPaths()

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.managedbuilder.makegen.gnu;
import java.util.Vector;
import java.util.HashMap;
/**
* This interface returns information about a Tool's inputs

View file

@ -149,6 +149,7 @@ BrowseEntryDialog.message.directory = Directory:
# ----------- New Configuration -----------
NewConfiguration.label.name=Name:
NewConfiguration.label.description=Description:
NewConfiguration.label.group=Copy settings from
NewConfiguration.label.copy=Default configuration:
NewConfiguration.label.clone=Existing configuration:
@ -157,12 +158,22 @@ NewConfiguration.error.duplicateName=A configuration named "{0}" already exists.
NewConfiguration.error.caseName=A configuration name that differs only in case to "{0}" exists.
NewConfiguration.error.invalidName=The name "{0}" is invalid.
# ----------- Rename Configuration -----------
RenameConfiguration.label.name=Name:
RenameConfiguration.label.description=Description:
RenameConfiguration.error.duplicateName=A configuration named "{0}" already exists.
RenameConfiguration.error.caseName=A configuration name that differs only in case to "{0}" exists.
RenameConfiguration.error.invalidName=The name "{0}" is invalid.
# ----------- Target/Config management dialog -----------------
ManageConfig.label.configs=Manage configurations
ManageConfig.label.restore=Restore
ManageConfig.label.configs.current=Current:
ManageConfig.label.configs.deleted=Deleted:
ManageConfig.label.rename=Rename
ManageConfig.label.conversionTargetLabel=Tool chain conversion targets:
ManageConfig.label.convertTarget=Convert
ManageConfig.label.new.config.dialog=Create configuration
ManageConfig.label.rename.config.dialog=Rename configuration
ManageConfig.deletedialog.message=Are you sure you want to delete the "{0}" configuration?
ManageConfig.deletedialog.title=Confirm Delete
# ----------- Build Property Common -----------
BuildPropertyCommon.label.title=Enter Value

View file

@ -301,11 +301,17 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
// Clear and replace the contents of the selector widget
configSelector.removeAll();
configSelector.setItems(getConfigurationNames());
configSelector.setItems(getConfigurationNamesAndDescriptions());
// Make sure the active configuration is selected
IConfiguration defaultConfig = info.getDefaultConfiguration();
int index = configSelector.indexOf(defaultConfig.getName());
int index;
if( (defaultConfig.getDescription() == null) || defaultConfig.getDescription().equals("") ) { //$NON-NLS-1$
index = configSelector.indexOf(defaultConfig.getName());
} else {
index = configSelector.indexOf(defaultConfig.getName() + "( " + defaultConfig.getDescription() + " )" ); //$NON-NLS-1$ //$NON-NLS-2$
}
configSelector.select(index == -1 ? 0 : index);
handleConfigSelection();
}
@ -313,13 +319,17 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
/* (non-Javadoc)
* @return an array of names for the configurations defined for the chosen
*/
private String [] getConfigurationNames () {
String [] names = new String[configurations.length /*+ 1*/];
private String [] getConfigurationNamesAndDescriptions () {
String [] namesAndDescriptions = new String[configurations.length /*+ 1*/];
for (int index = 0; index < configurations.length; ++index) {
names[index] = configurations[index].getName();
String description = configurations[index].getDescription();
if ( (description == null) || (description.equals("")) )
namesAndDescriptions[index] = configurations[index].getName(); //$NON-NLS-1$
else
namesAndDescriptions[index] = configurations[index].getName() + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
}
// names[names.length - 1] = ManagedBuilderUIPlugin.getResourceString(ALL_CONFS);
return names;
return namesAndDescriptions;
}
public void enableConfigSelection (boolean enable) {
@ -483,72 +493,36 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
}
// Event handler for the manage configuration button event
private void handleManageConfig () {
private void handleManageConfig() {
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
ManageConfigDialog manageDialog = new ManageConfigDialog(getShell(), ManagedBuilderUIMessages.getResourceString(MANAGE_TITLE), info.getManagedProject());
ManageConfigDialog manageDialog = new ManageConfigDialog(getShell(),
ManagedBuilderUIMessages.getResourceString(MANAGE_TITLE), info
.getManagedProject());
if (manageDialog.open() == ManageConfigDialog.OK) {
boolean updateConfigs = false;
// Check to see if any configurations have to be deleted
List deletedConfigs = manageDialog.getDeletedConfigIds();
Iterator iter = deletedConfigs.listIterator();
while (iter.hasNext()) {
String id = (String)iter.next();
// Remove the configurations from the project
info.getManagedProject().removeConfiguration(id);
String id = (String) iter.next();
// Remove any settings stores
fOptionBlock.removeValues(id);
// Clean up the UI
configurations = info.getManagedProject().getConfigurations();
configSelector.removeAll();
configSelector.setItems(getConfigurationNames());
configSelector.select(0);
updateConfigs = true;
}
// Check to see if any have to be added
SortedMap newConfigs = manageDialog.getNewConfigs();
Set keys = newConfigs.keySet();
Iterator keyIter = keys.iterator();
while (keyIter.hasNext()) {
String name = (String) keyIter.next();
IConfiguration parent = (IConfiguration) newConfigs.get(name);
if (parent != null) {
int id = ManagedBuildManager.getRandomNumber();
// Create ID for the new component based on the parent ID and random component
String newId = parent.getId();
int index = newId.lastIndexOf(ID_SEPARATOR);
if (index > 0) {
String lastComponent = newId.substring(index + 1, newId.length());
if (Character.isDigit(lastComponent.charAt(0))) {
// Strip the last component
newId = newId.substring(0, index);
}
}
newId += ID_SEPARATOR + id;
IConfiguration newConfig;
if (parent.isExtensionElement()) {
newConfig = info.getManagedProject().createConfiguration(parent, newId);
} else {
newConfig = info.getManagedProject().createConfigurationClone(parent, newId);
}
newConfig.setName(name);
newConfig.setArtifactName(info.getManagedProject().getDefaultArtifactName());
// Update the config lists
configurations = info.getManagedProject().getConfigurations();
configSelector.removeAll();
configSelector.setItems(getConfigurationNames());
configSelector.select(configSelector.indexOf(name));
updateConfigs = true;
}
}
if (updateConfigs){
handleConfigSelection();
// Update the config lists
configurations = info.getManagedProject().getConfigurations();
configSelector.removeAll();
configSelector.setItems(getConfigurationNamesAndDescriptions());
IConfiguration tmpSelectedConfiguration = manageDialog.getSelectedConfiguration();
String nameAndDescription = new String();
if ((tmpSelectedConfiguration.getDescription() == null)
|| (tmpSelectedConfiguration.getDescription().equals(""))) { //$NON-NLS-1$
nameAndDescription = tmpSelectedConfiguration.getName();
} else {
nameAndDescription = tmpSelectedConfiguration.getName() + "( " //$NON-NLS-1$
+ tmpSelectedConfiguration.getDescription() + " )"; //$NON-NLS-1$
}
configSelector.select(configSelector.indexOf(nameAndDescription));
handleConfigSelection();
}
return;
}

View file

@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (c) 2002,2004 IBM Corporation and others.
* Copyright (c) 2002,2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@ -14,27 +14,38 @@ import java.util.ArrayList;
import java.util.SortedMap;
import java.util.TreeMap;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
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.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import sun.security.x509.NameConstraintsExtension;
public class ManageConfigDialog extends Dialog {
// String constants
private static final String CMN_PREFIX = "BuildPropertyCommon"; //$NON-NLS-1$
@ -43,11 +54,20 @@ public class ManageConfigDialog extends Dialog {
private static final String REMOVE = CMN_LABEL + ".remove"; //$NON-NLS-1$
private static final String PREFIX = "ManageConfig"; //$NON-NLS-1$
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
private static final String RESTORE = LABEL + ".restore"; //$NON-NLS-1$
private static final String CONVERSION_TARGET_LABEL = LABEL + ".conversionTargetLabel"; //$NON-NLS-1$
private static final String CONVERT_TARGET = LABEL + ".convertTarget"; //$NON-NLS-1$
private static final String RENAME = LABEL + ".rename"; //$NON-NLS-1$
private static final String CONFIGS = LABEL + ".configs"; //$NON-NLS-1$
private static final String CURRENT_CONFIGS = CONFIGS + ".current"; //$NON-NLS-1$
private static final String DELETED_CONFIGS = CONFIGS + ".deleted"; //$NON-NLS-1$
private static final String CONF_DLG = LABEL + ".new.config.dialog"; //$NON-NLS-1$
private static final String NEW_CONF_DLG = LABEL + ".new.config.dialog"; //$NON-NLS-1$
private static final String RENAME_CONF_DLG = LABEL + ".rename.config.dialog"; //$NON-NLS-1$
private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
private static final String CONVERSION_TARGET_TIP = TIP + ".conversionTarget"; //$NON-NLS-1$
private static final String CONVERT_TIP = TIP + ".convert"; //$NON-NLS-1$
private static final String ID_SEPARATOR = "."; //$NON-NLS-1$
private static final String EMPTY_STRING = new String();
@ -57,20 +77,23 @@ public class ManageConfigDialog extends Dialog {
private SortedMap existingConfigs;
// The target the configs belong to
private IManagedProject managedProject;
/** All new configs added by the user but not yet part of target */
private SortedMap newAddedConfigs;
/** All new configs removed by the user but not yet part of target */
private SortedMap removedNewConfigs;
// selected Configuration
IConfiguration selectedConfiguration;
// The title of the dialog.
private String title = ""; //$NON-NLS-1$
private Combo conversionTargetSelector;
private Button convertTargetBtn;
// Widgets
protected List currentConfigList;
protected List deletedConfigList;
protected Button newBtn;
protected Button okBtn;
protected Button removeBtn;
protected Button restoreBtn;
protected Button renameBtn;
/**
* @param parentShell
@ -85,11 +108,23 @@ public class ManageConfigDialog extends Dialog {
IConfiguration [] configs = managedProject.getConfigurations();
for (int i = 0; i < configs.length; i++) {
IConfiguration configuration = configs[i];
getExistingConfigs().put(configuration.getName(), configuration.getId());
String name = configuration.getName();
String description = configuration.getDescription();
String nameAndDescription = new String();
if ( description == null || description.equals("") ) { //$NON-NLS-1$
nameAndDescription = name;
} else {
nameAndDescription = name + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
}
getExistingConfigs().put(nameAndDescription, configuration);
}
// Set the selectedConfiguration to default configuration.
selectedConfiguration = ManagedBuildManager.getSelectedConfiguration(getProject());
// clear DeletedConfig list
getDeletedConfigs().clear();
getNewConfigs().clear();
}
/* (non-Javadoc)
@ -107,7 +142,7 @@ public class ManageConfigDialog extends Dialog {
protected void createButtonsForButtonBar(Composite parent) {
// create OK and Cancel buttons by default
okBtn = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
// createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
updateButtons();
}
@ -120,39 +155,56 @@ public class ManageConfigDialog extends Dialog {
final Group configListGroup = new Group(parent, SWT.NONE);
configListGroup.setFont(parent.getFont());
configListGroup.setText(ManagedBuilderUIMessages.getResourceString(CONFIGS));
configListGroup.setLayout(new GridLayout(3, false));
configListGroup.setLayout(new GridLayout(1, false));
configListGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
// Create the 2 labels first to align the buttons and list controls
final Label currentConfigLabel = new Label(configListGroup, SWT.LEFT);
currentConfigLabel.setFont(configListGroup.getFont());
currentConfigLabel.setText(ManagedBuilderUIMessages.getResourceString(CURRENT_CONFIGS));
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
currentConfigLabel.setLayoutData(data);
final Label deletedConfigLabel = new Label(configListGroup, SWT.LEFT);
deletedConfigLabel.setFont(configListGroup.getFont());
deletedConfigLabel.setText(ManagedBuilderUIMessages.getResourceString(DELETED_CONFIGS));
deletedConfigLabel.setLayoutData(new GridData());
// Create the current config List
currentConfigList = new List(configListGroup, SWT.SINGLE|SWT.V_SCROLL|SWT.H_SCROLL|SWT.BORDER);
currentConfigList.setFont(configListGroup.getFont());
data = new GridData(GridData.FILL_BOTH);
data.widthHint = (IDialogConstants.ENTRY_FIELD_WIDTH / 2);
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = (IDialogConstants.ENTRY_FIELD_WIDTH);
currentConfigList.setLayoutData(data);
currentConfigList.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
currentConfigList = null;
}
});
currentConfigList.addListener(SWT.Selection, new Listener () {
public void handleEvent(Event e) {
handleConfigSelection();
}
});
// Create a composite for the buttons
// Create a composite for the conversion target combo
final Composite conversionGroup = new Composite(configListGroup, SWT.NULL);
conversionGroup.setFont(configListGroup.getFont());
conversionGroup.setLayout(new GridLayout(2, true));
conversionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Create the Tool chain conversion target list
Label conversionTargetLabel = ControlFactory.createLabel(conversionGroup, ManagedBuilderUIMessages.getResourceString(CONVERSION_TARGET_LABEL));
conversionTargetSelector = new Combo(conversionGroup, SWT.READ_ONLY|SWT.DROP_DOWN);
conversionTargetSelector.addListener(SWT.Selection, new Listener () {
public void handleEvent(Event e) {
handleConversionTargetSelection();
}
});
conversionTargetSelector.setToolTipText(ManagedBuilderUIMessages.getResourceString(CONVERSION_TARGET_TIP));
// Create a composite for the buttons
final Composite buttonBar = new Composite(configListGroup, SWT.NULL);
buttonBar.setFont(configListGroup.getFont());
buttonBar.setLayout(new GridLayout(1, true));
buttonBar.setLayoutData(new GridData(GridData.FILL_VERTICAL));
buttonBar.setLayout(new GridLayout(4, true));
buttonBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
convertTargetBtn = ControlFactory.createPushButton(buttonBar, ManagedBuilderUIMessages.getResourceString(CONVERT_TARGET));
convertTargetBtn.setToolTipText(ManagedBuilderUIMessages.getResourceString(CONVERT_TIP));
convertTargetBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleConversionTargetSelection();
}
});
newBtn = new Button(buttonBar, SWT.PUSH);
newBtn.setFont(buttonBar.getFont());
newBtn.setText(ManagedBuilderUIMessages.getResourceString(NEW));
@ -183,32 +235,25 @@ public class ManageConfigDialog extends Dialog {
}
});
restoreBtn = new Button(buttonBar, SWT.PUSH);
restoreBtn.setFont(buttonBar.getFont());
restoreBtn.setText(ManagedBuilderUIMessages.getResourceString(RESTORE));
setButtonLayoutData(restoreBtn);
restoreBtn.addSelectionListener(new SelectionAdapter () {
renameBtn = new Button(buttonBar, SWT.PUSH);
renameBtn.setFont(buttonBar.getFont());
renameBtn.setText(ManagedBuilderUIMessages.getResourceString(RENAME));
setButtonLayoutData(renameBtn);
renameBtn.addSelectionListener(new SelectionAdapter () {
public void widgetSelected(SelectionEvent e) {
handleRestorePressed();
handleRenamePressed();
}
});
restoreBtn.addDisposeListener(new DisposeListener() {
renameBtn.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
restoreBtn = null;
renameBtn = null;
}
});
//Create the deleted config list
deletedConfigList = new List(configListGroup, SWT.SINGLE|SWT.V_SCROLL|SWT.H_SCROLL|SWT.BORDER);
deletedConfigList.setFont(configListGroup.getFont());
data = new GridData(GridData.FILL_BOTH);
data.widthHint = (IDialogConstants.ENTRY_FIELD_WIDTH / 2);
deletedConfigList.setLayoutData(data);
deletedConfigList.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
deletedConfigList = null;
}
});
}
private void handleConversionTargetSelection() {
return;
}
/* (non-Javadoc)
@ -224,14 +269,46 @@ public class ManageConfigDialog extends Dialog {
createConfigListGroup(comp);
// Do the final widget prep
currentConfigList.setItems(getConfigurationNames());
currentConfigList.select(0);
// Set the configuration items
currentConfigList.setItems(getConfigurationNamesAndDescriptions());
// Set the selection to selectedConfiguration.
String name = getSelectedConfiguration().getName();
String description = getSelectedConfiguration().getDescription();
String nameAndDescription = new String();
if ( description == null || description.equals("") ) { //$NON-NLS-1$
nameAndDescription = name;
} else {
nameAndDescription = name + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
}
currentConfigList.select( currentConfigList.indexOf(nameAndDescription));
// Set the conversion target list.
updateConversionTargets(getSelectedConfiguration());
newBtn.setFocus();
return comp;
}
private String [] getConfigurationNames() {
return (String[]) getExistingConfigs().keySet().toArray(new String[getExistingConfigs().size()]);
private String [] getConversionTargetList(IConfiguration config) {
// This is temporary, once I implement backend & converter extension point,
// this will be replaced with original code.
String [] conversionTargetNames = { "GNU Toolchain version 4.0"}; //$NON-NLS-1$
return conversionTargetNames;
}
private void updateConversionTargets(IConfiguration config) {
conversionTargetSelector.setItems( getConversionTargetList(config));
conversionTargetSelector.select(0);
conversionTargetSelector.setEnabled(conversionTargetSelector.getItemCount() > 1);
convertTargetBtn.setEnabled( conversionTargetSelector.getItemCount() > 1);
}
private String [] getConfigurationNamesAndDescriptions() {
String [] namesAndDescriptions = (String[]) getExistingConfigs().keySet().toArray(new String[getExistingConfigs().size()]);
return namesAndDescriptions;
}
/* (non-javadoc)
@ -262,42 +339,7 @@ public class ManageConfigDialog extends Dialog {
return existingConfigs;
}
/**
* Answers a map of configuration names to <code>IConfiguration</code>.
* The name is selected by the user and should be unique for the target
* it will be added to. The configuration is the what the new
* configuration will be based on.
*
* @return Map
*/
public SortedMap getNewConfigs() {
if (newAddedConfigs == null) {
newAddedConfigs = new TreeMap();
}
return newAddedConfigs;
}
// Answers a list of new configuration names that have been added--
// or added and removed--by the user, but that have not yet been added
// to the target
private ArrayList getNewConfigNames() {
ArrayList names = new ArrayList();
names.addAll(getNewConfigs().keySet());
names.addAll(getRemovedNewConfigs().keySet());
return names;
}
// This data structure hangs on to a new configuration that is added
// by the user, then removed before it is added to the target. This is
// a required bookeeping step because the user may change their minds and
// restore the deleted configuration.
private SortedMap getRemovedNewConfigs() {
if (removedNewConfigs == null) {
removedNewConfigs = new TreeMap();
}
return removedNewConfigs;
}
/*
* @return the <code>IProject</code> associated with the managed project
*/
@ -309,86 +351,206 @@ public class ManageConfigDialog extends Dialog {
* Event handler for the add button
*/
protected void handleNewPressed() {
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
// Pop-up a dialog to properly handle the request
NewConfigurationDialog dialog = new NewConfigurationDialog(getShell(),
managedProject,
getNewConfigNames(),
ManagedBuilderUIMessages.getResourceString(CONF_DLG));
ManagedBuilderUIMessages.getResourceString(NEW_CONF_DLG));
if (dialog.open() == NewConfigurationDialog.OK) {
// Get the new name and configuration to base the new config on
// Get the new name & description and configuration to base the new config on
String newConfigName = dialog.getNewName();
getNewConfigs().put(newConfigName, dialog.getParentConfiguration());
currentConfigList.add(newConfigName);
currentConfigList.setSelection(currentConfigList.getItemCount() - 1);
String newConfigDescription = dialog.getNewDescription();
IConfiguration parentConfig = dialog.getParentConfiguration();
if (parentConfig != null) {
int id = ManagedBuildManager.getRandomNumber();
// Create ID for the new component based on the parent ID and random component
String newId = parentConfig.getId();
int index = newId.lastIndexOf(ID_SEPARATOR);
if (index > 0) {
String lastComponent = newId.substring(index + 1, newId.length());
if (Character.isDigit(lastComponent.charAt(0))) {
// Strip the last component
newId = newId.substring(0, index);
}
}
newId += ID_SEPARATOR + id;
IConfiguration newConfig;
if (parentConfig.isExtensionElement()) {
newConfig = info.getManagedProject().createConfiguration(parentConfig, newId);
} else {
newConfig = info.getManagedProject().createConfigurationClone(parentConfig, newId);
}
newConfig.setName(newConfigName);
newConfig.setDescription(newConfigDescription);
newConfig.setArtifactName(info.getManagedProject().getDefaultArtifactName());
// Add this new configuration to the existing list.
String nameAndDescription = new String();
if ( newConfigDescription == null || newConfigDescription.equals("") ) { //$NON-NLS-1$
nameAndDescription = newConfigName;
} else {
nameAndDescription = newConfigName + "( " + newConfigDescription + " )"; //$NON-NLS-1$ //$NON-NLS-2$
}
// Add the newConfig to the existing configurations
getExistingConfigs().put(nameAndDescription, newConfig);
// Set the selected Configuration to the newConfig
setSelectedConfiguration(newConfig);
// Update the Configuration combo list that is displayed to the user.
currentConfigList.setItems(getConfigurationNamesAndDescriptions());
// Get the index of selected configuration & set selection in config list.
int configIndex = currentConfigList.indexOf(nameAndDescription);
currentConfigList.setSelection(configIndex);
}
}
// Update the buttons based on the choices
updateButtons();
}
/* (non-javadoc)
* Event handler for the remove button
*/
protected void handleRemovePressed() {
protected void handleRenamePressed() {
IConfiguration selectedConfig = null;
String selectedConfigNameAndDescription = null;
// Determine which configuration was selected
int selectionIndex = currentConfigList.getSelectionIndex();
if (selectionIndex != -1){
String selectedConfigName = currentConfigList.getItem(selectionIndex);
// If this is a newly added config, remove it from the new map
// and add it to a special map to support the restore use case
if (getNewConfigs().containsKey(selectedConfigName)) {
IConfiguration selectedConfig = (IConfiguration) getNewConfigs().get(selectedConfigName);
getRemovedNewConfigs().put(selectedConfigName, selectedConfig);
getNewConfigs().remove(selectedConfigName);
} else {
// If it is not a new item, the ID is in the existing list
String selectedConfigId = (String) getExistingConfigs().get(selectedConfigName);
getDeletedConfigs().put(selectedConfigName, selectedConfigId);
}
if (selectionIndex != -1) {
selectedConfigNameAndDescription = currentConfigList
.getItem(selectionIndex);
selectedConfig = (IConfiguration) getExistingConfigs().get(
selectedConfigNameAndDescription);
// Clean up the UI lists
currentConfigList.remove(selectionIndex);
currentConfigList.setSelection(selectionIndex - 1);
deletedConfigList.add(selectedConfigName);
deletedConfigList.setSelection(deletedConfigList.getItemCount() - 1);
updateButtons();
// Pop-up a dialog to properly handle the request
RenameConfigurationDialog dialog = new RenameConfigurationDialog(
getShell(), managedProject, selectedConfig,
ManagedBuilderUIMessages.getResourceString(RENAME_CONF_DLG));
if (dialog.open() == RenameConfigurationDialog.OK) {
// Get the new name & description for the selected configuration
String newConfigName = dialog.getNewName();
String newConfigDescription = dialog.getNewDescription();
selectedConfig.setName(newConfigName);
selectedConfig.setDescription(newConfigDescription);
// Remove the old configuration from the list and add renamed
// configuration to the list.
getExistingConfigs().remove(selectedConfigNameAndDescription);
String nameAndDescription = new String();
if (newConfigDescription == null
|| newConfigDescription.equals("")) { //$NON-NLS-1$
nameAndDescription = newConfigName;
} else {
nameAndDescription = newConfigName + "( " //$NON-NLS-1$
+ newConfigDescription + " )"; //$NON-NLS-1$
}
getExistingConfigs().put(nameAndDescription, selectedConfig);
// Set the selected Configuration to the newConfig
setSelectedConfiguration(selectedConfig);
// Update the Configuration combo list that is displayed to the user.
currentConfigList.setItems(getConfigurationNamesAndDescriptions());
// Get the index of selected configuration & set selection in config list.
int configIndex = currentConfigList.indexOf(nameAndDescription);
currentConfigList.setSelection(configIndex);
// Update the buttons based on the choices
updateButtons();
}
}
}
/* (non-javadoc)
* Event handler for the restore button
/*
* (non-javadoc) Event handler for the remove button
*/
protected void handleRestorePressed() {
protected void handleRemovePressed() {
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
// Determine which configuration was selected
int selectionIndex = deletedConfigList.getSelectionIndex();
// Move the selected element from the correct deleted list to the current list
int selectionIndex = currentConfigList.getSelectionIndex();
if (selectionIndex != -1){
// Get the name of the item to delete
String selectedConfigName = deletedConfigList.getItem(selectionIndex);
String selectedConfigNameAndDescription = currentConfigList.getItem(selectionIndex);
// The deleted config may be one of the existing configs or one of the
// new configs that have not been added to the target yet
if (getRemovedNewConfigs().containsKey(selectedConfigName)) {
IConfiguration restoredConfig = managedProject.getConfiguration(selectedConfigName);
getNewConfigs().put(selectedConfigName, restoredConfig);
getRemovedNewConfigs().remove(selectedConfigName);
} else {
getDeletedConfigs().remove(selectedConfigName);
// Get the confirmation from user before deleting the configuration
Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
boolean shouldDelete = MessageDialog.openQuestion(shell,
ManagedBuilderUIMessages.getResourceString("ManageConfig.deletedialog.title"), //$NON-NLS-1$
ManagedBuilderUIMessages.getFormattedString("ManageConfig.deletedialog.message", //$NON-NLS-1$
new String[] {selectedConfigNameAndDescription}));
if (shouldDelete) {
IConfiguration selectedConfig = (IConfiguration) getExistingConfigs()
.get(selectedConfigNameAndDescription);
String selectedConfigId = (String) selectedConfig.getId();
getDeletedConfigs().put(selectedConfigNameAndDescription,
selectedConfigId);
// Remove the configurations from the project & from list
// configuration list
info.getManagedProject().removeConfiguration(selectedConfigId);
getExistingConfigs().remove(selectedConfigNameAndDescription);
// Update the Configuration combo list that is displayed to the
// user.
currentConfigList
.setItems(getConfigurationNamesAndDescriptions());
currentConfigList
.setSelection(currentConfigList.getItemCount() - 1);
// Update selected configuration variable
selectionIndex = currentConfigList.getSelectionIndex();
if (selectionIndex != -1) {
selectedConfigNameAndDescription = currentConfigList
.getItem(selectionIndex);
selectedConfig = (IConfiguration) getExistingConfigs().get(
selectedConfigNameAndDescription);
setSelectedConfiguration(selectedConfig);
}
// Clean up the UI lists
updateButtons();
}
// Clean up the UI
deletedConfigList.remove(selectionIndex);
deletedConfigList.setSelection(selectionIndex - 1);
currentConfigList.add(selectedConfigName);
currentConfigList.setSelection(currentConfigList.getItemCount());
updateButtons();
}
}
private void updateButtons() {
// Disable the remove button if there is only 1 configuration
removeBtn.setEnabled(currentConfigList.getItemCount() > 1);
// Enable the restore button if there is anything in the deleted list
restoreBtn.setEnabled(deletedConfigList.getItemCount() > 0);
convertTargetBtn.setEnabled( conversionTargetSelector.getItemCount() > 1);
}
private void handleConfigSelection() {
// Determine which configuration was selected
int selectionIndex = currentConfigList.getSelectionIndex();
String selectedConfigNameAndDescription = currentConfigList
.getItem(selectionIndex);
IConfiguration selectedConfig = (IConfiguration) getExistingConfigs()
.get(selectedConfigNameAndDescription);
setSelectedConfiguration(selectedConfig);
updateConversionTargets(selectedConfig);
return;
}
public IConfiguration getSelectedConfiguration() {
return selectedConfiguration;
}
public void setSelectedConfiguration(IConfiguration selectedConfiguration) {
this.selectedConfiguration = selectedConfiguration;
}
}

View file

@ -25,6 +25,8 @@ import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@ -49,11 +51,13 @@ public class NewConfigurationDialog extends StatusDialog {
private static final String DUPLICATE = ERROR + ".duplicateName"; //$NON-NLS-1$
private static final String CASE = ERROR + ".caseName"; //$NON-NLS-1$
private static final String INVALID = ERROR + ".invalidName"; //$NON-NLS-1$
private static final String DESCRIPTION = LABEL + ".description"; //$NON-NLS-1$
// Widgets
private Button btnClone;
private Button btnCopy;
private Text configName;
private Text configDescription;
private Combo copyConfigSelector;
private Combo cloneConfigSelector;
private Button btnShowAll;
@ -67,6 +71,7 @@ public class NewConfigurationDialog extends StatusDialog {
private IConfiguration parentConfig;
private IManagedProject managedProject;
private String newName;
private String newDescription;
/** A list containing config names that have been defined but not added to the target */
final private ArrayList reservedNames;
final private String title;
@ -78,15 +83,15 @@ public class NewConfigurationDialog extends StatusDialog {
* @param nameList A list of names (Strings) that have been added by the user but have not yet been added to the target
* @param title The title of the dialog
*/
protected NewConfigurationDialog(Shell parentShell, IManagedProject managedProject, ArrayList nameList, String title) {
protected NewConfigurationDialog(Shell parentShell, IManagedProject managedProject, String title) {
super(parentShell);
this.title = title;
setShellStyle(getShellStyle()|SWT.RESIZE);
newName = new String();
newDescription = new String();
parentConfig = null;
this.managedProject = managedProject;
reservedNames = nameList;
reservedNames = new ArrayList();
// The default behaviour is to clone the settings
clone = true;
@ -94,6 +99,12 @@ public class NewConfigurationDialog extends StatusDialog {
definedConfigs = managedProject.getConfigurations();
IProjectType projectType = managedProject.getProjectType();
defaultConfigs = projectType.getConfigurations();
// Get the defined configuration names
for (int i = 0; i < definedConfigs.length; i++) {
reservedNames.add(definedConfigs[i].getName());
}
}
/* (non-Javadoc)
@ -103,23 +114,42 @@ public class NewConfigurationDialog extends StatusDialog {
*/
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
String description = new String();
String nameAndDescription = new String();
String baseConfigNameAndDescription = new String();
newName = configName.getText().trim();
String baseConfigName = new String();
newDescription = configDescription.getText().trim();
if (clone) {
baseConfigName = cloneConfigSelector.getItem(cloneConfigSelector.getSelectionIndex());
baseConfigNameAndDescription = cloneConfigSelector.getItem(cloneConfigSelector.getSelectionIndex());
for (int i = 0; i < definedConfigs.length; i++) {
IConfiguration config = definedConfigs[i];
if (config.getName().equals(baseConfigName)) {
description = config.getDescription();
if( (description == null) || (description.equals("")) ){ //$NON-NLS-1$
nameAndDescription = config.getName();
} else {
nameAndDescription = config.getName() + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
}
if (nameAndDescription.equals(baseConfigNameAndDescription)) {
parentConfig = config;
break;
}
}
} else {
// Get the parent config out of the default config list
baseConfigName = copyConfigSelector.getItem(copyConfigSelector.getSelectionIndex());
baseConfigNameAndDescription = copyConfigSelector.getItem(copyConfigSelector.getSelectionIndex());
for (int i = 0; i < defaultConfigs.length; i++) {
IConfiguration config = defaultConfigs[i];
if (config.getName().equals(baseConfigName)) {
description = config.getDescription();
if( (description == null) || (description.equals("")) ) { //$NON-NLS-1$
nameAndDescription = config.getName();
} else {
nameAndDescription = config.getName() + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
}
if (nameAndDescription.equals(baseConfigNameAndDescription)) {
parentConfig = config;
break;
}
@ -127,6 +157,7 @@ public class NewConfigurationDialog extends StatusDialog {
}
} else {
newName = null;
newDescription = null;
parentConfig = null;
}
super.buttonPressed(buttonId);
@ -154,20 +185,36 @@ public class NewConfigurationDialog extends StatusDialog {
}
protected Control createDialogArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
composite.setFont(parent.getFont());
composite.setLayout(new GridLayout(3, false));
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Add a label and a text widget
final Label nameLabel = new Label(composite, SWT.LEFT);
// Create a group for the name & description
final Group group1 = new Group(composite, SWT.NONE);
group1.setFont(composite.getFont());
GridLayout layout1 = new GridLayout(3, false);
group1.setLayout(layout1);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 3;
group1.setLayoutData(gd);
// Add a label and a text widget for Configuration's name
final Label nameLabel = new Label(group1, SWT.LEFT);
nameLabel.setFont(parent.getFont());
nameLabel.setText(ManagedBuilderUIMessages.getResourceString(NAME));
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
gd.grabExcessHorizontalSpace = false;
nameLabel.setLayoutData(gd);
configName = new Text(composite, SWT.SINGLE | SWT.BORDER);
configName.setFont(composite.getFont());
configName = new Text(group1, SWT.SINGLE | SWT.BORDER);
configName.setFont(group1.getFont());
configName.setText(getNewName());
configName.setFocus();
gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
@ -178,7 +225,27 @@ public class NewConfigurationDialog extends StatusDialog {
}
});
// Create a group fro the radio buttons
// Add a label and a text widget for Configuration's description
final Label descriptionLabel = new Label(group1, SWT.LEFT);
descriptionLabel.setFont(parent.getFont());
descriptionLabel.setText(ManagedBuilderUIMessages.getResourceString(DESCRIPTION));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
gd.grabExcessHorizontalSpace = false;
descriptionLabel.setLayoutData(gd);
configDescription = new Text(group1, SWT.SINGLE | SWT.BORDER);
configDescription.setFont(group1.getFont());
configDescription.setText(getNewDescription());
configDescription.setFocus();
gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
configDescription.setLayoutData(gd);
// Create a group for the radio buttons
final Group group = new Group(composite, SWT.NONE);
group.setFont(composite.getFont());
group.setText(ManagedBuilderUIMessages.getResourceString(GROUP));
@ -226,7 +293,7 @@ public class NewConfigurationDialog extends StatusDialog {
cloneConfigSelector = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
cloneConfigSelector.setFont(group.getFont());
cloneConfigSelector.setItems(getDefinedConfigNames());
cloneConfigSelector.setItems(getDefinedConfigNamesAndDescriptions());
index = cloneConfigSelector.indexOf(newName);
cloneConfigSelector.select(index < 0 ? 0 : index);
gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
@ -286,16 +353,20 @@ public class NewConfigurationDialog extends StatusDialog {
}
if(defaultConfigs.length != 0){
String names[] = new String[defaultConfigs.length];
for (int i = 0; i < defaultConfigs.length; ++i)
names[i] = defaultConfigs[i].getName();
String namesAndDescriptions[] = new String[defaultConfigs.length];
for (int i = 0; i < defaultConfigs.length; ++i) {
if ( (defaultConfigs[i].getDescription() == null) || defaultConfigs[i].getDescription().equals("")) //$NON-NLS-1$
namesAndDescriptions[i] = defaultConfigs[i].getName();
else
namesAndDescriptions[i] = defaultConfigs[i].getName() + "( " + defaultConfigs[i].getDescription() + " )"; //$NON-NLS-1$ //$NON-NLS-2$
}
int selectionIndex = copyConfigSelector.getSelectionIndex();
String oldSelection = null;
if(selectionIndex != -1)
oldSelection = copyConfigSelector.getItem(selectionIndex);
copyConfigSelector.setItems(names);
copyConfigSelector.setItems(namesAndDescriptions);
if(oldSelection != null)
selectionIndex = copyConfigSelector.indexOf(oldSelection);
if(selectionIndex == -1)
@ -313,13 +384,16 @@ public class NewConfigurationDialog extends StatusDialog {
* This list will be used to populate the list of configurations to
* clone.
*/
private String [] getDefinedConfigNames() {
String [] names = new String[definedConfigs.length];
private String [] getDefinedConfigNamesAndDescriptions() {
String [] namesAndDescriptions = new String[definedConfigs.length];
for (int index = 0; index < definedConfigs.length; ++index) {
IConfiguration config = definedConfigs[index];
names[index] = config.getName();
if ( (config.getDescription() == null) || config.getDescription().equals("")) //$NON-NLS-1$
namesAndDescriptions[index] = config.getName();
else
namesAndDescriptions[index] = config.getName() + "( " + config.getDescription() +" )"; //$NON-NLS-1$ //$NON-NLS-2$
}
return names;
return namesAndDescriptions;
}
/**
@ -440,10 +514,15 @@ public class NewConfigurationDialog extends StatusDialog {
status.setError(ManagedBuilderUIMessages.getFormattedString(CASE, currentName));
} else if (!validateName(currentName)) {
// TODO Create a decent I18N string to describe this problem
status.setError(ManagedBuilderUIMessages.getFormattedString(INVALID, currentName)); //$NON-NLS-1$
status.setError(ManagedBuilderUIMessages.getFormattedString(INVALID, currentName));
}
updateStatus(status);
return;
}
public String getNewDescription() {
return newDescription;
}
}

View file

@ -0,0 +1,332 @@
/**********************************************************************
* Copyright (c) 2005 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.managedbuilder.ui.properties;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class RenameConfigurationDialog extends StatusDialog {
// String constants
private static final String PREFIX = "RenameConfiguration"; //$NON-NLS-1$
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
private static final String ERROR = PREFIX + ".error"; //$NON-NLS-1$
private static final String NAME = LABEL + ".name"; //$NON-NLS-1$
private static final String DUPLICATE = ERROR + ".duplicateName"; //$NON-NLS-1$
private static final String CASE = ERROR + ".caseName"; //$NON-NLS-1$
private static final String INVALID = ERROR + ".invalidName"; //$NON-NLS-1$
private static final String DESCRIPTION = LABEL + ".description"; //$NON-NLS-1$
// Widgets
private Text configName;
private Text configDescription;
private IConfiguration[] definedConfigs;
private IConfiguration renameConfig;
private IManagedProject managedProject;
private String newName;
private String newDescription;
private String originalName;
/** A list containing config names that have been defined but not added to the target */
final private ArrayList reservedNames;
final private String title;
/**
* @param parentShell
* @param managedTarget
* @param renameConfig
* @param title
*/
protected RenameConfigurationDialog(Shell parentShell, IManagedProject managedProject, IConfiguration renameConfig, String title) {
super(parentShell);
this.title = title;
this.renameConfig = renameConfig;
setShellStyle(getShellStyle()|SWT.RESIZE);
newName = renameConfig.getName();
newDescription = renameConfig.getDescription();
if(newDescription == null)
newDescription = new String();
// Store the original name
setOriginalName(renameConfig.getName());
this.managedProject = managedProject;
reservedNames = new ArrayList();
definedConfigs = managedProject.getConfigurations();
// Get the defined configuration names
for (int i = 0; i < definedConfigs.length; i++) {
reservedNames.add(definedConfigs[i].getName());
}
}
/* (non-Javadoc)
* Method declared on Dialog. Cache the name and base config selections.
* We don't have to worry that the index or name is wrong because we
* enable the OK button IFF those conditions are met.
*/
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
newName = configName.getText().trim();
newDescription = configDescription.getText().trim();
}
super.buttonPressed(buttonId);
}
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
*/
protected void configureShell(Shell shell) {
super.configureShell(shell);
if (title != null)
shell.setText(title);
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
*/
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
configName.setFocus();
if (configName != null) {
configName.setText(newName);
}
validateState();
}
protected Control createDialogArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
composite.setFont(parent.getFont());
composite.setLayout(new GridLayout(3, false));
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Create a group for the name & description
final Group group1 = new Group(composite, SWT.NONE);
group1.setFont(composite.getFont());
GridLayout layout1 = new GridLayout(3, false);
group1.setLayout(layout1);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 3;
group1.setLayoutData(gd);
// Add a label and a text widget for Configuration's name
final Label nameLabel = new Label(group1, SWT.LEFT);
nameLabel.setFont(parent.getFont());
nameLabel.setText(ManagedBuilderUIMessages.getResourceString(NAME));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
gd.grabExcessHorizontalSpace = false;
nameLabel.setLayoutData(gd);
configName = new Text(group1, SWT.SINGLE | SWT.BORDER);
configName.setFont(group1.getFont());
configName.setText(getNewName());
configName.setFocus();
gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
configName.setLayoutData(gd);
configName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateState();
}
});
// Add a label and a text widget for Configuration's description
final Label descriptionLabel = new Label(group1, SWT.LEFT);
descriptionLabel.setFont(parent.getFont());
descriptionLabel.setText(ManagedBuilderUIMessages.getResourceString(DESCRIPTION));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
gd.grabExcessHorizontalSpace = false;
descriptionLabel.setLayoutData(gd);
configDescription = new Text(group1, SWT.SINGLE | SWT.BORDER);
configDescription.setFont(group1.getFont());
configDescription.setText(getNewDescription());
configDescription.setFocus();
gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
configDescription.setLayoutData(gd);
return composite;
}
/* (non-Javadoc)
* Answers <code>true</code> if the name entered by the user clashes
* with an existing configuration name.
*
* @param newName
* @return
*/
protected boolean isDuplicateName(String newName) {
// First check whether the 'newName' is same as original name, if so return false.
// This is needed in case user wants to keep same name but change the description of configuration
if(newName.equals(getOriginalName()))
return false;
// Return true if there is already a config of that name defined
for (int index = 0; index < definedConfigs.length; index++) {
IConfiguration configuration = definedConfigs[index];
if (configuration.getName().equals(newName)) {
return true;
}
}
if (reservedNames.contains(newName)) {
return true;
}
return false;
}
/* (non-Javadoc)
* Answers <code>true</code> if the name entered by the user differs
* only in case from an existing name.
*
* @param newName
* @return
*/
protected boolean isSimilarName(String newName) {
// First check whether the 'newName' is similar to original name, if so return false.
// This is needed in case user wants to keep similar name
if(newName.equalsIgnoreCase(getOriginalName()))
return false;
// Return true if there is already a config of that name defined on the target
for (int index = 0; index < definedConfigs.length; index++) {
IConfiguration configuration = definedConfigs[index];
if (configuration.getName().equalsIgnoreCase(newName)) {
return true;
}
}
Iterator iter = reservedNames.listIterator();
while (iter.hasNext()) {
if (((String)iter.next()).equalsIgnoreCase(newName)) {
return true;
}
}
return false;
}
/* (non-Javadoc)
* Checks the argument for leading whitespaces and invalid directory name characters.
* @param name
* @return <I>true</i> is the name is a valid directory name with no whitespaces
*/
private boolean validateName(String name) {
// Iterate over the name checking for bad characters
char[] chars = name.toCharArray();
// No whitespaces at the start of a name
if (Character.isWhitespace(chars[0])) {
return false;
}
for (int index = 0; index < chars.length; ++index) {
// Config name must be a valid dir name too, so we ban "\ / : * ? " < >" in the names
if (!Character.isLetterOrDigit(chars[index])) {
switch (chars[index]) {
case '/':
case '\\':
case ':':
case '*':
case '?':
case '\"':
case '<':
case '>':
return false;
default:
break;
}
}
}
return true;
}
/* (non-Javadoc)
* Update the status message and button state based on the input selected
* by the user
*
*/
private void validateState() {
StatusInfo status= new StatusInfo();
String currentName = configName.getText();
int nameLength = currentName.length();
// Make sure the name is not a duplicate
if (isDuplicateName(currentName)) {
status.setError(ManagedBuilderUIMessages.getFormattedString(DUPLICATE, currentName));
} else if (isSimilarName(currentName)) {
status.setError(ManagedBuilderUIMessages.getFormattedString(CASE, currentName));
} else if (!validateName(currentName)) {
// TODO Create a decent I18N string to describe this problem
status.setError(ManagedBuilderUIMessages.getFormattedString(INVALID, currentName));
}
updateStatus(status);
return;
}
public String getNewName() {
return newName;
}
public String getNewDescription() {
return newDescription;
}
public void setNewDescription(String newDescription) {
this.newDescription = newDescription;
}
public void setNewName(String newName) {
this.newName = newName;
}
public String getOriginalName() {
return originalName;
}
public void setOriginalName(String originalName) {
this.originalName = originalName;
}
}

View file

@ -1,7 +1,7 @@
package org.eclipse.cdt.managedbuilder.ui.wizards;
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* Copyright (c) 2002,2005 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@ -24,7 +24,12 @@ public class ConfigurationLabelProvider extends LabelProvider implements ITableL
//
public String getColumnText(Object obj, int index) {
if (obj instanceof IConfiguration) {
return ((IConfiguration) obj).getName();
IConfiguration tmpConfig = (IConfiguration) obj;
if( (tmpConfig.getDescription() == null)|| (tmpConfig.getDescription().equals("")) ) //$NON-NLS-1$
return ((IConfiguration) obj).getName();
else
return ( tmpConfig.getName() + " ( " + tmpConfig.getDescription() + " )"); //$NON-NLS-1$ //$NON-NLS-2$
}
return new String();
}