mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Project remove handling fixes
Property manager fixes
This commit is contained in:
parent
45152faccd
commit
93c96e0452
3 changed files with 104 additions and 26 deletions
|
@ -35,6 +35,7 @@ import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.envvar.UserDefinedEnvironmentSupplier;
|
import org.eclipse.cdt.managedbuilder.internal.envvar.UserDefinedEnvironmentSupplier;
|
||||||
|
@ -45,9 +46,12 @@ import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceDelta;
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
|
import org.eclipse.core.resources.ProjectScope;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.PluginVersionIdentifier;
|
import org.eclipse.core.runtime.PluginVersionIdentifier;
|
||||||
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
|
import org.osgi.service.prefs.Preferences;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
@ -109,10 +113,11 @@ public class Configuration extends BuildObject implements IConfiguration {
|
||||||
//as a special Builder object of the tool-chain and implement the internal
|
//as a special Builder object of the tool-chain and implement the internal
|
||||||
//builder enabling/disabling as the Builder substitution functionality
|
//builder enabling/disabling as the Builder substitution functionality
|
||||||
//
|
//
|
||||||
//property that holds the Internal Builder enable state
|
private static final String INTERNAL_BUILDER = "internalBuilder";
|
||||||
private static final String INTERNAL_BUILDER_ENABLED = "internalBuilderOn"; //$NON-NLS-1$
|
//preference key that holds the Internal Builder enable state
|
||||||
//property that holds the internal builder mode
|
private static final String INTERNAL_BUILDER_ENABLED = "enabled"; //$NON-NLS-1$
|
||||||
private static final String INTERNAL_BUILDER_IGNORE_ERR = "internalBuilderIgnoreErr"; //$NON-NLS-1$
|
//preference key that holds the internal builder mode
|
||||||
|
private static final String INTERNAL_BUILDER_IGNORE_ERR = "ignoreErr"; //$NON-NLS-1$
|
||||||
//Internal Builder enable state
|
//Internal Builder enable state
|
||||||
private boolean internalBuilderEnabled;
|
private boolean internalBuilderEnabled;
|
||||||
//Internal Builder mode
|
//Internal Builder mode
|
||||||
|
@ -270,11 +275,12 @@ public class Configuration extends BuildObject implements IConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internalBuilderEnabled = Boolean.valueOf(
|
Preferences prefs = getPreferences(INTERNAL_BUILDER);
|
||||||
mngr.getProperty(this, INTERNAL_BUILDER_ENABLED)).booleanValue();
|
|
||||||
String tmp = mngr.getProperty(this, INTERNAL_BUILDER_IGNORE_ERR);
|
internalBuilderEnabled = prefs != null ?
|
||||||
if(tmp == null || Boolean.valueOf(tmp).booleanValue())
|
prefs.getBoolean(INTERNAL_BUILDER_ENABLED, false) : false;
|
||||||
internalBuilderIgnoreErr = true;
|
internalBuilderIgnoreErr = prefs != null ?
|
||||||
|
prefs.getBoolean(INTERNAL_BUILDER_IGNORE_ERR, true) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1722,7 +1728,14 @@ public class Configuration extends BuildObject implements IConfiguration {
|
||||||
public void enableInternalBuilder(boolean enable){
|
public void enableInternalBuilder(boolean enable){
|
||||||
if(internalBuilderEnabled != enable){
|
if(internalBuilderEnabled != enable){
|
||||||
internalBuilderEnabled = enable;
|
internalBuilderEnabled = enable;
|
||||||
PropertyManager.getInstance().setProperty(this, INTERNAL_BUILDER_ENABLED, Boolean.toString(internalBuilderEnabled));
|
Preferences prefs = getPreferences(INTERNAL_BUILDER);
|
||||||
|
if(prefs != null){
|
||||||
|
prefs.putBoolean(INTERNAL_BUILDER_ENABLED, internalBuilderEnabled);
|
||||||
|
try {
|
||||||
|
prefs.flush();
|
||||||
|
} catch (BackingStoreException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1746,7 +1759,14 @@ public class Configuration extends BuildObject implements IConfiguration {
|
||||||
public void setInternalBuilderIgnoreErr(boolean ignore){
|
public void setInternalBuilderIgnoreErr(boolean ignore){
|
||||||
if(internalBuilderIgnoreErr != ignore){
|
if(internalBuilderIgnoreErr != ignore){
|
||||||
internalBuilderIgnoreErr = ignore;
|
internalBuilderIgnoreErr = ignore;
|
||||||
PropertyManager.getInstance().setProperty(this, INTERNAL_BUILDER_IGNORE_ERR, Boolean.toString(internalBuilderIgnoreErr));
|
Preferences prefs = getPreferences(INTERNAL_BUILDER);
|
||||||
|
if(prefs != null){
|
||||||
|
prefs.putBoolean(INTERNAL_BUILDER_IGNORE_ERR, internalBuilderIgnoreErr);
|
||||||
|
try {
|
||||||
|
prefs.flush();
|
||||||
|
} catch (BackingStoreException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1760,4 +1780,22 @@ public class Configuration extends BuildObject implements IConfiguration {
|
||||||
public boolean getInternalBuilderIgnoreErr(){
|
public boolean getInternalBuilderIgnoreErr(){
|
||||||
return internalBuilderIgnoreErr;
|
return internalBuilderIgnoreErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Preferences getPreferences(String name){
|
||||||
|
if(isTemporary)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IProject project = (IProject)getOwner();
|
||||||
|
|
||||||
|
if(project == null || !project.exists() || !project.isOpen())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Preferences prefs = new ProjectScope(project).getNode(ManagedBuilderCorePlugin.getUniqueIdentifier());
|
||||||
|
if(prefs != null){
|
||||||
|
prefs = prefs.node(getId());
|
||||||
|
if(prefs != null && name != null)
|
||||||
|
prefs = prefs.node(name);
|
||||||
|
}
|
||||||
|
return prefs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ import org.osgi.service.prefs.Preferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class allows specifying BuildObject-specific persisted properties
|
* This class allows specifying BuildObject-specific persisted properties
|
||||||
* The properties are stored as project preferences for now
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PropertyManager {
|
public class PropertyManager {
|
||||||
|
@ -64,7 +63,6 @@ public class PropertyManager {
|
||||||
Properties props = getProperties(cfg, bo);
|
Properties props = getProperties(cfg, bo);
|
||||||
if(props != null){
|
if(props != null){
|
||||||
props.setProperty(prop, value);
|
props.setProperty(prop, value);
|
||||||
serialize(cfg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,9 +229,8 @@ public class PropertyManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Preferences getNode(IManagedProject mProject){
|
protected Preferences getNode(IManagedProject mProject){
|
||||||
//TODO: should we store the data as the workspaces preferences?
|
// return getProjNode(mProject);
|
||||||
return getProjNode(mProject);
|
return getInstNode(mProject);
|
||||||
// return getInstNode(mProject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Preferences getProjNode(IManagedProject mProject){
|
protected Preferences getProjNode(IManagedProject mProject){
|
||||||
|
@ -343,6 +340,23 @@ public class PropertyManager {
|
||||||
return getProperty(getConfiguration(builder), builder, key);
|
return getProperty(getConfiguration(builder), builder, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearProperties(IManagedProject mProject){
|
||||||
|
IConfiguration cfgs[] = mProject.getConfigurations();
|
||||||
|
for(int i = 0; i < cfgs.length; i++)
|
||||||
|
clearLoaddedData(cfgs[i]);
|
||||||
|
|
||||||
|
Preferences prefs = getNode(mProject);
|
||||||
|
if(prefs != null){
|
||||||
|
try {
|
||||||
|
Preferences parent = prefs.parent();
|
||||||
|
prefs.removeNode();
|
||||||
|
if(parent != null)
|
||||||
|
parent.flush();
|
||||||
|
} catch (BackingStoreException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void clearProperties(IConfiguration cfg){
|
public void clearProperties(IConfiguration cfg){
|
||||||
clearLoaddedData(cfg);
|
clearLoaddedData(cfg);
|
||||||
storeData(cfg, null);
|
storeData(cfg, null);
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.managedbuilder.internal.core;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -49,6 +50,8 @@ import org.eclipse.core.runtime.jobs.MultiRule;
|
||||||
|
|
||||||
public class ResourceChangeHandler implements IResourceChangeListener, ISaveParticipant {
|
public class ResourceChangeHandler implements IResourceChangeListener, ISaveParticipant {
|
||||||
|
|
||||||
|
private Map fRmProjectToBuildInfoMap = new HashMap();
|
||||||
|
|
||||||
private class ResourceConfigurationChecker implements IResourceDeltaVisitor{
|
private class ResourceConfigurationChecker implements IResourceDeltaVisitor{
|
||||||
private IResourceDelta fRootDelta;
|
private IResourceDelta fRootDelta;
|
||||||
private HashMap fBuildFileGeneratorMap = new HashMap();
|
private HashMap fBuildFileGeneratorMap = new HashMap();
|
||||||
|
@ -73,10 +76,17 @@ public class ResourceChangeHandler implements IResourceChangeListener, ISavePart
|
||||||
IResource rcToCheck = null;
|
IResource rcToCheck = null;
|
||||||
switch (delta.getKind()) {
|
switch (delta.getKind()) {
|
||||||
case IResourceDelta.REMOVED :
|
case IResourceDelta.REMOVED :
|
||||||
if ((delta.getFlags() & IResourceDelta.MOVED_TO) == 0 && rcType == IResource.PROJECT) {
|
if (rcType == IResource.PROJECT){
|
||||||
sendClose((IProject)dResource);
|
IManagedBuildInfo info = (IManagedBuildInfo)fRmProjectToBuildInfoMap.remove(dResource);
|
||||||
|
|
||||||
|
if((delta.getFlags() & IResourceDelta.MOVED_TO) == 0) {
|
||||||
|
if(info != null){
|
||||||
|
sendClose(info);
|
||||||
|
PropertyManager.getInstance().clearProperties(info.getManagedProject());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case IResourceDelta.CHANGED :
|
case IResourceDelta.CHANGED :
|
||||||
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
||||||
IPath path = delta.getMovedToPath();
|
IPath path = delta.getMovedToPath();
|
||||||
|
@ -281,7 +291,10 @@ public class ResourceChangeHandler implements IResourceChangeListener, ISavePart
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendClose(IProject project){
|
public void sendClose(IProject project){
|
||||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project,false);
|
sendClose(ManagedBuildManager.getBuildInfo(project,false));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendClose(IManagedBuildInfo info){
|
||||||
if(info != null){
|
if(info != null){
|
||||||
IManagedProject managedProj = info.getManagedProject();
|
IManagedProject managedProj = info.getManagedProject();
|
||||||
if (managedProj != null) {
|
if (managedProj != null) {
|
||||||
|
@ -313,9 +326,21 @@ public class ResourceChangeHandler implements IResourceChangeListener, ISavePart
|
||||||
if(proj instanceof IProject)
|
if(proj instanceof IProject)
|
||||||
sendClose((IProject)proj);
|
sendClose((IProject)proj);
|
||||||
break;
|
break;
|
||||||
|
case IResourceChangeEvent.PRE_DELETE :
|
||||||
|
IResource rc = event.getResource();
|
||||||
|
if(rc instanceof IProject){
|
||||||
|
IProject project = (IProject)rc;
|
||||||
|
try {
|
||||||
|
if (project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
|
||||||
|
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||||
|
if(info != null)
|
||||||
|
fRmProjectToBuildInfoMap.put(project, info);
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
case IResourceChangeEvent.POST_CHANGE :
|
case IResourceChangeEvent.POST_CHANGE :
|
||||||
case IResourceChangeEvent.POST_BUILD :
|
case IResourceChangeEvent.POST_BUILD :
|
||||||
case IResourceChangeEvent.PRE_DELETE :
|
|
||||||
IResourceDelta resDelta = event.getDelta();
|
IResourceDelta resDelta = event.getDelta();
|
||||||
if (resDelta == null) {
|
if (resDelta == null) {
|
||||||
break;
|
break;
|
||||||
|
@ -433,8 +458,9 @@ public class ResourceChangeHandler implements IResourceChangeListener, ISavePart
|
||||||
* @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext)
|
* @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext)
|
||||||
*/
|
*/
|
||||||
public void saving(ISaveContext context) throws CoreException {
|
public void saving(ISaveContext context) throws CoreException {
|
||||||
// No state to be saved by the plug-in, but request a
|
PropertyManager.getInstance().serialize();
|
||||||
// resource delta to be used on next activation.
|
|
||||||
|
//Request a resource delta to be used on next activation.
|
||||||
context.needDelta();
|
context.needDelta();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue