Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduard Bartsch2010-06-10 16:33:36 +0000
committerEduard Bartsch2010-06-10 16:33:36 +0000
commit875bbb9fab3131b51823c698021f638eaf368b34 (patch)
tree43975fc459261847f665bd93ce377efd9dc61517
parent060994ebe900bf800088d9b8cbbdbf0882dba269 (diff)
downloadorg.eclipse.e4.resources-875bbb9fab3131b51823c698021f638eaf368b34.tar.gz
org.eclipse.e4.resources-875bbb9fab3131b51823c698021f638eaf368b34.tar.xz
org.eclipse.e4.resources-875bbb9fab3131b51823c698021f638eaf368b34.zip
Bug 316462 - [sfs] improve robustness and error handling when content provider cann't be found or created
-rw-r--r--bundles/org.eclipse.core.resources.semantic/plugin.xml7
-rw-r--r--bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ISemanticFileStoreInternal.java2
-rw-r--r--bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticFileStore.java20
-rw-r--r--bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticFileSystemCore.java10
-rw-r--r--bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticResourceAdapterImpl.java7
-rw-r--r--bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/InvalidContentProvider.java137
-rw-r--r--bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/Messages.java1
-rw-r--r--bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/messages.properties1
-rw-r--r--bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/ISemanticFileSystem.java12
-rw-r--r--bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/ISemanticResource.java7
-rw-r--r--bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/spi/ISemanticFileStore.java19
-rw-r--r--bundles/org.eclipse.ui.resources.semantic/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.ui.resources.semantic/plugin.properties4
-rw-r--r--bundles/org.eclipse.ui.resources.semantic/plugin.xml16
-rw-r--r--bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/Messages.java2
-rw-r--r--bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSBrowserActionProvider.java69
-rw-r--r--bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSNavigator.java1
-rw-r--r--bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/ForceRemoveAction.java89
-rw-r--r--bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/Messages.java2
-rw-r--r--bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/ShowSFSBrowserViewAction.java54
-rw-r--r--bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/messages.properties2
-rw-r--r--bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/messages.properties2
-rw-r--r--examples/org.eclipse.ui.resources.semantic.examples/META-INF/MANIFEST.MF3
-rw-r--r--tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/TestsFederatingProvider.java86
-rw-r--r--tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/provider/FederatingContentProvider.java5
25 files changed, 549 insertions, 12 deletions
diff --git a/bundles/org.eclipse.core.resources.semantic/plugin.xml b/bundles/org.eclipse.core.resources.semantic/plugin.xml
index 3e61675..377e5d2 100644
--- a/bundles/org.eclipse.core.resources.semantic/plugin.xml
+++ b/bundles/org.eclipse.core.resources.semantic/plugin.xml
@@ -83,4 +83,11 @@
id="org.eclipse.core.resources.semantic.provider.DefaultContentProvider">
</contentProvider>
</extension>
+ <extension
+ point="org.eclipse.core.resources.semantic.contentProvider">
+ <contentProvider
+ class="org.eclipse.core.internal.resources.semantic.provider.InvalidContentProvider"
+ id="org.eclipse.core.resources.semantic.provider.InvalidContentProvider">
+ </contentProvider>
+ </extension>
</plugin>
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ISemanticFileStoreInternal.java b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ISemanticFileStoreInternal.java
index 786a71e..b43322f 100644
--- a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ISemanticFileStoreInternal.java
+++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ISemanticFileStoreInternal.java
@@ -93,4 +93,6 @@ interface ISemanticFileStoreInternal extends ISemanticProperties {
public void setRemoteURI(URI uri, IProgressMonitor monitor) throws CoreException;
+ public void forceRemoveFromWorkspace(int options, IProgressMonitor monitor) throws CoreException;
+
}
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 2ab61df..4d9c257 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
@@ -35,6 +35,7 @@ import org.eclipse.core.resources.semantic.ISemanticResourceInfo;
import org.eclipse.core.resources.semantic.SemanticResourceException;
import org.eclipse.core.resources.semantic.SemanticResourceStatusCode;
import org.eclipse.core.resources.semantic.SyncDirection;
+import org.eclipse.core.resources.semantic.spi.FileCacheServiceFactory;
import org.eclipse.core.resources.semantic.spi.ISemanticContentProvider;
import org.eclipse.core.resources.semantic.spi.ISemanticContentProviderFederation;
import org.eclipse.core.resources.semantic.spi.ISemanticContentProviderLocal;
@@ -43,6 +44,7 @@ import org.eclipse.core.resources.semantic.spi.ISemanticContentProviderREST;
import org.eclipse.core.resources.semantic.spi.ISemanticContentProviderRemote;
import org.eclipse.core.resources.semantic.spi.ISemanticFileStore;
import org.eclipse.core.resources.semantic.spi.ISemanticSpiResourceInfo;
+import org.eclipse.core.resources.semantic.spi.MemoryCacheServiceFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -898,6 +900,23 @@ public class SemanticFileStore extends SemanticProperties implements ISemanticFi
effectiveProvider.removeResource(this, monitor);
}
+ public void forceRemoveFromWorkspace(int options, IProgressMonitor monitor) throws CoreException {
+ if (SfsTraceLocation.CORE_VERBOSE.isActive()) {
+ SfsTraceLocation.getTrace().traceDumpStack(SfsTraceLocation.CORE_VERBOSE.getLocation());
+ }
+
+ checkAccessible();
+
+ new FileCacheServiceFactory().getCacheService().removeContentRecursive(getPath(), monitor);
+ new MemoryCacheServiceFactory().getCacheService().removeContentRecursive(getPath(), monitor);
+
+ this.remove(monitor);
+ }
+
+ public void forceRemove(int options, IProgressMonitor monitor) throws CoreException {
+ forceRemoveFromWorkspace(options, monitor);
+ }
+
public void synchronizeContentWithRemote(SyncDirection direction, IProgressMonitor monitor) throws CoreException {
if (SfsTraceLocation.CORE_VERBOSE.isActive()) {
SfsTraceLocation.getTrace().traceDumpStack(SfsTraceLocation.CORE_VERBOSE.getLocation());
@@ -1726,4 +1745,5 @@ public class SemanticFileStore extends SemanticProperties implements ISemanticFi
}
return monitor;
}
+
}
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticFileSystemCore.java b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticFileSystemCore.java
index 2d603b6..00cee83 100644
--- a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticFileSystemCore.java
+++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticFileSystemCore.java
@@ -37,6 +37,7 @@ import org.eclipse.osgi.util.NLS;
*/
public class SemanticFileSystemCore implements IRegistryChangeListener {
+ private static final String INVALID_CONTENT_PROVIDER = "org.eclipse.core.resources.semantic.provider.InvalidContentProvider"; //$NON-NLS-1$
private static final String PI_CONTENT_PROVIDER = "contentProvider"; //$NON-NLS-1$
private final static String EMPTY = ""; //$NON-NLS-1$
@@ -102,9 +103,12 @@ public class SemanticFileSystemCore implements IRegistryChangeListener {
IConfigurationElement element = registry.get(contentProviderID);
if (element == null) {
- throw new SemanticResourceException(SemanticResourceStatusCode.UNKNOWN_CONTENT_PROVIDER_ID, new Path(
- SemanticFileSystemCore.EMPTY), NLS.bind(Messages.SemanticFileSystemCore_TemplateIdNotFound_XMSG,
- contentProviderID));
+ element = registry.get(INVALID_CONTENT_PROVIDER);
+ if (element == null) {
+ throw new SemanticResourceException(SemanticResourceStatusCode.UNKNOWN_CONTENT_PROVIDER_ID, new Path(
+ SemanticFileSystemCore.EMPTY), NLS.bind(Messages.SemanticFileSystemCore_TemplateIdNotFound_XMSG,
+ INVALID_CONTENT_PROVIDER));
+ }
}
return element;
}
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticResourceAdapterImpl.java b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticResourceAdapterImpl.java
index e844b2e..a3f3d3b 100644
--- a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticResourceAdapterImpl.java
+++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/SemanticResourceAdapterImpl.java
@@ -216,8 +216,11 @@ public abstract class SemanticResourceAdapterImpl implements ISemanticResource {
ISemanticFileStoreInternal store = getOwnStore();
- store.removeFromWorkspace(monitor);
-
+ if ((options & ISemanticFileSystem.FORCE_REMOVE) != 0) {
+ store.forceRemoveFromWorkspace(options, monitor);
+ } else {
+ store.removeFromWorkspace(monitor);
+ }
refreshLocalIfNeeded(RuleType.DELETE, getRuleForType(RuleType.MODIFY, this.resource), options, monitor);
}
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/InvalidContentProvider.java b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/InvalidContentProvider.java
new file mode 100644
index 0000000..1604a11
--- /dev/null
+++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/InvalidContentProvider.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eduard Bartsch (SAP AG) - initial API and implementation
+ * Mathias Kinzler (SAP AG) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.internal.resources.semantic.provider;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.util.Map;
+
+import org.eclipse.core.internal.resources.semantic.SemanticResourcesPlugin;
+import org.eclipse.core.resources.semantic.SemanticResourceException;
+import org.eclipse.core.resources.semantic.SemanticResourceStatusCode;
+import org.eclipse.core.resources.semantic.SyncDirection;
+import org.eclipse.core.resources.semantic.spi.ContentProvider;
+import org.eclipse.core.resources.semantic.spi.DefaultMinimalSemanticResourceRuleFactory;
+import org.eclipse.core.resources.semantic.spi.ISemanticFileStore;
+import org.eclipse.core.resources.semantic.spi.ISemanticFileStore.ResourceType;
+import org.eclipse.core.resources.semantic.spi.ISemanticResourceRuleFactory;
+import org.eclipse.core.resources.semantic.spi.ISemanticSpiResourceInfo;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * This content provider is instantiated when the proper content provider can
+ * not be created.
+ * <p>
+ * It throws an exception for all methods.
+ *
+ */
+public class InvalidContentProvider extends ContentProvider {
+
+ private CoreException createException(ISemanticFileStore semanticFileStore) {
+ return new SemanticResourceException(SemanticResourceStatusCode.UNKNOWN_CONTENT_PROVIDER_ID, semanticFileStore.getPath(), NLS.bind(
+ Messages.InvalidContentProvider_InvalidContentProviderIDforPath_XMSG, this.getRootStore().getContentProviderID(),
+ semanticFileStore.getPath()));
+ }
+
+ public void revertChanges(ISemanticFileStore semanticFileStore, IProgressMonitor monitor) throws CoreException {
+ throw createException(semanticFileStore);
+ }
+
+ public void addFileFromRemoteByURI(ISemanticFileStore childStore, String name, URI uri, IProgressMonitor monitor) throws CoreException {
+ throw createException(childStore);
+ }
+
+ public void addFolderFromRemoteByURI(ISemanticFileStore childStore, String name, URI uri, IProgressMonitor monitor)
+ throws CoreException {
+ throw createException(childStore);
+ }
+
+ public String getURIString(ISemanticFileStore childStore) throws CoreException {
+ throw createException(childStore);
+ }
+
+ public void setURIString(ISemanticFileStore semanticFileStore, URI uri, IProgressMonitor monitor) throws CoreException {
+ throw createException(semanticFileStore);
+ }
+
+ public ISemanticSpiResourceInfo fetchResourceInfo(ISemanticFileStore semanticFileStore, int options, IProgressMonitor monitor)
+ throws CoreException {
+
+ throw createException(semanticFileStore);
+ }
+
+ public void setReadOnly(ISemanticFileStore childStore, boolean readonly, IProgressMonitor monitor) throws CoreException {
+ throw createException(childStore);
+ }
+
+ public void removeResource(ISemanticFileStore childStore, IProgressMonitor monitor) throws CoreException {
+ throw createException(childStore);
+ }
+
+ public void synchronizeContentWithRemote(ISemanticFileStore semanticFileStore, SyncDirection direction, IProgressMonitor monitor,
+ MultiStatus status) {
+ CoreException e = createException(semanticFileStore);
+
+ status.add(new Status(IStatus.ERROR, SemanticResourcesPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+
+ public IStatus validateEdit(ISemanticFileStore[] stores, Object shell) {
+ CoreException e = createException(stores[0]);
+
+ return new Status(IStatus.ERROR, SemanticResourcesPlugin.PLUGIN_ID, e.getMessage(), e);
+ }
+
+ public IStatus validateSave(ISemanticFileStore childStore) {
+ return validateEdit(new ISemanticFileStore[] {childStore}, null);
+ }
+
+ @Override
+ public ISemanticResourceRuleFactory getRuleFactory() {
+ return new DefaultMinimalSemanticResourceRuleFactory(this.getRootStore());
+ }
+
+ // not supported stuff
+
+ public void addResource(ISemanticFileStore parentStore, String name, ResourceType resourceType, IProgressMonitor monitor)
+ throws CoreException {
+ throw createException(parentStore);
+ }
+
+ public void addResource(ISemanticFileStore parentStore, String name, ResourceType resourceType, String contentProviderID,
+ Map<QualifiedName, String> properties) throws CoreException {
+ throw createException(parentStore);
+ }
+
+ public InputStream openInputStream(ISemanticFileStore semanticFileStore, IProgressMonitor monitor) throws CoreException {
+ throw createException(semanticFileStore);
+ }
+
+ public OutputStream openOutputStream(ISemanticFileStore semanticFileStore, int options, IProgressMonitor monitor) throws CoreException {
+ throw createException(semanticFileStore);
+ }
+
+ public long getResourceTimestamp(ISemanticFileStore semanticFileStore, IProgressMonitor monitor) throws CoreException {
+ throw createException(semanticFileStore);
+ }
+
+ public void setResourceTimestamp(ISemanticFileStore semanticFileStore, long timestamp, IProgressMonitor monitor) throws CoreException {
+ throw createException(semanticFileStore);
+ }
+
+}
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/Messages.java b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/Messages.java
index 98741f5..2575833 100644
--- a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/Messages.java
+++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/Messages.java
@@ -21,6 +21,7 @@ public class Messages extends NLS {
public static String DefaultContentProvider_RemotURINotSet_XMSG;
public static String DefaultContentProvider_UnknownHostError_XMSG;
public static String DefaultContentProvider_ValidateEditResult_XGRP;
+ public static String InvalidContentProvider_InvalidContentProviderIDforPath_XMSG;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/messages.properties b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/messages.properties
index 4c3af87..25ce99b 100644
--- a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/messages.properties
+++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/messages.properties
@@ -15,3 +15,4 @@ DefaultContentProvider_NotSupported_XMSG=Default Content Provider does not suppo
DefaultContentProvider_RemotURINotSet_XMSG=Remote URI is not set for file {0}
DefaultContentProvider_UnknownHostError_XMSG=Unknown host {0}
DefaultContentProvider_ValidateEditResult_XGRP=Validate Edit Result
+InvalidContentProvider_InvalidContentProviderIDforPath_XMSG=Unknown content provider ID {0} for path {1}
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/ISemanticFileSystem.java b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/ISemanticFileSystem.java
index 4ddc410..9e2cf00 100644
--- a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/ISemanticFileSystem.java
+++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/ISemanticFileSystem.java
@@ -51,6 +51,18 @@ public interface ISemanticFileSystem {
public static final int SUPPRESS_REFRESH = 1 << 1;
/**
+ * Option flag constant (value 1&lt;&lt;2) indicating that a resource
+ * hierarchy should be forcefully removed without consulting corresponding
+ * content provider.
+ * <p>
+ * This option should only be used as last resort for cleanup of corrupted
+ * content.
+ *
+ * @since 0.3
+ */
+ public static final int FORCE_REMOVE = 1 << 2;
+
+ /**
* Option flag constant (value 1 &lt;&lt;0) indicating that content should
* be appended to a resource.
*/
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/ISemanticResource.java b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/ISemanticResource.java
index e0282c2..a42f905 100644
--- a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/ISemanticResource.java
+++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/ISemanticResource.java
@@ -195,11 +195,16 @@ public interface ISemanticResource extends ISemanticProperties {
* Unless {@link ISemanticFileSystem#SUPPRESS_REFRESH} is specified in the
* options, the parent of this resource will be refreshed locally.
* <p>
+ * The resources and it's children will be forcefully removed without
+ * consulting corresponding content providers if the option
+ * {@link ISemanticFileSystem#FORCE_REMOVE} is specified.
+ * <p>
* This operation does <em>not</em> take resource state into account (e.g.
* read only flag, lock state...).
*
* @param options
- * only {@link ISemanticFileSystem#SUPPRESS_REFRESH} is supported
+ * only {@link ISemanticFileSystem#SUPPRESS_REFRESH} and
+ * {@link ISemanticFileSystem#FORCE_REMOVE} are supported
* @param monitor
* a progress monitor, or <code>null</code> if progress reporting
* is not desired
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 654585c..287de97 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
@@ -14,6 +14,7 @@ package org.eclipse.core.resources.semantic.spi;
import java.util.Map;
import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.semantic.ISemanticFileSystem;
import org.eclipse.core.resources.semantic.ISemanticProperties;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -192,6 +193,24 @@ public interface ISemanticFileStore extends ISemanticProperties, IFileStore {
public void remove(IProgressMonitor monitor) throws CoreException;
/**
+ * Removes the file store and it's children forcefully without consulting
+ * corresponding content providers.
+ * <p>
+ * Eventually available cached content for the removed resources is also
+ * cleaned up.
+ *
+ * @param options
+ * only {@link ISemanticFileSystem#NONE} is currently supported
+ * @param monitor
+ * a progress monitor, or <code>null</code> if progress reporting
+ * is not desired
+ * @throws CoreException
+ * in case of operation failure
+ * @since 0.3
+ */
+ public void forceRemove(int options, IProgressMonitor monitor) throws CoreException;
+
+ /**
* Returns the "effective" content provider.
* <p>
* If this is a resource which has a content provider ID assigned, this
diff --git a/bundles/org.eclipse.ui.resources.semantic/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.resources.semantic/META-INF/MANIFEST.MF
index d48e252..2e03e6f 100644
--- a/bundles/org.eclipse.ui.resources.semantic/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.ui.resources.semantic/META-INF/MANIFEST.MF
@@ -24,4 +24,5 @@ Export-Package: org.eclipse.core.internal.resources.semantic.ui;x-internal:=true
org.eclipse.core.internal.resources.semantic.ui.actions;x-internal:=true,
org.eclipse.core.internal.resources.semantic.ui.sync;x-internal:=true,
org.eclipse.core.internal.resources.semantic.ui.team;x-internal:=true,
- org.eclipse.core.internal.resources.semantic.ui.util;x-internal:=true
+ org.eclipse.core.internal.resources.semantic.ui.util;x-internal:=true,
+ org.eclipse.core.internal.resources.semantic.ui.wizard;x-internal:=true
diff --git a/bundles/org.eclipse.ui.resources.semantic/plugin.properties b/bundles/org.eclipse.ui.resources.semantic/plugin.properties
index f7a9b95..faf0e44 100644
--- a/bundles/org.eclipse.ui.resources.semantic/plugin.properties
+++ b/bundles/org.eclipse.ui.resources.semantic/plugin.properties
@@ -18,9 +18,11 @@ action.label.Revert_XMEN = Revert to Repository State
action.label.Sync_XMEN = Synchronize with Repository
action.label.Delete_XMEN = Delete in Repository
action.label.Remove_XMEN = Remove from Workspace
+action.label.ForceRemove_XMEN = Remove Corrupted Content from Workspace
action.label.RemoteHist_XMEN = Show Remote History
action.label.Diff_XMEN = Diff against Repository State
action.label.Unshare_XMEN = Unshare
+action.label.ShowInSemanticContentView_XMEN = Show in Semantic Content View
decorator.label_XGRP = Semantic Decorator
decorator.description_XGRP = Semantic Decorator
page.name_XGRP = Semantic Resource
@@ -35,9 +37,11 @@ command.Revert_XGRP = Revert
command.Sync_XGRP = Synchronize
command.Delete_XGRP = Delete
command.Remove_XGRP = Remove From Workspace
+command.ForceRemove_XGRP = Remove Corrupted Content From Workspace
command.History_XGRP = Remote History
command.Diff_XGRP = Diff
command.Unshare_XGRP = Unshare
+command.ShowInSFSBrowserView_XGRP = Show in Semantic Content View
configwizard.name_XGRP = Semantic File System
synchparticipant.name_XGRP = Semantic File System
synchwizard.description_XMSG = Semantic File System
diff --git a/bundles/org.eclipse.ui.resources.semantic/plugin.xml b/bundles/org.eclipse.ui.resources.semantic/plugin.xml
index 60cafab..093181d 100644
--- a/bundles/org.eclipse.ui.resources.semantic/plugin.xml
+++ b/bundles/org.eclipse.ui.resources.semantic/plugin.xml
@@ -84,6 +84,14 @@
menubarPath="team.main/group4">
</action>
<action
+ class="org.eclipse.core.internal.resources.semantic.ui.actions.ShowSFSBrowserViewAction"
+ definitionId="org.eclipse.core.resources.semantic.ui.ShowSFSBrowserViewCommand"
+ enablesFor="1"
+ id="org.eclipse.core.internal.resources.semantic.ui.ShowSFSBrowserViewAction"
+ label="%action.label.ShowInSemanticContentView_XMEN"
+ menubarPath="team.main/group4">
+ </action>
+ <action
class="org.eclipse.core.internal.resources.semantic.ui.actions.DiffAction"
definitionId="org.eclipse.core.resources.semantic.ui.DiffCommand"
enablesFor="1"
@@ -197,10 +205,18 @@
name="%command.Remove_XGRP">
</command>
<command
+ id="org.eclipse.core.resources.semantic.ui.ForceRemoveCommand"
+ name="%command.ForceRemove_XGRP">
+ </command>
+ <command
id="org.eclipse.core.resources.semantic.ui.RemoteHistoryCommand"
name="%command.History_XGRP">
</command>
<command
+ id="org.eclipse.core.resources.semantic.ui.ShowSFSBrowserViewCommand"
+ name="%command.ShowInSFSBrowserView_XGRP">
+ </command>
+ <command
id="org.eclipse.core.resources.semantic.ui.DiffCommand"
name="%command.Diff_XGRP">
</command>
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 a743360..04809cd 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
@@ -79,6 +79,8 @@ public class Messages extends NLS {
public static String SFSBrowserActionProvider_ConfirmDelete_XMSG;
public static String SFSBrowserActionProvider_Delete_XMIT;
public static String SFSBrowserActionProvider_DontAskAgain_XMSG;
+ public static String SFSBrowserActionProvider_DoYouWantToContinue_YMSG;
+ public static String SFSBrowserActionProvider_ForcefulDeleteOfCorruptedContent_XGRP;
public static String SFSBrowserActionProvider_OpenInProps_XMIT;
public static String SFSBrowserActionProvider_OpenInTextEditor_XMIT;
public static String SFSNavigator_AutoRefresh_XMIT;
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 6ec8fd3..c0a261d 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,6 +16,7 @@ import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeObject;
+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;
@@ -122,6 +123,74 @@ public class SFSBrowserActionProvider extends CommonActionProvider {
menu.add(deleteAction);
+ Action forceRemoveAction = new Action(Messages.SFSBrowserActionProvider_ForcefulDeleteOfCorruptedContent_XGRP) {
+
+ @SuppressWarnings("synthetic-access")
+ @Override
+ public void run() {
+
+ final boolean[] refresh = new boolean[] {false};
+
+ boolean dontAskAgain = false;
+
+ for (Object object : objects) {
+
+ final SFSBrowserTreeObject selected = (SFSBrowserTreeObject) object;
+
+ String question = NLS.bind(Messages.SFSBrowserActionProvider_DoYouWantToContinue_YMSG, selected.getPath().toString());
+
+ if (objects.length == 1) {
+ dontAskAgain = MessageDialog.openConfirm(shell, Messages.SFSBrowserActionProvider_ConfirmDelete_XGRP, question);
+ if (!dontAskAgain) {
+ return;
+ }
+ }
+
+ if (!dontAskAgain) {
+ MessageDialogWithToggle toggle = new MessageDialogWithToggle(shell,
+ Messages.SFSBrowserActionProvider_ConfirmDelete_XMSG, null, question, MessageDialog.WARNING, new String[] {
+ IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0,
+ Messages.SFSBrowserActionProvider_DontAskAgain_XMSG, false);
+ int result = toggle.open();
+ dontAskAgain = toggle.getToggleState();
+ if (result != 0) {
+ if (dontAskAgain) {
+ break;
+ }
+ continue;
+ }
+ }
+
+ IProgressService srv = PlatformUI.getWorkbench().getProgressService();
+
+ try {
+ srv.run(true, false, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException {
+ try {
+ ISemanticFileStore store = (ISemanticFileStore) selected.getStore();
+ store.forceRemove(ISemanticFileSystem.NONE, monitor);
+ refresh[0] = true;
+ } catch (CoreException ce) {
+ throw new InvocationTargetException(ce);
+ }
+ }
+ });
+ } catch (InvocationTargetException e1) {
+ SemanticResourcesUIPlugin.handleError(e1.getCause().getMessage(), e1.getCause(), true);
+ } catch (InterruptedException e1) {
+ // ignore
+ }
+ }
+
+ if (refresh[0]) {
+ getActionSite().getStructuredViewer().refresh();
+ }
+ }
+ };
+
+ menu.add(forceRemoveAction);
+
if (objects.length == 1) {
final SFSBrowserTreeObject ob = (SFSBrowserTreeObject) objects[0];
if (!ob.getInfo().isDirectory()) {
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSNavigator.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSNavigator.java
index ebab38b..c6523fa 100644
--- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSNavigator.java
+++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSNavigator.java
@@ -49,6 +49,7 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
*
*/
public class SFSNavigator extends CommonNavigator implements ITabbedPropertySheetPageContributor {
+ public static final String VIEW_ID = "org.eclipse.core.resources.semantic.resourceView"; //$NON-NLS-1$
private static final long AUTOREFREH_MILLI = 5000;
boolean autoRefreshActive = true;
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/ForceRemoveAction.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/ForceRemoveAction.java
new file mode 100644
index 0000000..9415c84
--- /dev/null
+++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/ForceRemoveAction.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eduard Bartsch (SAP AG) - initial API and implementation
+ * Mathias Kinzler (SAP AG) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.internal.resources.semantic.ui.actions;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.semantic.ISemanticResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Force removal from Workspace without consulting content providers
+ *
+ */
+public class ForceRemoveAction extends ActionBase {
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
+
+ super.selectionChanged(action, selection);
+ // all objects must be semantic resources
+ action.setEnabled(checkSelectionSemanticResource());
+ }
+
+ @SuppressWarnings({"rawtypes"})
+ public void run(IAction action) {
+ if (!MessageDialog.openConfirm(getShell(), Messages.ForceRemoveAction_ConfirmForcefulResourceRemoval_XMSG,
+ Messages.ForceRemoveAction_DoYouWantToContinue_YMSG)) {
+ return;
+ }
+
+ IRunnableWithProgress outerRunnable = new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor outerMonitor) throws InvocationTargetException, InterruptedException {
+
+ for (Iterator it = getSelection().iterator(); it.hasNext();) {
+
+ final ISemanticResource resource = (ISemanticResource) it.next();
+
+ outerMonitor.subTask(NLS.bind(Messages.RemoveAction_Removing_XMSG, resource.getAdaptedResource().getName()));
+
+ if (outerMonitor.isCanceled()) {
+ throw new InterruptedException();
+ }
+
+ IWorkspaceRunnable myRunnable = new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) throws CoreException {
+
+ resource.remove(ForceRemoveAction.this.options, monitor);
+ }
+ };
+
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ try {
+ workspace.run(myRunnable, workspace.getRuleFactory().refreshRule(resource.getAdaptedResource()), 0, null);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e, NLS.bind(Messages.RemoveAction_CouldNotRemoveResource_XMSG, resource
+ .getAdaptedResource().getFullPath().toString()));
+ }
+
+ }
+
+ }
+
+ };
+
+ run(outerRunnable);
+
+ }
+
+}
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/Messages.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/Messages.java
index a2fbd70..faac0cd 100644
--- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/Messages.java
+++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/Messages.java
@@ -25,6 +25,8 @@ public class Messages extends NLS {
public static String DiffAction_NoHistory_XMSG;
public static String EditAction_CouldNotOpenForEdit_XMSG;
public static String EditAction_Editing_XMSG;
+ public static String ForceRemoveAction_ConfirmForcefulResourceRemoval_XMSG;
+ public static String ForceRemoveAction_DoYouWantToContinue_YMSG;
public static String LockAction_CouldNotLockResource_XMSG;
public static String LockAction_LockingRes_XMSG;
public static String RemoveAction_ConfirmResourceRemoval_XGRP;
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/ShowSFSBrowserViewAction.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/ShowSFSBrowserViewAction.java
new file mode 100644
index 0000000..35dac9c
--- /dev/null
+++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/ShowSFSBrowserViewAction.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eduard Bartsch (SAP AG) - initial API and implementation
+ * Mathias Kinzler (SAP AG) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.internal.resources.semantic.ui.actions;
+
+import org.eclipse.core.internal.resources.semantic.ui.SFSNavigator;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Show Remote History
+ *
+ */
+public class ShowSFSBrowserViewAction extends ActionBase {
+
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
+
+ super.selectionChanged(action, selection);
+ // only single non-local object can show history
+ action.setEnabled(getSelection().size() == 1 && checkSelectionNonLocalOnly());
+ }
+
+ public void run(IAction action) {
+
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ // ((ISemanticFile) getSelection().getFirstElement()).getAdaptedFile();
+
+ try {
+ SFSNavigator view = (SFSNavigator) page.findView(SFSNavigator.VIEW_ID);
+ if (view == null) {
+ page.showView(SFSNavigator.VIEW_ID);
+ view = (SFSNavigator) page.findView(SFSNavigator.VIEW_ID);
+ }
+
+ page.activate(view);
+
+ // TODO locate the selected file store in viewer
+ } catch (PartInitException e) {
+ // Ignore
+ }
+ }
+}
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/messages.properties b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/messages.properties
index 11a1248..5d350cb 100644
--- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/messages.properties
+++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/actions/messages.properties
@@ -19,6 +19,8 @@ DiffAction_DiffFailedForFile_XMSG=Diff could not be performed for file {0}
DiffAction_NoHistory_XMSG=The content provider does not provider revision history support
EditAction_CouldNotOpenForEdit_XMSG=Resource {0} could not be opened for edit
EditAction_Editing_XMSG=Opening file {0} for editing
+ForceRemoveAction_ConfirmForcefulResourceRemoval_XMSG=Confirm Forceful Resource Removal
+ForceRemoveAction_DoYouWantToContinue_YMSG=You are about to forcefully remove some content in Semantic File System that will happen without execution of any consistency checks.\r\nPlease, execute this command only as last resort to remove corrupted content that can not be removed using normal remove/delete operations.\r\nDo you want to continue?
LockAction_CouldNotLockResource_XMSG=Could not lock resource {0}
LockAction_LockingRes_XMSG=Locking resource {0}
RemoveAction_ConfirmResourceRemoval_XGRP=Confirm Resource Removal
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 0634675..b0a1d89 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
@@ -73,6 +73,8 @@ SFSBrowserActionProvider_ConfirmDelete_XGRP=Confirm delete
SFSBrowserActionProvider_ConfirmDelete_XMSG=Do you want to delete Semantic File Store {0} with all children?
SFSBrowserActionProvider_Delete_XMIT=Delete
SFSBrowserActionProvider_DontAskAgain_XMSG=Don't ask again
+SFSBrowserActionProvider_DoYouWantToContinue_YMSG=You are about to forcefully remove some content in Semantic File System that will happen without execution of any consistency checks.\r\nPlease, execute this command only as last resort to remove corrupted content that can not be removed using normal remove/delete operations.\r\nDo you want to continue?
+SFSBrowserActionProvider_ForcefulDeleteOfCorruptedContent_XGRP=Forceful Delete of Corrupted Content
SFSBrowserActionProvider_OpenInProps_XMIT=Open in Properties View
SFSBrowserActionProvider_OpenInTextEditor_XMIT=Open in Text editor
SFSNavigator_AutoRefresh_XMIT=Auto Refresh
diff --git a/examples/org.eclipse.ui.resources.semantic.examples/META-INF/MANIFEST.MF b/examples/org.eclipse.ui.resources.semantic.examples/META-INF/MANIFEST.MF
index ed61f7a..8d2a2f0 100644
--- a/examples/org.eclipse.ui.resources.semantic.examples/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.ui.resources.semantic.examples/META-INF/MANIFEST.MF
@@ -17,4 +17,5 @@ Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Localization: plugin
Export-Package: org.eclipse.core.resources.semantic.examples,
- org.eclipse.core.resources.semantic.examples.remote
+ org.eclipse.core.resources.semantic.examples.remote,
+ org.eclipse.core.resources.semantic.examples.wizard
diff --git a/tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/TestsFederatingProvider.java b/tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/TestsFederatingProvider.java
index e933da2..f4ee755 100644
--- a/tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/TestsFederatingProvider.java
+++ b/tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/TestsFederatingProvider.java
@@ -22,6 +22,7 @@ import junit.framework.Assert;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.internal.resources.semantic.provider.DefaultContentProvider;
+import org.eclipse.core.internal.resources.semantic.provider.InvalidContentProvider;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -232,9 +233,51 @@ public class TestsFederatingProvider extends TestsContentProviderUtil {
Assert.assertTrue("Resource should exist " + sfile.getAdaptedResource().getLocationURI(), sfile.getAdaptedResource()
.exists());
- // Assert.assertTrue("Resource should exist " +
- // restSFile.getResource().getLocationURI(),
- // restSFile.getResource().exists());
+
+ Assert.assertTrue("Resource should exist " + restSFile.getAdaptedResource().getLocationURI(), restSFile
+ .getAdaptedResource().exists());
+
+ restSFolder.remove(ISemanticFileSystem.FORCE_REMOVE, monitor);
+
+ Assert.assertFalse("Resource should not exist " + restSFile.getAdaptedResource().getLocationURI(), restSFile
+ .getAdaptedResource().exists());
+ }
+ };
+
+ ResourcesPlugin.getWorkspace().run(runnable, new NullProgressMonitor());
+
+ }
+
+ /**
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testFederationAndInvalidContentProviderID() throws Exception {
+
+ final IFolder federatingFolder = testProject.getFolder(new Path("root/A/D"));
+
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) throws CoreException {
+ ISemanticFolder federatingSFolder = (ISemanticFolder) federatingFolder.getAdapter(ISemanticFolder.class);
+
+ try {
+ federatingSFolder.addFile("test", TestsFederatingProvider.this.options, null);
+ Assert.assertTrue("should have failed", false);
+ } catch (CoreException e) {
+ // Ignore
+ }
+
+ ISemanticFileStore sstore = (ISemanticFileStore) EFS.getStore(federatingSFolder.getAdaptedResource().getLocationURI());
+ ISemanticContentProvider cp = sstore.getEffectiveContentProvider();
+ // the folder should have the invalid content provider
+ Assert.assertEquals("Wrong content provider", InvalidContentProvider.class.getName(), cp.getClass().getName());
+
+ sstore = (ISemanticFileStore) sstore.getParent().getParent();
+ cp = sstore.getEffectiveContentProvider();
+ // the parent should still have the original one
+ Assert.assertEquals("Wrong content provider", FederatingContentProvider.class.getName(), cp.getClass().getName());
}
};
@@ -243,4 +286,41 @@ public class TestsFederatingProvider extends TestsContentProviderUtil {
}
+ /**
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testFederationAndInvalidContentProviderID2() throws Exception {
+
+ final IFolder federatingFolder = testProject.getFolder(new Path("root/A/D/C"));
+
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) throws CoreException {
+ ISemanticFolder federatingSFolder = (ISemanticFolder) federatingFolder.getAdapter(ISemanticFolder.class);
+
+ try {
+ federatingSFolder.addFile("test", TestsFederatingProvider.this.options, null);
+ Assert.assertTrue("should have failed", false);
+ } catch (CoreException e) {
+ // Ignore
+ }
+
+ ISemanticFileStore sstore = (ISemanticFileStore) EFS.getStore(federatingSFolder.getAdaptedResource().getLocationURI());
+ ISemanticContentProvider cp = sstore.getEffectiveContentProvider();
+ // the folder should have the invalid content provider
+ Assert.assertEquals("Wrong content provider", InvalidContentProvider.class.getName(), cp.getClass().getName());
+
+ sstore = (ISemanticFileStore) sstore.getParent().getParent();
+ cp = sstore.getEffectiveContentProvider();
+ // the parent should still have the original one
+ Assert.assertEquals("Wrong content provider", FederatingContentProvider.class.getName(), cp.getClass().getName());
+
+ }
+ };
+
+ ResourcesPlugin.getWorkspace().run(runnable, new NullProgressMonitor());
+
+ }
}
diff --git a/tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/provider/FederatingContentProvider.java b/tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/provider/FederatingContentProvider.java
index 792eb24..e0ddcf7 100644
--- a/tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/provider/FederatingContentProvider.java
+++ b/tests/org.eclipse.core.resources.semantic.test/src/org/eclipse/core/resources/semantic/test/provider/FederatingContentProvider.java
@@ -22,9 +22,9 @@ import org.eclipse.core.resources.semantic.SyncDirection;
import org.eclipse.core.resources.semantic.spi.ContentProvider;
import org.eclipse.core.resources.semantic.spi.ISemanticContentProviderFederation;
import org.eclipse.core.resources.semantic.spi.ISemanticFileStore;
+import org.eclipse.core.resources.semantic.spi.ISemanticFileStore.ResourceType;
import org.eclipse.core.resources.semantic.spi.ISemanticSpiResourceInfo;
import org.eclipse.core.resources.semantic.spi.SemanticSpiResourceInfo;
-import org.eclipse.core.resources.semantic.spi.ISemanticFileStore.ResourceType;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -45,6 +45,9 @@ public class FederatingContentProvider extends ContentProvider implements ISeman
pathTemplatMap.put(new Path("A/B").makeRelative(), FederatedContentProvider.class.getName());
// TODO use another content provider
pathTemplatMap.put(new Path("A/C").makeRelative(), "org.eclipse.core.resources.semantic.provider.DefaultContentProvider");
+
+ // invalid ID
+ pathTemplatMap.put(new Path("A/D").makeRelative(), "invalid ID");
}
public String getFederatedProviderIDForPath(IPath path) {

Back to the top