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

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

Best Java code snippets using com.vaadin.v7.ui.Field (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

/**
 * 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: OpenNMS/opennms

protected List<String> getNames() {
  Map<Object, String> objectToNameMap = provider.getNamesMap();
  if (fieldProvider == null) {
    return new ArrayList<>(objectToNameMap.values());
  }
  final Map<Object, String> clonedMap = new HashMap<>(objectToNameMap);
  final Map<Object, Field<String>> fieldValuesToMerge = fieldProvider.getObjectFieldMap();
  for (Map.Entry<Object, Field<String>> eachEntry : fieldValuesToMerge.entrySet()) {
    clonedMap.put(eachEntry.getKey(), eachEntry.getValue().getValue());
  }
  return new ArrayList<>(clonedMap.values());
}
origin: com.vaadin/vaadin-compatibility-server

/**
 * Clears field and any possible existing binding.
 *
 * @param field
 *            The field to be cleared
 * @since 7.7.5
 */
protected void clearField(Field<?> field) {
  // Clear any possible existing binding to clear the field
  field.setPropertyDataSource(null);
  boolean fieldReadOnly = field.isReadOnly();
  if (!fieldReadOnly) {
    field.clear();
  } else {
    // Temporarily make the field read-write so we can clear the
    // value. Needed because setPropertyDataSource(null) does not
    // currently clear the field
    // (https://dev.vaadin.com/ticket/14733)
    field.setReadOnly(false);
    field.clear();
    field.setReadOnly(true);
  }
}
origin: OpenNMS/opennms

private void setVisible(Field<?> field, boolean visible) {
  field.setEnabled(visible);
  field.setRequired(visible);
  field.setVisible(visible);
}
origin: OpenNMS/opennms

private void enableField(Field<?> field, boolean enabled) {
  field.setEnabled(enabled);
  // we revert changes, when we disable the fields
  if (!enabled) {
    field.discard();
    // hide validation errors when disabled
    if (field instanceof AbstractComponent) {
      ((AbstractComponent) field).setComponentError(null);
    }
  }
}
@Override
origin: com.vaadin/vaadin-compatibility-server

      + propertyId + "' can not be found.");
final Object value = oldField.getPropertyDataSource() == null
    ? oldField.getValue()
    : oldField.getPropertyDataSource().getValue();
newField.setCaption(oldField.getCaption());
newField.setReadOnly(oldField.isReadOnly());
newField.setBuffered(oldField.isBuffered());
final Property<?> property = oldField.getPropertyDataSource();
oldField.setPropertyDataSource(null);
newField.setPropertyDataSource(property);
fields.put(propertyId, newField);
newField.addListener(fieldValueChangeListener);
oldField.removeListener(fieldValueChangeListener);
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
@Ignore("See http://dev.vaadin.com/ticket/10663")
public void multiSelectTwinColFieldTest() throws Exception {
  // GIVEN
  definition.setMultiselect(true);
  twinSelect = new TwinColSelectFieldFactory(definition, baseItem, null, null, new MockComponentProvider());
  Field field = twinSelect.createField();
  // WHEN
  ArrayList<String> selected = new ArrayList<>();
  selected.add("1");
  selected.add("3");
  field.setValue(selected);
  // THEN
  assertEquals(2, ((Collection) field.getValue()).toArray().length);
  assertEquals("1", ((Collection) field.getValue()).toArray()[0]);
  assertEquals("3", ((Collection) field.getValue()).toArray()[1]);
}
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: de.mhus.lib/mhu-lib-vaadin

@SuppressWarnings("unchecked")
protected Field<?> createField(Container container,
    Object itemId, Object propertyId, Component uiContext) {
  
  ColumnModel model = getColumnModel(String.valueOf(propertyId));
  boolean editable = tableEditable && itemId.equals(editableId) && model.isEditable() ;
  Field<?> f = null;
  Class<?> type = container.getType(propertyId);
  f = createFieldForType(type);
  f.setCaption(null);
  f.setWidth("100%");
  f.setReadOnly(!editable);
  if (f instanceof AbstractField) {
    if (model.getConverter() == null) {
      model.setConverter(findDefaultConverter(model,type));
    }
    if (model.getConverter() != null)
      ((AbstractField<String>)f).setConverter((Converter<String, ?>)model.generateConverter(type));
  }
  return f;
}
origin: com.vaadin/vaadin-compatibility-server

private void commitTransactions() {
  for (Field<?> f : fieldToPropertyId.keySet()) {
    ((Property.Transactional<?>) f.getPropertyDataSource()).commit();
  }
}
origin: info.magnolia.activation/magnolia-module-activation

  keyLength.setEnabled(false);
  keyLength.setReadOnly(true);
  createButton.setEnabled(false);
publicKey.setReadOnly(true);
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: OpenNMS/opennms

@Override
public void selectionChanged(SelectionChangedEvent changeEvent) {
  if (parameter != null) {
    try {
      blockListenerOrValidators = true;
      setData(changeEvent.getSelectedBean());
      setItemId(changeEvent.getSelectedItemId());
      final BeanItem beanItem = new BeanItem(changeEvent.getSelectedBean(), parameter.getEditablePropertyName(), parameter.getNonEditablePropertyName());
      // this is a hack, but we need to know if the selection changed
      beanItem.addItemProperty("selected", changeEvent.getSelectedItem().getItemProperty("selected"));
      captionLabel.setValue(String.format("<b>%s</b>", parameter.getCaption()));
      fieldGroup = new FieldGroup();
      fieldGroup.setBuffered(false);
      fieldGroup.bind(selectedField, "selected");
      fieldGroup.bind(editableField, parameter.getEditablePropertyName());
      fieldGroup.bind(nonEditableField, parameter.getNonEditablePropertyName());
      fieldGroup.setItemDataSource(beanItem);
      fieldGroup.getField(parameter.getNonEditablePropertyName()).setCaption(parameter.getNonEditablePropertyCaption());
      fieldGroup.getField(parameter.getNonEditablePropertyName()).setReadOnly(true);
      fieldGroup.getField(parameter.getEditablePropertyName()).setCaption(parameter.getEditablePropertyCaption());
      fieldGroup.getField(parameter.getEditablePropertyName()).setReadOnly(false);
      updateEnabledState();
      UIHelper.validateField(editableField, true);
    } finally {
      blockListenerOrValidators = false;
    }
  }
}
origin: OpenNMS/opennms

  @Override
  public Field<?> createField(Container container, Object itemId, Object propertyId, Component uiContext) {
    Field<?> field = super.createField(container, itemId, propertyId, uiContext);
    if (propertyId.equals("Key")) {
      field.setReadOnly(true);
    } else {
      field.setSizeFull();
    }
    return field;
  }
});
origin: com.vaadin/vaadin-compatibility-server

/**
 * Binds an item property to a field generated by TableFieldFactory. The
 * default behavior is to bind property straight to Field. If
 * Property.Viewer type property (e.g. PropertyFormatter) is already set for
 * field, the property is bound to that Property.Viewer.
 *
 * @param rowId
 * @param colId
 * @param property
 * @param field
 * @since 6.7.3
 */
protected void bindPropertyToField(Object rowId, Object colId,
    Property property, Field field) {
  // check if field has a property that is Viewer set. In that case we
  // expect developer has e.g. PropertyFormatter that he wishes to use and
  // assign the property to the Viewer instead.
  boolean hasFilterProperty = field.getPropertyDataSource() != null
      && (field.getPropertyDataSource() instanceof Property.Viewer);
  if (hasFilterProperty) {
    ((Property.Viewer) field.getPropertyDataSource())
        .setPropertyDataSource(property);
  } else {
    field.setPropertyDataSource(property);
  }
}
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: com.vaadin/vaadin-compatibility-server

/**
 * Sets the component's to read-only mode to the specified state.
 *
 * @see Component#setReadOnly(boolean)
 */
@Override
public void setReadOnly(boolean readOnly) {
  super.setReadOnly(readOnly);
  for (final Object id : propertyIds) {
    fields.get(id).setReadOnly(readOnly);
  }
}
origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void setReadOnlyDefaultValue() throws Exception {
  // GIVEN
  baseItem = new JcrNewNodeAdapter(baseNode, baseNode.getPrimaryNodeType().getName());
  checkBoxField = new CheckBoxFieldFactory(definition, baseItem, uiContext, i18NAuthoringSupport);
  checkBoxField.setComponentProvider(componentProvider);
  definition.setDefaultValue("true");
  definition.setReadOnly(true);
  // WHEN
  Field<Boolean> field = checkBoxField.createField();
  // THEN
  assertEquals(true, field.getValue());
  assertTrue(field.isReadOnly());
  CheckBox checkBox = (CheckBox) ((CheckBoxField) field).iterator().next();
  assertEquals(true, checkBox.getValue());
  assertTrue(checkBox.isReadOnly());
}
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: viritin/viritin

  getAnnotation(
    NotNull.class);
if (notNullAnnotation != null && !field.isReadOnly()) {
  field.setRequired(true);
  Locale locale = getLocale();
  if (locale == null) {
  getField(property).setRequiredError(msg);
com.vaadin.v7.uiField

Javadoc

Field interface is implemented by all classes (field components) that have a value that the user can change through the user interface. Field components are built upon the framework defined in the Field interface and the AbstractField base class. The Field interface inherits the Component superinterface and also the Property interface to have a value for the field.

Most used methods

  • setReadOnly
  • getValue
  • setEnabled
  • getPropertyDataSource
  • isReadOnly
  • setCaption
  • validate
  • addValueChangeListener
  • discard
  • getCaption
  • getLocale
  • isModified
  • getLocale,
  • isModified,
  • isRequired,
  • isValid,
  • setRequired,
  • setValue,
  • setVisible,
  • setWidth,
  • addListener,
  • addValidator

Popular in Java

  • Finding current android device location
  • setContentView (Activity)
  • addToBackStack (FragmentTransaction)
  • getApplicationContext (Context)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • URLConnection (java.net)
    The abstract class URLConnection is the superclass of all classes that represent a communications li
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • LinkedHashMap (java.util)
    Hash table and linked list implementation of the Map interface, with predictable iteration order. Th
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
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