org.tentackle.ui
Class FormTableUtilityPopup

java.lang.Object
  extended by org.tentackle.ui.FormTableUtilityPopup
All Implemented Interfaces:
KeyListener, MouseListener, EventListener

public class FormTableUtilityPopup
extends Object
implements MouseListener, KeyListener

A utility popup menu to allow a FormTable to be printed, converted to excel, find an item in the table, set/get the preferences, size, columns, etc... The popup-Menu will be triggered by pressing the right-mouse button (using isPopupTrigger()) somewhere in the header of the table (by default).

Author:
harald

Constructor Summary
FormTableUtilityPopup(FormTable table)
          Creates a popup menu for a given table.
Listeners will be registered, default title and table.
FormTableUtilityPopup(FormTable table, boolean registerListeners, String title, String intro)
          Creates a popup menu for a given table.
FormTableUtilityPopup(FormTable table, String title, String intro)
          Creates a popup menu for a given table.
Listeners will be registered.
 
Method Summary
 void addKeyListener()
          Adds the default key listener for KeyEvent.VK_F3.
 void addKeyListenerForKey(int keyCode)
          Adds a key listener for a given keycode.
 void addMouseListenerForTable()
          Adds a mouse listener to the whole table (including the header) for this popup.
 void addMouseListenerForTableHeader()
          Adds a mouse listener only to the table header for this popup.
 void excel(File file, boolean onlySelected)
          Converts the table to an excel spreadsheet.
 String getIntro()
          Gets the intro text.
 String getTitle()
          Gets the title.
 boolean isColumnMenuEnabled()
          Returns whether the column menu is enabled.
 void keyPressed(KeyEvent e)
          Invoked when a key has been pressed.
 void keyReleased(KeyEvent e)
          Invoked when a key has been released.
 void keyTyped(KeyEvent e)
          Invoked when a key has been typed.
 void mouseClicked(MouseEvent e)
          Invoked when the mouse button has been clicked (pressed and released) on a component.
 void mouseEntered(MouseEvent e)
          Invoked when the mouse enters a component.
 void mouseExited(MouseEvent e)
          Invoked when the mouse exits a component.
 void mousePressed(MouseEvent e)
          Invoked when a mouse button has been pressed on a component.
 void mouseReleased(MouseEvent e)
          Invoked when a mouse button has been released on a component.
 void removeKeyListener()
          Removes the key listener.
 void removeMouseListenerForTable()
          Removes the table mouse listener for this popup.
 void removeMouseListenerForTableHeader()
          Removes the table header mouse listener for this popup.
 void restoreSettings(boolean system)
          Restores the tables default settings from the Preferences.
 void saveSettings(boolean system)
          Saves the table settings to the Preferences.
 boolean search(String searchText, boolean caseSensitive)
          Searches for a text starting at the current cell.
 void setColumnMenuEnabled(boolean columnMenuEnabled)
          Enables or disables the column menu.
The column menu allows to set the visibility of columns.
 void setIntro(String intro)
          Sets the intro-text.
The intro will be printed on the first page and shown in excel sheets.
 void setTitle(String title)
          Sets the title.
The title will be printed pn each page and shown in excel sheets.
 void showExcelDialog(boolean onlySelected)
          Opens a dialog to export a table to an excel sheet.
 void showPrintDialog()
          Prints the table.
 void showSearchDialog()
          Opens a dialog to search in a table starting at the current cell.
 void showXmlDialog(boolean onlySelected)
          Opens a dialog to export a table to an XML file.
 void uninstall()
          Uninstalls the popup from a table
 void xml(File file, boolean onlySelected)
          Exports a table to an XML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormTableUtilityPopup

public FormTableUtilityPopup(FormTable table,
                             boolean registerListeners,
                             String title,
                             String intro)
Creates a popup menu for a given table.

Parameters:
table - the formtable
registerListeners - true if register the mouse- and keyboard listeners
title - the table title, null if default
intro - the table intro, null if default

FormTableUtilityPopup

public FormTableUtilityPopup(FormTable table,
                             String title,
                             String intro)
Creates a popup menu for a given table.
Listeners will be registered.

Parameters:
table - the formtable
title - the table title, null if default
intro - the table intro, null if default

FormTableUtilityPopup

public FormTableUtilityPopup(FormTable table)
Creates a popup menu for a given table.
Listeners will be registered, default title and table. This is the standard constructor applications should use.

Parameters:
table - the formtable
Method Detail

uninstall

public void uninstall()
Uninstalls the popup from a table


setTitle

public void setTitle(String title)
Sets the title.
The title will be printed pn each page and shown in excel sheets.

Parameters:
title - the title, null if default from window

getTitle

public String getTitle()
Gets the title.

Returns:
the title, null if default from window

setIntro

public void setIntro(String intro)
Sets the intro-text.
The intro will be printed on the first page and shown in excel sheets.

Parameters:
intro - the intro, null = none

getIntro

public String getIntro()
Gets the intro text.

Returns:
the intro, null = none

isColumnMenuEnabled

public boolean isColumnMenuEnabled()
Returns whether the column menu is enabled.

Returns:
true if column menu is enabled

setColumnMenuEnabled

public void setColumnMenuEnabled(boolean columnMenuEnabled)
Enables or disables the column menu.
The column menu allows to set the visibility of columns.

Parameters:
columnMenuEnabled - true to enable column menu (default)

saveSettings

public void saveSettings(boolean system)
Saves the table settings to the Preferences.

Parameters:
system - is true if save to systemRoot, else userRoot

restoreSettings

public void restoreSettings(boolean system)
Restores the tables default settings from the Preferences.

Parameters:
system - is true if load ONLY from systemRoot, else try userRoot first (should be default)

search

public boolean search(String searchText,
                      boolean caseSensitive)
Searches for a text starting at the current cell.

Parameters:
searchText - the search text
caseSensitive - true if case sensitive
Returns:
true if found

showSearchDialog

public void showSearchDialog()
Opens a dialog to search in a table starting at the current cell.


showPrintDialog

public void showPrintDialog()
Prints the table.


excel

public void excel(File file,
                  boolean onlySelected)
           throws IOException
Converts the table to an excel spreadsheet.

Parameters:
file - the output file
onlySelected - true if export only selected rows
Throws:
IOException - if export failed

showExcelDialog

public void showExcelDialog(boolean onlySelected)
Opens a dialog to export a table to an excel sheet.

Parameters:
onlySelected - true if export only selected rows

xml

public void xml(File file,
                boolean onlySelected)
         throws IOException,
                TransformerConfigurationException,
                SAXException
Exports a table to an XML file.

Parameters:
file - the output file
onlySelected - true if export only selected rows
Throws:
IOException
TransformerConfigurationException
SAXException

showXmlDialog

public void showXmlDialog(boolean onlySelected)
Opens a dialog to export a table to an XML file.

Parameters:
onlySelected - true if export only selected rows

addMouseListenerForTableHeader

public void addMouseListenerForTableHeader()
Adds a mouse listener only to the table header for this popup. The listener will open the popup menu on a right click. Used if there the table body needs another listener.


removeMouseListenerForTableHeader

public void removeMouseListenerForTableHeader()
Removes the table header mouse listener for this popup.


addMouseListenerForTable

public void addMouseListenerForTable()
Adds a mouse listener to the whole table (including the header) for this popup. The listener will open the popup menu on a right click.


removeMouseListenerForTable

public void removeMouseListenerForTable()
Removes the table mouse listener for this popup.


mouseClicked

public void mouseClicked(MouseEvent e)
Description copied from interface: java.awt.event.MouseListener
Invoked when the mouse button has been clicked (pressed and released) on a component.

Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Description copied from interface: java.awt.event.MouseListener
Invoked when the mouse enters a component.

Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Description copied from interface: java.awt.event.MouseListener
Invoked when the mouse exits a component.

Specified by:
mouseExited in interface MouseListener

mousePressed

public void mousePressed(MouseEvent e)
Description copied from interface: java.awt.event.MouseListener
Invoked when a mouse button has been pressed on a component.

Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
Description copied from interface: java.awt.event.MouseListener
Invoked when a mouse button has been released on a component.

Specified by:
mouseReleased in interface MouseListener

addKeyListenerForKey

public void addKeyListenerForKey(int keyCode)
Adds a key listener for a given keycode.

Parameters:
keyCode - the keycode

addKeyListener

public void addKeyListener()
Adds the default key listener for KeyEvent.VK_F3. Pressing this key will start the search dialog or continue the search.


removeKeyListener

public void removeKeyListener()
Removes the key listener.


keyPressed

public void keyPressed(KeyEvent e)
Description copied from interface: java.awt.event.KeyListener
Invoked when a key has been pressed. See the class description for KeyEvent for a definition of a key pressed event.

Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent e)
Description copied from interface: java.awt.event.KeyListener
Invoked when a key has been released. See the class description for KeyEvent for a definition of a key released event.

Specified by:
keyReleased in interface KeyListener

keyTyped

public void keyTyped(KeyEvent e)
Description copied from interface: java.awt.event.KeyListener
Invoked when a key has been typed. See the class description for KeyEvent for a definition of a key typed event.

Specified by:
keyTyped in interface KeyListener


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de