workspace
Class SearchBar

java.lang.Object
  extended by workspace.SearchBar

public class SearchBar
extends java.lang.Object

Contributes a search bar component to the CodeBlocks GUI, which allows the user to find Searchables such as blocks in the drawers and workspace with a query by name.


Constructor Summary
SearchBar(java.lang.String defaultText, java.lang.String tooltip, java.awt.Component defaultComponent)
          Contructs a new search bar.
 
Method Summary
 void addSearchableContainer(SearchableContainer searchable)
          Adds a searchable to the set of searchables queried by this search bar.
 javax.swing.JComponent getComponent()
          Returns the Swing component representation of the search bar.
 java.lang.Iterable<SearchableElement> getSearchResults(SearchableContainer container)
          Returns a set of elements representing the search results for a particular container.
 void removeSearchableContainer(SearchableContainer searchable)
          Removes a searchable container from the set of searchables queried by this search bar.
 void reset()
          Clears all the internal data of this.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SearchBar

public SearchBar(java.lang.String defaultText,
                 java.lang.String tooltip,
                 java.awt.Component defaultComponent)
Contructs a new search bar.

Parameters:
defaultText - the text to show when the user is not using the search bar, such as "Search blocks"
tooltip - the text to show as a tooltip for the search bar when the user hovers the mouse over the search bar.
defaultComponent - the component for which focus should be requested if the user presses the Escape key while using the search bar.
Method Detail

getComponent

public javax.swing.JComponent getComponent()
Returns the Swing component representation of the search bar.

Returns:
the Swing the component representation of the search bar.

getSearchResults

public java.lang.Iterable<SearchableElement> getSearchResults(SearchableContainer container)
Returns a set of elements representing the search results for a particular container.

Parameters:
container - the returned search elements will be from this search container
Returns:
search results for a particular container

addSearchableContainer

public void addSearchableContainer(SearchableContainer searchable)
Adds a searchable to the set of searchables queried by this search bar. If more than one search bar exists, the same searchable should not be added to more than search bar.

Parameters:
searchable - the container to add

removeSearchableContainer

public void removeSearchableContainer(SearchableContainer searchable)
Removes a searchable container from the set of searchables queried by this search bar.

Parameters:
searchable - the container to remove

reset

public void reset()
Clears all the internal data of this.