Search in sources :

Example 21 with WButton

use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.

the class WTabAndCollapsibleExample method newVisibilityToggleForTab.

/**
 * Creates a button to toggle the visibility of a tab.
 *
 * @param idx the index of the tab.
 * @return a button which toggles the visibility of the tab.
 */
private WButton newVisibilityToggleForTab(final int idx) {
    WButton toggleButton = new WButton("Toggle visibility of tab " + (idx + 1));
    toggleButton.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            boolean tabVisible = tabset.isTabVisible(idx);
            tabset.setTabVisible(idx, !tabVisible);
        }
    });
    return toggleButton;
}
Also used : Action(com.github.bordertech.wcomponents.Action) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WButton(com.github.bordertech.wcomponents.WButton)

Example 22 with WButton

use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.

the class WDialogExample_Test method testModalDialog.

@Test
public void testModalDialog() {
    // Launch the web browser to the LDE
    WebDriver driver = getDriver();
    WDialogExample example = (WDialogExample) getUi();
    String expectedText = example.getModalText();
    final WButton testButton = example.getModalButton();
    // Display the modal dialog
    driver.findElement(byWComponent(testButton)).click();
    Assert.assertTrue("Should be displaying the dialog", driver.getPageSource().contains(expectedText));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 23 with WButton

use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.

the class WDialogExample_Test method testModalDialogSearch.

@Test
public void testModalDialogSearch() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    WDialogExample example = (WDialogExample) getUi();
    final WButton testButton = example.getModalButton();
    // Display the modal dialog
    driver.findElement(byWComponent(testButton)).click();
    driver.findWTextField(byWComponentPath("WDialogExample$SelectPersonPanel/WTextField[0]")).sendKeys("First");
    driver.findWTextField(byWComponentPath("WDialogExample$SelectPersonPanel/WTextField[1]")).sendKeys("Last");
    driver.findElement(byWComponentPath("WDialogExample$SelectPersonPanel/WButton[1]")).click();
    driver.findElement(byWComponentPath("WDialogExample$SelectPersonPanel/WRadioButtonSelect", "Last, First")).click();
    driver.findElement(byWComponentPath("WDialogExample$SelectPersonPanel/WButton[1]")).click();
    String message = driver.findElementImmediate(byWComponentPath("WMessageBox")).getText();
    Assert.assertTrue("Incorrect message text", message.contains("Selected: Last, First"));
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 24 with WButton

use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.

the class WDialogExample_Test method testModelessDialog.

@Test
public void testModelessDialog() {
    // Launch the web browser to the LDE
    WebDriver driver = getDriver();
    WDialogExample example = (WDialogExample) getUi();
    String expectedText = example.getNonModalText();
    final WButton testButton = example.getNonModalButton();
    // Display the modeless dialog
    driver.findElement(byWComponent(testButton)).click();
    Assert.assertTrue("Should not be displaying the dialog", driver.getPageSource().contains(expectedText));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 25 with WButton

use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.

the class WTableRenderer method paintTableActions.

/**
 * Paints the table actions of the table.
 *
 * @param table the table to paint the table actions for.
 * @param renderContext the RenderContext to paint to.
 */
private void paintTableActions(final WTable table, final WebXmlRenderContext renderContext) {
    XmlStringBuilder xml = renderContext.getWriter();
    List<WButton> tableActions = table.getActions();
    if (!tableActions.isEmpty()) {
        boolean hasActions = false;
        for (WButton button : tableActions) {
            if (!button.isVisible()) {
                continue;
            }
            if (!hasActions) {
                hasActions = true;
                xml.appendTag("ui:actions");
            }
            xml.appendTag("ui:action");
            List<WTable.ActionConstraint> constraints = table.getActionConstraints(button);
            if (constraints != null) {
                for (WTable.ActionConstraint constraint : constraints) {
                    int minRows = constraint.getMinSelectedRowCount();
                    int maxRows = constraint.getMaxSelectedRowCount();
                    String message = constraint.getMessage();
                    String type = constraint.isError() ? "error" : "warning";
                    xml.appendTagOpen("ui:condition");
                    xml.appendOptionalAttribute("minSelectedRows", minRows > 0, minRows);
                    xml.appendOptionalAttribute("maxSelectedRows", maxRows > 0, maxRows);
                    xml.appendAttribute("selectedOnOther", this.selectedOnOther);
                    xml.appendAttribute("type", type);
                    xml.appendAttribute("message", I18nUtilities.format(null, message));
                    xml.appendEnd();
                }
            }
            button.paint(renderContext);
            xml.appendEndTag("ui:action");
        }
        if (hasActions) {
            xml.appendEndTag("ui:actions");
        }
    }
}
Also used : WTable(com.github.bordertech.wcomponents.WTable) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder) WButton(com.github.bordertech.wcomponents.WButton)

Aggregations

WButton (com.github.bordertech.wcomponents.WButton)76 Test (org.junit.Test)39 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)25 Action (com.github.bordertech.wcomponents.Action)20 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)18 WTextField (com.github.bordertech.wcomponents.WTextField)17 WHeading (com.github.bordertech.wcomponents.WHeading)16 WContainer (com.github.bordertech.wcomponents.WContainer)14 WPanel (com.github.bordertech.wcomponents.WPanel)13 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)11 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)10 WLabel (com.github.bordertech.wcomponents.WLabel)9 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)8 UIContext (com.github.bordertech.wcomponents.UIContext)7 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)7 WText (com.github.bordertech.wcomponents.WText)6 WDataTable (com.github.bordertech.wcomponents.WDataTable)5 WFieldSet (com.github.bordertech.wcomponents.WFieldSet)5 WTable (com.github.bordertech.wcomponents.WTable)5 AdapterBasicTableModel (com.github.bordertech.wcomponents.AdapterBasicTableModel)4