本文整理汇总了Java中com.haulmont.cuba.gui.components.CheckBox类的典型用法代码示例。如果您正苦于以下问题:Java CheckBox类的具体用法?Java CheckBox怎么用?Java CheckBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CheckBox类属于com.haulmont.cuba.gui.components包,在下文中一共展示了CheckBox类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUnsubscribeComponentListener
import com.haulmont.cuba.gui.components.CheckBox; //导入依赖的package包/类
@Test
public void testUnsubscribeComponentListener() {
CheckBox checkBox = (CheckBox) factory.createComponent(CheckBox.NAME);
Datasource<User> userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setActive(true);
checkBox.setDatasource(userDs, "active");
// unbind
checkBox.setDatasource(null, null);
Component.ValueChangeListener valueChangeListener = e -> {
throw new RuntimeException("Value was changed externally");
};
checkBox.addValueChangeListener(valueChangeListener);
user.setActive(false);
assertEquals(true, checkBox.getValue());
}
示例2: testUnsubscribeDsListener
import com.haulmont.cuba.gui.components.CheckBox; //导入依赖的package包/类
@Test
public void testUnsubscribeDsListener() {
CheckBox checkBox = (CheckBox) factory.createComponent(CheckBox.NAME);
Datasource<User> userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setActive(true);
checkBox.setDatasource(userDs, "active");
// unbind
checkBox.setDatasource(null, null);
Datasource.ItemPropertyChangeListener<User> propertyChangeListener = e -> {
throw new RuntimeException("Value was changed externally");
};
userDs.addItemPropertyChangeListener(propertyChangeListener);
checkBox.setValue(false);
assertEquals(true, user.getActive());
}
示例3: testUnsubscribeSubscribeDsListener
import com.haulmont.cuba.gui.components.CheckBox; //导入依赖的package包/类
@Test
public void testUnsubscribeSubscribeDsListener() {
CheckBox checkBox = (CheckBox) factory.createComponent(CheckBox.NAME);
Datasource<User> userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setActive(true);
checkBox.setDatasource(userDs, "active");
// unbind
checkBox.setDatasource(null, null);
// setup
boolean[] valueWasChanged = {false};
Datasource.ItemPropertyChangeListener<User> listener = e -> valueWasChanged[0] = true;
userDs.addItemPropertyChangeListener(listener);
checkBox.setDatasource(userDs, "active");
checkBox.setValue(false);
assertEquals(true, valueWasChanged[0]);
assertEquals(false, user.getActive());
}
示例4: EntityNameFilter
import com.haulmont.cuba.gui.components.CheckBox; //导入依赖的package包/类
public EntityNameFilter(Metadata metadata, CheckBox assignedOnlyCheckBox, CheckBox systemLevelCheckBox,
TextField entityFilter) {
this.metadata = metadata;
this.assignedOnlyCheckBox = assignedOnlyCheckBox;
this.systemLevelCheckBox = systemLevelCheckBox;
this.entityFilter = entityFilter;
}
示例5: testUnsubscribeSubscribeComponentListener
import com.haulmont.cuba.gui.components.CheckBox; //导入依赖的package包/类
@Test
public void testUnsubscribeSubscribeComponentListener() {
CheckBox checkBox = (CheckBox) factory.createComponent(CheckBox.NAME);
Datasource<User> userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setActive(true);
checkBox.setDatasource(userDs, "active");
// unbind
checkBox.setDatasource(null, null);
// datasource before listener
checkBox.setDatasource(userDs, "active");
assertEquals(true, checkBox.getValue());
boolean[] valueWasChanged = {false};
Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
checkBox.addValueChangeListener(listener);
user.setActive(false);
assertEquals(true, valueWasChanged[0]);
assertEquals(false, checkBox.getValue());
// reset state
checkBox.removeValueChangeListener(listener);
checkBox.setDatasource(null, null);
valueWasChanged[0] = false;
checkBox.setValue(true);
// listener before datasource
checkBox.addValueChangeListener(listener);
checkBox.setDatasource(userDs, "active");
assertEquals(true, valueWasChanged[0]);
assertEquals(false, checkBox.getValue());
}
示例6: testValueChangeListener
import com.haulmont.cuba.gui.components.CheckBox; //导入依赖的package包/类
@Test
public void testValueChangeListener() {
CheckBox checkBox = (CheckBox) factory.createComponent(CheckBox.NAME);
Datasource<User> userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setActive(true);
// listener before datasource
Boolean[] valueWasChanged = {false};
Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
checkBox.addValueChangeListener(listener);
checkBox.setDatasource(userDs, "active");
assertEquals(true, valueWasChanged[0]);
// reset state
checkBox.setDatasource(null, null);
checkBox.removeValueChangeListener(listener);
valueWasChanged[0] = false;
// datasource before listener
checkBox.setDatasource(userDs, "active");
checkBox.addValueChangeListener(listener);
user.setActive(false);
assertEquals(true, valueWasChanged[0]);
}
示例7: createField
import com.haulmont.cuba.gui.components.CheckBox; //导入依赖的package包/类
@Override
public com.vaadin.ui.Field<?> createField(com.vaadin.data.Container container,
Object itemId, Object propertyId, Component uiContext) {
String fieldPropertyId = String.valueOf(propertyId);
Column columnConf = webTable.columns.get(propertyId);
Item item = container.getItem(itemId);
Entity entity = ((ItemWrapper) item).getItem();
Datasource fieldDatasource = webTable.getItemDatasource(entity);
com.haulmont.cuba.gui.components.Component columnComponent =
createField(fieldDatasource, fieldPropertyId, columnConf.getXmlDescriptor());
if (columnComponent instanceof Field) {
Field cubaField = (Field) columnComponent;
if (webTable.requiredColumns != null && webTable.requiredColumns.containsKey(columnConf)) {
cubaField.setRequired(true);
cubaField.setRequiredMessage(webTable.requiredColumns.get(columnConf));
}
}
if (!(columnComponent instanceof CheckBox)) {
columnComponent.setWidthFull();
}
if (columnComponent instanceof BelongToFrame) {
BelongToFrame belongToFrame = (BelongToFrame) columnComponent;
if (belongToFrame.getFrame() == null) {
belongToFrame.setFrame(webTable.getFrame());
}
}
applyPermissions(columnComponent);
columnComponent.setParent(webTable);
Component componentImpl = getComponentImplementation(columnComponent);
if (componentImpl instanceof com.vaadin.ui.Field) {
return (com.vaadin.ui.Field<?>) componentImpl;
}
return new EditableColumnFieldWrapper(componentImpl, columnComponent);
}
示例8: createComponent
import com.haulmont.cuba.gui.components.CheckBox; //导入依赖的package包/类
@Override
public void createComponent() {
resultComponent = (CheckBox) factory.createComponent(CheckBox.NAME);
loadId(resultComponent, element);
}