本文整理汇总了Java中com.haulmont.cuba.gui.components.OptionsGroup.addValueChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java OptionsGroup.addValueChangeListener方法的具体用法?Java OptionsGroup.addValueChangeListener怎么用?Java OptionsGroup.addValueChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.haulmont.cuba.gui.components.OptionsGroup
的用法示例。
在下文中一共展示了OptionsGroup.addValueChangeListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUnsubscribeComponentListener
import com.haulmont.cuba.gui.components.OptionsGroup; //导入方法依赖的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());
}
示例2: testUnsubscribeSubscribeComponentListener
import com.haulmont.cuba.gui.components.OptionsGroup; //导入方法依赖的package包/类
@Test
public void testUnsubscribeSubscribeComponentListener() {
OptionsGroup optionsGroup = (OptionsGroup) factory.createComponent(OptionsGroup.NAME);
Datasource<Role> roleDs = getTestRoleDatasource();
roleDs.getItem().setType(RoleType.DENYING);
optionsGroup.setDatasource(roleDs, "type");
optionsGroup.setDatasource(null, null);
// datasource before listener
optionsGroup.setDatasource(roleDs, "type");
boolean[] valueWasChanged = {false};
Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
optionsGroup.addValueChangeListener(listener);
roleDs.getItem().setType(RoleType.READONLY);
assertEquals(true, valueWasChanged[0]);
// reset state
valueWasChanged[0] = false;
optionsGroup.removeValueChangeListener(listener);
optionsGroup.setDatasource(null, null);
optionsGroup.setValue(null);
// listener before datasource
optionsGroup.addValueChangeListener(listener);
optionsGroup.setDatasource(roleDs, "type");
assertEquals(true, valueWasChanged[0]);
}
示例3: testValueChangeListener
import com.haulmont.cuba.gui.components.OptionsGroup; //导入方法依赖的package包/类
@Test
public void testValueChangeListener() {
OptionsGroup optionsGroup = (OptionsGroup) factory.createComponent(OptionsGroup.NAME);
// listener before datasource
boolean[] valueWasChanged = {false};
Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
optionsGroup.addValueChangeListener(listener);
Datasource<Role> roleDs = getTestRoleDatasource();
roleDs.getItem().setType(RoleType.READONLY);
optionsGroup.setDatasource(roleDs, "type");
assertTrue(valueWasChanged[0]);
// reset state
valueWasChanged[0] = false;
optionsGroup.removeValueChangeListener(listener);
optionsGroup.setDatasource(null, null);
// datasource before listener
optionsGroup.setDatasource(roleDs, "type");
optionsGroup.addValueChangeListener(listener);
roleDs.getItem().setType(RoleType.DENYING);
assertTrue(valueWasChanged[0]);
}