semorg.gui.util
Class ExtensibleSearchControl

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by semorg.gui.util.ExtensibleSearchControl
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class ExtensibleSearchControl
extends org.eclipse.swt.widgets.Composite

Provides a search control widget which can apply several conditions to the filter of a list window. This list of conditions can by expanded by the user to apply more and more conditions to the list window.


Field Summary
private static String[] booleanComparators
          Comparator constants which can be applied to boolean values.
private  org.eclipse.swt.widgets.Combo[] columnCombos
          The combo fields containing the names of the columns which are used for the filtering.
private  Vector<DBColumn> columns
          Columns on which the conditions get applied.
private  org.eclipse.swt.widgets.Combo[] comparatorCombos
          The combo fields containing the applicable comparators.
private  org.eclipse.swt.widgets.Combo[] conjunctionCombos
          The conjunction combos.
private static String[] conjunctions
          Conjunctions constants whose values depend on the selected language.
private static String[] dateComparators
          Comparator constants which can be applied to dates.
private  org.eclipse.swt.widgets.ToolItem[] extenders
          The buttons which extends the filter..
private  int filterExtensionCounter
          The number of the applied conditions.
private  org.eclipse.swt.widgets.Composite[] filterExtensions
          The filter extensions of the filter control.
private  org.eclipse.swt.widgets.Text[] filterTexts
          The text fields of the filter control.
private static String[] floatComparators
          Comparator constants which can be applied to floar numbers.
private static String[] intComparators
          Comparator constants which can be applied to integers.
private static String[] stringComparators
          Comparator constants which can be applied to strings.
private static String[] timeComparators
          Comparator constants which can be applied to times.
private static String[] timestampComparators
          Comparator constants which can be applied to timestamps.
private  org.eclipse.swt.widgets.Composite window
          The window containing the filter control.
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
ExtensibleSearchControl(org.eclipse.swt.widgets.Composite parent, int numberExtensions)
          Instantiates a new extensible search control.
 
Method Summary
 void addExtensionListener(org.eclipse.swt.events.SelectionListener arg0)
          Adds the extension listener.
 void addModifyListener(org.eclipse.swt.events.ModifyListener arg0)
          Adds the modify listener.
private  org.eclipse.swt.widgets.Composite createFilterExtension(int number)
          Creates a filter extension, i.e. it creates widgets in the array conjunctionCombos, columnCombos, comparatorCombos and filterTexts at the specified position.
private  String[] getComparatorString(String publicColumnName)
          Firstly this function resolves the DBColumn instance for the given public name and then returns the correct class of comparators depending on the type of the DBColumn.
 Vector<DBConstraint> getConstraints()
          Returns the constraints which are entered into the filter control by the user.
private  DBColumn getDBColumn(String publicColumnName)
          Returns a DBColumn for a given public name.
 void setColumns(Vector<DBColumn> columns)
          Inserts the given columns into the filter controls.
 void setData(String key, String value)
          Sets a pair of key and value to this control needed for testing with ATOSj.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

conjunctions

private static final String[] conjunctions
Conjunctions constants whose values depend on the selected language.


stringComparators

private static final String[] stringComparators
Comparator constants which can be applied to strings.


intComparators

private static final String[] intComparators
Comparator constants which can be applied to integers.


floatComparators

private static final String[] floatComparators
Comparator constants which can be applied to floar numbers.


dateComparators

private static final String[] dateComparators
Comparator constants which can be applied to dates.


timestampComparators

private static final String[] timestampComparators
Comparator constants which can be applied to timestamps.


timeComparators

private static final String[] timeComparators
Comparator constants which can be applied to times.


booleanComparators

private static final String[] booleanComparators
Comparator constants which can be applied to boolean values.


columns

private Vector<DBColumn> columns
Columns on which the conditions get applied.


filterExtensionCounter

private int filterExtensionCounter
The number of the applied conditions.


filterExtensions

private final org.eclipse.swt.widgets.Composite[] filterExtensions
The filter extensions of the filter control.


extenders

private final org.eclipse.swt.widgets.ToolItem[] extenders
The buttons which extends the filter..


conjunctionCombos

private final org.eclipse.swt.widgets.Combo[] conjunctionCombos
The conjunction combos.


columnCombos

private final org.eclipse.swt.widgets.Combo[] columnCombos
The combo fields containing the names of the columns which are used for the filtering.


comparatorCombos

private final org.eclipse.swt.widgets.Combo[] comparatorCombos
The combo fields containing the applicable comparators.


filterTexts

private final org.eclipse.swt.widgets.Text[] filterTexts
The text fields of the filter control.


window

private org.eclipse.swt.widgets.Composite window
The window containing the filter control.

Constructor Detail

ExtensibleSearchControl

public ExtensibleSearchControl(org.eclipse.swt.widgets.Composite parent,
                               int numberExtensions)
Instantiates a new extensible search control.

Parameters:
parent - the parent composite
numberExtensions - the number of extensions
Method Detail

createFilterExtension

private org.eclipse.swt.widgets.Composite createFilterExtension(int number)
Creates a filter extension, i.e. it creates widgets in the array conjunctionCombos, columnCombos, comparatorCombos and filterTexts at the specified position.

Parameters:
number - the index of the extension to create.
Returns:
the composite

addExtensionListener

public void addExtensionListener(org.eclipse.swt.events.SelectionListener arg0)
Adds the extension listener.

Parameters:
arg0 - the SelectionListener to add.

addModifyListener

public void addModifyListener(org.eclipse.swt.events.ModifyListener arg0)
Adds the modify listener.

Parameters:
arg0 - the ModifyListener to add.

getConstraints

public Vector<DBConstraint> getConstraints()
                                    throws Exception
Returns the constraints which are entered into the filter control by the user. Note that the conditions entered into the control get converted into a Vector of DBConstraint instances.

Returns:
a Vector of DBConstraint instances according to the conditions of the filter control.
Throws:
Exception - if the parsing of dates, times, timestamps, integers or float numbers fails for some reason.

setColumns

public void setColumns(Vector<DBColumn> columns)
Inserts the given columns into the filter controls.

Parameters:
columns - vector of DBColumn instances which should be inserted into the filter

getComparatorString

private String[] getComparatorString(String publicColumnName)
Firstly this function resolves the DBColumn instance for the given public name and then returns the correct class of comparators depending on the type of the DBColumn.

Parameters:
publicColumnName - the public name of the column
Returns:
string array containing all comparators applicable the DBColumn instance.

getDBColumn

private DBColumn getDBColumn(String publicColumnName)
Returns a DBColumn for a given public name.

Parameters:
publicColumnName - the public name of the column.
Returns:
DBColumn instance corresponding to the given public name.

setData

public void setData(String key,
                    String value)
Sets a pair of key and value to this control needed for testing with ATOSj.

Parameters:
key - the key (type) of the value set
value - the value set to the control