use of com.github.bordertech.wcomponents.WContainer 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.WContainer in project wcomponents by BorderTech.
the class ObjectGraphNode_Test method testToFlatSummary.
@Test
public void testToFlatSummary() {
WContainer component = new WContainer();
setActiveContext(createUIContext());
WLabel label = new WLabel(TEST_LABEL);
component.add(label);
final int nodeId = component.getIndexOfChild(label);
final String fieldName = label.getId();
ObjectGraphNode node = new ObjectGraphNode(nodeId, fieldName, label.getClass().getName(), label);
String flatSummary = node.toFlatSummary();
flatSummary = flatSummary.replaceAll("\n", "");
Assert.assertTrue("summary should start with size", flatSummary.startsWith(node.getSize() + " "));
Assert.assertTrue("summary should end with class name", flatSummary.endsWith(label.getClass().getName()));
}
use of com.github.bordertech.wcomponents.WContainer in project wcomponents by BorderTech.
the class TreeUtil_Test method initTree.
@Before
public void initTree() {
root = new WApplication();
containerChild = new WContainer();
simpleChild = new WTextField();
repeatedComponent = new WText();
repeaterChild = new WRepeater(repeatedComponent);
grandChild = new WTextArea();
cardManager = new WCardManager();
card1 = new WText();
card2 = new WText();
root.add(containerChild);
root.add(simpleChild);
root.add(repeaterChild);
root.add(cardManager);
containerChild.add(grandChild);
cardManager.add(card1);
cardManager.add(card2);
root.setLocked(true);
setActiveContext(new UIContextImpl());
repeaterChild.setData(Arrays.asList(new String[] { "1", "2", "3" }));
}
use of com.github.bordertech.wcomponents.WContainer in project wcomponents by BorderTech.
the class WContentExample method addContentRow.
/**
* Adds components to the given container which demonstrate various ways of acessing the given content.
*
* @param contentDesc the description of the content, used to label the controls.
* @param contentAccess the content which will be displayed.
* @param target the container to add the UI controls to.
*/
private void addContentRow(final String contentDesc, final ContentAccess contentAccess, final MutableContainer target) {
// Demonstrate WButton + WContent, round trip
WButton button = new WButton(contentDesc);
final WContent buttonContent = new WContent();
button.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
buttonContent.setContentAccess(contentAccess);
buttonContent.display();
}
});
WContainer buttonCell = new WContainer();
buttonCell.add(buttonContent);
buttonCell.add(button);
target.add(buttonCell);
// Demonstrate WButton + WContent, using AJAX
WButton ajaxButton = new WButton(contentDesc);
final WContent ajaxContent = new WContent();
ajaxButton.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
ajaxContent.setContentAccess(contentAccess);
ajaxContent.display();
}
});
WContainer ajaxCell = new WContainer();
// The WContent must be wrapped in an AJAX targetable container
WPanel ajaxContentPanel = new WPanel();
ajaxContentPanel.add(ajaxContent);
ajaxCell.add(ajaxButton);
ajaxCell.add(ajaxContentPanel);
ajaxButton.setAjaxTarget(ajaxContentPanel);
target.add(ajaxCell);
// Demonstrate WContentLink - new window
WContentLink contentLinkNewWindow = new WContentLink(contentDesc) {
@Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
setContentAccess(contentAccess);
}
};
target.add(contentLinkNewWindow);
// Demonstrate WContentLink - prompt to save
WContentLink contentLinkPromptToSave = new WContentLink(contentDesc) {
@Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
setContentAccess(contentAccess);
}
};
contentLinkPromptToSave.setDisplayMode(DisplayMode.PROMPT_TO_SAVE);
target.add(contentLinkPromptToSave);
// Demonstrate WContentLink - inline
WContentLink contentLinkInline = new WContentLink(contentDesc) {
@Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
setContentAccess(contentAccess);
}
};
contentLinkInline.setDisplayMode(DisplayMode.DISPLAY_INLINE);
target.add(contentLinkInline);
// Demonstrate targeting of content via a URL
WMenu menu = new WMenu(WMenu.MenuType.FLYOUT);
final WContent menuContent = new WContent();
menuContent.setDisplayMode(DisplayMode.PROMPT_TO_SAVE);
WMenuItem menuItem = new WMenuItem(contentDesc) {
@Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
menuContent.setContentAccess(contentAccess);
setUrl(menuContent.getUrl());
}
};
menu.add(menuItem);
WContainer menuCell = new WContainer();
menuCell.add(menuContent);
menuCell.add(menu);
target.add(menuCell);
}
use of com.github.bordertech.wcomponents.WContainer in project wcomponents by BorderTech.
the class WCheckBoxExample_Test method testFindByLabelId.
/**
* Test that ByLabel works for CheckBoxes by label id.
*/
@Test
public void testFindByLabelId() {
// Launch the web browser to the LDE
WebDriver driver = getDriver();
WContainer container = (WContainer) getUi();
WFieldLayout layout = (WFieldLayout) container.getChildAt(0);
WField field = (WField) layout.getChildAt(0);
String labelId = field.getLabel().getId();
String componentId = field.getField().getId();
WebElement checkBox = driver.findElement(new ByLabel(labelId));
Assert.assertNotNull("Unable to find checkbox by labelId", checkBox);
Assert.assertEquals("Checkbox element ID does not match expected", componentId, checkBox.getAttribute("id"));
}
Aggregations