### Eclipse Workspace Patch 1.0
#P jbt-examples-org.jboss.tools.project.examples
Index: src/org/jboss/tools/project/examples/model/ProjectUtil.java
===================================================================
--- src/org/jboss/tools/project/examples/model/ProjectUtil.java	(revision 37733)
+++ src/org/jboss/tools/project/examples/model/ProjectUtil.java	(working copy)
@@ -47,6 +47,7 @@
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Platform;
+import org.eclipse.ecf.filetransfer.IRemoteFileInfo;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.osgi.util.NLS;
 import org.jboss.tools.project.examples.Messages;
@@ -518,14 +519,9 @@
 						return file;
 					}
 				}
-				if (urlModified == 0) {
-					if (file.exists()) {
-						return file;
-					}
-				}
 				if (file.exists()) {
 					long modified = file.lastModified();
-					if (urlModified == modified) {
+					if (urlModified != IRemoteFileInfo.NO_LAST_MODIFIED && urlModified == modified) {
 						return file;
 					}
 				}
Index: src/org/jboss/tools/project/examples/model/IImportProjectExample.java
===================================================================
--- src/org/jboss/tools/project/examples/model/IImportProjectExample.java	(revision 37733)
+++ src/org/jboss/tools/project/examples/model/IImportProjectExample.java	(working copy)
@@ -36,4 +36,6 @@
 	String getType();
 	
 	IPath getLocation();
+	
+	File getExamplesFile(Project project, IProgressMonitor monitor);
 }
Index: src/org/jboss/tools/project/examples/model/AbstractImportProjectExample.java
===================================================================
--- src/org/jboss/tools/project/examples/model/AbstractImportProjectExample.java	(revision 37733)
+++ src/org/jboss/tools/project/examples/model/AbstractImportProjectExample.java	(working copy)
@@ -11,6 +11,10 @@
 
 package org.jboss.tools.project.examples.model;
 
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Path;
@@ -64,4 +68,19 @@
 		return Platform.getLocation();
 	}
 
+    @Override
+    public File getExamplesFile(Project project, IProgressMonitor monitor) {
+        String urlString = project.getUrl();
+        String name = project.getName();
+        URL url = null;
+        try {
+            url = new URL(urlString);
+        } catch (MalformedURLException e) {
+            ProjectExamplesActivator.log(e);
+            return null;
+        }
+        return ProjectUtil.getProjectExamplesFile(
+                url, name, ".zip", monitor); //$NON-NLS-1$
+    }
+
 }
Index: src/org/jboss/tools/project/examples/wizard/NewProjectExamplesJob.java
===================================================================
--- src/org/jboss/tools/project/examples/wizard/NewProjectExamplesJob.java	(revision 37733)
+++ src/org/jboss/tools/project/examples/wizard/NewProjectExamplesJob.java	(working copy)
@@ -1,5 +1,6 @@
 package org.jboss.tools.project.examples.wizard;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -32,15 +33,7 @@
 	public IStatus runInWorkspace(IProgressMonitor monitor)
 			throws CoreException {
 		projects .clear();
-		for (Project selectedProject : selectedProjects) {
-			boolean success = ProjectExamplesActivator.downloadProject(
-					selectedProject, monitor);
-			if (success) {
-				projects.add(selectedProject);
-			} else {
-				return Status.CANCEL_STATUS;
-			}
-		}
+		projects.addAll(selectedProjects);
 		try {
 			setName(Messages.NewProjectExamplesWizard_Importing);
 			for (final Project project : projects) {
@@ -57,6 +50,11 @@
 					});
 					return Status.CANCEL_STATUS;
 				}
+				File file = importProjectExample.getExamplesFile(project, monitor);
+				if (file == null) {
+                    return Status.CANCEL_STATUS;
+				}
+				project.setFile(file);
 				if (importProjectExample.importProject(project, project.getFile(), monitor)) {
 					importProjectExample.fix(project, monitor);						
 				} else {
Index: src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
===================================================================
--- src/org/jboss/tools/project/examples/ProjectExamplesActivator.java	(revision 37733)
+++ src/org/jboss/tools/project/examples/ProjectExamplesActivator.java	(working copy)
@@ -537,7 +537,12 @@
 
 	public static boolean extractZipFile(File file, File destination,
 			IProgressMonitor monitor) {
-		ZipFile zipFile = null;
+	    return extractZipFile(file, destination, null, monitor);
+	}
+
+	public static boolean extractZipFile(File file, File destination, String prefix,
+	        IProgressMonitor monitor) {
+	    ZipFile zipFile = null;
 		destination.mkdirs();
 		try {
 			zipFile = new ZipFile(file);
@@ -547,14 +552,18 @@
 					return false;
 				}
 				ZipEntry entry = (ZipEntry) entries.nextElement();
+				String entryName = entry.getName();
+                if (prefix != null && !entryName.startsWith(prefix)) {
+                    continue;
+                }
 				if (entry.isDirectory()) {
-					monitor.setTaskName("Extracting " + entry.getName());
-					File dir = new File(destination, entry.getName());
+					monitor.setTaskName("Extracting " + entryName);
+					File dir = new File(destination, entryName);
 					dir.mkdirs();
 					continue;
 				}
-				monitor.setTaskName("Extracting " + entry.getName());
-				File entryFile = new File(destination, entry.getName());
+				monitor.setTaskName("Extracting " + entryName);
+				File entryFile = new File(destination, entryName);
 				entryFile.getParentFile().mkdirs();
 				InputStream in = null;
 				OutputStream out = null;
#P jbt-maven-org.jboss.tools.maven.project.examples
Index: plugin.xml
===================================================================
--- plugin.xml	(revision 37746)
+++ plugin.xml	(working copy)
@@ -19,4 +19,13 @@
       </importProjectExample>
    </extension>
 
+   <extension
+         point="org.jboss.tools.project.examples.importProjectExamples">
+      <importProjectExample
+            class="org.jboss.tools.maven.project.examples.ImportMavenArtifactProjectExample"
+            name="Import Maven Artifact Project Examples"
+            type="mavenArtifact">
+      </importProjectExample>
+   </extension>
+
 </plugin>
Index: src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java
===================================================================
--- src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java	(revision 37746)
+++ src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java	(working copy)
@@ -96,7 +96,7 @@
 				return false;
 			}
 		}
-		boolean ok = ProjectExamplesActivator.extractZipFile(file, destination, monitor);
+		boolean ok = extractZip(projectDescription, file, destination, monitor);
 		monitor.setTaskName("");
 		if (monitor.isCanceled()) {
 			return false;
@@ -123,6 +123,10 @@
 		return true;
 	}
 
+	protected boolean extractZip(Project projectDescription, File file, File destination, IProgressMonitor monitor) {
+        return ProjectExamplesActivator.extractZipFile(file, destination, monitor);
+	}
+
 	private List<String> importMavenProjects(final File destination,
 			final Project projectDescription, IProgressMonitor monitor) {
 		List<String> projectNames = new ArrayList<String>();
Index: src/org/jboss/tools/maven/project/examples/ImportMavenArtifactProjectExample.java
===================================================================
--- src/org/jboss/tools/maven/project/examples/ImportMavenArtifactProjectExample.java	(revision 0)
+++ src/org/jboss/tools/maven/project/examples/ImportMavenArtifactProjectExample.java	(revision 0)
@@ -0,0 +1,55 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * 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:
+ *     JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.project.examples;
+
+import java.io.File;
+import java.util.Collections;
+
+import org.apache.maven.artifact.Artifact;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+import org.jboss.tools.project.examples.model.ArchetypeModel;
+import org.jboss.tools.project.examples.model.Project;
+
+/**
+ * @author snjeza
+ * 
+ */
+public class ImportMavenArtifactProjectExample extends ImportMavenProjectExample {
+
+    @SuppressWarnings("nls")
+    @Override
+    public File getExamplesFile(Project project, IProgressMonitor monitor) {
+        try {
+            ArchetypeModel model = project.getArchetypeModel();
+            Artifact artifact = MavenPlugin.getMaven().resolve(
+                    model.getArchetypeGroupId(),
+                    model.getArchetypeArtifactId(),
+                    model.getArchetypeVersion(),
+                    "zip",
+                    null,
+                    Collections.singletonList(MavenPlugin.getMaven().createArtifactRepository("temp-id",
+                            model.getArchetypeRepository())), monitor);
+            return artifact.getFile();
+        } catch (CoreException e) {
+            MavenProjectExamplesActivator.getDefault().getLog().log(e.getStatus());
+            return null;
+        }
+    }
+
+    @Override
+    protected boolean extractZip(Project projectDescription, File file, File destination, IProgressMonitor monitor) {
+        return ProjectExamplesActivator.extractZipFile(file, destination, projectDescription.getArchetypeModel().getJavaPackage(), monitor);
+    }
+
+}
#P jbt-examples-org.jboss.tools.project.examples.cheatsheet
Index: src/org/jboss/tools/project/examples/cheatsheet/actions/ImportProjectExample.java
===================================================================
--- src/org/jboss/tools/project/examples/cheatsheet/actions/ImportProjectExample.java	(revision 37733)
+++ src/org/jboss/tools/project/examples/cheatsheet/actions/ImportProjectExample.java	(working copy)
@@ -11,8 +11,6 @@
 package org.jboss.tools.project.examples.cheatsheet.actions;
 
 import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
@@ -33,7 +31,6 @@
 import org.jboss.tools.project.examples.cheatsheet.Activator;
 import org.jboss.tools.project.examples.model.IImportProjectExample;
 import org.jboss.tools.project.examples.model.Project;
-import org.jboss.tools.project.examples.model.ProjectUtil;
 
 /**
  * 
@@ -79,24 +76,13 @@
 			@Override
 			public IStatus runInWorkspace(IProgressMonitor monitor)
 					throws CoreException {
-				String urlString = project.getUrl();
-				String name = project.getName();
-				URL url = null;
-				try {
-					url = new URL(urlString);
-				} catch (MalformedURLException e) {
-					ProjectExamplesActivator.log(e);
-					return Status.CANCEL_STATUS;
-				}
-				final File file = ProjectUtil.getProjectExamplesFile(
-						url, name, ".zip", monitor); //$NON-NLS-1$
-				if (file == null) {
-					return Status.CANCEL_STATUS;
-				}
-				
 				setName(Messages.NewProjectExamplesWizard_Importing);
 				try {
 					IImportProjectExample importProjectExample = ProjectExamplesActivator.getDefault().getImportProjectExample(project.getImportType());
+					File file = importProjectExample.getExamplesFile(project, monitor);
+	                if (file == null) {
+	                    return Status.CANCEL_STATUS;
+	                }
 					if (importProjectExample.importProject(project, file, monitor)) {
 						importProjectExample.fix(project, monitor);
 					}
