Top Description Fields Constructors Methods
impl.org.controlsfx.spreadsheet

public Class CellView

extends TableCell<ObservableList<SpreadsheetCell>, SpreadsheetCell>
Class Inheritance
Imports
java.util.Objects, .Optional, java.util.logging.Logger, javafx.animation.FadeTransition, javafx.beans.binding.When, javafx.beans.value.WeakChangeListener, .ChangeListener, .ObservableValue, javafx.collections.ObservableList, .SetChangeListener, .WeakSetChangeListener, javafx.event.EventHandler, .WeakEventHandler, javafx.geometry.Side, javafx.scene.Cursor, .Node, .Parent, javafx.scene.control.ContentDisplay, .ContextMenu, .Control, .SelectionMode, .TableCell, .TablePositionBase, .TableView, .TableView.TableViewFocusModel, .TableView.TableViewSelectionModel, .Tooltip, javafx.scene.image.ImageView, javafx.scene.input.DragEvent, .Dragboard, .MouseButton, .MouseEvent, .TransferMode, javafx.util.Duration, org.controlsfx.control.spreadsheet.Filter, .SpreadsheetCell, .SpreadsheetCellEditor, .SpreadsheetCellType, .SpreadsheetView, .CellGraphicFactory, javafx.application.Platform, javafx.scene.layout.Region

The View cell that will be visible on screen. It holds the SpreadsheetCell.

Field Summary

Modifier and TypeField and Description
private final EventHandler<MouseEvent>
actionEventHandler

Event Handler when the cell is simply clicked in order to display the possible actions in MenuItem.

private static final String
ANCHOR_PROPERTY_KEY

Static Fields * *

private boolean
private EventHandler<DragEvent>
private final EventHandler<MouseEvent>
private EventHandler<DragEvent>
private static final Duration
private final ChangeListener<Node>
pack-priv final SpreadsheetHandle
private final ChangeListener<SpreadsheetCell>
private ChangeListener<Parent>
parentListener

When this cell looses its parent, we release the Graphic if we had one.

private final EventHandler<MouseEvent>
private final SetChangeListener<String>
private ChangeListener<String>
private Tooltip
tooltip

Hides javafx.scene.control.Control.tooltip.

Because we don't want to recreate Tooltip each time the TableCell is re-used.
private static final int
private final WeakEventHandler<T extends Event>
private final WeakChangeListener<Node>
private final WeakSetChangeListener<String>
private WeakChangeListener<String>

Constructor Summary

AccessConstructor and Description
public
CellView(SpreadsheetHandle handle)

Constructor * *

Method Summary

Modifier and TypeMethod and Description
public void
cancelEdit()

Overrides javafx.scene.control.TableCell.cancelEdit.

Cancels an edit to the value of the cell.

public void
commitEdit(SpreadsheetCell newValue)

Overrides javafx.scene.control.TableCell.commitEdit.

Commits an edit to the value of the cell.

protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.TableCell.createDefaultSkin.

Create a new instance of the default skin for this control.

private void
dragSelect(MouseEvent e)

Method that will select all the cells between the drag place and that cell.

pack-priv static TablePositionBase<?>
getAnchor(Control table, TablePositionBase<?> focusedCell)

private Tooltip
getAvailableTooltip()

See if a tootlip is available (either on the TableCell already, or in the Stack).

private EventHandler<DragEvent>
private EventHandler<DragEvent>
private GridCellEditor
getEditor(final SpreadsheetCell
The SpreadsheetCell
cell
,
final SpreadsheetView spv)

Return an instance of Editor specific to the Cell type We are not using the build-in editor-Cell because we cannot know in advance which editor we will need.

pack-priv Filter
getFilter()

Return the Filter associated to this cell or null otherwise.

public static void
getValue(final Runnable runnable)

Will safely execute the request on the JFX thread by checking whether we are on the JFX thread or not.

pack-priv static boolean
private void
public boolean

Returns:

true if this cell is the original cell (including filters) even when scrolling
isOriginalCell
()

Return true if this cell is the original cell (including filters) even when scrolling.

protected void
layoutChildren()

Overrides javafx.scene.control.TableCell.layoutChildren.

Invoked during the layout pass to layout the children in this Parent.

public void
releaseCellGraphic()

Releases and remove the graphic if any has been defined.

pack-priv static void
pack-priv static void
setAnchor(Control table, TablePositionBase<TC extends TableColumnBase<S, T>> anchor)

private void
setBrowserGraphic(SpreadsheetCell item)

Sets the browser in the cell.

private void
setCellGraphic(SpreadsheetCell
the SpreadsheetCell to set the graphic to
item
)

Set the cell graphic if any.

public void
show(final SpreadsheetCell cell)

Called in the gridRowSkinBase when doing layout This allow not to override opacity in the row and let the cell handle itself

public void
startEdit()

Overrides javafx.scene.control.TableCell.startEdit.

Public Methods * *

public void
updateItem(final SpreadsheetCell item, boolean empty)

Overrides javafx.scene.control.Cell.updateItem.

The updateItem method should not be called by developers, but it is the best method for developers to override to allow for them to customise the visuals of the cell.

Inherited from javafx.scene.control.TableCell:
executeAccessibleActiongetTableColumngetTableRowgetTableViewqueryAccessibleAttributetableColumnPropertytableRowPropertytableViewPropertyupdateSelectedupdateTableColumnupdateTableRowupdateTableView

Field Detail

actionEventHandlerback to summary
private final EventHandler<MouseEvent> actionEventHandler

Event Handler when the cell is simply clicked in order to display the possible actions in MenuItem.

ANCHOR_PROPERTY_KEYback to summary
private static final String ANCHOR_PROPERTY_KEY

Static Fields * *

dirtyStyleback to summary
private boolean dirtyStyle
dragDropHandlerback to summary
private EventHandler<DragEvent> dragDropHandler
dragMouseEventHandlerback to summary
private final EventHandler<MouseEvent> dragMouseEventHandler
dragOverHandlerback to summary
private EventHandler<DragEvent> dragOverHandler
FADE_DURATIONback to summary
private static final Duration FADE_DURATION
graphicListenerback to summary
private final ChangeListener<Node> graphicListener
handleback to summary
pack-priv final SpreadsheetHandle handle
itemChangeListenerback to summary
private final ChangeListener<SpreadsheetCell> itemChangeListener
parentListenerback to summary
private ChangeListener<Parent> parentListener

When this cell looses its parent, we release the Graphic if we had one.

startFullDragEventHandlerback to summary
private final EventHandler<MouseEvent> startFullDragEventHandler
styleClassListenerback to summary
private final SetChangeListener<String> styleClassListener
styleListenerback to summary
private ChangeListener<String> styleListener
tooltipback to summary
private Tooltip tooltip

Hides javafx.scene.control.Control.tooltip.

Because we don't want to recreate Tooltip each time the TableCell is re-used. We save it properly here so we avoid recreating it each time since it's really time-consuming.

TOOLTIP_MAX_WIDTHback to summary
private static final int TOOLTIP_MAX_WIDTH
weakActionhandlerback to summary
private final WeakEventHandler<T extends Event> weakActionhandler
weakGraphicListenerback to summary
private final WeakChangeListener<Node> weakGraphicListener
weakStyleClassListenerback to summary
private final WeakSetChangeListener<String> weakStyleClassListener
weakStyleListenerback to summary
private WeakChangeListener<String> weakStyleListener

Constructor Detail

CellViewback to summary
public CellView(SpreadsheetHandle handle)

Constructor * *

Method Detail

cancelEditback to summary
public void cancelEdit()

Overrides javafx.scene.control.TableCell.cancelEdit.

Doc from javafx.scene.control.TableCell.cancelEdit.

Cancels an edit to the value of the cell. Call this function to transition from an editing state into a non-editing state, without saving any user input.

Annotations
@Override
commitEditback to summary
public void commitEdit(SpreadsheetCell newValue)

Overrides javafx.scene.control.TableCell.commitEdit.

Doc from javafx.scene.control.TableCell.commitEdit.

Commits an edit to the value of the cell. Call this function when appropriate (based on the user interaction requirements of your cell editing user interface) to do two things:

  1. Fire the appropriate events back to the backing UI control (e.g., ListView). This will begin the process of pushing this edit back to the relevant data source / property (although it does not guarantee that this will be successful - that is dependent upon the specific edit commit handler being used). Refer to the UI control class javadoc for more detail.
  2. Begin the transition from an editing state into a non-editing state.

In general there is no need to override this method in custom cell implementations - it should be sufficient to simply call this method when appropriate (e.g., when the user pressed the Enter key, you may do something like cell.commitEdit(converter.fromString(textField.getText()));

Annotations
@Override
createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.TableCell.createDefaultSkin.

Doc from javafx.scene.control.TableCell.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
dragSelectback to summary
private void dragSelect(MouseEvent e)

Method that will select all the cells between the drag place and that cell.

getAnchorback to summary
pack-priv static TablePositionBase<?> getAnchor(Control table, TablePositionBase<?> focusedCell)
getAvailableTooltipback to summary
private Tooltip getAvailableTooltip()

See if a tootlip is available (either on the TableCell already, or in the Stack). And then set it to the TableCell.

getDragDropHandlerback to summary
private EventHandler<DragEvent> getDragDropHandler()
getDragOverHandlerback to summary
private EventHandler<DragEvent> getDragOverHandler()
getEditorback to summary
private GridCellEditor getEditor(final SpreadsheetCell cell, final SpreadsheetView spv)

Return an instance of Editor specific to the Cell type We are not using the build-in editor-Cell because we cannot know in advance which editor we will need. Furthermore, we want to control the behavior very closely in regards of the spanned cell (invisible etc).

Parameters
cell:SpreadsheetCell

The SpreadsheetCell

getFilterback to summary
pack-priv Filter getFilter()

Return the Filter associated to this cell or null otherwise.

getValueback to summary
public static void getValue(final Runnable runnable)

Will safely execute the request on the JFX thread by checking whether we are on the JFX thread or not.

hasAnchorback to summary
pack-priv static boolean hasAnchor(Control table)
initStyleListenerback to summary
private void initStyleListener()
isOriginalCellback to summary
public boolean isOriginalCell()

Return true if this cell is the original cell (including filters) even when scrolling.

Returns:boolean

true if this cell is the original cell (including filters) even when scrolling

layoutChildrenback to summary
protected void layoutChildren()

Overrides javafx.scene.control.TableCell.layoutChildren.

Doc from javafx.scene.control.Cell.layoutChildren.

Invoked during the layout pass to layout the children in this Parent. By default it will only set the size of managed, resizable content to their preferred sizes and does not do any node positioning.

Subclasses should override this function to layout content as needed.

Annotations
@Override
releaseCellGraphicback to summary
public void releaseCellGraphic()

Releases and remove the graphic if any has been defined. Useful when the graphic comes from the SpreadsheetView#getCellGraphicFactory() and explicitly needs to be given back.

removeAnchorback to summary
pack-priv static void removeAnchor(Control table)
setAnchorback to summary
pack-priv static void setAnchor(Control table, TablePositionBase<TC extends TableColumnBase<S, T>> anchor)
setBrowserGraphicback to summary
private void setBrowserGraphic(SpreadsheetCell item)

Sets the browser in the cell.

setCellGraphicback to summary
private void setCellGraphic(SpreadsheetCell item)

Set the cell graphic if any. If we have an Image, we try to make it take its full size (never more) within the cell's space. If we have some row span, we want to compute the image's size one time and then

Parameters
item:SpreadsheetCell

the SpreadsheetCell to set the graphic to

showback to summary
public void show(final SpreadsheetCell cell)

Called in the gridRowSkinBase when doing layout This allow not to override opacity in the row and let the cell handle itself

startEditback to summary
public void startEdit()

Overrides javafx.scene.control.TableCell.startEdit.

Public Methods * *

Annotations
@Override
updateItemback to summary
public void updateItem(final SpreadsheetCell item, boolean empty)

Overrides javafx.scene.control.Cell.updateItem.

Doc from javafx.scene.control.Cell.updateItem.

The updateItem method should not be called by developers, but it is the best method for developers to override to allow for them to customise the visuals of the cell. To clarify, developers should never call this method in their code (they should leave it up to the UI control, such as the javafx.scene.control.ListView control) to call this method. However, the purpose of having the updateItem method is so that developers, when specifying custom cell factories (again, like the ListView cell factory), the updateItem method can be overridden to allow for complete customisation of the cell.

It is very important that subclasses of Cell override the updateItem method properly, as failure to do so will lead to issues such as blank cells or cells with unexpected content appearing within them. Here is an example of how to properly override the updateItem method:

protected void updateItem(T item, boolean empty) {
    super.updateItem(item, empty);

    if (empty || item == null) {
        setText(null);
        setGraphic(null);
    } else {
        setText(item.toString());
    }
}

Note in this code sample two important points:

  1. We call the super.updateItem(T, boolean) method. If this is not done, the item and empty properties are not correctly set, and you are likely to end up with graphical issues.
  2. We test for the empty condition, and if true, we set the text and graphic properties to null. If we do not do this, it is almost guaranteed that end users will see graphical artifacts in cells unexpectedly.
Annotations
@Override