List of usage examples for com.vaadin.ui TextField addBlurListener
@Override
public Registration addBlurListener(BlurListener listener)
From source file:com.mycollab.module.project.view.milestone.ToggleTicketSummaryField.java
License:Open Source License
public ToggleTicketSummaryField(final ProjectTicket ticket) { this.ticket = ticket; this.setWidth("100%"); titleLinkLbl = ELabel.html(buildTicketLink()) .withStyleName(ValoTheme.LABEL_NO_MARGIN, UIConstants.LABEL_WORD_WRAP).withWidthUndefined(); if (ticket.isClosed()) { titleLinkLbl.addStyleName(WebUIConstants.LINK_COMPLETED); } else if (ticket.isOverdue()) { titleLinkLbl.addStyleName(WebUIConstants.LINK_OVERDUE); }/*from ww w. j a v a2 s . c o m*/ this.addComponent(titleLinkLbl); if (CurrentProjectVariables.canWriteTicket(ticket)) { this.addStyleName("editable-field"); buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false); MButton instantEditBtn = new MButton("", clickEvent -> { if (isRead) { removeComponent(titleLinkLbl); removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(ticket.getName()); editField.setWidth("100%"); editField.focus(); addComponent(editField); removeStyleName("editable-field"); editField.addValueChangeListener(valueChangeEvent -> updateFieldValue(editField)); editField.addBlurListener(blurEvent -> updateFieldValue(editField)); isRead = !isRead; } }).withIcon(FontAwesome.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ONLY, ValoTheme.BUTTON_ICON_ALIGN_TOP); instantEditBtn.setDescription(UserUIContext.getMessage(GenericI18Enum.ACTION_CLICK_TO_EDIT)); buttonControls.with(instantEditBtn); this.addComponent(buttonControls); } }
From source file:com.mycollab.module.project.view.task.components.ToggleTaskSummaryField.java
License:Open Source License
public ToggleTaskSummaryField(final SimpleTask task, int maxLength) { this.setWidth("100%"); this.maxLength = maxLength; this.task = task; titleLinkLbl = ELabel.html(buildTaskLink()).withWidthUndefined().withStyleName(UIConstants.LABEL_WORD_WRAP); this.addComponent(titleLinkLbl); buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { this.addStyleName("editable-field"); MButton instantEditBtn = new MButton("", clickEvent -> { if (isRead) { ToggleTaskSummaryField.this.removeComponent(titleLinkLbl); ToggleTaskSummaryField.this.removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(task.getTaskname()); editField.setWidth("100%"); editField.focus();/*from w ww . ja v a 2 s . c o m*/ ToggleTaskSummaryField.this.addComponent(editField); ToggleTaskSummaryField.this.removeStyleName("editable-field"); editField.addValueChangeListener(valueChangeEvent -> updateFieldValue(editField)); editField.addBlurListener(blurEvent -> updateFieldValue(editField)); isRead = !isRead; } }).withIcon(FontAwesome.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ONLY, ValoTheme.BUTTON_ICON_ALIGN_TOP); instantEditBtn.setDescription("Edit task name"); buttonControls.with(instantEditBtn); this.addComponent(buttonControls); } }
From source file:com.mycollab.module.project.view.task.ToggleTaskSummaryField.java
License:Open Source License
public ToggleTaskSummaryField(final SimpleTask task, int maxLength, boolean toggleStatusSupport, boolean canRemove) { this.setWidth("100%"); this.maxLength = maxLength; this.task = task; titleLinkLbl = ELabel.html(buildTaskLink()).withWidthUndefined().withStyleName(UIConstants.LABEL_WORD_WRAP); if (toggleStatusSupport && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { toggleStatusSelect = new CssCheckBox(); toggleStatusSelect.setSimpleMode(true); toggleStatusSelect.setValue(task.isCompleted()); displayTooltip();/* w w w .ja v a2 s.co m*/ toggleStatusSelect.addValueChangeListener(valueChangeEvent -> { if (task.isCompleted()) { task.setStatus(StatusI18nEnum.Open.name()); task.setPercentagecomplete(0d); titleLinkLbl.removeStyleName(WebThemes.LINK_COMPLETED); } else { task.setStatus(StatusI18nEnum.Closed.name()); task.setPercentagecomplete(100d); titleLinkLbl.addStyleName(WebThemes.LINK_COMPLETED); } displayTooltip(); ProjectTaskService projectTaskService = AppContextUtil.getSpringBean(ProjectTaskService.class); projectTaskService.updateWithSession(task, UserUIContext.getUsername()); if (StatusI18nEnum.Closed.name().equals(task.getStatus())) { Integer countOfOpenSubTasks = projectTaskService.getCountOfOpenSubTasks(task.getId()); if (countOfOpenSubTasks > 0) { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.OPT_QUESTION, MyCollabUI.getSiteName()), UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_CLOSE_SUB_ASSIGNMENTS), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { projectTaskService.massUpdateTaskStatuses(task.getId(), StatusI18nEnum.Closed.name(), MyCollabUI.getAccountId()); } }); } } }); this.addComponent(toggleStatusSelect); this.addComponent(ELabel.EMPTY_SPACE()); } this.addComponent(titleLinkLbl); buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true)) .withStyleName("toggle"); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { this.addStyleName("editable-field"); MButton instantEditBtn = new MButton("", clickEvent -> { if (isRead) { ToggleTaskSummaryField.this.removeComponent(titleLinkLbl); ToggleTaskSummaryField.this.removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(task.getName()); editField.setWidth("100%"); editField.focus(); ToggleTaskSummaryField.this.addComponent(editField); ToggleTaskSummaryField.this.removeStyleName("editable-field"); editField.addValueChangeListener(valueChangeEvent -> updateFieldValue(editField)); editField.addBlurListener(blurEvent -> updateFieldValue(editField)); isRead = !isRead; } }).withIcon(FontAwesome.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); instantEditBtn.setDescription(UserUIContext.getMessage(TaskI18nEnum.OPT_EDIT_TASK_NAME)); buttonControls.with(instantEditBtn); } if (canRemove && CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS)) { MButton removeBtn = new MButton("", clickEvent -> { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { AppContextUtil.getSpringBean(ProjectTaskService.class).removeWithSession(task, UserUIContext.getUsername(), MyCollabUI.getAccountId()); BlockRowRender rowRenderer = UIUtils.getRoot(ToggleTaskSummaryField.this, BlockRowRender.class); if (rowRenderer != null) { rowRenderer.selfRemoved(); } EventBusFactory.getInstance().post(new TaskEvent.TaskDeleted(this, task.getId())); } }); }).withIcon(FontAwesome.TRASH).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); buttonControls.with(removeBtn); } if (buttonControls.getComponentCount() > 0) { this.addComponent(buttonControls); } }
From source file:com.mycollab.module.project.view.ticket.ToggleTicketSummaryField.java
License:Open Source License
public ToggleTicketSummaryField(final ProjectTicket ticket) { this.ticket = ticket; this.setWidth("100%"); titleLinkLbl = ELabel.html(buildTicketLink()) .withStyleName(ValoTheme.LABEL_NO_MARGIN, UIConstants.LABEL_WORD_WRAP).withWidthUndefined(); if (ticket.isClosed()) { titleLinkLbl.addStyleName(WebThemes.LINK_COMPLETED); } else if (ticket.isOverdue()) { titleLinkLbl.addStyleName(WebThemes.LINK_OVERDUE); }// www. j av a 2 s. c o m this.addComponent(titleLinkLbl); if (CurrentProjectVariables.canWriteTicket(ticket)) { this.addStyleName("editable-field"); buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true)) .withStyleName("toggle"); buttonControls.setDefaultComponentAlignment(Alignment.TOP_LEFT); MButton instantEditBtn = new MButton("", clickEvent -> { if (isRead) { removeComponent(titleLinkLbl); removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(ticket.getName()); editField.setWidth("100%"); editField.focus(); addComponent(editField); removeStyleName("editable-field"); editField.addValueChangeListener(valueChangeEvent -> updateFieldValue(editField)); editField.addBlurListener(blurEvent -> updateFieldValue(editField)); isRead = !isRead; } }).withIcon(FontAwesome.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); instantEditBtn.setDescription(UserUIContext.getMessage(GenericI18Enum.ACTION_CLICK_TO_EDIT)); buttonControls.with(instantEditBtn); if ((ticket.isRisk() && CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.RISKS)) || (ticket.isBug() && CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.BUGS)) || (ticket.isTask() && CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS))) { MButton removeBtn = new MButton("", clickEvent -> { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { AppContextUtil.getSpringBean(ProjectTicketService.class).removeTicket(ticket, UserUIContext.getUsername()); BlockRowRender rowRenderer = UIUtils.getRoot(ToggleTicketSummaryField.this, BlockRowRender.class); if (rowRenderer != null) { rowRenderer.selfRemoved(); } EventBusFactory.getInstance() .post(new TicketEvent.HasTicketPropertyChanged(this, "all")); } }); }).withIcon(FontAwesome.TRASH).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); buttonControls.with(removeBtn); } this.addComponent(buttonControls); } }
From source file:com.mycollab.vaadin.web.ui.ShortcutExtension.java
License:Open Source License
public static TextField installShortcutAction(final TextField textField, final ShortcutListener listener) { textField.addFocusListener(focusEvent -> textField.addShortcutListener(listener)); textField.addBlurListener(blurEvent -> textField.removeShortcutListener(listener)); return textField; }
From source file:com.peergreen.example.webconsole.extensions.NotifierExtension.java
License:Open Source License
@PostConstruct public void init() { HorizontalLayout row = new HorizontalLayout(); row.setWidth("100%"); Button simpleButton = new Button("Click to create a notification !"); final Random random = new Random(); simpleButton.addClickListener(new Button.ClickListener() { @Override//from w w w. j a v a 2 s. co m public void buttonClick(Button.ClickEvent clickEvent) { notifierService.addNotification(MESSAGES[random.nextInt(MESSAGES.length)]); } }); simpleButton.setWidth("400px"); row.addComponent(simpleButton); row.setComponentAlignment(simpleButton, Alignment.BOTTOM_LEFT); final TextField customNotification = new TextField(); customNotification.setCaption("Write something and type enter"); final ShortcutListener addNotification = new ShortcutListener("Execute", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object o, Object o2) { notifierService.addNotification(customNotification.getValue()); customNotification.setValue(""); } }; customNotification.addFocusListener(new FieldEvents.FocusListener() { @Override public void focus(FieldEvents.FocusEvent focusEvent) { customNotification.addShortcutListener(addNotification); } }); customNotification.addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent blurEvent) { customNotification.removeShortcutListener(addNotification); } }); customNotification.setWidth("400px"); row.addComponent(customNotification); addComponent(row); setExpandRatio(row, 1.5f); }
From source file:com.peergreen.webconsole.scope.system.internal.shell.ShellConsoleView.java
License:Open Source License
private void initConsole() { Table table = new Table(); table.addStyleName("console-font"); table.addStyleName("borderless"); table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN); IndexedContainer container = new IndexedContainer(); table.setContainerDataSource(container); table.setImmediate(true);//from w w w .j av a 2 s . c om table.setSizeFull(); table.addContainerProperty("line", Label.class, null); addComponent(table); // Magic number: use all the empty space setExpandRatio(table, 1.5f); OutputStream out = new HtmlAnsiOutputStream(new WebConsoleOutputStream(table, container)); this.printStream = new PrintStream(out); session = processor.createSession(new ByteArrayInputStream("".getBytes()), printStream, printStream); final TextField input = new TextField(); input.setWidth("100%"); input.setInputPrompt(">$ "); final ShortcutListener shortcut = new ShortcutListener("Execute", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { try { String value = input.getValue(); printStream.printf(">$ %s\n", value); Object result = session.execute(value); //session.put(Constants.LAST_RESULT_VARIABLE, result); if (result != null) { session.getConsole().println(session.format(result, Converter.INSPECT)); } } catch (Exception e) { printException(printStream, e); } input.setValue(""); } }; // Install the shortcut listener only when the input text-field has the focus input.addFocusListener(new FieldEvents.FocusListener() { @Override public void focus(final FieldEvents.FocusEvent event) { input.addShortcutListener(shortcut); } }); input.addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(final FieldEvents.BlurEvent event) { input.removeShortcutListener(shortcut); } }); addComponent(input); doSessionBranding(printStream); }
From source file:cz.zcu.pia.social.network.frontend.handlers.OnEnterKeyHandler.java
public void installOn(final TextField component) { component.addFocusListener(new FieldEvents.FocusListener() { @Override//from w ww .j a v a2s. c om public void focus(FieldEvents.FocusEvent event) { component.addShortcutListener(enterShortCut); } }); component.addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent event) { component.removeShortcutListener(enterShortCut); } }); }
From source file:de.metas.ui.web.vaadin.listeners.OnEnterKeyHandler.java
License:Open Source License
public void installOn(final TextField component) { component.addFocusListener(new FieldEvents.FocusListener() { private static final long serialVersionUID = 1L; @Override/*from ww w . java 2s. c o m*/ public void focus(FieldEvents.FocusEvent event) { component.addShortcutListener(enterShortCut); } }); component.addBlurListener(new FieldEvents.BlurListener() { private static final long serialVersionUID = 1L; @Override public void blur(FieldEvents.BlurEvent event) { component.removeShortcutListener(enterShortCut); } }); }
From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java
public GroupView() { User user = UserUtils.getCurrent();/*w w w . j av a 2s.co m*/ Set<Group> groups = UserUtils.getAllGroups(user); CssLayout newGroupGroup = new CssLayout(); newGroupGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); TextField textFieldNewGroupName = new TextField(); Language.setCustom(Word.GROUP_NAME, s -> textFieldNewGroupName.setPlaceholder(s)); textFieldNewGroupName.setWidth("260px"); textFieldNewGroupName.setMaxLength(255); newGroupGroup.addComponent(textFieldNewGroupName); Button buttonNewGroup = new Button(); buttonNewGroup.setIcon(VaadinIcons.PLUS); buttonNewGroup.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonNewGroup.addClickListener(e -> { TabSheet.Tab newTab = accordion.addTab(createTab(createEmptyGroup(textFieldNewGroupName.getValue())), textFieldNewGroupName.getValue()); accordion.setSelectedTab(newTab); accordion.setWidth("100%"); textFieldNewGroupName.clear(); }); newGroupGroup.addComponent(buttonNewGroup); textFieldNewGroupName .addFocusListener(f -> buttonNewGroup.setClickShortcut(ShortcutAction.KeyCode.ENTER, null)); textFieldNewGroupName.addBlurListener(f -> buttonNewGroup.removeClickShortcut()); groups.forEach(g -> { accordion.addTab(createTab(g), g.getName()); }); addComponents(newGroupGroup, accordion); //SESSIONS.put(user, this); }