Codota Logo
Field.getPropertyDataSource
Code IndexAdd Codota to your IDE (free)

How to use
getPropertyDataSource
method
in
com.vaadin.v7.ui.Field

Best Java code snippets using com.vaadin.v7.ui.Field.getPropertyDataSource (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: com.vaadin/vaadin-compatibility-server

private void commitTransactions() {
  for (Field<?> f : fieldToPropertyId.keySet()) {
    ((Property.Transactional<?>) f.getPropertyDataSource()).commit();
  }
}
origin: com.vaadin/vaadin-compatibility-server

private void rollbackTransactions() {
  for (Field<?> f : fieldToPropertyId.keySet()) {
    try {
      ((Property.Transactional<?>) f.getPropertyDataSource())
          .rollback();
    } catch (Exception rollbackException) {
      // FIXME: What to do ?
    }
  }
}
origin: com.vaadin/vaadin-compatibility-server

private void startTransactions() throws CommitException {
  for (Field<?> f : fieldToPropertyId.keySet()) {
    Property.Transactional<?> property = (Property.Transactional<?>) f
        .getPropertyDataSource();
    if (property == null) {
      throw new CommitException(
          "Property \"" + fieldToPropertyId.get(f)
              + "\" not bound to datasource.");
    }
    property.startTransaction();
  }
}
origin: com.vaadin/vaadin-compatibility-server

/**
 * Sets the read only state to the given value for all fields with writable
 * data source. Fields with read only data source will always be set to read
 * only.
 *
 * @param fieldsReadOnly
 *            true to set the fields with writable data source to read only,
 *            false to set them to read write
 */
public void setReadOnly(boolean fieldsReadOnly) {
  readOnly = fieldsReadOnly;
  for (Field<?> field : getFields()) {
    if (field.getPropertyDataSource() == null
        || !field.getPropertyDataSource().isReadOnly()) {
      field.setReadOnly(fieldsReadOnly);
    } else {
      field.setReadOnly(true);
    }
  }
}
origin: viritin/viritin

/**
 * Configures a field with the settings set for this FieldBinder.
 * <p>
 * By default this updates the buffered, read only and enabled state of the
 * field. Also adds validators when applicable. Fields with read only data
 * source are always configured as read only.
 * <p>
 * Unlike the default implementation in FieldGroup, MBeanFieldGroup only
 * makes field read only based on the property's hint, not the opposite.
 * This way developer can in form code choose to make some fields read only.
 *
 * @param field The field to update
 */
@Override
protected void configureField(Field<?> field) {
  boolean readOnlyStatus = isReadOnly() || field.getPropertyDataSource().isReadOnly();
  super.configureField(field);
  // reset the badly set readOnlyStatus
  field.setReadOnly(readOnlyStatus);
}
origin: com.vaadin/vaadin-compatibility-server

/**
 * Configures a field with the settings set for this FieldBinder.
 * <p>
 * By default this updates the buffered, read only and enabled state of the
 * field. Also adds validators when applicable. Fields with read only data
 * source are always configured as read only.
 *
 * @param field
 *            The field to update
 */
protected void configureField(Field<?> field) {
  field.setBuffered(isBuffered());
  field.setEnabled(isEnabled());
  if (field.getPropertyDataSource().isReadOnly()) {
    field.setReadOnly(true);
  } else {
    field.setReadOnly(isReadOnly());
  }
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void simpleInitializationTest() {
  // GIVEN
  fieldFactory = new TestTextFieldFactory(definition, baseItem, null, i18NAuthoringSupport);
  fieldFactory.setComponentProvider(this.componentProvider);
  // WHEN
  Field<Object> field = fieldFactory.createField();
  // THEN
  assertTrue(TextField.class.isAssignableFrom(field.getClass()));
  assertEquals(definition, fieldFactory.getFieldDefinition());
  assertEquals(false, field.isRequired());
  assertEquals("label", field.getCaption());
  assertEquals(false, field.getPropertyDataSource().isReadOnly());
  assertEquals(true, field.getPropertyDataSource() instanceof TransformedProperty);
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void changePropertyValueTest() throws Exception {
  // GIVEN
  fieldFactory = new TestTextFieldFactory(definition, baseItem, null, i18NAuthoringSupport);
  fieldFactory.setComponentProvider(this.componentProvider);
  Field<Object> field = fieldFactory.createField();
  // WHEN
  field.setValue("new Value");
  // THEN
  Node res = ((JcrNodeAdapter) baseItem).applyChanges();
  assertEquals(true, res.hasProperty(propertyName));
  assertEquals("new Value", res.getProperty(propertyName).getString());
  assertEquals(PropertyType.STRING, res.getProperty(propertyName).getType());
  Property p = baseItem.getItemProperty(propertyName);
  assertEquals(field.getPropertyDataSource().getValue(), p.getValue());
  assertEquals("new Value", p.getValue());
  assertEquals(String.class, p.getValue().getClass());
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void preselectsFirstSelectedOptionWithConverter() throws Exception {
  // GIVEN a factory/field backed by a Float property, with a converter explicitly configured
  baseItem = new PropertysetItem();
  ObjectProperty<Float> preTypedProperty = new ObjectProperty<>(null, Float.class);
  baseItem.addItemProperty("floaty", preTypedProperty);
  // and some float options (with 2.5 and 3.5 marked selected)
  for (SelectFieldOptionDefinition optionDefinition : definition.getOptions()) {
    optionDefinition.setValue(optionDefinition.getValue() + ".5");
  }
  definition.getOptions().get(1).setSelected(true);
  definition.getOptions().get(2).setSelected(true);
  definition.setType(null);
  definition.setConverterClass(StringToFloatConverter.class);
  initializeSelectFieldFactory();
  // WHEN
  Field field = dialogSelect.createField();
  // THEN
  Property<?> p = field.getPropertyDataSource();
  assertThat(p.getValue(), equalTo((Object) 2.5f));
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void testDefaultValue() throws Exception {
  // GIVEN
  baseItem = new JcrNewNodeAdapter(baseNode, baseNode.getPrimaryNodeType().getName());
  checkBoxField = new CheckBoxFieldFactory(definition, baseItem, uiContext, i18NAuthoringSupport);
  checkBoxField.setComponentProvider(componentProvider);
  definition.setDefaultValue("true");
  // WHEN
  Field<Boolean> field = checkBoxField.createField();
  // THEN
  assertEquals(true, field.getPropertyDataSource().getValue());
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void testGetHiddenFieldPropertyDataSourceWhenItemNodeDoesNotIncludeHiddenProperty() throws Exception {
  // GIVEN
  definition.setDefaultValue("test");
  factory = new HiddenFieldFactory(definition, baseItem, uiContext, i18NAuthoringSupport);
  factory.setComponentProvider(componentProvider);
  // WHEN
  Field<?> field = factory.createField();
  // THEN
  Property<?> p = field.getPropertyDataSource();
  assertNotNull(p);
  assertEquals("test", p.getValue().toString());
  assertEquals("test", baseItem.getItemProperty("hiddenProperty").getValue());
  assertEquals("test", field.getValue());
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void supportsPropertysetItemWithNonExistingProperty() throws Exception {
  // GIVEN
  baseItem = new PropertysetItem();
  baseItem.addItemProperty("foo", new ObjectProperty<>("fooValue"));
  ConfiguredFieldDefinition def = createConfiguredFieldDefinition(new ConfiguredFieldDefinition(), "bar");
  fieldFactory = new TestTextFieldFactory(def, baseItem, null, i18NAuthoringSupport);
  fieldFactory.setComponentProvider(this.componentProvider);
  // WHEN
  Field<?> field = fieldFactory.createField();
  // THEN
  Property<?> p = field.getPropertyDataSource();
  assertNotNull(p);
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void preselectsFirstOptionIfNoneSelectedWithConverter() throws Exception {
  // GIVEN a factory/field backed by a Float property, with a converter explicitly configured
  baseItem = new PropertysetItem();
  ObjectProperty<Float> preTypedProperty = new ObjectProperty<>(null, Float.class);
  baseItem.addItemProperty("floaty", preTypedProperty);
  // and some float options (with none selected)
  for (SelectFieldOptionDefinition optionDefinition : definition.getOptions()) {
    optionDefinition.setValue(optionDefinition.getValue() + ".5");
  }
  definition.setType(null);
  definition.setConverterClass(StringToFloatConverter.class);
  initializeSelectFieldFactory();
  // WHEN
  Field field = dialogSelect.createField();
  // THEN first option is selected
  Property<?> p = field.getPropertyDataSource();
  assertThat(p.getValue(), equalTo((Object) 1.5f));
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void supportsBeanItem() throws Exception {
  // GIVEN
  baseItem = new BeanItem<>(new TestBean("bar"));
  ConfiguredFieldDefinition def = createConfiguredFieldDefinition(new ConfiguredFieldDefinition(), "foo");
  fieldFactory = new TestTextFieldFactory(def, baseItem, null, i18NAuthoringSupport);
  fieldFactory.setComponentProvider(this.componentProvider);
  // WHEN
  Field<?> field = fieldFactory.createField();
  // THEN
  Property<?> p = field.getPropertyDataSource();
  assertEquals("bar", p.getValue());
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void supportsPropertysetItem() throws Exception {
  // GIVEN
  baseItem = new PropertysetItem();
  baseItem.addItemProperty("foo", new ObjectProperty<>("fooValue"));
  ConfiguredFieldDefinition def = createConfiguredFieldDefinition(new ConfiguredFieldDefinition(), "foo");
  fieldFactory = new TestTextFieldFactory(def, baseItem, null, i18NAuthoringSupport);
  fieldFactory.setComponentProvider(this.componentProvider);
  // WHEN
  Field<?> field = fieldFactory.createField();
  // THEN
  Property<?> p = field.getPropertyDataSource();
  assertEquals("fooValue", p.getValue());
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void testGetHiddenFieldPropertyDataSourceWhenItemNodeIncludesHiddenProperty() throws Exception {
  // GIVEN
  definition.setDefaultValue("test2");
  baseItem.addItemProperty("hiddenProperty", new ObjectProperty<>("test1"));
  factory = new HiddenFieldFactory(definition, baseItem, uiContext, i18NAuthoringSupport);
  factory.setComponentProvider(componentProvider);
  // WHEN
  Field<?> field = factory.createField();
  // THEN
  Property<?> p = field.getPropertyDataSource();
  assertNotNull(p);
  assertEquals("test1", p.getValue().toString());
  assertEquals("test1", baseItem.getItemProperty("hiddenProperty").getValue());
  assertEquals("test1", field.getValue());
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void supportsBeanItemWithEnumMemberAndDefaultValue() throws Exception {
  // GIVEN
  baseItem = new BeanItem<>(new TestBean(null));
  ConfiguredFieldDefinition def = createConfiguredFieldDefinition(new ConfiguredFieldDefinition(), "breakfast");
  def.setType("info.magnolia.ui.form.field.factory.AbstractFieldFactoryTest$Breakfast");
  def.setDefaultValue(Breakfast.BAKED_BEANS.name());
  fieldFactory = new TestTextFieldFactory(def, baseItem, null, i18NAuthoringSupport);
  fieldFactory.setComponentProvider(this.componentProvider);
  // WHEN
  Field field = fieldFactory.createField();
  // THEN
  Property<?> p = field.getPropertyDataSource();
  assertEquals(Breakfast.BAKED_BEANS, p.getValue());
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void supportsBeanItemWithEnumMemberViaListToSetTransformer() throws Exception {
  // GIVEN
  baseItem = new BeanItem<>(new TestBean(null));
  ConfiguredFieldDefinition def = createConfiguredFieldDefinition(new ConfiguredFieldDefinition(), "breakfast");
  def.setType("info.magnolia.ui.form.field.factory.AbstractFieldFactoryTest$Breakfast");
  def.setDefaultValue(Breakfast.BAKED_BEANS.name());
  def.setTransformerClass((Class<? extends Transformer<?>>) (Object) ListToSetTransformer.class);
  fieldFactory = new TestTextFieldFactory(def, baseItem, null, i18NAuthoringSupport);
  fieldFactory.setComponentProvider(this.componentProvider);
  // WHEN
  Field field = fieldFactory.createField();
  // THEN
  Property<?> p = field.getPropertyDataSource();
  assertEquals(Breakfast.BAKED_BEANS, p.getValue());
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void supportsDefaultValueWithConfiguredConverter() throws Exception {
  // GIVEN a factory/field backed by a Float property, with a converter explicitly configured
  baseItem = new PropertysetItem();
  ObjectProperty<Float> preTypedProperty = new ObjectProperty<>(null, Float.class);
  baseItem.addItemProperty("floaty", preTypedProperty);
  ConfiguredFieldDefinition def = createConfiguredFieldDefinition(new ConfiguredFieldDefinition(), "floaty");
  def.setType(null);
  def.setDefaultValue("0.86");
  def.setConverterClass(StringToFloatConverter.class);
  fieldFactory = new TestTextFieldFactory(def, baseItem, null, i18NAuthoringSupport);
  fieldFactory.setComponentProvider(this.componentProvider);
  // WHEN
  Field<?> field = fieldFactory.createField();
  // THEN
  Property<?> p = field.getPropertyDataSource();
  assertEquals(0.86f, p.getValue());
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void supportsEnumPropertyAndDefaultValue() throws Exception {
  // GIVEN
  baseItem = new PropertysetItem();
  ObjectProperty<Breakfast> preTypedProperty = new ObjectProperty<>(Breakfast.EGGS_AND_BACON);
  preTypedProperty.setValue(null); // resetting actual value, so that defaultValue mechanism kicks in
  baseItem.addItemProperty("breakfast", preTypedProperty);
  ConfiguredFieldDefinition def = createConfiguredFieldDefinition(new ConfiguredFieldDefinition(), "breakfast");
  def.setType("info.magnolia.ui.form.field.factory.AbstractFieldFactoryTest$Breakfast");
  def.setDefaultValue(Breakfast.BAKED_BEANS.name());
  fieldFactory = new TestTextFieldFactory(def, baseItem, null, i18NAuthoringSupport);
  fieldFactory.setComponentProvider(this.componentProvider);
  // WHEN
  Field field = fieldFactory.createField();
  // THEN
  Property<?> p = field.getPropertyDataSource();
  assertEquals(Breakfast.BAKED_BEANS, p.getValue());
}
com.vaadin.v7.uiFieldgetPropertyDataSource

Popular methods of Field

  • setReadOnly
  • getValue
  • setEnabled
  • isReadOnly
  • setCaption
  • validate
  • addValueChangeListener
  • discard
  • getCaption
  • getLocale
  • isModified
  • isRequired
    Is this field required. Required fields must filled by the user.
  • isModified,
  • isRequired,
  • isValid,
  • setRequired,
  • setValue,
  • setVisible,
  • setWidth,
  • addListener,
  • addValidator

Popular in Java

  • Updating database using SQL prepared statement
  • getContentResolver (Context)
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • ArrayList (java.util)
    Resizable-array implementation of the List interface. Implements all optional list operations, and p
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now