use of com.github.bordertech.wcomponents.Margin in project wcomponents by BorderTech.
the class WRadioButtonTriggerActionExample method setup.
/**
* Add controls to the UI.
*/
private void setup() {
setLayout(new FlowLayout(FlowLayout.VERTICAL));
WFieldSet fset = new WFieldSet("Select a meal");
add(fset);
fset.setMargin(new Margin(null, null, Size.LARGE, null));
WFieldLayout flay = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
fset.add(flay);
flay.setLabelWidth(0);
flay.addField("Breakfast", rb1);
flay.addField("Lunch", rb2);
flay.addField("Dinner", rb3);
/*
* NOTE: you should never use submitOnChange with a WRadioButton
*/
fset.add(new WAjaxControl(mealSelections, textBox));
mealSelections.setActionOnChange(new Action() {
@Override
public void execute(final ActionEvent event) {
String selection = null;
if (rb1.isSelected()) {
selection = "Breakfast selected";
}
if (rb2.isSelected()) {
selection = "Lunch selected";
}
if (rb3.isSelected()) {
selection = "Dinner selected";
}
text1.setText(selection + " : " + (new Date()).toString());
}
});
textBox.add(text1);
add(textBox);
add(mealSelections);
}
use of com.github.bordertech.wcomponents.Margin in project wcomponents by BorderTech.
the class GridLayoutOptionsExample method getLayoutControls.
/**
* build the list controls field set.
*
* @param errors the error box to be linked to the apply button.
* @return a field set for the controls.
*/
private WFieldSet getLayoutControls(final WValidationErrors errors) {
// Options Layout
WFieldSet fieldSet = new WFieldSet("List configuration");
WFieldLayout layout = new ControlFieldLayout();
fieldSet.add(layout);
// options.
columnCount.setDecimalPlaces(0);
columnCount.setMinValue(0);
columnCount.setNumber(DEFAULT_COLUMN_COUNT);
columnCount.setMandatory(true);
layout.addField("Number of Columns", columnCount);
rowCount.setDecimalPlaces(0);
rowCount.setMinValue(0);
rowCount.setNumber(DEFAULT_ROW_COUNT);
rowCount.setMandatory(true);
layout.addField("Number of Rows", rowCount);
hGap.setDecimalPlaces(0);
hGap.setMinValue(0);
hGap.setNumber(0);
hGap.setMandatory(true);
layout.addField("Horizontal Gap", hGap);
vGap.setDecimalPlaces(0);
vGap.setMinValue(0);
vGap.setNumber(0);
vGap.setMandatory(true);
layout.addField("Vertical Gap", vGap);
boxCount.setDecimalPlaces(0);
boxCount.setMinValue(0);
boxCount.setNumber(DEFAULT_BOX_COUNT);
boxCount.setMandatory(true);
layout.addField("Number of Boxes", boxCount);
layout.addField("Visible", cbVisible);
layout.addField("Allow responsive design", cbResponsive);
// Apply Button
WButton apply = new WButton("Apply");
apply.setAction(new ValidatingAction(errors, this) {
@Override
public void executeOnValid(final ActionEvent event) {
applySettings();
}
});
layout.addField(apply);
fieldSet.add(new WAjaxControl(apply, container));
fieldSet.setMargin(new Margin(null, null, Size.LARGE, null));
return fieldSet;
}
use of com.github.bordertech.wcomponents.Margin in project wcomponents by BorderTech.
the class RepeaterExampleWithStaticIDs method createButtonBar.
/**
* Create the UI artefacts for the update and reset buttons.
*/
private void createButtonBar() {
// Update and reset controls for the repeater.
WPanel buttonPanel = new WPanel(WPanel.Type.FEATURE);
buttonPanel.setMargin(new Margin(Size.MEDIUM, null, Size.LARGE, null));
buttonPanel.setLayout(new BorderLayout());
WButton updateButton = new WButton("Update");
updateButton.setImage("/image/document-save-5.png");
updateButton.setImagePosition(WButton.ImagePosition.EAST);
buttonPanel.add(updateButton, BorderLayout.EAST);
WButton resetButton = new WButton("Reset");
resetButton.setImage("/image/edit-undo-8.png");
resetButton.setImagePosition(WButton.ImagePosition.WEST);
resetButton.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
repeater.setData(fetchDataList());
}
});
buttonPanel.add(resetButton, BorderLayout.WEST);
add(buttonPanel);
add(new WAjaxControl(updateButton, repeater));
add(new WAjaxControl(resetButton, repeater));
}
use of com.github.bordertech.wcomponents.Margin in project wcomponents by BorderTech.
the class WLabelExample method addNestedFieldExamples.
/**
* Examples showing WLabel with a nested input control WComponent.
* This is VERY dangerous as only a very few WComponents are valid for this scenario. If you go down this route: stop!!
* These are really here for framework testing, not as examples as to how to do things.
*/
private void addNestedFieldExamples() {
add(new WHeading(HeadingLevel.H2, "Label nesting which is technically OK"));
/* Just because it is OK to do this does not mean you should! So these "examples" have far fewer comments. */
WPanel errorLayoutPanel = new WPanel();
errorLayoutPanel.setLayout(new FlowLayout(FlowLayout.VERTICAL, Size.LARGE));
errorLayoutPanel.setMargin(new Margin(null, null, Size.XL, null));
add(errorLayoutPanel);
errorLayoutPanel.add(new ExplanatoryText("This example shows WLabels with a single nested simple form control WTextField." + " This is not a contravention of the HTML specification but you should not do it."));
WLabel outerLabel = new WLabel("Label with nested WTextField and not 'for' anything");
errorLayoutPanel.add(outerLabel);
outerLabel.add(new WTextField());
WTextField innerField = new WTextField();
outerLabel = new WLabel("Label 'for' nested WTextField", innerField);
errorLayoutPanel.add(outerLabel);
outerLabel.add(innerField);
}
use of com.github.bordertech.wcomponents.Margin in project wcomponents by BorderTech.
the class MarginRendererUtil method renderMargin.
/**
* @param component the marginable component to paint a margin
* @param renderContext the RenderContext to paint to.
*/
public static void renderMargin(final Marginable component, final WebXmlRenderContext renderContext) {
Margin margin = component.getMargin();
if (margin == null) {
return;
}
XmlStringBuilder xml = renderContext.getWriter();
if (margin.getMargin() != null) {
xml.appendTagOpen("ui:margin");
xml.appendAttribute("all", margin.getMargin().toString());
xml.appendEnd();
} else if (margin.getTop() != null || margin.getRight() != null || margin.getBottom() != null || margin.getLeft() != null) {
xml.appendTagOpen("ui:margin");
Size size = margin.getTop();
if (size != null) {
xml.appendAttribute("north", size.toString());
}
size = margin.getRight();
if (size != null) {
xml.appendAttribute("east", size.toString());
}
size = margin.getBottom();
if (size != null) {
xml.appendAttribute("south", size.toString());
}
size = margin.getLeft();
if (size != null) {
xml.appendAttribute("west", size.toString());
}
xml.appendEnd();
}
}
Aggregations