I work with Vaadin. I have a text field and a button. My button is initially disabled. When my text field is filled with valid data my button must activate. I can not activate my button. Could you help me ? Thank you
public static DynTextField createFromElement(Element elt, DynForm form) {
if (elt.getNodeName().equals("param") && elt.getAttribute("type").equals("TEXT")) {
DynTextField dtf = new DynTextField();
dtf.setForm(form);
if (elt.hasAttribute("texte"))
dtf.setCaption(elt.getAttribute("texte"));
dtf.nom = elt.getAttribute("nom");
if (elt.hasAttribute("FORMAT"))
dtf.setFormat(elt.getAttribute("FORMAT"));
dtf.setDescription(elt.getAttribute("description"));
dtf.setStyleName("param" + (elt.hasAttribute("class") ? elt.getAttribute("class") : ""));
return dtf;
} else
return null;
}
private void setFormat(String attribute) {
binder = new Binder<>();
binder.forField(this).withValidator(new RegexpValidator("Saisie obligatoire !!", attribute)).asRequired("Format Erroné").bind(No.getter(), No.setter());
//new Binder<>().forField(this).withValidator(new RegexpValidator(attribute, "Format Erroné")).asRequired();
}
// convenience empty getter and setter implementation for better readability
public static class No {
public static <SOURCE, TARGET> ValueProvider<SOURCE, TARGET> getter() {
return source -> null;
}
public static <BEAN, FIELDVALUE> Setter<BEAN, FIELDVALUE> setter() {
return (bean, fieldValue) -> {
//no op
};
}
}
The program that creates my button. This is where I would like to make my button active.
public DynButton(DynForm form, String as400PGMName, String[] parameterList) {
super(VaadinIcons.CHECK);
this.as400PGMName = as400PGMName;
if (parameterList.length == 1 && parameterList[0].equals(""))
this.parameterList = new String[] {};
else
this.parameterList = parameterList;
this.form = form;
addClickListener(event -> {
fireClickEvent(event);
});
addClickListener(this);
impl = new DynComponentImpl();
//boutton initially disable
this.setEnabled(isActif());
}
You can do it with a listener on either the text field or the binder
textField.addValueChangeListener(e ->
myButton.setEnabled(!e.getValue().equals("")));
or
binder.addStatusChangeListener(e ->
myButton.setEnabled(!e.hasValidationErrors()));
Related
We do have got preference page:
public class PreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage
{
// another preferences...
// add checkbox - enable export path setting
Composite exportPathControl = getFieldEditorParent();
exportPathC = new BooleanFieldEditor(PreferenceConstants.P_SETEXPORTPATHPREFERENCEPAGE, SetExportPathStrPref, exportPathControl);
addField(exportPathC);
boolean enableSetExportPathControl = Activator.getDefault().
getPreferenceStore().getBoolean(PreferenceConstants.P_SETEXPORTPATHPREFERENCEPAGE);
boolean checked = exportPathC.getBooleanValue();
// Path
setExportPathControl = getFieldEditorParent();
browserFE = new CustomDirectoryFieldEditor(PreferenceConstants.P_EXPORTPATHPREFERENCEPAGE,
ExportPathStrPref, setExportPathControl ,enableSetExportPathControl);
browserFE.setEmptyStringAllowed(false);
addField(browserFE);
// enable/disable export path DirectoryFieldEditor according to exportPathC
browserFE.setEnabled(enableSetExportPathControl, setExportPathControl);
((Button) exportPathC.getDescriptionControl(exportPathControl)).addSelectionListener(exportPathControlListener());
}
We do need avoid of checking browserFE if is disabled (exportPathC is deselected). We handled error message with browserFE.enableValidation(setExportPathEnabled):
// enable/disable possibility to set path according BooleanFieldEditor exportPathC
private SelectionListener exportPathControlListener()
{
return new SelectionListener()
{
#Override
public void widgetSelected(SelectionEvent event)
{
if (event.widget instanceof Button)
{
Boolean setExportPathEnabled = ((Button) event.widget).getSelection();
browserFE.setEnabled(setExportPathEnabled, setExportPathControl);
browserFE.enableValidation(setExportPathEnabled);
browserFE.checkState();
}
}
#Override
public void widgetDefaultSelected(SelectionEvent e)
{
widgetSelected(e);
}
};
}
But how to enable Apply button?
There is org.eclipse.jface.preference.FieldEditorPreferencePage.checkState(), but protected.
We could override org.eclipse.jface.preference.PreferencePage.isValid() and set it's output to true, but what is more paths are wrong? We do knot know, which path causes trouble, org.eclipse.jface.preference.FieldEditorPreferencePage.invalidFieldEditor is private as well.
Any idea? Thanks for any hint!!
Trying to upgrade from 6 to 7 VAADIN getting the following error.
I new to Java and Vaadin any help would be nice.
Thanks
Description Resource Path Location Type
The method getMainWindow() is undefined for the type
private void periodicRefresh() {
// Logout if requested
if (mKicker != null) {
String kickMessage = KickoutMessageText + mKicker.getData().getName();
mKicker = null;
logoutCore();
getMainWindow().showNotification(KickoutMessageTitle, kickMessage, Notification.TYPE_WARNING_MESSAGE);
}
// Refresh logged in users
refreshLoggedInUsers();
// Refresh GPIO pin states
refreshGPIOPinStates();
}
Second problem:
Description Resource Path Location Type
The method getMainWindow() is undefined for the type new LoginForm.LoginListener()
also in same code
Description Resource Path Location Type
The method addComponent(LoginForm) is undefined for the type Panel
private void createLoginUI(final AbstractOrderedLayout parentLayout) {
final Rpi_gpio_controllerApplication application = this;
LoginForm loginForm = new LoginForm();
loginForm.addListener(new LoginForm.LoginListener() {
Rpi_gpio_controllerApplication mApplication = application;
#Override
public void onLogin(LoginEvent event) {
String loginErrorMessage = new User(
new UserData(event.getLoginParameter("username"), event.getLoginParameter("password")),
mApplication).login();
if (loginErrorMessage != null) {
Notification notification = new Notification(LoginErrorMessage, loginErrorMessage,
Notification.TYPE_ERROR_MESSAGE);
notification.setDelayMsec(1000);
getMainWindow().showNotification(notification);
}
}
});
Panel loginPanel = new Panel("Log in!!!!");
loginPanel.setWidth("200px");
loginPanel.setHeight("250px");
loginPanel.addComponent(loginForm);
parentLayout.addComponent(loginPanel);
parentLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}
1st the notification are used in other way:
Notification.show(KickoutMessageTitle, kickMessage, Notification.TYPE_WARNING_MESSAGE);
2nd - panel in 6 has a default content and You can add components to it,
in version 7 the content must be set by You.
Solution - create a Layout (contentLayout) and use setContent(contentLayout)
then add other components to the contentLayout
If You need to get a Window (like the getMainWindowMethod) in vaadin 7 You need to use:
UI.getCurrent().getWindow()
EDIT:
1:
private void periodicRefresh() {
// Logout if requested
if (mKicker != null) {
String kickMessage = KickoutMessageText + mKicker.getData().getName();
mKicker = null;
logoutCore();
Notification.show(KickoutMessageTitle, kickMessage, Notification.TYPE_WARNING_MESSAGE);
}
// Refresh logged in users
refreshLoggedInUsers();
// Refresh GPIO pin states
refreshGPIOPinStates();
}
2:
private void createLoginUI(final AbstractOrderedLayout parentLayout) {
final Rpi_gpio_controllerApplication application = this;
LoginForm loginForm = new LoginForm();
loginForm.addListener(new LoginForm.LoginListener() {
Rpi_gpio_controllerApplication mApplication = application;
#Override
public void onLogin(LoginEvent event) {
String loginErrorMessage = new User(
new UserData(event.getLoginParameter("username"), event.getLoginParameter("password")),
mApplication).login();
if (loginErrorMessage != null) {
Notification notification = new Notification(LoginErrorMessage, loginErrorMessage,
Notification.TYPE_ERROR_MESSAGE);
notification.setDelayMsec(1000);
notification.show(Page.getCurrent());
}
}
});
Panel loginPanel = new Panel("Log in!!!!");
loginPanel.setWidth("200px");
loginPanel.setHeight("250px");
loginPanel.setContent(loginForm);
parentLayout.addComponent(loginPanel);
parentLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}
I'm using JavaFX and Scene Builder and I have a form with textfields. Three of these textfields are parsed from strings to doubles.
I want them to be school marks so they should only be allowed to be between 1.0 and 6.0. The user should not be allowed to write something like "2.34.4" but something like "5.5" or "2.9" would be ok.
Validation for the parsed fields:
public void validate(KeyEvent event) {
String content = event.getCharacter();
if ("123456.".contains(content)) {
// No numbers smaller than 1.0 or bigger than 6.0 - How?
} else {
event.consume();
}
}
How can I test if the user inputs a correct value?
I already searched on Stackoverflow and on Google but I didn't find a satisfying solution.
textField.focusedProperty().addListener((arg0, oldValue, newValue) -> {
if (!newValue) { //when focus lost
if(!textField.getText().matches("[1-5]\\.[0-9]|6\\.0")){
//when it not matches the pattern (1.0 - 6.0)
//set the textField empty
textField.setText("");
}
}
});
you could also change the pattern to [1-5](\.[0-9]){0,1}|6(.0){0,1} then 1,2,3,4,5,6would also be ok (not only 1.0,2.0,...)
update
Here is a small test application with the values 1(.00) to 6(.00) allowed:
public class JavaFxSample extends Application {
#Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Enter number and hit the button");
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
Label label1To6 = new Label("1.0-6.0:");
grid.add(label1To6, 0, 1);
TextField textField1To6 = new TextField();
textField1To6.focusedProperty().addListener((arg0, oldValue, newValue) -> {
if (!newValue) { // when focus lost
if (!textField1To6.getText().matches("[1-5](\\.[0-9]{1,2}){0,1}|6(\\.0{1,2}){0,1}")) {
// when it not matches the pattern (1.0 - 6.0)
// set the textField empty
textField1To6.setText("");
}
}
});
grid.add(textField1To6, 1, 1);
grid.add(new Button("Hit me!"), 2, 1);
Scene scene = new Scene(grid, 300, 275);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
I would not advise you to use KeyEvent for that.
You should use a more classical way such as validated the user input when the user finish to fill the text field or click on a save button.
/**
* Called this when the user clicks on the save button or finish to fill the text field.
*/
private void handleSave() {
// If the inputs are valid we save the data
if(isInputValid()){
note=(DOUBLE.parseDouble(textField.getText()));
}else // do something such as notify the user and empty the field
}
/**
* Validates the user input in the text fields.
*
* #return true if the input is valid
*/
private boolean isInputValid() {
Boolean b= false;
if (!(textField.getText() == null || textFiled.getText().length() == 0)) {
try {
// Do all the validation you need here such as
Double d = Double.parseInt(textFiled.getText());
if ( 1.0<d<6.0){
b=true;
}
} catch (NumberFormatException e) {
}
return b;
}
You can prevent illegal input using TextFormatter:
final Pattern pattern = Pattern.compile("(6\\.0)|([1-5]\\.[0-9])");
textField.setTextFormatter(new TextFormatter<>(new DoubleStringConverter(), 0.0, change -> {
final Matcher matcher = pattern.matcher(change.getControlNewText());
return (matcher.matches() || matcher.hitEnd()) ? change : null;
}));
In case you can use a third party library:
Similar question has been aswered here: Form validator message
.
For your case, you would choose a RegexValidator to check the textfield input, and pass the regex that you arrived to from previous answers:
JFXTextField validationField = new JFXTextField();
validationField.setPromptText("decimal between 1.0 and 6.0");
RegexValidator validator = new RegexValidator();
validator.setRegexPattern("[1-5](\\.[0-9]{1,2}){0,1}|6(\\.0{1,2}){0,1}");
validator.setMessage("Please enter proper value");
validationField.getValidators().add(validator);
validationField.focusedProperty().addListener((observable, oldValue, newValue) -> {
if(!newValue)
validationField.validate();
});
You can make a custom TextField that does input validation if you want.
import java.awt.Toolkit;
import javafx.event.EventHandler;
import javafx.scene.control.TextField;
import javafx.scene.control.TextInputControl;
import javafx.scene.input.KeyEvent;
/**
* A text field that limits the user to certain number of characters and
* prevents the user from typing certain characters
*
*
*/
public class CustomTextField extends TextField
{
/**
* The maximum number of characters this text field will allow
* */
private int maxNumOfCharacters;
/**
* A regular expression of characters that this text field does not allow
* */
private String unallowedCharactersRegEx;
/*
* If no max number of characters is specified the default value is set
* */
private static final int DEFAULT_MAX_NUM_OF_CHARACTERS = 1000;
public CustomTextField()
{
maxNumOfCharacters = DEFAULT_MAX_NUM_OF_CHARACTERS;
this.setOnKeyTyped(new EventHandler<KeyEvent>() {
public void handle(KeyEvent event)
{
// get the typed character
String characterString = event.getCharacter();
char c = characterString.charAt(0);
// if it is a control character or it is undefined, ignore it
if (Character.isISOControl(c) || characterString.contentEquals(KeyEvent.CHAR_UNDEFINED))
return;
// get the text field/area that triggered this key event and its text
TextInputControl source = (TextInputControl) event.getSource();
String text = source.getText();
// If the text exceeds its max length or if a character that matches
// notAllowedCharactersRegEx is typed
if (text.length() > maxNumOfCharacters
|| (unallowedCharactersRegEx != null && characterString.matches(unallowedCharactersRegEx)))
{
// remove the last character
source.deletePreviousChar();
// make a beep sound effect
Toolkit.getDefaultToolkit().beep();
}
}
});
}
public int getMaxNumOfCharacters()
{
return maxNumOfCharacters;
}
public void setMaxNumOfCharacters(int maxNumOfCharacters)
{
this.maxNumOfCharacters = maxNumOfCharacters;
}
public String getUnallowedCharactersRegEx()
{
return unallowedCharactersRegEx;
}
public void setUnallowedCharactersRegEx(String notAllowedRegEx)
{
this.unallowedCharactersRegEx = notAllowedRegEx;
}
}
My problem is annoying. My server side is generating 12 random numbers (double here).
My Client side received the correct data but nothing is displayed in my Chart. That worked fine with hardcoded data in the store but not with a REST call.
The transfer between my server and my client is that :
[{"key":"key0","value":0.47222548599297787},{"key":"key1","value":0.6009173797369691},{"key":"key2","value":0.13880104282435624},{"key":"key3","value":0.01804674319345545},{"key":"key4","value":0.5547733564202956},{"key":"key5","value":0.8229999661308851},{"key":"key6","value":0.8959346004391032},{"key":"key7","value":0.6848052288628435},{"key":"key8","value":0.10222856671111813},{"key":"key9","value":0.6931371931409103},{"key":"key10","value":0.2994297934549003},{"key":"key11","value":0.47566752196381334}]
Here my simple class used for my test. I am a newbie with GXT 3
public void onModuleLoad() {
final ListStore<JSOModel> store;
final ContentPanel panel = new FramedPanel();
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "/ws/DocumentService/v1/test");
builder.setHeader("Accept", "application/json");
HttpProxy proxy = new HttpProxy(builder);
final Loader<ListLoadConfig, ListLoadResult<JSOModel>> loader = new ListLoader<ListLoadConfig, ListLoadResult<JSOModel>>(proxy, new DataReader<ListLoadResult<JSOModel>, String>() {
#Override
public ListLoadResult<JSOModel> read(Object loadConfig, String data) {
List<JSOModel> jsoModels = new ArrayList<JSOModel>();
JsArray<JSOModel> jsoModelJsArray = JSOModel.arrayFromJson(data);
if(jsoModelJsArray != null) {
for(int i = 0; i < jsoModelJsArray.length(); i++) {
jsoModels.add(jsoModelJsArray.get(i));
}
}
return new ListLoadResultBean<JSOModel>(jsoModels);
}
});
store = new ListStore<JSOModel>(new ModelKeyProvider<JSOModel>() {
#Override
public String getKey(JSOModel item) {
return item.get("key");
}
});
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, JSOModel, ListLoadResult<JSOModel>>(store) {
#Override
public void onLoad(LoadEvent<ListLoadConfig, ListLoadResult<JSOModel>> event) {
ListLoadResult<JSOModel> loaded = event.getLoadResult();
if(loaded.getData() == null) {
store.replaceAll(new ArrayList<JSOModel>());
} else {
store.replaceAll(loaded.getData());
}
}
});
Chart<JSOModel> chart = new Chart<JSOModel>();
chart.setStore(store);
chart.setShadowChart(true);
NumericAxis<JSOModel> axis = new NumericAxis<JSOModel>();
axis.setPosition(Chart.Position.LEFT);
axis.addField(new ValueProvider<JSOModel, Number>() {
#Override
public Number getValue(JSOModel JSOModel) {
return JSOModel.getNumber("value");
}
#Override
public void setValue(JSOModel JSOModel, Number number) {
}
#Override
public String getPath() {
return "key";
}
});
axis.setTitleConfig(new TextSprite("Number of hits"));
axis.setWidth(50);
axis.setMinimum(0);
axis.setMaximum(100);
chart.addAxis(axis);
PathSprite odd = new PathSprite();
odd.setOpacity(1);
odd.setFill(new Color("#dff"));
odd.setStroke(new Color("#aaa"));
odd.setStrokeWidth(0.5);
axis.setGridOddConfig(odd);
CategoryAxis<JSOModel, String> horizontalAxis = new CategoryAxis<JSOModel, String>();
horizontalAxis.setPosition(Chart.Position.BOTTOM);
horizontalAxis.setField(new ValueProvider<JSOModel, String>() {
#Override
public String getValue(JSOModel JSOModel) {
return JSOModel.get("key");
}
#Override
public void setValue(JSOModel JSOModel, String s) {
}
#Override
public String getPath() {
return "key";
}
});
horizontalAxis.setTitleConfig(new TextSprite("month of year"));
chart.addAxis(horizontalAxis);
LineSeries<JSOModel> column = new LineSeries<JSOModel>();
column.setYAxisPosition(Chart.Position.LEFT);
column.setStroke(new RGB(148,174,10));
column.setHighlighting(true);
chart.addSeries(column);
axis.addField(column.getYField());
chart.addSeries(column);
chart.setHeight(100);
chart.setWidth(100);
Button b = new Button("ha");
b.addClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent clickEvent) {
loader.load();
}
});
RootPanel.get().add(b);
panel.setCollapsible(true);
panel.setHeadingText("Column Chart");
panel.setPixelSize(620, 500);
panel.setBodyBorder(true);
VerticalLayoutContainer layout = new VerticalLayoutContainer();
panel.add(layout);
chart.setLayoutData(new VerticalLayoutContainer.VerticalLayoutData(1,1));
layout.add(chart);
chart.setBackground(new Color("#dff"));
RootPanel.get().add(panel);
There are two ways to wire the chart into a store. One is to simply specify that the chart is using a store via setStore, as you have done:
chart.setStore(store);
When you do this, you must also inform the chart when it must redraw everything - you must call:
chart.redrawChart();
This call must be made shortly after the load is completed - consider doing it at the end of onLoad.
Why is this required? In some cases, developers want to make many changes to the store, one at a time, and if the chart automatically updated after each change, that would spawn many slow changes to the data model, and could end up looking strange. In a case like this, you would only call redrawChart() after all changes were complete.
There is another option however - instead of calling setStore, you can call bindStore, and ask the Chart to automatically update whenever any change occurs to the chart:
chart.bindStore(store);
In your case, this is likely the correct answer.
I need a wizard which second page content depends on the first page's selection. The first page asks the user the "kind" of filter he wants to create and the second one asks the user to create one filter instance of the selected "kind".
JFace's wizards pages contents (createControl(...) method) are all created when the wizard is open and not when a given page is displayed (this allow JFace to know the wizard size I guess ??).
Because of this, I have to create my second page content BEFORE the wizard is opened BUT I can't since the second page's content depends on the first page selection.
For now the cleaner solution I found consists in creating all (seconds) pages before the wizard is open (with their content) and override the getNextPage() method in the first page's implementation.
The main drawback of that solution is that it can be be expensive when there are many second pages to create.
What do you think about that solution ? How do you manage your wizard's pages ? Is there any cleaner solution I missed ?
The approach is right if you are several other pages which are
completely different one with another
depends on the previous choices made in a previous page
Then you can add the next page dynamically (also as described here)
But if you have just a next page with a dynamic content, you should be able to create that content in the onEnterPage() method
public void createControl(Composite parent)
{
//
// create the composite to hold the widgets
//
this.composite = new Composite(parent, SWT.NONE);
//
// create the desired layout for this wizard page
//
GridLayout layout = new GridLayout();
layout.numColumns = 4;
this.composite.setLayout(layout);
// set the composite as the control for this page
setControl(this.composite);
}
void onEnterPage()
{
final MacroModel model = ((MacroWizard) getWizard()).model;
String selectedKey = model.selectedKey;
String[] attrs = (String[]) model.macroMap.get(selectedKey);
for (int i = 0; i < attrs.length; i++)
{
String attr = attrs[i];
Label label = new Label(this.composite, SWT.NONE);
label.setText(attr + ":");
new Text(this.composite, SWT.NONE);
}
pack();
}
As shown in the eclipse corner article Creating JFace Wizards:
We can change the order of the wizard pages by overwriting the getNextPage method of any wizard page.Before leaving the page, we save in the model the values chosen by the user. In our example, depending on the choice of travel the user will next see either the page with flights or the page for travelling by car.
public IWizardPage getNextPage(){
saveDataToModel();
if (planeButton.getSelection()) {
PlanePage page = ((HolidayWizard)getWizard()).planePage;
page.onEnterPage();
return page;
}
// Returns the next page depending on the selected button
if (carButton.getSelection()) {
return ((HolidayWizard)getWizard()).carPage;
}
return null;
}
We define a method to do this initialization for the PlanePage, onEnterPage() and we invoke this method when moving to the PlanePage, that is in the getNextPage() method for the first page.
If you want to start a new wizard based on your selection on the first page, you can use the JFace base class org.eclipse.jface.wizard.WizardSelectionPage.
The example below shows a list of available wizards defined by an extension point.
When you press Next, the selected wizard is started.
public class ModelSetupWizardSelectionPage extends WizardSelectionPage {
private ComboViewer providerViewer;
private IConfigurationElement selectedProvider;
public ModelSetupWizardSelectionPage(String pageName) {
super(pageName);
}
private class WizardNode implements IWizardNode {
private IWizard wizard = null;
private IConfigurationElement configurationElement;
public WizardNode(IConfigurationElement c) {
this.configurationElement = c;
}
#Override
public void dispose() {
}
#Override
public Point getExtent() {
return new Point(-1, -1);
}
#Override
public IWizard getWizard() {
if (wizard == null) {
try {
wizard = (IWizard) configurationElement
.createExecutableExtension("wizardClass");
} catch (CoreException e) {
}
}
return wizard;
}
#Override
public boolean isContentCreated() {
// TODO Auto-generated method stub
return wizard != null;
}
}
#Override
public void createControl(Composite parent) {
setTitle("Select model provider");
Composite main = new Composite(parent, SWT.NONE);
GridLayout gd = new GridLayout(2, false);
main.setLayout(gd);
new Label(main, SWT.NONE).setText("Model provider");
Combo providerList = new Combo(main, SWT.NONE);
providerViewer = new ComboViewer(providerList);
providerViewer.setLabelProvider(new LabelProvider() {
#Override
public String getText(Object element) {
if (element instanceof IConfigurationElement) {
IConfigurationElement c = (IConfigurationElement) element;
String result = c.getAttribute("name");
if (result == null || result.length() == 0) {
result = c.getAttribute("class");
}
return result;
}
return super.getText(element);
}
});
providerViewer
.addSelectionChangedListener(new ISelectionChangedListener() {
#Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (!selection.isEmpty()
&& selection instanceof IStructuredSelection) {
Object o = ((IStructuredSelection) selection)
.getFirstElement();
if (o instanceof IConfigurationElement) {
selectedProvider = (IConfigurationElement) o;
setMessage(selectedProvider.getAttribute("description"));
setSelectedNode(new WizardNode(selectedProvider));
}
}
}
});
providerViewer.setContentProvider(new ArrayContentProvider());
List<IConfigurationElement> providers = new ArrayList<IConfigurationElement>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extensionPoint = registry
.getExtensionPoint(<your extension point namespace>,<extension point name>);
if (extensionPoint != null) {
IExtension extensions[] = extensionPoint.getExtensions();
for (IExtension extension : extensions) {
IConfigurationElement configurationElements[] = extension
.getConfigurationElements();
for (IConfigurationElement c : configurationElements) {
providers.add(c);
}
}
}
providerViewer.setInput(providers);
setControl(main);
}
The corresponding wizard class looks like this:
public class ModelSetupWizard extends Wizard {
private ModelSetupWizardSelectionPage wizardSelectionPage;
public ModelSetupWizard() {
setForcePreviousAndNextButtons(true);
}
#Override
public boolean performFinish() {
// Do what you have to do to finish the wizard
return true;
}
#Override
public void addPages() {
wizardSelectionPage = new ModelSetupWizardSelectionPage("Select a wizard");
addPage(wizardSelectionPage);
}
}
Another alternative is to #Override setVisible. You can update page values or add additional widgets at that time.
I have a different solution.
If page depends on the result of page 1, create a variable and pass it into to first page, when that wizard page has the option from the user, then the last thing before the page is closed is to set the variable to the required value.
Then pass this variable to wizard, then pass it to the next wizard page. Then do a simple if statement and that way you get both choices together.
Remember that in most code there is only a small difference in the user options, so remember not to get bogged down in duplicating your code.