當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。