# HG changeset patch # User Omair Majid # Date 1407851452 14400 # Node ID ee8e92ed83ba7fc76f83b7699d2a8d4727abdb87 # Parent 90f52517b76405920b6034a0c7e6162bf79545ae Add hints for fields in new project dialog Add some hints to clarify/illustrate what valid contents of fields in the new project dailog might look like. diff -r 90f52517b764 -r ee8e92ed83ba 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 Thu Jul 17 15:08:31 2014 -0400 +++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/Messages.java Tue Aug 12 09:50:52 2014 -0400 @@ -76,12 +76,17 @@ public static String PluginXmlProjectSelectionPage_projectNameLabel; public static String PluginXmlProjectSelectionPage_title; public static String ThermostatProjectCreationWizard_dialogTitle; + public static String NewProjectInformationPage_artifactIdHint; public static String NewProjectInformationPage_artifactIdLabel; + public static String NewProjectInformationPage_groupIdHint; public static String NewProjectInformationPage_groupIdLabel; + public static String NewProjectInformationPage_packagePrefixHint; public static String NewProjectInformationPage_packagePrefixLabel; public static String NewProjectInformationPage_thermostatVersionErrorMessage; + public static String NewProjectInformationPage_thermostatVersionHint; public static String NewProjectInformationPage_thermostatVersionLabel; public static String NewProjectInformationPage_versionErrorMessage; + public static String NewProjectInformationPage_versionHint; public static String NewProjectInformationPage_versionLabel; public static String NewProjectInformationPage_wizardDescription; public static String NewProjectInformationPage_wizardTitle; diff -r 90f52517b764 -r ee8e92ed83ba 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 Thu Jul 17 15:08:31 2014 -0400 +++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/messages.properties Tue Aug 12 09:50:52 2014 -0400 @@ -68,12 +68,17 @@ PluginXmlProjectSelectionPage_projectNameLabel=&Project: PluginXmlProjectSelectionPage_title=Thermostat Wizard ThermostatProjectCreationWizard_dialogTitle=Create New Thermostat Plugin +NewProjectInformationPage_artifactIdHint=Enter a suitable maven artifactId. NewProjectInformationPage_artifactIdLabel=Artifact Id +NewProjectInformationPage_groupIdHint=Enter a suitable maven groupId. NewProjectInformationPage_groupIdLabel=Group Id +NewProjectInformationPage_packagePrefixHint=Enter the package prefix. Something like 'com.yourcompany' or 'org.repository.project' NewProjectInformationPage_packagePrefixLabel=Package Prefix NewProjectInformationPage_thermostatVersionErrorMessage=Invalid thermostat version +NewProjectInformationPage_thermostatVersionHint=Enter the Thermostat version you are targetting. If you don't know, 1.0 is a good idea. NewProjectInformationPage_thermostatVersionLabel=Thermostat Version NewProjectInformationPage_versionErrorMessage=Version must not be empty +NewProjectInformationPage_versionHint=Entera a suitable version valid for a maven project NewProjectInformationPage_versionLabel=Version NewProjectInformationPage_wizardDescription=This wizard creates a new Thermostat Plugin. NewProjectInformationPage_wizardTitle=Thermostat projects Wizard diff -r 90f52517b764 -r ee8e92ed83ba com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/NewProjectInformationPage.java --- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/NewProjectInformationPage.java Thu Jul 17 15:08:31 2014 -0400 +++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/NewProjectInformationPage.java Tue Aug 12 09:50:52 2014 -0400 @@ -1,18 +1,23 @@ package com.redhat.thermostat.tools.eclipse.plugin.wizards; +import org.eclipse.core.databinding.Binding; 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.fieldassist.ControlDecorationSupport; import org.eclipse.jface.databinding.swt.WidgetProperties; -import org.eclipse.jface.databinding.wizard.WizardPageSupport; +import org.eclipse.jface.dialogs.DialogPage; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; 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.Shell; import org.eclipse.swt.widgets.Text; import com.redhat.thermostat.tools.eclipse.plugin.Messages; @@ -39,37 +44,71 @@ context = new DataBindingContext(); - createLabelAndInputField(container, Messages.NewProjectInformationPage_groupIdLabel, "groupId", //$NON-NLS-1$ + createLabelAndInputField(container, + Messages.NewProjectInformationPage_groupIdLabel, + Messages.NewProjectInformationPage_groupIdHint, + "groupId", //$NON-NLS-1$ new Validators.ValidIdRequired(Messages.NewProjectInformationPage_groupIdLabel)); - createLabelAndInputField(container, Messages.NewProjectInformationPage_artifactIdLabel, "artifactId", //$NON-NLS-1$ + createLabelAndInputField(container, + Messages.NewProjectInformationPage_artifactIdLabel, + Messages.NewProjectInformationPage_artifactIdHint, + "artifactId", //$NON-NLS-1$ new Validators.ValidIdRequired(Messages.NewProjectInformationPage_artifactIdLabel)); - createLabelAndInputField(container, Messages.NewProjectInformationPage_versionLabel, "version", //$NON-NLS-1$ + createLabelAndInputField(container, + Messages.NewProjectInformationPage_versionLabel, + Messages.NewProjectInformationPage_versionHint, + "version", //$NON-NLS-1$ new Validators.NonEmptyStringRequired(Messages.NewProjectInformationPage_versionErrorMessage)); - createLabelAndInputField(container, Messages.NewProjectInformationPage_packagePrefixLabel, "packageName", //$NON-NLS-1$ + createLabelAndInputField(container, + Messages.NewProjectInformationPage_packagePrefixLabel, + Messages.NewProjectInformationPage_packagePrefixHint, + "packageName", //$NON-NLS-1$ new Validators.PackageNameRequired()); - createLabelAndInputField(container, Messages.NewProjectInformationPage_thermostatVersionLabel, "thermostatVersion", //$NON-NLS-1$ + createLabelAndInputField(container, + Messages.NewProjectInformationPage_thermostatVersionLabel, + Messages.NewProjectInformationPage_thermostatVersionHint, + "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) { + private void createLabelAndInputField(Composite container, String labelText, String hint, 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)); + + hookHintToDialog(container.getShell(), text, hint); + 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); + Binding binding = context.bindValue(widgetValue, modelValue, targetToModelStrategy, null); + ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT); + } + + private void hookHintToDialog(Shell shell, Text text, final String hint) { + text.addFocusListener(new FocusListener() { + private String oldMessage; + private int oldType; + @Override + public void focusGained(FocusEvent e) { + oldMessage = NewProjectInformationPage.this.getMessage(); + oldType = NewProjectInformationPage.this.getMessageType(); + NewProjectInformationPage.this.setMessage(hint, DialogPage.INFORMATION); + } + @Override + public void focusLost(FocusEvent e) { + NewProjectInformationPage.this.setMessage(oldMessage, oldType); + } + }); } @Override