当前位置: 首页>>代码示例>>Java>>正文


Java Component.ValueChangeListener方法代码示例

本文整理汇总了Java中com.haulmont.cuba.gui.components.Component.ValueChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java Component.ValueChangeListener方法的具体用法?Java Component.ValueChangeListener怎么用?Java Component.ValueChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.haulmont.cuba.gui.components.Component的用法示例。


在下文中一共展示了Component.ValueChangeListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testValueChangeListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testValueChangeListener() {
    SearchField searchField = factory.createComponent(SearchField.class);

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    searchField.setOptionsDatasource(groupsDs);
    List<Group> groups = new ArrayList<>(groupsDs.getItems());

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setGroup(groups.get(0));

    boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
    searchField.addValueChangeListener(listener);

    searchField.setDatasource(userDs, "group");
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:SearchFieldDsTest.java

示例2: testUnsubscribeComponentListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testUnsubscribeComponentListener() {
    DateField dateField = (DateField) factory.createComponent(DateField.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();

    Date updateTs = new Date();
    user.setUpdateTs(updateTs);
    dateField.setDatasource(userDs, "updateTs");
    dateField.setResolution(DateField.Resolution.SEC);

    // unbind
    dateField.setDatasource(null, null);

    Component.ValueChangeListener valueChangeListener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    dateField.addValueChangeListener(valueChangeListener);

    user.setUpdateTs(new Date());
    assertEquals(updateTs, dateField.getValue());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:DateFieldDsTest.java

示例3: testUnsubscribeComponentListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testUnsubscribeComponentListener() {
    TextField textField = (TextField) factory.createComponent(TextField.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setName("testName");
    textField.setDatasource(userDs, "name");

    // unbind
    textField.setDatasource(null, null);

    Component.ValueChangeListener listener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    textField.addValueChangeListener(listener);
    user.setName("anotherName");
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:19,代码来源:TextFieldDsTest.java

示例4: testValueChangeListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testValueChangeListener() {
    LookupField lookupField = factory.createComponent(LookupField.class);

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    lookupField.setOptionsDatasource(groupsDs);
    List<Group> groups = new ArrayList<>(groupsDs.getItems());

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setGroup(groups.get(0));

    boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
    lookupField.addValueChangeListener(listener);

    lookupField.setDatasource(userDs, "group");
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:LookupFieldDsTest.java

示例5: testUnsubscribeComponentListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testUnsubscribeComponentListener() {
    LookupPickerField component = (LookupPickerField) factory.createComponent(LookupPickerField.NAME);

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    component.setOptionsDatasource(groupsDs);
    List<Group> groups = new ArrayList<>(groupsDs.getItems());

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setGroup(groups.get(0));

    component.setDatasource(userDs, "group");

    // unbind
    component.setDatasource(null, null);

    Component.ValueChangeListener listener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    component.addValueChangeListener(listener);

    user.setGroup(metadata.create(Group.class));
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:LookupPickerFieldDsTest.java

示例6: testUnsubscribeComponentListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testUnsubscribeComponentListener() {
    SearchField searchField = factory.createComponent(SearchField.class);

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    searchField.setOptionsDatasource(groupsDs);

    Datasource<User> userDs = getTestUserDatasource();
    Group group = groupsDs.getItems().iterator().next();
    User user = userDs.getItem();
    user.setGroup(group);
    searchField.setDatasource(userDs, "group");

    // unbind
    searchField.setDatasource(null, null);

    Component.ValueChangeListener listener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    searchField.addValueChangeListener(listener);

    user.setGroup(metadata.create(Group.class));
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:SearchFieldDsTest.java

示例7: testUnsubscribeComponentListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testUnsubscribeComponentListener() {
    OptionsGroup optionsGroup = (OptionsGroup) factory.createComponent(OptionsGroup.NAME);

    Datasource<Role> roleDs = getTestRoleDatasource();
    optionsGroup.setDatasource(roleDs, "type");
    optionsGroup.setValue(RoleType.STANDARD);

    optionsGroup.setDatasource(null, null);

    Component.ValueChangeListener listener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    optionsGroup.addValueChangeListener(listener);

    roleDs.getItem().setType(RoleType.DENYING);
    assertEquals(RoleType.STANDARD, optionsGroup.getValue());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:19,代码来源:OptionsGroupDsTest.java

示例8: testUnsubscribeSubscribeComponentListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testUnsubscribeSubscribeComponentListener() {
    OptionsList optionsList = (OptionsList) factory.createComponent(OptionsList.NAME);

    Datasource<Role> roleDs = getTestRoleDatasource();
    roleDs.getItem().setType(RoleType.DENYING);
    optionsList.setDatasource(roleDs, "type");

    optionsList.setDatasource(null, null);

    // datasource before listener
    optionsList.setDatasource(roleDs, "type");

    boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
    optionsList.addValueChangeListener(listener);

    roleDs.getItem().setType(RoleType.READONLY);
    Assert.assertEquals(true, valueWasChanged[0]);

    // reset state
    valueWasChanged[0] = false;
    optionsList.removeValueChangeListener(listener);
    optionsList.setDatasource(null, null);
    optionsList.setValue(null);

    // listener before datasource
    optionsList.addValueChangeListener(listener);
    optionsList.setDatasource(roleDs, "type");
    Assert.assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:32,代码来源:OptionsListDsTest.java

示例9: testValueChangeListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testValueChangeListener() {
    Label label = (Label) factory.createComponent(Label.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setName("testName");
    label.setDatasource(userDs, "name");

    // listener after datasource
    boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
    label.addValueChangeListener(listener);

    user.setName("anotherName");
    assertEquals(true, valueWasChanged[0]);

    // reset state
    label.removeValueChangeListener(listener);
    label.setDatasource(null, null);
    valueWasChanged[0] = false;
    label.setValue("testName");

    // datasource after listener
    label.addValueChangeListener(listener);
    label.setDatasource(userDs, "name");

    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:30,代码来源:LabelDsTest.java

示例10: testValueChangeListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testValueChangeListener() {
    DateField dateField = (DateField) factory.createComponent(DateField.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setUpdateTs(new Date());

    // listener before datasource
    Boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
    dateField.addValueChangeListener(listener);

    dateField.setDatasource(userDs, "updateTs");
    assertEquals(true, valueWasChanged[0]);

    // reset state
    dateField.setDatasource(null, null);
    dateField.removeValueChangeListener(listener);
    valueWasChanged[0] = false;

    // datasource before listener
    dateField.setDatasource(userDs, "updateTs");
    dateField.addValueChangeListener(listener);

    user.setUpdateTs(new Date());
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:29,代码来源:DateFieldDsTest.java

示例11: testUnsubscribeSubscribeComponentListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testUnsubscribeSubscribeComponentListener() {
    DatePicker datePicker = (DatePicker) factory.createComponent(DatePicker.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    Date updateTs = new Date();
    user.setUpdateTs(updateTs);
    datePicker.setDatasource(userDs, "updateTs");

    // unbind
    datePicker.setDatasource(null, null);

    // datasource before listener
    datePicker.setDatasource(userDs, "updateTs");
    assertEquals(updateTs, datePicker.getValue());

    boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
    datePicker.addValueChangeListener(listener);

    Date updateTs2 = new Date();
    user.setUpdateTs(updateTs2);
    assertEquals(true, valueWasChanged[0]);
    assertEquals(updateTs2, datePicker.getValue());

    // reset state
    datePicker.removeValueChangeListener(listener);
    datePicker.setDatasource(null, null);
    valueWasChanged[0] = false;
    datePicker.setValue(updateTs);

    // listener before datasource

    datePicker.addValueChangeListener(listener);
    datePicker.setDatasource(userDs, "updateTs");
    assertEquals(true, valueWasChanged[0]);
    assertEquals(updateTs2, datePicker.getValue());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:40,代码来源:DatePickerDsTest.java

示例12: testValueChangeListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testValueChangeListener() {
    DatePicker datePicker = (DatePicker) factory.createComponent(DatePicker.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setUpdateTs(new Date());

    // listener before datasource
    Boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
    datePicker.addValueChangeListener(listener);

    datePicker.setDatasource(userDs, "updateTs");
    assertEquals(true, valueWasChanged[0]);

    // reset state
    datePicker.setDatasource(null, null);
    datePicker.removeValueChangeListener(listener);
    valueWasChanged[0] = false;

    // datasource before listener
    datePicker.setDatasource(userDs, "updateTs");
    datePicker.addValueChangeListener(listener);

    user.setUpdateTs(new Date());
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:29,代码来源:DatePickerDsTest.java

示例13: testValueChangeListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testValueChangeListener() {
    PickerField pickerField = (PickerField) factory.createComponent(PickerField.NAME);

    Datasource<User> userDs = getTestUserDatasource();

    User user = userDs.getItem();
    Group group = metadata.create(Group.class);
    group.setName("Test group");
    user.setGroup(group);

    // datasource before listener

    boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
    pickerField.addValueChangeListener(listener);

    pickerField.setDatasource(userDs, "group");
    assertEquals(true, valueWasChanged[0]);

    // reset state
    pickerField.setDatasource(null, null);
    pickerField.removeValueChangeListener(listener);
    valueWasChanged[0] = false;
    pickerField.setValue(null);

    // listener before datasource
    pickerField.addValueChangeListener(listener);
    pickerField.setDatasource(userDs, "group");
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:32,代码来源:PickerFieldDsTest.java

示例14: testUnsubscribeSubscribeComponentListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testUnsubscribeSubscribeComponentListener() {
    PickerField pickerField = (PickerField) factory.createComponent(PickerField.NAME);

    Datasource<User> userDs = getTestUserDatasource();

    User user = userDs.getItem();
    Group group = metadata.create(Group.class);
    group.setName("Test group");
    user.setGroup(group);

    pickerField.setDatasource(userDs, "group");

    // unbind
    pickerField.setDatasource(null, null);

    // setup
    boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;

    // datasource before listener

    pickerField.setDatasource(userDs, "group");
    pickerField.addValueChangeListener(listener);

    user.setGroup(null);
    assertEquals(true, valueWasChanged[0]);

    // reset state
    pickerField.setDatasource(null, null);
    pickerField.removeValueChangeListener(listener);
    valueWasChanged[0] = false;
    user.setGroup(metadata.create(Group.class));

    // listener before datasource
    pickerField.addValueChangeListener(listener);
    pickerField.setDatasource(userDs, "group");

    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:41,代码来源:PickerFieldDsTest.java

示例15: testValueChangeListener

import com.haulmont.cuba.gui.components.Component; //导入方法依赖的package包/类
@Test
public void testValueChangeListener() {
    TextField textField = (TextField) factory.createComponent(TextField.NAME);

    Datasource<User> userDs = getTestUserDatasource();
    userDs.getItem().setName("testName");

    // listener before datasource

    boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
    textField.addValueChangeListener(listener);

    textField.setDatasource(userDs, "name");
    assertEquals(true, valueWasChanged[0]);

    // reset state
    valueWasChanged[0] = false;
    textField.removeValueChangeListener(listener);
    textField.setDatasource(null, null);

    // datasource before listener
    textField.setDatasource(userDs, "name");
    textField.addValueChangeListener(listener);
    userDs.getItem().setName("anotherName");
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:28,代码来源:TextFieldDsTest.java


注:本文中的com.haulmont.cuba.gui.components.Component.ValueChangeListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。