com.objexcel.gui
Class ObjexcelAbstractAction

java.lang.Object
  |
  +--javax.swing.AbstractAction
        |
        +--com.objexcel.gui.ObjexcelAbstractAction

public abstract class ObjexcelAbstractAction
extends javax.swing.AbstractAction

ObjexcelAbstractAction extends AbstractAction by adding

accelerator property, mnemonic property for buttons tooltips common rules can be used enable/disable ObjexcelAbstractAction allows one action to have many gui elements associated with it. ObjexcelAbstractAction allows creation of JMenuItems, JButton, a rollover toolbar suitable button. The text, icon, enable/disablement state of the action will be automatically reflected in all components created from it.

See Also:
Serialized Form

Inner Class Summary
 class ObjexcelAbstractAction.ObjDocumentListener
          add one of these to update these to your text component if the action's status depends on the contents of the a document changes
 class ObjexcelAbstractAction.ObjTableModelListener
          add one of these to a model to trigger an update based on a selection changing
static class ObjexcelAbstractAction.Rule
          Rule allows common logic to be shared accross actions.
 
Field Summary
static java.lang.String ACCELERATOR
          Property for keystroke accelerator
static java.lang.String MNEMONIC
          Property for changing mnemonic
 
Constructor Summary
ObjexcelAbstractAction()
           
ObjexcelAbstractAction(java.lang.String name)
           
ObjexcelAbstractAction(java.lang.String name, javax.swing.Icon i)
           
ObjexcelAbstractAction(java.lang.String name, javax.swing.Icon i, java.lang.String shortDescription)
          the short description is the default tool tip.
ObjexcelAbstractAction(java.lang.String name, javax.swing.Icon i, java.lang.String shortDescription, char mnemonic, javax.swing.KeyStroke keystroke)
          provide a mnemonic and keystroke accelerator for any controls created from this action.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          we handle this method, you handle actionPerformed2
abstract  void actionPerformed2(java.awt.event.ActionEvent e)
          subclass needs to implement this.
 void addRule(ObjexcelAbstractAction.Rule rule)
          if an action has a rule, the rule will be checked before isEnabled is checked.
 javax.swing.JButton createButton()
           
 javax.swing.JButton createButton(boolean bForToolbar)
           
 javax.swing.JMenuItem createMenuItem()
          create a menu item from this action
 javax.swing.JButton createToolbarButton()
          create a rollover button without borders.
static void paintLoweredBevel(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
           
static void paintRaisedBevel(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
           
 boolean resetTooltip()
          put the tooltip back to its original (short description per constructor)
 void updateStatus()
          update the status of the action.
 boolean updateStatus(boolean b, java.lang.String tooltip)
          set the enablement state of action.
 void updateStatusOnListSelectionChange(javax.swing.JList l)
          call this to update the command when the list selection on the specified list changes
 void updateStatusOnTableChanged(javax.swing.JTable t)
          call this to update the status when the table changes
 void updateStatusOnTableChanged(javax.swing.text.JTextComponent t)
          call this to update the status when the document changes
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MNEMONIC

public static final java.lang.String MNEMONIC
Property for changing mnemonic

ACCELERATOR

public static final java.lang.String ACCELERATOR
Property for keystroke accelerator
Constructor Detail

ObjexcelAbstractAction

public ObjexcelAbstractAction()

ObjexcelAbstractAction

public ObjexcelAbstractAction(java.lang.String name)

ObjexcelAbstractAction

public ObjexcelAbstractAction(java.lang.String name,
                              javax.swing.Icon i)

ObjexcelAbstractAction

public ObjexcelAbstractAction(java.lang.String name,
                              javax.swing.Icon i,
                              java.lang.String shortDescription)
the short description is the default tool tip.

ObjexcelAbstractAction

public ObjexcelAbstractAction(java.lang.String name,
                              javax.swing.Icon i,
                              java.lang.String shortDescription,
                              char mnemonic,
                              javax.swing.KeyStroke keystroke)
provide a mnemonic and keystroke accelerator for any controls created from this action.
Method Detail

resetTooltip

public boolean resetTooltip()
put the tooltip back to its original (short description per constructor)

actionPerformed2

public abstract void actionPerformed2(java.awt.event.ActionEvent e)
subclass needs to implement this. This class will call it from actionPerformed

updateStatus

public void updateStatus()
update the status of the action. Checks any rule associated with this action. Calls its isEnabledMethod.

addRule

public void addRule(ObjexcelAbstractAction.Rule rule)
if an action has a rule, the rule will be checked before isEnabled is checked. This allows common logic to be put into one place and shared between actions.

updateStatus

public boolean updateStatus(boolean b,
                            java.lang.String tooltip)
set the enablement state of action. Set the tooltip also (perhaps to indicate why the action is diabled.

actionPerformed

public final void actionPerformed(java.awt.event.ActionEvent e)
we handle this method, you handle actionPerformed2
Overrides:
actionPerformed in class javax.swing.AbstractAction

createButton

public javax.swing.JButton createButton()

createToolbarButton

public javax.swing.JButton createToolbarButton()
create a rollover button without borders.

paintRaisedBevel

public static void paintRaisedBevel(java.awt.Component c,
                                    java.awt.Graphics g,
                                    int x,
                                    int y,
                                    int width,
                                    int height)

paintLoweredBevel

public static void paintLoweredBevel(java.awt.Component c,
                                     java.awt.Graphics g,
                                     int x,
                                     int y,
                                     int width,
                                     int height)

createButton

public javax.swing.JButton createButton(boolean bForToolbar)

createMenuItem

public javax.swing.JMenuItem createMenuItem()
create a menu item from this action

updateStatusOnListSelectionChange

public void updateStatusOnListSelectionChange(javax.swing.JList l)
call this to update the command when the list selection on the specified list changes

updateStatusOnTableChanged

public void updateStatusOnTableChanged(javax.swing.JTable t)
call this to update the status when the table changes

updateStatusOnTableChanged

public void updateStatusOnTableChanged(javax.swing.text.JTextComponent t)
call this to update the status when the document changes