Skip to content

Commit 51c2f06

Browse files
author
Szymon Brandys
committed
bug 296691 - Change new Groups API to Virtual Resource API
1 parent ee5f7c9 commit 51c2f06

File tree

13 files changed

+99
-142
lines changed

13 files changed

+99
-142
lines changed

bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/CopyVisitor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2009 IBM Corporation and others.
2+
* Copyright (c) 2000, 2010 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -72,11 +72,11 @@ protected boolean copy(UnifiedTreeNode node) {
7272

7373
protected boolean copyContents(UnifiedTreeNode node, Resource source, Resource destination) {
7474
try {
75-
if (source.isGroup()) {
76-
((Folder) destination).createGroup(updateFlags & IResource.ALLOW_MISSING_LOCAL, null);
75+
if (source.isVirtual()) {
76+
((Folder) destination).create(IResource.VIRTUAL, true, null);
7777
return true;
7878
}
79-
if ((!isDeep || source.isUnderGroup()) && source.isLinked()) {
79+
if ((!isDeep || source.isUnderVirtual()) && source.isLinked()) {
8080
destination.createLink(source.getRawLocationURI(), updateFlags & IResource.ALLOW_MISSING_LOCAL, null);
8181
return false;
8282
}
@@ -144,8 +144,8 @@ protected Workspace getWorkspace() {
144144
}
145145

146146
protected boolean isSynchronized(UnifiedTreeNode node) {
147-
/* groups are always deemed as being synchronized */
148-
if (node.getResource().isGroup())
147+
/* virtual resources are always deemed as being synchronized */
148+
if (node.getResource().isVirtual())
149149
return true;
150150
/* does the resource exist in workspace and file system? */
151151
if (!node.existsInWorkspace() || !node.existsInFileSystem())

bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/DeleteVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2007 IBM Corporation and others.
2+
* Copyright (c) 2000, 2010 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -105,7 +105,7 @@ protected boolean isAncestorOfResourceToSkip(IResource resource) {
105105
private void recursiveKeepHistory(IHistoryStore store, UnifiedTreeNode node) {
106106
final IResource target = node.getResource();
107107
//we don't delete linked content, so no need to keep history
108-
if (target.isLinked() || target.isGroup() || node.isSymbolicLink())
108+
if (target.isLinked() || target.isVirtual() || node.isSymbolicLink())
109109
return;
110110
if (node.isFolder()) {
111111
monitor.subTask(NLS.bind(Messages.localstore_deleting, target.getFullPath()));

bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileSystemResourceManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ private FileStoreRoot getStoreRoot(IResource target) {
432432
root = info.getFileStoreRoot();
433433
if (root != null && root.isValid())
434434
return root;
435-
if (info.isSet(ICoreConstants.M_GROUP)) {
435+
if (info.isSet(ICoreConstants.M_VIRTUAL)) {
436436
ProjectDescription description = ((Project) target.getProject()).internalGetDescription();
437437
if (description != null) {
438438
setLocation(target, info, description.getGroupLocationURI(target.getProjectRelativePath()));

bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/AliasManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2009 IBM Corporation and others.
2+
* Copyright (c) 2000, 2010 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -363,7 +363,7 @@ private void addToLocationsMap(IProject project) {
363363
}
364364

365365
private void addToLocationsMap(IResource link, IFileStore location) {
366-
if (location != null && !link.isGroup())
366+
if (location != null && !link.isVirtual())
367367
if (locationsMap.add(location, link))
368368
nonDefaultResourceCount++;
369369
}

bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Folder.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2006 IBM Corporation and others.
2+
* Copyright (c) 2000, 2010 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -75,7 +75,12 @@ public IFile changeToFile() throws CoreException {
7575
/* (non-Javadoc)
7676
* @see IFolder#create(int, boolean, IProgressMonitor)
7777
*/
78-
public void create(int updateFlags, boolean local, IProgressMonitor monitor) throws CoreException {
78+
public void create(int updateFlags, boolean local, IProgressMonitor monitor) throws CoreException {
79+
if ((updateFlags & IResource.VIRTUAL) == IResource.VIRTUAL) {
80+
createLink(LinkDescription.GROUP_LOCATION, updateFlags, monitor);
81+
return;
82+
}
83+
7984
final boolean force = (updateFlags & IResource.FORCE) != 0;
8085
monitor = Policy.monitorFor(monitor);
8186
try {
@@ -120,16 +125,6 @@ public void create(boolean force, boolean local, IProgressMonitor monitor) throw
120125
create((force ? IResource.FORCE : IResource.NONE), local, monitor);
121126
}
122127

123-
/*
124-
* (non-Javadoc)
125-
*
126-
* @see org.eclipse.core.resources.IFolder#createGroup(int,
127-
* IProgressMonitor)
128-
*/
129-
public void createGroup(int updateFlags, IProgressMonitor monitor) throws CoreException {
130-
createLink(LinkDescription.GROUP_LOCATION, updateFlags, monitor);
131-
}
132-
133128
/**
134129
* Ensures that this folder exists in the workspace. This is similar in
135130
* concept to mkdirs but it does not work on projects.
@@ -150,8 +145,8 @@ public void ensureExists(IProgressMonitor monitor) throws CoreException {
150145
parent.checkExists(getFlags(info), true);
151146
} else
152147
((Folder) parent).ensureExists(monitor);
153-
if (getType() == FOLDER && isUnderGroup())
154-
createGroup(IResource.FORCE, monitor);
148+
if (getType() == FOLDER && isUnderVirtual())
149+
create(IResource.VIRTUAL | IResource.FORCE, true, monitor);
155150
else
156151
internalCreate(IResource.FORCE, true, monitor);
157152
}

bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ICoreConstants.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2007 IBM Corporation and others.
2+
* Copyright (c) 2000, 2010 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -59,10 +59,10 @@ public interface ICoreConstants {
5959
*/
6060
static final int M_LINK = 0x10000;
6161
/**
62-
* Marks this resource as a group.
62+
* Marks this resource as virtual.
6363
* @since 3.6
6464
*/
65-
static final int M_GROUP = 0x80000;
65+
static final int M_VIRTUAL = 0x80000;
6666
/**
6767
* The file has no content description.
6868
* @since 3.0

bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Project.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2009 IBM Corporation and others.
2+
* Copyright (c) 2000, 2010 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -749,8 +749,8 @@ public boolean isLinked(int options) {
749749
return false;//projects are never linked
750750
}
751751

752-
public boolean isGroup() {
753-
return false;// projects are never groups
752+
public boolean isVirtual() {
753+
return false; // projects are never virtual
754754
}
755755

756756
/* (non-Javadoc)
@@ -1024,7 +1024,7 @@ else if (arg0.equals(arg1))
10241024
((Folder) parent).ensureExists(Policy.monitorFor(null));
10251025
if (!toLink.exists() || !toLink.isLinked()) {
10261026
if (newLink.isGroup())
1027-
((Folder) toLink).createGroup(IResource.REPLACE | IResource.ALLOW_MISSING_LOCAL, null);
1027+
((Folder) toLink).create(IResource.REPLACE | IResource.VIRTUAL, true, null);
10281028
else
10291029
toLink.createLink(newLink.getLocationURI(), IResource.REPLACE | IResource.ALLOW_MISSING_LOCAL, null);
10301030
}

bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Resource.java

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2009 IBM Corporation and others.
2+
* Copyright (c) 2000, 2010 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -238,7 +238,7 @@ public IStatus checkCopyRequirements(IPath destination, int destinationType, int
238238
checkAccessibleAndLocal(DEPTH_INFINITE);
239239

240240
IPath destinationParent = destination.removeLastSegments(1);
241-
checkValidGroupContainer(destinationParent, isLinked(), isGroup());
241+
checkValidGroupContainer(destinationParent, isLinked(), isVirtual());
242242

243243
Resource dest = workspace.newResource(destination, destinationType);
244244
dest.checkDoesNotExist();
@@ -269,7 +269,7 @@ public IStatus checkCopyRequirements(IPath destination, int destinationType, int
269269
throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, getFullPath(), message, null);
270270
}
271271
URI destLocation = dest.getLocationURI();
272-
if (destLocation == null && (dest.isUnderGroup() == false)) {
272+
if (destLocation == null && (dest.isUnderVirtual() == false)) {
273273
message = NLS.bind(Messages.localstore_locationUndefined, dest.getFullPath());
274274
throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, dest.getFullPath(), message, null);
275275
}
@@ -371,7 +371,7 @@ protected IStatus checkMoveRequirements(IPath destination, int destinationType,
371371
checkAccessibleAndLocal(DEPTH_INFINITE);
372372

373373
IPath destinationParent = destination.removeLastSegments(1);
374-
checkValidGroupContainer(destinationParent, isLinked(), isGroup());
374+
checkValidGroupContainer(destinationParent, isLinked(), isVirtual());
375375

376376
Resource dest = workspace.newResource(destination, destinationType);
377377

@@ -406,7 +406,7 @@ protected IStatus checkMoveRequirements(IPath destination, int destinationType,
406406
throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, getFullPath(), message, null);
407407
}
408408
URI destLocation = dest.getLocationURI();
409-
if (destLocation == null && (dest.isUnderGroup() == false)) {
409+
if (destLocation == null && (dest.isUnderVirtual() == false)) {
410410
message = NLS.bind(Messages.localstore_locationUndefined, dest.getFullPath());
411411
throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, dest.getFullPath(), message, null);
412412
}
@@ -444,7 +444,7 @@ public void checkValidGroupContainer(IPath destination, boolean isLink, boolean
444444
String message = Messages.group_invalidParent;
445445
ResourceInfo info = workspace.getResourceInfo(destination, false,
446446
false);
447-
if (info != null && info.isSet(M_GROUP))
447+
if (info != null && info.isSet(M_VIRTUAL))
448448
throw new ResourceException(new ResourceStatus(
449449
IResourceStatus.INVALID_VALUE, null, message));
450450
}
@@ -460,7 +460,7 @@ public void checkValidGroupContainer(IPath destination, boolean isLink, boolean
460460
public void checkValidGroupContainer(Container destination, boolean isLink, boolean isGroup) throws CoreException {
461461
if (!isLink && !isGroup) {
462462
String message = Messages.group_invalidParent;
463-
if (destination.isGroup())
463+
if (destination.isVirtual())
464464
throw new ResourceException(new ResourceStatus(IResourceStatus.INVALID_VALUE, null, message));
465465
}
466466
}
@@ -469,7 +469,7 @@ public IStatus getValidGroupContainer(IPath destination, boolean isLink, boolean
469469
if (!isLink && !isGroup) {
470470
String message = Messages.group_invalidParent;
471471
ResourceInfo info = workspace.getResourceInfo(destination, false, false);
472-
if (info.isSet(M_GROUP))
472+
if (info.isSet(M_VIRTUAL))
473473
return new ResourceStatus(IResourceStatus.INVALID_VALUE, null, message);
474474
}
475475
return Status.OK_STATUS;
@@ -667,7 +667,7 @@ public void createLink(URI localLocation, int updateFlags, IProgressMonitor moni
667667
localLocation = FileUtil.canonicalURI(localLocation);
668668
LinkDescription linkDescription = new LinkDescription(this, localLocation);
669669
if (linkDescription.isGroup())
670-
info.set(M_GROUP);
670+
info.set(M_VIRTUAL);
671671
getLocalManager().link(this, localLocation, fileInfo);
672672
monitor.worked(Policy.opWork * 5 / 100);
673673
//save the location in the project description
@@ -1156,7 +1156,7 @@ private String findVariant(String target, String[] list) {
11561156
protected void fixupAfterMoveSource() throws CoreException {
11571157
ResourceInfo info = getResourceInfo(true, true);
11581158
//if a linked resource is moved, we need to remove the location info from the .project
1159-
if (isLinked() || isGroup()) {
1159+
if (isLinked() || isVirtual()) {
11601160
Project project = (Project) getProject();
11611161
if (project.internalGetDescription().setLinkLocation(getProjectRelativePath(), null))
11621162
project.writeDescription(IResource.NONE);
@@ -1220,7 +1220,7 @@ public FileSystemResourceManager getLocalManager() {
12201220
*/
12211221
public long getLocalTimeStamp() {
12221222
ResourceInfo info = getResourceInfo(false, false);
1223-
return (info == null || isGroup()) ? IResource.NULL_STAMP : info.getLocalSyncInfo();
1223+
return (info == null || isVirtual()) ? IResource.NULL_STAMP : info.getLocalSyncInfo();
12241224
}
12251225

12261226
/* (non-Javadoc)
@@ -1338,7 +1338,7 @@ public URI getRawLocationURI() {
13381338
* @see IResource#getResourceAttributes()
13391339
*/
13401340
public ResourceAttributes getResourceAttributes() {
1341-
if (!isAccessible() || isGroup())
1341+
if (!isAccessible() || isVirtual())
13421342
return null;
13431343
return getLocalManager().attributes(this);
13441344
}
@@ -1526,13 +1526,25 @@ public boolean isLinked(int options) {
15261526
return info != null && info.isSet(M_LINK);
15271527
}
15281528

1529-
/*
1530-
* (non-Javadoc)
1531-
* @see IResource#isGroup()
1529+
/* (non-Javadoc)
1530+
* @see org.eclipse.core.resources.IResource#isVirtual()
15321531
*/
1533-
public boolean isGroup() {
1532+
public boolean isVirtual() {
15341533
ResourceInfo info = getResourceInfo(false, false);
1535-
return info != null && info.isSet(M_GROUP);
1534+
return info != null && info.isSet(M_VIRTUAL);
1535+
}
1536+
1537+
/*
1538+
* @return whether the current resource has a parent that is virtual.
1539+
*/
1540+
public boolean isUnderVirtual() {
1541+
IContainer parent = getParent();
1542+
while (parent != null) {
1543+
if (parent.isVirtual())
1544+
return true;
1545+
parent = parent.getParent();
1546+
}
1547+
return false;
15361548
}
15371549

15381550
/* (non-Javadoc)
@@ -2122,7 +2134,7 @@ private void broadcastPreMoveEvent(final IResource destination, int updateFlags)
21222134
case IResource.FOLDER :
21232135
if (isLinked())
21242136
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags));
2125-
if (isGroup())
2137+
if (isVirtual())
21262138
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_GROUP_MOVE, this, destination, updateFlags));
21272139
break;
21282140
case IResource.PROJECT :
@@ -2288,18 +2300,4 @@ public void setLinkLocation(IPath location, int updateFlags, IProgressMonitor mo
22882300
setLinkLocation(URIUtil.toURI(location.toPortableString()), updateFlags, monitor);
22892301
}
22902302
}
2291-
2292-
/*
2293-
* @return whether the current resource has a parent that is a group.
2294-
*
2295-
*/
2296-
public boolean isUnderGroup() {
2297-
IContainer parent = getParent();
2298-
while (parent != null) {
2299-
if (parent.isGroup())
2300-
return true;
2301-
parent = parent.getParent();
2302-
}
2303-
return false;
2304-
}
23052303
}

bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ResourceTree.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2008 IBM Corporation and others.
2+
* Copyright (c) 2000, 2010 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -981,7 +981,7 @@ public void standardMoveFolder(IFolder source, IFolder destination, int flags, I
981981

982982
//for linked resources, nothing needs to be moved in the file system
983983
boolean isDeep = (flags & IResource.SHALLOW) == 0;
984-
if (!isDeep && (source.isLinked() || source.isGroup())) {
984+
if (!isDeep && (source.isLinked() || source.isVirtual())) {
985985
movedFolderSubtree(source, destination);
986986
return;
987987
}
@@ -1123,7 +1123,7 @@ private void updateTimestamps(IResource root, final boolean isDeep) {
11231123
IResourceVisitor visitor = new IResourceVisitor() {
11241124
public boolean visit(IResource resource) {
11251125
if (resource.isLinked()) {
1126-
if (isDeep && !((Resource) resource).isUnderGroup()) {
1126+
if (isDeep && !((Resource) resource).isUnderVirtual()) {
11271127
//clear the linked resource bit, if any
11281128
ResourceInfo info = ((Resource) resource).getResourceInfo(false, true);
11291129
info.clear(ICoreConstants.M_LINK);

bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2009 IBM Corporation and others.
2+
* Copyright (c) 2000, 2010 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -756,7 +756,7 @@ else if (destination.segmentCount() == 1)
756756
// update link locations in project descriptions
757757
if (source.isLinked()) {
758758
LinkDescription linkDescription;
759-
if (((updateFlags & IResource.SHALLOW) != 0) || ((Resource) source).isUnderGroup()) {
759+
if (((updateFlags & IResource.SHALLOW) != 0) || ((Resource) source).isUnderVirtual()) {
760760
//for shallow move the destination is a linked resource with the same location
761761
newInfo.set(ICoreConstants.M_LINK);
762762
linkDescription = new LinkDescription(destinationResource, source.getLocationURI());
@@ -869,6 +869,8 @@ public ResourceInfo createResource(IResource resource, int updateFlags) throws C
869869
info.set(M_TEAM_PRIVATE_MEMBER);
870870
if ((updateFlags & IResource.HIDDEN) != 0)
871871
info.set(M_HIDDEN);
872+
// if ((updateFlags & IResource.VIRTUAL) != 0)
873+
// info.set(M_VIRTUAL);
872874
return info;
873875
}
874876

0 commit comments

Comments
 (0)