com.limegroup.gnutella.gui.search
Class SearchMediator

java.lang.Object
  extended bycom.limegroup.gnutella.gui.search.SearchMediator
All Implemented Interfaces:
ThemeObserver

public final class SearchMediator
extends java.lang.Object
implements ThemeObserver

This class acts as a mediator between the various search components -- the hub that all traffic passes through. This allows the decoupling of the various search packages and simplfies the responsibilities of the underlying classes.


Field Summary
static java.lang.Object REPEAT_SEARCH_LOCK
          This object is used to synchronize the code that causes a repeat search to be initiated, and the code that adds lines to the resultPanel.
 
Constructor Summary
SearchMediator()
          Constructs the UI components of the search result display area of the search tab.
 
Method Summary
static void browseHostFailed(com.limegroup.gnutella.GUID guid)
          Call this when a Browse Host fails.
static void doBrowseHost(com.limegroup.gnutella.RemoteFileDesc rfd)
          Allows for browsing of a host from outside of the search package.
static void doBrowseHost(java.lang.String host, int port, com.limegroup.gnutella.GUID guid)
          Allows for browsing of a host from outside of the search package without an rfd.
static javax.swing.JComponent getComponent()
          Returns the JComponent instance containing all of the search result UI components.
static InputPanel getCurrentInputPanel()
          Returns the currently selected InputPanel instance.
static javax.swing.JComponent getSearchBoxPanel()
          Returns the search input panel component.
static void handleQueryResult(com.limegroup.gnutella.RemoteFileDesc rfd, com.limegroup.gnutella.search.HostData data, java.util.Set alts)
          If i rp is no longer the i'th panel of this, returns silently.
static void setConnected(boolean connected)
          Notifies the search window of the current connection status, making any necessary changes as a result, such as the enabled/disabled status of the search button.
static byte[] triggerSearch(java.lang.String stext)
          Triggers a search for the given text.
 void updateTheme()
          Update any required theme settings, such as colors or images.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPEAT_SEARCH_LOCK

public static final java.lang.Object REPEAT_SEARCH_LOCK
This object is used to synchronize the code that causes a repeat search to be initiated, and the code that adds lines to the resultPanel.

If the code in these two blocks are interleaved, the code that initiates a repeatSearch - could clear the grouper, and not the model yet, before another line is added to the grouper.

Therefore the code in ResultPanel.repeatSearch() and the code in SearchView.handleQueryReplyInternal, have to be atomic with respect to each other. They are both synchronized on this object.

Constructor Detail

SearchMediator

public SearchMediator()
Constructs the UI components of the search result display area of the search tab.

Method Detail

doBrowseHost

public static void doBrowseHost(com.limegroup.gnutella.RemoteFileDesc rfd)
Allows for browsing of a host from outside of the search package.


doBrowseHost

public static void doBrowseHost(java.lang.String host,
                                int port,
                                com.limegroup.gnutella.GUID guid)
Allows for browsing of a host from outside of the search package without an rfd.


browseHostFailed

public static void browseHostFailed(com.limegroup.gnutella.GUID guid)
Call this when a Browse Host fails.

Parameters:
guid - The guid associated with this Browse.

triggerSearch

public static byte[] triggerSearch(java.lang.String stext)
Triggers a search for the given text. For testing purposes returns the 16-byte GUID of the search or null if the search didn't happen because it was greedy, etc.


handleQueryResult

public static void handleQueryResult(com.limegroup.gnutella.RemoteFileDesc rfd,
                                     com.limegroup.gnutella.search.HostData data,
                                     java.util.Set alts)
If i rp is no longer the i'th panel of this, returns silently. Otherwise adds line to rp under the given group. Updates the count on the tab in this and restarts the spinning lime.


setConnected

public static void setConnected(boolean connected)
Notifies the search window of the current connection status, making any necessary changes as a result, such as the enabled/disabled status of the search button.

Parameters:
connected - the connected status of the client

getSearchBoxPanel

public static javax.swing.JComponent getSearchBoxPanel()
Returns the search input panel component.

Returns:
the search input panel component

getCurrentInputPanel

public static InputPanel getCurrentInputPanel()
Returns the currently selected InputPanel instance.

Returns:
the currently selected InputPanel instance

getComponent

public static javax.swing.JComponent getComponent()
Returns the JComponent instance containing all of the search result UI components.

Returns:
the JComponent instance containing all of the search result UI components

updateTheme

public void updateTheme()
Description copied from interface: ThemeObserver
Update any required theme settings, such as colors or images.

Specified by:
updateTheme in interface ThemeObserver