uk.ac.starlink.table.gui
Class PasteLoader

java.lang.Object
  |
  +--java.awt.event.MouseAdapter
        |
        +--uk.ac.starlink.util.gui.StringPaster
              |
              +--uk.ac.starlink.table.gui.PasteLoader
All Implemented Interfaces:
EventListener, MouseListener

public abstract class PasteLoader
extends StringPaster

MouseListener which will load a table when a string is pasted from the system selection into a component its listening to. To use this class, subclass it implementing the abstract tableLoaded(uk.ac.starlink.table.StarTable, java.lang.String) method and install it on a component using Component.addMouseListener(java.awt.event.MouseListener). Any time you paste a string into the component from the system selection (by default, using a single click of the middle mouse button) it will be submitted to the table factory using StarTableFactory.makeStarTable(java.lang.String) and loaded asynchronously. If it loads successfully then tableLoaded(uk.ac.starlink.table.StarTable, java.lang.String) will be called. If the pasted text is very long, it's ignored.

Since:
3 Dec 2004

Constructor Summary
PasteLoader(Component parent)
          Constructor.
 
Method Summary
abstract  StarTableFactory getTableFactory()
          Provides the table factory to be used for loading tables.
protected  Toolkit getToolkit()
           
protected  void pasted(String loc)
           
protected abstract  void tableLoaded(StarTable table, String location)
          Invoked if a table specified by pasting a string into a component watched by this listener is loaded successfully.
 
Methods inherited from class uk.ac.starlink.util.gui.StringPaster
isPasteEvent, mouseClicked
 
Methods inherited from class java.awt.event.MouseAdapter
mouseEntered, mouseExited, mousePressed, mouseReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PasteLoader

public PasteLoader(Component parent)
Constructor.

Parameters:
parent - parent component (may be used for placing windows)
Method Detail

getTableFactory

public abstract StarTableFactory getTableFactory()
Provides the table factory to be used for loading tables.

Returns:
table factory

pasted

protected void pasted(String loc)
Specified by:
pasted in class StringPaster

getToolkit

protected Toolkit getToolkit()
Overrides:
getToolkit in class StringPaster

tableLoaded

protected abstract void tableLoaded(StarTable table,
                                    String location)
Invoked if a table specified by pasting a string into a component watched by this listener is loaded successfully.

Parameters:
table - table
location - the pasted string (trimmed of spaces)

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