List of usage examples for com.vaadin.ui TextField TextField
public TextField()
TextField
with no caption. From source file:com.github.peholmst.i18n4vaadin.cdi.demo.DemoView.java
License:Apache License
@PostConstruct protected void init() { setSizeUndefined();//from w w w . ja v a 2 s . c o m setSpacing(true); setMargin(true); name = new TextField(); addComponent(name); sayHello = new Button(); sayHello.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { sayHello(); } }); addComponent(sayHello); updateStrings(); }
From source file:com.github.peholmst.i18n4vaadin.simple.demo.DemoView.java
License:Apache License
public DemoView() { setSizeUndefined();/*from w w w. ja v a 2 s . c o m*/ setSpacing(true); setMargin(true); name = new TextField(); addComponent(name); sayHello = new Button(); sayHello.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { sayHello(); } }); addComponent(sayHello); updateStrings(); }
From source file:com.haulmont.cuba.web.app.folders.FolderEditWindow.java
License:Apache License
public FolderEditWindow(boolean adding, Folder folder, Presentations presentations, Runnable commitHandler) { this.folder = folder; this.commitHandler = commitHandler; messages = AppBeans.get(Messages.NAME); messagesPack = AppConfig.getMessagesPack(); userSessionSource = AppBeans.get(UserSessionSource.NAME); Configuration configuration = AppBeans.get(Configuration.NAME); clientConfig = configuration.getConfig(ClientConfig.class); setCaption(adding ? getMessage("folders.folderEditWindow.adding") : getMessage("folders.folderEditWindow")); ThemeConstants theme = App.getInstance().getThemeConstants(); setWidthUndefined();/* ww w . ja va 2 s.c o m*/ setResizable(false); int[] modifiers = { ShortcutAction.ModifierKey.CTRL }; addAction(new ShortcutListener("commit", com.vaadin.event.ShortcutAction.KeyCode.ENTER, modifiers) { @Override public void handleAction(Object sender, Object target) { commit(); } }); layout = new VerticalLayout(); layout.setWidthUndefined(); layout.setSpacing(true); setContent(layout); setModal(true); center(); String fieldWidth = theme.get("cuba.web.FolderEditWindow.field.width"); nameField = new TextField(); nameField.setRequired(true); nameField.setCaption(getMessage("folders.folderEditWindow.nameField")); nameField.setWidth(fieldWidth); nameField.setValue(folder.getName()); nameField.focus(); layout.addComponent(nameField); tabNameField = new TextField(); tabNameField.setCaption(getMessage("folders.folderEditWindow.tabNameField")); tabNameField.setWidth(fieldWidth); tabNameField.setValue(StringUtils.trimToEmpty(folder.getTabName())); layout.addComponent(tabNameField); parentSelect = new ComboBox(); parentSelect.setCaption(getMessage("folders.folderEditWindow.parentSelect")); parentSelect.setWidth(fieldWidth); parentSelect.setNullSelectionAllowed(true); fillParentSelect(); parentSelect.setValue(folder.getParent()); layout.addComponent(parentSelect); if (folder instanceof SearchFolder) { if (presentations != null) { presentation = new ComboBox(); presentation.setCaption(getMessage("folders.folderEditWindow.presentation")); presentation.setWidth(fieldWidth); presentation.setNullSelectionAllowed(true); fillPresentations(presentations); presentation.setValue(((SearchFolder) folder).getPresentation()); layout.addComponent(presentation); } else if (((SearchFolder) folder).getPresentation() != null) { selectedPresentationField = new TextField(); selectedPresentationField.setWidth(fieldWidth); selectedPresentationField.setCaption(getMessage("folders.folderEditWindow.presentation")); selectedPresentationField.setValue(((SearchFolder) folder).getPresentation().getName()); selectedPresentationField.setEnabled(false); layout.addComponent(selectedPresentationField); } } sortOrderField = new TextField(); sortOrderField.setCaption(getMessage("folders.folderEditWindow.sortOrder")); sortOrderField.setWidth(fieldWidth); sortOrderField.setValue(folder.getSortOrder() == null ? "" : folder.getSortOrder().toString()); layout.addComponent(sortOrderField); if (userSessionSource.getUserSession().isSpecificPermitted("cuba.gui.searchFolder.global") && folder instanceof SearchFolder && BooleanUtils.isNotTrue(((SearchFolder) folder).getIsSet())) { globalCb = new CubaCheckBox(getMessage("folders.folderEditWindow.global")); globalCb.setValue(((SearchFolder) folder).getUser() == null); layout.addComponent(globalCb); } applyDefaultCb = new CubaCheckBox(getMessage("folders.folderEditWindow.applyDefault")); applyDefaultCb.setValue(BooleanUtils.isTrue(((AbstractSearchFolder) folder).getApplyDefault())); applyDefaultCb.setVisible(clientConfig.getGenericFilterManualApplyRequired() && folder instanceof SearchFolder && BooleanUtils.isNotTrue(((SearchFolder) folder).getIsSet())); layout.addComponent(applyDefaultCb); HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setMargin(new MarginInfo(true, false, false, false)); buttonsLayout.setSpacing(true); layout.addComponent(buttonsLayout); okBtn = new CubaButton(getMessage("actions.Ok")); okBtn.setIcon(WebComponentsHelper.getIcon("icons/ok.png")); okBtn.addStyleName(WebButton.ICON_STYLE); initButtonOkListener(); buttonsLayout.addComponent(okBtn); cancelBtn = new CubaButton(getMessage("actions.Cancel")); cancelBtn.setIcon(WebComponentsHelper.getIcon("icons/cancel.png")); cancelBtn.addStyleName(WebButton.ICON_STYLE); cancelBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { close(); } }); buttonsLayout.addComponent(cancelBtn); if (AppUI.getCurrent().isTestMode()) { setCubaId("folderEditWindow"); nameField.setCubaId("nameField"); tabNameField.setCubaId("tabNameField"); parentSelect.setCubaId("parentSelect"); if (presentation != null) { presentation.setCubaId("presentationSelect"); } sortOrderField.setCubaId("sortOrderField"); if (selectedPresentationField != null) { selectedPresentationField.setCubaId("selectedPresentationField"); } if (globalCb != null) { globalCb.setCubaId("globalCb"); } applyDefaultCb.setCubaId("applyDefaultCb"); okBtn.setCubaId("okBtn"); cancelBtn.setCubaId("cancelBtn"); } }
From source file:com.haulmont.cuba.web.LoginWindow.java
License:Apache License
public LoginWindow(AppUI ui) { log.trace("Creating {}", this); this.ui = ui; globalConfig = configuration.getConfig(GlobalConfig.class); webConfig = configuration.getConfig(WebConfig.class); locales = globalConfig.getAvailableLocales(); app = ui.getApp();/*from w w w. ja v a 2 s .c o m*/ resolvedLocale = resolveLocale(app); connection = app.getConnection(); loginField = new TextField(); passwordField = new CubaPasswordField(); localesSelect = new ComboBox(); localesSelect.setTextInputAllowed(false); // make fields immediate to resync fast in case of login is already performed from another UI (i.e. browser tab) loginField.setImmediate(true); passwordField.setImmediate(true); localesSelect.setImmediate(true); okButton = new CubaButton(); submitListener = new SubmitListener(); rememberMeAllowed = webConfig.getRememberMeEnabled(); if (rememberMeAllowed) { rememberMeCheckBox = new CubaCheckBox(); } setSizeFull(); // load theme from cookies if it is changed by user in settings dialog applyUserTheme(); initUI(); localesSelect.addValueChangeListener(event -> { if (!resolvedLocale.equals(getUserLocale())) { resolvedLocale = getUserLocale(); clearUI(); initUI(); } }); if (ui.isTestMode()) { loginField.setCubaId("loginField"); passwordField.setCubaId("passwordField"); localesSelect.setCubaId("localesField"); okButton.setCubaId("loginSubmitButton"); if (rememberMeCheckBox != null) { rememberMeCheckBox.setCubaId("rememberMeCheckBox"); } TestIdManager testIdManager = ui.getTestIdManager(); loginField.setId(testIdManager.reserveId("loginField")); passwordField.setId(testIdManager.reserveId("passwordField")); localesSelect.setId(testIdManager.reserveId("localesField")); okButton.setId(testIdManager.reserveId("loginSubmitButton")); if (rememberMeCheckBox != null) { rememberMeCheckBox.setId(testIdManager.reserveId("rememberMeCheckBox")); } } addShortcutListener(new ShortcutListener("Default key", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { doLogin(); } }); }
From source file:com.hris.employee.grid.EmployeeDataGridProperties.java
private void filterDataGrid(IndexedContainer container) { // Create a header row to hold column filters HeaderRow filterRow = appendHeaderRow(); // Set up a filter for all columns this.getContainerDataSource().getContainerPropertyIds().stream().filter((pid) -> (pid.equals("name"))) .forEach((pid) -> {//from w ww . j a v a 2 s . c o m HeaderCell cell = filterRow.getCell(pid); // Have an input field to use for filter TextField filterField = new TextField(); filterField.setWidth("100%"); filterField.setIcon(FontAwesome.SEARCH); filterField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); filterField.addStyleName(ValoTheme.TEXTFIELD_SMALL); filterField.setInputPrompt("Filter"); filterField.addTextChangeListener(change -> { container.removeContainerFilters(pid); if (!change.getText().isEmpty()) { container.addContainerFilter( new SimpleStringFilter(pid, change.getText().toUpperCase(), true, false)); } }); cell.setComponent(filterField); }); }
From source file:com.jain.addon.web.bean.factory.AbstractFieldFactory.java
License:Apache License
protected Field<?> createTextField(JNIProperty property) { if (property.getType() == JPropertyType.TEXT_AREA) { TextArea field = new TextArea(); field.setInputPrompt(getCaption(property)); field.setNullRepresentation(""); field.setRows(5);/* w w w .ja va2 s . com*/ return field; } if (property.getType() == JPropertyType.RICH_TEXT_AREA) { RichTextArea field = new RichTextArea(); field.setNullRepresentation(""); return field; } if (property.getType() == JPropertyType.IMAGE) { JImage image = new JImage(); image.setInterruptionMessage(property.getName() + ".upload.interruption"); image.setUploadButtonCaption(property.getName() + ".upload.button.caption"); return image; } TextField field = new TextField(); field.setInputPrompt(getCaption(property)); field.setNullRepresentation(""); return field; }
From source file:com.jain.addon.web.bean.factory.generator.text.TextFieldGenerator.java
License:Apache License
public Field<?> createField(Class<?> type, JNIProperty property) { TextField field = new TextField(); field.setInputPrompt(getCaption(property)); field.setNullRepresentation(""); return field; }
From source file:com.jiangyifen.ec2.ui.LoginLayout.java
/** * ?// ww w.j av a2 s . c om * * @param panelContent ???? * @param roleType ? */ private void createLoginMainComponents(VerticalLayout panelContent, RoleType roleType) { GridLayout gridLayout = new GridLayout(2, 5); gridLayout.setSpacing(true); gridLayout.setMargin(true); panelContent.addComponent(gridLayout); panelContent.setComponentAlignment(gridLayout, Alignment.MIDDLE_CENTER); // ?? Label username_lb = new Label(" ??", Label.CONTENT_XHTML); gridLayout.addComponent(username_lb, 0, 0); usernameTextField = new TextField(); usernameTextField.setWidth("170px"); usernameTextField.setValue(username); gridLayout.addComponent(usernameTextField, 1, 0); // ? Label password = new Label(" ?", Label.CONTENT_XHTML); gridLayout.addComponent(password, 0, 1); passwordTextField = new PasswordField(); passwordTextField.setWidth("170px"); gridLayout.addComponent(passwordTextField, 1, 1); // ?Csr ? if (roleType.equals(RoleType.csr)) { Label extenNoLabel = new Label(" ", Label.CONTENT_XHTML); gridLayout.addComponent(extenNoLabel, 0, 2); extenNoField = new TextField(); extenNoField.setWidth("170px"); extenNoField.setValue(exten); gridLayout.addComponent(extenNoField, 1, 2); } // ????? String warningMsg = "<font color='red'>?????</font>"; warningLabel = new Label(warningMsg, Label.CONTENT_XHTML); warningLabel.setVisible(false); gridLayout.addComponent(warningLabel, 1, 3); gridLayout.setComponentAlignment(warningLabel, Alignment.MIDDLE_CENTER); // ? login = new Button(" ", this); forget = new NativeButton("?", this); //??? Map<String, String> licenseMap = LicenseManager.licenseValidate(); String validateResult = licenseMap.get(LicenseManager.LICENSE_VALIDATE_RESULT); if (LicenseManager.LICENSE_VALID.equals(validateResult)) { SpringContextHolder.getHttpSession().removeAttribute("businessModels"); String licensedDate = licenseMap.get(LicenseManager.LICENSE_DATE); try { Date stopDate = LicenseManager.simpleDateFormat.parse(licensedDate); Long times = stopDate.getTime() - new Date().getTime(); int outdateWarnDay = (int) (times / (24 * 3600 * 1000)); if (outdateWarnDay < 7) { isValid = true; warningLabel.setValue("<font color='red'>" + outdateWarnDay + ",???</font>"); if (outdateWarnDay < 0) { warningLabel.setValue("<font color='red'>?,???</font>"); isValid = false; } else if (outdateWarnDay == 0) { warningLabel.setValue( "<font color='red'>?,???</font>"); } warningLabel.setVisible(true); } // //?? // if(roleType==RoleType.manager){ // login.setEnabled(true); // } // } catch (Exception e) { e.printStackTrace(); login.setEnabled(false); forget.setEnabled(false); } } else { warningLabel.setVisible(true); warningLabel.setValue("<font color='red'>??,???</font>"); login.setEnabled(false); forget.setEnabled(false); isValid = false; //chb ??? if (roleType == RoleType.manager) { if (isValid == false) { login.setEnabled(true); } else { //normal login } } } HorizontalLayout operatorHLayout = new HorizontalLayout(); operatorHLayout.setSpacing(true); operatorHLayout.addComponent(login); operatorHLayout.addComponent(forget); gridLayout.addComponent(operatorHLayout, 1, 4); }
From source file:com.jiangyifen.ec2.ui.mgr.system.tabsheet.DynQueueMemberManagement.java
/** * ?(??)/*w ww . ja v a 2 s.c o m*/ * @return */ private VerticalLayout createLeftComponents() { VerticalLayout leftVLayout = new VerticalLayout(); leftVLayout.setSpacing(true); leftVLayout.setWidth("100%"); // ? HorizontalLayout searchHLayout = new HorizontalLayout(); searchHLayout.setSpacing(true); leftVLayout.addComponent(searchHLayout); Label caption = new Label(""); caption.setWidth("-1px"); searchHLayout.addComponent(caption); searchHLayout.setComponentAlignment(caption, Alignment.MIDDLE_CENTER); leftKeyword = new TextField(); leftKeyword.setImmediate(true); leftKeyword.setInputPrompt("?"); leftKeyword.setDescription("??????????"); leftKeyword.setStyleName("search"); leftKeyword.addListener(this); searchHLayout.addComponent(leftKeyword); searchHLayout.setComponentAlignment(leftKeyword, Alignment.MIDDLE_CENTER); leftSearch = new Button("?", this); leftSearch.setImmediate(true); searchHLayout.addComponent(leftSearch); searchHLayout.setComponentAlignment(leftSearch, Alignment.MIDDLE_CENTER); // // leftTable = new Table("??"); leftTable.setStyleName("striped"); leftTable.setSelectable(true); leftTable.setMultiSelect(true); leftTable.setWidth("100%"); leftTable.setRowHeaderMode(Table.ROW_HEADER_MODE_INDEX); leftVLayout.addComponent(leftTable); leftTableContainer = new BeanItemContainer<User>(User.class); leftTableContainer.addNestedContainerProperty("department.name"); leftTable.setContainerDataSource(leftTableContainer); leftTable.setPageLength(20); leftTable.setVisibleColumns(VISIBLE_PROPERTIES); leftTable.setColumnHeaders(COL_HEADERS); return leftVLayout; }
From source file:com.jiangyifen.ec2.ui.mgr.system.tabsheet.DynQueueMemberManagement.java
/** * ??(????)/*from w w w. j a v a2 s. c om*/ * return */ private VerticalLayout createRightComponents() { VerticalLayout rightVLayout = new VerticalLayout(); rightVLayout.setSpacing(true); rightVLayout.setWidth("100%"); // ? HorizontalLayout searchHLayout = new HorizontalLayout(); searchHLayout.setSpacing(true); rightVLayout.addComponent(searchHLayout); Label caption = new Label(""); caption.setWidth("-1px"); searchHLayout.addComponent(caption); searchHLayout.setComponentAlignment(caption, Alignment.MIDDLE_CENTER); rightKeyword = new TextField(); rightKeyword.setImmediate(true); rightKeyword.setInputPrompt("?"); rightKeyword.setDescription("??????????"); rightKeyword.setStyleName("search"); rightKeyword.addListener(this); searchHLayout.addComponent(rightKeyword); searchHLayout.setComponentAlignment(rightKeyword, Alignment.MIDDLE_CENTER); rightSearch = new Button("?", this); rightSearch.setImmediate(true); searchHLayout.addComponent(rightSearch); searchHLayout.setComponentAlignment(rightSearch, Alignment.MIDDLE_CENTER); // // rightTable = new Table("?"); rightTable.setStyleName("striped"); rightTable.setSelectable(true); rightTable.setMultiSelect(true); rightTable.setWidth("100%"); rightTable.setPageLength(16); rightTable.setRowHeaderMode(Table.ROW_HEADER_MODE_INDEX); rightVLayout.addComponent(rightTable); rightTableContainer = new BeanItemContainer<User>(User.class); rightTableContainer.addNestedContainerProperty("department.name"); rightTable.setContainerDataSource(rightTableContainer); rightTable.setVisibleColumns(VISIBLE_PROPERTIES); rightTable.setColumnHeaders(COL_HEADERS); rightTable.addGeneratedColumn("priority", new PriorityColumnGenerate()); rightTable.setColumnHeader("priority", ""); return rightVLayout; }