use of com.github.bordertech.wcomponents.WMultiSelect in project wcomponents by BorderTech.
the class ExpressionBuilder_Test method testAndOperatorPrecedenceBoth.
/**
* Tests for correct operator precedence when there are ANDs on both sides of the OR: a {@literal &}{@literal &} b
* || c {@literal &}{@literal &} d.
*/
@Test
public void testAndOperatorPrecedenceBoth() {
builder.equals(new WTextField(), "1").and().equals(new WTextArea(), "2").or().equals(new WDropdown(), "3").and().equals(new WMultiSelect(), "4");
Assert.assertEquals("Incorrect condition", "((WTextField=\"1\" and WTextArea=\"2\") or (WDropdown=\"3\" and WMultiSelect=\"4\"))", builder.build().toString());
}
use of com.github.bordertech.wcomponents.WMultiSelect in project wcomponents by BorderTech.
the class ExpressionBuilder_Test method testAndandOrWithExpressions.
/**
* Tests nesting of expression builders to change the order of operations: (a {@literal &}{@literal &} b) || (c
* {@literal &}{@literal &} d).
*/
@Test
public void testAndandOrWithExpressions() {
builder.equals(new WTextField(), "1").and(new ExpressionBuilder().equals(new WTextArea(), "2")).or(new ExpressionBuilder().equals(new WDropdown(), "3")).and().equals(new WMultiSelect(), "4");
Assert.assertEquals("Incorrect condition", "((WTextField=\"1\" and WTextArea=\"2\") or (WDropdown=\"3\" and WMultiSelect=\"4\"))", builder.build().toString());
}
use of com.github.bordertech.wcomponents.WMultiSelect in project wcomponents by BorderTech.
the class ExpressionBuilder_Test method testNesting.
/**
* Tests nesting of expression builders to change the order of operations: (a {@literal &}{@literal &} (b || c)
* {@literal &}{@literal &} d).
*/
@Test
public void testNesting() {
builder.equals(new WTextField(), "1").and(new ExpressionBuilder().equals(new WTextArea(), "2").or().equals(new WDropdown(), "3")).and().equals(new WMultiSelect(), "4");
Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" and (WTextArea=\"2\" or WDropdown=\"3\") and WMultiSelect=\"4\")", builder.build().toString());
}
use of com.github.bordertech.wcomponents.WMultiSelect in project wcomponents by BorderTech.
the class ExpressionBuilder_Test method testOrOperatorPrecedenceBoth.
/**
* Tests for correct operator precedence when there are ANDs on both sides of the OR: a || b
* {@literal &}{@literal &} c || d.
*/
@Test
public void testOrOperatorPrecedenceBoth() {
builder.equals(new WTextField(), "1").or().equals(new WTextArea(), "2").and().equals(new WDropdown(), "3").or().equals(new WMultiSelect(), "4");
Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" or ((WTextArea=\"2\" and WDropdown=\"3\") or WMultiSelect=\"4\"))", builder.build().toString());
}
use of com.github.bordertech.wcomponents.WMultiSelect in project wcomponents by BorderTech.
the class WMultiSelectRenderer method doRender.
/**
* Paints the given WMultiSelect.
*
* @param component the WMultiSelect to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WMultiSelect listBox = (WMultiSelect) component;
XmlStringBuilder xml = renderContext.getWriter();
String dataKey = listBox.getListCacheKey();
boolean readOnly = listBox.isReadOnly();
int rows = listBox.getRows();
int min = listBox.getMinSelect();
int max = listBox.getMaxSelect();
xml.appendTagOpen("ui:listbox");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", listBox.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
xml.appendOptionalAttribute("data", dataKey != null && !readOnly, dataKey);
xml.appendOptionalAttribute("disabled", listBox.isDisabled(), "true");
xml.appendOptionalAttribute("required", listBox.isMandatory(), "true");
xml.appendOptionalAttribute("submitOnChange", listBox.isSubmitOnChange(), "true");
xml.appendOptionalAttribute("toolTip", component.getToolTip());
xml.appendOptionalAttribute("accessibleText", component.getAccessibleText());
xml.appendOptionalAttribute("rows", rows >= 2, rows);
xml.appendOptionalAttribute("min", min > 0, min);
xml.appendOptionalAttribute("max", max > 0, max);
}
xml.appendClose();
// Options
List<?> options = listBox.getOptions();
boolean renderSelectionsOnly = readOnly || dataKey != null;
if (options != null) {
int optionIndex = 0;
List<?> selections = listBox.getSelected();
for (Object option : options) {
if (option instanceof OptionGroup) {
xml.appendTagOpen("ui:optgroup");
xml.appendAttribute("label", ((OptionGroup) option).getDesc());
xml.appendClose();
for (Object nestedOption : ((OptionGroup) option).getOptions()) {
renderOption(listBox, nestedOption, optionIndex++, xml, selections, renderSelectionsOnly);
}
xml.appendEndTag("ui:optgroup");
} else {
renderOption(listBox, option, optionIndex++, xml, selections, renderSelectionsOnly);
}
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(listBox, renderContext);
}
xml.appendEndTag("ui:listbox");
}
Aggregations