# HG changeset patch # User Omair Majid # Date 1401831128 14400 # Node ID eef52fe805538a8af65cc14708e94c2093055d08 # Parent 01068177f0800eaa9a483fe1a7e0ec8c9cc833f9 Make wizard page names describe functionality Make it easier to share wizard pages between wizards by making names reflect purpose rather than which wizard is using them. diff -r 01068177f080 -r eef52fe80553 com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/Messages.java --- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/Messages.java Tue Jun 03 17:32:07 2014 -0400 +++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/Messages.java Tue Jun 03 17:32:08 2014 -0400 @@ -78,15 +78,15 @@ public static String PluginXmlProjectSelectionPage_projectNameLabel; public static String PluginXmlProjectSelectionPage_title; public static String ThermostatProjectCreationWizard_dialogTitle; - public static String ThermostatProjectCreationWizardPage_artifactIdLabel; - public static String ThermostatProjectCreationWizardPage_groupIdLabel; - public static String ThermostatProjectCreationWizardPage_packagePrefixLabel; - public static String ThermostatProjectCreationWizardPage_thermostatVersionErrorMessage; - public static String ThermostatProjectCreationWizardPage_thermostatVersionLabel; - public static String ThermostatProjectCreationWizardPage_versionErrorMessage; - public static String ThermostatProjectCreationWizardPage_versionLabel; - public static String ThermostatProjectCreationWizardPage_wizardDescription; - public static String ThermostatProjectCreationWizardPage_wizardTitle; + public static String NewProjectInformationPage_artifactIdLabel; + public static String NewProjectInformationPage_groupIdLabel; + public static String NewProjectInformationPage_packagePrefixLabel; + public static String NewProjectInformationPage_thermostatVersionErrorMessage; + public static String NewProjectInformationPage_thermostatVersionLabel; + public static String NewProjectInformationPage_versionErrorMessage; + public static String NewProjectInformationPage_versionLabel; + public static String NewProjectInformationPage_wizardDescription; + public static String NewProjectInformationPage_wizardTitle; static { // initialize resource bundle diff -r 01068177f080 -r eef52fe80553 com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/messages.properties --- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/messages.properties Tue Jun 03 17:32:07 2014 -0400 +++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/messages.properties Tue Jun 03 17:32:08 2014 -0400 @@ -70,12 +70,12 @@ PluginXmlProjectSelectionPage_projectNameLabel=&Project: PluginXmlProjectSelectionPage_title=Thermostat Wizard ThermostatProjectCreationWizard_dialogTitle=Create New Thermostat Plugin -ThermostatProjectCreationWizardPage_artifactIdLabel=Artifact Id -ThermostatProjectCreationWizardPage_groupIdLabel=Group Id -ThermostatProjectCreationWizardPage_packagePrefixLabel=Package Prefix -ThermostatProjectCreationWizardPage_thermostatVersionErrorMessage=Invalid thermostat version -ThermostatProjectCreationWizardPage_thermostatVersionLabel=Thermostat Version -ThermostatProjectCreationWizardPage_versionErrorMessage=Version must not be empty -ThermostatProjectCreationWizardPage_versionLabel=Version -ThermostatProjectCreationWizardPage_wizardDescription=This wizard creates a new Thermostat Plugin. -ThermostatProjectCreationWizardPage_wizardTitle=Thermostat projects Wizard +NewProjectInformationPage_artifactIdLabel=Artifact Id +NewProjectInformationPage_groupIdLabel=Group Id +NewProjectInformationPage_packagePrefixLabel=Package Prefix +NewProjectInformationPage_thermostatVersionErrorMessage=Invalid thermostat version +NewProjectInformationPage_thermostatVersionLabel=Thermostat Version +NewProjectInformationPage_versionErrorMessage=Version must not be empty +NewProjectInformationPage_versionLabel=Version +NewProjectInformationPage_wizardDescription=This wizard creates a new Thermostat Plugin. +NewProjectInformationPage_wizardTitle=Thermostat projects Wizard diff -r 01068177f080 -r eef52fe80553 com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/NewProjectInformationPage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/NewProjectInformationPage.java Tue Jun 03 17:32:08 2014 -0400 @@ -0,0 +1,135 @@ +package com.redhat.thermostat.tools.eclipse.plugin.wizards; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.UpdateValueStrategy; +import org.eclipse.core.databinding.beans.PojoObservables; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.core.databinding.validation.IValidator; +import org.eclipse.jface.databinding.swt.WidgetProperties; +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.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +import com.redhat.thermostat.tools.eclipse.plugin.Messages; +import com.redhat.thermostat.tools.eclipse.plugin.Validators; + +public class NewProjectInformationPage extends WizardPage { + + static final String PAGE_NAME = "newProjectInformation"; //$NON-NLS-1$ + + private ProjectModel model = new ProjectModel(); + private DataBindingContext context; + + public NewProjectInformationPage() { + super(PAGE_NAME); + setTitle(Messages.NewProjectInformationPage_wizardTitle); + setDescription(Messages.NewProjectInformationPage_wizardDescription); + } + + @Override + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(2, false); + container.setLayout(layout); + + context = new DataBindingContext(); + + createLabelAndInputField(container, Messages.NewProjectInformationPage_groupIdLabel, "groupId", //$NON-NLS-1$ + new Validators.ValidIdRequired(Messages.NewProjectInformationPage_groupIdLabel)); + + createLabelAndInputField(container, Messages.NewProjectInformationPage_artifactIdLabel, "artifactId", //$NON-NLS-1$ + new Validators.ValidIdRequired(Messages.NewProjectInformationPage_artifactIdLabel)); + + createLabelAndInputField(container, Messages.NewProjectInformationPage_versionLabel, "version", //$NON-NLS-1$ + new Validators.NonEmptyStringRequired(Messages.NewProjectInformationPage_versionErrorMessage)); + + createLabelAndInputField(container, Messages.NewProjectInformationPage_packagePrefixLabel, "packageName", //$NON-NLS-1$ + new Validators.PackageNameRequired()); + + createLabelAndInputField(container, Messages.NewProjectInformationPage_thermostatVersionLabel, "thermostatVersion", //$NON-NLS-1$ + new Validators.VersionRequired(Messages.NewProjectInformationPage_thermostatVersionErrorMessage)); + + setControl(container); + + WizardPageSupport.create(this, context); + } + + private void createLabelAndInputField(Composite container, String labelText, String propertyName, IValidator validator) { + Label label = new Label(container, SWT.NULL); + label.setText(labelText); + + Text text = new Text(container, SWT.BORDER | SWT.SINGLE); + text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + IObservableValue widgetValue = WidgetProperties.text(SWT.Modify).observe(text); + IObservableValue modelValue = PojoObservables.observeValue(model, propertyName); + UpdateValueStrategy targetToModelStrategy = new UpdateValueStrategy(); + targetToModelStrategy.setBeforeSetValidator(validator); + context.bindValue(widgetValue, modelValue, targetToModelStrategy, null); + } + + @Override + public void dispose() { + context.dispose(); + + super.dispose(); + } + + public ProjectModel getProjectInformation() { + return model; + } + + static class ProjectModel { + private String groupId; + private String artifactId; + private String version; + + private String packageName; + + private String thermostatVersion; + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getArtifactId() { + return artifactId; + } + + public void setArtifactId(String artifactId) { + this.artifactId = artifactId; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public String getThermostatVersion() { + return thermostatVersion; + } + + public void setThermostatVersion(String thermostatVersion) { + this.thermostatVersion = thermostatVersion; + } + } +} diff -r 01068177f080 -r eef52fe80553 com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/PluginXmlCreationWizard.java --- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/PluginXmlCreationWizard.java Tue Jun 03 17:32:07 2014 -0400 +++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/PluginXmlCreationWizard.java Tue Jun 03 17:32:08 2014 -0400 @@ -23,7 +23,7 @@ this.selection = selection; setWindowTitle(Messages.PluginXmlCreationWizard_windowTitle); -} + } @Override public void addPages() { diff -r 01068177f080 -r eef52fe80553 com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/PluginXmlProjectSelectionPage.java --- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/PluginXmlProjectSelectionPage.java Tue Jun 03 17:32:07 2014 -0400 +++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/PluginXmlProjectSelectionPage.java Tue Jun 03 17:32:08 2014 -0400 @@ -30,12 +30,15 @@ import com.redhat.thermostat.tools.eclipse.plugin.Messages; public class PluginXmlProjectSelectionPage extends WizardPage { + + static final String PAGE_NAME = "selectProjectForPluginXml"; //$NON-NLS-1$ + private Text containerText; private ISelection selection; public PluginXmlProjectSelectionPage(ISelection selection) { - super("wizardPage"); //$NON-NLS-1$ + super(PAGE_NAME); setTitle(Messages.PluginXmlProjectSelectionPage_title); setDescription(Messages.PluginXmlProjectSelectionPage_description); this.selection = selection; diff -r 01068177f080 -r eef52fe80553 com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizard.java --- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizard.java Tue Jun 03 17:32:07 2014 -0400 +++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizard.java Tue Jun 03 17:32:08 2014 -0400 @@ -11,11 +11,11 @@ import com.redhat.thermostat.tools.eclipse.plugin.Activator; import com.redhat.thermostat.tools.eclipse.plugin.Messages; -import com.redhat.thermostat.tools.eclipse.plugin.wizards.ThermostatProjectCreationWizardPage.ProjectModel; +import com.redhat.thermostat.tools.eclipse.plugin.wizards.NewProjectInformationPage.ProjectModel; public class ThermostatProjectCreationWizard extends Wizard implements INewWizard { - private ThermostatProjectCreationWizardPage pageOne; + private NewProjectInformationPage pageOne; @Override public void init(IWorkbench workbench, IStructuredSelection selection) { @@ -25,7 +25,7 @@ @Override public void addPages() { - pageOne = new ThermostatProjectCreationWizardPage(); + pageOne = new NewProjectInformationPage(); addPage(pageOne); } diff -r 01068177f080 -r eef52fe80553 com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizardPage.java --- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizardPage.java Tue Jun 03 17:32:07 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ -package com.redhat.thermostat.tools.eclipse.plugin.wizards; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.UpdateValueStrategy; -import org.eclipse.core.databinding.beans.PojoObservables; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.core.databinding.validation.IValidator; -import org.eclipse.jface.databinding.swt.WidgetProperties; -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.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -import com.redhat.thermostat.tools.eclipse.plugin.Messages; -import com.redhat.thermostat.tools.eclipse.plugin.Validators; - -public class ThermostatProjectCreationWizardPage extends WizardPage { - - private ProjectModel model = new ProjectModel(); - private DataBindingContext context; - - public ThermostatProjectCreationWizardPage() { - super("wizardPage"); //$NON-NLS-1$ - setTitle(Messages.ThermostatProjectCreationWizardPage_wizardTitle); - setDescription(Messages.ThermostatProjectCreationWizardPage_wizardDescription); - } - - @Override - public void createControl(Composite parent) { - Composite container = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(2, false); - container.setLayout(layout); - - context = new DataBindingContext(); - - createLabelAndInputField(container, Messages.ThermostatProjectCreationWizardPage_groupIdLabel, "groupId", //$NON-NLS-1$ - new Validators.ValidIdRequired(Messages.ThermostatProjectCreationWizardPage_groupIdLabel)); - - createLabelAndInputField(container, Messages.ThermostatProjectCreationWizardPage_artifactIdLabel, "artifactId", //$NON-NLS-1$ - new Validators.ValidIdRequired(Messages.ThermostatProjectCreationWizardPage_artifactIdLabel)); - - createLabelAndInputField(container, Messages.ThermostatProjectCreationWizardPage_versionLabel, "version", //$NON-NLS-1$ - new Validators.NonEmptyStringRequired(Messages.ThermostatProjectCreationWizardPage_versionErrorMessage)); - - createLabelAndInputField(container, Messages.ThermostatProjectCreationWizardPage_packagePrefixLabel, "packageName", //$NON-NLS-1$ - new Validators.PackageNameRequired()); - - createLabelAndInputField(container, Messages.ThermostatProjectCreationWizardPage_thermostatVersionLabel, "thermostatVersion", //$NON-NLS-1$ - new Validators.VersionRequired(Messages.ThermostatProjectCreationWizardPage_thermostatVersionErrorMessage)); - - setControl(container); - - WizardPageSupport.create(this, context); - } - - private void createLabelAndInputField(Composite container, String labelText, String propertyName, IValidator validator) { - Label label = new Label(container, SWT.NULL); - label.setText(labelText); - - Text text = new Text(container, SWT.BORDER | SWT.SINGLE); - text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - IObservableValue widgetValue = WidgetProperties.text(SWT.Modify).observe(text); - IObservableValue modelValue = PojoObservables.observeValue(model, propertyName); - UpdateValueStrategy targetToModelStrategy = new UpdateValueStrategy(); - targetToModelStrategy.setBeforeSetValidator(validator); - context.bindValue(widgetValue, modelValue, targetToModelStrategy, null); - } - - @Override - public void dispose() { - context.dispose(); - - super.dispose(); - } - - public ProjectModel getProjectInformation() { - return model; - } - - static class ProjectModel { - private String groupId; - private String artifactId; - private String version; - - private String packageName; - - private String thermostatVersion; - - public String getGroupId() { - return groupId; - } - - public void setGroupId(String groupId) { - this.groupId = groupId; - } - - public String getArtifactId() { - return artifactId; - } - - public void setArtifactId(String artifactId) { - this.artifactId = artifactId; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getPackageName() { - return packageName; - } - - public void setPackageName(String packageName) { - this.packageName = packageName; - } - - public String getThermostatVersion() { - return thermostatVersion; - } - - public void setThermostatVersion(String thermostatVersion) { - this.thermostatVersion = thermostatVersion; - } - } -}