Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## hibergui
Class Form<T>

    java.lang.Object
      hibergui.Component<T>
          hibergui.Form<T>

Type Parameters:
  `T` - The type of the business object edited by the form.

Direct Known Subclasses:
  HibernateForm

    public abstract class Form<T>

extends Component<T>

Common superclass of HiberGUI forms. Using forms business logic entities of type T can be created, deleted, updated or searched for. The individual properties of the entities are handled by edits. Forms have three parts. Edits are on the top of the form, they are created by the createFields method. Below the edits there are four buttons: create, delete, clear and search. The third part of forms is the selector table. It is visible only in search mode. It can be used for selecting one or more business entity.

Author:
  Miklós Espák

Field Summary
`private org.eclipse.swt.widgets.Button` | `btnClear`
`private org.eclipse.swt.widgets.Button` | `btnCreate`
`private org.eclipse.swt.widgets.Button` | `btnDelete`
`private org.eclipse.swt.widgets.Button` | `btnSearchMode`
`private java.util.Map<org.eclipse.swt.widgets.TableColumn,java.lang.String>` | `columnProperties`
`private boolean` | `dirty`
`protected java.util.List<Edit<?>>` | `fieldEditors`
`private boolean` | `hasChanged`
`private ModificationListener` | `lsnDirty`
`private org.eclipse.jface.viewers.ISelectionChangedListener` | `lsnSelection`
`private ChangeListener` | `lsnUpdate`
`private java.lang.String` | `message`
`private java.util.List<MessageListener>` | `messageListeners`
`private int` | `messageType`
`protected java.lang.Class<T>` | `persistentClass` The class representing the type parameter of the form.
`private boolean` | `searchMode`
`private org.eclipse.jface.viewers.IStructuredSelection` | `selection`
`private org.eclipse.swt.widgets.Table` | `tbl`
`private org.eclipse.jface.viewers.TableViewer` | `tbvSelector`
`private java.lang.String` | `title`
`private T` | `value` The actual business object selected by the form.

Fields inherited from class hibergui.Component
`lsn_WIDGET_FOCUS, lsn_WIDGET_KEY, style`

Constructor Summary
`Form(org.eclipse.swt.widgets.Composite cptParent, int style)` Constructs a form.

Method Summary
`private void` | `addChangeListeners(ChangeListener listener)`
`protected void` | `addColumn(int mode, java.lang.String prop, java.lang.String name, int width)` Helper method for customizing the columns of the selector table.
`(package private) void` | `addEdit(Edit<?> edit)`
`void` | `addMessageListener(MessageListener listener)`
`private void` | `addModificationListeners(ModificationListener listener)`
`void` | `apply()` Applies the recent changes and refreshes the form.
`private void` | `clear()` Clears the edits of the form and clears the selection from the selector table when search mode is on.
`protected abstract void` | `commit()` Commits the recent changes on the storage.
`protected void` | `create()` Creates a business entity by extracting the values typed into the form and then saves the entity to the storage.
`protected org.eclipse.swt.widgets.Composite` | `createButtons(org.eclipse.swt.widgets.Composite cptParent)` Creates the composite containing the control buttons of the form.
`protected abstract void` | `createColumnsForTable()` Creates the columns of the table.
`protected org.eclipse.swt.widgets.Composite` | `createContents(org.eclipse.swt.widgets.Composite cptParent)` Creates the GUI contents of the component.
`protected abstract org.eclipse.swt.widgets.Composite` | `createFields(org.eclipse.swt.widgets.Composite cptParent)` Creates the composite containing the edits of the form.
`private org.eclipse.jface.viewers.TableViewer` | `createSelector(org.eclipse.swt.widgets.Table tbl)`
`protected org.eclipse.swt.widgets.Table` | `createTable(org.eclipse.swt.widgets.Composite cptParent)` Creates the table using which some business entities found in search mode can be selected.
`protected void` | `delete()` Deletes the selected business entities from the storage and removes them from the selector table as well.
`protected abstract void` | `delete(T entity)` Deletes the business entity from the storage.
`protected void` | `dispose()` Disposes the edits of the form.
`protected T` | `extract()` Creates a new business entity and assigns the value filled into the edits to the corresponding properties of the entity.
`void` | `extract(T t)` Extracts the values of the edits of the form and assigns them to the corresponding properties of the entity.
`
`<P> void`
` | `fill(java.lang.String property, P value)` Fills some property of the entity into the corresponding edit of the form.
`void` | `fill(T t)` Fills each property of the entity into the corresponding edits of the form.
`protected abstract java.util.List<T>` | `findSuch()` Finds business entities similar to the entity extracted from the form.
`private void` | `fireMessageChanged(java.lang.String message, int type)`
`private void` | `fireTitleChanged(java.lang.String title)`
`T` | `get()` If the the form is in search mode and one entity is selected then returns that entity.
`protected java.lang.String` | `getColumnText(T t, int i)`
`T[]` | `getSelection()` Returns an array of business entities selected in the selector table.
`protected int` | `getSortDirection()`
`protected java.lang.String` | `getSortProperty()`
`boolean` | `hasChanged()`
`private void` | `hideSelector()`
`protected void` | `init()` Initializes the component.
`boolean` | `isDirty()`
`boolean` | `isSearchMode()` Returns whether the search mode is on.
`protected void` | `modify()` Modifies the selected or actual entity of the form.
`void` | `refresh()` Refreshes the form.
`void` | `refreshSelector()` Refreshes the selector table.
`private void` | `removeChangeListeners(ChangeListener listener)`
`void` | `removeMessageListener(MessageListener listener)`
`private void` | `removeModificationListeners(ModificationListener listener)`
`void` | `revoke()` Revokes the recent changes and refreshes the form.
`protected abstract void` | `rollback()` Rolls back the recent changes on the storage.
`protected abstract void` | `save(T entity)` Saves the business entity onto the storage.
`void` | `set(T newValue)` Sets the actual entity of the form.
`boolean` | `setFocus()`
`void` | `setMessage(java.lang.String message)`
`protected void` | `setMessage(java.lang.String message, int type)`
`void` | `setSearchMode(boolean b)` Switches search mode on or off.
`private void` | `setTitle(java.lang.String title)`
`protected void` | `setWindowTitle(java.lang.String windowTitle)` Sets the title of the window containing the form.
`private void` | `showSelector()`
`protected abstract void` | `update(T entity)` Updates the business entity on the storage.
`void` | `verify()`

Methods inherited from class hibergui.Component
`addChangeListener, addControlListener, addFocusListener, addKeyListener, fireChange, fireKeyPressed, fireKeyReleased, getControl, removeChangeListener, removeControlListener, removeFocusListener, removeKeyListener, setLayoutData`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### value

    private T value

  The actual business object selected by the form.

### selection

    private org.eclipse.jface.viewers.IStructuredSelection selection

### persistentClass

    protected final java.lang.Class<T> persistentClass

  The class representing the type parameter of the form.

### title

    private java.lang.String title

### message

    private java.lang.String message

### messageType

    private int messageType

### btnCreate

    private org.eclipse.swt.widgets.Button btnCreate

### btnDelete

    private org.eclipse.swt.widgets.Button btnDelete

### btnSearchMode

    private org.eclipse.swt.widgets.Button btnSearchMode

### btnClear

    private org.eclipse.swt.widgets.Button btnClear

### tbl

    private org.eclipse.swt.widgets.Table tbl

### columnProperties

    private java.util.Map<org.eclipse.swt.widgets.TableColumn,java.lang.String> columnProperties

### tbvSelector

    private org.eclipse.jface.viewers.TableViewer tbvSelector

### fieldEditors

    protected java.util.List<Edit<?>> fieldEditors

### dirty

    private boolean dirty

### hasChanged

    private boolean hasChanged

### searchMode

    private boolean searchMode

### lsnUpdate

    private final ChangeListener lsnUpdate

### lsnDirty

    private final ModificationListener lsnDirty

### lsnSelection

    private org.eclipse.jface.viewers.ISelectionChangedListener lsnSelection

### messageListeners

    private java.util.List<MessageListener> messageListeners

Constructor Detail

### Form

    public Form(org.eclipse.swt.widgets.Composite cptParent,
                int style)

  Constructs a form.

  Parameters:
    `cptParent` - The composite which the form will be placed on. The parent of the control of the form.
    `style` - The style of the form. It is a combination of constants defined in hibergui.HiberGUI.

Method Detail

### init

    protected void init()

  Description copied from class: `Component`
  Initializes the component. Initialization is done before creating the GUI contents of the component.

  Overrides:
    `init` in class `Component<T>`

### dispose

    protected void dispose()

  Disposes the edits of the form.

  Overrides:
    `dispose` in class `Component<T>`
  See Also:
    `Component.dispose()`

### addEdit

    void addEdit(Edit<?> edit)

### createContents

    protected org.eclipse.swt.widgets.Composite createContents(org.eclipse.swt.widgets.Composite cptParent)

  Description copied from class: `Component`
  Creates the GUI contents of the component. Subclasses should override it.

  Specified by:
    `createContents` in class `Component<T>`
  Parameters:
    `cptParent` - The composite which the component will be placed on. The parent of the control of the component.
  Returns:
    The control of the component containing its GUI elements.

### createFields

    protected abstract org.eclipse.swt.widgets.Composite createFields(org.eclipse.swt.widgets.Composite cptParent)

  Creates the composite containing the edits of the form. Subclasses should override it. The created composite will appear on the top part or the form.

  Parameters:
    `cptParent` - The composite which the composite of the edits should be placed on.
  Returns:
    The composite containing the edits.

### createButtons

    protected org.eclipse.swt.widgets.Composite createButtons(org.eclipse.swt.widgets.Composite cptParent)

  Creates the composite containing the control buttons of the form. Subclasses should override it. The created composite will appear below the edits. There are four buttons on the created composite:
  - Create: creates a business entity from the values typed into edits. The created object will be the actual entity of the form.
  - Delete: deletes the actual entity from the storage. The actual entity will be null.
  - Clear: clears the fields of the form.
  - Search: toggle button to switch search mode on/off.

  Parameters:
    `cptParent` - The composite which the composite of the buttons should be placed on.
  Returns:
    The composite containing the edits.

### createTable

    protected final org.eclipse.swt.widgets.Table createTable(org.eclipse.swt.widgets.Composite cptParent)

  Creates the table using which some business entities found in search mode can be selected. The columns of the table are created by the createColumsForTable method. Subclasses should override that method to customize the selector table.

  Parameters:
    `cptParent` - The composite which the composite of the edits should be placed on.
  Returns:
    The table containing the edits.

### addColumn

    protected void addColumn(int mode,
                             java.lang.String prop,
                             java.lang.String name,
                             int width)

  Helper method for customizing the columns of the selector table. Subclasses need not override it.

  Parameters:
    `mode` - Mode (e.g. alignment)
    `prop` - The property of the entity showed in the column.
    `name` - The name of the column visible on its top.
    `width` - The width of the column in pixels.

### createColumnsForTable

    protected abstract void createColumnsForTable()

  Creates the columns of the table. Subclasses should override it and invoke addColumn for the required properties.

### createSelector

    private org.eclipse.jface.viewers.TableViewer createSelector(org.eclipse.swt.widgets.Table tbl)

### getSortProperty

    protected final java.lang.String getSortProperty()

### getSortDirection

    protected final int getSortDirection()

### getColumnText

    protected java.lang.String getColumnText(T t,
                                             int i)

### get

    public final T get()

  If the the form is in search mode and one entity is selected then returns that entity. Otherwise it returns the actual entity of the form.

  Returns:
    The entity selected in the table or the actual entity of the form.

### set

    public void set(T newValue)

  Sets the actual entity of the form. If the form was in search mode then it will be switched off. Finally, the method fires a ChangeEvent.

  Parameters:
    `newValue` - The new actual entity of the form.

### refresh

    public void refresh()

  Refreshes the form. If the form has an actual entity, edits will be filled by its properties. Otherwise, edits will be cleared. In search mode the selector table will also be refreshed.

### refreshSelector

    public void refreshSelector()

  Refreshes the selector table.

### fill

    public void fill(T t)

  Fills each property of the entity into the corresponding edits of the form. In contrast with the set method, this will not make its argument to the actual object of the form.

  Parameters:
    `t` - The entity which should be filled into the form.

### fill

    public <P> void fill(java.lang.String property,
                         P value)

  Fills some property of the entity into the corresponding edit of the form.

  Type Parameters:
    `P` - The type of the property.
  Parameters:
    `property` - The name of the property.
    `value` - The value of the property.

### extract

    public void extract(T t)

  Extracts the values of the edits of the form and assigns them to the corresponding properties of the entity.

  Parameters:
    `t` -

### extract

    protected T extract()

  Creates a new business entity and assigns the value filled into the edits to the corresponding properties of the entity. Informally, it does something like this using reflection (unfortunately, generic parameter types cannot be instantiated): public T extract() { T t = new T(); extract(t); return t; } It may be overridden for performance reasons but leaving it unchanged is always a safe solution.

### apply

    public void apply()

  Applies the recent changes and refreshes the form.

### revoke

    public void revoke()

  Revokes the recent changes and refreshes the form.

### create

    protected void create()

  Creates a business entity by extracting the values typed into the form and then saves the entity to the storage. Finally, it sets the entity as the actual entity of the form. In case of failure the operation will be revoked.

### modify

    protected void modify()

  Modifies the selected or actual entity of the form. The entity gets the property values of the business entity extracted from the values typed into the form. The entity will be updated on the storage. Finally, it refreshes the selector table. In case of failure the operation will be revoked.

### delete

    protected void delete()

  Deletes the selected business entities from the storage and removes them from the selector table as well. Finally, it sets null as the actual entity of the form. In case of failure the operation will be revoked.

### clear

    private final void clear()

  Clears the edits of the form and clears the selection from the selector table when search mode is on.

### commit

    protected abstract void commit()
                            throws java.lang.Exception

  Commits the recent changes on the storage.

  Throws:
    `java.lang.Exception`

### rollback

    protected abstract void rollback()
                              throws java.lang.Exception

  Rolls back the recent changes on the storage.

  Throws:
    `java.lang.Exception`

### save

    protected abstract void save(T entity)
                          throws java.lang.Exception

  Saves the business entity onto the storage.

  Parameters:
    `entity` - the business entity to be saved
  Throws:
    `java.lang.Exception`

### update

    protected abstract void update(T entity)
                            throws java.lang.Exception

  Updates the business entity on the storage.

  Parameters:
    `entity` - the business entity to be updated
  Throws:
    `java.lang.Exception`

### delete

    protected abstract void delete(T entity)
                            throws java.lang.Exception

  Deletes the business entity from the storage.

  Parameters:
    `entity` - the business entity to be deleted
  Throws:
    `java.lang.Exception`

### findSuch

    protected abstract java.util.List<T> findSuch()
                                           throws java.lang.Exception

  Finds business entities similar to the entity extracted from the form.

  Returns:
  Throws:
    `java.lang.Exception`

### setFocus

    public boolean setFocus()

  Specified by:
    `setFocus` in class `Component<T>`

### addChangeListeners

    private void addChangeListeners(ChangeListener listener)

### removeChangeListeners

    private void removeChangeListeners(ChangeListener listener)

### isDirty

    public final boolean isDirty()

### addModificationListeners

    private void addModificationListeners(ModificationListener listener)

### removeModificationListeners

    private void removeModificationListeners(ModificationListener listener)

### hasChanged

    public final boolean hasChanged()

### addMessageListener

    public void addMessageListener(MessageListener listener)

### removeMessageListener

    public void removeMessageListener(MessageListener listener)

### fireTitleChanged

    private void fireTitleChanged(java.lang.String title)

### setTitle

    private void setTitle(java.lang.String title)

### fireMessageChanged

    private void fireMessageChanged(java.lang.String message,
                                    int type)

### setMessage

    protected void setMessage(java.lang.String message,
                              int type)

### setMessage

    public void setMessage(java.lang.String message)

### getSelection

    public T[] getSelection()

  Returns an array of business entities selected in the selector table.

  Returns:
    the selected business entities

### verify

    public void verify()

### showSelector

    private void showSelector()

### hideSelector

    private void hideSelector()

### setSearchMode

    public void setSearchMode(boolean b)

  Switches search mode on or off.

  Parameters:
    `b` - When true, search mode will be switched on, otherwise off.

### isSearchMode

    public boolean isSearchMode()

  Returns whether the search mode is on.

  Returns:
    the state of the search mode

### setWindowTitle

    protected final void setWindowTitle(java.lang.String windowTitle)

  Sets the title of the window containing the form.

  Parameters:
    `windowTitle` - the new window title

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD