本文整理匯總了Java中com.vaadin.data.Property.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java Property.getType方法的具體用法?Java Property.getType怎麽用?Java Property.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vaadin.data.Property
的用法示例。
在下文中一共展示了Property.getType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildAndBindField
import com.vaadin.data.Property; //導入方法依賴的package包/類
/**
* Method called to generate and bind the Field component corresponding to a
* scalar property
* @param label
* @param propId
* @param prop
* @return the generated Field object
*/
protected Field<?> buildAndBindField(String label, String propId, Property<?> prop)
{
Field<?> field = fieldGroup.buildAndBind(label, propId);
Class<?> propType = prop.getType();
if (propId.equals(PROP_ID))
field.setReadOnly(true);
else if (propId.endsWith("." + PROP_ID))
field.setVisible(false);
else if (propId.endsWith("." + PROP_NAME))
field.setVisible(false);
else if (propId.endsWith(PROP_ENABLED))
field.setVisible(false);
else if (propId.endsWith(PROP_MODULECLASS))
field.setReadOnly(true);
if (propType.equals(String.class))
field.setWidth(500, Unit.PIXELS);
else if (propType.equals(int.class) || propType.equals(Integer.class) ||
propType.equals(float.class) || propType.equals(Float.class) ||
propType.equals(double.class) || propType.equals(Double.class))
field.setWidth(200, Unit.PIXELS);
else if (Enum.class.isAssignableFrom(propType))
((ListSelect)field).setRows(3);
if (field instanceof TextField) {
((TextField)field).setNullSettingAllowed(true);
((TextField)field).setNullRepresentation("");
}
return field;
}
示例2: formatPropertyValue
import com.vaadin.data.Property; //導入方法依賴的package包/類
@Override
protected String formatPropertyValue(Object rowId, Object colId, Property<?> property) {
if (property.getValue() != null) {
if (property.getType() == Date.class) {
return CommonUiUtils.formatDateTime((Date) property.getValue());
}
}
return super.formatPropertyValue(rowId, colId, property);
}
示例3: createField
import com.vaadin.data.Property; //導入方法依賴的package包/類
@Override
public Field createField(Container container, Object itemId, Object propertyId, Component uiContext) {
Property containerProperty = container.getContainerProperty(itemId, propertyId);
Class<?> type = containerProperty.getType();
Field field = createFieldByPropertyType(type);
field.setCaption(createCaptionByPropertyId(propertyId));
return field;
}
示例4: testPropertyBoxItem
import com.vaadin.data.Property; //導入方法依賴的package包/類
@Test
public void testPropertyBoxItem() {
PropertyBox box = PropertyBox.builder(TestData.PROPERTIES).set(TestData.ID, "id")
.set(TestData.DESCRIPTION, "des").set(TestData.SEQUENCE, 1).set(TestData.OBSOLETE, true).build();
final Item item = PropertyBoxItem.create(box);
Collection<?> ids = item.getItemPropertyIds();
assertNotNull(ids);
assertEquals(4, ids.size());
assertTrue(ids.contains(TestData.ID));
assertTrue(ids.contains(TestData.DESCRIPTION));
assertTrue(ids.contains(TestData.SEQUENCE));
assertTrue(ids.contains(TestData.OBSOLETE));
Property<?> p = item.getItemProperty(TestData.ID);
assertNotNull(p);
Class<?> type = p.getType();
assertEquals(String.class, type);
Object value = p.getValue();
assertEquals("id", value);
p = item.getItemProperty(TestData.DESCRIPTION);
assertNotNull(p);
type = p.getType();
assertEquals(String.class, type);
value = p.getValue();
assertEquals("des", value);
p = item.getItemProperty(TestData.SEQUENCE);
assertNotNull(p);
type = p.getType();
assertEquals(Integer.class, type);
value = p.getValue();
assertEquals(1, value);
p = item.getItemProperty(TestData.OBSOLETE);
assertNotNull(p);
type = p.getType();
assertTrue(Boolean.class.isAssignableFrom(type));
value = p.getValue();
assertEquals(Boolean.TRUE, value);
p = item.getItemProperty(TestData.OBSOLETE);
assertNotNull(p);
p = item.getItemProperty("invalid");
assertNull(p);
TestUtils.expectedException(UnsupportedOperationException.class, new Runnable() {
@Override
public void run() {
item.addItemProperty("invalid", null);
}
});
TestUtils.expectedException(UnsupportedOperationException.class, new Runnable() {
@Override
public void run() {
item.removeItemProperty("invalid");
}
});
Item item2 = PropertyBoxItem.create(box);
p = item2.getItemProperty(TestData.ID);
assertNotNull(p);
assertFalse(p.isReadOnly());
}