use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class RepeaterExampleWithStaticIDs method createPrintContactsSubForm.
/**
* Create the UI artefacts for the "Print contacts" sub form.
*/
private void createPrintContactsSubForm() {
add(new WHeading(HeadingLevel.H3, "Print to CSV"));
WButton printBtn = new WButton("Print");
printBtn.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
printDetails();
}
});
printBtn.setImage("/image/document-print.png");
printBtn.setImagePosition(WButton.ImagePosition.EAST);
WFieldLayout layout = new WFieldLayout();
add(layout);
layout.setMargin(new Margin(Size.LARGE, null, null, null));
layout.addField("Print output", printOutput);
layout.addField((WLabel) null, printBtn);
add(new WAjaxControl(printBtn, printOutput));
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class RepeaterExampleWithStaticIDs method createAddContactSubForm.
/**
* Create the UI artefacts for the "Add contact" sub form.
*/
private void createAddContactSubForm() {
add(new WHeading(HeadingLevel.H3, "Add a new contact"));
WButton addBtn = new WButton("Add");
addBtn.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
addNewContact();
}
});
addBtn.setImage("/image/address-book-new.png");
newNameField.setDefaultSubmitButton(addBtn);
WContainer container = new WContainer();
container.add(newNameField);
container.add(addBtn);
WFieldLayout layout = new WFieldLayout();
add(layout);
layout.addField("New contact name", container);
add(new WAjaxControl(addBtn, new AjaxTarget[] { repeater, newNameField }));
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class TableRowEditingAjaxExample method setUpActionButtons.
/**
* Setup the action buttons and ajax controls in the action column.
*/
private void setUpActionButtons() {
// Buttons Panel
WPanel buttonPanel = new WPanel();
actionContainer.add(buttonPanel);
// Edit Button
final WButton editButton = new WButton("Edit") {
@Override
public boolean isVisible() {
Object key = TableUtil.getCurrentRowKey();
return !isEditRow(key);
}
};
editButton.setImage("/image/pencil.png");
editButton.setRenderAsLink(true);
editButton.setToolTip("Edit");
editButton.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
Object key = TableUtil.getCurrentRowKey();
addEditRow(key);
}
});
// Cancel Button
final WButton cancelButton = new WButton("Cancel") {
@Override
public boolean isVisible() {
Object key = TableUtil.getCurrentRowKey();
return isEditRow(key);
}
};
cancelButton.setImage("/image/cancel.png");
cancelButton.setRenderAsLink(true);
cancelButton.setToolTip("Cancel");
cancelButton.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
Object key = TableUtil.getCurrentRowKey();
removeEditRow(key);
firstNameField.reset();
lastNameField.reset();
dobField.reset();
}
});
// Delete Button
WConfirmationButton deleteButton = new WConfirmationButton("Delete") {
@Override
public boolean isVisible() {
Object key = TableUtil.getCurrentRowKey();
return !isEditRow(key);
}
};
deleteButton.setMessage("Do you want to delete row?");
deleteButton.setImage("/image/remove.png");
deleteButton.setRenderAsLink(true);
deleteButton.setToolTip("Delete");
deleteButton.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
Object key = TableUtil.getCurrentRowKey();
removeEditRow(key);
PersonBean bean = (PersonBean) actionContainer.getBean();
List<PersonBean> beans = (List<PersonBean>) table.getBean();
beans.remove(bean);
table.handleDataChanged();
messages.success(bean.getFirstName() + " " + bean.getLastName() + " removed.");
}
});
buttonPanel.add(editButton);
buttonPanel.add(cancelButton);
buttonPanel.add(deleteButton);
// Ajax - edit button
WAjaxControl editAjax = new WAjaxControl(editButton, new AjaxTarget[] { firstNameField, lastNameField, dobField, buttonPanel }) {
@Override
public boolean isVisible() {
return editButton.isVisible();
}
};
buttonPanel.add(editAjax);
// Ajax - cancel button
WAjaxControl cancelAjax = new WAjaxControl(cancelButton, new AjaxTarget[] { firstNameField, lastNameField, dobField, buttonPanel }) {
@Override
public boolean isVisible() {
return cancelButton.isVisible();
}
};
buttonPanel.add(cancelAjax);
buttonPanel.setIdName("buttons");
editAjax.setIdName("ajax_edit");
cancelAjax.setIdName("ajax_can");
editButton.setIdName("edit_btn");
cancelButton.setIdName("cancel_btn");
deleteButton.setIdName("delete_btn");
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WCheckBoxSelectExample method addExampleUsingArrayList.
/**
* This example creates the WCheckBoxSelect from a List of CarOptions.
*/
private void addExampleUsingArrayList() {
add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect created using an array list of options"));
List<CarOption> options = new ArrayList<>();
options.add(new CarOption("1", "Ferrari", "F-360"));
options.add(new CarOption("2", "Mercedez Benz", "amg"));
options.add(new CarOption("3", "Nissan", "Skyline"));
options.add(new CarOption("5", "Toyota", "Prius"));
final WCheckBoxSelect select = new WCheckBoxSelect(options);
select.setToolTip("Cars");
final WTextField text = new WTextField();
text.setReadOnly(true);
text.setText(NO_SELECTION);
WButton update = new WButton("Select Cars");
update.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
String output = select.getSelected().isEmpty() ? NO_SELECTION : "The selected cars are: " + select.getSelected();
text.setText(output);
}
});
select.setDefaultSubmitButton(update);
add(select);
add(update);
add(text);
add(new WAjaxControl(update, text));
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WCheckBoxSelectExample method addColumnSelectExample.
/**
* adds a WCheckBoxSelect with LAYOUT_COLUMN in 2 columns.
*/
private void addColumnSelectExample() {
add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect laid out in columns"));
add(new ExplanatoryText("Setting the layout to COLUMN will make the check boxes be rendered in 'n' columns. The number of columns is" + " determined by the layoutColumnCount property."));
final WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
select.setToolTip("Make a selection");
select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
select.setButtonColumns(2);
add(select);
add(new WHeading(HeadingLevel.H3, "Options equal to columns"));
String[] options = new String[] { "Dog", "Cat", "Bird" };
final WCheckBoxSelect select2 = new WCheckBoxSelect(options);
select2.setToolTip("Animals");
select2.setButtonColumns(3);
final WTextField text = new WTextField();
text.setReadOnly(true);
text.setText(NO_SELECTION);
WButton update = new WButton("Select Animals");
update.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
String output = select2.getSelected().isEmpty() ? NO_SELECTION : "The selected animals are: " + select2.getSelected();
text.setText(output);
}
});
select2.setDefaultSubmitButton(update);
add(select2);
add(update);
add(text);
add(new WAjaxControl(update, text));
}
Aggregations