com.vaadin.v7.data.Property类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中com.vaadin.v7.data.Property类的一些代码示例,展示了Property类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Property类的具体详情如下:
包路径:com.vaadin.v7.data.Property
类名称:Property

Property介绍

[英]The Property is a simple data object that contains one typed value. This interface contains methods to inspect and modify the stored value and its type, and the object's read-only state.

The Property also defines the events ReadOnlyStatusChangeEvent and ValueChangeEvent, and the associated listener and notifier interfaces.

The Property.Viewer interface should be used to attach the Property to an external data source. This way the value in the data source can be inspected using the Property interface.

The Property.editor interface should be implemented if the value needs to be changed through the implementing class.
[中]Property是一个简单的数据对象,包含一个类型化的值。此接口包含检查和修改存储值及其类型以及对象只读状态的方法。
Property还定义了事件ReadOnlyStatusChangeEventValueChangeEvent,以及相关的listenernotifier接口。
Property.Viewer接口应用于将属性附加到外部数据源。这样,可以使用Property接口检查数据源中的值。
如果需要通过实现类更改值,则应实现Property.editor接口。

代码示例

代码示例来源:origin: com.vaadin/vaadin-compatibility-server

/**
 * Gets the value from the data source. This is only here because of clarity
 * in the code that handles both the data model value and the field value.
 *
 * @return The value of the property data source
 */
private Object getDataSourceValue() {
  return dataSource.getValue();
}

代码示例来源:origin: OpenNMS/opennms

private void updateValidState(Item item, boolean valid) {
  if (item != null && !Objects.equals(item.getItemProperty("valid").getValue(), valid)) {
    item.getItemProperty("valid").setValue(Boolean.valueOf(valid)); // set the new validity
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public Object generateCell(Table source, Object itemId, Object columnId) {
    final ZoneId userTimeZoneId =  UserTimeZoneExtractor.extractUserTimeZoneIdOrNull(source.getUI());
    final Property property = source.getContainerProperty(itemId, columnId);
    if (property == null || property.getValue() == null) {
      return null;
    }
    String formattedValue;
    if(property.getType().equals(Instant.class)){
      formattedValue = timeformatService.format((Instant) property.getValue(), userTimeZoneId);
    } else if(property.getType().equals(Date.class)){
      formattedValue = timeformatService.format((Date) property.getValue(), userTimeZoneId);
    } else {
      formattedValue = property.toString();
    }
    return formattedValue;
  }
}

代码示例来源:origin: com.vaadin/vaadin-compatibility-server

@Override
public void setValue(T newValue) throws ReadOnlyException {
  // Causes a value change to be sent to this listener which in turn fires
  // a new value change event for this property
  wrappedProperty.setValue(newValue);
}

代码示例来源:origin: com.vaadin/vaadin-compatibility-server

@Override
public Class getType() {
  return wrappedProperty.getType();
}

代码示例来源:origin: com.vaadin/vaadin-compatibility-server

/** Reflects the read-only status of the datasource. */
@Override
public boolean isReadOnly() {
  return dataSource == null ? false : dataSource.isReadOnly();
}

代码示例来源:origin: com.vaadin/vaadin-compatibility-server

/**
 * Sets the Property's read-only mode to the specified status.
 *
 * @param newStatus
 *            the new read-only status of the Property.
 */
@Override
public void setReadOnly(boolean newStatus) {
  if (dataSource != null) {
    dataSource.setReadOnly(newStatus);
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
public void setScale(double scale) {
  m_scaleProperty.setValue(scale);
}

代码示例来源:origin: com.haulmont.cuba/cuba-web

@Override
public Class getType() {
  return itemProperty.getType();
}

代码示例来源:origin: com.vaadin/vaadin-compatibility-server

@Override
public boolean isReadOnly() {
  return wrappedProperty.isReadOnly();
}

代码示例来源:origin: viritin/viritin

/**
 * Sets the Property's read-only mode to the specified status.
 *
 * This functionality is optional, but all properties must implement the
 * <code>isReadOnly</code> mode query correctly.
 *
 * @param newStatus new read-only status of the Property
 * @return this (for method chaining)
 * @see #setReadOnly(boolean)
 */
public default S withReadOnly(boolean newStatus) {
  ((Property) this).setReadOnly(newStatus);
  return (S) this;
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public void buttonClick(Button.ClickEvent event) {
    Long businessServiceId = idProperty.getValue();
    String businessServiceLabel = labelProperty.getValue();
    BusinessServiceVertex vertex = new BusinessServiceVertex(
        businessServiceId,
        businessServiceLabel,
        0 /* does not matter in this case*/);
    fireVertexUpdatedEvent(vertex);
  }
});

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void createDefaultPropertyByPropertyTypeWithNullValue() {
  //WHEN
  Property property = DefaultPropertyUtil.newProperty(null, Long.class);
  //THEN
  assertEquals(null, property.getValue());
  assertEquals(Long.class, property.getType());
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
  public void returnsPropertiesWithChangedValues() throws RepositoryException {

    Node parentNode = session.getRootNode().addNode("node");
    parentNode.setProperty("name", "");
    JcrNodeAdapter adapter = new JcrNodeAdapter(parentNode);

    Property itemProperty1 = adapter.getItemProperty("name");

    itemProperty1.setValue("changed");

    Property itemProperty2 = adapter.getItemProperty("name");

    assertThat(itemProperty2.getValue(), equalTo("changed"));
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public void setItemProperties(Item item, Object itemId) {
    item.getItemProperty(MBeansTree.MetaMBeansTreeItem.ICON).setValue(Config.Icons.DUMMY);
    item.getItemProperty(MBeansTree.MetaMBeansTreeItem.CAPTION).setValue(((Map.Entry) itemId).getValue());
    item.getItemProperty(MBeansTree.MetaMBeansTreeItem.TOOLTIP).setValue(((Map.Entry) itemId).getValue());
  }
}

代码示例来源:origin: com.vaadin/vaadin-compatibility-server

/**
 * Constructs a new <code>DateField</code> that's bound to the specified
 * <code>Property</code> and has no caption.
 *
 * @param dataSource
 *            the Property to be edited with this editor.
 */
public DateField(Property dataSource) throws IllegalArgumentException {
  if (!Date.class.isAssignableFrom(dataSource.getType())) {
    throw new IllegalArgumentException(
        "Can't use " + dataSource.getType().getName()
            + " typed property as datasource");
  }
  setPropertyDataSource(dataSource);
}

代码示例来源:origin: com.haulmont.cuba/cuba-web

@Override
public boolean isReadOnly() {
  return itemProperty.isReadOnly();
}

代码示例来源:origin: com.haulmont.cuba/cuba-web

@Override
public void setReadOnly(boolean newStatus) {
  itemProperty.setReadOnly(newStatus);
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public void valueChange(ValueChangeEvent event) {
    if (Boolean.TRUE.equals(event.getProperty().getValue())) {
      m_selectedCheckboxes.add(property.getValue());
      m_notSelectedCheckboxes.remove(property.getValue());
    } else {
      m_selectedCheckboxes.remove(property.getValue());
      m_notSelectedCheckboxes.add(property.getValue());
    }
  }
});

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void testGetItemPropertyWithBooleanPropertyFromJcr() throws Exception {
  // GIVEN
  // Create a NewNodeAdapter
  String nodeName = "rootNode";
  String id = "propertyID";
  Boolean value = Boolean.TRUE;
  Node parentNode = session.getRootNode().addNode(nodeName);
  // Create the JCR property
  parentNode.setProperty(id, value);
  session.save();
  JcrNodeAdapter adapter = new JcrNodeAdapter(parentNode);
  // WHEN
  Property property = adapter.getItemProperty(id);
  // THEN
  assertEquals(PropertyType.nameFromValue(PropertyType.BOOLEAN), property.getType().getSimpleName());
  assertEquals(value, property.getValue());
}

相关文章

微信公众号

最新文章

更多