Search this API

y.view
Class CellEditorMode

java.lang.Object
  extended by y.view.ViewMode
      extended by y.view.CellEditorMode
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener

public class CellEditorMode
extends ViewMode

This ViewMode is designed to use instances of NodeCellEditor to display a visual editor inline in the Graph2DView to edit a node's data. This mode can be registered in EditMode using EditMode.setEditNodeMode(ViewMode) or used as a stand-alone ViewMode

 

Field Summary
 
Fields inherited from class y.view.ViewMode
ACTIVE_PROPERTY, ACTIVE_VIEW_PROPERTY, CHILD_MODE_PROPERTY, EDITING_PROPERTY, GRAB_FOCUS_ENABLED_PROPERTY, lastClickEvent, lastDragEvent, lastMoveEvent, lastPressEvent, lastReleaseEvent, MODIFIER_MASK_PROPERTY, NAME_PROPERTY, originalX, originalY, PARENT_MODE_PROPERTY, view
 
Constructor Summary
CellEditorMode(DataProvider nodeCellEditorProvider, DataMap userObjectMap)
          Creates a new CellEditorMode ViewMode that is responsible for displaying NodeCellEditor instances during editing.
CellEditorMode(NodeCellEditor nodeCellEditor, DataMap userObjectMap)
          Creates a new CellEditorMode ViewMode that is responsible for displaying NodeCellEditor instances during editing.
 
Method Summary
 void cancelCellEditing()
          Cancels the current edit process.
protected  void cellEditingCanceled()
          Callback method that is called when the editor canceled the editing process.
protected  void cellEditingStopped()
          Callback method that is being called when the editor stopped the editing process.
 boolean editNode(Node node, java.util.EventObject e)
          This method can be used to programmatically start editing a node.
 Node getEditingNode()
          Returns the Node that is currently being edited or null.
 NodeCellEditor getEditor()
          Returns the current NodeCellEditor in use.
 NodeCellEditor getNodeCellEditor(Node n)
          Returns the NodeCellEditor instance that will be used for the editing of the given node.
 java.lang.Object getUserObject(Node node)
          Callback method that determines the user object to pass to the NodeCellEditor.
protected  void installEditor(javax.swing.JComponent component, NodeRealizer nr)
          Installs the given editor JComponent for the given NodeRealizer.
 boolean isCellEditing()
          Returns whether the mode is currently editing a cell.
 boolean isNodeEditable(Node node)
          Determines whether a node is deemed editable.
 void mouseClicked(java.awt.event.MouseEvent e)
          A mouse button get clicked
 void mouseDragged(java.awt.event.MouseEvent e)
          The mouse gets dragged
 void mouseMoved(java.awt.event.MouseEvent e)
          The Mouse gets moved.
 void mousePressed(java.awt.event.MouseEvent e)
          A mouse button gets pressed.
 void mouseReleased(java.awt.event.MouseEvent e)
          A mouse button get released
protected  void removeEditor()
          This method removes the current editor instance from the canvas.
 void setUserObject(Node node, java.lang.Object userObject)
          Callback method that associates the user object with the node.
protected  boolean shouldStartCellEditing(java.awt.event.MouseEvent me)
          Callback method that determines whether the mouse event should start the process of cell editing.
 void startCellEditing(NodeRealizer nr, NodeCellEditor nce)
          Initiates cell editing for a given NodeRealizer and NodeCellEditor.
 boolean stopCellEditing()
          Tries to stop the current edit process.
 
Methods inherited from class y.view.ViewMode
activate, addPropertyChangeListener, addPropertyChangeListener, cancelEditing, deactivateChild, firePropertyChange, firePropertyChange, firePropertyChange, getChild, getGraph2D, getGridX, getGridY, getHitInfo, getHitInfo, getLastClickEvent, getLastDragEvent, getLastHitInfo, getLastMoveEvent, getLastPressEvent, getLastReleaseEvent, getModifierMask, getName, getParent, init, isActive, isEditing, isGrabFocusEnabled, isGridMode, isModifierPressed, mouseClicked, mouseDraggedLeft, mouseDraggedMiddle, mouseDraggedRight, mouseEntered, mouseExited, mouseMoved, mousePressedLeft, mousePressedMiddle, mousePressedRight, mouseReleased, mouseReleasedLeft, mouseReleasedMiddle, mouseReleasedRight, mouseShiftPressedLeft, mouseShiftPressedMiddle, mouseShiftPressedRight, mouseShiftReleasedLeft, mouseShiftReleasedMiddle, mouseShiftReleasedRight, reactivateParent, removePropertyChangeListener, removePropertyChangeListener, setActiveView, setChild, setChild, setEditing, setGrabFocusEnabled, setGridMode, setLastHitInfo, setModifierMask, setName, setParent, translateX, translateY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CellEditorMode

public CellEditorMode(NodeCellEditor nodeCellEditor,
                      DataMap userObjectMap)
Creates a new CellEditorMode ViewMode that is responsible for displaying NodeCellEditor instances during editing.

Parameters:
nodeCellEditor - the single NodeCellEditor to use for all nodes.
userObjectMap - a map to obtain the editor values from and store the modified values to

CellEditorMode

public CellEditorMode(DataProvider nodeCellEditorProvider,
                      DataMap userObjectMap)
Creates a new CellEditorMode ViewMode that is responsible for displaying NodeCellEditor instances during editing.

Parameters:
nodeCellEditorProvider - a DataProvider that will be queried for the NodeCellEditor instances for each node to determine the instance to use for editing.
userObjectMap - a map to obtain the editor values from and store the modified values to
Method Detail

editNode

public boolean editNode(Node node,
                        java.util.EventObject e)
This method can be used to programmatically start editing a node. If the node is not editable or this mode is currently editing and stopCellEditing() does not succeed, this method will do nothing but return false

Parameters:
node - the node to edit
e - an optional event object that triggered the editing gesture
Returns:
whether the editing has been successfully initiated.
See Also:
isNodeEditable(y.base.Node), isCellEditing(), stopCellEditing()

isNodeEditable

public boolean isNodeEditable(Node node)
Determines whether a node is deemed editable. This implementation calls getNodeCellEditor(y.base.Node) and sees if the result is non-null;

Parameters:
node - the node to check.
Returns:
whether the node is editable

getUserObject

public java.lang.Object getUserObject(Node node)
Callback method that determines the user object to pass to the NodeCellEditor.

Parameters:
node - the node to query the value from
Returns:
the user object
See Also:
setUserObject(y.base.Node, Object)

setUserObject

public void setUserObject(Node node,
                          java.lang.Object userObject)
Callback method that associates the user object with the node.

Parameters:
node - the node to associate the value with
userObject - the user object
See Also:
getUserObject(y.base.Node)

shouldStartCellEditing

protected boolean shouldStartCellEditing(java.awt.event.MouseEvent me)
Callback method that determines whether the mouse event should start the process of cell editing. This implementation returns true if the event is a MouseEvent.MOUSE_CLICKED event and the clickCount is 2.

Parameters:
me - the mouse event to inspect
Returns:
whether the mouse event initiates editing

getNodeCellEditor

public NodeCellEditor getNodeCellEditor(Node n)
Returns the NodeCellEditor instance that will be used for the editing of the given node.

Parameters:
n - the node
Returns:
a NodeCellEditor instance that can be used with the node or null if there is no such suitable editor

isCellEditing

public boolean isCellEditing()
Returns whether the mode is currently editing a cell.

Returns:
whether a cell is currently being edited

startCellEditing

public void startCellEditing(NodeRealizer nr,
                             NodeCellEditor nce)
Initiates cell editing for a given NodeRealizer and NodeCellEditor.

Parameters:
nr - the NodeRealizer context
nce - the NodeCellEditor to use

getEditor

public NodeCellEditor getEditor()
Returns the current NodeCellEditor in use.

Returns:
the current editor instance or null

getEditingNode

public Node getEditingNode()
Returns the Node that is currently being edited or null.

Returns:
the node or null

cancelCellEditing

public void cancelCellEditing()
Cancels the current edit process. Uncommitted edits will be lost.


stopCellEditing

public boolean stopCellEditing()
Tries to stop the current edit process.

Returns:
whether the editing was successfully stopped

cellEditingCanceled

protected void cellEditingCanceled()
Callback method that is called when the editor canceled the editing process.


cellEditingStopped

protected void cellEditingStopped()
Callback method that is being called when the editor stopped the editing process.


mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Description copied from class: ViewMode
The Mouse gets moved. Delegates to ViewMode.mouseMoved(double,double).

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class ViewMode

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Description copied from class: ViewMode
A mouse button get released

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class ViewMode

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Description copied from class: ViewMode
The mouse gets dragged

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Overrides:
mouseDragged in class ViewMode

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Description copied from class: ViewMode
A mouse button gets pressed.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class ViewMode

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Description copied from class: ViewMode
A mouse button get clicked

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class ViewMode

installEditor

protected void installEditor(javax.swing.JComponent component,
                             NodeRealizer nr)
Installs the given editor JComponent for the given NodeRealizer.

Parameters:
component - the component
nr - the NodeRealizer context

removeEditor

protected void removeEditor()
This method removes the current editor instance from the canvas.


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