1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Initial check-in for the Option Value Handler functionality fixes

This commit is contained in:
Mikhail Sennikovsky 2005-11-30 16:28:43 +00:00
parent 02eb2cab43
commit d4bc99f45d
11 changed files with 255 additions and 98 deletions

View file

@ -773,8 +773,9 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
try { try {
//an option can be null in the case of calling this method from the environment //an option can be null in the case of calling this method from the environment
//build path change listener //build path change listener
if (option != null && !(option.getValueType() == IOption.INCLUDE_PATH if (config.isTemporary() ||
|| option.getValueType() == IOption.PREPROCESSOR_SYMBOLS)) { (option != null && option.getValueType() != IOption.INCLUDE_PATH
&& option.getValueType() != IOption.PREPROCESSOR_SYMBOLS)) {
return; return;
} }
} catch (BuildException e) {return;} } catch (BuildException e) {return;}
@ -793,11 +794,12 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
public static void initializePathEntries(IConfiguration config, IOption option){ public static void initializePathEntries(IConfiguration config, IOption option){
try{ try{
if(option != null if(config.isTemporary() ||
(option != null
&& option.getValueType() != IOption.INCLUDE_PATH && option.getValueType() != IOption.INCLUDE_PATH
&& option.getValueType() != IOption.PREPROCESSOR_SYMBOLS && option.getValueType() != IOption.PREPROCESSOR_SYMBOLS
&& option.getValueType() != IOption.LIBRARIES && option.getValueType() != IOption.LIBRARIES
) ))
return; return;
} catch (BuildException e){ } catch (BuildException e){
return; return;
@ -820,8 +822,9 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
private static void notifyListeners(IResourceConfiguration resConfig, IOption option) { private static void notifyListeners(IResourceConfiguration resConfig, IOption option) {
// Continue if change is something that effect the scanreser // Continue if change is something that effect the scanreser
try { try {
if (!(option.getValueType() == IOption.INCLUDE_PATH if (resConfig.getParent().isTemporary() ||
|| option.getValueType() == IOption.PREPROCESSOR_SYMBOLS)) { (option != null && option.getValueType() != IOption.INCLUDE_PATH
&& option.getValueType() != IOption.PREPROCESSOR_SYMBOLS)) {
return; return;
} }
} catch (BuildException e) {return;} } catch (BuildException e) {return;}
@ -846,7 +849,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
*/ */
public static void setNewProjectVersion(IProject newProject) { public static void setNewProjectVersion(IProject newProject) {
// Get the build info for the argument // Get the build info for the argument
ManagedBuildInfo info = findBuildInfo(newProject); ManagedBuildInfo info = findBuildInfo(newProject, true);
info.setVersion(buildInfoVersion.toString()); info.setVersion(buildInfoVersion.toString());
} }
@ -869,8 +872,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
try { try {
// Request a value change and set dirty if real change results // Request a value change and set dirty if real change results
retOpt = config.setOption(holder, option, value); retOpt = config.setOption(holder, option, value);
initializePathEntries(config,option); if (retOpt.getValueHandler().handleValue(
notifyListeners(config, option); config,
holder,
retOpt,
retOpt.getValueHandlerExtraArgument(),
IManagedOptionValueHandler.EVENT_APPLY)) {
// TODO : Event is handled successfully and returned true.
// May need to do something here say log a message.
} else {
// Event handling Failed.
}
initializePathEntries(config,retOpt);
notifyListeners(config, retOpt);
} catch (BuildException e) { } catch (BuildException e) {
return null; return null;
} }
@ -896,8 +910,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
try { try {
// Request a value change and set dirty if real change results // Request a value change and set dirty if real change results
retOpt = resConfig.setOption(holder, option, value); retOpt = resConfig.setOption(holder, option, value);
initializePathEntries(resConfig,option); if (retOpt.getValueHandler().handleValue(
notifyListeners(resConfig, option); resConfig,
holder,
retOpt,
retOpt.getValueHandlerExtraArgument(),
IManagedOptionValueHandler.EVENT_APPLY)) {
// TODO : Event is handled successfully and returned true.
// May need to do something here say log a message.
} else {
// Event handling Failed.
}
initializePathEntries(resConfig,retOpt);
notifyListeners(resConfig, retOpt);
} catch (BuildException e) { } catch (BuildException e) {
return null; return null;
} }
@ -921,8 +946,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
IOption retOpt; IOption retOpt;
try { try {
retOpt = config.setOption(holder, option, value); retOpt = config.setOption(holder, option, value);
initializePathEntries(config,option); if (retOpt.getValueHandler().handleValue(
notifyListeners(config, option); config,
holder,
retOpt,
retOpt.getValueHandlerExtraArgument(),
IManagedOptionValueHandler.EVENT_APPLY)) {
// TODO : Event is handled successfully and returned true.
// May need to do something here say log a message.
} else {
// Event handling Failed.
}
initializePathEntries(config,retOpt);
notifyListeners(config, retOpt);
} catch (BuildException e) { } catch (BuildException e) {
return null; return null;
} }
@ -947,8 +983,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
IOption retOpt; IOption retOpt;
try { try {
retOpt = resConfig.setOption(holder, option, value); retOpt = resConfig.setOption(holder, option, value);
initializePathEntries(resConfig,option); if (retOpt.getValueHandler().handleValue(
notifyListeners(resConfig, option); resConfig,
holder,
retOpt,
retOpt.getValueHandlerExtraArgument(),
IManagedOptionValueHandler.EVENT_APPLY)) {
// TODO : Event is handled successfully and returned true.
// May need to do something here say log a message.
} else {
// Event handling Failed.
}
initializePathEntries(resConfig,retOpt);
notifyListeners(resConfig, retOpt);
} catch (BuildException e) { } catch (BuildException e) {
return null; return null;
} }
@ -972,8 +1019,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
IOption retOpt; IOption retOpt;
try { try {
retOpt = config.setOption(holder, option, value); retOpt = config.setOption(holder, option, value);
initializePathEntries(config,option); if (retOpt.getValueHandler().handleValue(
notifyListeners(config, option); config,
holder,
retOpt,
retOpt.getValueHandlerExtraArgument(),
IManagedOptionValueHandler.EVENT_APPLY)) {
// TODO : Event is handled successfully and returned true.
// May need to do something here say log a message.
} else {
// Event handling Failed.
}
initializePathEntries(config,retOpt);
notifyListeners(config, retOpt);
} catch (BuildException e) { } catch (BuildException e) {
return null; return null;
} }
@ -998,8 +1056,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
IOption retOpt; IOption retOpt;
try { try {
retOpt = resConfig.setOption(holder, option, value); retOpt = resConfig.setOption(holder, option, value);
initializePathEntries(resConfig,option); if (retOpt.getValueHandler().handleValue(
notifyListeners(resConfig, option); resConfig,
holder,
retOpt,
retOpt.getValueHandlerExtraArgument(),
IManagedOptionValueHandler.EVENT_APPLY)) {
// TODO : Event is handled successfully and returned true.
// May need to do something here say log a message.
} else {
// Event handling Failed.
}
initializePathEntries(resConfig,retOpt);
notifyListeners(resConfig, retOpt);
} catch (BuildException e) { } catch (BuildException e) {
return null; return null;
} }
@ -1167,9 +1236,20 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @param resource * @param resource
*/ */
public static void removeBuildInfo(IResource resource) { public static void removeBuildInfo(IResource resource) {
try { IManagedBuildInfo info = findBuildInfo(resource, false);
resource.setSessionProperty(buildInfoProperty, null); if(info != null){
} catch (CoreException e) { IConfiguration[] configs = info.getManagedProject().getConfigurations();
// Send an event to each configuration and if they exist, its resource configurations
for (int i=0; i < configs.length; ++i) {
ManagedBuildManager.performValueHandlerEvent(configs[i], IManagedOptionValueHandler.EVENT_CLOSE);
}
info.setValid(false);
try {
resource.setSessionProperty(buildInfoProperty, null);
} catch (CoreException e) {
}
} }
} }
@ -1183,11 +1263,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
public static void resetConfiguration(IProject project, IConfiguration configuration) { public static void resetConfiguration(IProject project, IConfiguration configuration) {
// reset the configuration // reset the configuration
((Configuration)configuration).reset(); ((Configuration)configuration).reset();
performValueHandlerEvent(configuration,
IManagedOptionValueHandler.EVENT_SETDEFAULT, false);
} }
public static void resetResourceConfiguration(IProject project, IResourceConfiguration resConfig) { public static void resetResourceConfiguration(IProject project, IResourceConfiguration resConfig) {
// reset the configuration // reset the configuration
((ResourceConfiguration) resConfig).reset(); ((ResourceConfiguration) resConfig).reset();
performValueHandlerEvent(resConfig,
IManagedOptionValueHandler.EVENT_SETDEFAULT);
} }
/** /**
* Adds a ProjectType that is is specified in the manifest to the * Adds a ProjectType that is is specified in the manifest to the
@ -1450,7 +1538,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// Get the build info associated with this project for this session // Get the build info associated with this project for this session
try { try {
buildInfo = findBuildInfo(resource.getProject()); buildInfo = findBuildInfo(resource.getProject(), true);
initBuildInfoContainer(buildInfo); initBuildInfoContainer(buildInfo);
} catch (CoreException e) { } catch (CoreException e) {
return new Status(IStatus.ERROR, return new Status(IStatus.ERROR,
@ -1641,13 +1729,13 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} }
} }
// Finish up
project.setSessionProperty(buildInfoProperty, buildInfo);
IConfiguration[] configs = buildInfo.getManagedProject().getConfigurations(); IConfiguration[] configs = buildInfo.getManagedProject().getConfigurations();
// Send an event to each configuration and if they exist, its resource configurations // Send an event to each configuration and if they exist, its resource configurations
for (int i=0; i < configs.length; ++i) { for (int i=0; i < configs.length; ++i) {
ManagedBuildManager.performValueHandlerEvent(configs[i], IManagedOptionValueHandler.EVENT_OPEN); ManagedBuildManager.performValueHandlerEvent(configs[i], IManagedOptionValueHandler.EVENT_OPEN);
} }
// Finish up
project.setSessionProperty(buildInfoProperty, buildInfo);
} }
} catch (Exception e) { } catch (Exception e) {
throw e; throw e;
@ -2083,18 +2171,10 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @param resource * @param resource
* @return * @return
*/ */
private static ManagedBuildInfo findBuildInfo(IResource resource/*, boolean create*/) { private static ManagedBuildInfo findBuildInfo(IResource resource, boolean forceLoad) {
if (resource == null) return null; if (resource == null) return null;
// Make sure the extension information is loaded first
try {
loadExtensions();
} catch (BuildException e) {
e.printStackTrace();
return null;
}
ManagedBuildInfo buildInfo = null; ManagedBuildInfo buildInfo = null;
// Check if there is any build info associated with this project for this session // Check if there is any build info associated with this project for this session
@ -2109,7 +2189,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} }
if (buildInfo == null && resource instanceof IProject) if (buildInfo == null && resource instanceof IProject)
buildInfo = findBuildInfoSynchronized((IProject)resource); buildInfo = findBuildInfoSynchronized((IProject)resource, forceLoad);
/* /*
// Nothing in session store, so see if we can load it from cdtbuild // Nothing in session store, so see if we can load it from cdtbuild
if (buildInfo == null && resource instanceof IProject) { if (buildInfo == null && resource instanceof IProject) {
@ -2181,25 +2261,32 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @param resource * @param resource
* @return * @return
*/ */
synchronized private static ManagedBuildInfo findBuildInfoSynchronized(IProject project/*, boolean create*/) { synchronized private static ManagedBuildInfo findBuildInfoSynchronized(IProject project, boolean forceLoad) {
ManagedBuildInfo buildInfo = null; ManagedBuildInfo buildInfo = null;
// Check if there is any build info associated with this project for this session // Check if there is any build info associated with this project for this session
try { try {
buildInfo = (ManagedBuildInfo)project.getSessionProperty(buildInfoProperty); buildInfo = (ManagedBuildInfo)project.getSessionProperty(buildInfoProperty);
// Make sure that if a project has build info, that the info is not corrupted // Make sure that if a project has build info, that the info is not corrupted
if (buildInfo != null) { if (buildInfo != null) {
buildInfo.updateOwner(project); buildInfo.updateOwner(project);
}
} catch (CoreException e) {
// return null;
} }
} catch (CoreException e) {
// return null;
}
if(buildInfo == null && forceLoad){
// Make sure the extension information is loaded first
try {
loadExtensions();
} catch (BuildException e) {
e.printStackTrace();
return null;
}
// Check weather getBuildInfo is called from converter // Check weather getBuildInfo is called from converter
if (buildInfo == null) { buildInfo = UpdateManagedProjectManager.getConvertedManagedBuildInfo(project);
buildInfo = UpdateManagedProjectManager.getConvertedManagedBuildInfo(project);
if (buildInfo != null) return buildInfo;
}
// Nothing in session store, so see if we can load it from cdtbuild // Nothing in session store, so see if we can load it from cdtbuild
if (buildInfo == null) { if (buildInfo == null) {
@ -2220,7 +2307,9 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
final Shell shell = window.getShell(); final Shell shell = window.getShell();
final String exceptionMsg = e.getMessage(); final String exceptionMsg = e.getMessage();
shell.getDisplay().syncExec( new Runnable() { //using syncExec could cause a dead-lock
//that is why asyncExec is used
shell.getDisplay().asyncExec( new Runnable() {
public void run() { public void run() {
MessageDialog.openError(shell, MessageDialog.openError(shell,
ManagedMakeMessages.getResourceString("ManagedBuildManager.error.open_failed_title"), //$NON-NLS-1$ ManagedMakeMessages.getResourceString("ManagedBuildManager.error.open_failed_title"), //$NON-NLS-1$
@ -2229,17 +2318,18 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} }
} ); } );
} }
}
if (buildInfo != null && !buildInfo.isContainerInited()) { if (buildInfo != null && !buildInfo.isContainerInited()) {
// NOTE: If this is called inside the above rule, then an IllegalArgumentException can // NOTE: If this is called inside the above rule, then an IllegalArgumentException can
// occur when the CDT project file is saved - it uses the Workspace Root as the scheduling rule. // occur when the CDT project file is saved - it uses the Workspace Root as the scheduling rule.
// //
try { try {
// Check if the project needs its container initialized // Check if the project needs its container initialized
initBuildInfoContainer(buildInfo); initBuildInfoContainer(buildInfo);
} catch (CoreException e) { } catch (CoreException e) {
// We can live without a path entry container if the build information is valid // We can live without a path entry container if the build information is valid
}
}
} }
} }
@ -2249,13 +2339,33 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
/** /**
* Finds, but does not create, the managed build information for the * Finds, but does not create, the managed build information for the
* argument. * argument.
* Loads the build info in case it is not currently loadded
* Calling this method is the same as calling getBuildInfo(IResource resource, boolean forceLoad)
* with the "forceLoad" argument set to true
*
* *
* @see ManagedBuildManager#initBuildInfo(IResource) * @see ManagedBuildManager#initBuildInfo(IResource)
* @param resource The resource to search for managed build information on. * @param resource The resource to search for managed build information on.
* @return IManagedBuildInfo The build information object for the resource. * @return IManagedBuildInfo The build information object for the resource.
*/ */
public static IManagedBuildInfo getBuildInfo(IResource resource) { public static IManagedBuildInfo getBuildInfo(IResource resource) {
return findBuildInfo(resource.getProject()); return getBuildInfo(resource, true);
}
/**
* Finds, but does not create, the managed build information for the
* argument.
* If the build info is not currently loadded and "forceLoad" argument is set to true,
* loads the build info from the .cdtbuild file
* In case "forceLoad" is false, does not load the build info and returns null in case it is not loadded
*
* @see ManagedBuildManager#initBuildInfo(IResource)
* @param resource The resource to search for managed build information on.
* @param forceLoad specifies whether the build info should be loadded in case it is not loadded currently.
* @return IManagedBuildInfo The build information object for the resource.
*/
public static IManagedBuildInfo getBuildInfo(IResource resource, boolean forceLoad) {
return findBuildInfo(resource.getProject(), forceLoad);
} }
/** /**
@ -2581,7 +2691,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// Call the handler // Call the handler
if (options[i].getValueHandler().handleValue( if (options[i].getValueHandler().handleValue(
config, config,
options[i].getOptionHolder(), toolChain,
options[i], options[i],
options[i].getValueHandlerExtraArgument(), options[i].getValueHandlerExtraArgument(),
event)) { event)) {
@ -2603,7 +2713,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// Call the handler // Call the handler
if (toolOptions[j].getValueHandler().handleValue( if (toolOptions[j].getValueHandler().handleValue(
config, config,
toolOptions[j].getOptionHolder(), tools[i],
toolOptions[j], toolOptions[j],
toolOptions[j].getValueHandlerExtraArgument(), toolOptions[j].getValueHandlerExtraArgument(),
event)) { event)) {
@ -2647,7 +2757,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// Call the handler // Call the handler
if (toolOptions[j].getValueHandler().handleValue( if (toolOptions[j].getValueHandler().handleValue(
config, config,
toolOptions[j].getOptionHolder(), tools[i],
toolOptions[j], toolOptions[j],
toolOptions[j].getValueHandlerExtraArgument(), toolOptions[j].getValueHandlerExtraArgument(),
event)) { event)) {

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.internal.core.ResourceChangeHandler; import org.eclipse.cdt.managedbuilder.internal.core.ResourceChangeHandler;
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer; import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildPathEntryContainerInitializer; import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildPathEntryContainerInitializer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.ISavedState; import org.eclipse.core.resources.ISavedState;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
@ -138,7 +139,11 @@ public class ManagedBuilderCorePlugin extends Plugin {
ResourcesPlugin.getWorkspace().addSaveParticipant(ManagedBuilderCorePlugin.this, listener); ResourcesPlugin.getWorkspace().addSaveParticipant(ManagedBuilderCorePlugin.this, listener);
ResourcesPlugin.getWorkspace().addResourceChangeListener( ResourcesPlugin.getWorkspace().addResourceChangeListener(
listener, IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_DELETE /*| IResourceChangeEvent.POST_BUILD*/); listener,
IResourceChangeEvent.POST_CHANGE
| IResourceChangeEvent.PRE_DELETE
| IResourceChangeEvent.PRE_CLOSE
/*| IResourceChangeEvent.POST_BUILD*/);
if (lastState != null) { if (lastState != null) {
lastState.processResourceChangeEvents(listener); lastState.processResourceChangeEvents(listener);
@ -153,6 +158,10 @@ public class ManagedBuilderCorePlugin extends Plugin {
// ResourceConfiguration elements up to date. It may also be needed by AdditionalInput // ResourceConfiguration elements up to date. It may also be needed by AdditionalInput
// elements // elements
ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener); ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener);
IProject projects[] = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for(int i = 0; i < projects.length; i++){
listener.sendClose(projects[i]);
}
listener = null; listener = null;
super.stop(context); super.stop(context);
} }

View file

@ -868,6 +868,8 @@ public class Configuration extends BuildObject implements IConfiguration {
} }
public void removeResourceConfiguration(IResourceConfiguration resConfig) { public void removeResourceConfiguration(IResourceConfiguration resConfig) {
ManagedBuildManager.performValueHandlerEvent(resConfig,
IManagedOptionValueHandler.EVENT_CLOSE);
getResourceConfigurationList().remove(resConfig); getResourceConfigurationList().remove(resConfig);
getResourceConfigurationMap().remove(resConfig.getResourcePath()); getResourceConfigurationMap().remove(resConfig.getResourcePath());
isDirty = true; isDirty = true;
@ -1391,7 +1393,7 @@ public class Configuration extends BuildObject implements IConfiguration {
// Send out the event to notify the options that they are about to be removed. // Send out the event to notify the options that they are about to be removed.
// Do not do this for the child resource configurations as they are handled when // Do not do this for the child resource configurations as they are handled when
// the configuration itself is destroyed. // the configuration itself is destroyed.
ManagedBuildManager.performValueHandlerEvent(this, IManagedOptionValueHandler.EVENT_CLOSE, false); // ManagedBuildManager.performValueHandlerEvent(this, IManagedOptionValueHandler.EVENT_CLOSE, false);
// Remove the configurations // Remove the configurations
for (int i = 0; i < tools.length; i++) { for (int i = 0; i < tools.length; i++) {
ITool tool = tools[i]; ITool tool = tools[i];

View file

@ -311,6 +311,8 @@ public class ManagedProject extends BuildObject implements IManagedProject {
} }
((IProject)proj).build(IncrementalProjectBuilder.CLEAN_BUILD, monitor); ((IProject)proj).build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
ManagedBuildManager.performValueHandlerEvent(config,
IManagedOptionValueHandler.EVENT_CLOSE);
getConfigurationList().remove(config); getConfigurationList().remove(config);
getConfigurationMap().remove(removeId); getConfigurationMap().remove(removeId);

View file

@ -1404,9 +1404,9 @@ public class Option extends BuildObject implements IOption {
* @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(boolean) * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(boolean)
*/ */
public void setValue(boolean value) throws BuildException { public void setValue(boolean value) throws BuildException {
if (!isExtensionElement() && getValueType() == BOOLEAN) if (/*!isExtensionElement() && */getValueType() == BOOLEAN){
this.value = new Boolean(value); this.value = new Boolean(value);
else { } else {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
setDirty(true); setDirty(true);
@ -1418,7 +1418,7 @@ public class Option extends BuildObject implements IOption {
*/ */
public void setValue(String value) throws BuildException { public void setValue(String value) throws BuildException {
// Note that we can still set the human-readable value here // Note that we can still set the human-readable value here
if (!isExtensionElement() && (getValueType() == STRING || getValueType() == ENUMERATED)) { if (/*!isExtensionElement() && */(getValueType() == STRING || getValueType() == ENUMERATED)) {
this.value = value; this.value = value;
} else { } else {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
@ -1431,14 +1431,17 @@ public class Option extends BuildObject implements IOption {
* @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(String []) * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(String [])
*/ */
public void setValue(String [] value) throws BuildException { public void setValue(String [] value) throws BuildException {
if (!isExtensionElement() && if (/*!isExtensionElement() && */
(getValueType() == STRING_LIST (getValueType() == STRING_LIST
|| getValueType() == INCLUDE_PATH || getValueType() == INCLUDE_PATH
|| getValueType() == PREPROCESSOR_SYMBOLS || getValueType() == PREPROCESSOR_SYMBOLS
|| getValueType() == LIBRARIES || getValueType() == LIBRARIES
|| getValueType() == OBJECTS)) { || getValueType() == OBJECTS)) {
// Just replace what the option reference is holding onto // Just replace what the option reference is holding onto
this.value = new ArrayList(Arrays.asList(value)); if(value == null)
this.value = null;
else
this.value = new ArrayList(Arrays.asList(value));
} }
else { else {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$

View file

@ -201,7 +201,7 @@ public class ProjectType extends BuildObject implements IProjectType {
*/ */
public IConfiguration createConfiguration(IConfiguration parent, String id, String name) { public IConfiguration createConfiguration(IConfiguration parent, String id, String name) {
Configuration config = new Configuration(this, parent, id, name); Configuration config = new Configuration(this, parent, id, name);
ManagedBuildManager.performValueHandlerEvent(config, IManagedOptionValueHandler.EVENT_OPEN); // ManagedBuildManager.performValueHandlerEvent(config, IManagedOptionValueHandler.EVENT_OPEN);
return (IConfiguration)config; return (IConfiguration)config;
} }

View file

@ -17,6 +17,7 @@ import java.util.HashSet;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.IManagedProject; import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
@ -73,6 +74,7 @@ public class ResourceChangeHandler implements IResourceChangeListener, ISavePart
switch (delta.getKind()) { switch (delta.getKind()) {
case IResourceDelta.REMOVED : case IResourceDelta.REMOVED :
if ((delta.getFlags() & IResourceDelta.MOVED_TO) == 0 && rcType == IResource.PROJECT) { if ((delta.getFlags() & IResourceDelta.MOVED_TO) == 0 && rcType == IResource.PROJECT) {
sendClose((IProject)dResource);
break; break;
} }
case IResourceDelta.CHANGED : case IResourceDelta.CHANGED :
@ -278,6 +280,16 @@ public class ResourceChangeHandler implements IResourceChangeListener, ISavePart
} }
} }
public void sendClose(IProject project){
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project,false);
if(info != null){
IConfiguration cfgs[] = info.getManagedProject().getConfigurations();
for(int i = 0; i < cfgs.length; i++)
ManagedBuildManager.performValueHandlerEvent(cfgs[i], IManagedOptionValueHandler.EVENT_CLOSE, true);
}
}
/* /*
* I R e s o u r c e C h a n g e L i s t e n e r * I R e s o u r c e C h a n g e L i s t e n e r
*/ */
@ -291,8 +303,13 @@ public class ResourceChangeHandler implements IResourceChangeListener, ISavePart
*/ */
public void resourceChanged(IResourceChangeEvent event) { public void resourceChanged(IResourceChangeEvent event) {
if (event.getSource() instanceof IWorkspace) { if (event.getSource() instanceof IWorkspace) {
switch (event.getType()) { switch (event.getType()) {
case IResourceChangeEvent.PRE_CLOSE:
IResource proj = event.getResource();
if(proj instanceof IProject)
sendClose((IProject)proj);
break;
case IResourceChangeEvent.POST_CHANGE : case IResourceChangeEvent.POST_CHANGE :
case IResourceChangeEvent.POST_BUILD : case IResourceChangeEvent.POST_BUILD :
case IResourceChangeEvent.PRE_DELETE : case IResourceChangeEvent.PRE_DELETE :

View file

@ -730,7 +730,7 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
// We just need to remove all Options // We just need to remove all Options
ITool[] tools = getTools(); ITool[] tools = getTools();
// Send out the event to notify the options that they are about to be removed // Send out the event to notify the options that they are about to be removed
ManagedBuildManager.performValueHandlerEvent(this, IManagedOptionValueHandler.EVENT_CLOSE); // ManagedBuildManager.performValueHandlerEvent(this, IManagedOptionValueHandler.EVENT_CLOSE);
// Remove the configurations // Remove the configurations
for (int i = 0; i < tools.length; i++) { for (int i = 0; i < tools.length; i++) {
ITool tool = tools[i]; ITool tool = tools[i];

View file

@ -21,7 +21,6 @@ import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
@ -500,7 +499,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
* Call an MBS CallBack function to inform that default settings have been applied. * Call an MBS CallBack function to inform that default settings have been applied.
* This has to be sent to all the Options associated with this configuration. * This has to be sent to all the Options associated with this configuration.
*/ */
private void performSetDefaultsEventCallBack() { /* private void performSetDefaultsEventCallBack() {
if ( element instanceof IProject) { if ( element instanceof IProject) {
// Do not send the event to the child resource configurations, as performDefaults // Do not send the event to the child resource configurations, as performDefaults
@ -514,7 +513,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
IManagedOptionValueHandler.EVENT_SETDEFAULT); IManagedOptionValueHandler.EVENT_SETDEFAULT);
} }
} }
*/
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
@ -585,7 +584,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
else else
ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfiguration()); ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfiguration());
performSetDefaultsEventCallBack(); // performSetDefaultsEventCallBack();
defaultNeeded = false; defaultNeeded = false;
} }
@ -634,7 +633,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
private void saveOption(IOption clonedOption, IHoldsOptions cloneHolder){ private void saveOption(IOption clonedOption, IHoldsOptions cloneHolder){
IConfiguration realCfg = null; IConfiguration realCfg = null;
IResourceConfiguration realRcCfg = null; IResourceConfiguration realRcCfg = null;
IBuildObject handler = null; // IBuildObject handler = null;
IOption realOption; IOption realOption;
IHoldsOptions realHolder; IHoldsOptions realHolder;
@ -643,12 +642,12 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
realHolder = resParent.getRealHoldsOptions(cloneHolder); realHolder = resParent.getRealHoldsOptions(cloneHolder);
realRcCfg = (IResourceConfiguration)((ITool)realHolder).getParent(); realRcCfg = (IResourceConfiguration)((ITool)realHolder).getParent();
realCfg = realRcCfg.getParent(); realCfg = realRcCfg.getParent();
handler = realRcCfg; // handler = realRcCfg;
} else { } else {
realOption = parent.getRealOption(clonedOption,cloneHolder); realOption = parent.getRealOption(clonedOption,cloneHolder);
realHolder = parent.getRealHoldsOptions(cloneHolder); realHolder = parent.getRealHoldsOptions(cloneHolder);
realCfg = parent.getConfigurationFromHoldsOptions(realHolder); realCfg = parent.getConfigurationFromHoldsOptions(realHolder);
handler = realCfg; // handler = realCfg;
} }
try { try {
@ -729,7 +728,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
if (setOption == null) if (setOption == null)
setOption = realOption; setOption = realOption;
if (setOption.getValueHandler().handleValue( /* if (setOption.getValueHandler().handleValue(
handler, handler,
setOption.getOptionHolder(), setOption.getOptionHolder(),
setOption, setOption,
@ -739,7 +738,8 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
// May need to do something here say log a message. // May need to do something here say log a message.
} else { } else {
// Event handling Failed. // Event handling Failed.
} }
*/
} catch (BuildException e) { } catch (BuildException e) {
} catch (ClassCastException e) { } catch (ClassCastException e) {
} }

View file

@ -326,7 +326,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
if (setOption == null) if (setOption == null)
setOption = realOption; setOption = realOption;
if (setOption.getValueHandler().handleValue( /* if (setOption.getValueHandler().handleValue(
handler, handler,
setOption.getOptionHolder(), setOption.getOptionHolder(),
setOption, setOption,
@ -336,7 +336,8 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
// May need to do something here say log a message. // May need to do something here say log a message.
} else { } else {
// Event handling Failed. // Event handling Failed.
} }
*/
} catch (BuildException e) { } catch (BuildException e) {
} catch (ClassCastException e) { } catch (ClassCastException e) {
} }
@ -448,9 +449,11 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
if(fe instanceof StringFieldEditor){ if(fe instanceof StringFieldEditor){
String val = ((StringFieldEditor)fe).getStringValue(); String val = ((StringFieldEditor)fe).getStringValue();
if (isItResourceConfigPage) { if (isItResourceConfigPage) {
newOption = clonedResConfig.setOption(changedHolder,changedOption,val); newOption = ManagedBuildManager.setOption(clonedResConfig,changedHolder,changedOption,val);
// newOption = clonedResConfig.setOption(changedHolder,changedOption,val);
} else { } else {
newOption = clonedConfig.setOption(changedHolder,changedOption,val); newOption = ManagedBuildManager.setOption(clonedConfig,changedHolder,changedOption,val);
// newOption = clonedConfig.setOption(changedHolder,changedOption,val);
} }
} }
break; break;
@ -458,9 +461,11 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
if(fe instanceof BooleanFieldEditor){ if(fe instanceof BooleanFieldEditor){
boolean val = ((BooleanFieldEditor)fe).getBooleanValue(); boolean val = ((BooleanFieldEditor)fe).getBooleanValue();
if (isItResourceConfigPage) { if (isItResourceConfigPage) {
newOption = clonedResConfig.setOption(changedHolder,changedOption,val); newOption = ManagedBuildManager.setOption(clonedResConfig,changedHolder,changedOption,val);
// newOption = clonedResConfig.setOption(changedHolder,changedOption,val);
} else { } else {
newOption = clonedConfig.setOption(changedHolder,changedOption,val); newOption = ManagedBuildManager.setOption(clonedConfig,changedHolder,changedOption,val);
// newOption = clonedConfig.setOption(changedHolder,changedOption,val);
} }
} }
break; break;
@ -469,11 +474,17 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
String name = ((BuildOptionComboFieldEditor)fe).getSelection(); String name = ((BuildOptionComboFieldEditor)fe).getSelection();
String enumId = changedOption.getEnumeratedId(name); String enumId = changedOption.getEnumeratedId(name);
if(isItResourceConfigPage) { if(isItResourceConfigPage) {
newOption = clonedResConfig.setOption(changedHolder, changedOption, newOption = ManagedBuildManager.setOption(clonedResConfig,changedHolder,changedOption,
(enumId != null && enumId.length() > 0) ? enumId : name); (enumId != null && enumId.length() > 0) ? enumId : name);
// newOption = clonedResConfig.setOption(changedHolder, changedOption,
// (enumId != null && enumId.length() > 0) ? enumId : name);
} else { } else {
newOption = clonedConfig.setOption(changedHolder, changedOption, newOption = ManagedBuildManager.setOption(clonedConfig,changedHolder,changedOption,
(enumId != null && enumId.length() > 0) ? enumId : name); (enumId != null && enumId.length() > 0) ? enumId : name);
// newOption = clonedConfig.setOption(changedHolder, changedOption,
// (enumId != null && enumId.length() > 0) ? enumId : name);
} }
} }
@ -486,9 +497,11 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
if(fe instanceof FileListControlFieldEditor){ if(fe instanceof FileListControlFieldEditor){
String val[] =((FileListControlFieldEditor)fe).getStringListValue(); String val[] =((FileListControlFieldEditor)fe).getStringListValue();
if (isItResourceConfigPage) { if (isItResourceConfigPage) {
newOption = clonedResConfig.setOption(changedHolder,changedOption,val); newOption = ManagedBuildManager.setOption(clonedResConfig,changedHolder,changedOption,val);
// newOption = clonedResConfig.setOption(changedHolder,changedOption,val);
} else { } else {
newOption = clonedConfig.setOption(changedHolder,changedOption,val); newOption = ManagedBuildManager.setOption(clonedConfig,changedHolder,changedOption,val);
// newOption = clonedConfig.setOption(changedHolder,changedOption,val);
} }
} }
break; break;

View file

@ -454,19 +454,19 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
Object[][] clonedOptions; Object[][] clonedOptions;
IResourceConfiguration realRcCfg = null; IResourceConfiguration realRcCfg = null;
IConfiguration realCfg = null; IConfiguration realCfg = null;
IBuildObject handler = null; // IBuildObject handler = null;
if (isItResourceConfigPage){ if (isItResourceConfigPage){
realRcCfg = buildPropPage.getRealRcConfig(clonedResConfig); realRcCfg = buildPropPage.getRealRcConfig(clonedResConfig);
if(realRcCfg == null) if(realRcCfg == null)
return false; return false;
handler = realRcCfg; // handler = realRcCfg;
clonedOptions = clonedCategory.getOptions(clonedResConfig); clonedOptions = clonedCategory.getOptions(clonedResConfig);
} else { } else {
realCfg = buildPropPage.getRealConfig(clonedConfig); realCfg = buildPropPage.getRealConfig(clonedConfig);
if(realCfg == null) if(realCfg == null)
return false; return false;
handler = realCfg; // handler = realCfg;
clonedOptions = clonedCategory.getOptions(clonedConfig); clonedOptions = clonedCategory.getOptions(clonedConfig);
} }
@ -535,7 +535,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
// press have been applied. // press have been applied.
if (setOption == null) if (setOption == null)
setOption = realOption; setOption = realOption;
/*
if (setOption.getValueHandler().handleValue( if (setOption.getValueHandler().handleValue(
handler, handler,
setOption.getOptionHolder(), setOption.getOptionHolder(),
@ -546,7 +546,8 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
// May need to do something here say log a message. // May need to do something here say log a message.
} else { } else {
// Event handling Failed. // Event handling Failed.
} }
*/
} catch (BuildException e) { } catch (BuildException e) {
} catch (ClassCastException e) { } catch (ClassCastException e) {
} }