当前位置: 首页>>代码示例>>Java>>正文


Java TextField.addShortcutListener方法代码示例

本文整理汇总了Java中com.vaadin.ui.TextField.addShortcutListener方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.addShortcutListener方法的具体用法?Java TextField.addShortcutListener怎么用?Java TextField.addShortcutListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vaadin.ui.TextField的用法示例。


在下文中一共展示了TextField.addShortcutListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSearchField

import com.vaadin.ui.TextField; //导入方法依赖的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

示例2: WebFtsField

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
public WebFtsField() {
    component = new CssLayout();
    component.setPrimaryStyleName(FTS_FIELD_STYLENAME);

    ComponentsFactory cf = AppBeans.get(ComponentsFactory.NAME);
    com.haulmont.cuba.gui.components.TextField searchFieldComponent =
            cf.createComponent(com.haulmont.cuba.gui.components.TextField.class);
    searchField = (TextField) WebComponentsHelper.unwrap(searchFieldComponent);
    searchField.setStyleName("c-ftsfield-text");

    AppUI ui = AppUI.getCurrent();
    if (ui.isTestMode()) {
        searchField.setCubaId("ftsField");
        searchField.setId(ui.getTestIdManager().reserveId("ftsField"));
    }
    searchField.addShortcutListener(new ShortcutListener("fts", com.vaadin.event.ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            openSearchWindow();
        }
    });

    searchBtn = new CubaButton();
    searchBtn.setStyleName("c-ftsfield-button");
    searchBtn.setIcon(WebComponentsHelper.getIcon("app/images/fts-button.png"));
    searchBtn.addClickListener(
            (Button.ClickListener) event -> openSearchWindow()
    );

    component.addComponent(searchField);
    component.addComponent(searchBtn);

    adjustHeight();
    adjustWidth();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:36,代码来源:WebFtsField.java

示例3: createSearchBar

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private MHorizontalLayout createSearchBar() {
    Label header = new Label("Bookery");
    header.addStyleName(ValoTheme.LABEL_BOLD);
    header.setSizeUndefined();
    header.addStyleName(ValoTheme.LABEL_H3);
    
    searchText = new TextField();
    searchText.setIcon(FontAwesome.SEARCH);
    searchText.addStyleName(ValoTheme.TEXTFIELD_LARGE);
    searchText.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    searchText.setWidth(100, Unit.PERCENTAGE);
    searchText.setInputPrompt("hier einfach suchen..");
    Button searchButton = new Button("such!", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Navigator navigator = ((App)UI.getCurrent()).getNavigator();
            if (navigator.getState().contains("search")) {
                navigator.navigateTo(navigator.getState());
            }
            else {
                navigator.navigateTo(SearchView.id);
            }
            
        }
    });
    searchButton.addStyleName(ValoTheme.BUTTON_LARGE);
    searchText.addShortcutListener(new Button.ClickShortcut(searchButton, ShortcutAction.KeyCode.ENTER));

    MHorizontalLayout layout = new MHorizontalLayout(header,searchText,searchButton);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setExpandRatio(searchText, 1.0f);
    return layout;
}
 
开发者ID:felixhusse,项目名称:bookery,代码行数:34,代码来源:AppHeader.java

示例4: VaadinQueryContent

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
public VaadinQueryContent() {
	setWidth("100%");
	
	label = new Label();
	if (Resources.isAvailable("Application.queryCaption")) {
		label.setCaption(Resources.getString("Application.queryCaption"));
	}
	label.addStyleName("queryContentLabel");
	addComponent(label);

	textField = new TextField();
	textField.setWidth("600px");
	textField.addShortcutListener(new ShortcutListener("Query", ShortcutAction.KeyCode.ENTER, null) {
		private static final long serialVersionUID = 1L;
		
		@Override
		public void handleAction(Object sender, Object target) {
			if (target == textField) {
				String query = textField.getValue();
				Page page = Application.getInstance().createSearchPage(query);
				Frontend.show(page);
			}
		}
	});
	addComponent(textField);
	setComponentAlignment(textField, Alignment.MIDDLE_CENTER);
}
 
开发者ID:BrunoEberhard,项目名称:minimal-j,代码行数:28,代码来源:VaadinQueryContent.java

示例5: buildFilter

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private Component buildFilter() {
    final TextField filter = new TextField();
    filter.addTextChangeListener(new TextChangeListener() {
        @Override
        public void textChange(final TextChangeEvent event) {
            Filterable data = (Filterable) table.getContainerDataSource();
            data.removeAllContainerFilters();
            data.addContainerFilter(new Filter() {
                @Override
                public boolean passesFilter(final Object itemId,
                        final Item item) {

                    if (event.getText() == null
                            || event.getText().equals("")) {
                        return true;
                    }

                    return filterByProperty("country", item,
                            event.getText())
                            || filterByProperty("city", item,
                                    event.getText())
                            || filterByProperty("title", item,
                                    event.getText());

                }

                @Override
                public boolean appliesToProperty(final Object propertyId) {
                    if (propertyId.equals("country")
                            || propertyId.equals("city")
                            || propertyId.equals("title")) {
                        return true;
                    }
                    return false;
                }
            });
        }
    });

    filter.setInputPrompt("Filter");
    filter.setIcon(FontAwesome.SEARCH);
    filter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    filter.addShortcutListener(new ShortcutListener("Clear",
            KeyCode.ESCAPE, null) {
        @Override
        public void handleAction(final Object sender, final Object target) {
            filter.setValue("");
            ((Filterable) table.getContainerDataSource())
                    .removeAllContainerFilters();
        }
    });
    return filter;
}
 
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:54,代码来源:TransactionsView.java


注:本文中的com.vaadin.ui.TextField.addShortcutListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。