Search in sources :

Example 1 with TextSearchControl

use of org.eclipse.mylyn.commons.workbench.search.TextSearchControl in project eclipse-integration-commons by spring-projects.

the class DashboardMainPage method createSearchBox.

private void createSearchBox(Composite composite) {
    TextSearchControl searchControl = new TextSearchControl(composite, false, null);
    searchControl.getTextControl().setMessage("Search spring.io");
    GridDataFactory.fillDefaults().grab(false, true).align(SWT.FILL, SWT.CENTER).hint(200, SWT.DEFAULT).applyTo(searchControl);
    searchBox = searchControl.getTextControl();
    searchBox.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.character == SWT.ESC && e.doit) {
                clearText();
            }
        }
    });
    searchControl.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            if (e.detail == TextSearchControl.ICON_CANCEL) {
                clearText();
            } else {
                searchSpringSource();
            }
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextSearchControl(org.eclipse.mylyn.commons.workbench.search.TextSearchControl)

Aggregations

TextSearchControl (org.eclipse.mylyn.commons.workbench.search.TextSearchControl)1 KeyAdapter (org.eclipse.swt.events.KeyAdapter)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1