Search in sources :

Example 1 with WContainer

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 }));
}
Also used : Action(com.github.bordertech.wcomponents.Action) WContainer(com.github.bordertech.wcomponents.WContainer) WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WButton(com.github.bordertech.wcomponents.WButton) WHeading(com.github.bordertech.wcomponents.WHeading) AjaxTarget(com.github.bordertech.wcomponents.AjaxTarget)

Example 2 with WContainer

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()));
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 3 with WContainer

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" }));
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WContainer(com.github.bordertech.wcomponents.WContainer) WApplication(com.github.bordertech.wcomponents.WApplication) WText(com.github.bordertech.wcomponents.WText) UIContextImpl(com.github.bordertech.wcomponents.UIContextImpl) WCardManager(com.github.bordertech.wcomponents.WCardManager) WTextField(com.github.bordertech.wcomponents.WTextField) WRepeater(com.github.bordertech.wcomponents.WRepeater) Before(org.junit.Before)

Example 4 with WContainer

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);
}
Also used : Action(com.github.bordertech.wcomponents.Action) WContainer(com.github.bordertech.wcomponents.WContainer) WMenuItem(com.github.bordertech.wcomponents.WMenuItem) WContent(com.github.bordertech.wcomponents.WContent) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WPanel(com.github.bordertech.wcomponents.WPanel) Request(com.github.bordertech.wcomponents.Request) WMenu(com.github.bordertech.wcomponents.WMenu) WButton(com.github.bordertech.wcomponents.WButton) WContentLink(com.github.bordertech.wcomponents.WContentLink)

Example 5 with WContainer

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"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WContainer(com.github.bordertech.wcomponents.WContainer) WField(com.github.bordertech.wcomponents.WField) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WebElement(org.openqa.selenium.WebElement) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Aggregations

WContainer (com.github.bordertech.wcomponents.WContainer)49 Test (org.junit.Test)41 WTextField (com.github.bordertech.wcomponents.WTextField)21 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)17 Equal (com.github.bordertech.wcomponents.subordinate.Equal)16 Rule (com.github.bordertech.wcomponents.subordinate.Rule)16 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)16 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)15 WButton (com.github.bordertech.wcomponents.WButton)14 GreaterThanOrEqual (com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual)14 LessThanOrEqual (com.github.bordertech.wcomponents.subordinate.LessThanOrEqual)14 NotEqual (com.github.bordertech.wcomponents.subordinate.NotEqual)14 SubordinateTrigger (com.github.bordertech.wcomponents.SubordinateTrigger)11 WComponentGroup (com.github.bordertech.wcomponents.WComponentGroup)10 Hide (com.github.bordertech.wcomponents.subordinate.Hide)10 Show (com.github.bordertech.wcomponents.subordinate.Show)10 WPanel (com.github.bordertech.wcomponents.WPanel)9 Diagnostic (com.github.bordertech.wcomponents.validation.Diagnostic)6 DiagnosticImpl (com.github.bordertech.wcomponents.validation.DiagnosticImpl)6 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)5