Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 93593 Details for
Bug 215299
add methods to IResource to get all session and persistent properties
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Reviewed patch
215299_20080326.txt (text/plain), 12.88 KB, created by
Szymon Brandys
on 2008-03-26 10:24:12 EDT
(
hide
)
Description:
Reviewed patch
Filename:
MIME Type:
Creator:
Szymon Brandys
Created:
2008-03-26 10:24:12 EDT
Size:
12.88 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.tests.resources >Index: src/org/eclipse/core/tests/resources/IResourceTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IResourceTest.java,v >retrieving revision 1.43 >diff -u -r1.43 IResourceTest.java >--- src/org/eclipse/core/tests/resources/IResourceTest.java 6 Dec 2007 20:38:14 -0000 1.43 >+++ src/org/eclipse/core/tests/resources/IResourceTest.java 26 Mar 2008 14:09:00 -0000 >@@ -1698,6 +1698,84 @@ > project.open(null); > assertEquals(stamp, file.getModificationStamp()); > } >+ >+ /** >+ * Tests IResource#getPersistentProperties and IResource#getSessionProperties >+ */ >+ public void testProperties() throws CoreException { >+ QualifiedName qn1 = new QualifiedName("package", "property1"); >+ QualifiedName qn2 = new QualifiedName("package", "property2"); >+ >+ IProject project = getWorkspace().getRoot().getProject("P1"); >+ IProject project2 = getWorkspace().getRoot().getProject("P2"); >+ project.create(null); >+ project.open(null); >+ project.setPersistentProperty(qn1, "value1"); >+ project.setPersistentProperty(qn2, "value2"); >+ project.setSessionProperty(qn1, "value1"); >+ project.setSessionProperty(qn2, "value2"); >+ >+ assertEquals("value1", project.getPersistentProperty(qn1)); >+ assertEquals("value2", project.getPersistentProperty(qn2)); >+ assertEquals("value1", project.getSessionProperty(qn1)); >+ assertEquals("value2", project.getSessionProperty(qn2)); >+ >+ Map props = project.getPersistentProperties(); >+ assertEquals(2, props.size()); >+ assertEquals("value1",props.get(qn1)); >+ assertEquals("value2",props.get(qn2)); >+ >+ props = project.getSessionProperties(); >+ // Don't check the size, because other plugins (like team) may add >+ // a property depending on if they are present or not >+ assertEquals("value1",props.get(qn1)); >+ assertEquals("value2",props.get(qn2)); >+ >+ project.setPersistentProperty(qn1, null); >+ project.setSessionProperty(qn1, null); >+ >+ props = project.getPersistentProperties(); >+ assertEquals(1, props.size()); >+ assertNull(props.get(qn1)); >+ assertEquals("value2",props.get(qn2)); >+ >+ props = project.getSessionProperties(); >+ assertNull(props.get(qn1)); >+ assertEquals("value2",props.get(qn2)); >+ >+ // Copy >+ project.copy(project2.getFullPath(), true, null); >+ >+ // Persistent properties go with the copy >+ props = project2.getPersistentProperties(); >+ assertEquals(1, props.size()); >+ assertNull(props.get(qn1)); >+ assertEquals("value2",props.get(qn2)); >+ >+ // Session properties don't >+ props = project2.getSessionProperties(); >+ // Don't check size (see above) >+ assertNull(props.get(qn1)); >+ assertNull(props.get(qn2)); >+ >+ >+ // Test persistence >+ project.close(null); >+ project.open(null); >+ >+ // Make sure they are really persistent >+ props = project.getPersistentProperties(); >+ assertEquals(1, props.size()); >+ assertNull(props.get(qn1)); >+ assertEquals("value2",props.get(qn2)); >+ >+ // Make sure they don't persist >+ props = project.getSessionProperties(); >+ // Don't check size (see above) >+ assertNull(props.get(qn1)); >+ assertNull(props.get(qn2)); >+ >+ } > > /** > * Tests IResource.isReadOnly and setReadOnly >#P org.eclipse.core.resources >Index: src/org/eclipse/core/internal/resources/ResourceInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ResourceInfo.java,v >retrieving revision 1.25 >diff -u -r1.25 ResourceInfo.java >--- src/org/eclipse/core/internal/resources/ResourceInfo.java 23 Jan 2007 22:45:37 -0000 1.25 >+++ src/org/eclipse/core/internal/resources/ResourceInfo.java 26 Mar 2008 14:09:16 -0000 >@@ -190,6 +190,20 @@ > } > > /** >+ * Returns a copy of the map of this resource session properties. >+ * An empty map is returned if there are none. >+ */ >+ public Map getSessionProperties() { >+ // thread safety: (Concurrency001) >+ ObjectMap temp = sessionProperties; >+ if (temp == null) >+ temp = new ObjectMap(5); >+ else >+ temp = (ObjectMap) sessionProperties.clone(); >+ return temp; >+ } >+ >+ /** > * Returns the value of the identified session property > */ > public Object getSessionProperty(QualifiedName name) { >Index: src/org/eclipse/core/internal/resources/Resource.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Resource.java,v >retrieving revision 1.158 >diff -u -r1.158 Resource.java >--- src/org/eclipse/core/internal/resources/Resource.java 13 Mar 2008 20:14:40 -0000 1.158 >+++ src/org/eclipse/core/internal/resources/Resource.java 26 Mar 2008 14:09:16 -0000 >@@ -192,6 +192,14 @@ > checkExists(flags, true); > } > >+ private ResourceInfo checkAccessibleAndLocal(int depth) throws CoreException { >+ ResourceInfo info = getResourceInfo(false, false); >+ int flags = getFlags(info); >+ checkAccessible(flags); >+ checkLocal(flags, depth); >+ return info; >+ } >+ > /** > * This method reports errors in two different ways. It can throw a > * CoreException or return a status. CoreExceptions are used according to the >@@ -218,11 +226,9 @@ > } > checkValidPath(destination, destinationType, false); > >- ResourceInfo info = getResourceInfo(false, false); >- int flags = getFlags(info); >- checkAccessible(flags); >- checkLocal(flags, DEPTH_INFINITE); >- >+ ResourceInfo info; >+ checkAccessibleAndLocal(DEPTH_INFINITE); >+ > Resource dest = workspace.newResource(destination, destinationType); > dest.checkDoesNotExist(); > >@@ -350,10 +356,8 @@ > } > checkValidPath(destination, destinationType, false); > >- ResourceInfo info = getResourceInfo(false, false); >- int flags = getFlags(info); >- checkAccessible(flags); >- checkLocal(flags, DEPTH_INFINITE); >+ ResourceInfo info; >+ checkAccessibleAndLocal(DEPTH_INFINITE); > > Resource dest = workspace.newResource(destination, destinationType); > >@@ -1032,14 +1036,19 @@ > * @see IResource#getPersistentProperty(QualifiedName) > */ > public String getPersistentProperty(QualifiedName key) throws CoreException { >- ResourceInfo info = getResourceInfo(false, false); >- int flags = getFlags(info); >- checkAccessible(flags); >- checkLocal(flags, DEPTH_ZERO); >+ checkAccessibleAndLocal(DEPTH_ZERO); > return getPropertyManager().getProperty(this, key); > } > > /* (non-Javadoc) >+ * @see IResource#getPersistentProperties() >+ */ >+ public Map getPersistentProperties() throws CoreException { >+ checkAccessibleAndLocal(DEPTH_ZERO); >+ return getPropertyManager().getProperties(this); >+ } >+ >+ /* (non-Javadoc) > * @see IResource#getProject() > */ > public IProject getProject() { >@@ -1097,13 +1106,18 @@ > * @see IResource#getSessionProperty(QualifiedName) > */ > public Object getSessionProperty(QualifiedName key) throws CoreException { >- ResourceInfo info = getResourceInfo(false, false); >- int flags = getFlags(info); >- checkAccessible(flags); >- checkLocal(flags, DEPTH_ZERO); >+ ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO); > return info.getSessionProperty(key); > } > >+ /* (non-Javadoc) >+ * @see IResource#getSessionProperties() >+ */ >+ public Map getSessionProperties() throws CoreException { >+ ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO); >+ return info.getSessionProperties(); >+ } >+ > public IFileStore getStore() { > return getLocalManager().getStore(this); > } >@@ -1497,10 +1511,7 @@ > throw new IllegalArgumentException("Illegal value: " + value); //$NON-NLS-1$ > // fetch the info but don't bother making it mutable even though we are going > // to modify it. It really doesn't matter as the change we are doing does not show up in deltas. >- ResourceInfo info = getResourceInfo(false, false); >- int flags = getFlags(info); >- checkAccessible(flags); >- checkLocal(flags, DEPTH_ZERO); >+ ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO); > info.setModificationStamp(value); > } > >@@ -1571,10 +1582,7 @@ > throw new IllegalArgumentException("Illegal value: " + value); //$NON-NLS-1$ > // fetch the info but don't bother making it mutable even though we are going > // to modify it. It really doesn't matter as the change we are doing does not show up in deltas. >- ResourceInfo info = getResourceInfo(false, false); >- int flags = getFlags(info); >- checkAccessible(flags); >- checkLocal(flags, DEPTH_ZERO); >+ ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO); > return getLocalManager().setLocalTimeStamp(this, info, value); > } > >@@ -1582,10 +1590,7 @@ > * @see IResource#setPersistentProperty(QualifiedName, String) > */ > public void setPersistentProperty(QualifiedName key, String value) throws CoreException { >- ResourceInfo info = getResourceInfo(false, false); >- int flags = getFlags(info); >- checkAccessible(flags); >- checkLocal(flags, DEPTH_ZERO); >+ checkAccessibleAndLocal(DEPTH_ZERO); > getPropertyManager().setProperty(this, key, value); > } > >@@ -1609,10 +1614,7 @@ > * @see org.eclipse.core.resources.IResource#setResourceAttributes(org.eclipse.core.resources.ResourceAttributes) > */ > public void setResourceAttributes(ResourceAttributes attributes) throws CoreException { >- ResourceInfo info = getResourceInfo(false, false); >- int flags = getFlags(info); >- checkAccessible(flags); >- checkLocal(flags, DEPTH_ZERO); >+ checkAccessibleAndLocal(DEPTH_ZERO); > getLocalManager().setResourceAttributes(this, attributes); > } > >@@ -1623,10 +1625,7 @@ > // fetch the info but don't bother making it mutable even though we are going > // to modify it. We don't know whether or not the tree is open and it really doesn't > // matter as the change we are doing does not show up in deltas. >- ResourceInfo info = getResourceInfo(false, false); >- int flags = getFlags(info); >- checkAccessible(flags); >- checkLocal(flags, DEPTH_ZERO); >+ ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO); > info.setSessionProperty(key, value); > } > >@@ -1676,10 +1675,7 @@ > final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(this); > try { > workspace.prepareOperation(rule, monitor); >- ResourceInfo info = getResourceInfo(false, false); >- int flags = getFlags(info); >- checkAccessible(flags); >- checkLocal(flags, DEPTH_ZERO); >+ ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO); > > workspace.beginOperation(true); > // fake a change by incrementing the content ID >Index: src/org/eclipse/core/resources/IResource.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/resources/IResource.java,v >retrieving revision 1.97 >diff -u -r1.97 IResource.java >--- src/org/eclipse/core/resources/IResource.java 6 Dec 2007 20:38:15 -0000 1.97 >+++ src/org/eclipse/core/resources/IResource.java 26 Mar 2008 14:09:18 -0000 >@@ -12,6 +12,7 @@ > package org.eclipse.core.resources; > > import java.net.URI; >+import java.util.Map; > import org.eclipse.core.runtime.*; > import org.eclipse.core.runtime.jobs.ISchedulingRule; > >@@ -1362,6 +1363,21 @@ > public IContainer getParent(); > > /** >+ * Returns a copy of the map of this resource persistent properties. >+ * Returns an empty map if there are none. >+ * >+ * @return the map containing the persistent properties where the key is >+ * the qualified name of the property and the value is the string value of the property. >+ * @exception CoreException if this method fails. Reasons include: >+ * <ul> >+ * <li> This resource does not exist.</li> >+ * <li> This resource is not local.</li> >+ * <li> This resource is a project that is not open.</li> >+ * </ul> >+ */ >+ public Map getPersistentProperties() throws CoreException; >+ >+ /** > * Returns the value of the persistent property of this resource identified > * by the given key, or <code>null</code> if this resource has no such property. > * >@@ -1502,6 +1518,21 @@ > public ResourceAttributes getResourceAttributes(); > > /** >+ * Returns a copy of the map of this resource session properties. >+ * Returns an empty map if there are none. >+ * >+ * @return the map containing the session properties where the key is >+ * the qualified name of the property and the value is the value of the property. >+ * @exception CoreException if this method fails. Reasons include: >+ * <ul> >+ * <li> This resource does not exist.</li> >+ * <li> This resource is not local.</li> >+ * <li> This resource is a project that is not open.</li> >+ * </ul> >+ */ >+ public Map getSessionProperties() throws CoreException; >+ >+ /** > * Returns the value of the session property of this resource identified > * by the given key, or <code>null</code> if this resource has no such property. > *
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 215299
:
88441
|
93593
|
93609