List of usage examples for com.vaadin.event ShortcutAction ShortcutAction
public ShortcutAction(String caption, int kc, int... m)
From source file:com.klwork.explorer.ui.user.ChangePasswordPopupWindow.java
License:Apache License
protected void initEnterKeyListener() { addActionHandler(new Handler() { public void handleAction(Action action, Object sender, Object target) { handlePasswordChange();/* w w w . jav a 2 s . c o m*/ } public Action[] getActions(Object target, Object sender) { return new Action[] { new ShortcutAction("enter", ShortcutAction.KeyCode.ENTER, null) }; } }); }
From source file:com.ocs.dynamo.ui.composite.form.AbstractModelBasedSearchForm.java
License:Apache License
@Override public void build() { VerticalLayout main = new DefaultVerticalLayout(false, true); // add a wrapper for adding an action handler wrapperPanel = new Panel(); main.addComponent(wrapperPanel);/* w w w . j av a 2s . co m*/ // create the search form filterLayout = constructFilterLayout(); wrapperPanel.setContent(filterLayout); // action handler for carrying out a search after an Enter press wrapperPanel.addActionHandler(new Handler() { private static final long serialVersionUID = -2136828212405809213L; private Action enter = new ShortcutAction(null, ShortcutAction.KeyCode.ENTER, null); @Override public Action[] getActions(Object target, Object sender) { return new Action[] { enter }; } @Override public void handleAction(Action action, Object sender, Object target) { if (action == enter) { search(); } } }); // create the button bar HorizontalLayout buttonBar = new DefaultHorizontalLayout(); main.addComponent(buttonBar); constructButtonBar(buttonBar); // add custom buttons postProcessButtonBar(buttonBar); // add any custom functionality postProcessLayout(); // initial search // search(); setCompositionRoot(main); }
From source file:it.vige.greenarea.bpm.custom.ui.LoginPanel.java
License:Apache License
private void addInputField() { VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true);/*from ww w . j av a2 s .c om*/ layout.setWidth(100, UNITS_PERCENTAGE); loginPanel.addComponent(layout); Panel textFieldPanel = new Panel(); // Hack: actionHandlers can only be // attached to panels or windows textFieldPanel.addStyleName(PANEL_LIGHT); textFieldPanel.setContent(new VerticalLayout()); textFieldPanel.setWidth(100, UNITS_PERCENTAGE); layout.addComponent(textFieldPanel); layout.setExpandRatio(textFieldPanel, 1.0f); Label labelUserName = new Label(i18nManager.getMessage(USER_NAME_TITLE)); labelUserName.addStyleName(LABEL_SMALL); userNameInputField = new TextField(); userNameInputField.setWidth(100, UNITS_PERCENTAGE); Label labelPassword = new Label(i18nManager.getMessage(PASSWORD_TITLE)); labelPassword.addStyleName(LABEL_SMALL); passwordInputField = new PasswordField(); passwordInputField.setWidth(100, UNITS_PERCENTAGE); textFieldPanel.addComponent(labelUserName); textFieldPanel.addComponent(userNameInputField); textFieldPanel.addComponent(labelPassword); textFieldPanel.addComponent(passwordInputField); // Hack to catch keyboard 'enter' textFieldPanel.addActionHandler(new Handler() { private static final long serialVersionUID = 6928598745792215505L; public void handleAction(Action action, Object sender, Object target) { login(userNameInputField.getValue().toString(), passwordInputField.getValue().toString()); } public Action[] getActions(Object target, Object sender) { return new Action[] { new ShortcutAction("enter", ENTER, null) }; } }); Button loginButton = new Button(i18nManager.getMessage(LOGIN)); layout.addComponent(loginButton); layout.setComponentAlignment(loginButton, MIDDLE_LEFT); loginButton.addListener(new ClickListener() { private static final long serialVersionUID = 7781253151592188006L; public void buttonClick(ClickEvent event) { login(userNameInputField.getValue().toString(), passwordInputField.getValue().toString()); } }); }
From source file:org.activiti.explorer.ui.custom.TaskListHeader.java
License:Apache License
protected void initKeyboardListener() { addActionHandler(new Handler() { public void handleAction(Action action, Object sender, Object target) { if (inputField.getValue() != null && !"".equals(inputField.getValue().toString())) { // Create task Task task = taskService.newTask(); task.setName(inputField.getValue().toString()); task.setOwner(ExplorerApp.get().getLoggedInUser().getId()); taskService.saveTask(task); // Switch to the new task ExplorerApp.get().getViewManager().showTasksPage(task.getId()); }/* w w w .j a v a2 s . com*/ } public Action[] getActions(Object target, Object sender) { return new Action[] { new ShortcutAction("enter", ShortcutAction.KeyCode.ENTER, null) }; } }); }
From source file:org.activiti.explorer.ui.task.SubTaskComponent.java
License:Apache License
protected void initAddSubTaskPanelKeyboardActions() { addSubTaskPanel.addActionHandler(new Handler() { public void handleAction(Action action, Object sender, Object target) { if ("escape".equals(action.getCaption())) { resetAddButton();//from w w w.j a v a 2 s . com } else if ("enter".equals(action.getCaption())) { if (newTaskTextField != null && newTaskTextField.getValue() != null && !"".equals(newTaskTextField.getValue().toString())) { LoggedInUser loggedInUser = ExplorerApp.get().getLoggedInUser(); // save task Task newTask = taskService.newTask(); newTask.setParentTaskId(parentTask.getId()); if (parentTask.getAssignee() != null) { newTask.setAssignee(parentTask.getAssignee()); } else { newTask.setAssignee(loggedInUser.getId()); } if (parentTask.getOwner() != null) { newTask.setOwner(parentTask.getOwner()); } else { newTask.setOwner(loggedInUser.getId()); } newTask.setName(newTaskTextField.getValue().toString()); taskService.saveTask(newTask); // Reset the add button to its original state resetAddButton(); // refresh sub tasks section refreshSubTasks(); } } } public Action[] getActions(Object target, Object sender) { return new Action[] { new ShortcutAction("enter", ShortcutAction.KeyCode.ENTER, null), new ShortcutAction("escape", ShortcutAction.KeyCode.ESCAPE, null) }; } }); }
From source file:org.activiti.explorer.ui.task.TaskEventsPanel.java
License:Apache License
protected void addInputField() { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true);/*from ww w . j a v a 2 s. c o m*/ layout.setWidth(100, UNITS_PERCENTAGE); addComponent(layout); Panel textFieldPanel = new Panel(); // Hack: actionHandlers can only be attached to panels or windows textFieldPanel.addStyleName(Reindeer.PANEL_LIGHT); textFieldPanel.setContent(new VerticalLayout()); textFieldPanel.setWidth(100, UNITS_PERCENTAGE); layout.addComponent(textFieldPanel); layout.setExpandRatio(textFieldPanel, 1.0f); commentInputField = new TextField(); commentInputField.setWidth(100, UNITS_PERCENTAGE); textFieldPanel.addComponent(commentInputField); // Hack to catch keyboard 'enter' textFieldPanel.addActionHandler(new Handler() { public void handleAction(Action action, Object sender, Object target) { addNewComment(commentInputField.getValue().toString()); } public Action[] getActions(Object target, Object sender) { return new Action[] { new ShortcutAction("enter", ShortcutAction.KeyCode.ENTER, null) }; } }); Button addCommentButton = new Button(i18nManager.getMessage(Messages.TASK_ADD_COMMENT)); layout.addComponent(addCommentButton); layout.setComponentAlignment(addCommentButton, Alignment.MIDDLE_LEFT); addCommentButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { addNewComment(commentInputField.getValue().toString()); } }); }
From source file:org.escidoc.browser.elabsmodul.views.AddNewEndpointURIWindow.java
License:Open Source License
@SuppressWarnings("serial") private Component buildGUI() { final VerticalLayout rootLayout = new VerticalLayout(); final HorizontalLayout inputLayout = new HorizontalLayout(); inputLayout.setSpacing(true);// w ww . ja v a2 s. co m endpointURITextField = new TextField(); endpointURITextField.setEnabled(true); endpointURITextField.setVisible(true); endpointURITextField.setNullRepresentation(""); endpointURITextField.setValue("http://"); endpointURITextField.setImmediate(true); endpointURITextField.setRequired(true); endpointURITextField.setRequiredError("URI cannot be empty!"); endpointURITextField.setWidth("350px"); endpointURITextField.focus(); if (isEsyncURI) { inputLayout.addComponent(new Label("New eSync-endpoint URI:"), 0); } else { inputLayout.addComponent(new Label("New deposit-endpoint URI:"), 0); } inputLayout.addComponent(endpointURITextField, 1); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); okButton = new Button(OK_BUTTON_TEXT, this); okButton.setIcon(ELabsViewContants.ICON_16_OK); okButton.setEnabled(true); cancelButton = new Button(CANCEL_BUTTON_TEXT, this); cancelButton.setIcon(ELabsViewContants.ICON_16_CANCEL); buttonLayout.addComponent(cancelButton); buttonLayout.addComponent(okButton); rootLayout.addComponent(inputLayout); rootLayout.addComponent(buttonLayout); Panel panel = new Panel(); panel.setContent(rootLayout); panel.addActionHandler(new Action.Handler() { private final Action action_ok = new ShortcutAction("Enter key", ShortcutAction.KeyCode.ENTER, null); private final Action action_esc = new ShortcutAction("Escape key", ShortcutAction.KeyCode.ESCAPE, null); @Override public void handleAction(Action action, Object sender, Object target) { if (action.equals(action_ok)) { AddNewEndpointURIWindow.this.closeMe(true); } else if (action.equals(action_esc)) { AddNewEndpointURIWindow.this.closeMe(false); } } @Override public Action[] getActions(Object target, Object sender) { return new Action[] { action_ok, action_esc }; } }); return panel; }
From source file:org.escidoc.browser.elabsmodul.views.AddNewStudyPublicationWindow.java
License:Open Source License
@SuppressWarnings("serial") private Component buildGUI() { final VerticalLayout rootLayout = new VerticalLayout(); final HorizontalLayout inputLayout = new HorizontalLayout(); inputLayout.setSpacing(true);/* w w w . j a v a 2 s. c o m*/ publicationTextField = new TextField(); publicationTextField.setEnabled(true); publicationTextField.setVisible(true); publicationTextField.setNullRepresentation(""); publicationTextField.setValue("http://"); publicationTextField.setImmediate(true); publicationTextField.setRequired(true); publicationTextField.setRequiredError("Document URL cannot be empty!"); publicationTextField.setWidth("350px"); publicationTextField.focus(); if (isMotPub) { inputLayout.addComponent(new Label("New motivating publication's URL:"), 0); } else { inputLayout.addComponent(new Label("New resulting publication's URL:"), 0); } inputLayout.addComponent(publicationTextField, 1); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); okButton = new Button(OK_BUTTON_TEXT, this); okButton.setIcon(ELabsViewContants.ICON_16_OK); okButton.setEnabled(true); cancelButton = new Button(CANCEL_BUTTON_TEXT, this); cancelButton.setIcon(ELabsViewContants.ICON_16_CANCEL); buttonLayout.addComponent(cancelButton); buttonLayout.addComponent(okButton); rootLayout.addComponent(inputLayout); rootLayout.addComponent(buttonLayout); Panel panel = new Panel(); panel.setContent(rootLayout); panel.addActionHandler(new Action.Handler() { private final Action action_ok = new ShortcutAction("Enter key", ShortcutAction.KeyCode.ENTER, null); private final Action action_esc = new ShortcutAction("Escape key", ShortcutAction.KeyCode.ESCAPE, null); @Override public void handleAction(Action action, Object sender, Object target) { if (action.equals(action_ok)) { AddNewStudyPublicationWindow.this.closeMe(true); } else if (action.equals(action_esc)) { AddNewStudyPublicationWindow.this.closeMe(false); } } @Override public Action[] getActions(Object target, Object sender) { return new Action[] { action_ok, action_esc }; } }); return panel; }
From source file:org.milleni.dunning.ui.customer.CustomerSearchPanel.java
License:Apache License
protected void initKeyboardListener() { addActionHandler(new Handler() { public void handleAction(Action action, Object sender, Object target) { CustomerListLazyLoadinQuery query = new CustomerListLazyLoadinQuery(); /*/*from w w w. j ava2 s.co m*/ if(txtCustomerId!=null ){ try { Long customerId = Long.parseLong(txtCustomerId.getValue().toString()); } catch (Exception e) { customer.setCustomerId(null); txtCustomerId.setValue(""); } //customer.setCustomerId(Long.parseLong(txtCustomerId.getValue().toString())); }*/ if (ExplorerApp.get().getLoggedInUser().isLimited() && org.h2.util.StringUtils.isNullOrEmpty((String) txtCustomerId.getValue())) { notificationManager.showErrorNotification("error", i18nManager.getMessage(Messages.CUSTOMER_SEARCH_NOT_NULL)); } else { if (customer != null) query.setCustomer(customer); //customer.setCustomerType(new CustomerType(1l)); customerPage.setDetailComponent(query); } } public Action[] getActions(Object target, Object sender) { return new Action[] { new ShortcutAction("enter", ShortcutAction.KeyCode.ENTER, null) }; } }); }
From source file:org.milleni.dunning.ui.dpdetail.DunningProcessDetailSearchPanel.java
License:Apache License
protected void initKeyboardListener() { addActionHandler(new Handler() { public void handleAction(Action action, Object sender, Object target) { DunningProcessDetailListLazyLoadinQuery query = new DunningProcessDetailListLazyLoadinQuery(); dpDetail.setProcessId(dpMaster); if (dpDetail != null) { query.setDpDetail(dpDetail); }//from w ww. ja va2s . c o m if (stepCreateDate.getValue() != null) query.getCriteriaMap().put("stepCreateDate", (Date) stepCreateDate.getValue()); if (stepCreateDateEnd.getValue() != null) query.getCriteriaMap().put("stepCreateDateEnd", (Date) stepCreateDateEnd.getValue()); if (statusChangeDate.getValue() != null) query.getCriteriaMap().put("statusChangeDate", (Date) statusChangeDate.getValue()); if (statusChangeDateEnd.getValue() != null) query.getCriteriaMap().put("statusChangeDateEnd", (Date) statusChangeDateEnd.getValue()); dunningProcessPage.setDetailComponent(query); } public Action[] getActions(Object target, Object sender) { return new Action[] { new ShortcutAction("enter", ShortcutAction.KeyCode.ENTER, null) }; } }); }