public class SpreadsheetView extends Control
TableView
control but with different functionalities and use cases. The aim is to have
a powerful grid where data can be written and retrieved.
SpreadsheetView
so that they
are always visible on screen.SpreadsheetView
so that
they are always visible on screen. Only columns without any spanning cells
can be fixed.getFixedRows()
and getFixedColumns()
. But you
are strongly advised to check if it's possible to do so with
SpreadsheetColumn.isColumnFixable()
for the fixed columns and with
isRowFixable(int)
for the fixed rows. Calling those methods prior
every move will ensure that no exception will be thrown.
setShowRowHeader(boolean)
or setShowColumnHeader(boolean)
.
getRowPickers()
and getColumnPickers()
. Then you can provide
a custom CallBack with setRowPickerCallback(javafx.util.Callback)
and
setColumnPickerCallback(javafx.util.Callback)
in order to react when
the user click on the picker. The Callback gives you the index of the picker.
.picker-label{ -fx-graphic: url("add.png"); -fx-background-color: transparent; -fx-padding: 0 0 0 0; }
SpreadsheetCellType
of the receiving cell. Pasting a Double into a
String will work but the reverse operation will not.
SpreadsheetCellType
Value Verification documentation for more
information.
TableView
, you instantiate the
underlying model, a Grid
. You will create some rows filled with SpreadsheetCell
.
int rowCount = 15; int columnCount = 10; GridBase grid = new GridBase(rowCount, columnCount); ObservableList<ObservableList<SpreadsheetCell>> rows = FXCollections.observableArrayList(); for (int row = 0; row < grid.getRowCount(); ++row) { final ObservableList<SpreadsheetCell> list = FXCollections.observableArrayList(); for (int column = 0; column < grid.getColumnCount(); ++column) { list.add(SpreadsheetCellType.STRING.createCell(row, column, 1, 1,"value")); } rows.add(list); } grid.setRows(rows); SpreadsheetView spv = new SpreadsheetView(grid);At that moment you can span some of the cells with the convenient method provided by the grid. Then you just need to instantiate the SpreadsheetView.
SpreadsheetCell
,
SpreadsheetCellBase
,
SpreadsheetColumn
,
Grid
,
GridBase
Type | Property and Description |
---|---|
BooleanProperty |
editable
Specifies whether this SpreadsheetView is editable - only if the
SpreadsheetView, and the
SpreadsheetCell within it are both
editable will a SpreadsheetCell be able to go into its editing
state. |
ReadOnlyBooleanProperty |
fixingColumnsAllowed
Return the Boolean property associated with the allowance of fixing or
unfixing some columns.
|
ReadOnlyBooleanProperty |
fixingRowsAllowed
Return the Boolean property associated with the allowance of fixing or
unfixing some rows.
|
ReadOnlyObjectProperty<Grid> |
grid
Return a
ReadOnlyObjectProperty containing the current Grid
used in the SpreadsheetView. |
BooleanProperty |
showColumnHeader
BooleanProperty associated with the column Header.
|
BooleanProperty |
showRowHeader
BooleanProperty associated with the row Header.
|
contextMenuProperty, skinClassNameProperty, skinProperty, tooltipProperty
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, heightProperty, insetsProperty, maxHeightProperty, maxWidthProperty, minHeightProperty, minWidthProperty, opaqueInsetsProperty, paddingProperty, prefHeightProperty, prefWidthProperty, scaleShapeProperty, shapeProperty, snapToPixelProperty, widthProperty
impl_traversalEngineProperty, needsLayoutProperty
blendModeProperty, boundsInLocalProperty, boundsInParentProperty, cacheHintProperty, cacheProperty, clipProperty, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, focusedProperty, focusTraversableProperty, hoverProperty, idProperty, impl_showMnemonicsProperty, impl_treeVisibleProperty, inputMethodRequestsProperty, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParentTransformProperty, localToSceneTransformProperty, managedProperty, mouseTransparentProperty, nodeOrientationProperty, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, pickOnBoundsProperty, pressedProperty, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, styleProperty, translateXProperty, translateYProperty, translateZProperty, visibleProperty
Modifier and Type | Class and Description |
---|---|
static class |
SpreadsheetView.SpanType
The SpanType describes in which state each cell can be.
|
USE_COMPUTED_SIZE, USE_PREF_SIZE
BASELINE_OFFSET_SAME_AS_HEIGHT
Constructor and Description |
---|
SpreadsheetView()
Creates a default SpreadsheetView control with no content and a Grid set
to null.
|
SpreadsheetView(Grid grid)
Creates a SpreadsheetView control with the
Grid specified. |
Modifier and Type | Method and Description |
---|---|
void |
copyClipboard()
Put the current selection into the ClipBoard.
|
void |
deleteSelectedCells()
This method is called when pressing the "delete" key on the
SpreadsheetView.
|
BooleanProperty |
editableProperty()
Specifies whether this SpreadsheetView is editable - only if the
SpreadsheetView, and the
SpreadsheetCell within it are both
editable will a SpreadsheetCell be able to go into its editing
state. |
ReadOnlyBooleanProperty |
fixingColumnsAllowedProperty()
Return the Boolean property associated with the allowance of fixing or
unfixing some columns.
|
ReadOnlyBooleanProperty |
fixingRowsAllowedProperty()
Return the Boolean property associated with the allowance of fixing or
unfixing some rows.
|
Callback<Integer,Void> |
getColumnPickerCallback() |
ObservableList<Integer> |
getColumnPickers() |
ObservableList<SpreadsheetColumn> |
getColumns()
Return an unmodifiable observableList of the
SpreadsheetColumn
used. |
TablePosition<ObservableList<SpreadsheetCell>,?> |
getEditingCell()
Return a
TablePosition of cell being currently edited. |
Optional<SpreadsheetCellEditor> |
getEditor(SpreadsheetCellType<?> cellType)
Return the editor associated with the CellType.
|
ObservableList<SpreadsheetColumn> |
getFixedColumns()
You can fix or unfix a column by modifying this list.
|
ObservableList<Integer> |
getFixedRows()
You can fix or unfix a row by modifying this list.
|
Grid |
getGrid()
Return the model Grid used by the SpreadsheetView
|
double |
getRowHeight(int row) |
Callback<Integer,Void> |
getRowPickerCallback() |
ObservableList<Integer> |
getRowPickers() |
TableView.TableViewSelectionModel<ObservableList<SpreadsheetCell>> |
getSelectionModel()
Return the selectionModel used by the SpreadsheetView.
|
SpreadsheetView.SpanType |
getSpanType(int row,
int column)
Return the
SpreadsheetView.SpanType of a cell, this is a shorcut for
Grid.getSpanType(org.controlsfx.control.spreadsheet.SpreadsheetView, int, int) . |
ContextMenu |
getSpreadsheetViewContextMenu()
Create a menu on rightClick with two options: Copy/Paste This can be
overridden by developers for custom behavior.
|
ReadOnlyObjectProperty<Grid> |
gridProperty()
Return a
ReadOnlyObjectProperty containing the current Grid
used in the SpreadsheetView. |
boolean |
isColumnFixable(int columnIndex)
Indicate whether this column can be fixed or not.
|
boolean |
isEditable()
Gets the value of the property editable.
|
boolean |
isFixingColumnsAllowed()
Return whether change to Fixed columns are allowed.
|
boolean |
isFixingRowsAllowed()
Return whether change to Fixed rows are allowed.
|
boolean |
isRowFixable(int row)
Indicate whether a row can be fixed or not.
|
boolean |
isShowColumnHeader()
Return if the Column Header is showing.
|
boolean |
isShowRowHeader()
Return if the row Header is showing.
|
void |
pasteClipboard()
Try to paste the clipBoard to the specified position.
|
void |
resizeRowsToDefault()
This method will wipe all changes made to the row's height and set all row's
height back to their default height defined in the model Grid.
|
void |
resizeRowsToFitContent()
This method will compute the best height for each line.
|
void |
resizeRowsToMaximum()
This method will first apply
resizeRowsToFitContent() and then
take the highest height and apply it to every row.\n
Just as resizeRowsToFitContent() , this method can be degrading
your performance on great grid. |
void |
setColumnPickerCallback(Callback<Integer,Void> callback)
Set a custom callback for the Column picker.
|
void |
setEditable(boolean b)
Sets the value of the property editable.
|
void |
setFixingColumnsAllowed(boolean b)
If set to true, user will be allowed to fix and unfix the columns.
|
void |
setFixingRowsAllowed(boolean b)
If set to true, user will be allowed to fix and unfix the rows.
|
void |
setGrid(Grid grid)
Set a new Grid for the SpreadsheetView.
|
void |
setRowPickerCallback(Callback<Integer,Void> callback)
Set a custom callback for the Row picker.
|
void |
setShowColumnHeader(boolean b)
Activate and deactivate the Column Header
|
void |
setShowRowHeader(boolean b)
Activate and deactivate the Row Header.
|
BooleanProperty |
showColumnHeaderProperty()
BooleanProperty associated with the column Header.
|
BooleanProperty |
showRowHeaderProperty()
BooleanProperty associated with the row Header.
|
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, createDefaultSkin, getBaselineOffset, getClassCssMetaData, getContextMenu, getControlCssMetaData, getCssMetaData, getSkin, getTooltip, getUserAgentStylesheet, impl_cssGetFocusTraversableInitialValue, impl_processCSS, isResizable, layoutChildren, setContextMenu, setSkin, setTooltip, skinClassNameProperty, skinProperty, tooltipProperty
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getWidth, heightProperty, impl_computeContains, impl_computeGeomBounds, impl_computeLayoutBounds, impl_createPeer, impl_notifyLayoutBoundsChanged, impl_pickNodeLocal, impl_updatePeer, insetsProperty, isCacheShape, isCenterShape, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapSize, snapSpace, snapToPixelProperty, widthProperty
getChildren, getChildrenUnmodifiable, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBounds
addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, containsBounds, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, hasProperties, hoverProperty, idProperty, impl_clearDirty, impl_computeIntersects, impl_cssGetCursorInitialValue, impl_geomChanged, impl_getAccessible, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_intersects, impl_intersectsBounds, impl_isDirty, impl_isDirtyEmpty, impl_isShowMnemonics, impl_isTreeVisible, impl_layoutBoundsChanged, impl_markDirty, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, impl_treeVisibleProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visibleProperty
public final ReadOnlyObjectProperty<Grid> gridProperty
ReadOnlyObjectProperty
containing the current Grid
used in the SpreadsheetView.getGrid()
,
setGrid(Grid)
public ReadOnlyBooleanProperty fixingRowsAllowedProperty
public ReadOnlyBooleanProperty fixingColumnsAllowedProperty
public final BooleanProperty showColumnHeaderProperty
isShowColumnHeader()
,
setShowColumnHeader(boolean)
public final BooleanProperty showRowHeaderProperty
isShowRowHeader()
,
setShowRowHeader(boolean)
public final BooleanProperty editableProperty
SpreadsheetCell
within it are both
editable will a SpreadsheetCell
be able to go into its editing
state.isEditable()
,
setEditable(boolean)
public SpreadsheetView()
public final void setGrid(Grid grid)
SpreadsheetView(Grid)
. So this is useful when you want to
refresh your SpreadsheetView with a new model. This will keep the state
of your SpreadsheetView (position of the bar, number of fixedRows etc).grid
- the new Gridpublic TablePosition<ObservableList<SpreadsheetCell>,?> getEditingCell()
TablePosition
of cell being currently edited.TablePosition
of cell being currently edited.public ObservableList<SpreadsheetColumn> getColumns()
SpreadsheetColumn
used.public final Grid getGrid()
public final ReadOnlyObjectProperty<Grid> gridProperty()
ReadOnlyObjectProperty
containing the current Grid
used in the SpreadsheetView.getGrid()
,
setGrid(Grid)
public ObservableList<Integer> getFixedRows()
isRowFixable(int)
before trying to fix a row. See
SpreadsheetView
description for information.public boolean isRowFixable(int row)
getFixedRows()
.row
- public boolean isFixingRowsAllowed()
public void setFixingRowsAllowed(boolean b)
b
- public ReadOnlyBooleanProperty fixingRowsAllowedProperty()
public ObservableList<SpreadsheetColumn> getFixedColumns()
SpreadsheetColumn.isColumnFixable()
on the column before adding
an item.public boolean isColumnFixable(int columnIndex)
SpreadsheetColumn
, call
SpreadsheetColumn.isColumnFixable()
on it directly. Call that
method before adding an item with getFixedColumns()
.columnIndex
- public boolean isFixingColumnsAllowed()
public void setFixingColumnsAllowed(boolean b)
b
- public ReadOnlyBooleanProperty fixingColumnsAllowedProperty()
public final void setShowColumnHeader(boolean b)
b
- public final boolean isShowColumnHeader()
public final BooleanProperty showColumnHeaderProperty()
isShowColumnHeader()
,
setShowColumnHeader(boolean)
public final void setShowRowHeader(boolean b)
b
- public final boolean isShowRowHeader()
public final BooleanProperty showRowHeaderProperty()
isShowRowHeader()
,
setShowRowHeader(boolean)
public ObservableList<Integer> getRowPickers()
public void setRowPickerCallback(Callback<Integer,Void> callback)
callback
- public Callback<Integer,Void> getRowPickerCallback()
public ObservableList<Integer> getColumnPickers()
public void setColumnPickerCallback(Callback<Integer,Void> callback)
callback
- public Callback<Integer,Void> getColumnPickerCallback()
public void resizeRowsToFitContent()
public void resizeRowsToMaximum()
resizeRowsToFitContent()
and then
take the highest height and apply it to every row.\n
Just as resizeRowsToFitContent()
, this method can be degrading
your performance on great grid.public void resizeRowsToDefault()
public double getRowHeight(int row)
row
- public TableView.TableViewSelectionModel<ObservableList<SpreadsheetCell>> getSelectionModel()
TableView.TableViewSelectionModel
public final Optional<SpreadsheetCellEditor> getEditor(SpreadsheetCellType<?> cellType)
SpreadsheetCellType.createEditor(SpreadsheetView)
. FIXME Maybe
keep the editor references inside the SpreadsheetCellTypecellType
- public final void setEditable(boolean b)
b
- public final boolean isEditable()
public final BooleanProperty editableProperty()
SpreadsheetCell
within it are both
editable will a SpreadsheetCell
be able to go into its editing
state.isEditable()
,
setEditable(boolean)
public void copyClipboard()
public void pasteClipboard()
public ContextMenu getSpreadsheetViewContextMenu()
public void deleteSelectedCells()
public SpreadsheetView.SpanType getSpanType(int row, int column)
SpreadsheetView.SpanType
of a cell, this is a shorcut for
Grid.getSpanType(org.controlsfx.control.spreadsheet.SpreadsheetView, int, int)
.row
- column
- SpreadsheetView.SpanType
of a cell