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.
SpreadsheetCellType of the receiving cell. Pasting a Double into a
String will work but the reverse operation will not. TableView, you instantiate the
underlying model, a Grid. You will create some ObservableList<
SpreadsheetCell> filled with SpreadsheetCell.
int rowCount = 15;
int columnCount = 10;
Grid grid = new Grid(rowCount, columnCount);
ArrayList<ObservableList<DataCell>> rows = new ArrayList<ObservableList<DataCell>>(grid.getRowCount());
for (int row = 0; row < grid.getRowCount(); ++row) {
final ObservableList<DataCell> ObservableList<DataCell> = new ObservableList<DataCell>(row, grid.getColumnCount());
for (int column = 0; column < grid.getColumnCount(); ++column) {
ObservableList<DataCell>.add(SpreadsheetCellType.STRING.createCell(row, column, 1, 1,""));
}
rows.add(ObservableList<DataCell>);
}
grid.setRows(rows);
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,
SpreadsheetColumn,
Grid| 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 |
BooleanProperty |
showColumnHeader
BooleanProperty associated with the column Header.
|
BooleanProperty |
showRowHeader
BooleanProperty associated with the row Header.
|
contextMenuProperty, skinClassNameProperty, skinProperty, tooltipPropertybackgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, heightProperty, insetsProperty, maxHeightProperty, maxWidthProperty, minHeightProperty, minWidthProperty, opaqueInsetsProperty, paddingProperty, prefHeightProperty, prefWidthProperty, scaleShapeProperty, shapeProperty, snapToPixelProperty, widthPropertyimpl_traversalEngineProperty, needsLayoutPropertyblendModeProperty, 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_SIZEBASELINE_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.
|
ObservableList<SpreadsheetColumn> |
getColumns()
Return an unmodifiable observableList of the
SpreadsheetColumn
used. |
TablePosition<ObservableList<SpreadsheetCell>,?> |
getEditingCell()
Return a
TablePosition of cell being currently edited. |
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
|
TableView.TableViewSelectionModel<ObservableList<SpreadsheetCell>> |
getSelectionModel()
Return the selectionModel used by the SpreadsheetView.
|
ContextMenu |
getSpreadsheetViewContextMenu()
Create a menu on rightClick with two options: Copy/Paste This can be
overridden by developers for custom behavior.
|
ReadOnlyObjectProperty<Grid> |
gridProperty() |
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 |
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 |
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, tooltipPropertybackgroundProperty, 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, widthPropertygetChildren, getChildrenUnmodifiable, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBoundsaddEventFilter, 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, visiblePropertypublic final ReadOnlyObjectProperty<Grid> gridProperty
getGrid(),
setGrid(Grid)public final BooleanProperty showColumnHeaderProperty
isShowColumnHeader(),
setShowColumnHeader(boolean)public final BooleanProperty showRowHeaderProperty
isShowRowHeader(),
setShowRowHeader(boolean)public ReadOnlyBooleanProperty fixingRowsAllowedProperty
public ReadOnlyBooleanProperty fixingColumnsAllowedProperty
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()
getGrid(),
setGrid(Grid)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> 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 TableView.TableViewSelectionModel<ObservableList<SpreadsheetCell>> getSelectionModel()
TableView.TableViewSelectionModelpublic final 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()