List of usage examples for com.vaadin.ui TextField TextField
public TextField()
TextField
with no caption. From source file:com.esspl.datagen.ui.TableDataView.java
License:Open Source License
public TableDataView(final JdbcTable table, final Connection connection, final DataGenApplication dataApp) { log.debug("TableDataView - constructor start"); setCaption("Data"); dataGenApplication = dataApp;/* w w w . j av a2 s . co m*/ VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); setCompositionRoot(vl); HorizontalLayout hBar = new HorizontalLayout(); hBar.setWidth("98%"); hBar.setHeight("40px"); rows = new TextField(); rows.setWidth("50px"); rows.setImmediate(true); rows.addValidator(new IntegerValidator("Rows must be an Integer")); Label lbl = new Label("Generate "); content = new HorizontalLayout(); content.setHeight("40px"); content.setMargin(false, false, false, true); content.setSpacing(true); content.addComponent(lbl); content.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER); content.addComponent(rows); content.setComponentAlignment(rows, Alignment.MIDDLE_CENTER); Button addDataButton = new Button("Row(S) Data", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { log.debug("TableDataView - Generate Data Button clicked"); populateGenerator(table); } }); addDataButton.addStyleName("small"); addDataButton.setIcon(DataGenConstant.ADD_SMALL); content.addComponent(addDataButton); content.setComponentAlignment(addDataButton, Alignment.MIDDLE_CENTER); Button refreshButton = new Button("Refresh", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { log.debug("TableDataView - Refresh Button clicked"); refreshDataView(table, connection); } }); refreshButton.addStyleName("small"); refreshButton.setIcon(DataGenConstant.RESET); content.addComponent(refreshButton); content.setComponentAlignment(refreshButton, Alignment.MIDDLE_CENTER); //Tapas:10/08/2012 - Export feature implementation started HorizontalLayout expContainer = new HorizontalLayout(); expContainer.setSpacing(true); PopupButton exportButton = new PopupButton("Export"); exportButton.setComponent(new DataExportView()); exportButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { //dataApp.getMainWindow().showNotification("Export Button clicked!"); } }); exportButton.setIcon(DataGenConstant.DATAEXPORT_ICON); expContainer.addComponent(exportButton); expContainer.setComponentAlignment(exportButton, Alignment.MIDDLE_LEFT); //Tapas:10/08/2012 - Import feature implementation started PopupButton importButton = new PopupButton("Import"); importButton.setComponent(new DataImportView()); importButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { //dataApp.getMainWindow().showNotification("Import Button clicked!"); } }); importButton.setIcon(DataGenConstant.DATAIMPORT_ICON); expContainer.addComponent(importButton); expContainer.setComponentAlignment(importButton, Alignment.MIDDLE_RIGHT); tableContainer = new VerticalLayout(); tableContainer.setSizeFull(); hBar.addComponent(content); hBar.setComponentAlignment(content, Alignment.MIDDLE_LEFT); hBar.addComponent(expContainer); hBar.setComponentAlignment(expContainer, Alignment.MIDDLE_RIGHT); vl.addComponent(hBar); vl.addComponent(tableContainer); vl.setExpandRatio(tableContainer, 1f); refreshDataView(table, connection); log.debug("TableDataView - constructor end"); }
From source file:com.esspl.datagen.util.DataGenEventHandler.java
License:Open Source License
public void addTextFields(HorizontalLayout addBar, String promptText1, String promptText2) { log.debug("DataGenEventHandler - addTextFields() method start"); TextField first = new TextField(); first.setInputPrompt(promptText1);/* w ww .j ava2 s.c o m*/ first.setWidth("95px"); first.setImmediate(true); if (promptText1.endsWith("Length") || promptText1.endsWith("Number") || promptText1.equals("Starting From")) { first.addValidator(new IntegerValidator(promptText1 + " must be an Integer")); } TextField second = new TextField(); second.setInputPrompt(promptText2); second.setWidth("95px"); second.setImmediate(true); if (promptText2.endsWith("Length") || promptText2.endsWith("Number") || promptText2.equals("Starting From")) { second.addValidator(new IntegerValidator(promptText2 + " must be an Integer")); } addBar.removeAllComponents(); addBar.setSpacing(true); addBar.addComponent(first); addBar.setComponentAlignment(first, Alignment.MIDDLE_LEFT); addBar.addComponent(second); addBar.setComponentAlignment(second, Alignment.MIDDLE_LEFT); log.debug("DataGenEventHandler - addTextFields() method end"); }
From source file:com.esspl.datagen.util.DataGenEventHandler.java
License:Open Source License
public void addSingleTextField(HorizontalLayout addBar, String promptText1) { log.debug("DataGenEventHandler - addSingleTextField() method start"); TextField first = new TextField(); first.setInputPrompt(promptText1);// w ww .java2 s. c om first.setWidth("95px"); first.setImmediate(true); if (promptText1.endsWith("Length") || promptText1.endsWith("Number") || promptText1.equals("Starting From")) { first.addValidator(new IntegerValidator(promptText1 + " must be an Integer")); } addBar.removeAllComponents(); addBar.setSpacing(true); addBar.addComponent(first); addBar.setComponentAlignment(first, Alignment.MIDDLE_CENTER); log.debug("DataGenEventHandler - addSingleTextField() method end"); }
From source file:com.esspl.datagen.util.DataGenEventHandler.java
License:Open Source License
public void addChkTextField(HorizontalLayout addBar, String promptText1, String promptText2) { log.debug("DataGenEventHandler - addSingleTextField() method start"); TextField first = new TextField(); first.setInputPrompt(promptText1);/* www . ja v a2 s .c o m*/ first.setWidth("95px"); first.setImmediate(true); if (promptText1.endsWith("Length") || promptText1.endsWith("Number") || promptText1.equals("Starting From")) { first.addValidator(new IntegerValidator(promptText1 + " must be an Integer")); } CheckBox cb = new CheckBox(promptText2); addBar.removeAllComponents(); addBar.setSpacing(true); addBar.addComponent(first); addBar.setComponentAlignment(first, Alignment.MIDDLE_LEFT); addBar.addComponent(cb); addBar.setComponentAlignment(cb, Alignment.MIDDLE_LEFT); log.debug("DataGenEventHandler - addSingleTextField() method end"); }
From source file:com.etest.valo.Tables.java
License:Apache License
static void configure(Table table, boolean footer, boolean sized, boolean expandRatios, boolean stripes, boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers, boolean compact, boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon, boolean componentsInRows) { table.setSelectable(true);// w w w . j av a2s . com table.setMultiSelect(true); table.setSortEnabled(true); table.setColumnCollapsingAllowed(true); table.setColumnReorderingAllowed(true); table.setPageLength(6); table.addActionHandler(MainUI.getActionHandler()); table.setDragMode(TableDragMode.MULTIROW); table.setDropHandler(new DropHandler() { @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } @Override public void drop(DragAndDropEvent event) { Notification.show(event.getTransferable().toString()); } }); table.setColumnAlignment(MainUI.DESCRIPTION_PROPERTY, Align.RIGHT); table.setColumnAlignment(MainUI.INDEX_PROPERTY, Align.CENTER); table.removeContainerProperty("textfield"); table.removeGeneratedColumn("textfield"); table.removeContainerProperty("button"); table.removeGeneratedColumn("button"); table.removeContainerProperty("label"); table.removeGeneratedColumn("label"); table.removeContainerProperty("checkbox"); table.removeGeneratedColumn("checkbox"); table.removeContainerProperty("datefield"); table.removeGeneratedColumn("datefield"); table.removeContainerProperty("combobox"); table.removeGeneratedColumn("combobox"); table.removeContainerProperty("optiongroup"); table.removeGeneratedColumn("optiongroup"); table.removeContainerProperty("slider"); table.removeGeneratedColumn("slider"); table.removeContainerProperty("progress"); table.removeGeneratedColumn("progress"); if (componentsInRows) { table.addContainerProperty("textfield", TextField.class, null); table.addGeneratedColumn("textfield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { TextField tf = new TextField(); tf.setInputPrompt("Type here"); // tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("datefield", TextField.class, null); table.addGeneratedColumn("datefield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { DateField tf = new DateField(); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("combobox", TextField.class, null); table.addGeneratedColumn("combobox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ComboBox tf = new ComboBox(); tf.setInputPrompt("Select"); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("button", Button.class, null); table.addGeneratedColumn("button", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Button b = new Button("Button"); b.addStyleName("small"); return b; } }); table.addContainerProperty("label", TextField.class, null); table.addGeneratedColumn("label", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Label label = new Label("Label component"); label.setSizeUndefined(); label.addStyleName("bold"); return label; } }); table.addContainerProperty("checkbox", TextField.class, null); table.addGeneratedColumn("checkbox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { CheckBox cb = new CheckBox(null, true); return cb; } }); table.addContainerProperty("optiongroup", TextField.class, null); table.addGeneratedColumn("optiongroup", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { OptionGroup op = new OptionGroup(); op.addItem("Male"); op.addItem("Female"); op.addStyleName("horizontal"); return op; } }); table.addContainerProperty("slider", TextField.class, null); table.addGeneratedColumn("slider", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Slider s = new Slider(); s.setValue(30.0); return s; } }); table.addContainerProperty("progress", TextField.class, null); table.addGeneratedColumn("progress", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ProgressBar bar = new ProgressBar(); bar.setValue(0.7f); return bar; } }); } table.setFooterVisible(footer); if (footer) { table.setColumnFooter(MainUI.CAPTION_PROPERTY, "caption"); table.setColumnFooter(MainUI.DESCRIPTION_PROPERTY, "description"); table.setColumnFooter(MainUI.ICON_PROPERTY, "icon"); table.setColumnFooter(MainUI.INDEX_PROPERTY, "index"); } if (sized) { table.setWidth("400px"); table.setHeight("300px"); } else { table.setSizeUndefined(); } if (expandRatios) { if (!sized) { table.setWidth("100%"); } } table.setColumnExpandRatio(MainUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0); table.setColumnExpandRatio(MainUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0); if (!stripes) { table.addStyleName("no-stripes"); } else { table.removeStyleName("no-stripes"); } if (!verticalLines) { table.addStyleName("no-vertical-lines"); } else { table.removeStyleName("no-vertical-lines"); } if (!horizontalLines) { table.addStyleName("no-horizontal-lines"); } else { table.removeStyleName("no-horizontal-lines"); } if (borderless) { table.addStyleName("borderless"); } else { table.removeStyleName("borderless"); } if (!headers) { table.addStyleName("no-header"); } else { table.removeStyleName("no-header"); } if (compact) { table.addStyleName("compact"); } else { table.removeStyleName("compact"); } if (small) { table.addStyleName("small"); } else { table.removeStyleName("small"); } if (!rowIndex && !rowCaption && rowIcon) { table.setRowHeaderMode(RowHeaderMode.HIDDEN); } if (rowIndex) { table.setRowHeaderMode(RowHeaderMode.INDEX); } if (rowCaption) { table.setRowHeaderMode(RowHeaderMode.PROPERTY); table.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); } else { table.setItemCaptionPropertyId(null); } if (rowIcon) { table.setRowHeaderMode(RowHeaderMode.ICON_ONLY); table.setItemIconPropertyId(MainUI.ICON_PROPERTY); } else { table.setItemIconPropertyId(null); } }
From source file:com.expressui.core.view.field.FormField.java
License:Open Source License
private Field generateField() { Class propertyType = getPropertyType(); if (propertyType == null) { return null; }// w ww. j a v a 2 s .c om if (Date.class.isAssignableFrom(propertyType)) { return new DateField(); } if (boolean.class.isAssignableFrom(propertyType) || Boolean.class.isAssignableFrom(propertyType)) { return new CheckBox(); } if (ReferenceEntity.class.isAssignableFrom(propertyType)) { return new Select(); } if (Currency.class.isAssignableFrom(propertyType)) { return new Select(); } if (propertyType.isEnum()) { return new Select(); } if (Collection.class.isAssignableFrom(propertyType)) { return new ListSelect(); } if (getBeanPropertyType().hasAnnotation(Lob.class)) { return new RichTextArea(); } return new TextField(); }
From source file:com.expressui.core.view.field.SelectField.java
License:Open Source License
private void initialize() { setSizeUndefined();/*w w w . j ava 2 s . c o m*/ field = new TextField(); FormField.initAbstractFieldDefaults(field); FormField.initTextFieldDefaults(field); field.setReadOnly(true); HorizontalLayout selectFieldLayout = new HorizontalLayout(); String id = StringUtil.generateDebugId("e", this, selectFieldLayout, "selectFieldLayout"); selectFieldLayout.setDebugId(id); selectFieldLayout.addComponent(field); searchButton = new Button(); searchButton.setDescription(uiMessageSource.getToolTip("selectField.search.toolTip")); searchButton.setSizeUndefined(); searchButton.addStyleName("borderless"); searchButton.setIcon(new ThemeResource("../chameleon/img/magnifier.png")); searchButton.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { entitySelect.open(); } }); selectFieldLayout.addComponent(searchButton); clearButton = new Button(); clearButton.setDescription(uiMessageSource.getToolTip("selectField.clear.toolTip")); clearButton.setSizeUndefined(); clearButton.addStyleName("borderless"); clearButton.setIcon(new ThemeResource("../runo/icons/16/cancel.png")); selectFieldLayout.addComponent(clearButton); entitySelect.getResults().addSelectActionListener(this, "itemSelected"); clearButton.addListener(Button.ClickEvent.class, this, "itemCleared"); setCompositionRoot(selectFieldLayout); }
From source file:com.expressui.core.view.results.Results.java
License:Open Source License
private TextField createFirstResultTextField() { TextField firstResultTextField = new TextField(); firstResultTextField.setImmediate(true); firstResultTextField.setInvalidAllowed(true); firstResultTextField.setInvalidCommitted(false); firstResultTextField.setWriteThrough(true); firstResultTextField/*from w w w . j av a 2s . c o m*/ .addValidator(new IntegerValidator(uiMessageSource.getMessage("results.firstResult.invalid")) { @Override protected boolean isValidString(String value) { try { Long longValue = (Long) defaultFormats.getNumberFormat().parse(value); if (getEntityQuery().getResultCount() > 0) { return longValue >= 1 && longValue <= getEntityQuery().getResultCount(); } else { return longValue == 0; } } catch (Exception e) { return false; } } }); PropertyFormatter propertyFormatter = defaultFormats.getNumberFormat(0, 1); propertyFormatter.setPropertyDataSource(new MethodProperty(getResultsTable(), "firstResult")); firstResultTextField.setPropertyDataSource(propertyFormatter); firstResultTextField.setWidth(3, Sizeable.UNITS_EM); return firstResultTextField; }
From source file:com.fatminds.vaadin_cmis_integration.demo.CMS_DataLists.java
License:Apache License
@AutoGenerated private AbsoluteLayout buildMainLayout() { // common part: create layout mainLayout = new AbsoluteLayout(); mainLayout.setImmediate(false);//from w w w.j a v a2 s. com mainLayout.setWidth("400px"); mainLayout.setHeight("250px"); mainLayout.setMargin(false); // top-level component properties setWidth("400px"); setHeight("250px"); // txtDataItemToAddEdit txtDataItemToAddEdit = new TextField(); txtDataItemToAddEdit.setImmediate(false); txtDataItemToAddEdit.setWidth("324px"); txtDataItemToAddEdit.setHeight("24px"); txtDataItemToAddEdit.setInputPrompt("Enter New Data Item"); txtDataItemToAddEdit.setSecret(false); mainLayout.addComponent(txtDataItemToAddEdit, "top:170.0px;left:40.0px;"); // btnAddDataItem btnAddDataItem = new Button(); btnAddDataItem.setCaption("Add/Update Data Item"); btnAddDataItem.setImmediate(true); btnAddDataItem.setWidth("-1px"); btnAddDataItem.setHeight("-1px"); mainLayout.addComponent(btnAddDataItem, "top:200.0px;left:40.0px;"); // btnDeleteDataItem btnDeleteDataItem = new Button(); btnDeleteDataItem.setCaption("Delete Selected Data Item"); btnDeleteDataItem.setImmediate(true); btnDeleteDataItem.setWidth("-1px"); btnDeleteDataItem.setHeight("-1px"); mainLayout.addComponent(btnDeleteDataItem, "top:200.0px;left:200.0px;"); // tblDataItems tblDataItems = new Table(); tblDataItems.setImmediate(false); tblDataItems.setWidth("324px"); tblDataItems.setHeight("163px"); mainLayout.addComponent(tblDataItems, "left:40.0px;"); return mainLayout; }
From source file:com.fatminds.vaadin_cmis_integration.demo.DemoFieldFactory.java
License:Apache License
public Field createField(Item item, Object propertyId, Component uiContext) { if (null == propertyId) throw new IllegalArgumentException("Cannot create field for null propertyId"); if (null != getField(propertyId)) { return getField(propertyId); }// ww w . j a va 2 s .co m // Identify the fields by their Property ID or other metadata String pid = (String) propertyId; CmisProperty prop = (CmisProperty) item.getItemProperty(propertyId); Class<?> type = prop.getType(); CmisItem cmisItem = (CmisItem) item; String title = prop.getTitle(); if (title == null || title.isEmpty()) { title = (String) propertyId; } // Note, THIS IS NULL if we have a transient (new) Item String thisObjId = (null == cmisItem.getCmisObject() ? null : cmisItem.getCmisObject().getId()); // This field is returned by the method. // If you don't want a TextField, set it to something else in your specialization clause. Field retField = null; // By default, a TextField is returned. Use this reference to set TextField-specific properties in your // specialization clause. TextField textField; retField = textField = new TextField(); textField.setNullRepresentation(""); //textField.setWidth("100%"); textField.setCaption(title); textField.setImmediate(true); textField.setValidationVisible(false); /*** * Handle your non-standard fields by name or id here. */ if ("fmexample:description".equals(pid)) { //RichTextArea rta = new RichTextArea(); TextArea ta = new TextArea(); ta.setCaption(title); ta.setNullRepresentation("Enter formatted description"); // rta.setSizeFull(); //rta.setImmediate(true); retField = ta; } /** * Adapt to taste for handling multi-valued CMIS properties. The following uses TokenField plus a FieldWrapper and ArrayListPropertyConverter * to provide for inline suggestion, and inline storage of newly entered values for future suggestions, for multi-valued string properties. * else if (prop.isMultivalued()) { TokenField tf = new TokenField(); tf.setWidth("1000px"); PropertyConverter pc = new ArrayListPropertyConverter(); FieldWrapper fw = new CmisManyField(tf, pc, ArrayList.class); fw.setCaption(title); fw.setReadOnly(true); retField = fw; if (null != catSvc.getCmisDatalistContainer(parentInstitution, pid)) { tf.setContainerDataSource(catSvc.getCmisDatalistContainer(parentInstitution, pid)); tf.setTokenCaptionPropertyId(propertyId); tf.setImmediate(true); } else { PropertysetItem pitem = new PropertysetItem(); pitem.addItemProperty(propertyId, new ObjectProperty(propertyId)); Set<Object> s = new HashSet<Object>(); s.add(propertyId); IndexedContainer ic = new IndexedContainer(s); tf.setContainerDataSource(ic); tf.setTokenCaptionPropertyId(propertyId); } } **/ else if (Double.class.isAssignableFrom(type) || Float.class.isAssignableFrom(type) || //Number.class.isAssignableFrom(type) || //BigInteger.class.isAssignableFrom(type) || BigDecimal.class.isAssignableFrom(type)) { textField.setMaxLength(10); textField.setCaption(title); textField.setImmediate(true); textField.setPropertyDataSource(new PropertyFormatter(item.getItemProperty(propertyId)) { public String format(Object value) { return value.toString(); } public Object parse(String formattedValue) throws Exception { return new BigDecimal(Double.parseDouble(formattedValue)); } }); retField = textField; } else if (Calendar.class.isAssignableFrom(type)) { CmisDateField dateFld = new CmisDateField(title); retField = dateFld; } else if (Boolean.class.isAssignableFrom(type)) { CheckBox cb = new CheckBox(title); cb.setDescription(title); retField = cb; } // Bind to CmisProperty retField.setPropertyDataSource(prop); // Be careful with this - if it's <mandatory> in the alfresco content model, it's mandatory in your forms. boolean isRequired = prop.isMandatory(); retField.setRequired(false); putField(propertyId, retField); //Add Validators addValidators(pid, retField, title, cmisItem); log.debug("Returning a " + retField.getClass() + " for cmis property " + propertyId); return retField; }