mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Progress monitor support basis for the CProjectDescription operation
This commit is contained in:
parent
2c66e22885
commit
968559df5c
15 changed files with 442 additions and 175 deletions
|
@ -48,6 +48,7 @@ import org.eclipse.cdt.managedbuilder.internal.core.NotificationManager;
|
|||
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
|
||||
|
@ -101,7 +102,8 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
|
|||
public CConfigurationData applyConfiguration(
|
||||
ICConfigurationDescription des,
|
||||
ICConfigurationDescription baseDescription,
|
||||
CConfigurationData base)
|
||||
CConfigurationData base,
|
||||
IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
if(des.isPreferenceConfiguration())
|
||||
return applyPreferences(des, base);
|
||||
|
@ -155,7 +157,8 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
|
|||
public CConfigurationData createConfiguration(
|
||||
ICConfigurationDescription des,
|
||||
ICConfigurationDescription baseDescription,
|
||||
CConfigurationData base, boolean clone)
|
||||
CConfigurationData base, boolean clone,
|
||||
IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
if(des.isPreferenceConfiguration())
|
||||
return createPreferences(des, base);
|
||||
|
@ -395,7 +398,8 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
|
|||
return emptyPrefCfg;
|
||||
}
|
||||
|
||||
public CConfigurationData loadConfiguration(ICConfigurationDescription des)
|
||||
public CConfigurationData loadConfiguration(ICConfigurationDescription des,
|
||||
IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
if(des.isPreferenceConfiguration())
|
||||
return loadPreferences(des);
|
||||
|
@ -425,7 +429,8 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
|
|||
|
||||
|
||||
public void removeConfiguration(ICConfigurationDescription des,
|
||||
CConfigurationData data) {
|
||||
CConfigurationData data,
|
||||
IProgressMonitor monitor) {
|
||||
IConfiguration cfg = ((BuildConfigurationData)data).getConfiguration();
|
||||
ManagedBuildManager.performValueHandlerEvent(cfg, IManagedOptionValueHandler.EVENT_CLOSE);
|
||||
IManagedBuildInfo info = getBuildInfo(des);
|
||||
|
|
|
@ -353,8 +353,9 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
|||
try {
|
||||
discoveryPage = (org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage) fElement.createExecutableExtension("class"); //$NON-NLS-1$
|
||||
} catch (CoreException e) {}
|
||||
if (discoveryPage == null)
|
||||
System.out.println(Messages.getString("DiscoveryTab.13") + fElement.getAttribute("class")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (discoveryPage == null) {
|
||||
// System.out.println(Messages.getString("DiscoveryTab.13") + fElement.getAttribute("class")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
return discoveryPage;
|
||||
}
|
||||
}
|
||||
|
@ -376,10 +377,11 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
|||
try {
|
||||
cbi2.applyInfo(ic, bi1);
|
||||
} catch (CoreException e) {
|
||||
System.out.println(Messages.getString("DiscoveryTab.15") + e.getLocalizedMessage()); //$NON-NLS-1$
|
||||
// System.out.println(Messages.getString("DiscoveryTab.15") + e.getLocalizedMessage()); //$NON-NLS-1$
|
||||
}
|
||||
} else
|
||||
System.out.println(Messages.getString("DiscoveryTab.16")); //$NON-NLS-1$
|
||||
} else {
|
||||
// System.out.println(Messages.getString("DiscoveryTab.16")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,6 @@ DiscoveryTab.1=Per Resource type
|
|||
DiscoveryTab.2=Configuration-wide
|
||||
DiscoveryTab.3=Unknown
|
||||
DiscoveryTab.6=No profiles found
|
||||
DiscoveryTab.13=failed to create:
|
||||
DiscoveryTab.15=applyInfo:
|
||||
DiscoveryTab.16=applyInfo: context does not fit
|
||||
ToolSelectionDialog.0=Select tools
|
||||
ToolSelectionDialog.1=Available tools
|
||||
ToolSelectionDialog.2=Used tools
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.eclipse.cdt.core.CCProjectNature;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.resources.IPathEntryStore;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.WriteAccessException;
|
||||
import org.eclipse.cdt.internal.core.model.APathEntry;
|
||||
|
@ -1318,6 +1317,10 @@ public class CoreModel {
|
|||
descriptionManager.setProjectDescription(project, des);
|
||||
}
|
||||
|
||||
public void setProjectDescription(IProject project, ICProjectDescription des, boolean force, IProgressMonitor monitor) throws CoreException {
|
||||
descriptionManager.setProjectDescription(project, des, force, monitor);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the project description associated with this project
|
||||
*
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.core.settings.model.extension;
|
|||
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
/**
|
||||
* the class is to be implemented by the Configuration data provider contributed via
|
||||
|
@ -22,7 +23,7 @@ public abstract class CConfigurationDataProvider {
|
|||
/**
|
||||
* requests the Configuration Data to be loadded for the given ConfigurationDescription
|
||||
*/
|
||||
public abstract CConfigurationData loadConfiguration(ICConfigurationDescription des) throws CoreException;
|
||||
public abstract CConfigurationData loadConfiguration(ICConfigurationDescription des, IProgressMonitor monitor) throws CoreException;
|
||||
|
||||
/**
|
||||
* requests the Configuration Data to be created for the given ConfigurationDescription
|
||||
|
@ -42,7 +43,8 @@ public abstract class CConfigurationDataProvider {
|
|||
*/
|
||||
public abstract CConfigurationData createConfiguration(ICConfigurationDescription des,
|
||||
ICConfigurationDescription baseDescription,
|
||||
CConfigurationData baseData, boolean clone) throws CoreException;
|
||||
CConfigurationData baseData, boolean clone,
|
||||
IProgressMonitor monitor) throws CoreException;
|
||||
|
||||
/**
|
||||
* called to notify the provider that the configuration is removed
|
||||
|
@ -50,7 +52,7 @@ public abstract class CConfigurationDataProvider {
|
|||
* @param des
|
||||
* @param data
|
||||
*/
|
||||
public abstract void removeConfiguration(ICConfigurationDescription des, CConfigurationData data);
|
||||
public abstract void removeConfiguration(ICConfigurationDescription des, CConfigurationData data, IProgressMonitor monitor);
|
||||
|
||||
/**
|
||||
* called during the setProjectDescription operation to notify the provider that the configuration data
|
||||
|
@ -64,5 +66,6 @@ public abstract class CConfigurationDataProvider {
|
|||
*/
|
||||
public abstract CConfigurationData applyConfiguration(ICConfigurationDescription des,
|
||||
ICConfigurationDescription baseDescription,
|
||||
CConfigurationData baseData) throws CoreException;
|
||||
CConfigurationData baseData,
|
||||
IProgressMonitor monitor) throws CoreException;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
|
|||
if(baseData instanceof CConfigurationDescriptionCache){
|
||||
baseData = ((CConfigurationDescriptionCache)baseData).getConfigurationData();
|
||||
}
|
||||
setData(CProjectDescriptionManager.getInstance().createData(this, base, baseData, false));
|
||||
setData(CProjectDescriptionManager.getInstance().createData(this, base, baseData, false, null));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -134,7 +134,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
|
|||
fCfgSpecSettings.setId(id);
|
||||
fCfgSpecSettings.setName(name);
|
||||
fCfgSpecSettings.setBuildSystemId(bsId);
|
||||
setData(CProjectDescriptionManager.getInstance().loadData(this));
|
||||
setData(CProjectDescriptionManager.getInstance().loadData(this, null));
|
||||
}
|
||||
|
||||
void doWritable() throws CoreException{
|
||||
|
@ -142,7 +142,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
|
|||
CConfigurationData data = getConfigurationData(false);
|
||||
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)data;
|
||||
data = cache.getConfigurationData();
|
||||
setData(CProjectDescriptionManager.getInstance().createData(this, cache, data, true));
|
||||
setData(CProjectDescriptionManager.getInstance().createData(this, cache, data, true, null));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
|
|||
|
||||
fDataLoadded = true;
|
||||
|
||||
fData = CProjectDescriptionManager.getInstance().loadData(this);
|
||||
fData = CProjectDescriptionManager.getInstance().loadData(this, null);
|
||||
copySettingsFrom(fData, true);
|
||||
|
||||
fSpecSettings.reconsileExtensionSettings(true);
|
||||
|
@ -125,7 +125,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
|
|||
if(fBaseDescription == null)
|
||||
return;
|
||||
|
||||
fData = CProjectDescriptionManager.getInstance().applyData(this, fBaseDescription, fData);
|
||||
fData = CProjectDescriptionManager.getInstance().applyData(this, fBaseDescription, fData, null);
|
||||
fDataLoadded = true;
|
||||
fName = fData.getName();
|
||||
fId = fData.getId();
|
||||
|
|
|
@ -47,8 +47,6 @@ import org.eclipse.cdt.core.model.ICElementDelta;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ILanguageDescriptor;
|
||||
import org.eclipse.cdt.core.model.LanguageManager;
|
||||
import org.eclipse.cdt.core.settings.model.ICBuildSetting;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICFileDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
|
||||
|
@ -96,12 +94,12 @@ import org.eclipse.core.runtime.IExtension;
|
|||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.ISafeRunnable;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
import org.eclipse.core.runtime.content.IContentTypeManager;
|
||||
import org.eclipse.core.runtime.content.IContentTypeSettings;
|
||||
|
@ -149,34 +147,74 @@ public class CProjectDescriptionManager {
|
|||
private static final QualifiedName SCANNER_INFO_PROVIDER_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, "scannerInfoProvider"); //$NON-NLS-1$
|
||||
private static final QualifiedName LOAD_FLAG = new QualifiedName(CCorePlugin.PLUGIN_ID, "descriptionLoadded"); //$NON-NLS-1$
|
||||
|
||||
private class CompositeSafeRunnable implements ISafeRunnable {
|
||||
// private class CompositeSafeRunnable implements ISafeRunnable {
|
||||
// private List fRunnables = new ArrayList();
|
||||
// private boolean fStopOnErr;
|
||||
//
|
||||
// public void add(ISafeRunnable runnable){
|
||||
// fRunnables.add(runnable);
|
||||
// }
|
||||
//
|
||||
// public void handleException(Throwable exception) {
|
||||
// }
|
||||
//
|
||||
// public void run() throws Exception {
|
||||
// for(Iterator iter = fRunnables.iterator(); iter.hasNext();){
|
||||
// ISafeRunnable r = (ISafeRunnable)iter.next();
|
||||
// try {
|
||||
// r.run();
|
||||
// } catch (Exception e){
|
||||
// r.handleException(e);
|
||||
// if(fStopOnErr)
|
||||
// throw e;
|
||||
// else
|
||||
// r.handleException(e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private class CompositeWorkspaceRunnable implements IWorkspaceRunnable {
|
||||
private List fRunnables = new ArrayList();
|
||||
private String fName;
|
||||
private boolean fStopOnErr;
|
||||
|
||||
public void add(ISafeRunnable runnable){
|
||||
CompositeWorkspaceRunnable(String name){
|
||||
if(name == null)
|
||||
name = ""; //$NON-NLS-1$
|
||||
fName = name;
|
||||
}
|
||||
|
||||
public void add(IWorkspaceRunnable runnable){
|
||||
fRunnables.add(runnable);
|
||||
}
|
||||
|
||||
public void handleException(Throwable exception) {
|
||||
}
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
monitor.beginTask(fName, fRunnables.size());
|
||||
|
||||
public void run() throws Exception {
|
||||
for(Iterator iter = fRunnables.iterator(); iter.hasNext();){
|
||||
ISafeRunnable r = (ISafeRunnable)iter.next();
|
||||
try {
|
||||
r.run();
|
||||
} catch (Exception e){
|
||||
r.handleException(e);
|
||||
if(fStopOnErr)
|
||||
throw e;
|
||||
else
|
||||
r.handleException(e);
|
||||
for(Iterator iter = fRunnables.iterator(); iter.hasNext();){
|
||||
IWorkspaceRunnable r = (IWorkspaceRunnable)iter.next();
|
||||
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
|
||||
try {
|
||||
r.run(subMonitor);
|
||||
} catch (CoreException e){
|
||||
if(fStopOnErr)
|
||||
throw e;
|
||||
} catch (RuntimeException e) {
|
||||
if(fStopOnErr)
|
||||
throw e;
|
||||
} finally {
|
||||
subMonitor.done();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
monitor.done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DesSerializationRunnable implements ISafeRunnable {
|
||||
|
||||
private class DesSerializationRunnable implements IWorkspaceRunnable {
|
||||
private ICProjectDescription fDes;
|
||||
private ICStorageElement fElement;
|
||||
|
||||
|
@ -185,10 +223,7 @@ public class CProjectDescriptionManager {
|
|||
fElement = el;
|
||||
}
|
||||
|
||||
public void handleException(Throwable exception) {
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
serialize(fDes.getProject(), STORAGE_FILE_NAME, fElement);
|
||||
((ContributedEnvironment)CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment()).serialize(fDes);
|
||||
}
|
||||
|
@ -574,15 +609,12 @@ public class CProjectDescriptionManager {
|
|||
private void saveConversion(final IProject proj,
|
||||
final IProjectDescription eDes,
|
||||
CProjectDescription des,
|
||||
final IProgressMonitor monitor) {
|
||||
IProgressMonitor monitor) {
|
||||
|
||||
CompositeSafeRunnable r = new CompositeSafeRunnable();
|
||||
r.add(new ISafeRunnable(){
|
||||
CompositeWorkspaceRunnable r = new CompositeWorkspaceRunnable(null);
|
||||
r.add(new IWorkspaceRunnable(){
|
||||
|
||||
public void handleException(Throwable exception) {
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
proj.setDescription(eDes, monitor);
|
||||
}
|
||||
});
|
||||
|
@ -596,7 +628,7 @@ public class CProjectDescriptionManager {
|
|||
runWspModification(r, monitor);
|
||||
}
|
||||
|
||||
public Job runWspModification(final ISafeRunnable runnable, IProgressMonitor monitor){
|
||||
public Job runWspModification(final IWorkspaceRunnable runnable, IProgressMonitor monitor){
|
||||
final IWorkspace wsp = ResourcesPlugin.getWorkspace();
|
||||
boolean scheduleRule = true;
|
||||
if(!wsp.isTreeLocked()) {
|
||||
|
@ -606,11 +638,12 @@ public class CProjectDescriptionManager {
|
|||
mngr.beginRule(rule, monitor);
|
||||
scheduleRule = false;
|
||||
|
||||
runAtomic(runnable);
|
||||
runAtomic(runnable, monitor);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
} catch (Exception e) {
|
||||
} finally {
|
||||
monitor.done();
|
||||
mngr.endRule(rule);
|
||||
}
|
||||
}
|
||||
|
@ -619,10 +652,12 @@ public class CProjectDescriptionManager {
|
|||
Job job = new Job(SettingsModelMessages.getString("CProjectDescriptionManager.12")){ //$NON-NLS-1$
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
runAtomic(runnable);
|
||||
runAtomic(runnable, monitor);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return e.getStatus();
|
||||
} finally {
|
||||
monitor.done();
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
@ -636,33 +671,76 @@ public class CProjectDescriptionManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
private void runAtomic(final ISafeRunnable r) throws CoreException{
|
||||
private void runAtomic(final IWorkspaceRunnable r, IProgressMonitor monitor) throws CoreException{
|
||||
IWorkspace wsp = ResourcesPlugin.getWorkspace();
|
||||
|
||||
try {
|
||||
// try {
|
||||
wsp.run(new IWorkspaceRunnable(){
|
||||
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
r.run();
|
||||
r.run(monitor);
|
||||
} catch (Exception e){
|
||||
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, e.getMessage(), e));
|
||||
CCorePlugin.log(e);
|
||||
// throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, e.getMessage(), e));
|
||||
}
|
||||
}
|
||||
|
||||
}, wsp.getRoot(), IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
|
||||
} catch (CoreException e){
|
||||
IStatus status = e.getStatus();
|
||||
if(CCorePlugin.PLUGIN_ID.equals(status.getPlugin())){
|
||||
Throwable t = status.getException();
|
||||
if(t instanceof Exception){
|
||||
r.handleException((Exception)t);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw e;
|
||||
}, wsp.getRoot(), IWorkspace.AVOID_UPDATE, monitor);
|
||||
// } catch (CoreException e){
|
||||
// IStatus status = e.getStatus();
|
||||
// if(!CCorePlugin.PLUGIN_ID.equals(status.getPlugin())){
|
||||
// throw e;
|
||||
// }
|
||||
//// Throwable t = status.getException();
|
||||
//// if(t instanceof Exception){
|
||||
//// r.handleException((Exception)t);
|
||||
//// return;
|
||||
//// }
|
||||
//// }
|
||||
//
|
||||
// throw e;
|
||||
// }
|
||||
}
|
||||
|
||||
public void updateProjectDescriptions(IProgressMonitor monitor) throws CoreException{
|
||||
IWorkspace wsp = ResourcesPlugin.getWorkspace();
|
||||
final IProject projects[] = wsp.getRoot().getProjects();
|
||||
final ICProjectDescription dess[] = new ICProjectDescription[projects.length];
|
||||
int num = 0;
|
||||
for(int i = 0; i < projects.length; i++){
|
||||
ICProjectDescription des = getProjectDescription(projects[i], false, true);
|
||||
if(des != null)
|
||||
dess[num++] = des;
|
||||
}
|
||||
|
||||
if(num != 0){
|
||||
final int[] fi = new int[num];
|
||||
runWspModification(new IWorkspaceRunnable(){
|
||||
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
monitor.beginTask("Refreshing the project settings", fi[0]);
|
||||
|
||||
for(int i = 0; i < dess.length; i++){
|
||||
ICProjectDescription des = dess[i];
|
||||
if(des == null)
|
||||
break;
|
||||
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
|
||||
try {
|
||||
setProjectDescription(des.getProject(), des, true, subMonitor);
|
||||
} catch (CoreException e){
|
||||
CCorePlugin.log(e);
|
||||
} finally {
|
||||
subMonitor.done();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, new NullProgressMonitor());
|
||||
|
||||
}
|
||||
|
||||
monitor.done();
|
||||
|
||||
}
|
||||
|
||||
private ICProjectConverter getConverter(IProject project, String oldOwnerId, ICProjectDescription des){
|
||||
|
@ -924,9 +1002,12 @@ public class CProjectDescriptionManager {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void setProjectDescription(IProject project, ICProjectDescription des) throws CoreException {
|
||||
if(!des.isModified())
|
||||
setProjectDescription(project, des, false, null);
|
||||
}
|
||||
|
||||
public void setProjectDescription(IProject project, ICProjectDescription des, boolean force, IProgressMonitor monitor) throws CoreException {
|
||||
if(!force && !des.isModified())
|
||||
return;
|
||||
|
||||
if(((CProjectDescription)des).isLoadding()){
|
||||
|
@ -940,12 +1021,15 @@ public class CProjectDescriptionManager {
|
|||
// throw ExceptionFactory.createCoreException("description is being applied");
|
||||
return;
|
||||
}
|
||||
|
||||
if(monitor == null)
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
CModelManager manager = CModelManager.getDefault();
|
||||
ICProject cproject = manager.create(project);
|
||||
|
||||
SetCProjectDescriptionOperation op = new SetCProjectDescriptionOperation(cproject, (CProjectDescription)des);
|
||||
op.runOperation(new NullProgressMonitor());
|
||||
op.runOperation(monitor);
|
||||
|
||||
|
||||
// CProjectDescription newDes = new CProjectDescription((CProjectDescription)des, true);
|
||||
|
@ -970,10 +1054,10 @@ public class CProjectDescriptionManager {
|
|||
// serialize(newDes);
|
||||
}
|
||||
|
||||
private ISafeRunnable createDesSerializationRunnable(CProjectDescription des) throws CoreException{
|
||||
private IWorkspaceRunnable createDesSerializationRunnable(CProjectDescription des) throws CoreException{
|
||||
final ICStorageElement element = des.getRootStorageElement();
|
||||
|
||||
ISafeRunnable r = new DesSerializationRunnable(des, element);
|
||||
IWorkspaceRunnable r = new DesSerializationRunnable(des, element);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -1037,7 +1121,7 @@ public class CProjectDescriptionManager {
|
|||
// }
|
||||
|
||||
void serialize(final CProjectDescription des) throws CoreException{
|
||||
ISafeRunnable r = createDesSerializationRunnable(des);
|
||||
IWorkspaceRunnable r = createDesSerializationRunnable(des);
|
||||
runWspModification(r, new NullProgressMonitor());
|
||||
|
||||
// IWorkspace wsp = ResourcesPlugin.getWorkspace();
|
||||
|
@ -1339,24 +1423,36 @@ public class CProjectDescriptionManager {
|
|||
return element;
|
||||
}
|
||||
|
||||
CConfigurationData loadData(ICConfigurationDescription des) throws CoreException{
|
||||
CConfigurationData loadData(ICConfigurationDescription des, IProgressMonitor monitor) throws CoreException{
|
||||
if(monitor == null)
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
CConfigurationDataProvider provider = getProvider(des);
|
||||
return provider.loadConfiguration(des);
|
||||
return provider.loadConfiguration(des, monitor);
|
||||
}
|
||||
|
||||
CConfigurationData applyData(ICConfigurationDescription des, ICConfigurationDescription baseDescription, CConfigurationData base) throws CoreException {
|
||||
CConfigurationData applyData(ICConfigurationDescription des, ICConfigurationDescription baseDescription, CConfigurationData base, IProgressMonitor monitor) throws CoreException {
|
||||
if(monitor == null)
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
CConfigurationDataProvider provider = getProvider(des);
|
||||
return provider.applyConfiguration(des, baseDescription, base);
|
||||
return provider.applyConfiguration(des, baseDescription, base, monitor);
|
||||
}
|
||||
|
||||
void removeData(ICConfigurationDescription des, CConfigurationData data) throws CoreException{
|
||||
void removeData(ICConfigurationDescription des, CConfigurationData data, IProgressMonitor monitor) throws CoreException{
|
||||
if(monitor == null)
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
CConfigurationDataProvider provider = getProvider(des);
|
||||
provider.removeConfiguration(des, data);
|
||||
provider.removeConfiguration(des, data, monitor);
|
||||
}
|
||||
|
||||
CConfigurationData createData(ICConfigurationDescription des, ICConfigurationDescription baseDescription, CConfigurationData base, boolean clone) throws CoreException{
|
||||
CConfigurationData createData(ICConfigurationDescription des, ICConfigurationDescription baseDescription, CConfigurationData base, boolean clone, IProgressMonitor monitor) throws CoreException{
|
||||
if(monitor == null)
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
CConfigurationDataProvider provider = getProvider(des);
|
||||
return provider.createConfiguration(des, baseDescription, base, clone);
|
||||
return provider.createConfiguration(des, baseDescription, base, clone, monitor);
|
||||
}
|
||||
|
||||
private CConfigurationDataProvider getProvider(ICConfigurationDescription des) throws CoreException{
|
||||
|
@ -1620,14 +1716,14 @@ public class CProjectDescriptionManager {
|
|||
} catch (CoreException e){
|
||||
//try refreshing
|
||||
final Throwable[] t = new Throwable[1];
|
||||
Job job = runWspModification(new ISafeRunnable(){
|
||||
Job job = runWspModification(new IWorkspaceRunnable(){
|
||||
|
||||
public void handleException(Throwable exception) {
|
||||
t[0] = exception;
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
rscFile.refreshLocal(IResource.DEPTH_ZERO, null);
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
rscFile.refreshLocal(IResource.DEPTH_ZERO, null);
|
||||
} catch (Exception e){
|
||||
t[0] = e;
|
||||
}
|
||||
}
|
||||
|
||||
}, null);
|
||||
|
@ -2565,7 +2661,7 @@ public class CProjectDescriptionManager {
|
|||
CConfigurationDescriptionCache des = (CConfigurationDescriptionCache)cfgDeltas[i].getOldSetting();
|
||||
CConfigurationData data = des.getConfigurationData();
|
||||
try {
|
||||
removeData(des, data);
|
||||
removeData(des, data, null);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
|||
import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
|
||||
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
public class DefaultConfigurationDataProvider extends
|
||||
CConfigurationDataProvider {
|
||||
|
@ -22,7 +23,8 @@ public class DefaultConfigurationDataProvider extends
|
|||
public CConfigurationData applyConfiguration(
|
||||
ICConfigurationDescription des,
|
||||
ICConfigurationDescription baseDescription,
|
||||
CConfigurationData base)
|
||||
CConfigurationData base,
|
||||
IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
//TODO: implement load/store
|
||||
return base;
|
||||
|
@ -32,13 +34,15 @@ public class DefaultConfigurationDataProvider extends
|
|||
ICConfigurationDescription des,
|
||||
ICConfigurationDescription baseDescription,
|
||||
CConfigurationData base,
|
||||
boolean clone) throws CoreException {
|
||||
boolean clone,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
//TODO: implement load/store
|
||||
CDefaultConfigurationData data = new CDefaultConfigurationData(des.getId(), des.getName(), base, null, clone);
|
||||
return data;
|
||||
}
|
||||
|
||||
public CConfigurationData loadConfiguration(ICConfigurationDescription des)
|
||||
public CConfigurationData loadConfiguration(ICConfigurationDescription des,
|
||||
IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
//TODO: implement load/store
|
||||
CDefaultConfigurationData data = new CDefaultConfigurationData(des.getId(), des.getName(), null);
|
||||
|
@ -47,7 +51,8 @@ public class DefaultConfigurationDataProvider extends
|
|||
}
|
||||
|
||||
public void removeConfiguration(ICConfigurationDescription des,
|
||||
CConfigurationData data) {
|
||||
CConfigurationData data,
|
||||
IProgressMonitor monitor) {
|
||||
//TODO: implement load/store
|
||||
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.eclipse.cdt.internal.core.model.PathEntryManager;
|
|||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
public class PathEntryConfigurationDataProvider extends
|
||||
|
@ -222,7 +223,8 @@ public class PathEntryConfigurationDataProvider extends
|
|||
public CConfigurationData applyConfiguration(
|
||||
ICConfigurationDescription des,
|
||||
ICConfigurationDescription baseDescription,
|
||||
CConfigurationData base)
|
||||
CConfigurationData base,
|
||||
IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
//TODO: check external/reference info here as well.
|
||||
if(!fFactory.isModified(base))
|
||||
|
@ -254,7 +256,8 @@ public class PathEntryConfigurationDataProvider extends
|
|||
ICConfigurationDescription des,
|
||||
ICConfigurationDescription baseDescription,
|
||||
CConfigurationData base,
|
||||
boolean clone) throws CoreException {
|
||||
boolean clone,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
CfgData copy = new CfgData(des.getId(), des.getName(), base, clone);
|
||||
copy.setModified(false);
|
||||
return copy;
|
||||
|
@ -318,13 +321,15 @@ public class PathEntryConfigurationDataProvider extends
|
|||
return ids;
|
||||
}
|
||||
|
||||
public CConfigurationData loadConfiguration(ICConfigurationDescription des)
|
||||
public CConfigurationData loadConfiguration(ICConfigurationDescription des,
|
||||
IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
return createData(des);
|
||||
}
|
||||
|
||||
public void removeConfiguration(ICConfigurationDescription des,
|
||||
CConfigurationData data) {
|
||||
CConfigurationData data,
|
||||
IProgressMonitor monitor) {
|
||||
//do nothing for now
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,10 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||
import org.eclipse.core.resources.ISaveContext;
|
||||
import org.eclipse.core.resources.ISaveParticipant;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.ISafeRunnable;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
public class ResourceChangeHandler extends ResourceChangeHandlerBase implements ISaveParticipant {
|
||||
|
@ -153,13 +154,9 @@ public class ResourceChangeHandler extends ResourceChangeHandlerBase implements
|
|||
}
|
||||
|
||||
if(fProjDesMap.size() != 0){
|
||||
fMngr.runWspModification(new ISafeRunnable(){
|
||||
fMngr.runWspModification(new IWorkspaceRunnable(){
|
||||
|
||||
public void handleException(Throwable exception) {
|
||||
CCorePlugin.log(exception);
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
for(Iterator iter = fProjDesMap.entrySet().iterator(); iter.hasNext();){
|
||||
Map.Entry entry = (Map.Entry)iter.next();
|
||||
IProject project = (IProject)entry.getKey();
|
||||
|
|
|
@ -1179,6 +1179,10 @@ public class CCorePlugin extends Plugin {
|
|||
fNewCProjectDescriptionManager.setProjectDescription(project, des);
|
||||
}
|
||||
|
||||
public void setProjectDescription(IProject project, ICProjectDescription des, boolean force, IProgressMonitor monitor) throws CoreException {
|
||||
fNewCProjectDescriptionManager.setProjectDescription(project, des, force, monitor);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the project description associated with this project
|
||||
*
|
||||
|
|
|
@ -141,13 +141,13 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
|
||||
ICdtVariable macro = macros.createMacro(macroName,type,value);
|
||||
if(macros.isChanged()){
|
||||
setRebuildStateForContext(contextType, contextData);
|
||||
macros.setChanged(false);
|
||||
}
|
||||
|
||||
if(macro != null){
|
||||
VariableChangeEvent event = createVariableChangeEvent(macro, oldVar);
|
||||
if(event != null){
|
||||
// updateProjectInfo(contextType, contextData);
|
||||
notifyListeners(event);
|
||||
}
|
||||
}
|
||||
|
@ -171,13 +171,13 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
|
||||
ICdtVariable macro = macros.createMacro(macroName,type,value);
|
||||
if(macros.isChanged()){
|
||||
setRebuildStateForContext(contextType, contextData);
|
||||
macros.setChanged(false);
|
||||
}
|
||||
|
||||
if(macro != null){
|
||||
VariableChangeEvent event = createVariableChangeEvent(macro, oldVar);
|
||||
if(event != null){
|
||||
// updateProjectInfo(contextType, contextData);
|
||||
notifyListeners(event);
|
||||
}
|
||||
}
|
||||
|
@ -200,13 +200,13 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
|
||||
ICdtVariable macro = macros.createMacro(copy);
|
||||
if(macros.isChanged()){
|
||||
setRebuildStateForContext(contextType, contextData);
|
||||
macros.setChanged(false);
|
||||
}
|
||||
|
||||
if(macro != null){
|
||||
VariableChangeEvent event = createVariableChangeEvent(macro, oldVar);
|
||||
if(event != null){
|
||||
// updateProjectInfo(contextType, contextData);
|
||||
notifyListeners(event);
|
||||
}
|
||||
}
|
||||
|
@ -219,10 +219,10 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
return null;
|
||||
ICdtVariable macro = macros.deleteMacro(name);
|
||||
if(macro != null){
|
||||
setRebuildStateForContext(contextType, contextData);
|
||||
|
||||
VariableChangeEvent event = createVariableChangeEvent(null, macro);
|
||||
if(event != null){
|
||||
// updateProjectInfo(contextType, contextData);
|
||||
notifyListeners(event);
|
||||
}
|
||||
|
||||
|
@ -238,11 +238,13 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
|
||||
ICdtVariable[] oldVars = macros.getMacros();
|
||||
|
||||
if(macros.deleteAll())
|
||||
setRebuildStateForContext(contextType, contextData);
|
||||
if(macros.deleteAll()){
|
||||
// setRebuildStateForContext(contextType, contextData);
|
||||
}
|
||||
|
||||
VariableChangeEvent event = createVariableChangeEvent(null, oldVars);
|
||||
if(event != null){
|
||||
// updateProjectInfo(contextType, contextData);
|
||||
notifyListeners(event);
|
||||
}
|
||||
|
||||
|
@ -257,11 +259,11 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
|
||||
macros.setMacros(m);
|
||||
if(macros.isChanged()){
|
||||
setRebuildStateForContext(contextType, contextData);
|
||||
macros.setChanged(false);
|
||||
|
||||
VariableChangeEvent event = createVariableChangeEvent(m, oldVars);
|
||||
if(event != null){
|
||||
// updateProjectInfo(contextType, contextData);
|
||||
notifyListeners(event);
|
||||
}
|
||||
|
||||
|
@ -450,7 +452,7 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
return new StorableCdtVariables(vars, false);
|
||||
}
|
||||
|
||||
public void setWorkspaceVariables(StorableCdtVariables vars) throws CoreException{
|
||||
public boolean setWorkspaceVariables(StorableCdtVariables vars) throws CoreException{
|
||||
StorableCdtVariables old = getStorableMacros(ICoreVariableContextInfo.CONTEXT_WORKSPACE, null);
|
||||
ICdtVariable[] oldVars = null;
|
||||
if(old != null)
|
||||
|
@ -462,10 +464,12 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
|
||||
VariableChangeEvent event = createVariableChangeEvent(newVars, oldVars);
|
||||
if(event != null){
|
||||
// updateProjectInfo(ICoreVariableContextInfo.CONTEXT_WORKSPACE, null);
|
||||
notifyListeners(event);
|
||||
}
|
||||
|
||||
storeWorkspaceVariables(true);
|
||||
return event != null;
|
||||
}
|
||||
|
||||
private Preferences getWorkspaceNode(){
|
||||
|
@ -636,33 +640,8 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
}
|
||||
}
|
||||
|
||||
protected void setRebuildStateForContext(int contextType, Object contextData){
|
||||
/*
|
||||
switch(contextType){
|
||||
case DefaultMacroContextInfo.CONTEXT_CONFIGURATION:
|
||||
if(contextData instanceof IConfiguration){
|
||||
((IConfiguration)contextData).setRebuildState(true);
|
||||
}
|
||||
break;
|
||||
case DefaultMacroContextInfo.CONTEXT_WORKSPACE:
|
||||
if(contextData instanceof IWorkspace){
|
||||
IProject projects[] = ((IWorkspace)contextData).getRoot().getProjects();
|
||||
for(int i = 0; i < projects.length; i++){
|
||||
if(ManagedBuildManager.manages(projects[i])){
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(projects[i]);
|
||||
if(info != null){
|
||||
IConfiguration cfgs[] = info.getManagedProject().getConfigurations();
|
||||
for(int j = 0; j < cfgs.length; j++){
|
||||
cfgs[j].setRebuildState(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
// protected void updateProjectInfo(int type, Object context){
|
||||
// }
|
||||
|
||||
public void addListener(ICdtVariableChangeListener listener){
|
||||
fListeners.add(listener);
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2007 Intel Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.envvar;
|
||||
|
||||
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
|
||||
|
||||
public class EnvironmentChangeEvent {
|
||||
private static final IEnvironmentVariable[] EMPTY_VAR_ARRAY = new IEnvironmentVariable[0];
|
||||
|
||||
private IEnvironmentVariable[] fAddedVars, fRemovedVars, fChangedVars;
|
||||
|
||||
EnvironmentChangeEvent(IEnvironmentVariable[] addedVars, IEnvironmentVariable[] removedVars, IEnvironmentVariable[] changedVars){
|
||||
fAddedVars = addedVars != null ? (IEnvironmentVariable[])addedVars.clone() : null;
|
||||
fRemovedVars = removedVars != null ? (IEnvironmentVariable[])removedVars.clone() : null;
|
||||
fChangedVars = changedVars != null ? (IEnvironmentVariable[])changedVars.clone() : null;
|
||||
}
|
||||
public IEnvironmentVariable[] getAddedVariables(){
|
||||
return fAddedVars != null ? (IEnvironmentVariable[])fAddedVars.clone() : EMPTY_VAR_ARRAY;
|
||||
}
|
||||
|
||||
public IEnvironmentVariable[] getRemovedVariables(){
|
||||
return fRemovedVars != null ? (IEnvironmentVariable[])fRemovedVars.clone() : EMPTY_VAR_ARRAY;
|
||||
}
|
||||
|
||||
public IEnvironmentVariable[] getChangedVariables(){
|
||||
return fChangedVars != null ? (IEnvironmentVariable[])fChangedVars.clone() : EMPTY_VAR_ARRAY;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,10 +10,15 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.envvar;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||
import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings;
|
||||
import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo;
|
||||
import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
|
||||
|
@ -51,6 +56,81 @@ public class UserDefinedEnvironmentSupplier extends
|
|||
*/
|
||||
private StorableEnvironment fWorkspaceVariables;
|
||||
|
||||
|
||||
static class VarKey {
|
||||
private IEnvironmentVariable fVar;
|
||||
private boolean fNameOnly;
|
||||
private int fCode;
|
||||
|
||||
VarKey(IEnvironmentVariable var, boolean nameOnly){
|
||||
fVar = var;
|
||||
fNameOnly = nameOnly;
|
||||
}
|
||||
|
||||
public IEnvironmentVariable getVariable(){
|
||||
return fVar;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if(obj == this)
|
||||
return true;
|
||||
|
||||
if(!(obj instanceof VarKey))
|
||||
return false;
|
||||
|
||||
VarKey other = (VarKey)obj;
|
||||
|
||||
IEnvironmentVariable otherVar = other.fVar;
|
||||
|
||||
if(fVar == otherVar)
|
||||
return true;
|
||||
|
||||
if(!CDataUtil.objectsEqual(fVar.getName(), otherVar.getName()))
|
||||
return false;
|
||||
|
||||
if(fNameOnly)
|
||||
return true;
|
||||
|
||||
if(fVar.getOperation() != otherVar.getOperation())
|
||||
return false;
|
||||
|
||||
if(!CDataUtil.objectsEqual(fVar.getValue(), otherVar.getValue()))
|
||||
return false;
|
||||
|
||||
if(!CDataUtil.objectsEqual(fVar.getDelimiter(),otherVar.getDelimiter()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int code = fCode;
|
||||
if(code == 0){
|
||||
code = 47;
|
||||
|
||||
String tmp = fVar.getName();
|
||||
if(tmp != null)
|
||||
code += tmp.hashCode();
|
||||
|
||||
if(fNameOnly)
|
||||
return code;
|
||||
|
||||
code += fVar.getOperation();
|
||||
|
||||
tmp = fVar.getValue();
|
||||
if(tmp != null)
|
||||
code += tmp.hashCode();
|
||||
|
||||
tmp = fVar.getDelimiter();
|
||||
if(tmp != null)
|
||||
code += tmp.hashCode();
|
||||
|
||||
fCode = code;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
protected StorableEnvironment getEnvironment(Object context){
|
||||
return getEnvironment(context,true);
|
||||
}
|
||||
|
@ -183,12 +263,86 @@ public class UserDefinedEnvironmentSupplier extends
|
|||
return new StorableEnvironment(envVar, false);
|
||||
}
|
||||
|
||||
public void setWorkspaceEnvironment(StorableEnvironment env){
|
||||
public boolean setWorkspaceEnvironment(StorableEnvironment env){
|
||||
StorableEnvironment oldEnv = getEnvironment(null);
|
||||
|
||||
fWorkspaceVariables = new StorableEnvironment(env, false);
|
||||
|
||||
EnvironmentChangeEvent event = createEnvironmentChangeEvent(fWorkspaceVariables.getVariables(), oldEnv.getVariables());
|
||||
|
||||
storeWorkspaceEnvironment(true);
|
||||
|
||||
// updateProjectInfo(null);
|
||||
|
||||
return event != null;
|
||||
}
|
||||
|
||||
static EnvironmentChangeEvent createEnvironmentChangeEvent(IEnvironmentVariable[] newVars, IEnvironmentVariable[] oldVars){
|
||||
IEnvironmentVariable[] addedVars = null, removedVars = null, changedVars = null;
|
||||
|
||||
if(oldVars == null || oldVars.length == 0){
|
||||
if(newVars != null && newVars.length != 0)
|
||||
addedVars = (IEnvironmentVariable[])newVars.clone() ;
|
||||
} else if(newVars == null || newVars.length == 0){
|
||||
removedVars = (IEnvironmentVariable[])oldVars.clone();
|
||||
} else {
|
||||
HashSet newSet = new HashSet(newVars.length);
|
||||
HashSet oldSet = new HashSet(oldVars.length);
|
||||
|
||||
for(int i = 0; i < newVars.length; i++){
|
||||
newSet.add(new VarKey(newVars[i], true));
|
||||
}
|
||||
|
||||
for(int i = 0; i < oldVars.length; i++){
|
||||
oldSet.add(new VarKey(oldVars[i], true));
|
||||
}
|
||||
|
||||
HashSet newSetCopy = (HashSet)newSet.clone();
|
||||
|
||||
newSet.removeAll(oldSet);
|
||||
oldSet.removeAll(newSetCopy);
|
||||
|
||||
if(newSet.size() != 0){
|
||||
addedVars = varsFromKeySet(newSet);
|
||||
}
|
||||
|
||||
if(oldSet.size() != 0){
|
||||
removedVars = varsFromKeySet(oldSet);
|
||||
}
|
||||
|
||||
newSetCopy.removeAll(newSet);
|
||||
|
||||
HashSet modifiedSet = new HashSet(newSetCopy.size());
|
||||
for(Iterator iter = newSetCopy.iterator(); iter.hasNext();){
|
||||
VarKey key = (VarKey)iter.next();
|
||||
modifiedSet.add(new VarKey(key.getVariable(), false));
|
||||
}
|
||||
|
||||
for(int i = 0; i < oldVars.length; i++){
|
||||
modifiedSet.remove(new VarKey(oldVars[i], false));
|
||||
}
|
||||
|
||||
if(modifiedSet.size() != 0)
|
||||
changedVars = varsFromKeySet(modifiedSet);
|
||||
}
|
||||
|
||||
if(addedVars != null || removedVars != null || changedVars != null)
|
||||
return new EnvironmentChangeEvent(addedVars, removedVars, changedVars);
|
||||
return null;
|
||||
}
|
||||
|
||||
static IEnvironmentVariable[] varsFromKeySet(Set set){
|
||||
IEnvironmentVariable vars[] = new IEnvironmentVariable[set.size()];
|
||||
int i = 0;
|
||||
for(Iterator iter = set.iterator(); iter.hasNext(); i++){
|
||||
VarKey key = (VarKey)iter.next();
|
||||
vars[i] = key.getVariable();
|
||||
}
|
||||
|
||||
return vars;
|
||||
}
|
||||
|
||||
|
||||
public void storeProjectEnvironment(ICProjectDescription des, boolean force){
|
||||
ICConfigurationDescription cfgs[] = des.getConfigurations();
|
||||
for(int i = 0; i < cfgs.length; i++){
|
||||
|
@ -242,7 +396,7 @@ public class UserDefinedEnvironmentSupplier extends
|
|||
return null;
|
||||
IEnvironmentVariable var = env.createVariable(name,value,op,delimiter);
|
||||
if(env.isChanged()){
|
||||
setRebuildStateForContext(context);
|
||||
// updateProjectInfo(context);
|
||||
env.setChanged(false);
|
||||
}
|
||||
return var;
|
||||
|
@ -253,8 +407,9 @@ public class UserDefinedEnvironmentSupplier extends
|
|||
if(env == null)
|
||||
return null;
|
||||
IEnvironmentVariable var = env.deleteVariable(name);
|
||||
if(var != null)
|
||||
setRebuildStateForContext(context);
|
||||
if(var != null){
|
||||
// updateProjectInfo(context);
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
|
@ -263,8 +418,9 @@ public class UserDefinedEnvironmentSupplier extends
|
|||
if(env == null)
|
||||
return;
|
||||
|
||||
if(env.deleteAll())
|
||||
setRebuildStateForContext(context);
|
||||
if(env.deleteAll()){
|
||||
// updateProjectInfo(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVariables(IEnvironmentVariable vars[], Object context){
|
||||
|
@ -274,35 +430,13 @@ public class UserDefinedEnvironmentSupplier extends
|
|||
|
||||
env.setVariales(vars);
|
||||
if(env.isChanged()){
|
||||
setRebuildStateForContext(context);
|
||||
// updateProjectInfo(context);
|
||||
env.setChanged(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setRebuildStateForContext(Object context){
|
||||
/* if(context == null)
|
||||
return;
|
||||
if(context instanceof ICConfigurationDescription){
|
||||
cfgVarsModified((ICConfigurationDescription)context);
|
||||
} else if(context == null || context instanceof IWorkspace){
|
||||
CoreModel model = CoreModel.getDefault();
|
||||
IProject projects[] = ((IWorkspace)context).getRoot().getProjects();
|
||||
for(int i = 0; i < projects.length; i++){
|
||||
ICProjectDescription des = model.getProjectDescription(projects[i]);
|
||||
|
||||
// if(ManagedBuildManager.manages(projects[i])){
|
||||
// IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(projects[i]);
|
||||
if(des != null){
|
||||
ICConfigurationDescription cfgs[] = des.getConfigurations();
|
||||
for(int j = 0; j < cfgs.length; j++){
|
||||
cfgVarsModified(cfgs[j]);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
// protected void updateProjectInfo(Object context){
|
||||
// }
|
||||
|
||||
// protected void cfgVarsModified(ICConfigurationDescription cfg){
|
||||
// cfg.setRebuildState(true);
|
||||
|
|
Loading…
Add table
Reference in a new issue