Class AbstractTableAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- adams.gui.action.AbstractBaseAction
-
- adams.gui.visualization.report.reportfactory.AbstractTableAction
-
- All Implemented Interfaces:
CleanUpHandler
,BaseAction
,ActionListener
,Serializable
,Cloneable
,EventListener
,Action
- Direct Known Subclasses:
AbstractTableActionWithDatabaseAccess
,AbstractTableActionWithDataContainerPanel
,AddField
,CopyFieldName
,CopyFieldValue
,ModifyValue
,PrintReport
,RemoveField
,SaveReport
,Separator
,ViewValue
public abstract class AbstractTableAction extends AbstractBaseAction
Ancestor for actions populating the popup menu of the Table class of theReportFactory
.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
KEY_FIELDS
the key for storing the fields in the action's hashtable.static String
KEY_ROWS
the key for storing the rows in the action's hashtable.static String
KEY_TABLE
the key for storing the table in the action's hashtable.static String
KEY_VALUES
the key for storing the values in the action's hashtable.static String
SEPARATOR
the placeholder for a separator in the popup menu.-
Fields inherited from class adams.gui.action.AbstractBaseAction
ASYNCHRONOUS
-
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
-
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
-
Constructor Summary
Constructors Constructor Description AbstractTableAction()
Defines anAbstractTableAction
object with a default description string and default icon.AbstractTableAction(String name)
Defines anAbstractTableAction
object with the specified description string and a default icon.AbstractTableAction(String name, String icon)
Defines anAbstractTableAction
object with the specified description string and a the specified icon.AbstractTableAction(String name, Icon icon)
Defines anAbstractTableAction
object with the specified description string and a the specified icon.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static String
createName(String prefix, AbstractField[] fields, int limit)
Creates a string for the menu based on the prefix and the fields.static BasePopupMenu
createPopup(String[] actions, ReportFactory.Table table, int[] rows)
Assembles the popup menu for the table.protected AbstractField[]
getFields()
Returns the currently selected fields in the table.protected AbstractReportFileChooser
getFileChooser()
Returns the underlying report file chooser.protected Report
getReport()
Returns the underlying report.protected ReportProvider<?,?>
getReportProvider()
Returns the underlying report provider.protected int[]
getRow()
Returns the currently selected rows in the table.protected ReportFactory.Table
getTable()
Returns the currently table.protected String[]
getValues()
Returns the currently selected values in the table.abstract boolean
isApplicable(ReportFactory.Table table, int row, AbstractField field, String value)
Checks whether the action is applicable and should be added to the popup menu.protected void
notifyReportChangeListeners()
Notifies the listeners that the report has changed.protected Boolean
parseBoolean(String s)
Parses a string as boolean.protected Double
parseDouble(String s)
Parses a string as double.protected void
setFields(AbstractField[] value)
Sets the fields to use.protected void
setReport(Report value)
Sets the underlying report.protected void
setRows(int[] value)
Sets the rows to use.protected void
setTable(ReportFactory.Table value)
Sets the table to use.protected void
setValues(String[] value)
Sets the values to use.-
Methods inherited from class adams.gui.action.AbstractBaseAction
actionPerformed, cleanUp, doActionPerformed, getAccelerator, getIcon, getMnemonic, getName, getToolTipText, hasAccelerator, hasIcon, hasMnemonic, hasToolTipText, initialize, isAsynchronous, isSelected, postActionPerformed, preActionPerformed, setAccelerator, setAsynchronous, setIcon, setIcon, setMnemonic, setName, setSelected, setToolTipText
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.swing.Action
accept, addPropertyChangeListener, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Field Detail
-
SEPARATOR
public static final String SEPARATOR
the placeholder for a separator in the popup menu.- See Also:
- Constant Field Values
-
KEY_TABLE
public static final String KEY_TABLE
the key for storing the table in the action's hashtable.- See Also:
- Constant Field Values
-
KEY_ROWS
public static final String KEY_ROWS
the key for storing the rows in the action's hashtable.- See Also:
- Constant Field Values
-
KEY_FIELDS
public static final String KEY_FIELDS
the key for storing the fields in the action's hashtable.- See Also:
- Constant Field Values
-
KEY_VALUES
public static final String KEY_VALUES
the key for storing the values in the action's hashtable.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractTableAction
public AbstractTableAction()
Defines anAbstractTableAction
object with a default description string and default icon.
-
AbstractTableAction
public AbstractTableAction(String name)
Defines anAbstractTableAction
object with the specified description string and a default icon.- Parameters:
name
- the description
-
AbstractTableAction
public AbstractTableAction(String name, Icon icon)
Defines anAbstractTableAction
object with the specified description string and a the specified icon.- Parameters:
name
- the descriptionicon
- the icon
-
-
Method Detail
-
setTable
protected void setTable(ReportFactory.Table value)
Sets the table to use.- Parameters:
value
- the table
-
getTable
protected ReportFactory.Table getTable()
Returns the currently table.- Returns:
- the table, null if not applicable
-
setRows
protected void setRows(int[] value)
Sets the rows to use.- Parameters:
value
- the rows
-
getRow
protected int[] getRow()
Returns the currently selected rows in the table.- Returns:
- the rows, null if not applicable
-
setFields
protected void setFields(AbstractField[] value)
Sets the fields to use.- Parameters:
value
- the fields
-
getFields
protected AbstractField[] getFields()
Returns the currently selected fields in the table.- Returns:
- the fields, null if not applicable
-
setValues
protected void setValues(String[] value)
Sets the values to use.- Parameters:
value
- the values
-
getValues
protected String[] getValues()
Returns the currently selected values in the table.- Returns:
- the values, null if not applicable
-
getReportProvider
protected ReportProvider<?,?> getReportProvider()
Returns the underlying report provider.- Returns:
- the report provider, null if not available
-
setReport
protected void setReport(Report value)
Sets the underlying report.- Parameters:
value
- the report to set
-
notifyReportChangeListeners
protected void notifyReportChangeListeners()
Notifies the listeners that the report has changed.
-
getReport
protected Report getReport()
Returns the underlying report.- Returns:
- the report, null if not available
-
getFileChooser
protected AbstractReportFileChooser getFileChooser()
Returns the underlying report file chooser.- Returns:
- the file chooser, null if not available
-
parseDouble
protected Double parseDouble(String s)
Parses a string as double. If parsing fails, an error dialog is popped up.- Parameters:
s
- the string to parse- Returns:
- the double or null in case of an error
-
parseBoolean
protected Boolean parseBoolean(String s)
Parses a string as boolean. If parsing fails, an error dialog is popped up.- Parameters:
s
- the string to parse- Returns:
- the boolean or null in case of an error
-
isApplicable
public abstract boolean isApplicable(ReportFactory.Table table, int row, AbstractField field, String value)
Checks whether the action is applicable and should be added to the popup menu.- Parameters:
table
- the table the popup menu is forrow
- the currently selected rowfield
- the field in the specified rowvalue
- the current value- Returns:
- true if the action is applicable, i.e., should be included in the popup menu
-
createPopup
public static BasePopupMenu createPopup(String[] actions, ReportFactory.Table table, int[] rows)
Assembles the popup menu for the table.- Parameters:
actions
- the classnames of the actions, "-" indicates a separatortable
- the table the popup menu is forrows
- the row(s) in the table this popup menu is for- Returns:
- the popup menu
- See Also:
SEPARATOR
-
createName
public static String createName(String prefix, AbstractField[] fields, int limit)
Creates a string for the menu based on the prefix and the fields.- Parameters:
prefix
- the prefix to use (separated by a blank from fields)fields
- the fieldslimit
- the maximum number of characters for the fields- Returns:
- the generated string
-
-