java.lang.Object |
↳ |
javax.swing.AbstractAction |
|
↳ |
org.mbari.awt.event.ActionAdapter |
|
|
↳ |
vars.query.ui.db.sql.QueryAction |
Class Overview
This action takes a SQL query (as a string) and an IQueryable object, executes
the query in a seperate thread and returns the results as a QueryResults object.
Here's an example of usage:
// Create our IQueryable object to execute our query
IQueryable q = new IQueryable() {
public QueryResults executeQuery(String query) {
// Get a JDBC connection
Connection c = ConnectionFactory.getConnection("vars");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
QueryResults queryResults = new QueryResults(rs);
s.close();
c.close();
return queryResults;
}
};
// Initialize our QueryAction
QueryAction a = new QueryAction("SELECT * from MyTable", q);
// We'll add some exception handling just to notify us of an error. This is optional
a.addExceptionHandler(new ExceptionHandler() {
public void doAction(Exception e) {
e.printStackTrace();
}
});
// Since it's multithreaded we can't just call getQueryResults because the
// query may not be finished (Calling getQueryResults would return null). So we
// attach a PropertyChangeListener to handle post query work
a.addPropertyChangeListener("queryResults", new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
System.out.println("Query is done");
// Normally you would put save or display code here.
}
});
Summary
[Expand]
Inherited Constants |
From interface
javax.swing.Action
String |
ACCELERATOR_KEY |
|
String |
ACTION_COMMAND_KEY |
|
String |
DEFAULT |
|
String |
DISPLAYED_MNEMONIC_INDEX_KEY |
|
String |
LARGE_ICON_KEY |
|
String |
LONG_DESCRIPTION |
|
String |
MNEMONIC_KEY |
|
String |
NAME |
|
String |
SELECTED_KEY |
|
String |
SHORT_DESCRIPTION |
|
String |
SMALL_ICON |
|
|
[Expand]
Inherited Fields |
From class
javax.swing.AbstractAction
protected
SwingPropertyChangeSupport |
changeSupport |
|
protected
boolean |
enabled |
|
|
Public Constructors |
|
QueryAction(String query, IQueryable queryable, KnowledgebaseDAOFactory knowledgebaseDAOFactory)
Constructor for the QueryAction object
|
|
QueryAction(String query, IQueryable queryable, KnowledgebaseDAOFactory knowledgebaseDAOFactory, boolean showHiearchy, boolean showBasicPhylogeny, boolean showFullPhylogeny)
Constructs ...
|
[Expand]
Inherited Methods |
From class
org.mbari.awt.event.ActionAdapter
final
void
|
actionPerformed(ActionEvent arg0)
|
abstract
void
|
doAction()
|
|
From class
javax.swing.AbstractAction
synchronized
void
|
addPropertyChangeListener(PropertyChangeListener arg0)
|
Object
|
clone()
|
void
|
firePropertyChange(String arg0, Object arg1, Object arg2)
|
Object[]
|
getKeys()
|
synchronized
PropertyChangeListener[]
|
getPropertyChangeListeners()
|
Object
|
getValue(String arg0)
|
boolean
|
isEnabled()
|
void
|
putValue(String arg0, Object arg1)
|
synchronized
void
|
removePropertyChangeListener(PropertyChangeListener arg0)
|
void
|
setEnabled(boolean arg0)
|
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0)
|
final
void
|
wait(long arg0, int arg1)
|
|
From interface
java.awt.event.ActionListener
abstract
void
|
actionPerformed(ActionEvent arg0)
|
|
From interface
javax.swing.Action
abstract
void
|
addPropertyChangeListener(PropertyChangeListener arg0)
|
abstract
Object
|
getValue(String arg0)
|
abstract
boolean
|
isEnabled()
|
abstract
void
|
putValue(String arg0, Object arg1)
|
abstract
void
|
removePropertyChangeListener(PropertyChangeListener arg0)
|
abstract
void
|
setEnabled(boolean arg0)
|
|
From interface
org.mbari.awt.event.IAction
|
Public Constructors
public
QueryAction
(String query, IQueryable queryable, KnowledgebaseDAOFactory knowledgebaseDAOFactory)
Constructor for the QueryAction object
Parameters
query
| Description of the Parameter |
queryable
| Description of the Parameter |
public
QueryAction
(String query, IQueryable queryable, KnowledgebaseDAOFactory knowledgebaseDAOFactory, boolean showHiearchy, boolean showBasicPhylogeny, boolean showFullPhylogeny)
Public Methods
public
synchronized
void
addExceptionHandler
(ExceptionHandler eh)
public
synchronized
void
addPropertyChangeListener
(PropertyChangeListener listener)
Adds a feature to the PropertyChangeListener attribute of the QueryAction object
Parameters
listener
| The feature to be added to the PropertyChangeListener attribute
|
public
synchronized
void
addPropertyChangeListener
(String propertyName, PropertyChangeListener listener)
public
void
doAction
()
Description of the Method
public
String
getQuery
()
public
synchronized
QueryResults
getQueryResults
()
Returns
- Returns the queryResults.
public
synchronized
boolean
isFinished
()
public
synchronized
void
removeExceptionHandler
(ExceptionHandler eh)
public
synchronized
void
removePropertyChangeListener
(PropertyChangeListener listener)
Description of the Method
Parameters
listener
| Description of the Parameter
|
public
synchronized
void
removePropertyChangeListener
(String propertyName, PropertyChangeListener listener)