|
Lines 31-37
Link Here
|
| 31 |
super(path, container); |
31 |
super(path, container); |
| 32 |
pathVariableManager = new ProjectPathVariableManager(this); |
32 |
pathVariableManager = new ProjectPathVariableManager(this); |
| 33 |
} |
33 |
} |
| 34 |
|
34 |
|
| 35 |
protected void assertCreateRequirements(IProjectDescription description) throws CoreException { |
35 |
protected void assertCreateRequirements(IProjectDescription description) throws CoreException { |
| 36 |
checkDoesNotExist(); |
36 |
checkDoesNotExist(); |
| 37 |
checkDescription(this, description, false); |
37 |
checkDescription(this, description, false); |
|
Lines 230-258
Link Here
|
| 230 |
public void create(IProgressMonitor monitor) throws CoreException { |
230 |
public void create(IProgressMonitor monitor) throws CoreException { |
| 231 |
create(null, monitor); |
231 |
create(null, monitor); |
| 232 |
} |
232 |
} |
| 233 |
|
233 |
|
| 234 |
/* (non-Javadoc) |
234 |
/* (non-Javadoc) |
| 235 |
* @see IProject#create(IProjectDescription, IProgressMonitor) |
235 |
* @see IProject#create(IProjectDescription, IProgressMonitor) |
| 236 |
*/ |
236 |
*/ |
| 237 |
public void create(IProjectDescription description, IProgressMonitor monitor) throws CoreException { |
237 |
public void create(IProjectDescription description, IProgressMonitor monitor) throws CoreException { |
| 238 |
create(description, IResource.NONE, monitor); |
238 |
create(description, IResource.NONE, monitor); |
| 239 |
} |
239 |
} |
| 240 |
|
240 |
|
| 241 |
/* (non-Javadoc) |
241 |
/* (non-Javadoc) |
| 242 |
* @see IProject#create(IProjectDescription, IProgressMonitor) |
242 |
* @see IProject#create(IProjectDescription, IProgressMonitor) |
| 243 |
*/ |
243 |
*/ |
| 244 |
public void create(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException { |
244 |
public void create(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException { |
| 245 |
monitor = Policy.monitorFor(monitor); |
245 |
monitor = Policy.monitorFor(monitor); |
| 246 |
try { |
246 |
try { |
| 247 |
monitor.beginTask(Messages.resources_create, Policy.totalWork); |
247 |
monitor.beginTask(Messages.resources_create, Policy.totalWork); |
| 248 |
checkValidPath(path, PROJECT, false); |
248 |
checkValidPath(path, PROJECT, false); |
| 249 |
final ISchedulingRule rule = workspace.getRuleFactory().createRule(this); |
249 |
final ISchedulingRule rule = workspace.getRuleFactory().createRule(this); |
| 250 |
try { |
250 |
try { |
| 251 |
workspace.prepareOperation(rule, monitor); |
251 |
workspace.prepareOperation(rule, monitor); |
| 252 |
if (description == null) { |
252 |
if (description == null) { |
| 253 |
description = new ProjectDescription(); |
253 |
description = new ProjectDescription(); |
| 254 |
description.setName(getName()); |
254 |
description.setName(getName()); |
| 255 |
} |
255 |
} |
| 256 |
assertCreateRequirements(description); |
256 |
assertCreateRequirements(description); |
| 257 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_CREATE, this)); |
257 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_CREATE, this)); |
| 258 |
workspace.beginOperation(true); |
258 |
workspace.beginOperation(true); |
|
Lines 329-335
Link Here
|
| 329 |
clearHistory(null); |
329 |
clearHistory(null); |
| 330 |
} |
330 |
} |
| 331 |
|
331 |
|
| 332 |
protected void fixupAfterMoveSource() throws CoreException { |
332 |
protected void fixupAfterMoveSource() throws CoreException { |
| 333 |
workspace.deleteResource(this); |
333 |
workspace.deleteResource(this); |
| 334 |
// check if we deleted a preferences file |
334 |
// check if we deleted a preferences file |
| 335 |
ProjectPreferences.deleted(this); |
335 |
ProjectPreferences.deleted(this); |
|
Lines 739-745
Link Here
|
| 739 |
public boolean isLinked(int options) { |
739 |
public boolean isLinked(int options) { |
| 740 |
return false;//projects are never linked |
740 |
return false;//projects are never linked |
| 741 |
} |
741 |
} |
| 742 |
|
742 |
|
| 743 |
public boolean isGroup() { |
743 |
public boolean isGroup() { |
| 744 |
return false;// projects are never groups |
744 |
return false;// projects are never groups |
| 745 |
} |
745 |
} |
|
Lines 898-904
Link Here
|
| 898 |
// the M_USED flag is used to indicate the difference between opening a project |
898 |
// the M_USED flag is used to indicate the difference between opening a project |
| 899 |
// for the first time and opening it from a previous close (restoring it from disk) |
899 |
// for the first time and opening it from a previous close (restoring it from disk) |
| 900 |
boolean used = info.isSet(M_USED); |
900 |
boolean used = info.isSet(M_USED); |
| 901 |
boolean minorIssuesDuringRestore = false; |
901 |
boolean minorIssuesDuringRestore = false; |
| 902 |
if (used) { |
902 |
if (used) { |
| 903 |
minorIssuesDuringRestore = workspace.getSaveManager().restore(this, Policy.subMonitorFor(monitor, Policy.opWork * 20 / 100)); |
903 |
minorIssuesDuringRestore = workspace.getSaveManager().restore(this, Policy.subMonitorFor(monitor, Policy.opWork * 20 / 100)); |
| 904 |
} else { |
904 |
} else { |
|
Lines 953-959
Link Here
|
| 953 |
*/ |
953 |
*/ |
| 954 |
public IStatus reconcileLinksAndGroups(ProjectDescription newDescription) { |
954 |
public IStatus reconcileLinksAndGroups(ProjectDescription newDescription) { |
| 955 |
String msg = Messages.links_errorLinkReconcile; |
955 |
String msg = Messages.links_errorLinkReconcile; |
| 956 |
HashMap newGroups = newDescription.getGroups(); |
|
|
| 957 |
HashMap newLinks = newDescription.getLinks(); |
956 |
HashMap newLinks = newDescription.getLinks(); |
| 958 |
MultiStatus status = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IResourceStatus.OPERATION_FAILED, msg, null); |
957 |
MultiStatus status = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IResourceStatus.OPERATION_FAILED, msg, null); |
| 959 |
//walk over old linked resources and remove those that are no longer defined |
958 |
//walk over old linked resources and remove those that are no longer defined |
|
Lines 981-1033
Link Here
|
| 981 |
} |
980 |
} |
| 982 |
} |
981 |
} |
| 983 |
} |
982 |
} |
| 984 |
HashMap oldGroups = oldDescription.getGroups(); |
|
|
| 985 |
if (oldGroups != null) { |
| 986 |
for (Iterator it = oldGroups.values().iterator(); it.hasNext();) { |
| 987 |
GroupDescription oldGroup = (GroupDescription) it.next(); |
| 988 |
Resource oldGroupResource = (Resource) findMember(oldGroup |
| 989 |
.getProjectRelativePath()); |
| 990 |
if (oldGroupResource == null || !oldGroupResource.isGroup()) |
| 991 |
continue; |
| 992 |
GroupDescription newGroup = null; |
| 993 |
if (newGroups != null) |
| 994 |
newGroup = (GroupDescription) newGroups.get(oldGroup |
| 995 |
.getProjectRelativePath()); |
| 996 |
// if the new group is missing then remove old group |
| 997 |
if (newGroup == null) { |
| 998 |
try { |
| 999 |
oldGroupResource.delete(IResource.NONE, null); |
| 1000 |
// refresh the resource, because removing a group |
| 1001 |
// can reveal a previously hidden resource in parent |
| 1002 |
oldGroupResource.refreshLocal( |
| 1003 |
IResource.DEPTH_INFINITE, null); |
| 1004 |
} catch (CoreException e) { |
| 1005 |
status.merge(e.getStatus()); |
| 1006 |
} |
| 1007 |
} |
| 1008 |
} |
| 1009 |
} |
| 1010 |
} |
983 |
} |
| 1011 |
// walk over new links and groups and create if necessary |
984 |
// walk over new links and groups and create if necessary |
| 1012 |
// Recreate them in order of the higher up in the tree hierarchy first, |
985 |
// Recreate them in order of the higher up in the tree hierarchy first, |
| 1013 |
// so we don't have to create intermediate directories that would turn |
986 |
// so we don't have to create intermediate directories that would turn |
| 1014 |
// out |
987 |
// out |
| 1015 |
// to be groups or link folders. |
988 |
// to be groups or link folders. |
| 1016 |
if (newLinks == null && newGroups == null) |
989 |
if (newLinks == null) |
| 1017 |
return status; |
990 |
return status; |
| 1018 |
//sort links to avoid creating nested links before their parents |
991 |
//sort links to avoid creating nested links before their parents |
| 1019 |
TreeSet newLinksAndGroups = new TreeSet(new Comparator() { |
992 |
TreeSet newLinksAndGroups = new TreeSet(new Comparator() { |
| 1020 |
public int compare(Object arg0, Object arg1) { |
993 |
public int compare(Object arg0, Object arg1) { |
| 1021 |
int numberOfSegments0; |
994 |
int numberOfSegments0 = ((LinkDescription) arg0).getProjectRelativePath().segmentCount(); |
| 1022 |
if (arg0 instanceof LinkDescription) |
995 |
int numberOfSegments1 = ((LinkDescription) arg1).getProjectRelativePath().segmentCount(); |
| 1023 |
numberOfSegments0 = ((LinkDescription) arg0).getProjectRelativePath().segmentCount(); |
|
|
| 1024 |
else |
| 1025 |
numberOfSegments0 = ((GroupDescription) arg0).getProjectRelativePath().segmentCount(); |
| 1026 |
int numberOfSegments1; |
| 1027 |
if (arg1 instanceof LinkDescription) |
| 1028 |
numberOfSegments1 = ((LinkDescription) arg1).getProjectRelativePath().segmentCount(); |
| 1029 |
else |
| 1030 |
numberOfSegments1 = ((GroupDescription) arg1).getProjectRelativePath().segmentCount(); |
| 1031 |
if (numberOfSegments0 != numberOfSegments1) |
996 |
if (numberOfSegments0 != numberOfSegments1) |
| 1032 |
return numberOfSegments0 - numberOfSegments1; |
997 |
return numberOfSegments0 - numberOfSegments1; |
| 1033 |
else if (arg0.equals(arg1)) |
998 |
else if (arg0.equals(arg1)) |
|
Lines 1039-1076
Link Here
|
| 1039 |
}); |
1004 |
}); |
| 1040 |
if (newLinks != null) |
1005 |
if (newLinks != null) |
| 1041 |
newLinksAndGroups.addAll(newLinks.values()); |
1006 |
newLinksAndGroups.addAll(newLinks.values()); |
| 1042 |
if (newGroups != null) |
|
|
| 1043 |
newLinksAndGroups.addAll(newGroups.values()); |
| 1044 |
|
1007 |
|
| 1045 |
for (Iterator it = newLinksAndGroups.iterator(); it.hasNext();) { |
1008 |
for (Iterator it = newLinksAndGroups.iterator(); it.hasNext();) { |
| 1046 |
Object description = it.next(); |
1009 |
Object description = it.next(); |
| 1047 |
if (description instanceof LinkDescription) { |
1010 |
LinkDescription newLink = (LinkDescription) description; |
| 1048 |
LinkDescription newLink = (LinkDescription) description; |
1011 |
try { |
| 1049 |
try { |
1012 |
Resource toLink = workspace.newResource(getFullPath().append(newLink.getProjectRelativePath()), newLink.getType()); |
| 1050 |
Resource toLink = workspace.newResource(getFullPath().append(newLink.getProjectRelativePath()), newLink.getType()); |
1013 |
IContainer parent = toLink.getParent(); |
| 1051 |
IContainer parent = toLink.getParent(); |
1014 |
if (parent != null && !parent.exists() && parent.getType() == FOLDER) |
| 1052 |
if (parent != null && !parent.exists() && parent.getType() == FOLDER) |
1015 |
((Folder) parent).ensureExists(Policy.monitorFor(null)); |
| 1053 |
((Folder) parent).ensureExists(Policy.monitorFor(null)); |
1016 |
if (newLink.isGroup()) |
| 1054 |
toLink.createLink(newLink.getLocationURI(), IResource.REPLACE | IResource.ALLOW_MISSING_LOCAL, |
1017 |
((Folder) toLink).createGroup(IResource.REPLACE | IResource.ALLOW_MISSING_LOCAL, null); |
| 1055 |
null); |
1018 |
else |
| 1056 |
} catch (CoreException e) { |
1019 |
toLink.createLink(newLink.getLocationURI(), IResource.REPLACE | IResource.ALLOW_MISSING_LOCAL, null); |
| 1057 |
status.merge(e.getStatus()); |
1020 |
} catch (CoreException e) { |
| 1058 |
} |
1021 |
status.merge(e.getStatus()); |
| 1059 |
} else { |
|
|
| 1060 |
GroupDescription newGroup = (GroupDescription) description; |
| 1061 |
try { |
| 1062 |
Resource toGroup = workspace.newResource(getFullPath() |
| 1063 |
.append(newGroup.getProjectRelativePath()), |
| 1064 |
IResource.FOLDER); |
| 1065 |
IContainer parent = toGroup.getParent(); |
| 1066 |
if (parent != null && !parent.exists() |
| 1067 |
&& parent.getType() == FOLDER) |
| 1068 |
((Folder) parent).ensureExists(Policy.monitorFor(null)); |
| 1069 |
((Folder) toGroup).createGroup(IResource.REPLACE |
| 1070 |
| IResource.ALLOW_MISSING_LOCAL, null); |
| 1071 |
} catch (CoreException e) { |
| 1072 |
status.merge(e.getStatus()); |
| 1073 |
} |
| 1074 |
} |
1022 |
} |
| 1075 |
} |
1023 |
} |
| 1076 |
return status; |
1024 |
return status; |
|
Lines 1090-1096
Link Here
|
| 1090 |
if ((updateFlags & IResource.AVOID_NATURE_CONFIG) != 0) |
1038 |
if ((updateFlags & IResource.AVOID_NATURE_CONFIG) != 0) |
| 1091 |
rule = workspace.getRuleFactory().modifyRule(this); |
1039 |
rule = workspace.getRuleFactory().modifyRule(this); |
| 1092 |
else |
1040 |
else |
| 1093 |
rule = workspace.getRoot(); |
1041 |
rule = workspace.getRoot(); |
| 1094 |
try { |
1042 |
try { |
| 1095 |
//need to use root rule because nature configuration calls third party code |
1043 |
//need to use root rule because nature configuration calls third party code |
| 1096 |
workspace.prepareOperation(rule, monitor); |
1044 |
workspace.prepareOperation(rule, monitor); |