uk.ac.starlink.table.gui
Class BasicTableConsumer

java.lang.Object
  extended byuk.ac.starlink.table.gui.BasicTableConsumer
All Implemented Interfaces:
TableConsumer

public abstract class BasicTableConsumer
extends Object
implements TableConsumer

Provides a basic implementation of TableConsumer. This provides a callback routine tableLoaded(uk.ac.starlink.table.StarTable) which is called if a successful table load completes. If the load fails, the user is informed in a popup dialogue. A cancel() method is provided to allow loading to be interrupted.

Since:
1 Dec 2004

Constructor Summary
BasicTableConsumer(Component parent)
          Constructor.
 
Method Summary
 void cancel()
          Called when the loading sequence is over, because a table load has completed successfully or unsuccessfully.
 boolean isLoading()
          Determines whether this consumer is currently waiting for a load to finish.
 void loadFailed(Throwable th)
          Loading fails.
 void loadStarted(String id)
          Loading starts.
 void loadSucceeded(StarTable table)
          Loading succeeds.
protected  void processError(Throwable th)
          Disposes of a throwable which has resulted from a failed load.
protected  void setLoading(boolean isLoading)
          Called when the loading status changes.
protected abstract  void tableLoaded(StarTable table)
          Called from the event dispatch thread if and when a table is successfully loaded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicTableConsumer

public BasicTableConsumer(Component parent)
Constructor.

Parameters:
parent - parent component (may be null)
Method Detail

tableLoaded

protected abstract void tableLoaded(StarTable table)
Called from the event dispatch thread if and when a table is successfully loaded.

Parameters:
table - the loaded table

cancel

public void cancel()
Called when the loading sequence is over, because a table load has completed successfully or unsuccessfully. You can also call this method (on any thread) to interrupt loading - this will prevent tableLoaded(uk.ac.starlink.table.StarTable) being called in the future (until after another loadStarted(java.lang.String) call). Calling this method when loading is not in progress has no effect.


isLoading

public boolean isLoading()
Determines whether this consumer is currently waiting for a load to finish.

Returns:
true iff we're waiting to do something when the load succeeds or fails

setLoading

protected void setLoading(boolean isLoading)
Called when the loading status changes.

Parameters:
isLoading - whether the status is now waiting or not waiting

loadStarted

public void loadStarted(String id)
Loading starts.

Specified by:
loadStarted in interface TableConsumer
Parameters:
id - load target name
Throws:
IllegalStateException - if a load is already in progress

loadSucceeded

public void loadSucceeded(StarTable table)
Loading succeeds. tableLoaded(uk.ac.starlink.table.StarTable) is called unless the operation has already been cancelled.

Specified by:
loadSucceeded in interface TableConsumer
Parameters:
table - table

loadFailed

public void loadFailed(Throwable th)
Loading fails. The user is informed by a popup dialogue that this has happened.

Specified by:
loadFailed in interface TableConsumer
Parameters:
th - error

processError

protected void processError(Throwable th)
Disposes of a throwable which has resulted from a failed load. The error should normally be delivered to the user in some way. The BasicTableConsumer implementation displays the message in a modal dialogue.

Parameters:
th - error

Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.