public abstract class JotyTableTransferHandler
extends javax.swing.TransferHandler
javax.swing.TransferHandler
class to work for a
Table
object.
The class receives in the constructor the reference to the Table
object which this instance have to work for, so the setting (actually made to
the inner JotyJTable
object) is made in the initialization and the
reference to the Table is hold for internal use .
In the constructor also the types of action along with the handler behaves
when the JotyJTable
object is either the target or the source of the
D&D action, must be specified.
It can support the move of the dragged item toward a special target, a
NavigatorPanel
instance content area, that behaves like a drain,
since used ideally to loose the item. This feature also must be declared in
the constructor invocation.
The data type transferred are a simple text string so that the java.awt.datatransfer.StringSelection class is used to instantiate a java.awt.datatransfer.Transferable object; however the javax.swing.TransferHandler.createTransferable method is overridden in order to deny the drop-ability over regions of the screen that don't own to the Joty application.
Even if the data type chosen as vehicle is the text string, actually the
class manages transfer of an integer number and it is exchanged as text. The
class collaborates with the Application
instance to dialogue with the
other side of the D&D operations for the transfer to occur.
The integer number exchanged is typically a id value of the entity hosted by
the GridBuffer
of the source Table
object.
In the code the concept of 'actor' takes place, for the JotyJtable
(and Table
indeed) managed in the class. If the actor is the source,
the index of the selected row is used to pick the data id up from the data
buffer (the valueToTransfer
method does it) and this is provided to
the createTransferable
implementation. If the actor is the target,
the getTargetIndex
method detects the index of the row on which or
next to which the drop will occur, and informs the calling context whether to
continue or not to.
It is manifest that the class instance understands which side it is on (source or target) depending on which methods are called among those overridden from the Swing ancestor: within each of those overrides it builds its environmental state that is clearly dedicated to the respective case.
The importData
and the exportDone
overrides implement the
actual actions in the Joty scenario: they performs changes in the state of
the database; their implementation is such that the whole D&D operation is
self contained in a database transaction, no matter what the Joty running
mode is, another way to say could be that this class assures the D&D user
action to happen within a Joty transaction.
The transaction management performed by the exportDone
implementation
can occur only when neither a transaction nor an atomic sql statement have
been performed by the 'target' side of the D&D action (see
checkExportTransaction()
).
The class identifies the abstract contribute that the handler must provide in
both side of the D&D action: far from any responsibility coming from the
ancestor and deriving from the needs of transaction management the contribute
is formalized by the
exportAction, importAction, getRowToBeSelected, validate
methods.
The class supports the use of the application Accessor
object, client
or server side located.
Furthermore the class participates in the publishers-subscribers model implementation for the updating propagation of the managed information.
NavigatorPanel
,
Table
,
GridBuffer
,
Accessor
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected int |
m_actionAsTarget |
protected Table.JotyJTable |
m_actor
The
JotyJTable object in the Table object to which this
instance is assigned |
protected java.lang.String |
m_id_dbField |
protected int |
m_index
Hosts the index of the selected row of the
JotyJTable object when
the 'actor' is the source |
protected java.lang.String |
m_managedDbTable |
protected boolean |
m_moveToDrain |
protected boolean |
m_showDropLocation |
protected Table |
m_table |
Constructor and Description |
---|
JotyTableTransferHandler(int actionAsSource,
int actionAsTarget,
Table table,
boolean moveToDrain) |
Modifier and Type | Method and Description |
---|---|
boolean |
canImport(javax.swing.TransferHandler.TransferSupport support) |
protected java.lang.String |
carriedValExpr(java.lang.String carried_val,
boolean carriedValDelayed) |
protected boolean |
checkExportTransaction()
Can return true only in the case no action has taken on the database by
the target side.
|
protected boolean |
checkImportTransaction() |
protected boolean |
checkInternalMove() |
protected boolean |
checkNeighbourhood() |
protected boolean |
checkToDelete() |
protected void |
completeImportTransaction(long dndID,
boolean internalMove,
boolean delayedDndId) |
protected org.joty.common.BasicPostStatement |
createContextPostStatement() |
protected java.awt.datatransfer.Transferable |
createTransferable(javax.swing.JComponent c) |
protected void |
endTransaction() |
protected abstract boolean |
exportAction(java.lang.String carried_val,
java.lang.String identifying_id_val) |
protected void |
exportDone(javax.swing.JComponent source,
java.awt.datatransfer.Transferable transferable,
int action) |
protected boolean |
getAndCheckSourceIndex(javax.swing.JComponent c) |
protected abstract int |
getRowToBeSelected(long carriedID,
java.lang.Long identifyingID) |
int |
getSourceActions(javax.swing.JComponent comp) |
boolean |
getSuccess() |
protected boolean |
getTargetIndex(javax.swing.TransferHandler.TransferSupport support) |
protected abstract boolean |
importAction(java.lang.String carried_val,
java.lang.String identifying_id_val,
java.awt.datatransfer.Transferable transferable,
boolean carriedValDelayed) |
boolean |
importData(javax.swing.TransferHandler.TransferSupport support) |
protected void |
loadData() |
protected java.lang.String |
managedDbTable() |
protected void |
manageExportActions(java.awt.datatransfer.Transferable transferable,
boolean transaction,
boolean foreignCall) |
protected void |
postImport() |
protected void |
postInit() |
protected void |
prepareTransfer() |
protected void |
selectContext(long dndID,
long identifyingID) |
protected void |
setCurrContext() |
void |
setManagedDbTable(java.lang.String name) |
void |
setSuccess() |
protected long |
sourceIdentifyingID() |
protected long |
targetIdentifyingID(javax.swing.TransferHandler.TransferSupport support) |
protected abstract boolean |
validate(long carriedID,
javax.swing.TransferHandler.TransferSupport support) |
protected long |
valueToTransfer() |
protected int m_index
JotyJTable
object when
the 'actor' is the sourceprotected java.lang.String m_id_dbField
protected boolean m_showDropLocation
protected java.lang.String m_managedDbTable
protected boolean m_moveToDrain
protected int m_actionAsTarget
protected Table m_table
protected Table.JotyJTable m_actor
JotyJTable
object in the Table
object to which this
instance is assignedpublic JotyTableTransferHandler(int actionAsSource, int actionAsTarget, Table table, boolean moveToDrain)
protected void postInit()
public boolean canImport(javax.swing.TransferHandler.TransferSupport support)
canImport
in class javax.swing.TransferHandler
protected java.lang.String carriedValExpr(java.lang.String carried_val, boolean carriedValDelayed)
protected boolean checkExportTransaction()
protected boolean checkImportTransaction()
protected boolean checkInternalMove()
protected boolean checkNeighbourhood()
protected boolean checkToDelete()
protected void completeImportTransaction(long dndID, boolean internalMove, boolean delayedDndId)
protected org.joty.common.BasicPostStatement createContextPostStatement()
protected java.awt.datatransfer.Transferable createTransferable(javax.swing.JComponent c)
createTransferable
in class javax.swing.TransferHandler
protected void endTransaction()
protected abstract boolean exportAction(java.lang.String carried_val, java.lang.String identifying_id_val)
protected abstract boolean importAction(java.lang.String carried_val, java.lang.String identifying_id_val, java.awt.datatransfer.Transferable transferable, boolean carriedValDelayed)
protected abstract boolean validate(long carriedID, javax.swing.TransferHandler.TransferSupport support)
protected abstract int getRowToBeSelected(long carriedID, java.lang.Long identifyingID)
protected void exportDone(javax.swing.JComponent source, java.awt.datatransfer.Transferable transferable, int action)
exportDone
in class javax.swing.TransferHandler
protected boolean getAndCheckSourceIndex(javax.swing.JComponent c)
public int getSourceActions(javax.swing.JComponent comp)
getSourceActions
in class javax.swing.TransferHandler
public boolean getSuccess()
protected boolean getTargetIndex(javax.swing.TransferHandler.TransferSupport support)
public boolean importData(javax.swing.TransferHandler.TransferSupport support)
importData
in class javax.swing.TransferHandler
protected void loadData()
protected java.lang.String managedDbTable()
protected void manageExportActions(java.awt.datatransfer.Transferable transferable, boolean transaction, boolean foreignCall) throws java.lang.Exception
java.lang.Exception
protected void postImport()
protected void prepareTransfer()
protected void selectContext(long dndID, long identifyingID)
protected void setCurrContext()
public void setManagedDbTable(java.lang.String name)
public void setSuccess()
protected long sourceIdentifyingID()
protected long targetIdentifyingID(javax.swing.TransferHandler.TransferSupport support)
protected long valueToTransfer()