View Single Post
  #2 (permalink)  
Old July 3rd, 2011
GregorK GregorK is offline
Phex Developer
Join Date: May 9th, 2001
Location: Stuttgart, Germany
Posts: 981
GregorK is flying high

I know Phex is not optimal here and the handling should be improved. I hope this helps you anyway.

For step 2 here ist some pseudo code for the steps to do:

SearchContainer searchContainer = QueryManager.getSearchContainer()
Search newSearch = searchContainer.createSearch( searchString );
newSearch.startSearching( new DefaultSearchProgress(DEFAULT_QUERY_TIMEOUT, DESIRED_RESULTS) );

To get results add a method like this somewhere:
@EventTopicSubscriber(topic=PhexEventTopics.Search _Data)
public void onSearchDataEvent( String topic, SearchDataEvent event )
if ( newSearch != event.getSource() )
if ( event.getType() == SearchDataEvent.SEARCH_HITS_ADDED )
RemoteFile[] newSearchResults = event.getSearchData();

And register the method by calling this in the class constructor:
Phex.getEventService().processAnnotations( this );

There is no real way to do (3), the query results can come in minutes after the search is triggered, there is no official end. The UI uses a combination of timeout and a pseudo progress indicator using the number of received results.
Ask your DefaultSearchProgress instance if it thinks the search is over. But still expect results to come in afterwards.

Can you tell me more about the kind of application you like to embed Phex into?

Look at SearchControllPanel to see how the UI does it.

Reply With Quote