Search this API

y.view.tabular
Class TableOrderEditor

java.lang.Object
  extended by y.view.AbstractMouseInputEditor
      extended by y.view.tabular.TableOrderEditor
All Implemented Interfaces:
MouseInputEditor, MultiplexingNodeEditor.NodeEditor

public class TableOrderEditor
extends AbstractMouseInputEditor

This MultiplexingNodeEditor.NodeEditor can be used to move rows and columns of a TableGroupNodeRealizer via drag'n'drop. While dragging a row or column, a drawable previews the new position and bounds of the dragged item.

Whether rows and columns have to be selected before they can be moved can be configured by the movePolicy).

See Also:
setMovePolicy(byte)
 

Field Summary
static byte MOVE_POLICY_IGNORE_SELECTION
          This policy determines that a row or column can be moved independent of it's selection status.
static byte MOVE_POLICY_ONLY_ON_SELECTION
          This policy determines that a row or column has to be selected before it can be moved.
 
Constructor Summary
TableOrderEditor()
          The default constructor for this class.
 
Method Summary
protected  boolean columnMovementHit(TableGroupNodeRealizer.Column column, double x, double y)
          Determines whether a mouse drag starting at the specified hit location should start the editor for the specified column.
protected  Drawable createColumnMoveDrawable(TableGroupNodeRealizer.Column column, java.awt.geom.Rectangle2D bounds)
          Creates a drawable with the specified bounds used to indicate the new position of the moved column.
protected  Drawable createRowMoveDrawable(TableGroupNodeRealizer.Row row, java.awt.geom.Rectangle2D bounds)
          Creates a drawable with the specified bounds used to indicate the new position of the moved row.
 java.awt.Cursor getCursor(Mouse2DEvent event)
          Returns Cursor.MOVE_CURSOR if the event's location is a valid start position or null otherwise.
 int getMaxColumnLevel()
          The maximum number of levels the column hierarchy may have.
 int getMaxRowLevel()
          The maximum number of levels the row hierarchy may have.
 byte getMovePolicy()
          The policy defining if a row or column has to be selected before it can be moved.
 TableSupport getTableSupport()
          Returns the TableSupport used to reparent and reposition the rows and columns.
 boolean isExtendedMovementHitEnabled()
          Returns true if the editor should allow reordering for columns and rows that have no children upon drags outside of the column's top inset area or the row's left inset area and false otherwise.
 boolean isValidStartPosition(double x, double y)
          Returns true only if the left insets of a row or the top insets of a column can be found at the specified coordinates.
 void mouse2DEventHappened(Mouse2DEvent event)
          Listener-like interface that will be notified of Mouse2DEvents.
protected  void mouseDragged(double x, double y)
          Calculates the new parent container and position that would be used if the mouse would be released at the given mouse location and updates the drawable indicating the row or columns new location.
protected  void mousePressed(double x, double y)
          Create the drawables for the row or column that shall be moved and stores the initial parent container and position.
protected  void mouseReleased(double x, double y)
          Moves the row or column to the new parent container and position determined for the given coordinates and finishes the editing action.
protected  boolean rowMovementHit(TableGroupNodeRealizer.Row row, double x, double y)
          Determines whether a mouse drag starting at the specified hit location should start the editor for the specified row.
 void setContext(Graph2DView view, MultiplexingNodeEditor parent, NodeRealizer realizer)
          Provides context information for the editor.
 void setExtendedMovementHitEnabled(boolean enabled)
          Specifies whether the editor may reorder columns and rows that have no children upon drags outside of the column's top inset area or the row's left inset area.
 void setMaxColumnLevel(int maxColumnLevel)
          Specifies the maximum nesting depth of columns in a TableGroupNodeRealizer's table model that the editor can create.
 void setMaxRowLevel(int maxRowLevel)
          Specifies the maximum nesting depth of rows in a TableGroupNodeRealizer's table model that the editor can create.
 void setMovePolicy(byte movePolicy)
          Specifies the movement policy for rows and columns.
 void setTableSupport(TableSupport support)
          Specifies the support class to handle content (nodes and bends) moving during move operations.
 boolean startsEditing(Mouse2DEvent event)
          This method is used by clients to query whether the given event is deemed as a starting gesture.
 void stopEditing()
          Called by clients to stop the editing process cleanly.
 
Methods inherited from class y.view.AbstractMouseInputEditor
addChangeListener, fireStateChanged, isEditing, isEnabled, isInterestedInEvents, removeChangeListener, setEnabled, startEditing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface y.view.MouseInputEditor
addChangeListener, isEditing, isInterestedInEvents, removeChangeListener, startEditing
 

Field Detail

MOVE_POLICY_ONLY_ON_SELECTION

public static final byte MOVE_POLICY_ONLY_ON_SELECTION
This policy determines that a row or column has to be selected before it can be moved. The move policy can be set via setMovePolicy(byte).

See Also:
Constant Field Values

MOVE_POLICY_IGNORE_SELECTION

public static final byte MOVE_POLICY_IGNORE_SELECTION
This policy determines that a row or column can be moved independent of it's selection status. The move policy can be set via setMovePolicy(byte).

See Also:
Constant Field Values
Constructor Detail

TableOrderEditor

public TableOrderEditor()
The default constructor for this class.

Method Detail

getTableSupport

public TableSupport getTableSupport()
Returns the TableSupport used to reparent and reposition the rows and columns.

Returns:
the TableSupport used to reparent and reposition the rows and columns.
See Also:
setTableSupport(TableSupport)

setTableSupport

public void setTableSupport(TableSupport support)
Specifies the support class to handle content (nodes and bends) moving during move operations.

Parameters:
support - the support class to handle content (nodes and bends) moving.
See Also:
getTableSupport()

isValidStartPosition

public boolean isValidStartPosition(double x,
                                    double y)
Returns true only if the left insets of a row or the top insets of a column can be found at the specified coordinates.

Parameters:
x - The horizontal position.
y - The vertical position.
Returns:
true only if the left insets of a row or the top insets of a column can be found at the specified coordinates; false otherwise.

columnMovementHit

protected boolean columnMovementHit(TableGroupNodeRealizer.Column column,
                                    double x,
                                    double y)
Determines whether a mouse drag starting at the specified hit location should start the editor for the specified column. The default implementation returns true only if the editor's movePolicy is MOVE_POLICY_IGNORE_SELECTION or the specified column is selected.

Parameters:
column - the Column to check.
x - the x-coordinate of the hit location.
y - the y-coordinate of the hit location.
Returns:
true if the editor should start editing; false otherwise.
See Also:
getMovePolicy()

rowMovementHit

protected boolean rowMovementHit(TableGroupNodeRealizer.Row row,
                                 double x,
                                 double y)
Determines whether a mouse drag starting at the specified hit location should start the editor for the specified row. The default implementation returns true only if the editor's movePolicy is MOVE_POLICY_IGNORE_SELECTION or the specified row is selected.

Parameters:
row - the Row to check.
x - the x-coordinate of the hit location.
y - the y-coordinate of the hit location.
Returns:
true if the editor should start editing; false otherwise.
See Also:
getMovePolicy()

mousePressed

protected void mousePressed(double x,
                            double y)
Create the drawables for the row or column that shall be moved and stores the initial parent container and position.

Parameters:
x - The horizontal coordinate to look for a row or column to move.
y - The vertical coordinate to look for a row or column to move.

mouseReleased

protected void mouseReleased(double x,
                             double y)
Moves the row or column to the new parent container and position determined for the given coordinates and finishes the editing action.

Parameters:
x - The horizontal coordinate to determine the new parent container and position.
y - The vertical coordinate to determine the new parent container and position.

mouseDragged

protected void mouseDragged(double x,
                            double y)
Calculates the new parent container and position that would be used if the mouse would be released at the given mouse location and updates the drawable indicating the row or columns new location.

Parameters:
x - The horizontal coordinate to check.
y - The vertical coordinate to check.

stopEditing

public void stopEditing()
Description copied from interface: MouseInputEditor
Called by clients to stop the editing process cleanly.

Specified by:
stopEditing in interface MouseInputEditor

createRowMoveDrawable

protected Drawable createRowMoveDrawable(TableGroupNodeRealizer.Row row,
                                         java.awt.geom.Rectangle2D bounds)
Creates a drawable with the specified bounds used to indicate the new position of the moved row.

Parameters:
row - The row a drawable shall be created for.
bounds - The bounds of the drawable to indicate.
Returns:
A drawable indicating the new bounds of the row.

createColumnMoveDrawable

protected Drawable createColumnMoveDrawable(TableGroupNodeRealizer.Column column,
                                            java.awt.geom.Rectangle2D bounds)
Creates a drawable with the specified bounds used to indicate the new position of the moved column.

Parameters:
column - The column a drawable shall be created for.
bounds - The bounds of the drawable to indicate.
Returns:
A drawable indicating the new bounds of the column.

getMaxRowLevel

public int getMaxRowLevel()

The maximum number of levels the row hierarchy may have. The moved row can't be placed in a level so that any of its child rows would end up in a deeper nesting level.

A row can always be placed top-level even if the row and its descendants already span more then the maximum number of levels.

The default is Integer.MAX_VALUE.

See Also:
setMaxRowLevel(int)

setMaxRowLevel

public void setMaxRowLevel(int maxRowLevel)
Specifies the maximum nesting depth of rows in a TableGroupNodeRealizer's table model that the editor can create.

The default is Integer.MAX_VALUE.

Parameters:
maxRowLevel - the maximum number of nesting levels for rows that the editor can create.
See Also:
getMaxRowLevel()

getMaxColumnLevel

public int getMaxColumnLevel()

The maximum number of levels the column hierarchy may have. The moved column can't be placed in a level so that any of its child columns would end up in a deeper nesting level.

A column can always be placed top-level even if the column and its descendants already span more then the maximum number of levels.

The default is Integer.MAX_VALUE.

See Also:
setMaxRowLevel(int)

setMaxColumnLevel

public void setMaxColumnLevel(int maxColumnLevel)
Specifies the maximum nesting depth of columns in a TableGroupNodeRealizer's table model that the editor can create.

The default is Integer.MAX_VALUE.

Parameters:
maxColumnLevel - the maximum number of nesting levels for columns that the editor can create.
See Also:
getMaxColumnLevel()

getMovePolicy

public byte getMovePolicy()

The policy defining if a row or column has to be selected before it can be moved.

One of The default of this policy is MOVE_POLICY_ONLY_ON_SELECTION.

Returns:
policy defining if a row or column has to be selected before it can be moved.
See Also:
setMovePolicy(byte)

setMovePolicy

public void setMovePolicy(byte movePolicy)
Specifies the movement policy for rows and columns. The movement policy determines whether a row or column has to be selected for the editor to be able to move it.

Parameters:
movePolicy - one of
Throws:
java.lang.IllegalArgumentException - if movePolicy does not equal one of the movement policy constants.

startsEditing

public boolean startsEditing(Mouse2DEvent event)
Description copied from interface: MouseInputEditor
This method is used by clients to query whether the given event is deemed as a starting gesture.

Parameters:
event - the event that happened
Returns:
whether the given gesture can be used to start the editing
See Also:
MouseInputEditor.isInterestedInEvents()

mouse2DEventHappened

public void mouse2DEventHappened(Mouse2DEvent event)
Description copied from interface: MouseInputEditor
Listener-like interface that will be notified of Mouse2DEvents.

Parameters:
event - the event that happened
See Also:
MouseInputEditor.isInterestedInEvents()

getCursor

public java.awt.Cursor getCursor(Mouse2DEvent event)
Returns Cursor.MOVE_CURSOR if the event's location is a valid start position or null otherwise.

Specified by:
getCursor in interface MultiplexingNodeEditor.NodeEditor
Parameters:
event - The mouse event a cursor can be returned for.
Returns:
Cursor.MOVE_CURSOR if the event's location is a valid start position or null otherwise.

isExtendedMovementHitEnabled

public boolean isExtendedMovementHitEnabled()
Returns true if the editor should allow reordering for columns and rows that have no children upon drags outside of the column's top inset area or the row's left inset area and false otherwise. Note, that even if this property is true column reordering is only allowed by dragging outside of any rows and row reordering is only allowed by dragging outside of any columns.

By default, this property is true.

Returns:
true if the editor should allow column and row reordering for columns and rows that have no children upon drags outside of the column's top inset area or the row's left inset area and false otherwise.
See Also:
setExtendedMovementHitEnabled(boolean), columnMovementHit(y.view.tabular.TableGroupNodeRealizer.Column, double, double), rowMovementHit(y.view.tabular.TableGroupNodeRealizer.Row, double, double)

setExtendedMovementHitEnabled

public void setExtendedMovementHitEnabled(boolean enabled)
Specifies whether the editor may reorder columns and rows that have no children upon drags outside of the column's top inset area or the row's left inset area.

By default, this property is true.

Parameters:
enabled - if true the editor may reorder columns and rows that have no children upon drags outside of the column's top inset area or the row's left inset area; if false only drags inside a column's top inset area or a row's left inset area will result in any reordering.
See Also:
isExtendedMovementHitEnabled(), columnMovementHit(y.view.tabular.TableGroupNodeRealizer.Column, double, double), rowMovementHit(y.view.tabular.TableGroupNodeRealizer.Row, double, double)

setContext

public void setContext(Graph2DView view,
                       MultiplexingNodeEditor parent,
                       NodeRealizer realizer)
Description copied from interface: MultiplexingNodeEditor.NodeEditor
Provides context information for the editor.

Specified by:
setContext in interface MultiplexingNodeEditor.NodeEditor
Parameters:
view - the current view in which the editing is done.
parent - the multiplexing editor that delegates to the node editor.
realizer - the realizer representing the node to edit.

© Copyright 2000-2021,
yWorks GmbH.
All rights reserved.