本文整理匯總了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;
}