Java Code Examples for com.vaadin.ui.TextField#addShortcutListener()

The following examples show how to use com.vaadin.ui.TextField#addShortcutListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobLogFilter.java    From chipster with MIT License 4 votes vote down vote up
public JobLogFilter(final JobLogView view, String column, String search) {
	this.view = view;

	searchStringField = new TextField();
	if (search != null) {
		searchStringField.setValue(search);
	}
	searchStringField.setDescription("Search for values starting with this string. Question mark (?) is a wildcard for a single character and asterisk (*) for any number of characters.");  
	searchStringField.addShortcutListener(new ShortcutListener("Search", ShortcutAction.KeyCode.ENTER, null) {

		@Override
		public void handleAction(Object sender, Object target) {
			view.update();
		}
	});

	columnToSearch = new NativeSelect();

	Button clearButton = new Button();
	clearButton.setIcon(new ThemeResource("crystal/button_cancel-bw.png"));
	clearButton.setDescription("Remove filter");
	clearButton.addStyleName("search-button");

	for (int i = 0; i < JobLogContainer.NATURAL_COL_ORDER.length; i++) {

		//Do not search from generated columns
		if (SEARCH_COLUMNS.contains(JobLogContainer.NATURAL_COL_ORDER[i])) {
			columnToSearch.addItem(JobLogContainer.NATURAL_COL_ORDER[i]);
			columnToSearch.setItemCaption(JobLogContainer.NATURAL_COL_ORDER[i],
					JobLogContainer.COL_HEADERS_ENGLISH[i]);
		}
	}

	if (column != null) {
		columnToSearch.setValue(column);
	} else {
		columnToSearch.setValue(JobLogContainer.USERNAME);
	}
	columnToSearch.setNullSelectionAllowed(false);

	clearButton.addClickListener(new Button.ClickListener() {
		public void buttonClick(ClickEvent event) {
			getView().clearFilter(JobLogFilter.this);
		}
	});

	addComponent(columnToSearch);
	addComponent(searchStringField);
	addComponent(clearButton);

	addStyleName("search-filter-bg");
	addStyleName("search-filter");
}