How can we declare UI? We have got 3 ways
Ok, I see that Wazaabi enable to define the UI as models, and those models are rendered at runtime by engines. But now I want to create a GUI, how can I declare such models?
| Date | Editor | Preview |
|---|---|---|
Wazaabi provides a complete a complete model support for describing UI in SWT, SWING and JSF, but can be extended to other UI technologies.
Ok, I see that Wazaabi enable to define the UI as models, and those models are rendered at runtime by engines. But now I want to create a GUI, how can I declare such models?
Wazaabi API enables developer to directly build the UI as other traditional UI. In this example we build a simple form [The complete JAVA code can be downloaded here].
// create a composite and set its layout
Composite composite = WidgetsFactory.eINSTANCE.createComposite();
GridLayout gridLayout = LayoutsFactory.eINSTANCE.createGridLayout();
composite.setLayout(gridLayout);
//Set the number of columns
gridLayout.setNumColumns(2);
// create two labels with text
Label nameLabel = WidgetsFactory.eINSTANCE.createLabel();
Text nameText = WidgetsFactory.eINSTANCE.createText();
Label addressLabel = WidgetsFactory.eINSTANCE.createLabel();
Text addressText = WidgetsFactory.eINSTANCE.createText();
//Set the labels
nameLabel.setText("Name:");
addressLabel.setText("Address:");
//Save & cancel button
PushButton save = WidgetsFactory.eINSTANCE.createPushButton();
save.setText("Save");
PushButton cancel = WidgetsFactory.eINSTANCE.createPushButton();
cancel.setText("cancel");
//Add to the composite
composite.getChildren().add(nameLabel);
composite.getChildren().add(nameText);
composite.getChildren().add(addressLabel);
composite.getChildren().add(addressText);
composite.getChildren().add(save);
composite.getChildren().add(cancel);
The Wazaabi framework is delivered with declarative editor on which you can simply declare the content and the design of the GUI.