Bug 2779 - Better naming for Application templates
authorEugene Ostroukhov <eugeneo@symbian.org>
Mon, 07 Jun 2010 16:22:59 -0700
changeset 353 7d239d0853b9
parent 352 9e80d9bd54fe
child 354 0bceeb415e7f
Bug 2779 - Better naming for Application templates
org.symbian.tools.wrttools/plugin.xml
org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage.java
org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WizardContext.java
org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java
--- a/org.symbian.tools.wrttools/plugin.xml	Mon Jun 07 14:58:15 2010 -0700
+++ b/org.symbian.tools.wrttools/plugin.xml	Mon Jun 07 16:22:59 2010 -0700
@@ -155,7 +155,7 @@
 	<extension point="org.symbian.tools.wrttools.projectTemplates">
 
       <projectTemplate
-		name="Basic Widget Project"
+		name="Basic Project"
         archive="projecttemplates/basic.zip"
         default-css-name="basic"
         default-html-name="index"
@@ -168,7 +168,7 @@
 	  </projectTemplate> 
 
       <projectTemplate
-            name="Hello Application Project with WRTKit Support"
+            name="Advanced Project"
             archive="projecttemplates/helloWithWRTKit.zip"
             default-css-name="HelloWithWRTKit"
             default-html-name="index"
@@ -183,7 +183,7 @@
       </projectTemplate>
 
       <projectTemplate
-            name="Flickr Application Project"
+            name="Flickr Project"
             archive="projecttemplates/flickr.zip"
             default-css-name="Flickr"
             default-html-name="index"
@@ -198,7 +198,7 @@
       </projectTemplate>
 
       <projectTemplate
-            name="RSS Reader Application Project"
+            name="RSS Reader Project"
             archive="projecttemplates/rssreader.zip"
             default-css-name="RSSReader"
             default-html-name="index"
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage.java	Mon Jun 07 14:58:15 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage.java	Mon Jun 07 16:22:59 2010 -0700
@@ -32,19 +32,19 @@
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.FormAttachment;
 import org.eclipse.swt.layout.FormData;
 import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
 import org.symbian.tools.wrttools.core.ProjectTemplate;
 
-public class WRTProjectTemplateWizardPage extends WizardPage {
+public class WRTProjectTemplateWizardPage extends WizardNewProjectCreationPage {
 
 	public class ProjectTemplateLabelProvider extends LabelProvider {
 
@@ -65,37 +65,33 @@
 	private final DataBindingContext bindingContext;
 
 	public WRTProjectTemplateWizardPage(WizardContext context, DataBindingContext bindingContext) {
-		super("WRTTemplate", "Application Template Selection", null);
+        super("Create a New Mobile Web Application");
+        setTitle("Create a New Mobile Web Application");
 		this.context = context;
 		this.bindingContext = bindingContext;
-		setDescription("Select template that will be used to populate your new project");
+        setDescription("Select project name and template that will be used to populate");
 	}
 	
-	public void createControl(Composite parent) {
+    public void createControl(Composite parent) {
+        super.createControl(parent);
+        final Composite root = (Composite) getControl();
 		ProjectTemplate[] allTemplates = ProjectTemplate.getAllTemplates();
 
 		if (allTemplates.length == 1) {
 			context.setTemplate(allTemplates[0]);
 		}
-		
-		Composite composite = new Composite(parent, SWT.NONE);
+        Composite composite = new Composite(root, SWT.NONE);
+        composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
 		FormLayout layout = new FormLayout();
 		layout.marginWidth = 5;
 		composite.setLayout(layout);
-		
-		Label label = new Label(composite, SWT.NONE);
-		label.setText("Choose a template");
-		FormData data = new FormData();
-		data.left = new FormAttachment(0, 0);
-		data.top = new FormAttachment(0, 0);
-		label.setLayoutData(data);
-		
+
 		templates = new TableViewer(composite, SWT.BORDER | SWT.SINGLE);
 		FormData templatesData = new FormData();
-		templatesData.top = new FormAttachment(label, 5);
+        templatesData.top = new FormAttachment(0, 8);
 		templatesData.left = new FormAttachment(0, 0);
-		templatesData.right = new FormAttachment(100, 0);
-		templatesData.bottom = new FormAttachment(70, 0);
+        templatesData.right = new FormAttachment(40, -2);
+        templatesData.bottom = new FormAttachment(100, 0);
 		templates.getControl().setLayoutData(templatesData);
 		templates.addSelectionChangedListener(new ISelectionChangedListener() {
 			public void selectionChanged(SelectionChangedEvent event) {
@@ -113,9 +109,9 @@
 		
 		description = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT .READ_ONLY);
 		FormData descriptionData = new FormData();
-		descriptionData.top = new FormAttachment(templates.getControl(), 10);
+        descriptionData.top = new FormAttachment(0, 8);
 		descriptionData.bottom = new FormAttachment(100, 0);
-		descriptionData.left = new FormAttachment(0, 0);
+        descriptionData.left = new FormAttachment(templates.getControl(), 5);
 		descriptionData.right = new FormAttachment(100, 0);
 		description.setLayoutData(descriptionData);
 		
@@ -123,7 +119,6 @@
 		templates.setLabelProvider(new ProjectTemplateLabelProvider());
 		templates.setInput(allTemplates);
 		
-		setControl(composite);
 		setPageComplete(false);
 
 		IViewerObservableValue selection = ViewersObservables.observeSingleSelection(templates);
@@ -150,16 +145,30 @@
 
 	protected void refreshSelection(ProjectTemplate template) {
 		if (template != null) {
-			setErrorMessage(null);
-			setPageComplete(true);
 			description.setText(template.getDescription());
 		} else {
-			setErrorMessage("Project template is not selected");
-			setPageComplete(false);
 			description.setText("");
 		}
+        validatePage();
 	}
 
+    @Override
+    protected boolean validatePage() {
+        if (super.validatePage()) {
+            if (templates.getSelection().isEmpty()) {
+                setErrorMessage("Project template is not selected");
+                setPageComplete(false);
+                return false;
+            } else {
+                setErrorMessage(null);
+                setPageComplete(true);
+                return true;
+            }
+        } else {
+            return false;
+        }
+    }
+
 	public ProjectTemplate getSelectedProjectTemplate() {
 		IStructuredSelection selection = (IStructuredSelection) templates.getSelection();
 		return (ProjectTemplate) selection.getFirstElement();
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WizardContext.java	Mon Jun 07 14:58:15 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WizardContext.java	Mon Jun 07 16:22:59 2010 -0700
@@ -195,7 +195,7 @@
 			propertySupport.firePropertyChange(CSS_FILE, getCssFile(), css);
 		}
         if (cssFile == null) {
-            propertySupport.firePropertyChange(LIBRARIES, getCssFile(), css);
+            propertySupport.firePropertyChange(LIBRARIES, getLibraries(), libraries);
         }
 	}
 
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java	Mon Jun 07 14:58:15 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java	Mon Jun 07 16:22:59 2010 -0700
@@ -54,7 +54,6 @@
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.INewWizard;
 import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
 import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
 import org.symbian.tools.wrttools.Activator;
 import org.symbian.tools.wrttools.core.ProjectTemplate;
@@ -65,7 +64,6 @@
 import org.symbian.tools.wrttools.wizards.libraries.WRTProjectLibraryWizardPage;
 
 public class WrtWidgetWizard extends Wizard implements INewWizard, IExecutableExtension {
-    private WizardNewProjectCreationPage resourcePage;
     private WizardContext context;
     private DataBindingContext bindingContext;
     private final Map<ProjectTemplate, WRTProjectDetailsWizardPage> templateDetails = new HashMap<ProjectTemplate, WRTProjectDetailsWizardPage>();
@@ -215,11 +213,6 @@
 
     @Override
     public void addPages() {
-        resourcePage = new WizardNewProjectCreationPage("Resource");
-        resourcePage.setDescription("Create a Web Runtime application project in the workspace or other location");
-        resourcePage.setTitle("Create a New Web Runtime Application Project");
-        addPage(resourcePage);
-
         templatesPage = new WRTProjectTemplateWizardPage(context, bindingContext);
         addPage(templatesPage);
 
@@ -243,11 +236,9 @@
 
     @Override
     public IWizardPage getNextPage(IWizardPage page) {
-        if (page == resourcePage) {
-            context.setProjectName(resourcePage.getProjectName());
-            context.setProjectUri(resourcePage.getLocationURI());
-        }
         if (page == templatesPage) {
+            context.setProjectName(templatesPage.getProjectName());
+            context.setProjectUri(templatesPage.getLocationURI());
             ProjectTemplate template = context.getTemplate();
             if (template != null) {
                 WRTProjectDetailsWizardPage activePage = templateDetails.get(template);