当前位置: 首页>>代码示例>>Java>>正文


Java TextField类代码示例

本文整理汇总了Java中com.vaadin.ui.TextField的典型用法代码示例。如果您正苦于以下问题:Java TextField类的具体用法?Java TextField怎么用?Java TextField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TextField类属于com.vaadin.ui包,在下文中一共展示了TextField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createComponent

import com.vaadin.ui.TextField; //导入依赖的package包/类
public Optional<Component> createComponent(Field field) {
	Class<?> classToTest = field.getType();
	while (classToTest != null) {
		List<Pair<Predicate<Field>, Function<Field, Component>>> candidates = builders.get(classToTest);
		if (candidates != null) {
			Optional<Pair<Predicate<Field>, Function<Field, Component>>> match = candidates.stream()
					.filter(e -> e.getFirst().test(field)).findFirst();
			if (match.isPresent()) {
				log.log(Level.INFO, "Fould build rule for field=<{0}> using type={1}",
						new Object[] { field, classToTest });
				return Optional.of(match.get().getSecond().apply(field));
			}
		}

		log.log(Level.INFO, "No build rule for field=<{0}> with type=<{1}>", new Object[] { field, classToTest });
		classToTest = classToTest.getSuperclass();
	}

	log.log(Level.INFO, "No match for field=<{1}> with type=<{2}>, generating a text field",
			new Object[] { field, field.getType() });
	return Optional.of(new TextField(SharedUtil.camelCaseToHumanFriendly(field.getName())));
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:23,代码来源:ComponentFactoryRegistry.java

示例2: testReadWriteBeanEmptySetter

import com.vaadin.ui.TextField; //导入依赖的package包/类
@Test
public void testReadWriteBeanEmptySetter() throws ValidationException {
	@SuppressWarnings("unchecked")
	BasicBinder<TestEntity> binder = mock(BasicBinder.class);
	BinderAdapter<TestEntity> binderAdapter = new BinderAdapter<TestEntity>(binder, TestEntity.class);

	when(binder.getBean()).thenReturn(new TestEntity());
	when(binder.isValid()).thenReturn(true);

	EasyBinding<TestEntity, String, Integer> binding = new EasyBinding<>(
			binder,
			new TextField(),
			TestEntity::getTest,
			null,
			"test",
			new StringToIntegerConverter(""));

	when(binder.getBindings()).thenReturn(Arrays.asList(binding));

	TestEntity testEntity = new TestEntity();

	// Just verify that no null pointer exception is thrown
	binderAdapter.readBean(testEntity);
	binderAdapter.writeBean(testEntity);
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:26,代码来源:BinderAdapterTest.java

示例3: testValid

import com.vaadin.ui.TextField; //导入依赖的package包/类
@Test
public void testValid() {
	TextField text = new TextField();

	binder.bind(text, d -> d.getText() == null ? "" : d.getText(), (e, f) -> e.setText("".equals(f) ? null : f),
			"text");

	MyEntity t = new MyEntity();

	t.setText("bla");
	binder.setBean(t);

	assertTrue(binder.isValid());

	text.setValue("");
	assertNull(t.getText());
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:18,代码来源:BasicBinderStringTest.java

示例4: testNullRepresentation

import com.vaadin.ui.TextField; //导入依赖的package包/类
@Test
public void testNullRepresentation() {
	TextField field = new TextField();

	// Bind with null representation
	Binder<MyEntity> binder = new BeanValidationBinder<>(MyEntity.class);
	binder.forField(field).withNullRepresentation("").bind("text");

	MyEntity bean = new MyEntity();

	assertTrue(validator.validate(bean).isEmpty());
	assertTrue(binder.validate().isOk());

	binder.setBean(bean);

	field.setValue("test");
	assertEquals("test", bean.getText());

	field.setValue("");
	assertNull(bean.getText());

	assertTrue(validator.validate(bean).isEmpty());
	assertTrue(binder.validate().isOk());
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:25,代码来源:BeanValidationBinderStringTest.java

示例5: testNullRepresentationSizeMin1

import com.vaadin.ui.TextField; //导入依赖的package包/类
@Test
public void testNullRepresentationSizeMin1() {
	TextField field = new TextField();

	// Bind with null representation
	Binder<MyEntitySizeMin1> binder = new BeanValidationBinder<>(MyEntitySizeMin1.class);
	binder.forField(field).withNullRepresentation("").bind("text");

	MyEntitySizeMin1 bean = new MyEntitySizeMin1();

	assertTrue(validator.validate(bean).isEmpty());
	assertTrue(binder.validate().isOk());

	binder.setBean(bean);

	field.setValue("test");
	assertEquals("test", bean.getText());

	field.setValue("");
	assertNull(bean.getText());

	assertTrue(validator.validate(bean).isEmpty());
	assertTrue(binder.validate().isOk());
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:25,代码来源:BeanValidationBinderStringTest.java

示例6: testBeanClassLevelValidation

import com.vaadin.ui.TextField; //导入依赖的package包/类
@Test
public void testBeanClassLevelValidation() {
	TextField field1 = new TextField();
	TextField field2 = new TextField();
	Label statusLabel = new Label();

	Binder<MyEntity> binder = new BeanValidationBinder<>(MyEntity.class);
	binder.forField(field1).withNullRepresentation("").bind("s1");
	binder.forField(field2).withNullRepresentation("").bind("s2");

	binder.setStatusLabel(statusLabel);

	MyEntity bean = new MyEntity();

	binder.setBean(bean);

	assertFalse(validator.validate(bean).isEmpty());
	assertTrue(binder.validate().isOk());

	// JSR303 bean level validation still missing:
	// https://github.com/vaadin/framework/issues/8498
	// assertFalse(binder.validate().isOk());
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:24,代码来源:BeanValidationBinderBeanLevelTest.java

示例7: setup

import com.vaadin.ui.TextField; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@BeforeClass
public static void setup() {
	binder.buildAndBind("flightId");

	form.airline = (TextField) binder.getFieldForProperty("flightId.airline").get();
	form.flightNumber = (TextField) binder.getFieldForProperty("flightId.flightNumber").get();
	form.flightSuffix = (TextField) binder.getFieldForProperty("flightId.flightSuffix").get();
	form.date = (DateField) binder.getFieldForProperty("flightId.date").get();
	form.legType = (AbstractSingleSelect<LegType>) binder.getFieldForProperty("flightId.legType").get();
	form.sbt = (DateTimeField) binder.getFieldForProperty("sbt").get();
	form.ebt = (DateTimeField) binder.getFieldForProperty("ebt").get();
	form.abt = (DateTimeField) binder.getFieldForProperty("abt").get();
	form.gate = (TextField) binder.getFieldForProperty("gate").get();
	form.canceled = (CheckBox) binder.getFieldForProperty("canceled").get();
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:17,代码来源:BuildAndBindTest.java

示例8: SearchAnneeUnivApoField

import com.vaadin.ui.TextField; //导入依赖的package包/类
/**
 * Constructeur, initialisation du champs
 * @param libelleBtnFind 
 */
public SearchAnneeUnivApoField(String libelleBtnFind) {
	super();
	layout = new HorizontalLayout();
	layout.setSpacing(true);
	anneeField = new TextField();
	anneeField.addValueChangeListener(e->showOrHideError());
	anneeField.setNullRepresentation("");
	anneeField.setReadOnly(true);
	btnSearch = new OneClickButton(libelleBtnFind,FontAwesome.SEARCH);
	btnSearch.addClickListener(e->{
		SearchAnneeUnivApoWindow window = new SearchAnneeUnivApoWindow();
		window.addAnneeUniListener(a->changeFieldValue(a));
		UI.getCurrent().addWindow(window);
	});
	layout.addComponent(anneeField);
	layout.addComponent(btnSearch);
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:22,代码来源:SearchAnneeUnivApoField.java

示例9: validateFields

import com.vaadin.ui.TextField; //导入依赖的package包/类
/** Colore les champs en rouge si erreur
 * @param validate
 */
@SuppressWarnings("unchecked")
private void validateFields(Boolean validate){
	listLayoutTraductions.forEach(e -> {		
		AbstractField<String> tf;			
		if (e.getComponent(0) instanceof TextField || e.getComponent(0) instanceof RichTextArea){
			tf = (AbstractField<String>) e.getComponent(0);				
		}else if (e.getComponent(0) instanceof HorizontalLayout){				
			tf = (AbstractField<String>) e.getComponent(1);
		}else{
			tf = (AbstractField<String>) e.getComponent(1);
		}
		/* Ajout du style*/
		if (validate){
			tf.removeStyleName(StyleConstants.FIELD_ERROR_COMPLETE);
		}else{
			tf.addStyleName(StyleConstants.FIELD_ERROR_COMPLETE);
		}
	});
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:23,代码来源:I18nField.java

示例10: addStringFilters

import com.vaadin.ui.TextField; //导入依赖的package包/类
/**
 * Ajoute un filtre en TextField sur une liste de colonnes
 * 
 * @param filterRow
 * @param container
 * @param propertys
 */
private void addStringFilters(String... propertys) {
	for (String property : propertys) {
		HeaderCell cell = getFilterCell(property);
		TextField filterField = new TextField();
		filterField.setImmediate(true);
		filterField.setWidth(100, Unit.PERCENTAGE);
		filterField.addStyleName(ValoTheme.TEXTFIELD_TINY);
		filterField.setInputPrompt(applicationContext.getMessage("filter.all", null, UI.getCurrent().getLocale()));
		filterField.addTextChangeListener(change -> {
			// Can't modify filters so need to replace
			container.removeContainerFilters(property);
			// (Re)create the filter if necessary
			if (!change.getText().isEmpty()) {
				container.addContainerFilter(new InsensitiveStringFilter(property, change.getText()));
			}
			fireFilterListener();
		});
		cell.setComponent(filterField);
	}
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:28,代码来源:GridFormatting.java

示例11: populateForm

import com.vaadin.ui.TextField; //导入依赖的package包/类
@Override
public void populateForm() {
    this.ipAddress = new TextField("IPv4 Address");
    this.ipAddress.setImmediate(true);

    // filling form with existing data
    if (this.networkLayout.natTable.getItem(1).getItemProperty("Value").getValue() != null) {
        this.ipAddress.setValue(this.networkLayout.natTable.getItem(1).getItemProperty("Value").getValue()
                .toString());
    }

    // adding not null constraint
    this.ipAddress.setRequired(true);
    this.ipAddress.setRequiredError("IPv4 Address cannot be empty");

    this.form.addComponent(this.ipAddress);
    this.ipAddress.focus();

}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:20,代码来源:SetNATSettingsWindow.java

示例12: updateOffHeapGrid

import com.vaadin.ui.TextField; //导入依赖的package包/类
private void updateOffHeapGrid() {
  int nRows = offheaps.getValue().intValue() + 1;
  // removes rows
  for (int r = offheapGrid.getRows(); r > nRows; r--) {
    offheapGrid.removeRow(r - 1);
  }
  // set new row limit
  offheapGrid.setRows(nRows);
  // add new rows
  for (int r = 1; r < nRows; r++) {
    if (offheapGrid.getComponent(0, r) == null) {
      TextField name = new TextField();
      name.setPlaceholder("Name");
      name.setValue("offheap-" + r);
      TextField memory = new TextField();
      memory.setPlaceholder("Size (MB)");
      memory.setValue("256");
      offheapGrid.addComponent(name, 0, r);
      offheapGrid.addComponent(memory, 1, r);
    }
  }
}
 
开发者ID:Terracotta-OSS,项目名称:tinypounder,代码行数:23,代码来源:TinyPounderMainUI.java

示例13: updateDataRootGrid

import com.vaadin.ui.TextField; //导入依赖的package包/类
private void updateDataRootGrid() {
  int header = getDataRootFirstRow();
  int nRows = dataRoots.getValue().intValue() + header;
  // removes rows
  for (int r = dataRootGrid.getRows(); r > nRows; r--) {
    dataRootGrid.removeRow(r - 1);
  }
  // set new row limit
  dataRootGrid.setRows(nRows);
  // add new rows
  for (int r = header; r < nRows; r++) {
    if (dataRootGrid.getComponent(0, r) == null) {
      TextField id = new TextField();
      id.setPlaceholder("ID");
      id.setValue("dataroot-" + (r - header + 1));
      TextField path = new TextField();
      path.setPlaceholder("Location");
      path.setValue(new File(baseLocation.getValue(), "data/dataroot-" + (r - header + 1)).getAbsolutePath());
      path.setEnabled(false);
      id.addValueChangeListener(event -> path.setValue(new File(baseLocation.getValue(), "data/" + event.getValue()).getAbsolutePath()));
      path.setWidth(100, Unit.PERCENTAGE);
      dataRootGrid.addComponent(id, 0, r, 1, r);
      dataRootGrid.addComponent(path, DATAROOT_PATH_COLUMN, r);
    }
  }
}
 
开发者ID:Terracotta-OSS,项目名称:tinypounder,代码行数:27,代码来源:TinyPounderMainUI.java

示例14: platformBackupWanted

import com.vaadin.ui.TextField; //导入依赖的package包/类
private void platformBackupWanted(boolean wanted) {
  int row = getBackupRow();
  if (wanted) {
    dataRootGrid.insertRow(row);
    TextField id = new TextField();
    id.setPlaceholder("ID");
    id.setValue("BACKUP");
    id.setReadOnly(true);
    TextField path = new TextField();
    path.setPlaceholder("Location");
    path.setValue(new File(baseLocation.getValue(), "data/backup").getAbsolutePath());
    path.setEnabled(false);
    path.setWidth(100, Unit.PERCENTAGE);
    dataRootGrid.addComponent(id, 0, row, 1, row);
    dataRootGrid.addComponent(path, DATAROOT_PATH_COLUMN, row);
  } else {
    dataRootGrid.removeRow(row);
  }
}
 
开发者ID:Terracotta-OSS,项目名称:tinypounder,代码行数:20,代码来源:TinyPounderMainUI.java

示例15: platformPersistenceWanted

import com.vaadin.ui.TextField; //导入依赖的package包/类
private void platformPersistenceWanted(boolean wanted) {
  int row = getPersistenceRow();
  if (wanted) {
    dataRootGrid.insertRow(row);
    TextField id = new TextField();
    id.setPlaceholder("ID");
    id.setValue("PLATFORM");
    id.setReadOnly(true);
    TextField path = new TextField();
    path.setPlaceholder("Location");
    path.setValue(new File(baseLocation.getValue(), "data/platform").getAbsolutePath());
    path.setEnabled(false);
    path.setWidth(100, Unit.PERCENTAGE);
    dataRootGrid.addComponent(id, 0, row, 1, row);
    dataRootGrid.addComponent(path, DATAROOT_PATH_COLUMN, row);
  } else {
    dataRootGrid.removeRow(row);
  }
}
 
开发者ID:Terracotta-OSS,项目名称:tinypounder,代码行数:20,代码来源:TinyPounderMainUI.java


注:本文中的com.vaadin.ui.TextField类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。