Search in sources :

Example 6 with IQueryListener

use of org.eclipse.search.ui.IQueryListener in project eclipse.platform.text by eclipse.

the class QueryManagerTest method testQueryListener.

@Test
public void testQueryListener() {
    final boolean[] wasAdded = { false };
    final boolean[] wasRemoved = { false };
    IQueryListener l = new IQueryListener() {

        @Override
        public void queryAdded(ISearchQuery query) {
            wasAdded[0] = true;
        }

        @Override
        public void queryRemoved(ISearchQuery query) {
            wasRemoved[0] = true;
        }

        @Override
        public void queryStarting(ISearchQuery query) {
        // not interested
        }

        @Override
        public void queryFinished(ISearchQuery query) {
        // not interested
        }
    };
    NewSearchUI.addQueryListener(l);
    ISearchQuery query = new NullQuery();
    InternalSearchUI.getInstance().addQuery(query);
    assertTrue(wasAdded[0]);
    InternalSearchUI.getInstance().removeQuery(query);
    assertTrue(wasRemoved[0]);
    InternalSearchUI.getInstance().removeQueryListener(l);
    wasAdded[0] = false;
    wasRemoved[0] = false;
    InternalSearchUI.getInstance().addQuery(query);
    assertFalse(wasAdded[0]);
    InternalSearchUI.getInstance().removeQuery(query);
    assertFalse(wasRemoved[0]);
}
Also used : IQueryListener(org.eclipse.search.ui.IQueryListener) ISearchQuery(org.eclipse.search.ui.ISearchQuery) Test(org.junit.Test)

Example 7 with IQueryListener

use of org.eclipse.search.ui.IQueryListener in project che by eclipse.

the class QueryManager method fireStarting.

public void fireStarting(ISearchQuery query) {
    Set copiedListeners = new HashSet();
    synchronized (fListeners) {
        copiedListeners.addAll(fListeners);
    }
    Iterator listeners = copiedListeners.iterator();
    while (listeners.hasNext()) {
        IQueryListener l = (IQueryListener) listeners.next();
        l.queryStarting(query);
    }
}
Also used : IQueryListener(org.eclipse.search.ui.IQueryListener) HashSet(java.util.HashSet) Set(java.util.Set) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Example 8 with IQueryListener

use of org.eclipse.search.ui.IQueryListener in project che by eclipse.

the class QueryManager method fireFinished.

public void fireFinished(ISearchQuery query) {
    Set copiedListeners = new HashSet();
    synchronized (fListeners) {
        copiedListeners.addAll(fListeners);
    }
    Iterator listeners = copiedListeners.iterator();
    while (listeners.hasNext()) {
        IQueryListener l = (IQueryListener) listeners.next();
        l.queryFinished(query);
    }
}
Also used : IQueryListener(org.eclipse.search.ui.IQueryListener) HashSet(java.util.HashSet) Set(java.util.Set) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Example 9 with IQueryListener

use of org.eclipse.search.ui.IQueryListener in project eclipse.platform.text by eclipse.

the class AbstractTextSearchViewPage method createQueryListener.

private IQueryListener createQueryListener() {
    return new IQueryListener() {

        @Override
        public void queryAdded(ISearchQuery query) {
        // ignore
        }

        @Override
        public void queryRemoved(ISearchQuery query) {
        // ignore
        }

        @Override
        public void queryStarting(final ISearchQuery query) {
            final Runnable runnable1 = new Runnable() {

                @Override
                public void run() {
                    updateBusyLabel();
                    AbstractTextSearchResult result = getInput();
                    if (result == null || !result.getQuery().equals(query)) {
                        return;
                    }
                    turnOffDecoration();
                    scheduleUIUpdate();
                }
            };
            asyncExec(runnable1);
        }

        @Override
        public void queryFinished(final ISearchQuery query) {
            // handle the end of the query in the UIUpdateJob, as ui updates
            // may not be finished here.
            postEnsureSelection();
        }
    };
}
Also used : IQueryListener(org.eclipse.search.ui.IQueryListener) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) ISearchQuery(org.eclipse.search.ui.ISearchQuery)

Example 10 with IQueryListener

use of org.eclipse.search.ui.IQueryListener in project eclipse.platform.text by eclipse.

the class QueryManager method fireFinished.

public void fireFinished(ISearchQuery query) {
    Set<IQueryListener> copiedListeners = new HashSet<>();
    synchronized (fListeners) {
        copiedListeners.addAll(fListeners);
    }
    Iterator<IQueryListener> listeners = copiedListeners.iterator();
    while (listeners.hasNext()) {
        IQueryListener l = listeners.next();
        l.queryFinished(query);
    }
}
Also used : IQueryListener(org.eclipse.search.ui.IQueryListener) HashSet(java.util.HashSet)

Aggregations

IQueryListener (org.eclipse.search.ui.IQueryListener)10 HashSet (java.util.HashSet)8 Iterator (java.util.Iterator)4 Set (java.util.Set)4 ISearchQuery (org.eclipse.search.ui.ISearchQuery)2 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)1 Test (org.junit.Test)1