|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectp3j.gui.panels.matrices.GridBehaviourAdapter
public class GridBehaviourAdapter
An adapter to integrate Copy/Paste-Behaviour to JGrid
. Implements
'fast' navigation and selection by pressing CTRL + Arrow or CTRL + SHIFT +
Arrow. Implements clipboard operations to deliver a user-friendly UI.
Inspired by code from Nils O. Sel(ao)sdal (see
http://groups.google.com/group/comp
.lang.java.gui/browse_frm/thread/2289d2f55aaed5ad
/3665b8ac63e4656a?tvc=1&q=copy+paste+excel+nach+jtable#3665b8ac63e4656a)
Created on January 10, 2007
Field Summary | |
---|---|
static String |
ACTION_COMMAND_DOWN
The action command for 'down'. |
static String |
ACTION_COMMAND_LEFT
The action command for 'left' |
static String |
ACTION_COMMAND_RIGHT
The action command for 'right'. |
static String |
ACTION_COMMAND_UP
The action command for 'up'. |
static int |
DIR_DOWN
Downwards. |
static int |
DIR_LEFT
Left direction. |
static int |
DIR_RIGHT
Right direction. |
static int |
DIR_UP
Upwards. |
static String |
FAST_PREFIX
The prefix for 'fast' action commands. |
static String |
FAST_SELECTION_CMD_PREFIX
The prefix for 'fast' action commands on the selection. |
Constructor Summary | |
---|---|
GridBehaviourAdapter(net.sf.jeppers.grid.JGrid target)
Default constructor. |
Method Summary | |
---|---|
void |
actionPerformed(ActionEvent e)
|
protected void |
copyToClipBoard(boolean cut)
Copies or cuts selected values to clipboard. |
static KeyStroke |
getCopyKeyStroke()
Returns KeyStroke for copying to clipboard (CTRL + C). |
static KeyStroke |
getCutKeyStroke()
Returns KeyStroke for cutting to clipboard (CTRL + X). |
static KeyStroke |
getPasteKeyStroke()
Returns KeyStroke for pasting from clipboard (CTRL + V). |
protected String |
getValue(boolean modifyX,
int offSet,
int currentRow,
int currentCol,
int rowCount,
int colCount)
Gets a value from the JGrid component. |
protected void |
moveFast(p3j.gui.panels.matrices.Direction direction,
boolean select)
Emulates positioning when CTRIL is pressed. |
protected void |
pasteFromClipboard()
Pastes from clipboard. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ACTION_COMMAND_RIGHT
public static final String ACTION_COMMAND_LEFT
public static final String ACTION_COMMAND_UP
public static final String ACTION_COMMAND_DOWN
public static final String FAST_PREFIX
public static final String FAST_SELECTION_CMD_PREFIX
public static final int DIR_UP
public static final int DIR_RIGHT
public static final int DIR_DOWN
public static final int DIR_LEFT
Constructor Detail |
---|
public GridBehaviourAdapter(net.sf.jeppers.grid.JGrid target)
target
- the grid of which the behaviour shall be controlledMethod Detail |
---|
public static KeyStroke getCopyKeyStroke()
KeyStroke
for copying to clipboard (CTRL + C).
public static KeyStroke getCutKeyStroke()
KeyStroke
for cutting to clipboard (CTRL + X).
public static KeyStroke getPasteKeyStroke()
KeyStroke
for pasting from clipboard (CTRL + V).
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
protected void copyToClipBoard(boolean cut)
cut
- if true, values will be cut outprotected void pasteFromClipboard()
protected void moveFast(p3j.gui.panels.matrices.Direction direction, boolean select)
JGrid
. This methods walks in the given
Direction
until it encounters an empty field or the end of the
matrix.
direction
- the direction in which to goselect
- flag to determine if passed elements shall be selected (i.e., is
SHIFT also pressed?)protected String getValue(boolean modifyX, int offSet, int currentRow, int currentCol, int rowCount, int colCount)
JGrid
component. Checks bounds etc.
modifyX
- flag to determine whether X is modified (true) or Y is modified
(false)offSet
- either -1 or 1, depending on the direction and whether the
column/row index has to be incremented or decremented to go in
this direction, see Direction.getOffset()
currentRow
- current row numbercurrentCol
- current column numberrowCount
- number of rowscolCount
- number of columns
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |