1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Check for Reorder changes in the IPathEntry settings,.

This commit is contained in:
Alain Magloire 2004-03-18 22:53:11 +00:00
parent 1df94abba2
commit 1aeedbdee2
6 changed files with 73 additions and 40 deletions

View file

@ -1,3 +1,13 @@
2004-03-18 Alain Magloire
Check for IPathEntry reorder changes.
* model/org/eclipse/cdt/core/model/ICElementDelta.java
* model/org/eclipse/cdt/internal/core/model/CContainerInfo.java
* model/org/eclipse/cdt/internal/core/model/CProjectInfoInfo.java
* model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
* model/org/eclipse/cdt/internal/core/model/SetPathEntriesOperation.java
2004-03-18 Alain Magloire 2004-03-18 Alain Magloire
Change in the hierarchy of the core Model: Change in the hierarchy of the core Model:

View file

@ -129,7 +129,11 @@ public interface ICElementDelta {
*/ */
public int F_CHANGED_PATHENTRY_PROJECT = 0x04000; public int F_CHANGED_PATHENTRY_PROJECT = 0x04000;
//public int F_PATHENTRY_REORDER = 0x040000; /**
* Reordering of the path entries.
*/
public int F_PATHENTRY_REORDER = 0x040000;
//public int F_SUPER_TYPES = 0x080000; //public int F_SUPER_TYPES = 0x080000;
/** /**

View file

@ -54,8 +54,8 @@ public class CContainerInfo extends OpenableInfo {
if (resources != null) { if (resources != null) {
CModelManager factory = CModelManager.getDefault(); CModelManager factory = CModelManager.getDefault();
for (int i = 0; i < resources.length; i++) {
ICElement[] children = getChildren(); ICElement[] children = getChildren();
for (int i = 0; i < resources.length; i++) {
boolean found = false; boolean found = false;
for (int j = 0; j < children.length; j++) { for (int j = 0; j < children.length; j++) {
IResource r = children[j].getResource(); IResource r = children[j].getResource();

View file

@ -79,13 +79,13 @@ class CProjectInfo extends CContainerInfo {
if (resources != null) { if (resources != null) {
CModelManager factory = CModelManager.getDefault(); CModelManager factory = CModelManager.getDefault();
for (int i = 0; i < resources.length; i++) {
ICElement[] children; ICElement[] children;
if (root == null) { if (root == null) {
children = getChildren(); children = getChildren();
} else { } else {
children = root.getChildren(); children = root.getChildren();
} }
for (int i = 0; i < resources.length; i++) {
boolean found = false; boolean found = false;
for (int j = 0; j < children.length; j++) { for (int j = 0; j < children.length; j++) {
IResource r = children[j].getResource(); IResource r = children[j].getResource();

View file

@ -418,20 +418,25 @@ public class PathEntryManager {
public ICElementDelta[] generatePathEntryDeltas(ICProject cproject, IPathEntry[] oldEntries, IPathEntry[] newEntries) { public ICElementDelta[] generatePathEntryDeltas(ICProject cproject, IPathEntry[] oldEntries, IPathEntry[] newEntries) {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
CModelManager manager = CModelManager.getDefault(); CModelManager manager = CModelManager.getDefault();
boolean needToUpdateDependents = false;
boolean hasDelta = false; boolean hasDelta = false;
// Sanity checks
if (oldEntries == null) {
oldEntries = new IPathEntry[0];
}
if (newEntries == null) {
newEntries = new IPathEntry[0];
}
// Check the removed entries. // Check the removed entries.
if (oldEntries != null) {
for (int i = 0; i < oldEntries.length; i++) { for (int i = 0; i < oldEntries.length; i++) {
boolean found = false; boolean found = false;
if (newEntries != null) {
for (int j = 0; j < newEntries.length; j++) { for (int j = 0; j < newEntries.length; j++) {
if (oldEntries[i].equals(newEntries[j])) { if (oldEntries[i].equals(newEntries[j])) {
found = true; found = true;
break; break;
} }
} }
}
// Was it deleted. // Was it deleted.
if (!found) { if (!found) {
ICElementDelta delta = makePathEntryDelta(cproject, oldEntries[i], true); ICElementDelta delta = makePathEntryDelta(cproject, oldEntries[i], true);
@ -440,19 +445,16 @@ public class PathEntryManager {
} }
} }
} }
}
// Check the new entries. // Check the new entries.
if (newEntries != null) {
for (int i = 0; i < newEntries.length; i++) { for (int i = 0; i < newEntries.length; i++) {
boolean found = false; boolean found = false;
if (oldEntries != null) {
for (int j = 0; j < oldEntries.length; j++) { for (int j = 0; j < oldEntries.length; j++) {
if (newEntries[i].equals(oldEntries[j])) { if (newEntries[i].equals(oldEntries[j])) {
found = true; found = true;
break; break;
} }
} }
}
// is it new? // is it new?
if (!found) { if (!found) {
ICElementDelta delta = makePathEntryDelta(cproject, newEntries[i], false); ICElementDelta delta = makePathEntryDelta(cproject, newEntries[i], false);
@ -461,6 +463,17 @@ public class PathEntryManager {
} }
} }
} }
// Check for reorder
if (list.size() == 0 && oldEntries.length == newEntries.length) {
for (int i = 0; i < newEntries.length; i++) {
if (!newEntries[i].equals(oldEntries[i])) {
ICElementDelta delta = makePathEntryDelta(cproject, null, false);
if (delta != null) {
list.add(delta);
}
}
}
} }
ICElementDelta[] deltas = new ICElementDelta[list.size()]; ICElementDelta[] deltas = new ICElementDelta[list.size()];
list.toArray(deltas); list.toArray(deltas);
@ -474,7 +487,10 @@ public class PathEntryManager {
int kind = entry.getEntryKind(); int kind = entry.getEntryKind();
ICElement celement = null; ICElement celement = null;
int flag = 0; int flag = 0;
if (kind == IPathEntry.CDT_SOURCE) { if (entry == null) {
celement = cproject;
flag = ICElementDelta.F_PATHENTRY_REORDER;
} else if (kind == IPathEntry.CDT_SOURCE) {
ISourceEntry source = (ISourceEntry) entry; ISourceEntry source = (ISourceEntry) entry;
IPath path = source.getPath(); IPath path = source.getPath();
celement = CoreModel.getDefault().create(path); celement = CoreModel.getDefault().create(path);

View file

@ -53,13 +53,16 @@ public class SetPathEntriesOperation extends CModelOperation {
// project reference updated - may throw an exception if unable to write .cdtproject file // project reference updated - may throw an exception if unable to write .cdtproject file
updateProjectReferencesIfNecessary(); updateProjectReferencesIfNecessary();
PathEntryManager mgr = PathEntryManager.getDefault(); PathEntryManager mgr = PathEntryManager.getDefault();
mgr.saveRawPathEntries(cproject, newRawEntries);
hasModifiedResource = true; hasModifiedResource = true;
IPathEntry[] newResolvedEntries = mgr.getResolvedPathEntries(cproject); IPathEntry[] newResolvedEntries = mgr.getResolvedPathEntries(cproject);
ICElementDelta[] deltas = mgr.generatePathEntryDeltas(cproject, oldResolvedEntries, newResolvedEntries); ICElementDelta[] deltas = mgr.generatePathEntryDeltas(cproject, oldResolvedEntries, newResolvedEntries);
for (int i = 0; i < deltas.length; i++) { for (int i = 0; i < deltas.length; i++) {
addDelta(deltas[i]); addDelta(deltas[i]);
} }
// Only save when necessary
if (deltas.length > 0) {
mgr.saveRawPathEntries(cproject, newRawEntries);
}
done(); done();
} }