本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}