[jbosstools-commits] JBoss Tools SVN: r43638 - in trunk: examples/plugins/org.jboss.tools.project.examples and 8 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Sep 13 05:23:25 EDT 2012


Author: fbricon
Date: 2012-09-13 05:23:24 -0400 (Thu, 13 Sep 2012)
New Revision: 43638

Added:
   trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenExamplesRequirementsPage.java
   trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/NewProjectExamplesStacksRequirementsPage.java
Modified:
   trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/wizards/AbstractJBossCentralProjectWizard.java
   trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml
   trunk/examples/plugins/org.jboss.tools.project.examples/schema/wizardpages.exsd
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExample.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExampleUtil.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ContributedPage.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/IProjectExamplesWizardPage.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/IWizardContextChangeListener.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesLocationPage.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesMainPage.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesRequirementsPage.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard2.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/WizardContext.java
   trunk/maven/plugins/org.jboss.tools.maven.project.examples/META-INF/MANIFEST.MF
   trunk/maven/plugins/org.jboss.tools.maven.project.examples/plugin.xml
   trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExampleDelegate.java
   trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java
   trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
Log:
JBIDE-12472 : refactor the project example page navigation to allow use of different requirement pages for archetypes.

Modified: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/wizards/AbstractJBossCentralProjectWizard.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/wizards/AbstractJBossCentralProjectWizard.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/wizards/AbstractJBossCentralProjectWizard.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -18,12 +18,9 @@
 import org.eclipse.jface.dialogs.ProgressMonitorDialog;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.jboss.tools.central.JBossCentralActivator;
 import org.jboss.tools.central.jobs.RefreshTutorialsJob;
-import org.jboss.tools.project.examples.ProjectExamplesActivator;
 import org.jboss.tools.project.examples.model.ProjectExample;
 import org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard2;
 
@@ -33,7 +30,7 @@
 	
 	public AbstractJBossCentralProjectWizard(String exampleName) {
 		super();
-		Assert.isNotNull(exampleName);
+		Assert.isNotNull(exampleName, "Project name is null");
 		this.exampleName = exampleName;
 		ProjectExample example = lookupProjectExample();
 		initializeProjectExample(example);
@@ -69,9 +66,9 @@
 	
 	private boolean matches(ProjectExample expl) {
 		if (expl != null && exampleName.equals(expl.getName())) {
-			if (expl.getSite() != null && "Shared examples".equals(expl.getSite().getName())){
+//			if (expl.getSite() != null && "Shared examples".equals(expl.getSite().getName())){
 				return true;
-			}
+//			}
 		}
 		return false;
 	}

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml	2012-09-13 09:23:24 UTC (rev 43638)
@@ -76,7 +76,7 @@
    
     <extension
         point="org.jboss.tools.project.examples.projectExamplesXml"
-        name="Shared examples">
+        name="Shared Examples">
         <url>http://download.jboss.org/jbosstools/examples/project-examples-shared-4.0.Alpha1.xml</url>
         <experimental>false</experimental>
     </extension>
@@ -86,5 +86,16 @@
         name="Project Examples Categories">
         <url>http://download.jboss.org/jbosstools/examples/project-examples-category-3.3.xml</url>
     </extension>
-    
+   
+    <extension
+         point="org.jboss.tools.project.examples.wizardpages">
+         <page
+            class="org.jboss.tools.project.examples.wizard.NewProjectExamplesRequirementsPage"
+            id="org.jboss.tools.project.examples.wizard.NewProjectExamplesRequirementsPage"
+            name="Project Example requirementPage"
+            priority="1"
+            pageType="requirement"
+            type="zip">
+      </page>
+   </extension>
 </plugin>

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/schema/wizardpages.exsd
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/schema/wizardpages.exsd	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/schema/wizardpages.exsd	2012-09-13 09:23:24 UTC (rev 43638)
@@ -87,6 +87,23 @@
                </appInfo>
             </annotation>
          </attribute>
+         <attribute name="pageType" use="required">
+            <annotation>
+               <documentation>
+                  Page type. Valid values are : requirement, location, extra
+               </documentation>
+            </annotation>
+            <simpleType>
+               <restriction base="string">
+                  <enumeration value="requirement">
+                  </enumeration>
+                  <enumeration value="location">
+                  </enumeration>
+                  <enumeration value="extra">
+                  </enumeration>
+               </restriction>
+            </simpleType>
+         </attribute>
       </complexType>
    </element>
 

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -1138,7 +1138,8 @@
 						}
 					}
 					String type = configurationElement.getAttribute(TYPE);
-					ContributedPage contributedPage = new ContributedPage(configurationElement, type, priority, clazz);
+					String pageType = configurationElement.getAttribute("pageType");
+					ContributedPage contributedPage = new ContributedPage(configurationElement, type, pageType, priority, clazz);
 					List<ContributedPage> contributions = contributedPages.get(type);
 					if (contributions == null) {
 						contributions = new ArrayList<ContributedPage>();

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExample.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExample.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExample.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -54,7 +54,7 @@
 	private Set<String> essentialEnterpriseDependencies;
 	private String iconPath;
 	private String sourceLocation;
-
+	private String stacksId;
 	public ProjectExample() {
 		name = ""; //$NON-NLS-1$
 		shortDescription = ""; //$NON-NLS-1$
@@ -62,7 +62,7 @@
 		url = ""; //$NON-NLS-1$
 		welcome = false;
 		perspectiveId = null;
-		importType = null;
+		importType = "zip";
 		setCategory(ProjectExampleCategory.OTHER);
 	}
 
@@ -362,4 +362,13 @@
 	public void setSourceLocation(String sourceLocation) {
 		this.sourceLocation = sourceLocation;
 	}
+	
+	public String getStacksId() {
+		return stacksId;
+	}
+
+	public void setStacksId(String stacksId) {
+		this.stacksId = stacksId;
+	}
+
 }

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExampleUtil.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExampleUtil.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExampleUtil.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -478,6 +478,11 @@
 									}
 								} else if (nodeName.equals("essentialEnterpriseDependencies")) {
 									parseEssentialEnterpriseDependencies(project, child);
+								} else if (nodeName.equals("stacksId")) {
+									String stacksId = child.getAttribute("stacksId"); //$NON-NLS-1$
+									if (stacksId != null) {
+										project.setStacksId(stacksId);
+									}
 								}
 							}
 						}

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ContributedPage.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ContributedPage.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ContributedPage.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -4,26 +4,28 @@
 
 public class ContributedPage implements Comparable<ContributedPage> {
 
-	private String type;
+	private String exampleType;
 	private int priority;
 	private IConfigurationElement configurationElement;
 	private String clazz;
+	private String pageType;
 
 	public ContributedPage(IConfigurationElement configurationElement,
-			String type, int priority, String clazz) {
+			String type, String pageType, int priority, String clazz) {
 		super();
 		this.configurationElement = configurationElement;
-		this.type = type;
+		this.exampleType = type;
+		this.setPageType(pageType);
 		this.priority = priority;
 		this.clazz = clazz;
 	}
 
 	public String getType() {
-		return type;
+		return exampleType;
 	}
 
 	public void setType(String type) {
-		this.type = type;
+		this.exampleType = type;
 	}
 
 	public int getPriority() {
@@ -63,4 +65,12 @@
 		return 0;
 	}
 
+	public String getPageType() {
+		return pageType;
+	}
+
+	public void setPageType(String pageType) {
+		this.pageType = pageType;
+	}
+
 }

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/IProjectExamplesWizardPage.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/IProjectExamplesWizardPage.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/IProjectExamplesWizardPage.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -16,4 +16,6 @@
 	Map<String, Object> getPropertiesMap();
 	
 	void setWizardContext(WizardContext context);
+
+	String getPageType();
 }

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/IWizardContextChangeListener.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/IWizardContextChangeListener.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/IWizardContextChangeListener.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -12,5 +12,7 @@
 
 public interface IWizardContextChangeListener {
 
+	String PROJECT_EXAMPLE_KEY = "project.example"; //$NON-NLS-1$
+	
 	void onWizardContextChange(String key, Object value);
 }

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesLocationPage.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesLocationPage.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesLocationPage.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -316,7 +316,7 @@
 		if (wizard instanceof NewProjectExamplesWizard2) {
 			ProjectExample projectExample = ((NewProjectExamplesWizard2)wizard).getSelectedProjectExample();
 			if (projectExample != null && projectExample.getImportType() != null) {
-				List<IProjectExamplesWizardPage> pages = ((NewProjectExamplesWizard2)wizard).getContributedPages();
+				List<IProjectExamplesWizardPage> pages = ((NewProjectExamplesWizard2)wizard).getContributedPages("extra");
 				for (IProjectExamplesWizardPage page:pages) {
 					if (projectExample.getImportType().equals(page.getProjectExampleType())) {
 						return page;

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesMainPage.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesMainPage.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesMainPage.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -31,6 +31,8 @@
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
@@ -72,19 +74,13 @@
 	private Combo siteCombo;
 	private List<ProjectExampleCategory> categories;
 	private Text descriptionText;
-	private NewProjectExamplesRequirementsPage requirementsPage;
-	//private NewProjectExamplesReadyPage readyPage;
-	private List<IProjectExamplesWizardPage> pages;
 	private ProjectExample selectedProject;
 	private Combo targetRuntimeTypesCombo;
 	
-	public NewProjectExamplesMainPage(NewProjectExamplesRequirementsPage requirementsPage, List<IProjectExamplesWizardPage> pages) {
+	public NewProjectExamplesMainPage() {
 		super("org.jboss.tools.project.examples.main"); //$NON-NLS-1$
         setTitle( Messages.NewProjectExamplesWizardPage_Project_Example );
         setDescription( Messages.NewProjectExamplesWizardPage_Import_Project_Example );
-        this.requirementsPage = requirementsPage;
-        //this.readyPage = readyPage;
-        this.pages = pages;
     }
 
 	public void createControl(Composite parent) {
@@ -189,22 +185,15 @@
 			public void selectionChanged(SelectionChangedEvent event) {
 				selection = (IStructuredSelection) event.getSelection();
 				Object selected = selection.getFirstElement();
+				String projectType = null;
 				if (selected instanceof ProjectExample && selection.size() == 1) {
 					selectedProject = (ProjectExample) selected;
 					descriptionText.setText(selectedProject.getDescription());
 					projectName.setText(selectedProject.getName());
 					projectURL.setText(selectedProject.getUrl());
 					projectSize.setText(selectedProject.getSizeAsText());
-					requirementsPage.setProjectExample(selectedProject);
 					//readyPage.setProjectExample(selectedProject);
-					String projectType = selectedProject.getImportType();
-					for (IProjectExamplesWizardPage page:pages) {
-						if (projectType != null && projectType.equals(page.getProjectExampleType())) {
-							page.setProjectExample(selectedProject);
-						} else {
-							page.setProjectExample(null);
-						}
-					}
+					projectType = selectedProject.getImportType();
 				} else {
 					selectedProject = null;
 					String description = ""; //$NON-NLS-1$
@@ -218,9 +207,19 @@
 					projectName.setText(""); //$NON-NLS-1$
 					projectURL.setText(""); //$NON-NLS-1$
 					projectSize.setText(""); //$NON-NLS-1$
-					requirementsPage.setProjectExample(null);
-					//readyPage.setProjectExample(null);
 				}
+				
+				for (IWizardPage page : getWizard().getPages()) {
+					if (page instanceof IProjectExamplesWizardPage) {
+						IProjectExamplesWizardPage pewp = (IProjectExamplesWizardPage) page;
+						if (projectType != null && projectType.equals(pewp.getProjectExampleType())) {
+							pewp.setProjectExample(selectedProject);
+						} else {
+							pewp.setProjectExample(null);
+						}
+					}
+				}
+				
 				boolean canFinish = refresh(false);
 				setPageComplete(canFinish);
 			}
@@ -512,4 +511,22 @@
 		//Reset position of combo to the appropriate item index
 		combo.select(selectedIdx); 
 	}
+	
+	@Override
+	public IWizardPage getNextPage() {
+		IWizard wizard = getWizard();
+		if (wizard instanceof NewProjectExamplesWizard2) {
+			ProjectExample projectExample = ((NewProjectExamplesWizard2)wizard).getSelectedProjectExample();
+			if (projectExample != null && projectExample.getImportType() != null) {
+				List<IProjectExamplesWizardPage> pages = ((NewProjectExamplesWizard2)wizard).getContributedPages("requirement");
+				for (IProjectExamplesWizardPage page:pages) {
+					if (projectExample.getImportType().equals(page.getProjectExampleType())) {
+						return page;
+					}
+				}
+			} 
+			//return ((NewProjectExamplesWizard2)wizard).getReadyPage();
+		}
+		return super.getNextPage();
+	}
 }

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesRequirementsPage.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesRequirementsPage.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesRequirementsPage.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -5,6 +5,7 @@
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -64,7 +65,7 @@
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceReference;
 
-public class NewProjectExamplesRequirementsPage extends WizardPage {
+public class NewProjectExamplesRequirementsPage extends WizardPage implements IProjectExamplesWizardPage {
 
 	private static final String PAGE_NAME = "org.jboss.tools.project.examples.requirements"; //$NON-NLS-1$
 	private ProjectExample projectExample;
@@ -78,12 +79,18 @@
 	private Link link;
 	
 	public NewProjectExamplesRequirementsPage(ProjectExample projectExample) {
-		super(PAGE_NAME);
+		this(PAGE_NAME, projectExample);
+	}
+
+	public NewProjectExamplesRequirementsPage(String pageName, ProjectExample projectExample) {
+		super(pageName);
 		this.projectExample = projectExample;
 		setTitleAndDescription(projectExample);
+        checkboxOn = RuntimeUIActivator.imageDescriptorFromPlugin(RuntimeUIActivator.PLUGIN_ID, "/icons/xpl/complete_tsk.gif").createImage();
+		checkboxOff = RuntimeUIActivator.imageDescriptorFromPlugin(RuntimeUIActivator.PLUGIN_ID, "/icons/xpl/incomplete_tsk.gif").createImage();
 	}
 
-	private void setTitleAndDescription(ProjectExample projectExample) {
+	protected void setTitleAndDescription(ProjectExample projectExample) {
 		setTitle( "Requirements" );
         setDescription( "Project Example Requirements" );
 		if (projectExample != null) {
@@ -111,7 +118,7 @@
 		}
 	}
 
-	protected NewProjectExamplesRequirementsPage() {
+	public NewProjectExamplesRequirementsPage() {
 		super(PAGE_NAME);
         setTitleAndDescription(null);
         checkboxOn = RuntimeUIActivator.imageDescriptorFromPlugin(RuntimeUIActivator.PLUGIN_ID, "/icons/xpl/complete_tsk.gif").createImage();
@@ -565,13 +572,13 @@
 	@Override
 	public IWizardPage getNextPage() {
 		// FIXME
-		if (projectExample != null && ProjectExamplesActivator.MAVEN_ARCHETYPE.equals(projectExample.getImportType())) {
+		if (projectExample != null) {
 			IWizard wizard = getWizard();
 			if (wizard instanceof NewProjectExamplesWizard2) {
-				ProjectExample projectExample = ((NewProjectExamplesWizard2)wizard).getSelectedProjectExample();
+				NewProjectExamplesWizard2 exampleWizard = ((NewProjectExamplesWizard2)wizard); 
+				ProjectExample projectExample = exampleWizard.getSelectedProjectExample();
 				if (projectExample != null && projectExample.getImportType() != null) {
-					List<IProjectExamplesWizardPage> pages = ((NewProjectExamplesWizard2)wizard).getContributedPages();
-					for (IProjectExamplesWizardPage page:pages) {
+					for (IProjectExamplesWizardPage page: exampleWizard.getContributedPages("extra")) {
 						if (projectExample.getImportType().equals(page.getProjectExampleType())) {
 							return page;
 						}
@@ -593,4 +600,37 @@
 		}
 		super.dispose();
 	}
+
+	@Override
+	public void onWizardContextChange(String key, Object value) {
+		// TODO Auto-generated method stub
+	}
+
+	@Override
+	public boolean finishPage() {
+		// TODO Auto-generated method stub
+		return true;
+	}
+
+	@Override
+	public String getProjectExampleType() {
+		return "zip";
+	}
+
+	@Override
+	public Map<String, Object> getPropertiesMap() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void setWizardContext(WizardContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public String getPageType() {
+		return "requirement";
+	}
 }

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard2.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard2.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard2.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -15,6 +15,7 @@
  * 
  */
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -143,30 +144,34 @@
 	@Override
 	public void addPages() {
 		createContributedPages();
-		requirementsPage = new NewProjectExamplesRequirementsPage();
-		//readyPage = new NewProjectExamplesReadyPage();
+		
 		if (projectExample == null) {
-			mainPage = new NewProjectExamplesMainPage(requirementsPage, contributedPages);
+			mainPage = new NewProjectExamplesMainPage();
 			addPage(mainPage);
-		} else {
-			requirementsPage.setProjectExample(projectExample);
-			//readyPage.setProjectExample(projectExample);
+		} 
+		for(IProjectExamplesWizardPage page: getContributedPages("requirement")) {
+			if (projectExample == null || projectExample.getImportType().equals(page.getProjectExampleType())) {
+				addPage(page);
+			}
 		}
-		addPage(requirementsPage);
+
 		locationPage = new NewProjectExamplesLocationPage();
 		addPage(locationPage);
 		if (getSelection() != null) {
 			locationPage.init(getSelection(), getActivePart());
 		}
+		
 		// contributed page
-		for(IProjectExamplesWizardPage page:contributedPages) {
-			addPage(page);
+		for(IProjectExamplesWizardPage page: getContributedPages("extra")) {
+			if (projectExample == null || projectExample.getImportType().equals(page.getProjectExampleType())) {
+				addPage(page);
+			}
 		}
-		//addPage(readyPage);
-		//quickFixPage = new QuickFixPage("Quick Fix Descripton", new LinkedHashMap());
-		//addPage(quickFixPage);
 	}
 
+	
+	
+	
 	protected void createContributedPages() {
 		Map<String, List<ContributedPage>> extensionPages = ProjectExamplesActivator.getDefault().getContributedPages();
 		Set<String> keySet = extensionPages.keySet();
@@ -228,6 +233,22 @@
 		return contributedPages;
 	}
 
+	public List<IProjectExamplesWizardPage> getContributedPages(String pageType) {
+		if (contributedPages == null || contributedPages.isEmpty()) {
+			return Collections.emptyList();
+		}
+		
+		List<IProjectExamplesWizardPage> filteredPages = new ArrayList<IProjectExamplesWizardPage>();
+		
+		for (IProjectExamplesWizardPage p : contributedPages) {
+			if (pageType.equals(p.getPageType())) {
+				filteredPages.add(p);
+			}
+		}
+		
+		return filteredPages;
+	}
+	
 	public IWizardPage getLocationsPage() {
 		return locationPage;
 	}

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/WizardContext.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/WizardContext.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/WizardContext.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -10,11 +10,16 @@
  ************************************************************************************/
 package org.jboss.tools.project.examples.wizard;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.eclipse.ui.IWorkingSet;
+import org.jboss.tools.project.examples.model.ProjectExample;
+
 public class WizardContext {
 
 	private Map<String, Object> context;
@@ -42,6 +47,14 @@
 			fireChangeEvent(key, value);
 		}
 	}
+	
+	public ProjectExample getProjectExample() {
+		return (ProjectExample) context.get(IWizardContextChangeListener.PROJECT_EXAMPLE_KEY) ;
+	}
+	
+	public void setProjectExample(ProjectExample example) {
+		context.put(IWizardContextChangeListener.PROJECT_EXAMPLE_KEY, example);
+	}
 
 	public Object getProperty(String key) {
 		return context.get(key);
@@ -52,4 +65,16 @@
 			listener.onWizardContextChange(key, value);
 		}
 	}
+	
+	public List<IWorkingSet> getWorkingSets() {
+		return (List<IWorkingSet>) context.get("workingSets") ;
+	}
+	
+	public void setWorkingSets(List<IWorkingSet> workingSets) {
+		context.put("workingSets", workingSets);
+	}
+
+	public Map<String, Object> getProperties() {
+		return Collections.unmodifiableMap(context);
+	}
 }

Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/META-INF/MANIFEST.MF	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/META-INF/MANIFEST.MF	2012-09-13 09:23:24 UTC (rev 43638)
@@ -17,7 +17,9 @@
  org.jboss.ide.eclipse.as.core;bundle-version="2.3.0",
  org.eclipse.wst.server.core,
  org.jboss.tools.maven.ui;bundle-version="1.3.0",
- org.eclipse.core.filesystem;bundle-version="1.3.100"
+ org.eclipse.core.filesystem;bundle-version="1.3.100",
+ org.jboss.tools.runtime.ui;bundle-version="2.0.0",
+ org.jboss.tools.runtime.core;bundle-version="2.0.0"
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-Vendor: %Bundle-Vendor

Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/plugin.xml	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/plugin.xml	2012-09-13 09:23:24 UTC (rev 43638)
@@ -21,10 +21,27 @@
    <extension
          point="org.jboss.tools.project.examples.wizardpages">
       <page
+            class="org.jboss.tools.maven.project.examples.wizard.MavenExamplesRequirementsPage"
+            id="org.jboss.tools.maven.project.examples.wizard.MavenExamplesRequirementsPage"
+            name="Maven Project Requirement Page"
+            priority="1"
+            pageType="requirement"
+            type="maven">
+      </page>      
+      <page
+            class="org.jboss.tools.maven.project.examples.wizard.NewProjectExamplesStacksRequirementsPage"
+            id="org.jboss.tools.maven.project.examples.wizard.NewProjectExamplesStacksRequirementsPage"
+            name="Maven Archetype First Page"
+            priority="1"
+            pageType="requirement"
+            type="mavenArchetype">
+      </page>
+      <page
             class="org.jboss.tools.maven.project.examples.wizard.ArchetypeExamplesWizardFirstPage"
             id="org.jboss.tools.maven.project.examples.wizard.ArchetypeExamplesWizardFirstPage"
             name="Maven Archetype First Page"
             priority="1"
+            pageType="extra"
             type="mavenArchetype">
       </page>
       <page
@@ -32,9 +49,8 @@
             id="org.jboss.tools.maven.project.examples.wizard.ArchetypeExamplesWizardPage"
             name="Maven Archetype Second Page"
             priority="2"
+            pageType="extra"
             type="mavenArchetype">
       </page>
    </extension>
-   
-
 </plugin>

Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExampleDelegate.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExampleDelegate.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExampleDelegate.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -44,12 +44,6 @@
 			Map<String, Object> propertiesMap, final IProgressMonitor monitor) throws Exception {
 		List<ProjectExample> projects = new ArrayList<ProjectExample>();
 		projects.add(projectDescription);
-//		ArchetypeExamplesWizard wizard = new ArchetypeExamplesWizard(projectDescription);
-//		WizardDialog wizardDialog = new WizardDialog(getActiveShell(), wizard);
-//		int ok = wizardDialog.open();
-//		if (ok != Window.OK) {
-//			return false;
-//		}
 		List<String> includedProjects = projectDescription.getIncludedProjects();
 		if (includedProjects == null) {
 			includedProjects = new ArrayList<String>();

Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -523,7 +523,7 @@
 		if (wizard instanceof NewProjectExamplesWizard2) {
 			ProjectExample projectExample = ((NewProjectExamplesWizard2)wizard).getSelectedProjectExample();
 			if (projectExample != null && projectExample.getImportType() != null) {
-				List<IProjectExamplesWizardPage> pages = ((NewProjectExamplesWizard2)wizard).getContributedPages();
+				List<IProjectExamplesWizardPage> pages = ((NewProjectExamplesWizard2)wizard).getContributedPages("extra");
 				for (IProjectExamplesWizardPage page:pages) {
 					if (page == this) {
 						continue;
@@ -541,7 +541,15 @@
 	public IWizardPage getPreviousPage() {
 		IWizard wizard = getWizard();
 		if (wizard instanceof NewProjectExamplesWizard2) {
-			return ((NewProjectExamplesWizard2) wizard).getRequirementsPage();
+			ProjectExample projectExample = ((NewProjectExamplesWizard2)wizard).getSelectedProjectExample();
+			if (projectExample != null && projectExample.getImportType() != null) {
+				List<IProjectExamplesWizardPage> pages = ((NewProjectExamplesWizard2)wizard).getContributedPages("requirement");
+				for (IProjectExamplesWizardPage page:pages) {
+					if (projectExample.getImportType().equals(page.getProjectExampleType())) {
+						return page;
+					}
+				}
+			} 
 		}
 		return super.getPreviousPage();
 	}
@@ -604,5 +612,10 @@
 	private Model getModel() {
 		return (Model) context.getProperty(MavenProjectConstants.MAVEN_MODEL);
 	}
+
+	@Override
+	public String getPageType() {
+		return "extra";
+	}
 	
 }

Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java	2012-09-13 09:15:17 UTC (rev 43637)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -507,5 +507,10 @@
 	    };
 	    return model;
 	  }
-	
+
+	@Override
+	public String getPageType() {
+		return "extra";
+	}
+
 }

Added: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenExamplesRequirementsPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenExamplesRequirementsPage.java	                        (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenExamplesRequirementsPage.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -0,0 +1,22 @@
+/*************************************************************************************
+ * Copyright (c) 2012 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.wizard;
+
+import org.jboss.tools.project.examples.wizard.NewProjectExamplesRequirementsPage;
+
+
+public class MavenExamplesRequirementsPage extends NewProjectExamplesRequirementsPage {
+
+	 @Override
+	public String getProjectExampleType() {
+		return "maven";
+	}
+}

Added: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/NewProjectExamplesStacksRequirementsPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/NewProjectExamplesStacksRequirementsPage.java	                        (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/NewProjectExamplesStacksRequirementsPage.java	2012-09-13 09:23:24 UTC (rev 43638)
@@ -0,0 +1,33 @@
+/*************************************************************************************
+ * Copyright (c) 2012 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.wizard;
+
+import org.jboss.tools.project.examples.model.ProjectExample;
+import org.jboss.tools.project.examples.wizard.NewProjectExamplesRequirementsPage;
+
+public class NewProjectExamplesStacksRequirementsPage extends NewProjectExamplesRequirementsPage {
+
+	private static final String PAGE_NAME = "org.jboss.tools.project.examples.stacksrequirements"; //$NON-NLS-1$
+
+	public NewProjectExamplesStacksRequirementsPage() {
+		this(null);
+	}
+	
+	public NewProjectExamplesStacksRequirementsPage(ProjectExample projectExample) {
+		super(PAGE_NAME, projectExample);
+	}
+
+	@Override
+	public String getProjectExampleType() {
+		return "mavenArchetype";
+	}
+
+}



More information about the jbosstools-commits mailing list