Bug 313152 - [sfs] Implement "New WebDAV Resource" wizard
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 1e98c3e..ed61f7a 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
@@ -1,6 +1,6 @@
 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
-Bundle-Name: Examples how to use Semantic File System (Incubation)
+Bundle-Name: %Bundle-Name
 Bundle-SymbolicName: org.eclipse.ui.resources.semantic.examples;singleton:=true
 Bundle-Version: 0.1.0.qualifier
 Bundle-Activator: org.eclipse.core.resources.semantic.examples.SemanticResourcesPluginExamples
@@ -15,5 +15,6 @@
  org.eclipse.core.resources.semantic.examples;bundle-version="0.1.0"
 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
diff --git a/examples/org.eclipse.ui.resources.semantic.examples/icons/webdav.gif b/examples/org.eclipse.ui.resources.semantic.examples/icons/webdav.gif
new file mode 100644
index 0000000..9cc52af
--- /dev/null
+++ b/examples/org.eclipse.ui.resources.semantic.examples/icons/webdav.gif
Binary files differ
diff --git a/examples/org.eclipse.ui.resources.semantic.examples/plugin.properties b/examples/org.eclipse.ui.resources.semantic.examples/plugin.properties
new file mode 100644
index 0000000..dec6a26
--- /dev/null
+++ b/examples/org.eclipse.ui.resources.semantic.examples/plugin.properties
@@ -0,0 +1,23 @@
+###############################################################################
+#  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
+###############################################################################
+#Properties file for org.eclipse.ui.resources.semantic.examples
+Bundle-Name = Examples how to use Semantic File System (Incubation)
+category.name = Semantic File System
+wizard.name.DEMOProject = Demo Project
+wizard.name.WebDAVResource = WebDAV Resource
+wizard.description.WebDAVResource = Creates a WebDAV resource. Depending on whether the parent folder is a Semantic Resource or not, the WebDAV resource is created as child folder or as link.
+editor.name = RemoteStore Editor
+command.name = Add Resource From Remote
+command.name.0 = Add Demo REST Resource
+command.name.1 = Add a Local File System Resource
+command.name.2 = Create a remote Resource
+command.name.3 = Add a WSDL Resource
\ No newline at end of file
diff --git a/examples/org.eclipse.ui.resources.semantic.examples/plugin.xml b/examples/org.eclipse.ui.resources.semantic.examples/plugin.xml
index 70fb776..36500c7 100644
--- a/examples/org.eclipse.ui.resources.semantic.examples/plugin.xml
+++ b/examples/org.eclipse.ui.resources.semantic.examples/plugin.xml
@@ -18,16 +18,29 @@
          point="org.eclipse.ui.newWizards">
       <category
             id="org.eclipse.core.resources.semantic.examples.category"
-            name="Semantic File System">
+            name="%category.name">
       </category>
       <wizard
             category="org.eclipse.core.resources.semantic.examples.category"
             class="org.eclipse.core.resources.semantic.examples.NewDemoSemanticProjectWizard"
             icon="icons/newprj_wiz.gif"
             id="org.eclipse.core.resources.semantic.examples_demoProjectWizard"
-            name="Demo Project"
+            name="%wizard.name.DEMOProject"
             project="true">
       </wizard>
+      <wizard
+            category="org.eclipse.core.resources.semantic.examples.category"
+            class="org.eclipse.core.resources.semantic.examples.wizard.AddWebDAVResourceWizard"
+            icon="icons/webdav.gif"
+            id="org.eclipse.ui.resources.semantic.examples.wizard1"
+            name="%wizard.name.WebDAVResource">
+         <selection
+               class="org.eclipse.core.resources.IContainer">
+         </selection>
+         <description>
+         %wizard.description.WebDAVResource
+         </description>
+      </wizard>
    </extension>
    <extension
          point="org.eclipse.ui.editors">
@@ -35,7 +48,7 @@
             class="org.eclipse.core.resources.semantic.examples.remote.RemoteStoreEditor"
             extensions="xml"
             id="org.eclipse.core.resources.semantic.examples.editors.RemoteStoreEditor"
-            name="RemoteStore Editor">
+            name="%editor.name">
       </editor>
    </extension>
    <extension
@@ -43,27 +56,27 @@
       <command
             defaultHandler="org.eclipse.core.resources.semantic.examples.HandleAddFromRemote"
             id="org.eclipse.core.resources.semantic.examples_addFromRemote"
-            name="Add Resource From Remote">
+            name="%command.name">
       </command>
       <command
             defaultHandler="org.eclipse.core.resources.semantic.examples.HandleAddRestResource"
             id="org.eclipse.core.resources.semantic.examples_addRESTResource"
-            name="Add Demo REST Resource">
+            name="%command.name.0">
       </command>
       <command
             defaultHandler="org.eclipse.core.resources.semantic.examples.HandleAddFileFromRemote"
             id="org.eclipse.core.resources.semantic.examples_addFileFromRemote"
-            name="Add a Local File System Resource">
+            name="%command.name.1">
       </command>
       <command
             defaultHandler="org.eclipse.core.resources.semantic.examples.HandleCreateRemotely"
             id="org.eclipse.core.resources.semantic.examples_createRemote"
-            name="Create a remote Resource">
+            name="%command.name.2">
       </command>
       <command
             defaultHandler="org.eclipse.core.resources.semantic.examples.HandleAddWsFileFromRemote"
             id="org.eclipse.core.resources.semantic.examples_addWSDLResource"
-            name="Add a WSDL Resource">
+            name="%command.name.3">
       </command>
    </extension>
 
diff --git a/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/Messages.java b/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/Messages.java
index b6f59c9..a1b45d9 100644
--- a/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/Messages.java
+++ b/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/Messages.java
@@ -37,6 +37,39 @@
 	public static String AddFileOrFolderFromRemotePage_ParentFolder_XFLD;
 	public static String AddFileOrFolderFromRemotePage_PathMssing_XMSG;
 	public static String AddFileOrFolderFromRemotePage_Select_XMSG;
+	public static String AddWebDAVResourceCheckURLPage_ChecksIgnoreMessage;
+	public static String AddWebDAVResourceCheckURLPage_FileLabel;
+	public static String AddWebDAVResourceCheckURLPage_FolderLabel;
+	public static String AddWebDAVResourceCheckURLPage_IgnoreButton;
+	public static String AddWebDAVResourceCheckURLPage_InvalidUrlMessage;
+	public static String AddWebDAVResourceCheckURLPage_InvalidURLWithCause;
+	public static String AddWebDAVResourceCheckURLPage_MustBeFileOrFolderMessage;
+	public static String AddWebDAVResourceCheckURLPage_NoURLMessage;
+	public static String AddWebDAVResourceCheckURLPage_PageTitle;
+	public static String AddWebDAVResourceCheckURLPage_RetrieveContentAfterFinish;
+	public static String AddWebDAVResourceCheckURLPage_URLLabel;
+	public static String AddWebDAVResourceNameAndURLPage_BrowseButton;
+	public static String AddWebDAVResourceNameAndURLPage_ChildExistsMessage;
+	public static String AddWebDAVResourceNameAndURLPage_ChooseParentFolderMessage;
+	public static String AddWebDAVResourceNameAndURLPage_ChooseURLMessage;
+	public static String AddWebDAVResourceNameAndURLPage_LinksForbiddenMessage;
+	public static String AddWebDAVResourceNameAndURLPage_MustProviderChildMessage;
+	public static String AddWebDAVResourceNameAndURLPage_NameLabel;
+	public static String AddWebDAVResourceNameAndURLPage_OverwriteChildMessage;
+	public static String AddWebDAVResourceNameAndURLPage_OverwriteLabel;
+	public static String AddWebDAVResourceNameAndURLPage_PageTitle;
+	public static String AddWebDAVResourceNameAndURLPage_ParentIsSemanticMessage;
+	public static String AddWebDAVResourceNameAndURLPage_ParentLabel;
+	public static String AddWebDAVResourceNameAndURLPage_ParentNotSemanticMessage;
+	public static String AddWebDAVResourceNameAndURLPage_SelectFolderMessage;
+	public static String AddWebDAVResourceNameAndURLPage_StoreExistsMessage;
+	public static String AddWebDAVResourceNameAndURLPage_StoreOverwriteMessage;
+	public static String AddWebDAVResourceNameAndURLPage_WebDAVUrlLabel;
+	public static String AddWebDAVResourceWizard_ActionAbortedMessage;
+	public static String AddWebDAVResourceWizard_AlreadyExistsMessaage;
+	public static String AddWebDAVResourceWizard_CreationFailedMessage;
+	public static String AddWebDAVResourceWizard_RetrieveWebDAVContent;
+	public static String AddWebDAVResourceWizard_WizardTitle;
 	public static String CreateDemoProjectPage_Browse_XBUT;
 	public static String CreateDemoProjectPage_CreateProject_XGRP;
 	public static String CreateDemoProjectPage_DirRequired_XMSG;
diff --git a/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/SemanticResourcesPluginExamples.java b/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/SemanticResourcesPluginExamples.java
index 57f4201..3f0d240 100644
--- a/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/SemanticResourcesPluginExamples.java
+++ b/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/SemanticResourcesPluginExamples.java
@@ -11,9 +11,12 @@
  *******************************************************************************/
 package org.eclipse.core.resources.semantic.examples;
 
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.menus.IMenuService;
+import org.eclipse.ui.statushandlers.StatusManager;
 import org.osgi.framework.BundleContext;
 
 /**
@@ -55,4 +58,21 @@
 		return plugin;
 	}
 
+	/**
+	 * Handle an error. The error is logged. If <code>show</code> is
+	 * <code>true</code> the error is shown to the user.
+	 * 
+	 * @param message
+	 *            a localized message
+	 * @param throwable
+	 * @param show
+	 */
+	public static void handleError(String message, Throwable throwable, boolean show) {
+		IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, throwable);
+		int style = StatusManager.LOG;
+		if (show)
+			style |= StatusManager.SHOW;
+		StatusManager.getManager().handle(status, style);
+	}
+
 }
diff --git a/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/messages.properties b/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/messages.properties
index f7fecdb..1b9da09 100644
--- a/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/messages.properties
+++ b/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/messages.properties
@@ -31,6 +31,39 @@
 AddFileOrFolderFromRemotePage_ParentFolder_XFLD=Parent folder
 AddFileOrFolderFromRemotePage_PathMssing_XMSG=Please provide a path
 AddFileOrFolderFromRemotePage_Select_XMSG=Please select a file or folder from the local file system and a child name
+AddWebDAVResourceCheckURLPage_ChecksIgnoreMessage=URL checks will be ignored
+AddWebDAVResourceCheckURLPage_FileLabel=Create as File
+AddWebDAVResourceCheckURLPage_FolderLabel=Create as Folder
+AddWebDAVResourceCheckURLPage_IgnoreButton=Ignore URL Check rsults
+AddWebDAVResourceCheckURLPage_InvalidUrlMessage=Not a valid URL: {0}
+AddWebDAVResourceCheckURLPage_InvalidURLWithCause=Invalid URL {0}, cause: {1}
+AddWebDAVResourceCheckURLPage_MustBeFileOrFolderMessage=Please specify whether a file or a folder is to be created
+AddWebDAVResourceCheckURLPage_NoURLMessage=No URL was provided
+AddWebDAVResourceCheckURLPage_PageTitle=Determine whether a file or a folder is to be created
+AddWebDAVResourceCheckURLPage_RetrieveContentAfterFinish=Retrieve file/folder content after finish
+AddWebDAVResourceCheckURLPage_URLLabel=URL
+AddWebDAVResourceNameAndURLPage_BrowseButton=Browse
+AddWebDAVResourceNameAndURLPage_ChildExistsMessage=Child with name {0} already exists
+AddWebDAVResourceNameAndURLPage_ChooseParentFolderMessage=Please choose a parent folder or project
+AddWebDAVResourceNameAndURLPage_ChooseURLMessage=Please provide a URL
+AddWebDAVResourceNameAndURLPage_LinksForbiddenMessage=Please, choose another parent. Nested links are not supported.
+AddWebDAVResourceNameAndURLPage_MustProviderChildMessage=Must provide a child name
+AddWebDAVResourceNameAndURLPage_NameLabel=Name
+AddWebDAVResourceNameAndURLPage_OverwriteChildMessage=Child with name {0} will be overwritten
+AddWebDAVResourceNameAndURLPage_OverwriteLabel=Overwrite existing child
+AddWebDAVResourceNameAndURLPage_PageTitle=Choose a name and URL for the WebDAV resource
+AddWebDAVResourceNameAndURLPage_ParentIsSemanticMessage=Parent is a Semantic Resource, child will be created as child resource
+AddWebDAVResourceNameAndURLPage_ParentLabel=Parent Folder
+AddWebDAVResourceNameAndURLPage_ParentNotSemanticMessage=Parent is not a Semantic Resource, child will be created as linked resource
+AddWebDAVResourceNameAndURLPage_SelectFolderMessage=Please select a folder
+AddWebDAVResourceNameAndURLPage_StoreExistsMessage=Semantic File Store {0} already exists
+AddWebDAVResourceNameAndURLPage_StoreOverwriteMessage=Semantic File Store {0} will be overwritten
+AddWebDAVResourceNameAndURLPage_WebDAVUrlLabel=WebDAV URL
+AddWebDAVResourceWizard_ActionAbortedMessage=Action aborted
+AddWebDAVResourceWizard_AlreadyExistsMessaage=Resource already exists
+AddWebDAVResourceWizard_CreationFailedMessage=Creation failed
+AddWebDAVResourceWizard_RetrieveWebDAVContent=Retrieve WebDAV content
+AddWebDAVResourceWizard_WizardTitle=Create a WebDAV Resource
 CreateDemoProjectPage_Browse_XBUT=Browse...
 CreateDemoProjectPage_CreateProject_XGRP=Create a Semantic File System Demo Project
 CreateDemoProjectPage_DirRequired_XMSG=Please provide a directory for temporary files
diff --git a/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/wizard/AddWebDAVResourceCheckURLPage.java b/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/wizard/AddWebDAVResourceCheckURLPage.java
new file mode 100644
index 0000000..e9e2f29
--- /dev/null
+++ b/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/wizard/AddWebDAVResourceCheckURLPage.java
@@ -0,0 +1,191 @@
+package org.eclipse.core.resources.semantic.examples.wizard;
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.core.resources.semantic.examples.Messages;
+import org.eclipse.core.resources.semantic.examples.SemanticResourcesPluginExamples;
+import org.eclipse.core.resources.semantic.examples.webdav.WebDAVUtil;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class AddWebDAVResourceCheckURLPage extends WizardPage {
+
+	public AddWebDAVResourceCheckURLPage() {
+		super(AddWebDAVResourceNameAndURLPage.class.getName());
+		setTitle(Messages.AddWebDAVResourceCheckURLPage_PageTitle);
+	}
+
+	public boolean isFolder() {
+		return asFolder.getSelection();
+	}
+
+	public boolean shouldRetrieveContent() {
+		return retrieveContent.getSelection();
+	}
+
+	Text urlText;
+	Button asFolder;
+	Button asFile;
+
+	Button ignoreCheckResults;
+	Button retrieveContent;
+
+	String url;
+
+	public void setUrl(String newUrl) {
+		setPageComplete(false);
+		this.url = newUrl;
+		if (urlText != null)
+			if (this.url == null)
+				urlText.setText(""); //$NON-NLS-1$
+			else
+				urlText.setText(this.url);
+	}
+
+	public void createControl(Composite parent) {
+		Composite main = new Composite(parent, SWT.NONE);
+		main.setLayout(new GridLayout(2, false));
+		GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
+
+		new Label(main, SWT.NONE).setText(Messages.AddWebDAVResourceCheckURLPage_URLLabel);
+		urlText = new Text(main, SWT.BORDER);
+		urlText.setEnabled(false);
+		GridDataFactory.fillDefaults().grab(true, false).applyTo(urlText);
+		if (url != null)
+			urlText.setText(url);
+		asFolder = new Button(main, SWT.RADIO);
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(asFolder);
+		asFolder.setText(Messages.AddWebDAVResourceCheckURLPage_FolderLabel);
+		asFolder.setEnabled(false);
+		asFolder.addSelectionListener(new SelectionAdapter() {
+
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				checkPage();
+			}
+		});
+
+		asFile = new Button(main, SWT.RADIO);
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(asFile);
+		asFile.setText(Messages.AddWebDAVResourceCheckURLPage_FileLabel);
+		asFile.setEnabled(false);
+		asFile.addSelectionListener(new SelectionAdapter() {
+
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				checkPage();
+			}
+		});
+
+		ignoreCheckResults = new Button(main, SWT.CHECK);
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(ignoreCheckResults);
+		ignoreCheckResults.setText(Messages.AddWebDAVResourceCheckURLPage_IgnoreButton);
+		ignoreCheckResults.addSelectionListener(new SelectionAdapter() {
+
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				asFolder.setEnabled(ignoreCheckResults.getSelection());
+				asFile.setEnabled(ignoreCheckResults.getSelection());
+				checkPage();
+			}
+
+		});
+
+		retrieveContent = new Button(main, SWT.CHECK);
+		retrieveContent.setSelection(true);
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(retrieveContent);
+		retrieveContent.setText(Messages.AddWebDAVResourceCheckURLPage_RetrieveContentAfterFinish);
+
+		setPageComplete(false);
+
+		setControl(main);
+	}
+
+	@Override
+	public void setVisible(boolean visible) {
+		super.setVisible(visible);
+		if (visible) {
+			checkPage();
+		}
+	}
+
+	void checkPage() {
+
+		setErrorMessage(null);
+		setMessage(null, IMessageProvider.WARNING);
+
+		try {
+			if (url == null) {
+				setErrorMessage(Messages.AddWebDAVResourceCheckURLPage_NoURLMessage);
+				return;
+			}
+			final URI uri;
+			try {
+				uri = new URI(url);
+			} catch (URISyntaxException e) {
+				setErrorMessage(NLS.bind(Messages.AddWebDAVResourceCheckURLPage_InvalidUrlMessage, url));
+				return;
+			}
+
+			if (!ignoreCheckResults.getSelection()) {
+				asFolder.setSelection(false);
+				asFile.setSelection(false);
+
+				final boolean[] isFolder = new boolean[] {true};
+				final Exception[] exception = new Exception[] {null};
+
+				try {
+					getWizard().getContainer().run(false, false, new IRunnableWithProgress() {
+
+						public void run(IProgressMonitor monitor) {
+							try {
+								isFolder[0] = WebDAVUtil.checkWebDAVURL(uri, monitor);
+							} catch (Exception e) {
+								exception[0] = e;
+							}
+						}
+					});
+				} catch (InvocationTargetException e) {
+					SemanticResourcesPluginExamples.handleError(e.getMessage(), e, true);
+				} catch (InterruptedException e) {
+					SemanticResourcesPluginExamples.handleError(e.getMessage(), e, true);
+				}
+
+				if (exception[0] != null) {
+					setErrorMessage(NLS.bind(Messages.AddWebDAVResourceCheckURLPage_InvalidURLWithCause, url, exception[0].getMessage()));
+					return;
+				}
+				if (isFolder[0]) {
+					asFolder.setSelection(true);
+				} else {
+					asFile.setSelection(true);
+				}
+			}
+
+			if (!asFile.getSelection() && !asFolder.getSelection())
+				setErrorMessage(Messages.AddWebDAVResourceCheckURLPage_MustBeFileOrFolderMessage);
+
+		} finally {
+			boolean errorFound = getErrorMessage() != null;
+			if (!errorFound && ignoreCheckResults.getSelection()) {
+				setMessage(Messages.AddWebDAVResourceCheckURLPage_ChecksIgnoreMessage, IMessageProvider.WARNING);
+			}
+			setPageComplete(getErrorMessage() == null);
+		}
+
+	}
+}
diff --git a/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/wizard/AddWebDAVResourceNameAndURLPage.java b/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/wizard/AddWebDAVResourceNameAndURLPage.java
new file mode 100644
index 0000000..1c0471b
--- /dev/null
+++ b/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/wizard/AddWebDAVResourceNameAndURLPage.java
@@ -0,0 +1,243 @@
+/*******************************************************************************
+ * 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.resources.semantic.examples.wizard;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.semantic.ISemanticFileSystem;
+import org.eclipse.core.resources.semantic.ISemanticResource;
+import org.eclipse.core.resources.semantic.examples.Messages;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionValidator;
+
+/**
+ * Allows the user to enter a parent folder, a name, and a (WebDAV-) URL
+ */
+public class AddWebDAVResourceNameAndURLPage extends WizardPage {
+
+	private IContainer myContainer;
+
+	private Text parentText;
+	private Text childText;
+	private Text urlText;
+	private Button forceOverwrite;
+
+	public AddWebDAVResourceNameAndURLPage() {
+		super(AddWebDAVResourceNameAndURLPage.class.getName());
+		setTitle(Messages.AddWebDAVResourceNameAndURLPage_PageTitle);
+	}
+
+	public void setResourceContainer(IContainer container) {
+		myContainer = container;
+		if (myContainer != null) {
+			if (myContainer.getAdapter(ISemanticResource.class) == null) {
+				setMessage(Messages.AddWebDAVResourceNameAndURLPage_ParentNotSemanticMessage);
+			} else {
+				setMessage(Messages.AddWebDAVResourceNameAndURLPage_ParentIsSemanticMessage);
+			}
+			if (parentText != null)
+				parentText.setText(myContainer.getFullPath().toString());
+		}
+	}
+
+	public IContainer getResourceContainer() {
+		return myContainer;
+	}
+
+	public boolean getForceOverwrite() {
+		return forceOverwrite.getSelection();
+	}
+
+	public void createControl(Composite parent) {
+		Composite main = new Composite(parent, SWT.NONE);
+
+		main.setLayout(new GridLayout(3, false));
+
+		new Label(main, SWT.NONE).setText(Messages.AddWebDAVResourceNameAndURLPage_ParentLabel);
+		parentText = new Text(main, SWT.BORDER);
+		if (myContainer != null)
+			parentText.setText(myContainer.getFullPath().toString());
+		parentText.setEnabled(false);
+		GridDataFactory.fillDefaults().grab(true, false).applyTo(parentText);
+		Button browseButton = new Button(main, SWT.PUSH);
+		browseButton.setText(Messages.AddWebDAVResourceNameAndURLPage_BrowseButton);
+		browseButton.addSelectionListener(new SelectionAdapter() {
+
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+
+				ContainerSelectionDialog csd = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
+						Messages.AddWebDAVResourceNameAndURLPage_SelectFolderMessage);
+				csd.setValidator(new ISelectionValidator() {
+
+					public String isValid(Object selection) {
+						IPath path = (IPath) selection;
+						if (path.segmentCount() > 1) {
+							IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
+							if (folder.isLinked())
+								return Messages.AddWebDAVResourceNameAndURLPage_LinksForbiddenMessage;
+							return null;
+						}
+						IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
+						if (project.isLinked())
+							return Messages.AddWebDAVResourceNameAndURLPage_LinksForbiddenMessage;
+						return null;
+					}
+				});
+
+				if (csd.open() == Window.OK) {
+					Object[] result = csd.getResult();
+					IPath path = (IPath) result[0];
+					if (path.segmentCount() > 1) {
+						IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
+						setResourceContainer(folder);
+					} else {
+						IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
+						setResourceContainer(project);
+					}
+					checkPage();
+				}
+			}
+
+		});
+
+		new Label(main, SWT.NONE).setText(Messages.AddWebDAVResourceNameAndURLPage_NameLabel);
+		childText = new Text(main, SWT.BORDER);
+		GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(childText);
+		childText.addModifyListener(new ModifyListener() {
+
+			public void modifyText(ModifyEvent e) {
+				checkPage();
+			}
+		});
+
+		new Label(main, SWT.NONE).setText(Messages.AddWebDAVResourceNameAndURLPage_WebDAVUrlLabel);
+		urlText = new Text(main, SWT.BORDER);
+		GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(urlText);
+		urlText.addModifyListener(new ModifyListener() {
+
+			public void modifyText(ModifyEvent e) {
+				checkPage();
+			}
+		});
+
+		forceOverwrite = new Button(main, SWT.CHECK);
+		forceOverwrite.setText(Messages.AddWebDAVResourceNameAndURLPage_OverwriteLabel);
+		GridDataFactory.fillDefaults().span(3, 1).applyTo(forceOverwrite);
+		forceOverwrite.addSelectionListener(new SelectionAdapter() {
+
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				checkPage();
+			}
+		});
+
+		// we'll have to enter something
+		setPageComplete(false);
+		setControl(main);
+	}
+
+	protected void checkPage() {
+		setErrorMessage(null);
+		setMessage(null, IMessageProvider.WARNING);
+
+		try {
+			if (myContainer == null) {
+				setErrorMessage(Messages.AddWebDAVResourceNameAndURLPage_ChooseParentFolderMessage);
+				return;
+			}
+			if (childText.getText().length() == 0) {
+				setErrorMessage(Messages.AddWebDAVResourceNameAndURLPage_MustProviderChildMessage);
+				return;
+			}
+
+			if (myContainer.exists(new Path(childText.getText()))) {
+				if (forceOverwrite.getSelection())
+					setMessage(NLS.bind(Messages.AddWebDAVResourceNameAndURLPage_OverwriteChildMessage, childText.getText()),
+							IMessageProvider.WARNING);
+				else
+					setErrorMessage(NLS.bind(Messages.AddWebDAVResourceNameAndURLPage_ChildExistsMessage, childText.getText()));
+				forceOverwrite.setEnabled(true);
+				return;
+			}
+
+			// TODO adjust this once we can create files, too
+			IStatus valid = ResourcesPlugin.getWorkspace().validateName(childText.getText(), IResource.FOLDER);
+			if (!valid.isOK()) {
+				setErrorMessage(valid.getMessage());
+				return;
+			}
+
+			try {
+				String childPath = myContainer.getFullPath().append(childText.getText()).toString();
+				URI sfsUri = new URI(ISemanticFileSystem.SCHEME, null, childPath, null);
+				if (EFS.getStore(sfsUri).fetchInfo().exists()) {
+
+					if (forceOverwrite.getSelection())
+						setMessage(NLS.bind(Messages.AddWebDAVResourceNameAndURLPage_StoreOverwriteMessage, sfsUri.toString()),
+								IMessageProvider.WARNING);
+					else
+						setErrorMessage(NLS.bind(Messages.AddWebDAVResourceNameAndURLPage_StoreExistsMessage, sfsUri.toString()));
+					forceOverwrite.setEnabled(true);
+
+					return;
+				}
+			} catch (URISyntaxException e) {
+				// ignore here
+			} catch (CoreException e) {
+				// ignore here
+			}
+
+			if (urlText.getText().length() == 0) {
+				setErrorMessage(Messages.AddWebDAVResourceNameAndURLPage_ChooseURLMessage);
+				return;
+			}
+
+		} finally {
+			setPageComplete(getErrorMessage() == null);
+		}
+	}
+
+	public String getChildName() {
+		return childText.getText();
+	}
+
+	public String getUrl() {
+		return urlText.getText();
+	}
+}
\ No newline at end of file
diff --git a/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/wizard/AddWebDAVResourceWizard.java b/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/wizard/AddWebDAVResourceWizard.java
new file mode 100644
index 0000000..65ac8dc
--- /dev/null
+++ b/examples/org.eclipse.ui.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/wizard/AddWebDAVResourceWizard.java
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * 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.resources.semantic.examples.wizard;
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.resources.semantic.ISemanticFile;
+import org.eclipse.core.resources.semantic.ISemanticFileSystem;
+import org.eclipse.core.resources.semantic.ISemanticFolder;
+import org.eclipse.core.resources.semantic.ISemanticResource;
+import org.eclipse.core.resources.semantic.SyncDirection;
+import org.eclipse.core.resources.semantic.examples.Messages;
+import org.eclipse.core.resources.semantic.examples.SemanticResourcesPluginExamples;
+import org.eclipse.core.resources.semantic.examples.providers.SampleWebDAVContentProvider;
+import org.eclipse.core.resources.semantic.spi.ISemanticFileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+public class AddWebDAVResourceWizard extends Wizard implements INewWizard {
+
+	AddWebDAVResourceNameAndURLPage nameAndUrlPage = new AddWebDAVResourceNameAndURLPage();
+	AddWebDAVResourceCheckURLPage checkPage = new AddWebDAVResourceCheckURLPage();
+
+	public AddWebDAVResourceWizard() {
+		setWindowTitle(Messages.AddWebDAVResourceWizard_WizardTitle);
+	}
+
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+		Object testObject = selection.getFirstElement();
+		if (testObject instanceof IContainer)
+			nameAndUrlPage.setResourceContainer((IContainer) testObject);
+		else
+			nameAndUrlPage.setResourceContainer(null);
+
+	}
+
+	@Override
+	public void addPages() {
+		addPage(nameAndUrlPage);
+		addPage(checkPage);
+	}
+
+	@Override
+	public IWizardPage getNextPage(IWizardPage page) {
+		if (page == nameAndUrlPage)
+			checkPage.setUrl(nameAndUrlPage.getUrl());
+		return super.getNextPage(page);
+	}
+
+	@Override
+	public boolean performFinish() {
+
+		try {
+
+			getContainer().run(false, false, new IRunnableWithProgress() {
+
+				public void run(IProgressMonitor outerMonitor) throws InvocationTargetException, InterruptedException {
+
+					final ISemanticFolder parentResource = (ISemanticFolder) nameAndUrlPage.getResourceContainer().getAdapter(
+							ISemanticFolder.class);
+					final URI uri;
+					final boolean asFolder = checkPage.isFolder();
+					final boolean shouldRetrieveContent = checkPage.shouldRetrieveContent();
+					final String fileOrFolder;
+					if (asFolder) {
+						fileOrFolder = "folder"; //$NON-NLS-1$
+					} else {
+						fileOrFolder = "file"; //$NON-NLS-1$
+					}
+
+					final boolean forceMode = nameAndUrlPage.getForceOverwrite();
+					try {
+						if (parentResource != null) {
+							uri = new URI(nameAndUrlPage.getUrl());
+						} else {
+							// TODO adjust this in order to create files
+							IPath newPath = nameAndUrlPage.getResourceContainer().getFullPath().append(nameAndUrlPage.getChildName());
+							uri = new URI(ISemanticFileSystem.SCHEME, null, newPath.toString(), "type=" + fileOrFolder //$NON-NLS-1$
+									+ ";create=true;provider=" + SampleWebDAVContentProvider.class.getName() //$NON-NLS-1$
+									+ ";uri=" + nameAndUrlPage.getUrl(), null); //$NON-NLS-1$
+
+						}
+					} catch (URISyntaxException e1) {
+						throw new InvocationTargetException(e1);
+					}
+
+					if (outerMonitor.isCanceled()) {
+						throw new InterruptedException();
+					}
+
+					try {
+						IWorkspaceRunnable wsr = new IWorkspaceRunnable() {
+
+							public void run(IProgressMonitor monitor) throws CoreException {
+								if (parentResource != null) {
+									if (parentResource.hasResource(nameAndUrlPage.getChildName())) {
+										if (!forceMode) {
+											throw new CoreException(new Status(IStatus.ERROR, SemanticResourcesPluginExamples.PLUGIN_ID,
+													Messages.AddWebDAVResourceWizard_AlreadyExistsMessaage));
+										}
+
+										parentResource.getResource(nameAndUrlPage.getChildName()).remove(
+												ISemanticFileSystem.SUPPRESS_REFRESH, monitor);
+									}
+									if (asFolder) {
+										ISemanticFolder sFolder = parentResource.addFolder(nameAndUrlPage.getChildName(),
+												SampleWebDAVContentProvider.class.getName(), null, ISemanticFileSystem.NONE, monitor);
+
+										sFolder.setRemoteURI(uri, ISemanticFileSystem.NONE, monitor);
+									} else {
+										ISemanticFile sFile = parentResource.addFile(nameAndUrlPage.getChildName(),
+												SampleWebDAVContentProvider.class.getName(), null, ISemanticFileSystem.NONE, monitor);
+
+										sFile.setRemoteURI(uri, ISemanticFileSystem.NONE, monitor);
+									}
+
+									if (shouldRetrieveContent) {
+										final ISemanticResource resource = parentResource.getResource(nameAndUrlPage.getChildName());
+
+										if (resource != null) {
+											WorkspaceJob job = new WorkspaceJob(Messages.AddWebDAVResourceWizard_RetrieveWebDAVContent) {
+
+												@Override
+												public IStatus runInWorkspace(IProgressMonitor monitor1) throws CoreException {
+													resource.synchronizeContentWithRemote(SyncDirection.INCOMING, ISemanticFileSystem.NONE,
+															monitor1);
+													return Status.OK_STATUS;
+												}
+											};
+											job.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().refreshRule(
+													resource.getAdaptedResource()));
+											job.schedule();
+										}
+									}
+								} else {
+									IContainer container = nameAndUrlPage.getResourceContainer();
+									IPath childPath = new Path(nameAndUrlPage.getChildName());
+
+									if (container.exists(childPath)) {
+										if (!forceMode) {
+											throw new CoreException(new Status(IStatus.ERROR, SemanticResourcesPluginExamples.PLUGIN_ID,
+													Messages.AddWebDAVResourceWizard_AlreadyExistsMessaage));
+										}
+
+										IResource child = container.findMember(nameAndUrlPage.getChildName());
+										if (child != null && child.isLinked()) {
+											URI oldURI = child.getLocationURI();
+
+											child.delete(true, monitor);
+
+											if (oldURI != null && oldURI.getScheme().equals(ISemanticFileSystem.SCHEME)) {
+												IFileStore store = EFS.getStore(oldURI);
+
+												if (store != null && store instanceof ISemanticFileStore) {
+													store.delete(EFS.NONE, monitor);
+												}
+											}
+										} else {
+											IFolder childFolder = container.getFolder(childPath);
+											if (childFolder.exists()) {
+												childFolder.delete(false, monitor);
+											}
+
+											IFile childFile = container.getFile(childPath);
+											if (childFile.exists()) {
+												childFile.delete(false, monitor);
+											}
+										}
+									}
+
+									final IResource resource;
+
+									if (asFolder) {
+										IFolder folder = container.getFolder(childPath);
+										resource = folder;
+										folder.createLink(uri, 0, monitor);
+									} else {
+										IFile file = container.getFile(childPath);
+										resource = file;
+										file.createLink(uri, IResource.ALLOW_MISSING_LOCAL, monitor);
+									}
+
+									if (shouldRetrieveContent) {
+										final ISemanticResource sResource = (ISemanticResource) resource
+												.getAdapter(ISemanticResource.class);
+
+										if (sResource != null) {
+											WorkspaceJob job = new WorkspaceJob(Messages.AddWebDAVResourceWizard_RetrieveWebDAVContent) {
+
+												@Override
+												public IStatus runInWorkspace(IProgressMonitor monitor1) throws CoreException {
+													sResource.synchronizeContentWithRemote(SyncDirection.INCOMING,
+															ISemanticFileSystem.NONE, monitor1);
+													return Status.OK_STATUS;
+												}
+											};
+											job.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().refreshRule(resource));
+											job.schedule();
+										}
+									}
+								}
+							}
+						};
+						ResourcesPlugin.getWorkspace().run(wsr, outerMonitor);
+					} catch (CoreException e) {
+						throw new InvocationTargetException(e);
+					}
+
+				}
+			});
+		} catch (InvocationTargetException e) {
+			SemanticResourcesPluginExamples.handleError(Messages.AddWebDAVResourceWizard_CreationFailedMessage, e.getCause(), true);
+			return false;
+		} catch (InterruptedException e) {
+			SemanticResourcesPluginExamples.handleError(Messages.AddWebDAVResourceWizard_ActionAbortedMessage, e, true);
+			return false;
+		}
+
+		return true;
+	}
+}