Search in sources :

Example 6 with WNumberField

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

the class SubordinateControlOptionsExample method setupTrigger.

/**
 * Setup the trigger for the subordinate control.
 */
private void setupTrigger() {
    String label = drpTriggerType.getSelected() + " Trigger";
    WFieldLayout layout = new WFieldLayout();
    layout.setLabelWidth(LABEL_WIDTH);
    buildControlPanel.add(layout);
    switch((TriggerType) drpTriggerType.getSelected()) {
        case RADIOBUTTONGROUP:
            trigger = new RadioButtonGroup();
            WFieldSet rbSet = new WFieldSet("Select an option");
            RadioButtonGroup group = (RadioButtonGroup) trigger;
            WRadioButton rb1 = group.addRadioButton("A");
            WRadioButton rb2 = group.addRadioButton("B");
            WRadioButton rb3 = group.addRadioButton("C");
            rbSet.add(group);
            rbSet.add(rb1);
            rbSet.add(new WLabel("A", rb1));
            rbSet.add(new WText("\u00a0"));
            rbSet.add(rb2);
            rbSet.add(new WLabel("B", rb2));
            rbSet.add(new WText("\u00a0"));
            rbSet.add(rb3);
            rbSet.add(new WLabel("C", rb3));
            layout.addField(label, rbSet);
            return;
        case CHECKBOX:
            trigger = new WCheckBox();
            break;
        case CHECKBOXSELECT:
            trigger = new WCheckBoxSelect(LOOKUP_TABLE_NAME);
            break;
        case DATEFIELD:
            trigger = new WDateField();
            break;
        case DROPDOWN:
            trigger = new WDropdown(new TableWithNullOption(LOOKUP_TABLE_NAME));
            break;
        case EMAILFIELD:
            trigger = new WEmailField();
            break;
        case MULTISELECT:
            trigger = new WMultiSelect(LOOKUP_TABLE_NAME);
            break;
        case MULTISELECTPAIR:
            trigger = new WMultiSelectPair(LOOKUP_TABLE_NAME);
            break;
        case NUMBERFIELD:
            trigger = new WNumberField();
            break;
        case PARTIALDATEFIELD:
            trigger = new WPartialDateField();
            break;
        case PASSWORDFIELD:
            trigger = new WPasswordField();
            break;
        case PHONENUMBERFIELD:
            trigger = new WPhoneNumberField();
            break;
        case RADIOBUTTONSELECT:
            trigger = new WRadioButtonSelect(LOOKUP_TABLE_NAME);
            break;
        case SINGLESELECT:
            trigger = new WSingleSelect(LOOKUP_TABLE_NAME);
            break;
        case TEXTAREA:
            trigger = new WTextArea();
            ((WTextArea) trigger).setMaxLength(1000);
            break;
        case TEXTFIELD:
            trigger = new WTextField();
            break;
        default:
            throw new SystemException("Trigger type not valid");
    }
    layout.addField(label, trigger);
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) WNumberField(com.github.bordertech.wcomponents.WNumberField) WEmailField(com.github.bordertech.wcomponents.WEmailField) WPasswordField(com.github.bordertech.wcomponents.WPasswordField) WMultiSelect(com.github.bordertech.wcomponents.WMultiSelect) WLabel(com.github.bordertech.wcomponents.WLabel) WTextArea(com.github.bordertech.wcomponents.WTextArea) WRadioButton(com.github.bordertech.wcomponents.WRadioButton) WDropdown(com.github.bordertech.wcomponents.WDropdown) SystemException(com.github.bordertech.wcomponents.util.SystemException) WText(com.github.bordertech.wcomponents.WText) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) TableWithNullOption(com.github.bordertech.wcomponents.examples.common.ExampleLookupTable.TableWithNullOption) WRadioButtonSelect(com.github.bordertech.wcomponents.WRadioButtonSelect) WTextField(com.github.bordertech.wcomponents.WTextField) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect) WMultiSelectPair(com.github.bordertech.wcomponents.WMultiSelectPair) WPhoneNumberField(com.github.bordertech.wcomponents.WPhoneNumberField) WSingleSelect(com.github.bordertech.wcomponents.WSingleSelect) RadioButtonGroup(com.github.bordertech.wcomponents.RadioButtonGroup) WCheckBox(com.github.bordertech.wcomponents.WCheckBox) WPartialDateField(com.github.bordertech.wcomponents.WPartialDateField) WDateField(com.github.bordertech.wcomponents.WDateField)

Example 7 with WNumberField

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

the class NotEqual_Test method testDoCompare.

@Test
public void testDoCompare() {
    WNumberField trigger = new WNumberField();
    // ------------------------------
    // Setup NOT EQUAL - with value
    NotEqual compare = new NotEqual(trigger, EQ_VALUE);
    trigger.setNumber(null);
    Assert.assertTrue("Not Equal - Compare for null value should be true", compare.execute());
    trigger.setNumber(LT_VALUE);
    Assert.assertTrue("Not Equal - Compare for less value should be true", compare.execute());
    trigger.setNumber(EQ_VALUE);
    Assert.assertFalse("Not Equal - Compare for equal value should be false", compare.execute());
    trigger.setNumber(GT_VALUE);
    Assert.assertTrue("Not Equal - Compare for greater value should be true", compare.execute());
    // ------------------------------
    // Setup NOT EQUAL - with null value
    compare = new NotEqual(trigger, null);
    trigger.setNumber(null);
    Assert.assertFalse("Not Equal With Null Value - Compare for null value should be false", compare.execute());
    trigger.setNumber(EQ_VALUE);
    Assert.assertTrue("Not Equal With Null Value - Compare for value should be true", compare.execute());
}
Also used : WNumberField(com.github.bordertech.wcomponents.WNumberField) Test(org.junit.Test)

Example 8 with WNumberField

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

the class Equal_Test method testDoCompare.

@Test
public void testDoCompare() {
    WNumberField trigger = new WNumberField();
    // ------------------------------
    // Setup EQUAL - with value
    Equal compare = new Equal(trigger, EQ_VALUE);
    trigger.setNumber(null);
    Assert.assertFalse("Equal Type - Compare for null value should be false", compare.execute());
    trigger.setNumber(LT_VALUE);
    Assert.assertFalse("Equal Type - Compare for less value should be false", compare.execute());
    trigger.setNumber(EQ_VALUE);
    Assert.assertTrue("Equal Type - Compare for equal value should be true", compare.execute());
    trigger.setNumber(GT_VALUE);
    Assert.assertFalse("Equal Type - Compare for greater value should be false", compare.execute());
    // ------------------------------
    // Setup EQUAL - with null value
    compare = new Equal(trigger, null);
    trigger.setNumber(null);
    Assert.assertTrue("Equal Type With Null Value - Compare for null value should be true", compare.execute());
    trigger.setNumber(EQ_VALUE);
    Assert.assertFalse("Equal Type With Null Value - Compare for value should be false", compare.execute());
}
Also used : WNumberField(com.github.bordertech.wcomponents.WNumberField) Test(org.junit.Test)

Example 9 with WNumberField

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

the class LessThan_Test method testDoCompare.

@Test
public void testDoCompare() {
    WNumberField trigger = new WNumberField();
    // ------------------------------
    // Setup LESS THAN - with value
    LessThan compare = new LessThan(trigger, EQ_VALUE);
    trigger.setNumber(null);
    Assert.assertFalse("Less Than - Compare for null value should be false", compare.execute());
    trigger.setNumber(LT_VALUE);
    Assert.assertTrue("Less Than - Compare for less value should be true", compare.execute());
    trigger.setNumber(EQ_VALUE);
    Assert.assertFalse("Less Than - Compare for equal value should be false", compare.execute());
    trigger.setNumber(GT_VALUE);
    Assert.assertFalse("Less Than - Compare for greater value should be false", compare.execute());
    // ------------------------------
    // Setup LESS THAN - with null value
    compare = new LessThan(trigger, null);
    trigger.setNumber(null);
    Assert.assertFalse("Less Than With Null Value - Compare for null value should be false", compare.execute());
    trigger.setNumber(EQ_VALUE);
    Assert.assertFalse("Less Than With Null Value - Compare for value should be false", compare.execute());
}
Also used : WNumberField(com.github.bordertech.wcomponents.WNumberField) Test(org.junit.Test)

Example 10 with WNumberField

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

the class GreaterThanOrEqual_Test method testDoCompare.

@Test
public void testDoCompare() {
    WNumberField trigger = new WNumberField();
    // ------------------------------
    // Setup GREATER THAN OR EQUAL - with value
    GreaterThanOrEqual compare = new GreaterThanOrEqual(trigger, EQ_VALUE);
    trigger.setNumber(null);
    Assert.assertFalse("Greater Than Or Equal - Compare for null value should be false", compare.execute());
    trigger.setNumber(LT_VALUE);
    Assert.assertFalse("Greater Than Or Equal - Compare for less value should be false", compare.execute());
    trigger.setNumber(EQ_VALUE);
    Assert.assertTrue("Greater Than Or Equal - Compare for equal value should be true", compare.execute());
    trigger.setNumber(GT_VALUE);
    Assert.assertTrue("Greater Than Or Equal - Compare for greater value should be true", compare.execute());
    // ------------------------------
    // Setup GREATER THAN - with null value
    compare = new GreaterThanOrEqual(trigger, null);
    trigger.setNumber(null);
    Assert.assertTrue("Greater Than Or Equal With Null Value - Compare for null value should be true", compare.execute());
    trigger.setNumber(EQ_VALUE);
    Assert.assertFalse("Greater Than Or Equal With Null Value - Compare for value should be false", compare.execute());
}
Also used : WNumberField(com.github.bordertech.wcomponents.WNumberField) Test(org.junit.Test)

Aggregations

WNumberField (com.github.bordertech.wcomponents.WNumberField)20 Test (org.junit.Test)16 BigDecimal (java.math.BigDecimal)5 WDateField (com.github.bordertech.wcomponents.WDateField)4 AbstractWSelectList (com.github.bordertech.wcomponents.AbstractWSelectList)2 RadioButtonGroup (com.github.bordertech.wcomponents.RadioButtonGroup)2 SubordinateTrigger (com.github.bordertech.wcomponents.SubordinateTrigger)2 WContainer (com.github.bordertech.wcomponents.WContainer)2 WRadioButton (com.github.bordertech.wcomponents.WRadioButton)2 WTextField (com.github.bordertech.wcomponents.WTextField)2 Date (java.util.Date)2 AbstractWMultiSelectList (com.github.bordertech.wcomponents.AbstractWMultiSelectList)1 AbstractWSingleSelectList (com.github.bordertech.wcomponents.AbstractWSingleSelectList)1 Input (com.github.bordertech.wcomponents.Input)1 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)1 WButton (com.github.bordertech.wcomponents.WButton)1 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)1 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)1 WComponent (com.github.bordertech.wcomponents.WComponent)1 WDropdown (com.github.bordertech.wcomponents.WDropdown)1