semorg.gui.list
Class ListWindow

java.lang.Object
  extended by semorg.gui.list.ListWindow
Direct Known Subclasses:
AssociateListWindow, ClientBookingListWindow, ClientListWindow, CompanyBookingListWindow, CompanyInternalPresentationListWindow, CompanyListWindow, LecturerListWindow, PresentationListWindow, PublicPresentationListWindow, SeminarTypeListWindow

public abstract class ListWindow
extends Object

Super class for all list window classes. Encapsulates all properties and methods, which have all list window classes in common.


Field Summary
protected  org.eclipse.swt.widgets.Button chooseButton
          The button to select an existing data record.
protected  Vector<DBColumn> columns
          The DBColumns corresponding to the displayed data records.
private  org.eclipse.swt.widgets.ToolItem configureItem
          The button to configure the GUI table.
protected  org.eclipse.swt.widgets.ToolItem deleteItem
          The button to delete an existing data record.
protected  org.eclipse.swt.widgets.ToolItem editItem
          The button to edit an existing data record.
(package private)  ExtensibleSearchControl filter
          The search widget in the list window.
protected  org.eclipse.swt.widgets.ToolItem filterItem
          Item which allows to filter entries in the list window.
protected  org.eclipse.swt.widgets.Table mainTable
          The GUI table wrapped by the mainTableViewer.
protected  org.eclipse.jface.viewers.TableViewer mainTableViewer
          MVC wrapper around the GUI table for seperating presentation from data.
protected  org.eclipse.swt.widgets.ToolItem newItem
          The button to create a new data record.
protected  org.eclipse.swt.widgets.Shell shell
          The window itself.
protected  String sortString
          String which is used for sorting the rows of the GUI table.
protected  org.eclipse.swt.widgets.Composite toolBar
          The toolbar of the list window.
private  DBTableChangedListener updateListener
          A listener which reacts on changes of the database table.
 
Constructor Summary
ListWindow(org.eclipse.swt.widgets.Shell parent, Vector<DBColumn> columns)
          Constructor for list windows called from the main menu, i.e. non-popup list windows.
ListWindow(org.eclipse.swt.widgets.Shell parent, Vector<DBColumn> columns, AssociationTabControl caller)
          Constructor for ListWindow instances created by user operations in the AssociationTabControl.
ListWindow(org.eclipse.swt.widgets.Shell parent, Vector<DBColumn> columns, ForeignKeyConstraintSelector caller)
          Constructor for list window instances invoked by instances of the class ForeignKeyConstraintSelector.
 
Method Summary
protected  void addUpdateListener(int type)
          Listener which reacts on changes of the database.
private  org.eclipse.swt.widgets.Composite createButtonArea()
          Creates a composite containing the buttons choose and abort and returns it.
protected abstract  void createChooseButtonListener(AssociationTabControl caller)
          Creates a SelectionListener for the choose button which passes the SimpleIDKeys of the selected elements to the calling AssociationTabControl by invoking the method addSelectedIds of the caller instance.
protected abstract  void createChooseButtonListener(ForeignKeyConstraintSelector caller)
          Creates a SelectionListener for the choose button which passes the database id of the selected element to the calling ForeignKeyConstraintSelector by invoking the method setSelectedId of the caller instance.
protected  void createListToolbarBasics(boolean isPopup)
          Creates the toolbar composite and its basic components.
protected abstract  void createSpecializedMainTableListener()
          Creates a DBTableChangedListener and adds it to the mainTableViewer.
protected abstract  void createSpecializedMainTableListener(AssociationTabControl caller)
          This method creates two listener and adds them to the main table viewer.
protected abstract  void createSpecializedMainTableListener(ForeignKeyConstraintSelector caller)
          This method creates two listener and adds them to the main table viewer.
protected abstract  void createSpecializedToolBarListeners()
          Creates listeners for the toolbar buttons editItem, newItem and deleteItem which provide the functionality of the buttons.
protected  void createTableBasics()
          Creates for each db column (columns) a corresponding GUI column.
protected abstract  Object getTableInputFromDB()
          Returns a vector of table class instances which will be displayed in the GUI table of the list window.
protected  void setActive()
          Sets the list window to active.
 void setVisible(boolean vis)
          Sets the visibility of the list window according to the given parameter.
 void update()
          Updates the GUI table with the actual records from a database query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shell

protected org.eclipse.swt.widgets.Shell shell
The window itself.


toolBar

protected org.eclipse.swt.widgets.Composite toolBar
The toolbar of the list window.


filterItem

protected org.eclipse.swt.widgets.ToolItem filterItem
Item which allows to filter entries in the list window.


mainTableViewer

protected org.eclipse.jface.viewers.TableViewer mainTableViewer
MVC wrapper around the GUI table for seperating presentation from data. Uses a ConentProvider for the data and LabelProvider for the presentation.


mainTable

protected org.eclipse.swt.widgets.Table mainTable
The GUI table wrapped by the mainTableViewer.


columns

protected final Vector<DBColumn> columns
The DBColumns corresponding to the displayed data records.


filter

ExtensibleSearchControl filter
The search widget in the list window.


sortString

protected String sortString
String which is used for sorting the rows of the GUI table.

Since the db function is used for the sorting it's just an SQL string like ORDER BY (column) [ASC|DSC].


newItem

protected org.eclipse.swt.widgets.ToolItem newItem
The button to create a new data record.


editItem

protected org.eclipse.swt.widgets.ToolItem editItem
The button to edit an existing data record.


deleteItem

protected org.eclipse.swt.widgets.ToolItem deleteItem
The button to delete an existing data record.


chooseButton

protected org.eclipse.swt.widgets.Button chooseButton
The button to select an existing data record.


configureItem

private org.eclipse.swt.widgets.ToolItem configureItem
The button to configure the GUI table.


updateListener

private DBTableChangedListener updateListener
A listener which reacts on changes of the database table.

Constructor Detail

ListWindow

public ListWindow(org.eclipse.swt.widgets.Shell parent,
                  Vector<DBColumn> columns)
Constructor for list windows called from the main menu, i.e. non-popup list windows.

Parameters:
parent - the parent window of the list window
columns - the columns corresponding to the displayed data.

ListWindow

public ListWindow(org.eclipse.swt.widgets.Shell parent,
                  Vector<DBColumn> columns,
                  AssociationTabControl caller)
Constructor for ListWindow instances created by user operations in the AssociationTabControl.

Parameters:
parent - the parent shell (window) of the new list window
columns - the columns to be displayed in the new list window
caller - the AssociationTabControl instance which invoked this constructor

ListWindow

public ListWindow(org.eclipse.swt.widgets.Shell parent,
                  Vector<DBColumn> columns,
                  ForeignKeyConstraintSelector caller)
Constructor for list window instances invoked by instances of the class ForeignKeyConstraintSelector.

Parameters:
parent - the parent shell (window) of the new list window
columns - the columns to be displayed in the new list window
caller - the ForeignKeyConstraintSelector instance which invoked this constructor
Method Detail

createButtonArea

private org.eclipse.swt.widgets.Composite createButtonArea()
Creates a composite containing the buttons choose and abort and returns it.

Returns:
the composite including two buttons

setActive

protected void setActive()
Sets the list window to active.


setVisible

public void setVisible(boolean vis)
Sets the visibility of the list window according to the given parameter.

Parameters:
vis - if true the list window is set to visible, else (false) it is set to invisible

update

public void update()
Updates the GUI table with the actual records from a database query.

For example if the rows of the GUI table are sorted by a column or a record has been deleted.


createListToolbarBasics

protected void createListToolbarBasics(boolean isPopup)
Creates the toolbar composite and its basic components.

The appearance of the toolbar in a popup list window and normal list window differs (i.e. not all buttons are displayed in popup window), thus you have to specify for which kind of list window the toolbar is meant for.

Parameters:
isPopup - Indicates whether the list window is used as a popup window (true) or as a normal list window called by the main window menu (false).

createTableBasics

protected void createTableBasics()
Creates for each db column (columns) a corresponding GUI column.

In addition a SelectionListener is added to the GUI columns so that a selection of a column header causes the sorting of the rows by the according column. The current sort column is marked by an upside respectively downside triangle.


addUpdateListener

protected void addUpdateListener(int type)
Listener which reacts on changes of the database. It simply updates the GUI table to changes of the database table.

Parameters:
type - the wanted type of the DBTableChangedListener

getTableInputFromDB

protected abstract Object getTableInputFromDB()
Returns a vector of table class instances which will be displayed in the GUI table of the list window. The filter and sorting preferences are also consindered.

Returns:
a vector filled with table class instances according to the current sorting and filter preferences.

createSpecializedToolBarListeners

protected abstract void createSpecializedToolBarListeners()
Creates listeners for the toolbar buttons editItem, newItem and deleteItem which provide the functionality of the buttons. These listeners opens edit windows or deleting dialogs and invoke the deleting or creating methods.


createSpecializedMainTableListener

protected abstract void createSpecializedMainTableListener()
Creates a DBTableChangedListener and adds it to the mainTableViewer.

This listener opens a editing window filled with the values of the selected GUI table entry on doubleclicking the entry.


createSpecializedMainTableListener

protected abstract void createSpecializedMainTableListener(AssociationTabControl caller)
This method creates two listener and adds them to the main table viewer.

The first one is a DBTableChangedListener which reacts on changes of the database table.
The second one is special DoubleClickListener according to the table class (e.g. Lecturer, Client) of the displayed data. This listener gets the selected entry and delivers its id to the AssociationTabControl instance which called the list window by invoking the method AssociationTabControl.addSelectedIds(semorg.sql.tables.SimpleIDKey[], boolean).

Parameters:
caller - the AssociationTabControl instance which called the actual list window

createSpecializedMainTableListener

protected abstract void createSpecializedMainTableListener(ForeignKeyConstraintSelector caller)
This method creates two listener and adds them to the main table viewer.

The first one is a DBTableChangedListener which reacts on changes of the database table.
The second one is special DoubleClickListener according to the table class (e.g. Lecturer, Client) of the displayed data. This listener gets the selected entry and delivers its id to the ForeignKeyConstraintSelector instance which called the list window by invoking the method ForeignKeyConstraintSelector.setSelectedId(int).

Parameters:
caller - the ForeignKeyConstraintSelector instance which called the actual list window

createChooseButtonListener

protected abstract void createChooseButtonListener(AssociationTabControl caller)
Creates a SelectionListener for the choose button which passes the SimpleIDKeys of the selected elements to the calling AssociationTabControl by invoking the method addSelectedIds of the caller instance.

Parameters:
caller - the AssociationTabControl instance which called the list window.
See Also:
AssociationTabControl.addSelectedIds(semorg.sql.tables.SimpleIDKey[], boolean)

createChooseButtonListener

protected abstract void createChooseButtonListener(ForeignKeyConstraintSelector caller)
Creates a SelectionListener for the choose button which passes the database id of the selected element to the calling ForeignKeyConstraintSelector by invoking the method setSelectedId of the caller instance.

Parameters:
caller - the ForeignKeyConstraintSelector instance which called the list window.
See Also:
ForeignKeyConstraintSelector.setSelectedId(int)