List of usage examples for com.vaadin.ui Button setClickShortcut
public void setClickShortcut(int keyCode, int... modifiers)
From source file:com.cerebro.provevaadin.ChatOffGame.java
public ChatOffGame() { Panel messagesPanel = new Panel(); messagesPanel.setSizeFull();/*from w w w .jav a 2s . c o m*/ messagesPanel.setContent(messages); this.addComponent(messagesPanel); this.setExpandRatio(messagesPanel, 1.0f); HorizontalLayout sendBar = new HorizontalLayout(); sendBar.setWidth("100%"); final TextField input = new TextField(); input.setWidth("100%"); sendBar.addComponent(input); sendBar.setExpandRatio(input, 1.0f); Button send = new Button("Send"); send.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); send.addClickListener((Button.ClickEvent event) -> { BroadcasterOffGame.broadcast(input.getValue(), FROM); input.setValue(""); }); sendBar.addComponent(send); this.addComponent(sendBar); BroadcasterOffGame.register(this); }
From source file:com.cerebro.provevaadin.ChatOnGame.java
public ChatOnGame(User user) { if (user.getUltimoLuogoPG() != null) { logger.info("Luogo: " + user.getUltimoLuogoPG()); } else {/*from ww w. ja v a 2 s . c o m*/ logger.info("Nessun luogo selezionato"); } Panel messagesPanel = new Panel(); messagesPanel.setSizeFull(); messagesPanel.setContent(messages); this.addComponent(messagesPanel); this.setExpandRatio(messagesPanel, 1.0f); HorizontalLayout sendBar = new HorizontalLayout(); sendBar.setWidth("100%"); final TextField input = new TextField(); input.setWidth("100%"); sendBar.addComponent(input); sendBar.setExpandRatio(input, 1.0f); Button send = new Button("Send"); send.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); send.addClickListener((Button.ClickEvent event) -> { logger.info("Invio del messaggio al server"); BroadcasterOnGame.broadcast(input.getValue(), FROM); input.setValue(""); }); sendBar.addComponent(send); this.addComponent(sendBar); BroadcasterOnGame.register(this); }
From source file:com.cms.utils.ShortcutUtils.java
public static ShortcutAction setShortkeyCopy(Button button) { button.setClickShortcut(KeyCode.P, ModifierKey.ALT); return null; }
From source file:com.cms.utils.ShortcutUtils.java
public static ShortcutAction setShortkeyEdit(Button button) { button.setClickShortcut(ShortcutAction.KeyCode.ENTER, ModifierKey.ALT); return null;//from ww w. j a va 2 s . co m }
From source file:com.cms.utils.ShortcutUtils.java
public static ShortcutAction setShortkeyALT1(Button button) { button.setClickShortcut(ShortcutAction.KeyCode.NUM1, ModifierKey.ALT); return null;/*from w w w .j av a 2s .c om*/ }
From source file:com.haulmont.cuba.web.gui.components.WebComponentsHelper.java
License:Apache License
public static void setClickShortcut(Button button, String shortcut) { KeyCombination closeCombination = KeyCombination.create(shortcut); int[] closeModifiers = KeyCombination.Modifier.codes(closeCombination.getModifiers()); int closeCode = closeCombination.getKey().getCode(); button.setClickShortcut(closeCode, closeModifiers); }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private void addLinkUserContainer() { VerticalLayout cDeletePrompt = new VerticalLayout(); cPlaceholder.addComponent(cDeletePrompt); cPlaceholder.setComponentAlignment(cDeletePrompt, Alignment.MIDDLE_CENTER); // cDeletePrompt.setWidth("100%"); cDeletePrompt.setStyleName("c_link"); cDeletePrompt.setSpacing(true);/*from ww w . j a v a 2s.c o m*/ String username = curUser; Label lbActivationPrompt = new Label( "<span style='text-align: center;'>Please enter Child Username to link to " + username + "'s Account</span>"); lbActivationPrompt.setContentMode(ContentMode.HTML); lbActivationPrompt.setWidth("300px"); lbActivationPrompt.setStyleName("lb_link_user"); cDeletePrompt.addComponent(lbActivationPrompt); cDeletePrompt.setComponentAlignment(lbActivationPrompt, Alignment.TOP_LEFT); VerticalLayout frmDeleteReason = new VerticalLayout(); frmDeleteReason.setSizeUndefined(); frmDeleteReason.setSpacing(true); frmDeleteReason.setMargin(true); cDeletePrompt.addComponent(frmDeleteReason); cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.TOP_CENTER); tFU = new TextField("Child Username"); tFU.setRequired(true); final ComboBox comboUProf = new ComboBox("Select Profile"); comboUProf.setNullSelectionAllowed(false); comboUProf.setRequired(true); comboUProf.addItem(8); comboUProf.setItemCaption(8, "DEPOSIT_ONLY"); comboUProf.addItem(9); comboUProf.setItemCaption(9, "DEPOSIT_AND_WITHDRAWAL"); comboUProf.select(8); final TextField tFP = new TextField("Parent Account ID"); tFP.setValue(username); tFP.setEnabled(false); final TextField tFInitUser = new TextField("Initiating User"); tFInitUser.setValue(UI.getCurrent().getSession().getAttribute("user").toString()); tFInitUser.focus(); tFInitUser.setEnabled(false); frmDeleteReason.addComponent(tFU); frmDeleteReason.addComponent(comboUProf); frmDeleteReason.addComponent(tFP); frmDeleteReason.addComponent(tFInitUser); HorizontalLayout cPopupBtns = new HorizontalLayout(); cPopupBtns.setSizeUndefined(); cPopupBtns.setSpacing(true); final Button btnCancel = new Button(); btnCancel.setIcon(FontAwesome.UNDO); btnCancel.setStyleName("btn_link"); btnCancel.setDescription("Cancel"); final Button btnSet = new Button("Link"); btnSet.setDescription("Link specified account."); btnSet.setIcon(FontAwesome.LINK); cPopupBtns.addComponent(btnSet); cPopupBtns.addComponent(btnCancel); frmDeleteReason.addComponent(cPopupBtns); cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.MIDDLE_CENTER); btnSet.setClickShortcut(KeyCode.ENTER, null); btnSet.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -6318666715385643538L; @Override public void buttonClick(ClickEvent event) { tFU.validate(); btnSet.setEnabled(false); btnCancel.setEnabled(false); Button btn = event.getButton(); if (ums == null) ums = new UserManagementService(); btn.setEnabled(false); String strResponse = null; try { strResponse = UserManagementService.linkUser(tFP.getValue(), new Integer(comboUProf.getValue().toString()), tFInitUser.getValue(), tFU.getValue()); if (strResponse.equals("The operation was successful and completed")) { updateLinksTable(tFU.getValue()); cPlaceholder.setVisible(false); tFU.setValue(""); btnLink.setVisible(true); NotifCustom.show("Link", strResponse); } else { NotifCustom.show("Link", strResponse); } } catch (RemoteException e) { e.printStackTrace(); } btnSet.setEnabled(true); btnCancel.setEnabled(true); } }); btnCancel.addClickListener(new ClickListener() { private static final long serialVersionUID = 7161821652386306043L; @Override public void buttonClick(ClickEvent event) { btnLink.setVisible(true); cPlaceholder.setVisible(false); } }); }
From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java
public GroupView() { User user = UserUtils.getCurrent();//w w w . j a va 2 s . c om 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); }
From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java
public VerticalLayout createTab(Group g) { User u = UserUtils.getCurrent();//from ww w. ja va 2 s.c om VerticalLayout groupSettingsLayout = new VerticalLayout(); groupSettingsLayouts.put(g, groupSettingsLayout); GridLayout tabContent; TextField textFieldName = new TextField(); if (GroupUtils.isAdmin(g, u)) { tabContent = new GridLayout(3, 2); Language.set(Word.NAME, textFieldName); textFieldName.setWidth("100%"); textFieldName.setValue(g.getName()); textFieldName.setMaxLength(255); tabContent.addComponent(textFieldName); tabContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT); } else { tabContent = new GridLayout(3, 1); } buttonLeave = new Button(); Language.set(Word.LEAVE, buttonLeave); buttonLeave.setIcon(VaadinIcons.MINUS); buttonLeave.addStyleName(ValoTheme.BUTTON_DANGER); buttonLeave.addClickListener(ce -> { ConfirmationDialog.show(Language.get(Word.REALLY_LEAVE_GROUP).replace("[GROUP]", g.getName()), () -> { long amountAdmins = g.getUsers().entrySet().stream().filter(e -> e.getValue()).count(); if (amountAdmins > 1 || !GroupUtils.isAdmin(g, u)) { GroupUtils.removeUser(g, u); refreshAll(g); } else { VaadinUtils.errorNotification(Language.get(Word.NOT_ENOUGH_ADMINS_IN_GROUP)); } }); }); buttonDelete = new Button(); Language.set(Word.DELETE, buttonDelete); buttonDelete.setIcon(VaadinIcons.TRASH); buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER); buttonDelete.addClickListener(ce -> { ConfirmationDialog.show(Language.get(Word.REALLY_DELETE_GROUP).replace("[GROUP]", g.getName()), () -> { GroupUtils.removeGroup(g); refreshAll(g); }); }); Button buttonSave = new Button(); Language.set(Word.SAVE, buttonSave); buttonSave.setIcon(VaadinIcons.CHECK); buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonSave.addClickListener(ce -> { if (GroupUtils.isAdmin(g, u)) { GroupUtils.changeName(g, textFieldName.getValue()); accordion.getTab(groupSettingsLayout).setCaption(textFieldName.getValue()); } VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED)); }); buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); Label placeholder = new Label(); Label placeholder2 = new Label(); placeholder2.setWidth("100%"); Label placeholder3 = new Label(); GridLayout footer = new GridLayout(4, 1); footer.setSpacing(true); footer.setMargin(new MarginInfo(false, true)); footer.setSizeUndefined(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth("100%"); footer.addStyleName("menubar"); if (GroupUtils.isAdmin(g, u)) { footer.addComponents(placeholder, buttonDelete, buttonLeave, buttonSave); footer.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER); } else { footer.addComponents(placeholder, placeholder3, buttonLeave, buttonSave); } footer.setColumnExpandRatio(0, 5); footer.setComponentAlignment(buttonLeave, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER); if (GroupUtils.isAdmin(g, u)) { tabContent.addComponent(getProfiles(g), 0, 1, 1, 1); tabContent.addComponent(getMembers(g), 2, 1); } else { tabContent.addComponent(getProfiles(g), 0, 0, 1, 0); tabContent.addComponent(getMembers(g), 2, 0); } tabContent.setWidth("100%"); tabContent.setSpacing(true); tabContent.setMargin(true); tabContent.addStyleName("profiles"); groupSettingsLayout.addComponents(tabContent, footer); groupSettingsLayout.setMargin(false); groupSettingsLayout.setSpacing(false); groupSettingsLayout.setWidth("100%"); return groupSettingsLayout; }
From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java
public InterestProfileView() { User user = UserUtils.getCurrent();/* w ww.ja v a 2s .co m*/ Set<InterestProfile> profiles = UserUtils.getAllInterestProfiles(user); CssLayout newProfileGroup = new CssLayout(); newProfileGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); TextField textFieldNewProfileName = new TextField(); Language.setCustom(Word.PROFILE_NAME, s -> textFieldNewProfileName.setPlaceholder(s)); textFieldNewProfileName.setWidth("260px"); textFieldNewProfileName.setMaxLength(255); newProfileGroup.addComponent(textFieldNewProfileName); Button buttonNewProfile = new Button(); buttonNewProfile.setIcon(VaadinIcons.PLUS); buttonNewProfile.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonNewProfile.addClickListener(e -> { Tab newTab = accordion.addTab(createTab(createEmptyProfile(textFieldNewProfileName.getValue())), textFieldNewProfileName.getValue()); accordion.setSelectedTab(newTab); accordion.setWidth("100%"); textFieldNewProfileName.clear(); }); newProfileGroup.addComponent(buttonNewProfile); textFieldNewProfileName .addFocusListener(f -> buttonNewProfile.setClickShortcut(ShortcutAction.KeyCode.ENTER, null)); textFieldNewProfileName.addBlurListener(f -> buttonNewProfile.removeClickShortcut()); profiles.forEach((InterestProfile profile) -> { accordion.addTab(createTab(profile), profile.getName()); }); addComponents(newProfileGroup, accordion); SESSIONS.put(user, this); }