mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Changes in the PathEntryStore API
This commit is contained in:
parent
6797f7dd40
commit
dc57a7a2d1
5 changed files with 131 additions and 28 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2004-04-26 Alain Magloire
|
||||||
|
|
||||||
|
Changes in the PathEntryStore API
|
||||||
|
* model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
|
||||||
|
* model/org/eclipse/cdt/internal/core/model/PathEntryStore.java
|
||||||
|
* src/org/eclipse/cdt/core/resources/IPathEntryStore.java
|
||||||
|
* src/org/eclipse/cdt/core/resources/PathEntryStoreChangedEvent.java
|
||||||
|
|
||||||
2004-04-26 Alain Magloire
|
2004-04-26 Alain Magloire
|
||||||
|
|
||||||
Move the persistency of the IPathEntry in a differenct
|
Move the persistency of the IPathEntry in a differenct
|
||||||
|
|
|
@ -630,22 +630,34 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
*/
|
*/
|
||||||
public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
|
public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
|
||||||
IProject project = event.getProject();
|
IProject project = event.getProject();
|
||||||
if (project != null && (CoreModel.hasCNature(project) || CoreModel.hasCCNature(project))) {
|
|
||||||
CModelManager manager = CModelManager.getDefault();
|
// sanity
|
||||||
ICProject cproject = manager.create(project);
|
if (project == null) {
|
||||||
try {
|
return;
|
||||||
IPathEntry[] oldResolvedEntries = getResolvedPathEntries(cproject);
|
}
|
||||||
resolvedMap.remove(cproject);
|
|
||||||
IPathEntry[] newResolvedEntries = getResolvedPathEntries(cproject);
|
IPathEntryStore store = (IPathEntryStore)storeMap.get(project);
|
||||||
ICElementDelta[] deltas = generatePathEntryDeltas(cproject, oldResolvedEntries, newResolvedEntries);
|
if (store != null) {
|
||||||
if (deltas.length > 0) {
|
if (event.hasClosed()) {
|
||||||
cproject.close();
|
storeMap.remove(project);
|
||||||
for (int i = 0; i < deltas.length; i++) {
|
store.removePathEntryStoreListener(this);
|
||||||
manager.registerCModelDelta(deltas[i]);
|
}
|
||||||
|
if (project.isAccessible()) {
|
||||||
|
CModelManager manager = CModelManager.getDefault();
|
||||||
|
ICProject cproject = manager.create(project);
|
||||||
|
try {
|
||||||
|
IPathEntry[] oldResolvedEntries = getResolvedPathEntries(cproject);
|
||||||
|
IPathEntry[] newResolvedEntries = getResolvedPathEntries(cproject);
|
||||||
|
ICElementDelta[] deltas = generatePathEntryDeltas(cproject, oldResolvedEntries, newResolvedEntries);
|
||||||
|
if (deltas.length > 0) {
|
||||||
|
cproject.close();
|
||||||
|
for (int i = 0; i < deltas.length; i++) {
|
||||||
|
manager.registerCModelDelta(deltas[i]);
|
||||||
|
}
|
||||||
|
manager.fire(ElementChangedEvent.POST_CHANGE);
|
||||||
}
|
}
|
||||||
manager.fire(ElementChangedEvent.POST_CHANGE);
|
} catch (CModelException e) {
|
||||||
}
|
}
|
||||||
} catch (CModelException e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -671,9 +683,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
if (((flags & ICElementDelta.F_CLOSED) != 0) || (kind == ICElementDelta.REMOVED)) {
|
if (((flags & ICElementDelta.F_CLOSED) != 0) || (kind == ICElementDelta.REMOVED)) {
|
||||||
if (element.getElementType() == ICElement.C_PROJECT) {
|
if (element.getElementType() == ICElement.C_PROJECT) {
|
||||||
IProject project = element.getCProject().getProject();
|
IProject project = element.getCProject().getProject();
|
||||||
IPathEntryStore store = (IPathEntryStore)storeMap.remove(project);
|
IPathEntryStore store = (IPathEntryStore)storeMap.get(project);
|
||||||
store.removePathEntryStoreListener(this);
|
if (store != null) {
|
||||||
resolvedMap.remove(project);
|
store.fireClosedEvent(project);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ICElementDelta[] affectedChildren= delta.getAffectedChildren();
|
ICElementDelta[] affectedChildren= delta.getAffectedChildren();
|
||||||
|
|
|
@ -344,12 +344,7 @@ public class PathEntryStore extends AbstractCExtension implements IPathEntryStor
|
||||||
CModelManager manager = CModelManager.getDefault();
|
CModelManager manager = CModelManager.getDefault();
|
||||||
IProject project = cdesc.getProject();
|
IProject project = cdesc.getProject();
|
||||||
// Call the listeners.
|
// Call the listeners.
|
||||||
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(project);
|
fireContentChangedEvent(project);
|
||||||
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[listeners.size()];
|
|
||||||
listeners.toArray(observers);
|
|
||||||
for (int i = 0; i < observers.length; i++) {
|
|
||||||
observers[i].pathEntryStoreChanged(evt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,4 +363,28 @@ public class PathEntryStore extends AbstractCExtension implements IPathEntryStor
|
||||||
listeners.remove(listener);
|
listeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.resources.IPathEntryStore#fireContentChangedEvent(IProject)
|
||||||
|
*/
|
||||||
|
public void fireContentChangedEvent(IProject project) {
|
||||||
|
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, project, PathEntryStoreChangedEvent.CONTENT_CHANGED);
|
||||||
|
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[listeners.size()];
|
||||||
|
listeners.toArray(observers);
|
||||||
|
for (int i = 0; i < observers.length; i++) {
|
||||||
|
observers[i].pathEntryStoreChanged(evt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.resources.IPathEntryStore#fireClosedChangedEvent(IProject)
|
||||||
|
*/
|
||||||
|
public void fireClosedEvent(IProject project) {
|
||||||
|
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, project, PathEntryStoreChangedEvent.STORE_CLOSED);
|
||||||
|
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[listeners.size()];
|
||||||
|
listeners.toArray(observers);
|
||||||
|
for (int i = 0; i < observers.length; i++) {
|
||||||
|
observers[i].pathEntryStoreChanged(evt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,52 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* IPathEntryStore
|
* IPathEntryStore
|
||||||
*/
|
*/
|
||||||
public interface IPathEntryStore {
|
public interface IPathEntryStore {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path entries save on the project.
|
||||||
|
* @param project
|
||||||
|
* @return
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
IPathEntry[] getRawPathEntries(IProject project) throws CoreException;
|
IPathEntry[] getRawPathEntries(IProject project) throws CoreException;
|
||||||
void setRawPathEntries(IProject project, IPathEntry[] engries) throws CoreException;
|
|
||||||
|
/**
|
||||||
|
* Save the entries on the project.
|
||||||
|
* Setting paths should fire a CONTENT_CHANGED events to the listeners.
|
||||||
|
* It is up to the listener to calculate the deltas.
|
||||||
|
*
|
||||||
|
* @param project
|
||||||
|
* @param entries
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
void setRawPathEntries(IProject project, IPathEntry[] entries) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a listener to the store.
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
*/
|
||||||
void addPathEntryStoreListener(IPathEntryStoreListener listener);
|
void addPathEntryStoreListener(IPathEntryStoreListener listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the listener form the list.
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
*/
|
||||||
void removePathEntryStoreListener(IPathEntryStoreListener listener);
|
void removePathEntryStoreListener(IPathEntryStoreListener listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fire a CONTENT_CHANGED event to the listeners.
|
||||||
|
*
|
||||||
|
* @param project
|
||||||
|
*/
|
||||||
|
void fireContentChangedEvent(IProject project);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fire a CLOSE_STORE event to the listeners.
|
||||||
|
*
|
||||||
|
* @param project
|
||||||
|
*/
|
||||||
|
void fireClosedEvent(IProject project);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,15 +19,35 @@ import org.eclipse.core.resources.IProject;
|
||||||
* PathEntryChangedEvent
|
* PathEntryChangedEvent
|
||||||
*/
|
*/
|
||||||
public class PathEntryStoreChangedEvent extends EventObject {
|
public class PathEntryStoreChangedEvent extends EventObject {
|
||||||
|
|
||||||
|
public static final int CONTENT_CHANGED = 1;
|
||||||
|
public static final int STORE_CLOSED = 2;
|
||||||
|
|
||||||
|
private final int flags;
|
||||||
|
private final IProject project;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public PathEntryStoreChangedEvent(Object object) {
|
public PathEntryStoreChangedEvent(IPathEntryStore store, IProject project, int flags) {
|
||||||
super(object);
|
super(store);
|
||||||
|
this.project = project;
|
||||||
|
this.flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPathEntryStore getPathEntryStore() {
|
||||||
|
return (IPathEntryStore)getSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IProject getProject() {
|
public IProject getProject() {
|
||||||
return (IProject)getSource();
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasContentChanged() {
|
||||||
|
return (flags & CONTENT_CHANGED) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasClosed() {
|
||||||
|
return (flags & STORE_CLOSED) != 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue