List of usage examples for com.vaadin.ui TextField getValue
@Override
public String getValue()
From source file:com.cms.utils.CommonValidator.java
public static boolean checkMaxlength(TextField field, int length, boolean allowNull) { if (allowNull == true) { return false; } else {/* ww w. j a va 2s . co m*/ if (field.getValue().trim().length() > length) { Notification.show(BundleUtils.getString("message.error.overlengthString"), Notification.Type.WARNING_MESSAGE); field.focus(); return true; } } return false; }
From source file:com.cms.utils.CommonValidator.java
public static Boolean validateNumber(TextField field) { String regex = "[0-9]+"; String str = field.getValue().trim(); if (str.matches(regex)) { return true; }//from www . j a v a 2 s . com return false; }
From source file:com.cms.utils.CommonValidator.java
public static Boolean validateTextField(TextField field, int length, boolean allowNull) { String text = field.getValue().trim(); if (!isNumberCharSpaceValid(text)) { return true; } else if (checkMaxlength(field, length, allowNull)) { return true; } else {//from ww w . j a v a2s . c o m return false; } }
From source file:com.cms.utils.ShortcutUtils.java
public static void doTextChangePhoneNumber(final TextField field) { field.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override// www . j a v a 2 s. co m public void textChange(FieldEvents.TextChangeEvent event) { try { String phone; if (field.getValue().length() < 10) { field.setBuffered(true); phone = event.getText(); field.setValue(phone); } if (field.getValue().length() >= 10) { field.setCursorPosition(event.getCursorPosition()); phone = convertText2PhoneFormat(event.getText()); field.setValue(phone); } if (field.getValue().length() == 11) { field.setCursorPosition(event.getCursorPosition()); phone = convertText2PhoneFormat(event.getText()); field.setValue(phone); } field.validate(); } catch (InvalidValueException e) { e.printStackTrace(); } } }); }
From source file:com.cms.utils.ShortcutUtils.java
public static void setVisibleTextfield(TextField field, boolean ok) { if (field.getValue() != null) { field.setEnabled(ok);/*from ww w. ja va 2 s . c o m*/ } }
From source file:com.coatl.pruebas.MyUI.java
@Override protected void init(VaadinRequest vaadinRequest) { final VerticalLayout layout = new VerticalLayout(); final TextField name = new TextField(); name.setCaption("Escribe algo aqu:"); Button button = new Button("Dime que escrib"); button.addClickListener(new Button.ClickListener() { @Override/*from w w w . j av a 2s.com*/ public void buttonClick(Button.ClickEvent event) { System.out.println("Click!"); layout.addComponent(new Label("Usted escribi> " + name.getValue())); } }); layout.addComponents(name, button); layout.setMargin(true); layout.setSpacing(true); setContent(layout); }
From source file:com.emuanalytics.vaadin.enhancedjavascript.BasicTestUI.java
License:Apache License
private Component createTestPanel() { TextField valueField = new TextField("Server value to send:"); valueField.setId("server-value-input"); Button setValueButton = new Button("Set Value From Server", clickEvent -> { sampleComponent.setValue(valueField.getValue()); });/* www . j av a2 s. co m*/ setValueButton.setId("set-value-button"); Button setTitleButton = new Button("Set Title From Server", clickEvent -> { sampleComponent.setTitle(valueField.getValue()); }); setTitleButton.setId("set-title-button"); Button setValueRPCButton = new Button("Set Value Via RPC", clickEvent -> { sampleComponent.setValueViaRPC(valueField.getValue()); }); setValueRPCButton.setId("set-value-rpc-button"); CheckBox immediateCheckbox = new CheckBox("Immediate variable notification"); immediateCheckbox.addValueChangeListener(e -> { sampleComponent.setImmediate(immediateCheckbox.getValue()); }); immediateCheckbox.setId("immediate-checkbox"); lastEventField = new TextField("Last event:"); lastEventField.setId("last-event-field"); lastVariableChangeField = new TextField("Last variable change:"); lastVariableChangeField.setId("last-variable-change-field"); VerticalLayout testLayout = new VerticalLayout(valueField, setValueButton, setTitleButton, setValueRPCButton, immediateCheckbox, lastEventField, lastVariableChangeField); testLayout.setWidth("300px"); testLayout.setSpacing(true); for (Component c : testLayout) { c.setWidth("100%"); } return testLayout; }
From source file:com.esofthead.mycollab.module.project.view.bug.components.ToggleBugSummaryField.java
License:Open Source License
private void updateFieldValue(TextField editField) { removeComponent(editField);//from w ww. ja va2 s. c o m addComponent(titleLinkLbl); addComponent(buttonControls); addStyleName("editable-field"); String newValue = editField.getValue(); if (StringUtils.isNotBlank(newValue) && !newValue.equals(bug.getSummary())) { bug.setSummary(newValue); titleLinkLbl.setValue(buildBugLink()); BugService bugService = AppContextUtil.getSpringBean(BugService.class); bugService.updateSelectiveWithSession(BeanUtility.deepClone(bug), AppContext.getUsername()); } isRead = !isRead; }
From source file:com.esofthead.mycollab.module.project.view.kanban.AddNewColumnWindow.java
License:Open Source License
public AddNewColumnWindow(final IKanbanView kanbanView, final String type, final String fieldGroup) { super(AppContext.getMessage(TaskI18nEnum.ACTION_NEW_COLUMN)); this.setWidth("800px"); this.setModal(true); this.setResizable(false); this.center(); MVerticalLayout layout = new MVerticalLayout().withMargin(new MarginInfo(false, false, true, false)); GridFormLayoutHelper gridFormLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4); this.setContent(layout); final TextField stageField = new TextField(); final CheckBox defaultProject = new CheckBox(); defaultProject.setEnabled(AppContext.canBeYes(RolePermissionCollections.GLOBAL_PROJECT_SETTINGS)); final ColorPicker colorPicker = new ColorPicker("", new com.vaadin.shared.ui.colorpicker.Color( DEFAULT_COLOR.getRed(), DEFAULT_COLOR.getGreen(), DEFAULT_COLOR.getBlue())); final TextArea description = new TextArea(); gridFormLayoutHelper.addComponent(stageField, AppContext.getMessage(GenericI18Enum.FORM_NAME), 0, 0); gridFormLayoutHelper.addComponent(defaultProject, AppContext.getMessage(TaskI18nEnum.FORM_COLUMN_DEFAULT_FOR_NEW_PROJECT), 0, 1); gridFormLayoutHelper.addComponent(colorPicker, AppContext.getMessage(TaskI18nEnum.FORM_COLUMN_COLOR), 0, 2); gridFormLayoutHelper.addComponent(description, AppContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0, 3);/*from ww w .j a va2 s .c o m*/ Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { OptionVal optionVal = new OptionVal(); optionVal.setCreatedtime(new GregorianCalendar().getTime()); optionVal.setCreateduser(AppContext.getUsername()); optionVal.setDescription(description.getValue()); com.vaadin.shared.ui.colorpicker.Color color = colorPicker.getColor(); String cssColor = color.getCSS(); if (cssColor.startsWith("#")) { cssColor = cssColor.substring(1); } optionVal.setColor(cssColor); if (defaultProject.getValue()) { optionVal.setIsdefault(true); } else { optionVal.setIsdefault(false); optionVal.setExtraid(CurrentProjectVariables.getProjectId()); } optionVal.setSaccountid(AppContext.getAccountId()); optionVal.setType(type); optionVal.setTypeval(stageField.getValue()); optionVal.setFieldgroup(fieldGroup); OptionValService optionService = AppContextUtil.getSpringBean(OptionValService.class); int optionValId = optionService.saveWithSession(optionVal, AppContext.getUsername()); if (optionVal.getIsdefault()) { optionVal.setId(null); optionVal.setIsdefault(false); optionVal.setRefoption(optionValId); optionVal.setExtraid(CurrentProjectVariables.getProjectId()); optionService.saveWithSession(optionVal, AppContext.getUsername()); } kanbanView.addColumn(optionVal); close(); } }); saveBtn.setIcon(FontAwesome.SAVE); saveBtn.setStyleName(UIConstants.BUTTON_ACTION); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { close(); } }); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); MHorizontalLayout controls = new MHorizontalLayout().with(cancelBtn, saveBtn) .withMargin(new MarginInfo(false, true, false, false)); layout.with(gridFormLayoutHelper.getLayout(), controls).withAlign(controls, Alignment.BOTTOM_RIGHT); }
From source file:com.esofthead.mycollab.module.project.view.milestone.ToggleGenericTaskSummaryField.java
License:Open Source License
private void updateFieldValue(TextField editField) { removeComponent(editField);// w w w . j a v a2 s .c om addComponent(titleLinkLbl); addComponent(buttonControls); addStyleName("editable-field"); String newValue = editField.getValue(); if (StringUtils.isNotBlank(newValue) && !newValue.equals(genericTask.getName())) { genericTask.setName(newValue); titleLinkLbl.setValue(buildGenericTaskLink()); if (genericTask.isBug()) { BugWithBLOBs bug = new BugWithBLOBs(); bug.setId(genericTask.getTypeId()); bug.setSummary(genericTask.getName()); bug.setSaccountid(AppContext.getAccountId()); BugService bugService = AppContextUtil.getSpringBean(BugService.class); bugService.updateSelectiveWithSession(bug, AppContext.getUsername()); } else if (genericTask.isTask()) { Task task = new Task(); task.setId(genericTask.getTypeId()); task.setTaskname(genericTask.getName()); task.setSaccountid(AppContext.getAccountId()); ProjectTaskService taskService = AppContextUtil.getSpringBean(ProjectTaskService.class); taskService.updateSelectiveWithSession(task, AppContext.getUsername()); } else if (genericTask.isRisk()) { Risk risk = new Risk(); risk.setId(genericTask.getTypeId()); risk.setRiskname(genericTask.getName()); risk.setSaccountid(AppContext.getAccountId()); RiskService riskService = AppContextUtil.getSpringBean(RiskService.class); riskService.updateSelectiveWithSession(risk, AppContext.getUsername()); } } isRead = !isRead; }