當前位置: 首頁>>代碼示例>>Java>>正文


Java ShortcutAction類代碼示例

本文整理匯總了Java中com.vaadin.event.ShortcutAction的典型用法代碼示例。如果您正苦於以下問題:Java ShortcutAction類的具體用法?Java ShortcutAction怎麽用?Java ShortcutAction使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ShortcutAction類屬於com.vaadin.event包,在下文中一共展示了ShortcutAction類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testButton

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
@Test
public void testButton() {
    FButton button = new FButton().withCaption("My button")
                                  .withIcon(VaadinIcons.ARROW_BACKWARD)
                                  .withIconAlternateText("backward")
                                  .withClickListener(click -> System.out.println("clicked"))
                                  .withClickShortcut(ShortcutAction.KeyCode.ENTER, null)
                                  .withBlurListener(blur -> System.out.println("lost focus"))
                                  .withFocusListener(focus -> System.out.println("gain focus"))
                                  .withTabIndex(5)
                                  .withDisableOnClick(true);

    assertEquals("My button", button.getCaption());
    assertEquals(VaadinIcons.ARROW_BACKWARD, button.getIcon());
    assertEquals("backward", button.getIconAlternateText());
    assertEquals(5, button.getTabIndex());
    assertEquals(1, button.getListeners(ClickEvent.class).size());
    assertEquals(1, button.getListeners(FocusEvent.class).size());
    assertEquals(1, button.getListeners(BlurEvent.class).size());
    assertTrue(button.getClickShortcut() != null);
    assertTrue(button.isDisableOnClick());

}
 
開發者ID:viydaag,項目名稱:vaadin-fluent-api,代碼行數:24,代碼來源:FButtonTest.java

示例2: testNativeButton

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
@Test
public void testNativeButton() {
    FNativeButton button = new FNativeButton().withCaption("My button")
                                              .withIcon(VaadinIcons.ARROW_BACKWARD)
                                              .withIconAlternateText("backward")
                                              .withClickListener(click -> System.out.println("clicked"))
                                              .withClickShortcut(ShortcutAction.KeyCode.ENTER, null)
                                              .withBlurListener(blur -> System.out.println("lost focus"))
                                              .withFocusListener(focus -> System.out.println("gain focus"))
                                              .withTabIndex(5)
                                              .withDisableOnClick(true);

    assertEquals("My button", button.getCaption());
    assertEquals(VaadinIcons.ARROW_BACKWARD, button.getIcon());
    assertEquals("backward", button.getIconAlternateText());
    assertEquals(5, button.getTabIndex());
    assertEquals(1, button.getListeners(ClickEvent.class).size());
    assertEquals(1, button.getListeners(FocusEvent.class).size());
    assertEquals(1, button.getListeners(BlurEvent.class).size());
    assertTrue(button.isDisableOnClick());

}
 
開發者ID:viydaag,項目名稱:vaadin-fluent-api,代碼行數:23,代碼來源:FButtonTest.java

示例3: init

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
@PostConstruct
    void init() {
        addComponent(spacer);
        spacer.setHeight("5em");
        addComponent(warning);
        warning.setSizeUndefined();
//        setComponentAlignment(warning, Alignment.MIDDLE_CENTER);

        HorizontalLayout horizontalLayout = new HorizontalLayout();
        horizontalLayout.setSpacing(true);
        horizontalLayout.setMargin(true);

        horizontalLayout.addComponent(goToTillReport);
        goToTillReport.focus();
        goToTillReport.setClickShortcut(ShortcutAction.KeyCode.ENTER);
        goToTillReport.addStyleName(ValoTheme.BUTTON_PRIMARY);
        goToTillReport.addClickListener((Button.ClickListener) clickEvent -> navigateTo(CloseOutTillView.VIEW_NAME));
        horizontalLayout.addComponent(logout);
        logout.addClickListener((Button.ClickListener) clickEvent -> handler.logout(this));
        addComponent(horizontalLayout);
//        setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER);
    }
 
開發者ID:kumoregdev,項目名稱:kumoreg,代碼行數:23,代碼來源:LogoutView.java

示例4: init

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
@PostConstruct
    void init() {
        FormLayout formLayout = new FormLayout();
        formLayout.addComponent(usernameField);
        formLayout.addComponent(passwordField);
        formLayout.addComponent(loginButton);
        formLayout.setWidth(null);
        addComponent(formLayout);

        loginButton.setClickShortcut( ShortcutAction.KeyCode.ENTER ) ;
        loginButton.addClickListener((Button.ClickListener) clickEvent -> {
            if (usernameField.isEmpty()) {
                Notification.show("Username is required");
                usernameField.focus();
            } else if (passwordField.isEmpty()) {
                Notification.show("Password is required");
                passwordField.focus();
            } else {
                handler.login(this, usernameField.getValue(), passwordField.getValue());
            }
        });
        usernameField.focus();

//        setComponentAlignment(formLayout, Alignment.MIDDLE_CENTER);
    }
 
開發者ID:kumoregdev,項目名稱:kumoreg,代碼行數:26,代碼來源:LoginView.java

示例5: AttendeeDetailWindow

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
public AttendeeDetailWindow(AttendeePrintView parentView, AttendeeSearchPresenter handler) {
    super("Attendee Detail");
    this.handler = handler;
    this.parentView = parentView;
    setIcon(FontAwesome.USER);
    center();
    setModal(true);
    setWidth(1100, Unit.PIXELS);
    setHeight(800, Unit.PIXELS);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(false);
    verticalLayout.setSpacing(true);
    form = new AttendeeDetailForm(this);
    form.setAllFieldsButCheckInDisabled();
    verticalLayout.addComponent(form);
    verticalLayout.addComponent(buildSaveCancel());
    setContent(verticalLayout);

    btnSave.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    btnSave.addStyleName(ValoTheme.BUTTON_PRIMARY);
}
 
開發者ID:kumoregdev,項目名稱:kumoreg,代碼行數:23,代碼來源:AttendeeDetailWindow.java

示例6: WarningWindow

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
public WarningWindow(String message) {
    super("Warning");

    setIcon(FontAwesome.WARNING);
    setModal(true);
    center();

    lblMessage.setValue(message);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(true);
    verticalLayout.setSpacing(true);
    verticalLayout.addComponent(lblMessage);

    verticalLayout.addComponent(btnOk);
    btnOk.focus();
    btnOk.addClickListener((Button.ClickListener) clickEvent -> this.close());
    setContent(verticalLayout);

    btnOk.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    btnOk.addStyleName(ValoTheme.BUTTON_DANGER);
}
 
開發者ID:kumoregdev,項目名稱:kumoreg,代碼行數:23,代碼來源:WarningWindow.java

示例7: CustomerEditor

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
@Autowired
public CustomerEditor(CustomerRepository repository) {
	this.repository = repository;

	addComponents(firstName, lastName, actions);

	// Configure and style components
	setSpacing(true);
	actions.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
	save.setStyleName(ValoTheme.BUTTON_PRIMARY);
	save.setClickShortcut(ShortcutAction.KeyCode.ENTER);

	// wire action buttons to save, delete and reset
	save.addClickListener(e -> repository.save(customer));
	delete.addClickListener(e -> repository.delete(customer));
	cancel.addClickListener(e -> editCustomer(customer));
	setVisible(false);
}
 
開發者ID:tortuvshin,項目名稱:restaurant-web,代碼行數:19,代碼來源:CustomerEditor.java

示例8: postInit

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
@PostConstruct
private void postInit() {
    addStyleName("product-form-wrapper");
    addStyleName("product-form");
    titleLabel = new Label("Title - Author");
    titleLabel.addStyleName(ValoTheme.LABEL_COLORED);
    titleLabel.addStyleName(ValoTheme.LABEL_BOLD);
    descriptionLabel = new Label("Description", ContentMode.HTML);
    descriptionLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    descriptionLabel.setValue("Keine Beschreibung vorhanden");
    
    cancelButton = new Button("close", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            setLayoutVisible(false);
        }
    });
    cancelButton.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
    cancelButton.addStyleName(ValoTheme.BUTTON_DANGER);
    
    VerticalLayout rootLayout = new VerticalLayout(titleLabel,createImageLayout(),descriptionLabel,cancelButton);
    rootLayout.setSpacing(true);
    addComponent(rootLayout);
}
 
開發者ID:felixhusse,項目名稱:bookery,代碼行數:26,代碼來源:BookDetailLayout.java

示例9: postInit

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
@PostConstruct
private void postInit() {
    addStyleName("bookery-menu-wrapper");
    addStyleName("bookery-menu");
    Label titleLabel = new Label("Bookery Menu");
    titleLabel.addStyleName(ValoTheme.LABEL_COLORED);
    titleLabel.addStyleName(ValoTheme.LABEL_BOLD);
    
    
    Button cancelButton = new Button("close", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            setLayoutVisible(false);
        }
    });
    cancelButton.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
    cancelButton.addStyleName(ValoTheme.BUTTON_DANGER);
    
    
    VerticalLayout rootLayout = new VerticalLayout(titleLabel,cancelButton);
    rootLayout.setSpacing(true);
    addComponent(rootLayout);   
}
 
開發者ID:felixhusse,項目名稱:bookery,代碼行數:25,代碼來源:BookMenuLayout.java

示例10: modifyLabel

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
private void modifyLabel(final LabelClickEvent event) {
    final Window window = createWindow(event, "Modify label value");
    VerticalLayout layout = createWindowLayout(window);

    Label info = new Label("Note: Normally you would use this in case of more complex edit functionality.");
    info.addStyleName(ValoTheme.LABEL_SMALL);
    info.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(info);

    final TextField textField = new TextField("Label value");
    textField.setWidth(100, Unit.PERCENTAGE);
    textField.setValue(event.getLabel().getValue());
    layout.addComponent(textField);

    Button okButton = new Button("Apply", e -> {
        event.getLabel().setValue(textField.getValue());
        window.close();
    });
    okButton.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    layout.addComponent(okButton);
    layout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT);

    getUI().addWindow(window);
    textField.focus();
}
 
開發者ID:alump,項目名稱:LabelButton,代碼行數:26,代碼來源:DemoUI.java

示例11: createSearchField

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
private TextField createSearchField() {
TextField textFieldSearch = new TextField();
      textFieldSearch.setWidth("30ex");
      textFieldSearch.addShortcutListener(new ShortcutListener("Search", ShortcutAction.KeyCode.ENTER, null) {
	private static final long serialVersionUID = 1L;

	@Override
	public void handleAction(Object sender, Object target) {
		if (target == textFieldSearch) {
			String query = textFieldSearch.getValue();
			Page page = Application.getInstance().createSearchPage(query);
			show(page);
		}
	}
});
      
      return textFieldSearch;
  }
 
開發者ID:BrunoEberhard,項目名稱:minimal-j,代碼行數:19,代碼來源:Vaadin.java

示例12: VaadinTextAreaField

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
public VaadinTextAreaField(InputComponentListener changeListener, int maxLength, String allowedCharacters) {
	setMaxLength(maxLength);
	if (changeListener != null) {
		addValueChangeListener(event -> changeListener.changed(VaadinTextAreaField.this));
		addShortcutListener(new ShortcutListener("Commit", ShortcutAction.KeyCode.ENTER, null) {
			private static final long serialVersionUID = 1L;

			@Override
			public void handleAction(Object sender, Object target) {
				if (target == VaadinTextAreaField.this) {
					if (commitListener != null) {
						commitListener.run();
					}
				}
			}
		});
	} else {
		setReadOnly(true);
	}
}
 
開發者ID:BrunoEberhard,項目名稱:minimal-j,代碼行數:21,代碼來源:VaadinTextAreaField.java

示例13: show

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
public void show() {

        buttonBar.removeAllComponents();

        // initialize buttons depending on null selection option
        // should be moved somewhere else, but it cannot be done during initialization
        if (field.isNullSelectionEnabled()) {
            buttonBar.addComponents(spacer, btnSelect, btnSelectNone, btnCancel);
            btnSelectNone.setClickShortcut(ShortcutAction.KeyCode.ENTER,
                    ShortcutAction.ModifierKey.SHIFT);
        } else {
            buttonBar.addComponents(spacer, btnSelect, btnCancel);
        }

        buttonBar.setStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
        buttonBar.setWidth("100%");
        buttonBar.setSpacing(true);
        buttonBar.setExpandRatio(spacer, 1);

        field.getZoomDialog().show(this.field.getValue());
        UI.getCurrent().addWindow(this);
        center();
        focus();
    }
 
開發者ID:tyl,項目名稱:field-binder,代碼行數:25,代碼來源:ZoomWindow.java

示例14: DrillDownWindow

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
public DrillDownWindow(ZoomField<T> field) {
    super(field.getCaption());

    makeLayout(field);

    setContent(rootLayout);

    //FIXME these values should not be hardcoded
    setWidth("1200px");
    setHeight("400px");

    this.field = field;

    btnClose.addClickListener(this);
    btnClose.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
    btnClose.setClickShortcut(ShortcutAction.KeyCode.ENTER);
}
 
開發者ID:tyl,項目名稱:field-binder,代碼行數:18,代碼來源:DrillDownWindow.java

示例15: constructBody

import com.vaadin.event.ShortcutAction; //導入依賴的package包/類
@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().withInputPrompt(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(FontAwesome.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;
}
 
開發者ID:MyCollab,項目名稱:mycollab,代碼行數:20,代碼來源:ProjectRoleSearchPanel.java


注:本文中的com.vaadin.event.ShortcutAction類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。