Search in sources :

Example 1 with SearchMatcher

use of org.eclipse.m2e.editor.pom.SearchMatcher in project m2e-core by eclipse-m2e.

the class DependenciesComposite method setSearchControl.

public void setSearchControl(SearchControl searchControl) {
    if (this.searchControl != null) {
        return;
    }
    this.searchMatcher = new SearchMatcher(searchControl);
    this.searchFilter = new DependencyFilter(searchMatcher);
    this.searchControl = searchControl;
    // we add filter here as the default behaviour is to filter..
    final TableViewer dependenciesViewer = dependenciesEditor.getViewer();
    dependenciesViewer.addFilter(searchFilter);
    final TableViewer dependencyManagementViewer = dependencyManagementEditor.getViewer();
    dependencyManagementViewer.addFilter(searchFilter);
    // Create a job to update the contents of the viewers when the
    // filter text is modified. Using a job is in this way lets us
    // defer updating the field while the user is typing.
    final Job updateJob = new WorkbenchJob("Update Maven Dependency Viewers") {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            dependenciesViewer.refresh();
            dependencyManagementViewer.refresh();
            return Status.OK_STATUS;
        }
    };
    // Run the update job when the user modifies the filter text.
    this.searchControl.getSearchText().addModifyListener(e -> {
        // The net effect here is that the field will update 200 ms after
        // the user stops typing.
        updateJob.cancel();
        updateJob.schedule(200);
    });
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) WorkbenchJob(org.eclipse.ui.progress.WorkbenchJob) WorkbenchJob(org.eclipse.ui.progress.WorkbenchJob) Job(org.eclipse.core.runtime.jobs.Job) TableViewer(org.eclipse.jface.viewers.TableViewer) SearchMatcher(org.eclipse.m2e.editor.pom.SearchMatcher)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 SearchMatcher (org.eclipse.m2e.editor.pom.SearchMatcher)1 WorkbenchJob (org.eclipse.ui.progress.WorkbenchJob)1