com.vaadin.event.ShortcutListener Java Examples

The following examples show how to use com.vaadin.event.ShortcutListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SearchTextField.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
public SearchTextField() {
    this.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT);
    ELabel icon = ELabel.fontIcon(VaadinIcons.SEARCH);
    innerField = new TextField();
    innerField.setPlaceholder(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
    innerField.setWidth("180px");
    this.with(icon, innerField).withStyleName("searchfield");
    ShortcutListener shortcutListener = new ShortcutListener("searchfield", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            String value = ((TextField) target).getValue();
            if (isNotBlank(value)) {
                doSearch(value);
            } else {
                emptySearch();
            }
        }
    };
    ShortcutExtension.installShortcutAction(innerField, shortcutListener);
}
 
Example #2
Source File: SideMenuBuilder.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void assignShortcut(Window webWindow, SideMenu.MenuItem menuItem, MenuItem item) {
    KeyCombination itemShortcut = item.getShortcut();
    if (itemShortcut != null) {
        ShortcutListener shortcut = new SideMenuShortcutListener(menuItem, item);

        AbstractComponent windowImpl = webWindow.unwrap(AbstractComponent.class);
        windowImpl.addShortcutListener(shortcut);

        if (Strings.isNullOrEmpty(menuItem.getBadgeText())) {
            menuItem.setDescription(itemShortcut.format());
        }
    }
}
 
Example #3
Source File: CubaTable.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public Registration addShortcutListener(ShortcutListener shortcut) {
    if (shortcutActionManager == null) {
        shortcutActionManager = new ShortcutActionManager(this);
    }

    shortcutActionManager.addAction(shortcut);
    return () -> getActionManager().removeAction(shortcut);
}
 
Example #4
Source File: CubaTreeTable.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public Registration addShortcutListener(ShortcutListener shortcut) {
    if (shortcutActionManager == null) {
        shortcutActionManager = new ShortcutActionManager(this);
    }

    shortcutActionManager.addAction(shortcut);
    return () -> getActionManager().removeAction(shortcut);
}
 
Example #5
Source File: ToggleBugSummaryField.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
ToggleBugSummaryField(SimpleBug bug, int trimCharacters) {
    this.bug = bug;
    this.maxLength = trimCharacters;
    titleLinkLbl = ELabel.html(buildBugLink()).withStyleName(WebThemes.LABEL_WORD_WRAP).withUndefinedWidth();
    this.addComponent(titleLinkLbl);
    buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false);
    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) {
        this.addStyleName("editable-field");
        MButton instantEditBtn = new MButton("", clickEvent -> {
            if (isRead) {
                ToggleBugSummaryField.this.removeComponent(titleLinkLbl);
                ToggleBugSummaryField.this.removeComponent(buttonControls);
                TextField editField = new TextField();
                editField.setValue(bug.getName());
                editField.setWidth("100%");
                editField.focus();
                ToggleBugSummaryField.this.addComponent(editField);
                ToggleBugSummaryField.this.removeStyleName("editable-field");
                editField.addShortcutListener(new ShortcutListener("enter", ShortcutAction.KeyCode.ENTER, (int[]) null) {
                    @Override
                    public void handleAction(Object sender, Object target) {
                        updateFieldValue(editField);
                    }
                });
                editField.addBlurListener(blurEvent -> updateFieldValue(editField));
                isRead = !isRead;
            }
        }).withDescription(UserUIContext.getMessage(BugI18nEnum.OPT_EDIT_BUG_NAME))
                .withIcon(VaadinIcons.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ONLY, ValoTheme.BUTTON_ICON_ALIGN_TOP);
        buttonControls.with(instantEditBtn);
        this.addComponent(buttonControls);
    }
}
 
Example #6
Source File: TestStepperField.java    From cuba with Apache License 2.0 5 votes vote down vote up
private ShortcutListener createAdjustmentShortcut(int keyCode, int adjustment) {
    return new ShortcutListener(null, keyCode, (int[]) null) {
        @Override
        public void handleAction(Object sender, Object target) {
            updateValue(adjustment);
        }
    };
}
 
Example #7
Source File: WebAbstractBox.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void addShortcutAction(ShortcutAction action) {
    KeyCombination keyCombination = action.getShortcutCombination();
    com.vaadin.event.ShortcutListener shortcut =
            new ContainerShortcutActionWrapper(action, this, keyCombination);
    component.addShortcutListener(shortcut);

    if (shortcuts == null) {
        shortcuts = new HashMap<>(4);
    }
    shortcuts.put(action, shortcut);
}
 
Example #8
Source File: WebGridLayout.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void addShortcutAction(ShortcutAction action) {
    KeyCombination keyCombination = action.getShortcutCombination();
    com.vaadin.event.ShortcutListener shortcut =
            new ContainerShortcutActionWrapper(action, this, keyCombination);
    component.addShortcutListener(shortcut);

    if (shortcuts == null) {
        shortcuts = new HashMap<>(4);
    }
    shortcuts.put(action, shortcut);
}
 
Example #9
Source File: WebAppWorkArea.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected ShortcutListener createPreviousWindowTabShortcut(RootWindow topLevelWindow) {
    Configuration configuration = beanLocator.get(Configuration.NAME);
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);

    String previousTabShortcut = clientConfig.getPreviousTabShortcut();
    KeyCombination combination = KeyCombination.create(previousTabShortcut);

    return new ShortcutListenerDelegate("onPreviousTab", combination.getKey().getCode(),
            KeyCombination.Modifier.codes(combination.getModifiers())
    ).withHandler((sender, target) -> {
        TabSheetBehaviour tabSheet = getTabbedWindowContainer().getTabSheetBehaviour();

        if (tabSheet != null
                && !hasModalWindow()
                && tabSheet.getComponentCount() > 1) {
            com.vaadin.ui.Component selectedTabComponent = tabSheet.getSelectedTab();
            String selectedTabId = tabSheet.getTab(selectedTabComponent);
            int tabPosition = tabSheet.getTabPosition(selectedTabId);
            int newTabPosition = (tabSheet.getComponentCount() + tabPosition - 1) % tabSheet.getComponentCount();

            String newTabId = tabSheet.getTab(newTabPosition);
            tabSheet.setSelectedTab(newTabId);

            moveFocus(tabSheet, newTabId);
        }
    });
}
 
Example #10
Source File: WebAppWorkArea.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected ShortcutListener createNextWindowTabShortcut(RootWindow topLevelWindow) {
    Configuration configuration = beanLocator.get(Configuration.NAME);
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);

    String nextTabShortcut = clientConfig.getNextTabShortcut();
    KeyCombination combination = KeyCombination.create(nextTabShortcut);

    return new ShortcutListenerDelegate(
            "onNextTab", combination.getKey().getCode(),
            KeyCombination.Modifier.codes(combination.getModifiers())
    ).withHandler((sender, target) -> {
        TabSheetBehaviour tabSheet = getTabbedWindowContainer().getTabSheetBehaviour();

        if (tabSheet != null
                && !hasModalWindow()
                && tabSheet.getComponentCount() > 1) {
            com.vaadin.ui.Component selectedTabComponent = tabSheet.getSelectedTab();
            String tabId = tabSheet.getTab(selectedTabComponent);
            int tabPosition = tabSheet.getTabPosition(tabId);
            int newTabPosition = (tabPosition + 1) % tabSheet.getComponentCount();

            String newTabId = tabSheet.getTab(newTabPosition);
            tabSheet.setSelectedTab(newTabId);

            moveFocus(tabSheet, newTabId);
        }
    });
}
 
Example #11
Source File: WebAppWorkArea.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected ShortcutListener createCloseShortcut(RootWindow topLevelWindow) {
    Configuration configuration = beanLocator.get(Configuration.NAME);
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination combination = KeyCombination.create(closeShortcut);

    return new ShortcutListenerDelegate("onClose", combination.getKey().getCode(),
            KeyCombination.Modifier.codes(combination.getModifiers()))
            .withHandler((sender, target) ->
                    closeWindowByShortcut(topLevelWindow)
            );
}
 
Example #12
Source File: WebGroupBox.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void addShortcutAction(ShortcutAction action) {
    KeyCombination keyCombination = action.getShortcutCombination();
    com.vaadin.event.ShortcutListener shortcut =
            new ContainerShortcutActionWrapper(action, this, keyCombination);
    component.addShortcutListener(shortcut);

    if (shortcuts == null) {
        shortcuts = new HashMap<>(4);
    }
    shortcuts.put(action, shortcut);
}
 
Example #13
Source File: WebAbstractOrderedLayout.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void addShortcutAction(ShortcutAction action) {
    KeyCombination keyCombination = action.getShortcutCombination();
    com.vaadin.event.ShortcutListener shortcut =
            new ContainerShortcutActionWrapper(action, this, keyCombination);
    component.addShortcutListener(shortcut);

    if (shortcuts == null) {
        shortcuts = new HashMap<>(4);
    }
    shortcuts.put(action, shortcut);
}
 
Example #14
Source File: MenuBuilder.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void assignShortcut(Window webWindow, AppMenu.MenuItem menuItem, MenuItem item) {
    KeyCombination itemShortcut = item.getShortcut();
    if (itemShortcut != null) {
        ShortcutListener shortcut = new MenuShortcutAction(menuItem, "shortcut_" + item.getId(), item.getShortcut());

        AbstractComponent windowImpl = webWindow.unwrap(AbstractComponent.class);
        windowImpl.addShortcutListener(shortcut);

        appMenu.setMenuItemShortcutCaption(menuItem, itemShortcut.format());
    }
}
 
Example #15
Source File: WebScrollBoxLayout.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void addShortcutAction(ShortcutAction action) {
    KeyCombination keyCombination = action.getShortcutCombination();
    com.vaadin.event.ShortcutListener shortcut =
            new ContainerShortcutActionWrapper(action, this, keyCombination);
    component.addShortcutListener(shortcut);

    if (shortcuts == null) {
        shortcuts = new HashMap<>(4);
    }
    shortcuts.put(action, shortcut);
}
 
Example #16
Source File: ShortcutExtension.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public static TextField installShortcutAction(final TextField textField, final ShortcutListener listener) {
    textField.addFocusListener(focusEvent -> textField.addShortcutListener(listener));
    textField.addBlurListener(blurEvent -> textField.removeShortcutListener(listener));
    return textField;
}
 
Example #17
Source File: ToggleTaskSummaryField.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public ToggleTaskSummaryField(SimpleTask task, int maxLength, boolean toggleStatusSupport, boolean canRemove) {
    this.setWidth("100%");
    this.maxLength = maxLength;
    this.task = task;
    titleLinkLbl = ELabel.html(buildTaskLink()).withUndefinedWidth().withStyleName(WebThemes.LABEL_WORD_WRAP);

    if (toggleStatusSupport && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) {
        toggleStatusSelect = new CheckBox();
        toggleStatusSelect.setValue(task.isCompleted());
        displayTooltip();
        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();
            TaskService taskService = AppContextUtil.getSpringBean(TaskService.class);
            taskService.updateWithSession(task, UserUIContext.getUsername());

            if (StatusI18nEnum.Closed.name().equals(task.getStatus())) {
                Integer countOfOpenSubTasks = taskService.getCountOfOpenSubTasks(task.getId());
                if (countOfOpenSubTasks > 0) {
                    ConfirmDialogExt.show(UI.getCurrent(),
                            UserUIContext.getMessage(GenericI18Enum.OPT_QUESTION, AppUI.getSiteName()),
                            UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_CLOSE_SUB_ASSIGNMENTS),
                            UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                            UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                            confirmDialog -> {
                                if (confirmDialog.isConfirmed()) {
                                    taskService.massUpdateTaskStatuses(task.getId(), StatusI18nEnum.Closed.name(),
                                            AppUI.getAccountId());
                                }
                            });
                }
            }
        });
        this.withComponents(toggleStatusSelect, 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.addShortcutListener(new ShortcutListener("enter", ShortcutAction.KeyCode.ENTER, (int[]) null) {
                    @Override
                    public void handleAction(Object sender, Object target) {
                        updateFieldValue(editField);
                    }
                });
                editField.addBlurListener(blurEvent -> updateFieldValue(editField));
                isRead = !isRead;
            }
        }).withIcon(VaadinIcons.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, AppUI.getSiteName()),
                    UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                    UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                    UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                    confirmDialog -> {
                        if (confirmDialog.isConfirmed()) {
                            AppContextUtil.getSpringBean(TaskService.class).removeWithSession(task,
                                    UserUIContext.getUsername(), AppUI.getAccountId());
                            TicketRowRender rowRenderer = UIUtils.getRoot(ToggleTaskSummaryField.this, TicketRowRender.class);
                            if (rowRenderer != null) {
                                rowRenderer.selfRemoved();
                            }
                            EventBusFactory.getInstance().post(new TaskEvent.TaskDeleted(this, task.getId()));
                        }
                    });
        }).withIcon(VaadinIcons.TRASH).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
        buttonControls.with(removeBtn);
    }
    if (buttonControls.getComponentCount() > 0) {
        this.addComponent(buttonControls);
    }
}
 
Example #18
Source File: ToggleMilestoneSummaryField.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
ToggleMilestoneSummaryField(final SimpleMilestone milestone, int maxLength, boolean toggleStatusSupport, boolean isDeleteSupport) {
    this.milestone = milestone;
    this.maxLength = maxLength;
    this.setWidth("100%");
    this.addStyleName("editable-field");
    if (toggleStatusSupport && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) {
        toggleStatusSelect = new CheckBox();
        toggleStatusSelect.setValue(milestone.isCompleted());
        this.addComponent(toggleStatusSelect);
        this.addComponent(ELabel.EMPTY_SPACE());
        displayTooltip();

        toggleStatusSelect.addValueChangeListener(valueChangeEvent -> {
            if (milestone.isCompleted()) {
                milestone.setStatus(MilestoneStatus.InProgress.name());
                titleLinkLbl.removeStyleName(WebThemes.LINK_COMPLETED);
            } else {
                milestone.setStatus(MilestoneStatus.Closed.name());
                titleLinkLbl.addStyleName(WebThemes.LINK_COMPLETED);
            }
            displayTooltip();
            MilestoneService milestoneService = AppContextUtil.getSpringBean(MilestoneService.class);
            milestoneService.updateSelectiveWithSession(milestone, UserUIContext.getUsername());
            ProjectTicketSearchCriteria searchCriteria = new ProjectTicketSearchCriteria();
            searchCriteria.setProjectIds(new SetSearchField<>(CurrentProjectVariables.getProjectId()));
            searchCriteria.setTypes(new SetSearchField<>(ProjectTypeConstants.BUG, ProjectTypeConstants.RISK,
                    ProjectTypeConstants.TASK));
            searchCriteria.setMilestoneId(NumberSearchField.equal(milestone.getId()));
            searchCriteria.setOpen(new SearchField());
            ProjectTicketService genericTaskService = AppContextUtil.getSpringBean(ProjectTicketService.class);
            int openAssignmentsCount = genericTaskService.getTotalCount(searchCriteria);
            if (openAssignmentsCount > 0) {
                ConfirmDialogExt.show(UI.getCurrent(),
                        UserUIContext.getMessage(GenericI18Enum.OPT_QUESTION, AppUI.getSiteName()),
                        UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_CLOSE_SUB_ASSIGNMENTS),
                        UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                        UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                        confirmDialog -> {
                            if (confirmDialog.isConfirmed()) {
                                genericTaskService.closeSubAssignmentOfMilestone(milestone.getId());
                            }
                        });
            }
        });
    }

    titleLinkLbl = ELabel.h3(buildMilestoneLink()).withStyleName(WebThemes.LABEL_WORD_WRAP).withUndefinedWidth();
    this.addComponent(titleLinkLbl);
    buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true)).withStyleName("toggle");
    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) {
        MButton instantEditBtn = new MButton("", clickEvent -> {
            if (isRead) {
                ToggleMilestoneSummaryField.this.removeComponent(titleLinkLbl);
                ToggleMilestoneSummaryField.this.removeComponent(buttonControls);
                final MTextField editField = new MTextField(milestone.getName()).withFullWidth();
                editField.focus();
                ToggleMilestoneSummaryField.this.addComponent(editField);
                ToggleMilestoneSummaryField.this.removeStyleName("editable-field");
                editField.addShortcutListener(new ShortcutListener("enter", ShortcutAction.KeyCode.ENTER, (int[]) null) {
                    @Override
                    public void handleAction(Object sender, Object target) {
                        updateFieldValue(editField);
                    }
                });
                editField.addBlurListener(blurEvent -> updateFieldValue(editField));
                isRead = !isRead;
            }
        }).withDescription(UserUIContext.getMessage(MilestoneI18nEnum.OPT_EDIT_PHASE_NAME))
                .withIcon(VaadinIcons.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
        buttonControls.with(instantEditBtn);
    }
    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MILESTONES)) {
        MButton removeBtn = new MButton("", clickEvent -> {
            ConfirmDialogExt.show(UI.getCurrent(),
                    UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppUI.getSiteName()),
                    UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                    UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                    UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                    confirmDialog -> {
                        if (confirmDialog.isConfirmed()) {
                            AppContextUtil.getSpringBean(MilestoneService.class).removeWithSession(milestone,
                                    UserUIContext.getUsername(), AppUI.getAccountId());
                            TicketRowRender rowRenderer = UIUtils.getRoot(ToggleMilestoneSummaryField.this, TicketRowRender.class);
                            if (rowRenderer != null) {
                                rowRenderer.selfRemoved();
                            }
                            EventBusFactory.getInstance().post(new MilestoneEvent.MilestoneDeleted(this, milestone.getId()));
                        }
                    });
        }).withIcon(VaadinIcons.TRASH).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
        buttonControls.with(removeBtn);
    }
    if (buttonControls.getComponentCount() > 0) {
        this.addComponent(buttonControls);
    }
}
 
Example #19
Source File: ToggleTicketSummaryField.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public ToggleTicketSummaryField(ProjectTicket ticket) {
    this.ticket = ticket;
    this.setWidth("100%");
    titleLinkLbl = ELabel.html(buildTicketLink()).withStyleName(ValoTheme.LABEL_NO_MARGIN,
            WebThemes.LABEL_WORD_WRAP).withUndefinedWidth();
    if (ticket.isClosed()) {
        titleLinkLbl.addStyleName(WebThemes.LINK_COMPLETED);
    } else if (ticket.isOverdue()) {
        titleLinkLbl.addStyleName(WebThemes.LINK_OVERDUE);
    }
    this.addComponent(titleLinkLbl);
    if (CurrentProjectVariables.canWriteTicket(ticket)) {
        this.addStyleName("editable-field");
        buttonControls = new MHorizontalLayout().withMargin(false).withStyleName("toggle");
        buttonControls.setDefaultComponentAlignment(Alignment.TOP_LEFT);
        MButton instantEditBtn = new MButton("", clickEvent -> {
            if (isRead) {
                removeComponent(titleLinkLbl);
                removeComponent(buttonControls);
                TextField editField = new TextField();
                editField.setValue(ticket.getName());
                editField.setWidth("100%");
                editField.focus();
                addComponent(editField);
                removeStyleName("editable-field");
                editField.addShortcutListener(new ShortcutListener("enter", ShortcutAction.KeyCode.ENTER, (int[]) null) {
                    @Override
                    public void handleAction(Object sender, Object target) {
                        updateFieldValue(editField);
                    }
                });
                editField.addBlurListener(blurEvent -> updateFieldValue(editField));
                isRead = !isRead;
            }
        }).withIcon(VaadinIcons.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP)
                .withDescription(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, AppUI.getSiteName()),
                        UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                        UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                        UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                        confirmDialog -> {
                            if (confirmDialog.isConfirmed()) {
                                AppContextUtil.getSpringBean(ProjectTicketService.class).removeTicket(ticket, UserUIContext.getUsername());
                                TicketRowRender rowRenderer = UIUtils.getRoot(ToggleTicketSummaryField.this,
                                        TicketRowRender.class);
                                if (rowRenderer != null) {
                                    rowRenderer.selfRemoved();
                                }
                                EventBusFactory.getInstance().post(new TicketEvent.HasTicketPropertyChanged(this, "all"));
                            }
                        });
            }).withIcon(VaadinIcons.TRASH).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
            buttonControls.with(removeBtn);
        }

        this.addComponent(buttonControls);
    }
}
 
Example #20
Source File: CubaTextField.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public void removeShortcutListener(ShortcutListener listener) {
    getActionManager().removeAction(listener);
}
 
Example #21
Source File: JobLogFilter.java    From chipster with MIT License 4 votes vote down vote up
public JobLogFilter(final JobLogView view, String column, String search) {
	this.view = view;

	searchStringField = new TextField();
	if (search != null) {
		searchStringField.setValue(search);
	}
	searchStringField.setDescription("Search for values starting with this string. Question mark (?) is a wildcard for a single character and asterisk (*) for any number of characters.");  
	searchStringField.addShortcutListener(new ShortcutListener("Search", ShortcutAction.KeyCode.ENTER, null) {

		@Override
		public void handleAction(Object sender, Object target) {
			view.update();
		}
	});

	columnToSearch = new NativeSelect();

	Button clearButton = new Button();
	clearButton.setIcon(new ThemeResource("crystal/button_cancel-bw.png"));
	clearButton.setDescription("Remove filter");
	clearButton.addStyleName("search-button");

	for (int i = 0; i < JobLogContainer.NATURAL_COL_ORDER.length; i++) {

		//Do not search from generated columns
		if (SEARCH_COLUMNS.contains(JobLogContainer.NATURAL_COL_ORDER[i])) {
			columnToSearch.addItem(JobLogContainer.NATURAL_COL_ORDER[i]);
			columnToSearch.setItemCaption(JobLogContainer.NATURAL_COL_ORDER[i],
					JobLogContainer.COL_HEADERS_ENGLISH[i]);
		}
	}

	if (column != null) {
		columnToSearch.setValue(column);
	} else {
		columnToSearch.setValue(JobLogContainer.USERNAME);
	}
	columnToSearch.setNullSelectionAllowed(false);

	clearButton.addClickListener(new Button.ClickListener() {
		public void buttonClick(ClickEvent event) {
			getView().clearFilter(JobLogFilter.this);
		}
	});

	addComponent(columnToSearch);
	addComponent(searchStringField);
	addComponent(clearButton);

	addStyleName("search-filter-bg");
	addStyleName("search-filter");
}
 
Example #22
Source File: CubaTextField.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addShortcutListener(ShortcutListener listener) {
    getActionManager().addAction(listener);
    return () -> getActionManager().removeAction(listener);
}
 
Example #23
Source File: CubaComboBox.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public void removeShortcutListener(ShortcutListener listener) {
    getActionManager().removeAction(listener);
}
 
Example #24
Source File: CubaComboBox.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addShortcutListener(ShortcutListener listener) {
    getActionManager().addAction(listener);
    return () -> getActionManager().removeAction(listener);
}
 
Example #25
Source File: CubaTable.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public void removeShortcutListener(ShortcutListener shortcut) {
    if (shortcutActionManager != null) {
        shortcutActionManager.removeAction(shortcut);
    }
}
 
Example #26
Source File: CubaGridLayout.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public void removeShortcutListener(ShortcutListener listener) {
    getActionManager().removeAction(listener);
}
 
Example #27
Source File: CubaGridLayout.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addShortcutListener(ShortcutListener listener) {
    getActionManager().addAction(listener);
    return () -> getActionManager().removeAction(listener);
}
 
Example #28
Source File: CubaTreeTable.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public void removeShortcutListener(ShortcutListener shortcut) {
    if (shortcutActionManager != null) {
        shortcutActionManager.removeAction(shortcut);
    }
}
 
Example #29
Source File: CubaCssActionsLayout.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public void removeShortcutListener(ShortcutListener listener) {
    getActionManager().removeAction(listener);
}
 
Example #30
Source File: CubaCssActionsLayout.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addShortcutListener(ShortcutListener listener) {
    getActionManager().addAction(listener);
    return () -> getActionManager().removeAction(listener);
}