visad
Class ActionImpl

java.lang.Object
  extended by visad.ActionImpl
All Implemented Interfaces:
java.lang.Runnable, java.util.EventListener, Action, ThingChangedListener
Direct Known Subclasses:
CellImpl, DisplayImpl, FormulaVar

public abstract class ActionImpl
extends java.lang.Object
implements Action, java.lang.Runnable

ActionImpl is the abstract superclass for runnable threads that need to be notified when ThingReference objects change. For example, this may be used for a Data display or for a spreadsheet cell.

ActionImpl is not Serializable and should not be copied between JVMs.


Constructor Summary
ActionImpl(java.lang.String name)
           
 
Method Summary
 void addReference(ThingReference ref)
          Creates a link to a ThingReference.
 boolean checkTicks()
           
 void disableAction()
          disable this Action and if necessary wait for end of doAction
abstract  void doAction()
           
 void enableAction()
          enable and notify this Action
 ReferenceActionLink findReference(ThingReference ref)
          Returns the link associated with a ThingReference.
 java.lang.Thread getCurrentActionThread()
           
 java.util.Vector getLinks()
          return vector of ReferenceActionLink-s
 java.lang.String getName()
          return name of this Action
 void removeAllReferences()
          remove all ThingReferences
 void removeReference(ThingReference ref)
          Removes a link to a ThingReference.
 void run()
          code executed by a thread to manage updates to the corresponding Thing
 boolean setEnabled(boolean enable)
          Set the "enabled" state of this action.
 void setName(java.lang.String name)
          change name of this Action
static void setThreadPoolMaximum(int num)
          increase the maximum number of threads allowed for the thread pool
 void stop()
           
static void stopThreadPool()
          destroy all threads after they've drained the job queue
 boolean thingChanged(ThingChangedEvent e)
           
 void waitForTasks()
          wait for currently-running actions to finish
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionImpl

public ActionImpl(java.lang.String name)
Method Detail

stopThreadPool

public static void stopThreadPool()
destroy all threads after they've drained the job queue


setThreadPoolMaximum

public static void setThreadPoolMaximum(int num)
                                 throws java.lang.Exception
increase the maximum number of threads allowed for the thread pool

Throws:
java.lang.Exception

stop

public void stop()

checkTicks

public boolean checkTicks()

enableAction

public void enableAction()
enable and notify this Action


disableAction

public void disableAction()
disable this Action and if necessary wait for end of doAction


setEnabled

public boolean setEnabled(boolean enable)
Set the "enabled" state of this action. This may be used in code like the following to ensure that the action has the same "enabled" state on leaving the code as it did on entering it:

 ActionImpl action = ...;
 boolean wasEnabled = action.setEnabled(false);
 ...
 action.setEnabled(wasEnabled);
 

Parameters:
enable - The new "enabled" state for this action.
Returns:
The previous "enabled" state of this action.

getCurrentActionThread

public java.lang.Thread getCurrentActionThread()

run

public void run()
code executed by a thread to manage updates to the corresponding Thing

Specified by:
run in interface java.lang.Runnable

doAction

public abstract void doAction()
                       throws VisADException,
                              java.rmi.RemoteException
Throws:
VisADException
java.rmi.RemoteException

thingChanged

public boolean thingChanged(ThingChangedEvent e)
                     throws VisADException,
                            java.rmi.RemoteException
Specified by:
thingChanged in interface ThingChangedListener
Throws:
VisADException
java.rmi.RemoteException

waitForTasks

public void waitForTasks()
wait for currently-running actions to finish


addReference

public void addReference(ThingReference ref)
                  throws ReferenceException,
                         RemoteVisADException,
                         VisADException,
                         java.rmi.RemoteException
Creates a link to a ThingReference. Note that this method causes this object to register itself with the ThingReference.

Specified by:
addReference in interface Action
Parameters:
ref - The ThingReference to which to create the link. Subsequent invocation of thingChanged(ThingChangedEvent) causes invocation of ref.acknowledgeThingChanged(this) . This method invokes ref.addThingChangedListener(this, ...).
Throws:
RemoteVisADException - if the reference isn't a ThingReferenceImpl.
ReferenceException - if the reference has already been added.
VisADException - if a VisAD failure occurs.
java.rmi.RemoteException - if a Java RMI failure occurs.
See Also:
thingChanged(ThingChangedEvent), ThingReference.addThingChangedListener(ThingChangedListener, long)

removeReference

public void removeReference(ThingReference ref)
                     throws VisADException,
                            java.rmi.RemoteException

Removes a link to a ThingReference.

This implementation invokes findReference(ThingReference).

Specified by:
removeReference in interface Action
Parameters:
ref - The reference to be removed.
Throws:
RemoteVisADException - if the reference isn't a ThingReferenceImpl.
ReferenceException - if the reference isn't a part of this instance.
VisADException - if a VisAD failure occurs.
java.rmi.RemoteException - if a Java RMI failure occurs.

removeAllReferences

public void removeAllReferences()
                         throws VisADException,
                                java.rmi.RemoteException
remove all ThingReferences

Specified by:
removeAllReferences in interface Action
Throws:
VisADException
java.rmi.RemoteException

findReference

public ReferenceActionLink findReference(ThingReference ref)
                                  throws VisADException
Returns the link associated with a ThingReference.

Parameters:
ref - The reference to find.
Returns:
The link associated with the reference.
Throws:
ReferenceException - if the argument is null.
VisADException - if the argument is null.

getLinks

public java.util.Vector getLinks()
return vector of ReferenceActionLink-s


getName

public java.lang.String getName()
return name of this Action

Specified by:
getName in interface Action

setName

public void setName(java.lang.String name)
change name of this Action