use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class SeleniumWMultiDropdownWebElement method switchOption.
/**
* Change a selected option from one value to another.
* @param fromText the current selected text
* @param toText the text to select
*/
public void switchOption(final String fromText, final String toText) {
if (isReadOnly()) {
throw new SystemException("Cannot switch selection from a read-only WMultiDropdown");
}
WebElement dropdown = getDropdown(fromText);
Select se = new Select(dropdown);
se.selectByVisibleText(toText);
}
use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class SeleniumWMultiDropdownWebElement method getRemoveButton.
/**
* @param dropdown the WebElement representing the dropdown which will be removed if the remove button is invoked
* @return the remove button for the dropdown
*/
public WebElement getRemoveButton(final WebElement dropdown) {
if (isReadOnly()) {
throw new SystemException("Cannot get remove button from a read-only WMultiDropdown");
}
if (dropdown == null) {
throw new IllegalArgumentException("Cannot get remove button without a reference dropdown");
}
String id = dropdown.getAttribute("id");
WebElement firstOption = getFirstDropdown();
if (id.equals(firstOption.getAttribute("id"))) {
throw new SystemException("Cannot get remove button for the first option");
}
String cssSelector = "button[aria-controls='" + id + "']";
return findElementImmediate(By.cssSelector(cssSelector));
}
use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class SeleniumWMultiDropdownWebElement method select.
/**
* Select an option using its visible text.
* @param optionText the text of the option to select
*/
public void select(final String optionText) {
if (isReadOnly()) {
throw new SystemException("Cannot select from a read-only WMultiDropdown");
}
clickButton(getAddButton(), true);
Select se = new Select(getFirstDropdown());
se.selectByVisibleText(optionText);
}
use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class WSubordinateControlRenderer method paintCondition.
/**
* Paints a condition.
*
* @param condition the condition to paint.
* @param xml the writer to send the output to
*/
private void paintCondition(final Condition condition, final XmlStringBuilder xml) {
if (condition instanceof And) {
xml.appendTag("ui:and");
for (Condition operand : ((And) condition).getConditions()) {
paintCondition(operand, xml);
}
xml.appendEndTag("ui:and");
} else if (condition instanceof Or) {
xml.appendTag("ui:or");
for (Condition operand : ((Or) condition).getConditions()) {
paintCondition(operand, xml);
}
xml.appendEndTag("ui:or");
} else if (condition instanceof Not) {
xml.appendTag("ui:not");
paintCondition(((Not) condition).getCondition(), xml);
xml.appendEndTag("ui:not");
} else if (condition instanceof AbstractCompare) {
AbstractCompare compare = (AbstractCompare) condition;
xml.appendTagOpen("ui:condition");
xml.appendAttribute("controller", compare.getTrigger().getId());
xml.appendAttribute("value", compare.getComparePaintValue());
xml.appendOptionalAttribute("operator", getCompareTypeName(compare.getCompareType()));
xml.appendEnd();
} else {
throw new SystemException("Unknown condition: " + condition);
}
}
use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class WDataTableRenderer method paintPaginationElement.
/**
* Paint the pagination aspects of the WDataTable.
* @param table the WDataTable being rendered
* @param xml the string builder in use
*/
private void paintPaginationElement(final WDataTable table, final XmlStringBuilder xml) {
TableDataModel model = table.getDataModel();
xml.appendTagOpen("ui:pagination");
if (model instanceof TreeTableDataModel) {
// For tree tables, we only include top-level nodes for pagination.
TreeNode firstNode = ((TreeTableDataModel) model).getNodeAtLine(0);
xml.appendAttribute("rows", firstNode == null ? 0 : firstNode.getParent().getChildCount());
} else {
xml.appendAttribute("rows", model.getRowCount());
}
xml.appendAttribute("rowsPerPage", table.getRowsPerPage());
xml.appendAttribute("currentPage", table.getCurrentPage());
switch(table.getPaginationMode()) {
case CLIENT:
xml.appendAttribute("mode", "client");
break;
case DYNAMIC:
case SERVER:
xml.appendAttribute("mode", "dynamic");
break;
case NONE:
break;
default:
throw new SystemException("Unknown pagination mode: " + table.getPaginationMode());
}
xml.appendEnd();
}
Aggregations