org.formaria.editor.netbeans.actions
Class CodeFragmentAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.formaria.editor.netbeans.actions.CodeFragmentAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action, AttributeEvaluator

public class CodeFragmentAction
extends javax.swing.AbstractAction
implements AttributeEvaluator

The action for the code fragments option

Copyright (c) Formaria Ltd., 2001-2006, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from Formaria.

$Revision: 1.8 $

See Also:
Serialized Form

Field Summary
 
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
CodeFragmentAction(EditorProject project, Page page, java.lang.String text, javax.swing.ImageIcon icon, java.lang.String desc, java.lang.Integer mnemonic)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 java.lang.Object evaluateAttribute(java.lang.Object instance, java.lang.String attributeValue)
          Get the value of an attribute.
 MethodReference getMethodReference(java.lang.Object instance, java.lang.String attributeValue)
          Get the value of an attribute by evaluating a method reference
 MethodReference getMethodReference(java.lang.String attributeValue)
          Get the method reference for the methods named in the attribute
 java.lang.Object getResult()
          Explicitly get the result of an evaluation.
 void setCurrentProject(Project project)
          Set the current project and complete any initialization that depends on the project reference/instance.
 void setExceptionHandler(ExceptionHandler eh)
          Set an exception handler for processing exceptions
 void setResult(java.lang.Object value)
          Explicitly set the result of an evaluation.
 
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
 

Constructor Detail

CodeFragmentAction

public CodeFragmentAction(EditorProject project,
                          Page page,
                          java.lang.String text,
                          javax.swing.ImageIcon icon,
                          java.lang.String desc,
                          java.lang.Integer mnemonic)
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

evaluateAttribute

public java.lang.Object evaluateAttribute(java.lang.Object instance,
                                          java.lang.String attributeValue)
Get the value of an attribute.

Specified by:
evaluateAttribute in interface AttributeEvaluator
Parameters:
page - the page being loaded
attributeValue - the raw value of the attribute
Returns:
the evaluated value of the attribute

setCurrentProject

public void setCurrentProject(Project project)
Set the current project and complete any initialization that depends on the project reference/instance.

Specified by:
setCurrentProject in interface AttributeEvaluator
Parameters:
project - the current or owning project

getMethodReference

public MethodReference getMethodReference(java.lang.String attributeValue)
Get the method reference for the methods named in the attribute

Specified by:
getMethodReference in interface AttributeEvaluator
Parameters:
attributeValue - the method name
Returns:
the method reference or null if the referenced/named method cannot be found

getMethodReference

public MethodReference getMethodReference(java.lang.Object instance,
                                          java.lang.String attributeValue)
Get the value of an attribute by evaluating a method reference

Specified by:
getMethodReference in interface AttributeEvaluator
Parameters:
page - the current page
attributeValue - the method name
Returns:
the method reference or null if the referenced/named method cannot be found

setResult

public void setResult(java.lang.Object value)
Explicitly set the result of an evaluation. This method may be used by an exception handler to override the result and set a sensible value in case of an exception

Specified by:
setResult in interface AttributeEvaluator
Parameters:
the - new result value

getResult

public java.lang.Object getResult()
Explicitly get the result of an evaluation. This method may be used by an exception handler to determine the result and set a sensible value in case of an exception

Specified by:
getResult in interface AttributeEvaluator
Returns:
the current/intermediate result value

setExceptionHandler

public void setExceptionHandler(ExceptionHandler eh)
Set an exception handler for processing exceptions

Specified by:
setExceptionHandler in interface AttributeEvaluator
Parameters:
eh - the exception handler