Bug 313675 - [sfs] Unification of SFS Resource and Properties Views and migration to CNF: 2nd round - improvements and related bugfixes
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticFileStore.java b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticFileStore.java index b199e9c..a9380c5 100644 --- a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticFileStore.java +++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticFileStore.java
@@ -214,6 +214,28 @@ return actProvider; } + public String getEffectiveContentProviderID() throws CoreException { + try { + this.fs.lockForWrite(); + + if (this.getContentProviderID() != null) { + return this.getContentProviderID(); + } + + ContentProviderData effectiveProviderData = getEffectiveContentProviderInternal(); + + if (effectiveProviderData.provider instanceof ISemanticContentProviderFederation2) { + IPath thisPath = this.getPath(); + + return findFederatedContentProvider(thisPath, this.fs, this.node, effectiveProviderData).providerID; + } + + return effectiveProviderData.providerID; + } finally { + this.fs.unlockForWrite(); + } + } + public ISemanticContentProvider getEffectiveContentProvider() throws CoreException { try { this.fs.lockForWrite(); @@ -222,39 +244,39 @@ return this.provider; } - ISemanticContentProvider effectiveProvider = getEffectiveContentProviderInternal(); + ContentProviderData effectiveProviderData = getEffectiveContentProviderInternal(); - if (effectiveProvider instanceof ISemanticContentProviderFederation2) { + if (effectiveProviderData.provider instanceof ISemanticContentProviderFederation2) { IPath thisPath = this.getPath(); - return findFederatedContentProvider(thisPath, this.fs, this.node, effectiveProvider); + return findFederatedContentProvider(thisPath, this.fs, this.node, effectiveProviderData).provider; } - return effectiveProvider; + return effectiveProviderData.provider; } finally { this.fs.unlockForWrite(); } } - private static ISemanticContentProvider findFederatedContentProvider(IPath path, SemanticFileSystem fs, ResourceTreeNode node, - ISemanticContentProvider parentProvider) throws CoreException { + private static ContentProviderData findFederatedContentProvider(IPath path, SemanticFileSystem fs, ResourceTreeNode node, + ContentProviderData parentProviderData) throws CoreException { - int relativePathLength = path.segmentCount() - parentProvider.getRootStore().getPath().segmentCount(); + int relativePathLength = path.segmentCount() - parentProviderData.provider.getRootStore().getPath().segmentCount(); if (relativePathLength > 0) { - ISemanticContentProviderFederation2 federatingProvider = (ISemanticContentProviderFederation2) parentProvider; + ISemanticContentProviderFederation2 federatingProvider = (ISemanticContentProviderFederation2) parentProviderData.provider; FederatedProviderInfo info = federatingProvider.getFederatedProviderInfoForPath(path); if (info != null) { if (info.contentProviderID == null) { throw new SemanticResourceException(SemanticResourceStatusCode.FEDERATION_EMPTY_FEDERATED_PROVIDER_ID, path, NLS.bind( - Messages.SemanticFileStore_FederatingContentProviderReturnedNull_XMSG, parentProvider.getClass().getName(), + Messages.SemanticFileStore_FederatingContentProviderReturnedNull_XMSG, federatingProvider.getClass().getName(), path.toString())); } if (info.rootNodePosition <= 0 || info.rootNodePosition > relativePathLength) { throw new SemanticResourceException(SemanticResourceStatusCode.FEDERATION_INVALID_ROOT_NODE_POSITION, path, NLS.bind( - Messages.SemanticFileStore_FederatingContentProviderReturnedInvalidRootNodePosition_XMSG, parentProvider + Messages.SemanticFileStore_FederatingContentProviderReturnedInvalidRootNodePosition_XMSG, federatingProvider .getClass().getName(), path.toString())); } @@ -275,16 +297,27 @@ ISemanticContentProvider nestedProvider = initProvider(info.contentProviderID, fs.getStore(parent)); + ContentProviderData nestedProviderData = new ContentProviderData(nestedProvider, info.contentProviderID); if (nestedProvider instanceof ISemanticContentProviderFederation2) { - return findFederatedContentProvider(path, fs, node, nestedProvider); + return findFederatedContentProvider(path, fs, node, nestedProviderData); } - return nestedProvider; + return nestedProviderData; } } - return parentProvider; + return parentProviderData; } - private ISemanticContentProvider getEffectiveContentProviderInternal() throws CoreException { + private static class ContentProviderData { + ContentProviderData(ISemanticContentProvider provider, String providerID) { + this.provider = provider; + this.providerID = providerID; + } + + ISemanticContentProvider provider; + String providerID; + } + + private ContentProviderData getEffectiveContentProviderInternal() throws CoreException { ISemanticFileStore parentStore; String parentContentProviderId = SemanticFileStore.DEFAULT_CONTENT_PROVIDER_ID; ResourceTreeNode parent = null; @@ -301,7 +334,7 @@ SfsTraceLocation.getTrace().traceExit(SfsTraceLocation.CORE_VERBOSE.getLocation(), contentProviderID); } - return this.provider; + return new ContentProviderData(this.provider, contentProviderID); } if (this.node.getDynamicContentProviderID() != null) { @@ -313,7 +346,7 @@ SfsTraceLocation.getTrace().traceExit(SfsTraceLocation.CORE_VERBOSE.getLocation(), contentProviderID); } - return this.provider; + return new ContentProviderData(this.provider, contentProviderID); } if (!this.node.isExists()) { @@ -363,7 +396,7 @@ SfsTraceLocation.getTrace().traceExit(SfsTraceLocation.CORE_VERBOSE.getLocation(), parentContentProviderId); } - return parentProvider; + return new ContentProviderData(parentProvider, parentContentProviderId); } // walk up to find a contentProviderID @@ -373,7 +406,7 @@ // this is a root store with default content provider ISemanticContentProvider parentProvider = initProvider(parentContentProviderId, this); - return parentProvider; + return new ContentProviderData(parentProvider, parentContentProviderId); } ResourceTreeNode oldParent = this.node; @@ -404,7 +437,7 @@ SfsTraceLocation.getTrace().traceExit(SfsTraceLocation.CORE_VERBOSE.getLocation(), parentContentProviderId); } - return parentProvider; + return new ContentProviderData(parentProvider, parentContentProviderId); } @Override
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/messages.properties b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/messages.properties index ebc933d..e8cc905 100644 --- a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/messages.properties +++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/messages.properties
@@ -53,10 +53,10 @@ SemanticFileSystem_SFSInitError_XMSG=Semantic File System Initialization Error SemanticFileSystem_SFSUpdateError_XMSG=Error when updating Sematnic File System metadata SemanticFileSystemCore_TemplateIdNotFound_XMSG=No template with id {0} -SemanticProperties_StoreNotAccessible_XMSG=The Semantic File Store is not accessible +SemanticProperties_StoreNotAccessible_XMSG=The Semantic file store doesn't exist and can not be accessed SemanticResourceAdapterImpl_CalledOutsideRule_XMSG=Method called outside of scheduling rule SemanticResourceAdapterImpl_JobNoRule_XMSG=Job has no scheduling rule -SemanticResourceAdapterImpl_NoSemanticStore_XMSG=The FileStore for the Semantic Resource at location {0} is not a Semantic File Store +SemanticResourceAdapterImpl_NoSemanticStore_XMSG=The file store for the Semantic resource at location {0} is not a Semantic file store SemanticResourceAdapterImpl_NullFile_XMSG=A "null" file store was encountered: check initialization of the Semantic File System SemanticResourceAdapterImpl_OperationNotCoveredByRule_XMSG=The current scheduling rule doesn't cover the requested operation SemanticResourceAdapterImpl_ProjectNotAccessible_XMSG=Project {0} is not accessible
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/spi/ISemanticFileStore.java b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/spi/ISemanticFileStore.java index 287de97..1742f61 100644 --- a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/spi/ISemanticFileStore.java +++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/spi/ISemanticFileStore.java
@@ -235,6 +235,14 @@ public String getContentProviderID(); /** + * Returns the ID of the effective content provider. + * + * @return the ID string + * @since 0.3 + */ + public String getEffectiveContentProviderID() throws CoreException; + + /** * Returns the exists flag. * <p> * TODO javadoc
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/Messages.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/Messages.java index 04809cd..fa0f5f5 100644 --- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/Messages.java +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/Messages.java
@@ -53,11 +53,13 @@ public static String PropertiesContentProvider_ExceptionGettingChildren_XMSG; public static String PropertiesContentProvider_ExceptionGettingValue_XMSG; public static String PropertiesContentProvider_ExistsRemotely_XFLD; + public static String PropertiesContentProvider_IsRootNode_XFLD; public static String PropertiesContentProvider_Key_XGRP; public static String PropertiesContentProvider_LastModified_XFLD; public static String PropertiesContentProvider_LocalOnly_XFLD; public static String PropertiesContentProvider_Locked_XFLD; public static String PropertiesContentProvider_LockingSupported_XFLD; + public static String PropertiesContentProvider_PersistentContentProviderID_XFLD; public static String PropertiesContentProvider_PersistentProps_XGRP; public static String PropertiesContentProvider_ProviderID_XFLD; public static String PropertiesContentProvider_ReadOnly_XFLD; @@ -65,6 +67,7 @@ public static String PropertiesContentProvider_ResInfoAttributes_XGRP; public static String PropertiesContentProvider_SessionProps_XGRP; public static String PropertiesContentProvider_Value_XGRP; + public static String PropertySection_RefreshSemanticPropertiesViewJob_XMSG; public static String SemanticFileSystemPreferencePage_Confirm_XGRP; public static String SemanticFileSystemPreferencePage_Confirm_XMSG; public static String SemanticFileSystemPreferencePage_CouldNotDelete_XMSG; @@ -83,6 +86,7 @@ public static String SFSBrowserActionProvider_ForcefulDeleteOfCorruptedContent_XGRP; public static String SFSBrowserActionProvider_OpenInProps_XMIT; public static String SFSBrowserActionProvider_OpenInTextEditor_XMIT; + public static String SFSBrowserActionProvider_RefreshWorkspaceJobName_XMSG; public static String SFSNavigator_AutoRefresh_XMIT; public static String SFSNavigator_Refresh_XBUT; static {
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/PropertiesContentProvider.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/PropertiesContentProvider.java index 4f3c0a2..ef088da 100644 --- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/PropertiesContentProvider.java +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/PropertiesContentProvider.java
@@ -65,6 +65,13 @@ props.add(new KeyValuePair(Messages.PropertiesContentProvider_LastModified_XFLD, df.format(modified))); + try { + props.add(new KeyValuePair(Messages.PropertiesContentProvider_ProviderID_XFLD, nullToSpace(sfs.getEffectiveContentProviderID()))); + } catch (CoreException e) { + props.add(new KeyValuePair(Messages.PropertiesContentProvider_ProviderID_XFLD, + Messages.PropertiesContentProvider_ExceptionGettingValue_XMSG)); + } + String contentProvider; try { contentProvider = nullToSpace(sfs.getEffectiveContentProvider().getClass().getName()); @@ -72,7 +79,20 @@ contentProvider = Messages.PropertiesContentProvider_ExceptionGettingValue_XMSG; } props.add(new KeyValuePair(Messages.PropertiesContentProvider_EffectiveContentProvider_XFLD, contentProvider)); - props.add(new KeyValuePair(Messages.PropertiesContentProvider_ProviderID_XFLD, nullToSpace(sfs.getContentProviderID()))); + + props.add(new KeyValuePair(Messages.PropertiesContentProvider_PersistentContentProviderID_XFLD, nullToSpace(sfs.getContentProviderID()))); + + boolean isContentProviderRootNode = false; + try { + if (sfs.getEffectiveContentProvider().getRootStore().getPath().equals(sfs.getPath())) { + isContentProviderRootNode = true; + } + props.add(new KeyValuePair(Messages.PropertiesContentProvider_IsRootNode_XFLD, String.valueOf(isContentProviderRootNode))); + } catch (Exception e) { + props.add(new KeyValuePair(Messages.PropertiesContentProvider_IsRootNode_XFLD, + Messages.PropertiesContentProvider_ExceptionGettingValue_XMSG)); + } + String remoteUri; try { remoteUri = nullToSpace(sfs.getRemoteURIString());
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSBrowserActionProvider.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSBrowserActionProvider.java index c0a261d..a44dd74 100644 --- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSBrowserActionProvider.java +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSBrowserActionProvider.java
@@ -16,11 +16,16 @@ import org.eclipse.core.filesystem.EFS; import org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeObject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.resources.semantic.ISemanticFileSystem; import org.eclipse.core.resources.semantic.spi.ISemanticFileStore; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.dialogs.IDialogConstants; @@ -117,6 +122,17 @@ if (refresh[0]) { getActionSite().getStructuredViewer().refresh(); + + WorkspaceJob job = new WorkspaceJob(Messages.SFSBrowserActionProvider_RefreshWorkspaceJobName_XMSG) { + @Override + public IStatus runInWorkspace(IProgressMonitor monitor1) throws CoreException { + ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor1); + return Status.OK_STATUS; + } + }; + + job.setRule(ResourcesPlugin.getWorkspace().getRoot()); + job.schedule(); } } }; @@ -185,6 +201,17 @@ if (refresh[0]) { getActionSite().getStructuredViewer().refresh(); + + WorkspaceJob job = new WorkspaceJob(Messages.SFSBrowserActionProvider_RefreshWorkspaceJobName_XMSG) { + @Override + public IStatus runInWorkspace(IProgressMonitor monitor1) throws CoreException { + ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor1); + return Status.OK_STATUS; + } + }; + + job.setRule(ResourcesPlugin.getWorkspace().getRoot()); + job.schedule(); } } };
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/messages.properties b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/messages.properties index b0a1d89..bed3f14 100644 --- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/messages.properties +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/messages.properties
@@ -43,22 +43,25 @@ BrowseSFSDialog_Browser_XGRP=Browse the Semantic File System BrowseSFSDialog_Path_XFLD=Path PropertiesContentProvider_ContentType_XFLD=Content Type -PropertiesContentProvider_EffectiveContentProvider_XFLD=Effective Content Provider +PropertiesContentProvider_EffectiveContentProvider_XFLD=Effective Content Provider Class PropertiesContentProvider_ExceptionGettingChildren_XMSG=<Exception getting the children> PropertiesContentProvider_ExceptionGettingValue_XMSG=<Exception getting the value> PropertiesContentProvider_ExistsRemotely_XFLD=Exists remotely +PropertiesContentProvider_IsRootNode_XFLD=Is Content Provider Root Node PropertiesContentProvider_Key_XGRP=Key PropertiesContentProvider_LastModified_XFLD=Last modified PropertiesContentProvider_LocalOnly_XFLD=Local only PropertiesContentProvider_Locked_XFLD=Locked PropertiesContentProvider_LockingSupported_XFLD=Locking supported +PropertiesContentProvider_PersistentContentProviderID_XFLD=Persistent Content Provider ID PropertiesContentProvider_PersistentProps_XGRP=Persistent Properties -PropertiesContentProvider_ProviderID_XFLD=Content Provider ID +PropertiesContentProvider_ProviderID_XFLD=Effective Content Provider ID PropertiesContentProvider_ReadOnly_XFLD=Read only PropertiesContentProvider_RemoteUri_XFLD=Remote URI PropertiesContentProvider_ResInfoAttributes_XGRP=Semantic Resource Info Attributes PropertiesContentProvider_SessionProps_XGRP=Session Properties PropertiesContentProvider_Value_XGRP=Value +PropertySection_RefreshSemanticPropertiesViewJob_XMSG=Refresh Semantic Properties View Job SemanticFileSystemPreferencePage_Confirm_XGRP=Confirm SemanticFileSystemPreferencePage_Confirm_XMSG=All data in the Semantic File System will be lost, continue? SemanticFileSystemPreferencePage_CouldNotDelete_XMSG=Could not delete the cache file store {0} @@ -77,5 +80,6 @@ SFSBrowserActionProvider_ForcefulDeleteOfCorruptedContent_XGRP=Forceful Delete of Corrupted Content SFSBrowserActionProvider_OpenInProps_XMIT=Open in Properties View SFSBrowserActionProvider_OpenInTextEditor_XMIT=Open in Text editor +SFSBrowserActionProvider_RefreshWorkspaceJobName_XMSG=Refresh workspace after SFS content removal SFSNavigator_AutoRefresh_XMIT=Auto Refresh SFSNavigator_Refresh_XBUT=Refresh
diff --git a/tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/TestsFederatingProvider2.java b/tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/TestsFederatingProvider2.java index b39f77f..69abc31 100644 --- a/tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/TestsFederatingProvider2.java +++ b/tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/TestsFederatingProvider2.java
@@ -345,32 +345,44 @@ ISemanticFileStore sstore = (ISemanticFileStore) EFS.getStore(sFile.getAdaptedResource().getLocationURI()); ISemanticContentProvider cp = sstore.getEffectiveContentProvider(); Assert.assertEquals("Wrong content provider", FederatedContentProvider.class.getName(), cp.getClass().getName()); + Assert.assertEquals("Wrong content provider ID", FederatedContentProvider.class.getName(), sstore + .getEffectiveContentProviderID()); // root/A/E/X/B sstore = (ISemanticFileStore) EFS.getStore(federatingSFolder.getAdaptedResource().getLocationURI()); cp = sstore.getEffectiveContentProvider(); Assert.assertEquals("Wrong content provider", FederatedContentProvider.class.getName(), cp.getClass().getName()); + Assert.assertEquals("Wrong content provider ID", FederatedContentProvider.class.getName(), sstore + .getEffectiveContentProviderID()); // root/A/E/X sstore = (ISemanticFileStore) sstore.getParent(); cp = sstore.getEffectiveContentProvider(); Assert.assertEquals("Wrong content provider", FederatingContentProvider3.class.getName(), cp.getClass().getName()); + Assert.assertEquals("Wrong content provider ID", FederatingContentProvider3.class.getName(), sstore + .getEffectiveContentProviderID()); // root/A/E sstore = (ISemanticFileStore) sstore.getParent(); cp = sstore.getEffectiveContentProvider(); Assert.assertEquals("Wrong content provider", FederatingContentProvider3.class.getName(), cp.getClass().getName()); + Assert.assertEquals("Wrong content provider ID", FederatingContentProvider3.class.getName(), sstore + .getEffectiveContentProviderID()); // root/A sstore = (ISemanticFileStore) sstore.getParent(); cp = sstore.getEffectiveContentProvider(); // the parent should still have the original one Assert.assertEquals("Wrong content provider", FederatingContentProvider2.class.getName(), cp.getClass().getName()); + Assert.assertEquals("Wrong content provider ID", FederatingContentProvider2.class.getName(), sstore + .getEffectiveContentProviderID()); // root sstore = (ISemanticFileStore) sstore.getParent(); cp = sstore.getEffectiveContentProvider(); Assert.assertEquals("Wrong content provider", FederatingContentProvider2.class.getName(), cp.getClass().getName()); + Assert.assertEquals("Wrong content provider ID", FederatingContentProvider2.class.getName(), sstore + .getEffectiveContentProviderID()); } };