net.refractions.udig.ui
Class SearchPart

java.lang.Object
  extended by ViewPart
      extended by net.refractions.udig.ui.SearchPart

public class SearchPart
extends ViewPart

A ViewPart with support for a background "search" process.

The part will automatically show the "progress" when the monitored Job(s) are running.

Since:
1.0.0
Author:
jgarnett

Nested Class Summary
protected static class SearchPart.Orientation
           
static class SearchPart.ResultSet
           
 
Field Summary
protected  IAction cancel
          Used to cancel current searchMonitor
protected  SearchPart.Orientation orientation
           
protected  Composite parent
           
protected  IMemento save
          Save state here
protected  IProgressMonitor searchMonitor
          Used to control search jobs.
protected  SashForm splitter
           
protected  StructuredViewer viewer
          Viewer for search results List/Tree/Table ...
 
Constructor Summary
protected SearchPart(IDialogSettings dialogSettings)
          We need dialog settings for persistence
 
Method Summary
protected  IStructuredContentProvider createContentProvider()
          Default implementation will work for lists, please overide if you are into the whole tree thing.
protected  Composite createDetails(SashForm splitter)
          Subclass should override to provide custom details display.
protected  IBaseLabelProvider createLabelProvider()
           
 void createPartControl(Composite aParent)
          Creates the SWT controls for this workbench part.
protected  ISelectionChangedListener createSelectionListener()
          Default implementation calls showDetail( IStructuredSelection ).
protected  StructuredViewer createViewer(Composite parent)
          Create viewer (default is a ListViewer please override if you want a Tree or Table Viewer.
protected  void fillActionBars()
          Create toolbar with cancel.
protected  void fillViewMenu()
           
protected  Composite getDetails()
          Subclass can override to return its kind of details, example a PageBook.
protected  ISelection getSelection(java.util.List<java.lang.Object> input)
          Called to determine what object(s) in the input should be the selection in the viewer.
 void init(IViewSite site, IMemento memento)
           
protected  void initDragAndDrop()
          Subclass should override to support DnD.
protected  void makeActions()
           
protected  void notifyChange(SearchPart.ResultSet set, java.util.Collection<? extends java.lang.Object> newObjects)
          Called each time data is added to the result set by the search.
 void quick(java.lang.String pattern)
           
 void saveState(IMemento memento)
           
protected  void saveViewSettings()
           
 void search(java.lang.Object newFilter)
          Search the catalog for text and update view contents
protected  void searchImplementation(java.lang.Object filter, IProgressMonitor monitor, SearchPart.ResultSet results)
           
 void selectReveal(ISelection selection)
           
 void setFocus()
           
protected  void setOrientation(SearchPart.Orientation orientation)
          called from ToggleOrientationAction (or compute).
 void setShowDetails(boolean show)
           
protected  void showDetail(java.lang.Object selection)
          Allows subclass to focus the detail on this selection
protected  boolean showSelection()
          Returns true if the selection returned by #getNewSelection(List) should be shown in the viewer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

viewer

protected StructuredViewer viewer
Viewer for search results List/Tree/Table ...


cancel

protected IAction cancel
Used to cancel current searchMonitor

Usually available in the toolbar.


searchMonitor

protected IProgressMonitor searchMonitor
Used to control search jobs.

Only one "batch" of search jobs is outstanding at anyone time.


splitter

protected SashForm splitter

save

protected IMemento save
Save state here


parent

protected Composite parent

orientation

protected SearchPart.Orientation orientation
Constructor Detail

SearchPart

protected SearchPart(IDialogSettings dialogSettings)
We need dialog settings for persistence

Method Detail

init

public void init(IViewSite site,
                 IMemento memento)
          throws PartInitException
Throws:
PartInitException

saveState

public void saveState(IMemento memento)

setOrientation

protected void setOrientation(SearchPart.Orientation orientation)
called from ToggleOrientationAction (or compute).

Parameters:
orientation - Orientation.HORIZONTAL or Orientation.VERTICAL

setShowDetails

public void setShowDetails(boolean show)

createPartControl

public void createPartControl(Composite aParent)
Creates the SWT controls for this workbench part.

The details (from IWorkbenchPart.createPartControl( Composite ))

Multi-step process:

  1. Create one or more controls within the parent.
  2. Set the parent layout as needed.
  3. Register any global actions with the IActionService.
  4. Register any popup menus with the IActionService.
  5. Register a selection provider with the ISelectionService (optional).

Parameters:
parent -
See Also:
org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)

saveViewSettings

protected void saveViewSettings()

createDetails

protected Composite createDetails(SashForm splitter)
Subclass should override to provide custom details display.

Many subclasses use PageBook with page selection based on the selection in the viewer.

Parameters:
splitter -
Returns:
Composite to use for details display

getDetails

protected Composite getDetails()
Subclass can override to return its kind of details, example a PageBook.

Returns:

createViewer

protected StructuredViewer createViewer(Composite parent)
Create viewer (default is a ListViewer please override if you want a Tree or Table Viewer.

Note the following will be called after creation:

This allows people who subclass you to do their own thing.

Parameters:
page -
Returns:

createSelectionListener

protected ISelectionChangedListener createSelectionListener()
Default implementation calls showDetail( IStructuredSelection ).

Override if you want to do something else.


showDetail

protected void showDetail(java.lang.Object selection)
Allows subclass to focus the detail on this selection


createContentProvider

protected IStructuredContentProvider createContentProvider()
Default implementation will work for lists, please overide if you are into the whole tree thing.

Returns:

createLabelProvider

protected IBaseLabelProvider createLabelProvider()
Returns:

initDragAndDrop

protected void initDragAndDrop()
Subclass should override to support DnD.


makeActions

protected void makeActions()

fillViewMenu

protected void fillViewMenu()

fillActionBars

protected void fillActionBars()
Create toolbar with cancel.


quick

public void quick(java.lang.String pattern)

notifyChange

protected void notifyChange(SearchPart.ResultSet set,
                            java.util.Collection<? extends java.lang.Object> newObjects)
Called each time data is added to the result set by the search. Note: Many items or a single item could have been added.

Parameters:
set - the results of the search at the current point.
newObjects - the objects that have been added this time.

getSelection

protected ISelection getSelection(java.util.List<java.lang.Object> input)
Called to determine what object(s) in the input should be the selection in the viewer. This method is called when the search is complete. The default selection is the first object in the list.

Parameters:
the - complete list of objects in the viewer.
Returns:
the selection that will be set in the viewer. may be null.

showSelection

protected boolean showSelection()
Returns true if the selection returned by #getNewSelection(List) should be shown in the viewer.

Returns:
true if the selection returned by #getNewSelection(List) should be shown in the viewer.

search

public void search(java.lang.Object newFilter)
Search the catalog for text and update view contents

Parameters:
pattern -

searchImplementation

protected void searchImplementation(java.lang.Object filter,
                                    IProgressMonitor monitor,
                                    SearchPart.ResultSet results)

selectReveal

public void selectReveal(ISelection selection)

setFocus

public void setFocus()