/** * Updates the recent list with the new selection. * * @param newSelection the new selection. */ private void updateRecent(final String newSelection) { List recentList = recentDropdown.getOptions(); if (recentList.contains(newSelection)) { recentList.remove(newSelection); } recentList.add(0, newSelection); recentDropdown.setOptions(recentList); recentDropdown.setSelected(newSelection); }
@Override protected void preparePaintComponent(final Request request) { if (!isInitialised()) { dropdownSelected.setSelected(dropdownSelected.getOptions().get(2)); multiDropdownSelected.setSelected(Arrays.asList(new Object[]{multiDropdownSelected. getOptions().get(2)})); boxSelected.setSelected(Arrays.asList(new Object[]{boxSelected.getOptions().get(2)})); setInitialised(true); } } }
/** * Override preparePaintComponent to set the initial selection from the app preferences. The selection is set the * first time the example is accessed or when the reset button is used. * * @param request the request being responded to. */ @Override public void preparePaintComponent(final Request request) { if (!this.isInitialised() || resetButton.isPressed()) { String preferredState = request.getAppPreferenceParameter("example.preferred.state"); stateSelector.setSelected(preferredState); this.setInitialised(true); } } }
/** * Based on selection it is responsible for displaying a WComponent and making sure the recent list is updated. * If selectionText is supplied then it is selected and if not then example list is checked. If these both are * not supplied then it looks for recent list selection. */ private void doSelect() { String selection = ""; if (selectionTextField.getText() == null || selectionTextField.getText().equals("")) { selection = (String) examplesDropdown.getSelected(); if (selection != null) { examplesDropdown.setSelected(null); } else { selection = (String) recentDropdown.getSelected(); if (selection == null) { // No selection so don't change anything. return; } } } else { selection = selectionTextField.getText(); } if (selection != null) { updateRecent(selection); } executeOnSelect(); cardManager.makeVisible(mainDisplay); }
/** * Setup the default values for the configuration options. */ private void setPresets() { TriggerType selectedTrigger = (TriggerType) drpTriggerType.getSelected(); comboField.setVisible( selectedTrigger != TriggerType.DateField && selectedTrigger != TriggerType.NumberField); dateField.setVisible(selectedTrigger == TriggerType.DateField); numberField.setVisible(selectedTrigger == TriggerType.NumberField); // If a group action selected, then target can only be the field (as it is defined in a group) switch ((ControlActionType) drpActionType.getSelected()) { case ENABLEIN_DISABLEIN: case SHOWIN_HIDEIN: drpTargetType.setSelected(TargetType.WFIELD); drpTargetType.setDisabled(true); break; default: drpTargetType.setDisabled(false); } }
/** * Sets the details to display. * * @param row the details to display. */ public void setDetails(final SearchResultRowBO row) { textField.setText(row.getName()); dropdown.setSelected(row.getCountry()); checkbox.setSelected(Boolean.TRUE.equals(row.getTicked())); radioGroup.setData(row.getHappy()); multiSelect.setSelected(row.getAnimals()); textArea.setText(row.getDesc()); } }
wdPanelType.setSelected(WPanel.Type.PLAIN); wdListLayoutType.setSelected(ListLayout.Type.FLAT); wdListLayoutAlignment.setSelected(ListLayout.Alignment.CENTER); wdListLayoutSeparator.setSelected(ListLayout.Separator.BAR);
rppOptions.add(100); rowsPerPage.setOptions(rppOptions); rowsPerPage.setSelected(Integer.valueOf(DEFAULT_ROWS_PER_PAGE));
@Test public void testDoPaintReadOnly() throws IOException, SAXException, XpathException { // Shared options. WDropdown drop = new WDropdown(); drop.setOptions(new String[]{"A", "B", "C"}); setActiveContext(createUIContext()); // Check Readonly - only render selected option drop.setReadOnly(true); drop.setSelected("B"); assertSchemaMatch(drop); assertXpathEvaluatesTo("true", "//ui:dropdown/@readOnly", drop); assertXpathEvaluatesTo("1", "count(//ui:dropdown/ui:option)", drop); assertXpathEvaluatesTo("1", "count(//ui:dropdown/ui:option[@selected='true'])", drop); assertXpathEvaluatesTo("B", "//ui:dropdown/ui:option[@selected='true']", drop); }
drop.setSelected("B.3"); assertXpathEvaluatesTo("1", "count(//ui:option[@selected='true'])", drop); assertXpathExists("//ui:dropdown/ui:optgroup/ui:option[text()='B.3'][@selected='true']",
dropdown.setSelected(selected);
@Test public void testEditableComboOption() throws IOException, SAXException, XpathException { String[] options = new String[]{"A", "B", "C"}; WDropdown drop = new WDropdown(options); drop.setType(WDropdown.DropdownType.COMBO); assertSchemaMatch(drop); assertXpathEvaluatesTo("3", "count(//ui:dropdown/ui:option)", drop); assertXpathEvaluatesTo("1", "count(//ui:option[@selected='true'])", drop); assertXpathExists("//ui:dropdown/ui:option[text()='A'][@selected='true']", drop); // Set a new selection which is not in the list. drop.setSelected("D"); assertSchemaMatch(drop); assertXpathEvaluatesTo("4", "count(//ui:dropdown/ui:option)", drop); assertXpathEvaluatesTo("1", "count(//ui:option[@selected='true'])", drop); assertXpathExists("//ui:dropdown/ui:option[text()='D'][@selected='true']", drop); }
dropdown.setSelected(OPTIONS_ARRAY[1]); addFieldToLayout(dropdown, "Simple drop-down with default selection", null); dropdown.setSelected(OPTIONS_ARRAY[1]); dropdown.setDisabled(true); addFieldToLayout(dropdown, "Disabled drop-down with default selection", null);
panelContentRO.setRichTextArea(true); panelType.setOptions(WPanel.Type.values()); panelType.setSelected(WPanel.Type.PLAIN); applyConfigButton.setAction(new Action() { @Override
@Test public void testConditionWithListTrigger() throws IOException, SAXException, XpathException { WDropdown condTrigger = new WDropdown(); SubordinateTarget actionTarget = new WTextField(); // Setup a rule with a condition using a dropdown Rule rule = new Rule(); rule.setCondition(new Equal(condTrigger, "b")); rule.addActionOnTrue(new Show(actionTarget)); rule.addActionOnFalse(new Hide(actionTarget)); // Setup Subordinate WSubordinateControl control = new WSubordinateControl(); control.addRule(rule); WContainer root = new WContainer(); root.add(condTrigger); root.add(actionTarget); root.add(control); condTrigger.setOptions(Arrays.asList(new String[]{"a", "b", "c", "d", "e"})); condTrigger.setSelected("e"); // Apply the controls control.applyTheControls(); // Validate Schema assertSchemaMatch(root); // Check Condition Value is the "Code Value" assertXpathEvaluatesTo("2", "//ui:subordinate/ui:condition/@value", root); // Check action target assertXpathEvaluatesTo("true", "//ui:textfield/@hidden", root); }
ddExpMode.setSelected(WTree.ExpandMode.CLIENT); layout.addField("Expand mode", ddExpMode);