# HG changeset patch # User Eugene Ostroukhov # Date 1282609211 25200 # Node ID e2f461f0a9e0bc2c31faa94352ea0d2d34ab8854 # Parent 8e8aed9adb99de9d7d3fb30c19684f0e40920834 All templates are ported to a new framework diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.tmw.ui/bin/org/symbian/tools/tmw/internal/ui/wizard/CompoundValidator.class Binary file plugins/org.symbian.tools.tmw.ui/bin/org/symbian/tools/tmw/internal/ui/wizard/CompoundValidator.class has changed diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.tmw.ui/bin/org/symbian/tools/tmw/internal/ui/wizard/NonEmptyStringValidator.class Binary file plugins/org.symbian.tools.tmw.ui/bin/org/symbian/tools/tmw/internal/ui/wizard/NonEmptyStringValidator.class has changed diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.tmw.ui/bin/org/symbian/tools/tmw/internal/ui/wizard/WizardContext.class Binary file plugins/org.symbian.tools.tmw.ui/bin/org/symbian/tools/tmw/internal/ui/wizard/WizardContext.class has changed diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.tmw.ui/bin/org/symbian/tools/tmw/ui/project/AbstractNewApplicationWizardPage.class Binary file plugins/org.symbian.tools.tmw.ui/bin/org/symbian/tools/tmw/ui/project/AbstractNewApplicationWizardPage.class has changed diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/CompoundValidator.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/CompoundValidator.java Mon Aug 23 15:08:34 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/CompoundValidator.java Mon Aug 23 17:20:11 2010 -0700 @@ -1,3 +1,21 @@ +/** + * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the License "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Symbian Foundation - initial contribution. + * Contributors: + * Description: + * Overview: + * Details: + * Platforms/Drives/Compatibility: + * Assumptions/Requirement/Pre-requisites: + * Failures and causes: + */ package org.symbian.tools.tmw.internal.ui.wizard; import org.eclipse.core.databinding.validation.IValidator; diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/NonEmptyStringValidator.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/NonEmptyStringValidator.java Mon Aug 23 15:08:34 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/NonEmptyStringValidator.java Mon Aug 23 17:20:11 2010 -0700 @@ -26,22 +26,17 @@ import org.symbian.tools.tmw.ui.TMWCoreUI; public class NonEmptyStringValidator implements IValidator { - private final String propertyName; - private final AbstractDataBindingPage page; + private final String propertyName; - public NonEmptyStringValidator(String propertyName, AbstractDataBindingPage page) { - this.propertyName = propertyName; - this.page = page; - } + public NonEmptyStringValidator(String propertyName) { + this.propertyName = propertyName; + } - public IStatus validate(Object value) { - if (page != null && page.isActive()) { - if (value == null || value.toString().trim().length() == 0) { - return new Status(IStatus.ERROR, TMWCoreUI.PLUGIN_ID, - MessageFormat.format("Field {0} is empty", - propertyName)); - } - } - return Status.OK_STATUS; - } + public IStatus validate(Object value) { + if (value == null || value.toString().trim().length() == 0) { + return new Status(IStatus.ERROR, TMWCoreUI.PLUGIN_ID, MessageFormat.format("Field {0} is empty", + propertyName)); + } + return Status.OK_STATUS; + } } \ No newline at end of file diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/WizardContext.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/WizardContext.java Mon Aug 23 15:08:34 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/WizardContext.java Mon Aug 23 17:20:11 2010 -0700 @@ -101,7 +101,7 @@ text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); ISWTObservableValue view = SWTObservables.observeText(text, SWT.Modify); UpdateValueStrategy strategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); - NonEmptyStringValidator validator = new NonEmptyStringValidator(propertyName, page); + NonEmptyStringValidator validator = new NonEmptyStringValidator(propertyName); strategy.setBeforeSetValidator(validators.length == 0 ? validator : new CompoundValidator(validator, validators)); bindingContext.bindValue(view, model, strategy, null); @@ -323,7 +323,6 @@ } } - public void addIncludedJsFile(IFile file) { jsIncludes.add(file.getProjectRelativePath().makeRelative().toString()); } diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/project/AbstractNewApplicationWizardPage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/project/AbstractNewApplicationWizardPage.java Mon Aug 23 17:20:11 2010 -0700 @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the License "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Symbian Foundation - initial contribution. + * Contributors: + * Description: + * Overview: + * Details: + * Platforms/Drives/Compatibility: + * Assumptions/Requirement/Pre-requisites: + * Failures and causes: + */ +package org.symbian.tools.tmw.ui.project; + +import java.util.Collection; +import java.util.LinkedList; + +import org.eclipse.core.databinding.Binding; +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.UpdateValueStrategy; +import org.eclipse.core.databinding.validation.IValidator; +import org.eclipse.jface.databinding.swt.ISWTObservableValue; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.symbian.tools.tmw.internal.ui.wizard.CompoundValidator; +import org.symbian.tools.tmw.internal.ui.wizard.NonEmptyStringValidator; + +/** + * Boilerplate code to make it easier creating such wizard pages. + * + * @author Eugene Ostroukhov (eugeneo@symbian.org) + */ +public abstract class AbstractNewApplicationWizardPage extends WizardPage implements INewApplicationWizardPage { + protected DataBindingContext bindingContext; + protected final Collection bindings = new LinkedList(); + protected IProjectTemplateContext context; + + public AbstractNewApplicationWizardPage(String name, String title, String description) { + super(name); + setTitle(title); + setDescription(description); + } + + public void init(IProjectTemplateContext context, DataBindingContext bindingContext) { + this.context = context; + this.bindingContext = bindingContext; + } + + public void remove() { + for (Binding binding : bindings) { + bindingContext.removeBinding(binding); + } + } + + protected void createLabel(Composite root, String text) { + Label label = new Label(root, SWT.NONE); + label.setText(text); + } + + protected Text createText(Composite root, String property, String propertyName, DataBindingContext bindingContext, + IValidator... validators) { + Text text = new Text(root, SWT.BORDER); + text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + ISWTObservableValue view = SWTObservables.observeText(text, SWT.Modify); + UpdateValueStrategy strategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); + NonEmptyStringValidator validator = new NonEmptyStringValidator(propertyName); + strategy.setBeforeSetValidator(validators.length == 0 ? validator + : new CompoundValidator(validator, validators)); + bindings.add(bindingContext.bindValue(view, context.getParameterObservable(property), strategy, null)); + return text; + } +} diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/NewFlickrApplicationWizardPage$NonEmptyStringValidator.class Binary file plugins/org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/NewFlickrApplicationWizardPage$NonEmptyStringValidator.class has changed diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/NewFlickrApplicationWizardPage.class Binary file plugins/org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/NewFlickrApplicationWizardPage.class has changed diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/NewRSSReaderApplicationWizardPage.class Binary file plugins/org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/NewRSSReaderApplicationWizardPage.class has changed diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/NewWrtAppTemplatePage.class Binary file plugins/org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/NewWrtAppTemplatePage.class has changed diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.wrttools/plugin.xml --- a/plugins/org.symbian.tools.wrttools/plugin.xml Mon Aug 23 15:08:34 2010 -0700 +++ b/plugins/org.symbian.tools.wrttools/plugin.xml Mon Aug 23 17:20:11 2010 -0700 @@ -132,63 +132,8 @@ - - - This wizard generates a basic Hello project with a minimal Info.plist, html,css and js along with WRTKit. - - org.symbian.wrtkit - - - - This wizard generates a project based on the PhoneGap library that showcases PhoneGap API usage. PhoneGap applications require WRT 1.1 or newer. - - phonegap - - - - This wizard generates an RSS Reader project with a minimal Info.plist, html,css and js and WRTKit. - - org.symbian.wrtkit - - - - Includes templates for high-end devices from Forum.Nokia. - - @@ -849,9 +794,6 @@ id="org.symbian.tools.wrttools.wrt" version="1.1"> - - @@ -873,6 +815,159 @@ version="1.0"> + + + + + @@ -903,6 +998,26 @@ class="org.symbian.tools.wrttools.wizards.NewFlickrApplicationWizardPage" template-id="org.symbian.wrt11.flickr"> + + + + + + + + + + diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.wrttools/projecttemplates/basic.zip Binary file plugins/org.symbian.tools.wrttools/projecttemplates/basic.zip has changed diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.wrttools/projecttemplates/helloWithWRTKit.zip Binary file plugins/org.symbian.tools.wrttools/projecttemplates/helloWithWRTKit.zip has changed diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.wrttools/projecttemplates/phonegap.zip Binary file plugins/org.symbian.tools.wrttools/projecttemplates/phonegap.zip has changed diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.wrttools/projecttemplates/rssreader.zip Binary file plugins/org.symbian.tools.wrttools/projecttemplates/rssreader.zip has changed diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.wrttools/projecttemplates/uitemplate.zip Binary file plugins/org.symbian.tools.wrttools/projecttemplates/uitemplate.zip has changed diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/NewFlickrApplicationWizardPage.java --- a/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/NewFlickrApplicationWizardPage.java Mon Aug 23 15:08:34 2010 -0700 +++ b/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/NewFlickrApplicationWizardPage.java Mon Aug 23 17:20:11 2010 -0700 @@ -18,58 +18,11 @@ */ package org.symbian.tools.wrttools.wizards; -import java.text.MessageFormat; -import java.util.Collection; -import java.util.LinkedList; +import org.eclipse.swt.widgets.Composite; -import org.eclipse.core.databinding.Binding; -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.UpdateValueStrategy; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.core.databinding.validation.IValidator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.databinding.swt.ISWTObservableValue; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.databinding.wizard.WizardPageSupport; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -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.symbian.tools.tmw.ui.project.INewApplicationWizardPage; -import org.symbian.tools.tmw.ui.project.IProjectTemplate; -import org.symbian.tools.tmw.ui.project.IProjectTemplateContext; -import org.symbian.tools.wrttools.Activator; -import org.symbian.tools.wrttools.util.CompoundValidator; - -public class NewFlickrApplicationWizardPage extends WizardPage implements INewApplicationWizardPage { - private static class NonEmptyStringValidator implements IValidator { - private final String propertyName; - - public NonEmptyStringValidator(String propertyName) { - this.propertyName = propertyName; - } - - public IStatus validate(Object value) { - if (value == null || value.toString().trim().length() == 0) { - return new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format("Field {0} is empty", - propertyName)); - } - return Status.OK_STATUS; - } - } - private DataBindingContext bindingContext; - private final Collection bindings = new LinkedList(); - private IProjectTemplateContext context; - +public class NewFlickrApplicationWizardPage extends NewWrtAppTemplatePage { public NewFlickrApplicationWizardPage() { - super("FlickrFiles"); - setTitle("Application Files"); - setDescription("Specify application file names"); + super("FlickrFiles", "Application Files", "Specify application file names"); } protected void addTemplateControls(Composite root) { @@ -79,64 +32,4 @@ createLabel(root, ""); } - public void createControl(Composite parent) { - Composite root = new Composite(parent, SWT.NONE); - WizardPageSupport.create(this, bindingContext); - root.setLayout(new GridLayout(2, false)); - - createLabel(root, "Name of main HTML:"); - createText(root, IProjectTemplate.CommonKeys.main_html, "HTML file name", bindingContext); - createLabel(root, ""); - createLabel(root, ""); - createLabel(root, "Name of CSS file:"); - createText(root, IProjectTemplate.CommonKeys.main_css, "CSS file name", bindingContext); - createLabel(root, ""); - createLabel(root, ""); - createLabel(root, "Name of JavaScript file:"); - createText(root, IProjectTemplate.CommonKeys.main_js, "JavaScript file name", bindingContext); - - createLabel(root, ""); - Button homeScreen = new Button(root, SWT.CHECK); - homeScreen.setText("Enable HomeScreen"); - - createLabel(root, ""); - createLabel(root, ""); - - IObservableValue view = SWTObservables.observeSelection(homeScreen); - IObservableValue model = context.getParameterObservable(WizardContext.HOME_SCREEN); - bindingContext.bindValue(view, model); - - addTemplateControls(root); - - setControl(root); - } - - protected void createLabel(Composite root, String text) { - Label label = new Label(root, SWT.NONE); - label.setText(text); - } - - protected Text createText(Composite root, String property, String propertyName, DataBindingContext bindingContext, - IValidator... validators) { - Text text = new Text(root, SWT.BORDER); - text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - ISWTObservableValue view = SWTObservables.observeText(text, SWT.Modify); - UpdateValueStrategy strategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); - NonEmptyStringValidator validator = new NonEmptyStringValidator(propertyName); - strategy.setBeforeSetValidator(validators.length == 0 ? validator - : new CompoundValidator(validator, validators)); - bindings.add(bindingContext.bindValue(view, context.getParameterObservable(property), strategy, null)); - return text; - } - - public void init(IProjectTemplateContext context, DataBindingContext bindingContext) { - this.context = context; - this.bindingContext = bindingContext; - } - - public void remove() { - for (Binding binding : bindings) { - bindingContext.removeBinding(binding); - } - } } diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/NewRSSReaderApplicationWizardPage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/NewRSSReaderApplicationWizardPage.java Mon Aug 23 17:20:11 2010 -0700 @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the License "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Symbian Foundation - initial contribution. + * Contributors: + * Description: + * Overview: + * Details: + * Platforms/Drives/Compatibility: + * Assumptions/Requirement/Pre-requisites: + * Failures and causes: + */ +package org.symbian.tools.wrttools.wizards; + +import org.eclipse.swt.widgets.Composite; + +public class NewRSSReaderApplicationWizardPage extends NewWrtAppTemplatePage { + + public NewRSSReaderApplicationWizardPage() { + super("RssFiles", "RSS Application Settings", "Customize your RSS reader application project"); + } + + @Override + protected void addTemplateControls(Composite root) { + createLabel(root, "Feed URL:"); + createText(root, "feedUrl", "feed URL", bindingContext); + createLabel(root, "Feed Name:"); + createText(root, "feedName", "feed name", bindingContext); + createLabel(root, ""); + createLabel(root, ""); + } +} diff -r 8e8aed9adb99 -r e2f461f0a9e0 plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/NewWrtAppTemplatePage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/NewWrtAppTemplatePage.java Mon Aug 23 17:20:11 2010 -0700 @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the License "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Symbian Foundation - initial contribution. + * Contributors: + * Description: + * Overview: + * Details: + * Platforms/Drives/Compatibility: + * Assumptions/Requirement/Pre-requisites: + * Failures and causes: + */ +package org.symbian.tools.wrttools.wizards; + +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.databinding.wizard.WizardPageSupport; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.symbian.tools.tmw.ui.project.AbstractNewApplicationWizardPage; +import org.symbian.tools.tmw.ui.project.IProjectTemplate; + +/** + * Entry for the basic template parameters. + * + * @author Eugene Ostroukhov (eugeneo@symbian.org) + */ +public class NewWrtAppTemplatePage extends AbstractNewApplicationWizardPage { + + public NewWrtAppTemplatePage() { + this("WRTApplicationFiles", "Application Files", "Specify application file names"); + } + + protected NewWrtAppTemplatePage(String name, String title, String description) { + super(name, title, description); + } + + public final void createControl(Composite parent) { + Composite root = new Composite(parent, SWT.NONE); + WizardPageSupport.create(this, bindingContext); + root.setLayout(new GridLayout(2, false)); + + createLabel(root, "Name of main HTML:"); + createText(root, IProjectTemplate.CommonKeys.main_html, "HTML file name", bindingContext); + createLabel(root, ""); + createLabel(root, ""); + createLabel(root, "Name of CSS file:"); + createText(root, IProjectTemplate.CommonKeys.main_css, "CSS file name", bindingContext); + createLabel(root, ""); + createLabel(root, ""); + createLabel(root, "Name of JavaScript file:"); + createText(root, IProjectTemplate.CommonKeys.main_js, "JavaScript file name", bindingContext); + + createLabel(root, ""); + Button homeScreen = new Button(root, SWT.CHECK); + homeScreen.setText("Enable HomeScreen"); + + createLabel(root, ""); + createLabel(root, ""); + + IObservableValue view = SWTObservables.observeSelection(homeScreen); + IObservableValue model = context.getParameterObservable(WizardContext.HOME_SCREEN); + bindingContext.bindValue(view, model); + + addTemplateControls(root); + + setControl(root); + } + + protected void addTemplateControls(Composite root) { + // Subclasses may override + } +}