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 88441 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]
Patch for I20071213-1500
215299.patch (text/plain), 12.67 KB, created by
Francis Upton IV
on 2008-01-31 14:26:01 EST
(
hide
)
Description:
Patch for I20071213-1500
Filename:
MIME Type:
Creator:
Francis Upton IV
Created:
2008-01-31 14:26:01 EST
Size:
12.67 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.resources >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.155 >diff -u -r1.155 Resource.java >--- src/org/eclipse/core/internal/resources/Resource.java 6 Dec 2007 20:38:15 -0000 1.155 >+++ src/org/eclipse/core/internal/resources/Resource.java 31 Jan 2008 19:21:27 -0000 >@@ -192,6 +192,14 @@ > checkExists(flags, true); > } > >+ protected 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); > >@@ -1008,14 +1012,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() { >@@ -1073,13 +1082,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); > } >@@ -1471,10 +1485,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); > } > >@@ -1545,10 +1556,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); > } > >@@ -1556,10 +1564,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); > } > >@@ -1583,10 +1588,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); > } > >@@ -1597,10 +1599,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); > } > >@@ -1650,10 +1649,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/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 31 Jan 2008 19:21:28 -0000 >@@ -189,6 +189,13 @@ > return null; > } > >+ /** >+ * Returns the a map of the session properties. >+ */ >+ public Map getSessionProperties() { >+ return sessionProperties; >+ } >+ > /** > * Returns the value of the identified session property > */ >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 31 Jan 2008 19:21:30 -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; > >@@ -270,7 +271,7 @@ > * @since 3.2 > */ > public static final int TEAM_PRIVATE = 0x800; >- >+ > /** > * Update flag constant (bit mask value 0x1000) indicating that a > * resource should be marked as a hidden resource. >@@ -1362,6 +1363,20 @@ > public IContainer getParent(); > > /** >+ * Returns a map of all persistent properties of this resource. >+ * >+ * @return a Map containing the persistent 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 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 +1517,20 @@ > public ResourceAttributes getResourceAttributes(); > > /** >+ * Returns a map of all session properties of this resource. >+ * >+ * @return a 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. > * >@@ -1582,7 +1611,7 @@ > * @since 2.0 > */ > public boolean isDerived(); >- >+ > /** > * Returns whether this resource subtree is marked as derived. Returns > * <code>false</code> if this resource does not exist. >@@ -2504,6 +2533,5 @@ > * @see IResourceDelta#DESCRIPTION > */ > public void touch(IProgressMonitor monitor) throws CoreException; >- >- >+ > } >#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 31 Jan 2008 19:21:32 -0000 >@@ -1698,6 +1698,84 @@ > project.open(null); > assertEquals(stamp, file.getModificationStamp()); > } >+ >+ /** >+ * Test properties. >+ */ >+ 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
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