Java源码示例:com.vaadin.event.ShortcutAction
示例1
protected CubaVerticalActionsLayout createFoldersPaneLayout(Component foldersPane, Label foldersLabel) {
CubaVerticalActionsLayout layout = new CubaVerticalActionsLayout();
layout.setMargin(true);
layout.setSpacing(true);
layout.setSizeFull();
if (foldersLabel != null)
addFoldersLabel(layout, foldersLabel);
layout.addComponent(foldersPane);
layout.setExpandRatio(foldersPane, 1);
layout.addShortcutListener(
new ShortcutListenerDelegate("apply" + foldersPane.getCubaId(), ShortcutAction.KeyCode.ENTER, null)
.withHandler((sender, target) -> {
if (sender == layout) {
handleFoldersPaneShortcutAction(foldersPane);
}
}));
return layout;
}
示例2
@Override
public ComponentContainer constructBody() {
MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
basicSearchBody.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
basicSearchBody.addComponent(new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":"));
nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT))
.withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
basicSearchBody.addComponent(nameField);
MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction())
.withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION)
.withClickShortcut(ShortcutAction.KeyCode.ENTER);
basicSearchBody.addComponent(searchBtn);
MButton clearBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue(""))
.withStyleName(WebThemes.BUTTON_OPTION);
basicSearchBody.addComponent(clearBtn);
return basicSearchBody;
}
示例3
@Override
public ComponentContainer constructBody() {
MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
basicSearchBody.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
Label nameLbl = new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":");
basicSearchBody.with(nameLbl);
nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT))
.withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
basicSearchBody.with(nameField);
myItemCheckbox = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
basicSearchBody.with(myItemCheckbox);
MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction())
.withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION)
.withClickShortcut(ShortcutAction.KeyCode.ENTER);
basicSearchBody.with(searchBtn);
MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue(""))
.withStyleName(WebThemes.BUTTON_OPTION);
basicSearchBody.with(cancelBtn);
return basicSearchBody;
}
示例4
@Override
public ComponentContainer constructBody() {
MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
basicSearchBody.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
Label nameLbl = new Label("Name:");
basicSearchBody.with(nameLbl);
nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT))
.withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
basicSearchBody.with(nameField);
MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction())
.withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION)
.withClickShortcut(ShortcutAction.KeyCode.ENTER);
basicSearchBody.with(searchBtn);
MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue(""))
.withStyleName(WebThemes.BUTTON_OPTION);
basicSearchBody.with(cancelBtn);
return basicSearchBody;
}
示例5
@Override
public ComponentContainer constructBody() {
MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT))
.withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
basicSearchBody.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER);
MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent ->
callSearchAction()).withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION)
.withClickShortcut(ShortcutAction.KeyCode.ENTER);
basicSearchBody.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_LEFT);
MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR),
clickEvent -> nameField.setValue("")).withStyleName(WebThemes.BUTTON_OPTION);
basicSearchBody.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER);
MButton advancedSearchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH),
clickEvent -> moveToAdvancedSearchLayout()).withStyleName(WebThemes.BUTTON_LINK);
basicSearchBody.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER);
return basicSearchBody;
}
示例6
@Override
public ComponentContainer constructBody() {
MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true)
.with(new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":"));
nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT))
.withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
basicSearchBody.addComponent(nameField);
MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction())
.withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION)
.withClickShortcut(ShortcutAction.KeyCode.ENTER);
basicSearchBody.addComponent(searchBtn);
MButton clearBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue(""))
.withStyleName(WebThemes.BUTTON_OPTION);
basicSearchBody.addComponent(clearBtn);
basicSearchBody.setComponentAlignment(clearBtn, Alignment.MIDDLE_LEFT);
return basicSearchBody;
}
示例7
private void buildSaveFilterBox() {
filterBox.removeAllComponents();
TextField queryTextField = new TextField();
filterBox.addComponent(queryTextField);
MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> {
String queryText = queryTextField.getValue();
saveSearchCriteria(queryText);
}).withIcon(VaadinIcons.CLIPBOARD).withStyleName(WebThemes.BUTTON_ACTION).withClickShortcut(ShortcutAction.KeyCode.ENTER);
filterBox.addComponent(saveBtn);
MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> buildFilterBox(null))
.withStyleName(WebThemes.BUTTON_OPTION);
filterBox.addComponent(cancelBtn);
}
示例8
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);
}
示例9
/**
* @deprecated Will be removed without replacement
*/
@Deprecated
public static void addEnterShortcut(TextField textField, Runnable runnable) {
textField.withUnwrapped(CubaTextField.class, vTextField ->
vTextField.addShortcutListener(
new ShortcutListenerDelegate("", ShortcutAction.KeyCode.ENTER, null)
.withHandler((sender, target) ->
runnable.run()
)));
}
示例10
@Override
protected void initComponent(CubaPickerField<V> component) {
CubaComboBoxPickerField<V> impl = (CubaComboBoxPickerField<V>) component;
impl.setItemCaptionGenerator(this::generateItemCaption);
impl.getFieldInternal().setCustomValueEquals(this::fieldValueEquals);
component.addShortcutListener(new ShortcutListenerDelegate("clearShortcut",
ShortcutAction.KeyCode.DELETE, new int[]{ShortcutAction.ModifierKey.SHIFT})
.withHandler(this::handleClearShortcut));
}
示例11
public void addAction(Action action, int index) {
actionList.add(index, action);
updateOrderedShortcuts();
KeyCombination combination = action.getShortcutCombination();
if (combination != null) {
int key = combination.getKey().getCode();
int[] modifiers = KeyCombination.Modifier.codes(combination.getModifiers());
ShortcutAction providedShortcut = new ShortcutAction(action.getCaption(), key, modifiers);
shortcuts.add(providedShortcut);
actionsMap.put(providedShortcut, action);
}
}
示例12
public void removeAction(Action action) {
List<ShortcutAction> existActions = new ArrayList<>(4);
for (Map.Entry<ShortcutAction, Action> entry : actionsMap.entrySet()) {
if (entry.getValue().equals(action)) {
existActions.add(entry.getKey());
}
}
shortcuts.removeAll(existActions);
for (ShortcutAction shortcut : existActions) {
actionsMap.remove(shortcut);
}
actionList.remove(action);
updateOrderedShortcuts();
}
示例13
@Override
protected void setComposition(CssLayout composition) {
super.setComposition(composition);
valueField = getInnerComponent("stepper_valueField");
CubaTextField cubaTextField = valueField.unwrap(CubaTextField.class);
cubaTextField.addShortcutListener(createAdjustmentShortcut(ShortcutAction.KeyCode.ARROW_UP, 1));
cubaTextField.addShortcutListener(createAdjustmentShortcut(ShortcutAction.KeyCode.ARROW_DOWN, -1));
upBtn = getInnerComponent("stepper_upBtn");
downBtn = getInnerComponent("stepper_downBtn");
upBtn.addClickListener(clickEvent -> updateValue(1));
downBtn.addClickListener(clickEvent -> updateValue(-1));
}
示例14
private void configureComponents() {
/* Highlight primary actions.
*
* With Vaadin built-in styles you can highlight the primary save button
* and give it a keyboard shortcut for a better UX.
*/
save.setStyleName(ValoTheme.BUTTON_PRIMARY);
save.setClickShortcut(ShortcutAction.KeyCode.ENTER);
setVisible(false);
}
示例15
/**
* Returns the ctrl or meta modifier depending on the platform.
*
* @return on mac return
* {@link com.vaadin.event.ShortcutAction.ModifierKey#META} other
* platform return
* {@link com.vaadin.event.ShortcutAction.ModifierKey#CTRL}
*/
public static int getCtrlOrMetaModifier() {
final WebBrowser webBrowser = Page.getCurrent().getWebBrowser();
if (webBrowser.isMacOSX()) {
return ShortcutAction.ModifierKey.META;
}
return ShortcutAction.ModifierKey.CTRL;
}
示例16
@Override
public ComponentContainer constructBody() {
MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
Label nameLbl = new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":");
basicSearchBody.with(nameLbl).withAlign(nameLbl, Alignment.MIDDLE_LEFT);
nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT))
.withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
basicSearchBody.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER);
myItemCheckbox = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
basicSearchBody.with(myItemCheckbox).withAlign(myItemCheckbox, Alignment.MIDDLE_CENTER);
MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction())
.withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION)
.withClickShortcut(ShortcutAction.KeyCode.ENTER);
basicSearchBody.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_LEFT);
MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue(""))
.withStyleName(WebThemes.BUTTON_OPTION);
basicSearchBody.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER);
if (canSwitchToAdvanceLayout) {
MButton advancedSearchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH),
clickEvent -> moveToAdvancedSearchLayout()).withStyleName(WebThemes.BUTTON_LINK);
basicSearchBody.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER);
}
return basicSearchBody;
}
示例17
@Override
public ComponentContainer constructBody() {
MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
Label nameLbl = new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":");
basicSearchBody.with(nameLbl).withAlign(nameLbl, Alignment.MIDDLE_LEFT);
nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT))
.withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
basicSearchBody.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER);
myItemCheckbox = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
basicSearchBody.with(myItemCheckbox).withAlign(myItemCheckbox, Alignment.MIDDLE_CENTER);
MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction())
.withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION)
.withClickShortcut(ShortcutAction.KeyCode.ENTER);
basicSearchBody.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_LEFT);
MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue(""))
.withStyleName(WebThemes.BUTTON_OPTION);
basicSearchBody.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER);
if (canSwitchToAdvanceLayout) {
MButton advancedSearchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH),
clickEvent -> moveToAdvancedSearchLayout()).withStyleName(WebThemes.BUTTON_LINK);
basicSearchBody.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER);
}
return basicSearchBody;
}
示例18
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);
}
}
示例19
@Override
public ComponentContainer constructBody() {
MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
Label nameLbl = new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":");
basicSearchBody.with(nameLbl).withAlign(nameLbl, Alignment.MIDDLE_LEFT);
nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT))
.withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
basicSearchBody.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER);
myItemCheckbox = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
basicSearchBody.with(myItemCheckbox).withAlign(myItemCheckbox, Alignment.MIDDLE_CENTER);
MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction())
.withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION)
.withClickShortcut(ShortcutAction.KeyCode.ENTER);
basicSearchBody.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_LEFT);
MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue(""))
.withStyleName(WebThemes.BUTTON_OPTION);
basicSearchBody.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER);
if (canSwitchToAdvanceLayout) {
MButton advancedSearchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH),
clickEvent -> moveToAdvancedSearchLayout()).withStyleName(WebThemes.BUTTON_LINK);
basicSearchBody.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER);
}
return basicSearchBody;
}
示例20
@Override
protected Component createContent(TextField usernameField, PasswordField passwordField, Button loginBtn) {
custom = CustomLayoutExt.createLayout("loginForm");
Resource logoResource = AccountAssetsResolver.createLogoResource(AppUI.getBillingAccount().getLogopath(), 150);
custom.addComponent(new Image(null, logoResource), "logo-here");
custom.addComponent(ELabel.h1(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.BUTTON_LOG_IN))
.withUndefinedWidth(), "form-header");
custom.addStyleName("customLoginForm");
custom.addComponent(usernameField, "usernameField");
custom.addComponent(passwordField, "passwordField");
rememberMe = new CheckBox(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.OPT_REMEMBER_PASSWORD),
false);
custom.addComponent(rememberMe, "rememberMe");
loginBtn.setStyleName(WebThemes.BUTTON_ACTION);
loginBtn.setClickShortcut(ShortcutAction.KeyCode.ENTER);
custom.addComponent(loginBtn, "loginButton");
MButton forgotPasswordBtn = new MButton(LocalizationHelper.getMessage(AppUI.getDefaultLocale(),
ShellI18nEnum.BUTTON_FORGOT_PASSWORD), clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoForgotPasswordPage(this, null)))
.withStyleName(WebThemes.BUTTON_LINK);
custom.addComponent(forgotPasswordBtn, "forgotLink");
custom.addComponent(ELabel.html(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.OPT_REMEMBER_PASSWORD,
ShellI18nEnum.OPT_SIGNIN_MYCOLLAB)), "newToUs");
custom.addComponent(ELabel.html(new A("https://www.mycollab.com/pricing/", "_blank").appendText
(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.ACTION_CREATE_ACCOUNT)).write())
.withUndefinedWidth(), "createAccountLink");
return custom;
}
示例21
private TableShortCutHandler(final VaadinMessageSource i18n) {
selectAllText = i18n.getMessage("action.target.table.selectall");
selectAllAction = new ShortcutAction(selectAllText, ShortcutAction.KeyCode.A,
new int[] { ShortCutModifierUtils.getCtrlOrMetaModifier() });
}
示例22
private void setupPrimaryButton() {
setStyleName("primary default");
setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
}
示例23
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);
}
}
示例24
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);
}
}
示例25
public NotificationSettingWindow(SimpleProjectMember projectMember) {
super(UserUIContext.getMessage(ProjectCommonI18nEnum.ACTION_EDIT_NOTIFICATION));
withModal(true).withResizable(false).withWidth("600px").withCenter();
ProjectNotificationSettingService prjNotificationSettingService = AppContextUtil.getSpringBean(ProjectNotificationSettingService.class);
ProjectNotificationSetting notification = prjNotificationSettingService.findNotification(projectMember.getUsername(), projectMember.getProjectid(),
projectMember.getSaccountid());
MVerticalLayout body = new MVerticalLayout();
final RadioButtonGroup<String> optionGroup = new RadioButtonGroup(null);
optionGroup.setItems(NotificationType.Default.name(), NotificationType.None.name(), NotificationType.Minimal.name(), NotificationType.Full.name());
optionGroup.setItemCaptionGenerator((ItemCaptionGenerator<String>) item -> {
if (item.equals(NotificationType.Default.name())) {
return UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_DEFAULT_SETTING);
} else if (item.equals(NotificationType.None.name())) {
return UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_NONE_SETTING);
} else if (item.equals(NotificationType.Minimal.name())) {
return UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_MINIMUM_SETTING);
} else if (item.equals(NotificationType.Full.name())) {
return UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_MAXIMUM_SETTING);
} else {
throw new MyCollabException("Not supported");
}
});
optionGroup.setWidth("100%");
body.with(optionGroup);
String levelVal = notification.getLevel();
if (levelVal == null) {
optionGroup.setValue(NotificationType.Default.name());
} else {
optionGroup.setValue(levelVal);
}
MButton closeBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLOSE), clickEvent -> close())
.withStyleName(WebThemes.BUTTON_OPTION);
MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> {
try {
notification.setLevel(optionGroup.getValue());
ProjectNotificationSettingService projectNotificationSettingService = AppContextUtil.getSpringBean(ProjectNotificationSettingService.class);
if (notification.getId() == null) {
projectNotificationSettingService.saveWithSession(notification, UserUIContext.getUsername());
} else {
projectNotificationSettingService.updateWithSession(notification, UserUIContext.getUsername());
}
NotificationUtil.showNotification(UserUIContext.getMessage(GenericI18Enum.OPT_CONGRATS),
UserUIContext.getMessage(ProjectSettingI18nEnum.DIALOG_UPDATE_SUCCESS));
close();
} catch (Exception e) {
throw new MyCollabException(e);
}
}).withStyleName(WebThemes.BUTTON_ACTION).withIcon(VaadinIcons.CLIPBOARD)
.withClickShortcut(ShortcutAction.KeyCode.ENTER);
MHorizontalLayout btnControls = new MHorizontalLayout(closeBtn, saveBtn);
body.with(btnControls).withAlign(btnControls, Alignment.TOP_RIGHT);
withContent(body);
}
示例26
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);
}
}
示例27
ForgotPwdForm() {
CustomLayout customLayout = CustomLayoutExt.createLayout("forgotPassword");
customLayout.setStyleName("forgotPwdForm");
Resource logoResource = AccountAssetsResolver.createLogoResource(AppUI.getBillingAccount().getLogopath(), 150);
customLayout.addComponent(new Image(null, logoResource), "logo-here");
customLayout.addComponent(new ELabel(LocalizationHelper.getMessage(AppUI.getDefaultLocale(),
ShellI18nEnum.BUTTON_FORGOT_PASSWORD)), "formHeader");
customLayout.addComponent(ELabel.html(LocalizationHelper.getMessage(AppUI.getDefaultLocale(),
ShellI18nEnum.OPT_FORGOT_PASSWORD_INTRO)), "intro-text");
nameOrEmailField = new TextField(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), GenericI18Enum.FORM_EMAIL));
customLayout.addComponent(nameOrEmailField, "nameoremail");
MButton sendEmail = new MButton(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.BUTTON_RESET_PASSWORD), clickEvent -> {
String username = nameOrEmailField.getValue();
if (StringUtils.isValidEmail(username)) {
UserService userService = AppContextUtil.getSpringBean(UserService.class);
User user = userService.findUserByUserName(username);
if (user == null) {
NotificationUtil.showErrorNotification(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), GenericI18Enum.ERROR_USER_IS_NOT_EXISTED, username));
} else {
userService.requestToResetPassword(user.getUsername());
NotificationUtil.showNotification(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), GenericI18Enum.OPT_SUCCESS),
LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.OPT_EMAIL_SENDER_NOTIFICATION));
EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null));
}
} else {
NotificationUtil.showErrorNotification(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ErrorI18nEnum.NOT_VALID_EMAIL, username));
}
}).withStyleName(WebThemes.BUTTON_ACTION).withClickShortcut(ShortcutAction.KeyCode.ENTER);
customLayout.addComponent(sendEmail, "loginButton");
MButton memoBackBtn = new MButton(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.BUTTON_IGNORE_RESET_PASSWORD),
clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null)))
.withStyleName(WebThemes.BUTTON_LINK);
customLayout.addComponent(memoBackBtn, "forgotLink");
this.setCompositionRoot(customLayout);
}
示例28
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");
}