mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
update cdescriptor (see changelog)
This commit is contained in:
parent
001891858b
commit
0114d4cd78
10 changed files with 257 additions and 213 deletions
|
@ -1,3 +1,22 @@
|
||||||
|
2004-03-19 David Inglis
|
||||||
|
|
||||||
|
* model/org/eclipse/cdt/core/model/CoreModel.java
|
||||||
|
* model/org/eclipse/cdt/internal/core/model/CModelManager.java
|
||||||
|
Removed deprecated method and now use descriptor change events for binary parser change.
|
||||||
|
|
||||||
|
* model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
|
||||||
|
Fixed setting raw paths entries to not clear cached until after raw set.
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/core/CCorePlugin.java
|
||||||
|
* src/org/eclipse/cdt/core/ICDescriptorManager.java
|
||||||
|
* src/org/eclipse/cdt/core/ICDescriptorOperation.java
|
||||||
|
* src/org/eclipse/cdt/internal/core/CDescriptor.java
|
||||||
|
* src/org/eclipse/cdt/internal/core/CDescriptorManager.java
|
||||||
|
* src/org/eclipse/cdt/internal/core/CExtensionReference.java
|
||||||
|
Fixed decriptor file updating to be handling as a job when extensions change.
|
||||||
|
Update operation runnable to take project and IProgress.
|
||||||
|
Suppress events and saves on initialization.
|
||||||
|
|
||||||
2004-03-19 Hoda Amer
|
2004-03-19 Hoda Amer
|
||||||
The CModelBuilder sets TranslationUnit.isStructureKnown() based on
|
The CModelBuilder sets TranslationUnit.isStructureKnown() based on
|
||||||
both parser errors and IProblems sent to the callback.
|
both parser errors and IProblems sent to the callback.
|
||||||
|
|
|
@ -652,16 +652,6 @@ public class CoreModel implements ICDescriptorListener {
|
||||||
return pathEntryManager.getPathEntryContainerInitializer(containerID);
|
return pathEntryManager.getPathEntryContainerInitializer(containerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: this is a temporary hack until, the CDescriptor manager is in
|
|
||||||
* place and could fire deltas of Parser change.
|
|
||||||
*
|
|
||||||
* @deprecated this function will be removed shortly.
|
|
||||||
*/
|
|
||||||
public void resetBinaryParser(IProject project) {
|
|
||||||
manager.resetBinaryParser(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the singleton.
|
* Return the singleton.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -141,6 +141,10 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
| IResourceChangeEvent.POST_CHANGE
|
| IResourceChangeEvent.POST_CHANGE
|
||||||
| IResourceChangeEvent.PRE_DELETE
|
| IResourceChangeEvent.PRE_DELETE
|
||||||
| IResourceChangeEvent.PRE_CLOSE);
|
| IResourceChangeEvent.PRE_CLOSE);
|
||||||
|
|
||||||
|
// Register the Core Model on the Descriptor
|
||||||
|
// Manager, it needs to know about changes.
|
||||||
|
CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(factory);
|
||||||
}
|
}
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
@ -544,7 +548,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
binaryParsersMap.remove(project);
|
binaryParsersMap.remove(project);
|
||||||
celement = create(project);
|
celement = create(project);
|
||||||
Parent parent = (Parent)celement.getParent();
|
Parent parent = (Parent)celement.getParent();
|
||||||
CElementInfo info = (CElementInfo)parent.getElementInfo();
|
CElementInfo info = parent.getElementInfo();
|
||||||
info.addChild(celement);
|
info.addChild(celement);
|
||||||
|
|
||||||
// Fired and ICElementDelta.PARSER_CHANGED
|
// Fired and ICElementDelta.PARSER_CHANGED
|
||||||
|
@ -831,7 +835,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
* @see org.eclipse.cdt.core.ICDescriptorListener#descriptorChanged(org.eclipse.cdt.core.CDescriptorEvent)
|
* @see org.eclipse.cdt.core.ICDescriptorListener#descriptorChanged(org.eclipse.cdt.core.CDescriptorEvent)
|
||||||
*/
|
*/
|
||||||
public void descriptorChanged(CDescriptorEvent event) {
|
public void descriptorChanged(CDescriptorEvent event) {
|
||||||
/* int flags = event.getFlags();
|
int flags = event.getFlags();
|
||||||
if ((flags & CDescriptorEvent.EXTENSION_CHANGED) != 0) {
|
if ((flags & CDescriptorEvent.EXTENSION_CHANGED) != 0) {
|
||||||
ICDescriptor cdesc = event.getDescriptor();
|
ICDescriptor cdesc = event.getDescriptor();
|
||||||
if (cdesc != null) {
|
if (cdesc != null) {
|
||||||
|
@ -845,7 +849,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
} else { // may reorder
|
} else { // may reorder
|
||||||
for (int i = 0; i < newIds.length; i++) {
|
for (int i = 0; i < newIds.length; i++) {
|
||||||
String id = newIds[i];
|
String id = newIds[i];
|
||||||
if (!id.equals(currentConfigs)) {
|
if (!id.equals(currentConfigs[i].getId())) {
|
||||||
resetBinaryParser(project);
|
resetBinaryParser(project);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -856,7 +860,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/ }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fire C Model deltas, flushing them after the fact.
|
* Fire C Model deltas, flushing them after the fact.
|
||||||
|
|
|
@ -130,7 +130,6 @@ public class PathEntryManager {
|
||||||
public void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
|
public void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
|
||||||
try {
|
try {
|
||||||
IPathEntry[] oldResolvedEntries = (IPathEntry[]) resolvedMap.get(cproject);
|
IPathEntry[] oldResolvedEntries = (IPathEntry[]) resolvedMap.get(cproject);
|
||||||
resolvedMap.put(cproject, null);
|
|
||||||
SetPathEntriesOperation op = new SetPathEntriesOperation(cproject, oldResolvedEntries, newEntries);
|
SetPathEntriesOperation op = new SetPathEntriesOperation(cproject, oldResolvedEntries, newEntries);
|
||||||
CModelManager.getDefault().runOperation(op, monitor);
|
CModelManager.getDefault().runOperation(op, monitor);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -410,6 +409,7 @@ public class PathEntryManager {
|
||||||
encodePathEntries(cproject.getPath(), doc, rootElement, newRawEntries);
|
encodePathEntries(cproject.getPath(), doc, rootElement, newRawEntries);
|
||||||
}
|
}
|
||||||
descriptor.saveProjectData();
|
descriptor.saveProjectData();
|
||||||
|
resolvedMap.put(cproject, null);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
throw new CModelException(e);
|
throw new CModelException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,8 @@ public class CCorePlugin extends Plugin {
|
||||||
private static CCorePlugin fgCPlugin;
|
private static CCorePlugin fgCPlugin;
|
||||||
private static ResourceBundle fgResourceBundle;
|
private static ResourceBundle fgResourceBundle;
|
||||||
|
|
||||||
private CDescriptorManager fDescriptorManager;
|
private CDescriptorManager fDescriptorManager = new CDescriptorManager();
|
||||||
|
|
||||||
private CoreModel fCoreModel;
|
private CoreModel fCoreModel;
|
||||||
|
|
||||||
// -------- static methods --------
|
// -------- static methods --------
|
||||||
|
@ -230,6 +231,8 @@ public class CCorePlugin extends Plugin {
|
||||||
//Set debug tracing options
|
//Set debug tracing options
|
||||||
CCorePlugin.getDefault().configurePluginDebugOptions();
|
CCorePlugin.getDefault().configurePluginDebugOptions();
|
||||||
|
|
||||||
|
fDescriptorManager.startup();
|
||||||
|
|
||||||
// Fired up the model.
|
// Fired up the model.
|
||||||
fCoreModel = CoreModel.getDefault();
|
fCoreModel = CoreModel.getDefault();
|
||||||
fCoreModel.startup();
|
fCoreModel.startup();
|
||||||
|
@ -237,13 +240,6 @@ public class CCorePlugin extends Plugin {
|
||||||
//Fired up the indexer
|
//Fired up the indexer
|
||||||
fCoreModel.startIndexing();
|
fCoreModel.startIndexing();
|
||||||
|
|
||||||
fDescriptorManager = new CDescriptorManager();
|
|
||||||
fDescriptorManager.startup();
|
|
||||||
|
|
||||||
// Register the Core Model on the Descriptor
|
|
||||||
// Manager, it needs to know about changes.
|
|
||||||
fDescriptorManager.addDescriptorListener(fCoreModel);
|
|
||||||
|
|
||||||
// Set the default for using the structual parse mode to build the CModel
|
// Set the default for using the structual parse mode to build the CModel
|
||||||
getPluginPreferences().setDefault(PREF_USE_STRUCTURAL_PARSE_MODE, false);
|
getPluginPreferences().setDefault(PREF_USE_STRUCTURAL_PARSE_MODE, false);
|
||||||
|
|
||||||
|
@ -819,7 +815,7 @@ public class CCorePlugin extends Plugin {
|
||||||
if (extensions.length > 0)
|
if (extensions.length > 0)
|
||||||
provider = (IScannerInfoProvider) extensions[0].createExtension();
|
provider = (IScannerInfoProvider) extensions[0].createExtension();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
log(e);
|
// log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return provider;
|
return provider;
|
||||||
|
|
|
@ -11,11 +11,12 @@ package org.eclipse.cdt.core;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
public interface ICDescriptorManager {
|
public interface ICDescriptorManager {
|
||||||
public ICDescriptor getDescriptor(IProject project) throws CoreException;
|
public ICDescriptor getDescriptor(IProject project) throws CoreException;
|
||||||
|
|
||||||
public void runDescriptorOperation(ICDescriptor descriptor, ICDescriptorOperation op) throws CoreException;
|
public void runDescriptorOperation(IProject project, ICDescriptorOperation op, IProgressMonitor monitor) throws CoreException;
|
||||||
|
|
||||||
public void addDescriptorListener(ICDescriptorListener listener);
|
public void addDescriptorListener(ICDescriptorListener listener);
|
||||||
public void removeDescriptorListener(ICDescriptorListener listener);
|
public void removeDescriptorListener(ICDescriptorListener listener);
|
||||||
|
|
|
@ -10,9 +10,10 @@
|
||||||
package org.eclipse.cdt.core;
|
package org.eclipse.cdt.core;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
public interface ICDescriptorOperation {
|
public interface ICDescriptorOperation {
|
||||||
|
|
||||||
void execute(ICDescriptor descriptor) throws CoreException;
|
void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,12 +38,15 @@ import org.eclipse.cdt.core.ICOwnerInfo;
|
||||||
import org.eclipse.core.resources.IFile;
|
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.IWorkspace;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtension;
|
import org.eclipse.core.runtime.IExtension;
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IPluginRegistry;
|
import org.eclipse.core.runtime.IPluginRegistry;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
@ -58,7 +61,6 @@ public class CDescriptor implements ICDescriptor {
|
||||||
|
|
||||||
final CDescriptorManager fManager;
|
final CDescriptorManager fManager;
|
||||||
private final IProject fProject;
|
private final IProject fProject;
|
||||||
|
|
||||||
private COwner fOwner;
|
private COwner fOwner;
|
||||||
|
|
||||||
private HashMap extMap = new HashMap(4);
|
private HashMap extMap = new HashMap(4);
|
||||||
|
@ -82,8 +84,8 @@ public class CDescriptor implements ICDescriptor {
|
||||||
private static final String PROJECT_DATA_ITEM = "item"; //$NON-NLS-1$
|
private static final String PROJECT_DATA_ITEM = "item"; //$NON-NLS-1$
|
||||||
private static final String PROJECT_DATA_ID = "id"; //$NON-NLS-1$
|
private static final String PROJECT_DATA_ID = "id"; //$NON-NLS-1$
|
||||||
|
|
||||||
private boolean fDirty;
|
private boolean fUpdating;
|
||||||
private boolean fAutoSave;
|
boolean isInitializing = false;
|
||||||
|
|
||||||
protected CDescriptor(CDescriptorManager manager, IProject project, String id) throws CoreException {
|
protected CDescriptor(CDescriptorManager manager, IProject project, String id) throws CoreException {
|
||||||
fProject = project;
|
fProject = project;
|
||||||
|
@ -109,6 +111,10 @@ public class CDescriptor implements ICDescriptor {
|
||||||
throw new CoreException(status);
|
throw new CoreException(status);
|
||||||
}
|
}
|
||||||
fOwner = new COwner(id);
|
fOwner = new COwner(id);
|
||||||
|
isInitializing = true;
|
||||||
|
fOwner.configure(project, this);
|
||||||
|
isInitializing = false;
|
||||||
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CDescriptor(CDescriptorManager manager, IProject project) throws CoreException {
|
protected CDescriptor(CDescriptorManager manager, IProject project) throws CoreException {
|
||||||
|
@ -146,11 +152,10 @@ public class CDescriptor implements ICDescriptor {
|
||||||
}
|
}
|
||||||
readCDTProjectFile(descriptionPath);
|
readCDTProjectFile(descriptionPath);
|
||||||
fOwner = owner;
|
fOwner = owner;
|
||||||
setDirty();
|
isInitializing = true;
|
||||||
}
|
fOwner.configure(project, this);
|
||||||
|
isInitializing = false;
|
||||||
protected COwner getOwner() {
|
save();
|
||||||
return fOwner;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readCDTProjectFile(IPath descriptionPath) throws CoreException {
|
private String readCDTProjectFile(IPath descriptionPath) throws CoreException {
|
||||||
|
@ -214,8 +219,13 @@ public class CDescriptor implements ICDescriptor {
|
||||||
ICExtensionReference[] ext = get(extensionID);
|
ICExtensionReference[] ext = get(extensionID);
|
||||||
if (ext.length == 0 && update) {
|
if (ext.length == 0 && update) {
|
||||||
try {
|
try {
|
||||||
|
boolean oldIsInitializing = isInitializing;
|
||||||
|
isInitializing = true;
|
||||||
fOwner.update(fProject, this, extensionID);
|
fOwner.update(fProject, this, extensionID);
|
||||||
setDirty();
|
isInitializing = oldIsInitializing;
|
||||||
|
if (!isInitializing) {
|
||||||
|
updateOnDisk();
|
||||||
|
}
|
||||||
ext = get(extensionID);
|
ext = get(extensionID);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
|
@ -223,7 +233,7 @@ public class CDescriptor implements ICDescriptor {
|
||||||
return ext;
|
return ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public ICExtensionReference create(String extensionPoint, String extensionID) throws CoreException {
|
private CExtensionReference createRef(String extensionPoint, String extension) {
|
||||||
CExtensionReference extensions[] = (CExtensionReference[]) extMap.get(extensionPoint);
|
CExtensionReference extensions[] = (CExtensionReference[]) extMap.get(extensionPoint);
|
||||||
if (extensions == null) {
|
if (extensions == null) {
|
||||||
extensions = new CExtensionReference[1];
|
extensions = new CExtensionReference[1];
|
||||||
|
@ -234,12 +244,19 @@ public class CDescriptor implements ICDescriptor {
|
||||||
extensions = newExtensions;
|
extensions = newExtensions;
|
||||||
extMap.put(extensionPoint, extensions);
|
extMap.put(extensionPoint, extensions);
|
||||||
}
|
}
|
||||||
extensions[extensions.length - 1] = new CExtensionReference(this, extensionPoint, extensionID);
|
extensions[extensions.length - 1] = new CExtensionReference(this, extensionPoint, extension);
|
||||||
setDirty();
|
|
||||||
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
|
|
||||||
return extensions[extensions.length - 1];
|
return extensions[extensions.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized public ICExtensionReference create(String extensionPoint, String extension) throws CoreException {
|
||||||
|
CExtensionReference extRef = createRef(extensionPoint, extension);
|
||||||
|
if (!isInitializing) {
|
||||||
|
updateOnDisk();
|
||||||
|
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
|
||||||
|
}
|
||||||
|
return extRef;
|
||||||
|
}
|
||||||
|
|
||||||
synchronized public void remove(ICExtensionReference ext) throws CoreException {
|
synchronized public void remove(ICExtensionReference ext) throws CoreException {
|
||||||
CExtensionReference extensions[] = (CExtensionReference[]) extMap.get(ext.getExtension());
|
CExtensionReference extensions[] = (CExtensionReference[]) extMap.get(ext.getExtension());
|
||||||
for (int i = 0; i < extensions.length; i++) {
|
for (int i = 0; i < extensions.length; i++) {
|
||||||
|
@ -252,19 +269,25 @@ public class CDescriptor implements ICDescriptor {
|
||||||
} else {
|
} else {
|
||||||
extMap.remove(ext.getExtension());
|
extMap.remove(ext.getExtension());
|
||||||
}
|
}
|
||||||
setDirty();
|
if (!isInitializing) {
|
||||||
|
updateOnDisk();
|
||||||
|
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED,
|
||||||
|
CDescriptorEvent.EXTENSION_CHANGED));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void remove(String extensionPoint) throws CoreException {
|
synchronized public void remove(String extensionPoint) throws CoreException {
|
||||||
CExtensionReference extensions[] = (CExtensionReference[]) extMap.get(extensionPoint);
|
CExtensionReference extensions[] = (CExtensionReference[]) extMap.get(extensionPoint);
|
||||||
if (extensions != null) {
|
if (extensions != null) {
|
||||||
extMap.remove(extensionPoint);
|
extMap.remove(extensionPoint);
|
||||||
setDirty();
|
if (!isInitializing) {
|
||||||
|
updateOnDisk();
|
||||||
|
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED,
|
||||||
|
CDescriptorEvent.EXTENSION_CHANGED));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized CExtensionInfo getInfo(CExtensionReference cProjectExtension) {
|
synchronized CExtensionInfo getInfo(CExtensionReference cProjectExtension) {
|
||||||
|
@ -276,11 +299,17 @@ public class CDescriptor implements ICDescriptor {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized protected void saveInfo() throws CoreException {
|
protected IFile getFile() {
|
||||||
|
return getProject().getFile(DESCRIPTION_FILE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized void save() throws CoreException {
|
||||||
String xml;
|
String xml;
|
||||||
if (!isDirty()) {
|
if (!fProject.isAccessible()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
fUpdating = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
xml = getAsXML();
|
xml = getAsXML();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -302,104 +331,76 @@ public class CDescriptor implements ICDescriptor {
|
||||||
} else {
|
} else {
|
||||||
rscFile.create(inputStream, IResource.FORCE, null);
|
rscFile.create(inputStream, IResource.FORCE, null);
|
||||||
}
|
}
|
||||||
fDirty = false;
|
fUpdating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IFile getFile() {
|
boolean isUpdating() {
|
||||||
return getProject().getFile(DESCRIPTION_FILE_NAME);
|
return fUpdating;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAutoSave() {
|
synchronized void updateOnDisk() {
|
||||||
return fAutoSave;
|
if (isUpdating()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fUpdating = true;
|
||||||
|
fManager.updateDescriptor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAutoSave(boolean autoSave) {
|
synchronized void updateFromDisk() throws CoreException {
|
||||||
fAutoSave = autoSave;
|
IPath projectLocation = fProject.getDescription().getLocation();
|
||||||
}
|
|
||||||
|
|
||||||
protected void setDirty() throws CoreException {
|
if (projectLocation == null) {
|
||||||
fDirty = true;
|
projectLocation = getProjectDefaultLocation(fProject);
|
||||||
if (isAutoSave())
|
}
|
||||||
fManager.updateDescriptor(this);
|
IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
|
||||||
}
|
if (!descriptionPath.toFile().exists()) {
|
||||||
|
updateOnDisk();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
COwner origOwner = fOwner;
|
||||||
|
HashMap origExtMap = extMap;
|
||||||
|
HashMap origExtInfoMap = extInfoMap;
|
||||||
|
Document origDataDoc = dataDoc;
|
||||||
|
|
||||||
protected boolean isDirty() {
|
extMap = new HashMap(4);
|
||||||
return fDirty;
|
extInfoMap = new HashMap(4);
|
||||||
}
|
dataDoc = null;
|
||||||
|
|
||||||
protected String serializeDocument(Document doc) throws IOException, TransformerException {
|
try {
|
||||||
ByteArrayOutputStream s = new ByteArrayOutputStream();
|
fOwner = new COwner(readCDTProjectFile(descriptionPath));
|
||||||
|
} catch (CoreException e) {
|
||||||
TransformerFactory factory = TransformerFactory.newInstance();
|
CCorePlugin.log(e);
|
||||||
Transformer transformer = factory.newTransformer();
|
fOwner = origOwner;
|
||||||
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
|
extMap = origExtMap;
|
||||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
|
extInfoMap = origExtInfoMap;
|
||||||
|
dataDoc = origDataDoc;
|
||||||
DOMSource source = new DOMSource(doc);
|
}
|
||||||
StreamResult outputTarget = new StreamResult(s);
|
if (!fOwner.equals(origOwner)) {
|
||||||
transformer.transform(source, outputTarget);
|
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.OWNER_CHANGED));
|
||||||
|
} else {
|
||||||
return s.toString("UTF8"); //$NON-NLS-1$
|
boolean extChanges = true;
|
||||||
}
|
if (extMap.size() == origExtMap.size() && extInfoMap.size() == origExtInfoMap.size()) {
|
||||||
|
extChanges = false;
|
||||||
void updateFromDisk() throws CoreException {
|
Iterator entries = extMap.entrySet().iterator();
|
||||||
synchronized (this) {
|
while (entries.hasNext()) {
|
||||||
IPath projectLocation = fProject.getDescription().getLocation();
|
Entry entry = (Entry) entries.next();
|
||||||
|
if (!origExtMap.containsKey(entry.getKey())) {
|
||||||
if (projectLocation == null) {
|
extChanges = true;
|
||||||
projectLocation = getProjectDefaultLocation(fProject);
|
break;
|
||||||
}
|
}
|
||||||
IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
|
CExtensionReference origExt[] = (CExtensionReference[]) origExtMap.get(entry.getKey());
|
||||||
if (!descriptionPath.toFile().exists()) {
|
CExtensionReference newExt[] = (CExtensionReference[]) entry.getValue();
|
||||||
setDirty();
|
if (!Arrays.equals(origExt, newExt)) {
|
||||||
return;
|
extChanges = true;
|
||||||
}
|
break;
|
||||||
COwner origOwner = fOwner;
|
|
||||||
HashMap origExtMap = extMap;
|
|
||||||
HashMap origExtInfoMap = extInfoMap;
|
|
||||||
Document origDataDoc = dataDoc;
|
|
||||||
|
|
||||||
extMap = new HashMap(4);
|
|
||||||
extInfoMap = new HashMap(4);
|
|
||||||
dataDoc = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
fOwner = new COwner(readCDTProjectFile(descriptionPath));
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
fOwner = origOwner;
|
|
||||||
extMap = origExtMap;
|
|
||||||
extInfoMap = origExtInfoMap;
|
|
||||||
dataDoc = origDataDoc;
|
|
||||||
}
|
|
||||||
setDirty();
|
|
||||||
if (!fOwner.equals(origOwner)) {
|
|
||||||
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.OWNER_CHANGED));
|
|
||||||
} else {
|
|
||||||
boolean extChanges = true;
|
|
||||||
if (extMap.size() == origExtMap.size() && extInfoMap.size() == origExtInfoMap.size()) {
|
|
||||||
extChanges = false;
|
|
||||||
Iterator entries = extMap.entrySet().iterator();
|
|
||||||
while (entries.hasNext()) {
|
|
||||||
Entry entry = (Entry) entries.next();
|
|
||||||
if (!origExtMap.containsKey(entry.getKey())) {
|
|
||||||
extChanges = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
CExtensionReference origExt[] = (CExtensionReference[]) origExtMap.get(entry.getKey());
|
|
||||||
CExtensionReference newExt[] = (CExtensionReference[]) entry.getValue();
|
|
||||||
if (!Arrays.equals(origExt, newExt)) {
|
|
||||||
extChanges = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (extChanges) {
|
}
|
||||||
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED,
|
if (extChanges) {
|
||||||
CDescriptorEvent.EXTENSION_CHANGED));
|
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED,
|
||||||
} else {
|
CDescriptorEvent.EXTENSION_CHANGED));
|
||||||
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
|
} else {
|
||||||
}
|
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -430,31 +431,17 @@ public class CDescriptor implements ICDescriptor {
|
||||||
private void decodeProjectExtension(Element element) throws CoreException {
|
private void decodeProjectExtension(Element element) throws CoreException {
|
||||||
String point = element.getAttribute(PROJECT_EXTENSION_ATTR_POINT);
|
String point = element.getAttribute(PROJECT_EXTENSION_ATTR_POINT);
|
||||||
String id = element.getAttribute(PROJECT_EXTENSION_ATTR_ID);
|
String id = element.getAttribute(PROJECT_EXTENSION_ATTR_ID);
|
||||||
ICExtensionReference ext = create(point, id);
|
CExtensionReference ext = createRef(point, id);
|
||||||
NodeList extAttrib = element.getChildNodes();
|
NodeList extAttrib = element.getChildNodes();
|
||||||
for (int j = 0; j < extAttrib.getLength(); j++) {
|
for (int j = 0; j < extAttrib.getLength(); j++) {
|
||||||
if (extAttrib.item(j).getNodeName().equals(PROJECT_EXTENSION_ATTRIBUTE)) {
|
if (extAttrib.item(j).getNodeName().equals(PROJECT_EXTENSION_ATTRIBUTE)) {
|
||||||
NamedNodeMap attrib = extAttrib.item(j).getAttributes();
|
NamedNodeMap attrib = extAttrib.item(j).getAttributes();
|
||||||
ext.setExtensionData(attrib.getNamedItem(PROJECT_EXTENSION_ATTRIBUTE_KEY).getNodeValue(), attrib.getNamedItem(
|
getInfo(ext).setAttribute(attrib.getNamedItem(PROJECT_EXTENSION_ATTRIBUTE_KEY).getNodeValue(),
|
||||||
PROJECT_EXTENSION_ATTRIBUTE_VALUE).getNodeValue()); //$NON-NLS-1$ //$NON-NLS-2$
|
attrib.getNamedItem(PROJECT_EXTENSION_ATTRIBUTE_VALUE).getNodeValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getAsXML() throws IOException, TransformerException, ParserConfigurationException {
|
|
||||||
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
|
|
||||||
DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
|
|
||||||
Document doc = docBuilder.newDocument();
|
|
||||||
ProcessingInstruction version = doc.createProcessingInstruction("eclipse-cdt", "version=\"2.0\""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
doc.appendChild(version);
|
|
||||||
Element configRootElement = doc.createElement(PROJECT_DESCRIPTION);
|
|
||||||
doc.appendChild(configRootElement);
|
|
||||||
configRootElement.setAttribute(PROJECT_OWNER_ID, fOwner.getID());
|
|
||||||
encodeProjectExtensions(doc, configRootElement);
|
|
||||||
encodeProjectData(doc, configRootElement);
|
|
||||||
return serializeDocument(doc);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void encodeProjectExtensions(Document doc, Element configRootElement) {
|
private void encodeProjectExtensions(Document doc, Element configRootElement) {
|
||||||
Element element;
|
Element element;
|
||||||
Iterator extIterator = extMap.values().iterator();
|
Iterator extIterator = extMap.values().iterator();
|
||||||
|
@ -479,6 +466,20 @@ public class CDescriptor implements ICDescriptor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getAsXML() throws IOException, TransformerException, ParserConfigurationException {
|
||||||
|
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
|
||||||
|
DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
|
||||||
|
Document doc = docBuilder.newDocument();
|
||||||
|
ProcessingInstruction version = doc.createProcessingInstruction("eclipse-cdt", "version=\"2.0\""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
doc.appendChild(version);
|
||||||
|
Element configRootElement = doc.createElement(PROJECT_DESCRIPTION);
|
||||||
|
doc.appendChild(configRootElement);
|
||||||
|
configRootElement.setAttribute(PROJECT_OWNER_ID, fOwner.getID());
|
||||||
|
encodeProjectExtensions(doc, configRootElement);
|
||||||
|
encodeProjectData(doc, configRootElement);
|
||||||
|
return serializeDocument(doc);
|
||||||
|
}
|
||||||
|
|
||||||
protected ICExtension createExtensions(ICExtensionReference ext) throws CoreException {
|
protected ICExtension createExtensions(ICExtensionReference ext) throws CoreException {
|
||||||
InternalCExtension cExtension = null;
|
InternalCExtension cExtension = null;
|
||||||
IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
|
IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
|
||||||
|
@ -486,7 +487,7 @@ public class CDescriptor implements ICDescriptor {
|
||||||
IExtension extension = extensionPoint.getExtension(ext.getID());
|
IExtension extension = extensionPoint.getExtension(ext.getID());
|
||||||
if (extension == null) {
|
if (extension == null) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
|
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
|
||||||
CCorePlugin.getResourceString("CDescriptor.exception.providerNotFound"), null)); //$NON-NLS-1$
|
CCorePlugin.getResourceString("CDescriptor.exception.providerNotFound" + ":" + ext.getID()), null)); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
IConfigurationElement element[] = extension.getConfigurationElements();
|
IConfigurationElement element[] = extension.getConfigurationElements();
|
||||||
for (int i = 0; i < element.length; i++) {
|
for (int i = 0; i < element.length; i++) {
|
||||||
|
@ -517,6 +518,31 @@ public class CDescriptor implements ICDescriptor {
|
||||||
return new IConfigurationElement[0];
|
return new IConfigurationElement[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Element getProjectData(String id) throws CoreException {
|
||||||
|
NodeList nodes = getProjectDataDoc().getDocumentElement().getElementsByTagName(PROJECT_DATA_ITEM);
|
||||||
|
for (int i = 0; i < nodes.getLength(); ++i) {
|
||||||
|
Element element = (Element) nodes.item(i);
|
||||||
|
if (element.getAttribute(PROJECT_DATA_ID).equals(id))
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not found, make a new one
|
||||||
|
Element element = dataDoc.createElement(PROJECT_DATA_ITEM);
|
||||||
|
element.setAttribute(PROJECT_DATA_ID, id);
|
||||||
|
dataDoc.getDocumentElement().appendChild(element);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveProjectData() throws CoreException {
|
||||||
|
fManager.getWorkspace().run(new IWorkspaceRunnable() {
|
||||||
|
|
||||||
|
public void run(IProgressMonitor mon) throws CoreException {
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
}, fProject, IWorkspace.AVOID_UPDATE, null);
|
||||||
|
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
|
||||||
|
}
|
||||||
|
|
||||||
// The project data allows for the storage of any structured information
|
// The project data allows for the storage of any structured information
|
||||||
// into the cdtproject file.
|
// into the cdtproject file.
|
||||||
synchronized private Document getProjectDataDoc() throws CoreException {
|
synchronized private Document getProjectDataDoc() throws CoreException {
|
||||||
|
@ -538,26 +564,6 @@ public class CDescriptor implements ICDescriptor {
|
||||||
doc.replaceChild(doc.importNode(data, true), doc.getDocumentElement());
|
doc.replaceChild(doc.importNode(data, true), doc.getDocumentElement());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element getProjectData(String id) throws CoreException {
|
|
||||||
NodeList nodes = getProjectDataDoc().getDocumentElement().getElementsByTagName(PROJECT_DATA_ITEM);
|
|
||||||
for (int i = 0; i < nodes.getLength(); ++i) {
|
|
||||||
Element element = (Element) nodes.item(i);
|
|
||||||
if (element.getAttribute(PROJECT_DATA_ID).equals(id))
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not found, make a new one
|
|
||||||
Element element = dataDoc.createElement(PROJECT_DATA_ITEM);
|
|
||||||
element.setAttribute(PROJECT_DATA_ID, id);
|
|
||||||
dataDoc.getDocumentElement().appendChild(element);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveProjectData() throws CoreException {
|
|
||||||
setDirty();
|
|
||||||
fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void encodeProjectData(Document doc, Element root) {
|
private void encodeProjectData(Document doc, Element root) {
|
||||||
// Don't create or encode the doc if it isn't there already
|
// Don't create or encode the doc if it isn't there already
|
||||||
if (dataDoc != null) {
|
if (dataDoc != null) {
|
||||||
|
@ -573,4 +579,19 @@ public class CDescriptor implements ICDescriptor {
|
||||||
root.appendChild(doc.importNode(dataDoc.getDocumentElement(), true));
|
root.appendChild(doc.importNode(dataDoc.getDocumentElement(), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String serializeDocument(Document doc) throws IOException, TransformerException {
|
||||||
|
ByteArrayOutputStream s = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
TransformerFactory factory = TransformerFactory.newInstance();
|
||||||
|
Transformer transformer = factory.newTransformer();
|
||||||
|
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
|
||||||
|
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
DOMSource source = new DOMSource(doc);
|
||||||
|
StreamResult outputTarget = new StreamResult(s);
|
||||||
|
transformer.transform(source, outputTarget);
|
||||||
|
|
||||||
|
return s.toString("UTF8"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -37,6 +37,7 @@ import org.eclipse.core.runtime.ISafeRunnable;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
|
||||||
public class CDescriptorManager implements ICDescriptorManager, IResourceChangeListener {
|
public class CDescriptorManager implements ICDescriptorManager, IResourceChangeListener {
|
||||||
|
|
||||||
|
@ -44,7 +45,36 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
HashMap fDescriptorMap = new HashMap();
|
HashMap fDescriptorMap = new HashMap();
|
||||||
List listeners = new Vector();
|
List listeners = new Vector();
|
||||||
|
|
||||||
private IWorkspace getWorkspace() {
|
class CDescriptorUpdater extends Job {
|
||||||
|
|
||||||
|
CDescriptor fDescriptor;
|
||||||
|
|
||||||
|
public CDescriptorUpdater(CDescriptor descriptor) {
|
||||||
|
super(CCorePlugin.getResourceString("CDescriptorManager.async_updater")); //$NON-NLS-1$
|
||||||
|
fDescriptor = descriptor;
|
||||||
|
setPriority(Job.INTERACTIVE);
|
||||||
|
setSystem(true);
|
||||||
|
setRule(descriptor.getProject());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
|
try {
|
||||||
|
getWorkspace().run(new IWorkspaceRunnable() {
|
||||||
|
|
||||||
|
public void run(IProgressMonitor mon) throws CoreException {
|
||||||
|
fDescriptor.save();
|
||||||
|
}
|
||||||
|
}, getRule(), IWorkspace.AVOID_UPDATE, monitor);
|
||||||
|
|
||||||
|
} catch (CoreException e) {
|
||||||
|
return e.getStatus();
|
||||||
|
}
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
IWorkspace getWorkspace() {
|
||||||
return ResourcesPlugin.getWorkspace();
|
return ResourcesPlugin.getWorkspace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,10 +89,8 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
if (resource.getType() == IResource.PROJECT) {
|
if (resource.getType() == IResource.PROJECT) {
|
||||||
IProject project = (IProject) resource;
|
IProject project = (IProject) resource;
|
||||||
try {
|
try {
|
||||||
if (project.hasNature(CProjectNature.C_NATURE_ID)) {
|
if (project.isAccessible() && project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||||
if (project.isOpen()) {
|
getDescriptor(project);
|
||||||
getDescriptor(project);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
@ -86,8 +114,8 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
IResource resource = event.getResource();
|
IResource resource = event.getResource();
|
||||||
|
|
||||||
switch (event.getType()) {
|
switch (event.getType()) {
|
||||||
case IResourceChangeEvent.PRE_DELETE:
|
case IResourceChangeEvent.PRE_DELETE :
|
||||||
case IResourceChangeEvent.PRE_CLOSE:
|
case IResourceChangeEvent.PRE_CLOSE :
|
||||||
try {
|
try {
|
||||||
if (resource.getType() == IResource.PROJECT && ((IProject) resource).hasNature(CProjectNature.C_NATURE_ID)) {
|
if (resource.getType() == IResource.PROJECT && ((IProject) resource).hasNature(CProjectNature.C_NATURE_ID)) {
|
||||||
CDescriptor descriptor = (CDescriptor) fDescriptorMap.remove(resource);
|
CDescriptor descriptor = (CDescriptor) fDescriptorMap.remove(resource);
|
||||||
|
@ -99,7 +127,7 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IResourceChangeEvent.PRE_AUTO_BUILD:
|
case IResourceChangeEvent.PRE_AUTO_BUILD :
|
||||||
IResourceDelta resDelta = event.getDelta();
|
IResourceDelta resDelta = event.getDelta();
|
||||||
if (resDelta == null) {
|
if (resDelta == null) {
|
||||||
break;
|
break;
|
||||||
|
@ -112,15 +140,12 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
if (dResource.getType() == IResource.PROJECT) {
|
if (dResource.getType() == IResource.PROJECT) {
|
||||||
if (0 != (delta.getFlags() & IResourceDelta.OPEN)) {
|
if (0 != (delta.getFlags() & IResourceDelta.OPEN)) {
|
||||||
IProject project = (IProject) dResource;
|
IProject project = (IProject) dResource;
|
||||||
if (project.hasNature(CProjectNature.C_NATURE_ID)) {
|
if (project.isAccessible() && project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||||
if (project.isOpen()) {
|
getDescriptor(project);
|
||||||
getDescriptor(project);
|
} else {
|
||||||
} else {
|
CDescriptor descriptor = (CDescriptor) fDescriptorMap.remove(project);
|
||||||
CDescriptor descriptor = (CDescriptor) fDescriptorMap.remove(project);
|
if (descriptor != null) {
|
||||||
if (descriptor != null) {
|
fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_REMOVED, 0));
|
||||||
fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_REMOVED,
|
|
||||||
0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -134,7 +159,7 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
// the file got deleted lets
|
// the file got deleted lets
|
||||||
// try
|
// try
|
||||||
// and restore for memory.
|
// and restore for memory.
|
||||||
updateDescriptor(descriptor);
|
descriptor.updateOnDisk();
|
||||||
} else if ((delta.getFlags() & IResourceDelta.CONTENT) != 0) {
|
} else if ((delta.getFlags() & IResourceDelta.CONTENT) != 0) {
|
||||||
// content change lets try to
|
// content change lets try to
|
||||||
// read and update
|
// read and update
|
||||||
|
@ -160,7 +185,6 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
CDescriptor descriptor = (CDescriptor) fDescriptorMap.get(project);
|
CDescriptor descriptor = (CDescriptor) fDescriptorMap.get(project);
|
||||||
if (descriptor == null) {
|
if (descriptor == null) {
|
||||||
descriptor = new CDescriptor(this, project);
|
descriptor = new CDescriptor(this, project);
|
||||||
descriptor.setAutoSave(true);
|
|
||||||
fDescriptorMap.put(project, descriptor);
|
fDescriptorMap.put(project, descriptor);
|
||||||
}
|
}
|
||||||
return descriptor;
|
return descriptor;
|
||||||
|
@ -171,7 +195,7 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
descriptor = (CDescriptor) fDescriptorMap.get(project);
|
descriptor = (CDescriptor) fDescriptorMap.get(project);
|
||||||
if (descriptor != null) {
|
if (descriptor != null) {
|
||||||
if (!descriptor.getOwner().getID().equals(id)) {
|
if (!descriptor.getProjectOwner().getID().equals(id)) {
|
||||||
IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, CCorePlugin.STATUS_CDTPROJECT_EXISTS,
|
IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, CCorePlugin.STATUS_CDTPROJECT_EXISTS,
|
||||||
CCorePlugin.getResourceString("CDescriptorManager.exception.alreadyConfigured"), //$NON-NLS-1$
|
CCorePlugin.getResourceString("CDescriptorManager.exception.alreadyConfigured"), //$NON-NLS-1$
|
||||||
(Throwable) null);
|
(Throwable) null);
|
||||||
|
@ -181,7 +205,6 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
descriptor = new CDescriptor(this, project, id);
|
descriptor = new CDescriptor(this, project, id);
|
||||||
descriptor.getOwner().configure(project, descriptor);
|
|
||||||
} catch (CoreException e) { // if .cdtproject already exists will
|
} catch (CoreException e) { // if .cdtproject already exists will
|
||||||
// use that
|
// use that
|
||||||
IStatus status = e.getStatus();
|
IStatus status = e.getStatus();
|
||||||
|
@ -193,8 +216,6 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
fDescriptorMap.put(project, descriptor);
|
fDescriptorMap.put(project, descriptor);
|
||||||
}
|
}
|
||||||
fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_ADDED, 0));
|
fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_ADDED, 0));
|
||||||
descriptor.setAutoSave(true);
|
|
||||||
updateDescriptor(descriptor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void convert(IProject project, String id) throws CoreException {
|
public void convert(IProject project, String id) throws CoreException {
|
||||||
|
@ -202,11 +223,8 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
descriptor = new CDescriptor(this, project, new COwner(id));
|
descriptor = new CDescriptor(this, project, new COwner(id));
|
||||||
fDescriptorMap.put(project, descriptor);
|
fDescriptorMap.put(project, descriptor);
|
||||||
descriptor.getOwner().configure(project, descriptor);
|
|
||||||
}
|
}
|
||||||
fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.OWNER_CHANGED));
|
fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.OWNER_CHANGED));
|
||||||
descriptor.setAutoSave(true);
|
|
||||||
updateDescriptor(descriptor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDescriptorListener(ICDescriptorListener listener) {
|
public void addDescriptorListener(ICDescriptorListener listener) {
|
||||||
|
@ -257,11 +275,12 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runDescriptorOperation(ICDescriptor descriptor, ICDescriptorOperation op) throws CoreException {
|
public void runDescriptorOperation(IProject project, ICDescriptorOperation op, IProgressMonitor monitor) throws CoreException {
|
||||||
|
ICDescriptor descriptor = getDescriptor(project);
|
||||||
synchronized (descriptor) {
|
synchronized (descriptor) {
|
||||||
beginOperation(descriptor);
|
beginOperation(descriptor);
|
||||||
try {
|
try {
|
||||||
op.execute(descriptor);
|
op.execute(descriptor, monitor);
|
||||||
} finally {
|
} finally {
|
||||||
endOperation(descriptor);
|
endOperation(descriptor);
|
||||||
}
|
}
|
||||||
|
@ -286,15 +305,7 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
* owner update method, while the workspace is locked (ie during a
|
* owner update method, while the workspace is locked (ie during a
|
||||||
* resourceChange event).
|
* resourceChange event).
|
||||||
*/
|
*/
|
||||||
protected void updateDescriptor(final CDescriptor descriptor) throws CoreException {
|
protected void updateDescriptor(CDescriptor descriptor) {
|
||||||
if (fOperationMap.containsKey(descriptor)) {
|
new CDescriptorUpdater(descriptor).schedule();
|
||||||
return;
|
|
||||||
}
|
|
||||||
getWorkspace().run(new IWorkspaceRunnable() {
|
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
|
||||||
descriptor.saveInfo();
|
|
||||||
}
|
|
||||||
}, descriptor.getProject(), IWorkspace.AVOID_UPDATE, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -53,9 +53,10 @@ public class CExtensionReference implements ICExtensionReference {
|
||||||
|
|
||||||
public void setExtensionData(String key, String value) throws CoreException {
|
public void setExtensionData(String key, String value) throws CoreException {
|
||||||
getInfo().setAttribute(key, value);
|
getInfo().setAttribute(key, value);
|
||||||
fDescriptor.setDirty();
|
if (!fDescriptor.isInitializing) {
|
||||||
fDescriptor.fManager.fireEvent(new CDescriptorEvent(fDescriptor, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
|
fDescriptor.updateOnDisk();
|
||||||
|
fDescriptor.fManager.fireEvent(new CDescriptorEvent(fDescriptor, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExtensionData(String key) {
|
public String getExtensionData(String key) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue