public class NatTable extends org.eclipse.swt.widgets.Canvas implements ILayer, org.eclipse.swt.events.PaintListener, IClientAreaProvider, ILayerListener, IPersistable
Modifier and Type | Field and Description |
---|---|
protected Collection<IConfiguration> |
configurations |
static int |
DEFAULT_STYLE_OPTIONS |
protected String |
id |
DOT, VALUE_SEPARATOR
DEFAULT
Constructor and Description |
---|
NatTable(org.eclipse.swt.widgets.Composite parent) |
NatTable(org.eclipse.swt.widgets.Composite parent,
boolean autoconfigure) |
NatTable(org.eclipse.swt.widgets.Composite parent,
ILayer layer) |
NatTable(org.eclipse.swt.widgets.Composite parent,
ILayer layer,
boolean autoconfigure) |
NatTable(org.eclipse.swt.widgets.Composite parent,
int style) |
NatTable(org.eclipse.swt.widgets.Composite parent,
int style,
boolean autoconfigure) |
NatTable(org.eclipse.swt.widgets.Composite parent,
int style,
ILayer layer) |
NatTable(org.eclipse.swt.widgets.Composite parent,
int style,
ILayer layer,
boolean autoconfigure) |
Modifier and Type | Method and Description |
---|---|
void |
addConfiguration(IConfiguration configuration)
Adds a configuration to the table.
|
void |
addDragSupport(int operations,
org.eclipse.swt.dnd.Transfer[] transferTypes,
org.eclipse.swt.dnd.DragSourceListener listener)
Adds support for dragging items out of this control via a user
drag-and-drop operation.
|
void |
addDropSupport(int operations,
org.eclipse.swt.dnd.Transfer[] transferTypes,
org.eclipse.swt.dnd.DropTargetListener listener)
Adds support for dropping items into this control via a user drag-and-drop
operation.
|
void |
addLayerListener(ILayerListener listener) |
void |
addOverlayPainter(IOverlayPainter overlayPainter) |
protected void |
checkSubclass() |
void |
configure()
Processes all the registered
IConfiguration (s). |
void |
configure(ConfigRegistry configRegistry,
UiBindingRegistry uiBindingRegistry)
Every layer gets this call back, starting at the top of the stack.
|
boolean |
doCommand(ILayerCommand command)
Opportunity to respond to a command as it flows down the stack.
|
void |
fireLayerEvent(ILayerEvent event)
Events can be fired to notify other components of the grid.
|
boolean |
forceFocus() |
org.eclipse.swt.graphics.Rectangle |
getBoundsByPosition(int columnPosition,
int rowPosition)
Calculates the bounds in pixel for the given cell position.
|
ILayerCell |
getCellByPosition(int columnPosition,
int rowPosition) |
ICellPainter |
getCellPainter(int columnPosition,
int rowPosition,
ILayerCell cell,
IConfigRegistry configRegistry) |
IClientAreaProvider |
getClientAreaProvider() |
int |
getColumnCount() |
int |
getColumnIndexByPosition(int columnPosition)
Gets the underlying non-transformed column index for the given column position.
|
int |
getColumnPositionByX(int x)
Returns the column position that contains the given x coordinate.
|
int |
getColumnWidthByPosition(int columnPosition)
Returns the width in pixels of the given column.
|
LabelStack |
getConfigLabelsByPosition(int columnPosition,
int rowPosition) |
IConfigRegistry |
getConfigRegistry() |
Object |
getDataValueByPosition(int columnPosition,
int rowPosition) |
String |
getDisplayModeByPosition(int columnPosition,
int rowPosition) |
int |
getHeight()
Returns the total height in pixels of this layer.
|
String |
getID() |
ILayer |
getLayer() |
ILayerPainter |
getLayerPainter() |
List<IOverlayPainter> |
getOverlayPainters() |
int |
getPreferredColumnCount() |
int |
getPreferredHeight() |
int |
getPreferredRowCount() |
int |
getPreferredWidth() |
LabelStack |
getRegionLabelsByXY(int x,
int y)
Layer can apply its own labels to any cell it wishes.
|
int |
getRowCount() |
int |
getRowHeightByPosition(int rowPosition)
Returns the height in pixels of the given row.
|
int |
getRowIndexByPosition(int rowPosition)
Gets the underlying non-transformed row index for the given row position.
|
int |
getRowPositionByY(int y)
Returns the row position that contains the given y coordinate.
|
int |
getStartXOfColumnPosition(int columnPosition)
Returns the x offset in pixels of the given column.
|
int |
getStartYOfRowPosition(int rowPosition)
Returns the y offset in pixels of the given row.
|
UiBindingRegistry |
getUiBindingRegistry() |
ILayer |
getUnderlyingLayerByPosition(int columnPosition,
int rowPosition) |
Collection<ILayer> |
getUnderlyingLayersByColumnPosition(int columnPosition) |
Collection<ILayer> |
getUnderlyingLayersByRowPosition(int rowPosition) |
protected IEventConflater |
getVisualChangeEventConflater() |
int |
getWidth()
Returns the total width in pixels of this layer.
|
void |
handleLayerEvent(ILayerEvent event)
Handle an event notification from an
ILayer |
boolean |
hasLayerListener(Class<? extends ILayerListener> layerListenerClass) |
protected void |
initInternalListener() |
boolean |
isColumnPositionResizable(int columnPosition) |
boolean |
isRowPositionResizable(int rowPosition) |
void |
loadState(String prefix,
Properties properties)
Restore the state of the underlying layers from the values in the properties object.
|
int |
localToUnderlyingColumnPosition(int localColumnPosition)
Convert a column position to the coordinates of the underlying layer.
|
int |
localToUnderlyingRowPosition(int localRowPosition) |
void |
paintControl(org.eclipse.swt.events.PaintEvent event) |
void |
refresh()
Refreshes the entire NatTable as every layer will be refreshed.
|
void |
registerCommandHandler(ILayerCommandHandler<?> commandHandler) |
void |
registerPersistable(IPersistable persistable)
Persistables registered with a layer will have a chance to write their data out to the
Properties instance when the layer is persisted. |
void |
removeLayerListener(ILayerListener listener) |
void |
removeOverlayPainter(IOverlayPainter overlayPainter) |
void |
repaintColumn(int columnPosition)
Repaint only a specific column in the grid.
|
void |
repaintRow(int rowPosition)
Repaint only a specific row in the grid.
|
void |
saveState(String prefix,
Properties properties)
Save the state of the table to the properties object.
|
void |
setClientAreaProvider(IClientAreaProvider clientAreaProvider) |
void |
setConfigRegistry(IConfigRegistry configRegistry) |
void |
setLayer(ILayer layer) |
void |
setLayerPainter(ILayerPainter layerPainter) |
void |
setUiBindingRegistry(UiBindingRegistry uiBindingRegistry) |
int |
underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer,
int underlyingColumnPosition) |
Collection<Range> |
underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer,
Collection<Range> underlyingColumnPositionRanges) |
int |
underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer,
int underlyingRowPosition) |
Collection<Range> |
underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer,
Collection<Range> underlyingRowPositionRanges) |
void |
unregisterCommandHandler(Class<? extends ILayerCommand> commandClass) |
void |
unregisterPersistable(IPersistable persistable) |
void |
updateResize() |
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIME
changed, computeSize, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
addControlListener, addDragDetectListener, addFocusListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTraverseListener, computeSize, dragDetect, dragDetect, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getRegion, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setRegion, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getClientArea
public static final int DEFAULT_STYLE_OPTIONS
protected final Collection<IConfiguration> configurations
protected String id
public NatTable(org.eclipse.swt.widgets.Composite parent)
public NatTable(org.eclipse.swt.widgets.Composite parent, boolean autoconfigure)
parent
- widget for the table.autoconfigure
- if set to False
- No auto configuration is done
- Default settings are not loaded. Configuration(s) have to be manually
added by invoking addConfiguration(). At the minimum the DefaultNatTableStyleConfiguration
must be added for the table to render.public NatTable(org.eclipse.swt.widgets.Composite parent, ILayer layer)
public NatTable(org.eclipse.swt.widgets.Composite parent, ILayer layer, boolean autoconfigure)
public NatTable(org.eclipse.swt.widgets.Composite parent, int style)
public NatTable(org.eclipse.swt.widgets.Composite parent, int style, boolean autoconfigure)
public NatTable(org.eclipse.swt.widgets.Composite parent, int style, ILayer layer)
public NatTable(org.eclipse.swt.widgets.Composite parent, int style, ILayer layer, boolean autoconfigure)
protected IEventConflater getVisualChangeEventConflater()
public ILayer getLayer()
public void setLayer(ILayer layer)
public void addConfiguration(IConfiguration configuration)
Configurations are processed when the configure()
method is invoked.
Each configuration object then has a chance to configure the
public IConfigRegistry getConfigRegistry()
IConfigRegistry
used to hold the configuration bindings
by Layer, DisplayMode and Config labels.public void setConfigRegistry(IConfigRegistry configRegistry)
public UiBindingRegistry getUiBindingRegistry()
public void setUiBindingRegistry(UiBindingRegistry uiBindingRegistry)
public String getID()
protected void checkSubclass()
checkSubclass
in class org.eclipse.swt.widgets.Composite
protected void initInternalListener()
public boolean forceFocus()
forceFocus
in class org.eclipse.swt.widgets.Control
public List<IOverlayPainter> getOverlayPainters()
public void addOverlayPainter(IOverlayPainter overlayPainter)
public void removeOverlayPainter(IOverlayPainter overlayPainter)
public void paintControl(org.eclipse.swt.events.PaintEvent event)
paintControl
in interface org.eclipse.swt.events.PaintListener
public ILayerPainter getLayerPainter()
getLayerPainter
in interface ILayer
public void setLayerPainter(ILayerPainter layerPainter)
public void repaintColumn(int columnPosition)
columnPosition
- column of the grid to repaintpublic void repaintRow(int rowPosition)
rowPosition
- row of the grid to repaintpublic void updateResize()
public void refresh()
public void configure(ConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry)
ILayer
configure()
method. This is an opportunity to add
any key/mouse bindings and other general configuration.public void configure()
IConfiguration
(s).
All the underlying layers are walked and given a chance to configure.
Note: all desired configuration tweaks must be done before this method is invoked.public void handleLayerEvent(ILayerEvent event)
ILayerListener
ILayer
handleLayerEvent
in interface ILayerListener
event
- the eventpublic void saveState(String prefix, Properties properties)
IPersistable.saveState(String, Properties)
is invoked on all the underlying layers.
This properties object will be populated with the settings of all underlying layers
and any IPersistable
registered with those layers.saveState
in interface IPersistable
prefix
- The prefix to use for the state keys. Is also used as the state
configuration name.properties
- The Properties instance to save the state to.public void loadState(String prefix, Properties properties)
loadState
in interface IPersistable
prefix
- The prefix to use for the state keys. Is also used as the state
configuration name.properties
- The Properties instance to load the state from.saveState(String, Properties)
public void registerPersistable(IPersistable persistable)
ILayer
Properties
instance when the layer is persisted.registerPersistable
in interface ILayer
persistable
- the persistable to be registeredILayer.registerPersistable(IPersistable)
public void unregisterPersistable(IPersistable persistable)
unregisterPersistable
in interface ILayer
public boolean doCommand(ILayerCommand command)
ILayer
ILayerCommand.convertToTargetLayer(ILayer)
public void registerCommandHandler(ILayerCommandHandler<?> commandHandler)
registerCommandHandler
in interface ILayer
public void unregisterCommandHandler(Class<? extends ILayerCommand> commandClass)
unregisterCommandHandler
in interface ILayer
public void fireLayerEvent(ILayerEvent event)
ILayer
Example: When the contents of the grid change IVisualChangeEvent
can be
fired to notify other layers to refresh their caches etc.
fireLayerEvent
in interface ILayer
event
- the event to firepublic void addLayerListener(ILayerListener listener)
addLayerListener
in interface ILayer
public void removeLayerListener(ILayerListener listener)
removeLayerListener
in interface ILayer
public boolean hasLayerListener(Class<? extends ILayerListener> layerListenerClass)
hasLayerListener
in interface ILayer
layerListenerClass
- The type of ILayerListener
to check for existencetrue
if this ILayer
has a ILayerListener
registered for the specified type, false
if there is
no such listener registered alreadypublic int getColumnCount()
getColumnCount
in interface ILayer
public int getPreferredColumnCount()
getPreferredColumnCount
in interface ILayer
public int getColumnIndexByPosition(int columnPosition)
ILayer
getColumnIndexByPosition
in interface ILayer
columnPosition
- a column position relative to this coordinate modelpublic int localToUnderlyingColumnPosition(int localColumnPosition)
ILayer
localToUnderlyingColumnPosition
in interface ILayer
localColumnPosition
- column position in local (the layer's own) coordinatespublic int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition)
underlyingToLocalColumnPosition
in interface ILayer
public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges)
underlyingToLocalColumnPositions
in interface ILayer
public int getWidth()
ILayer
public int getPreferredWidth()
getPreferredWidth
in interface ILayer
public int getColumnWidthByPosition(int columnPosition)
ILayer
getColumnWidthByPosition
in interface ILayer
columnPosition
- the column position in this layerpublic boolean isColumnPositionResizable(int columnPosition)
isColumnPositionResizable
in interface ILayer
public int getColumnPositionByX(int x)
ILayer
getColumnPositionByX
in interface ILayer
x
- a horizontal pixel location relative to the pixel boundary of this layerpublic int getStartXOfColumnPosition(int columnPosition)
ILayer
getStartXOfColumnPosition
in interface ILayer
columnPosition
- the column position in this layerpublic Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition)
getUnderlyingLayersByColumnPosition
in interface ILayer
public int getRowCount()
getRowCount
in interface ILayer
public int getPreferredRowCount()
getPreferredRowCount
in interface ILayer
public int getRowIndexByPosition(int rowPosition)
ILayer
getRowIndexByPosition
in interface ILayer
rowPosition
- a row position relative to this coordinate modelpublic int localToUnderlyingRowPosition(int localRowPosition)
localToUnderlyingRowPosition
in interface ILayer
public int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition)
underlyingToLocalRowPosition
in interface ILayer
public Collection<Range> underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingRowPositionRanges)
underlyingToLocalRowPositions
in interface ILayer
public int getHeight()
ILayer
public int getPreferredHeight()
getPreferredHeight
in interface ILayer
public int getRowHeightByPosition(int rowPosition)
ILayer
getRowHeightByPosition
in interface ILayer
rowPosition
- the row position in this layerpublic boolean isRowPositionResizable(int rowPosition)
isRowPositionResizable
in interface ILayer
public int getRowPositionByY(int y)
ILayer
getRowPositionByY
in interface ILayer
y
- a vertical pixel location relative to the pixel boundary of this layerpublic int getStartYOfRowPosition(int rowPosition)
ILayer
getStartYOfRowPosition
in interface ILayer
rowPosition
- the row position in this layerpublic Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition)
getUnderlyingLayersByRowPosition
in interface ILayer
public ILayerCell getCellByPosition(int columnPosition, int rowPosition)
getCellByPosition
in interface ILayer
public org.eclipse.swt.graphics.Rectangle getBoundsByPosition(int columnPosition, int rowPosition)
ILayer
getBoundsByPosition
in interface ILayer
columnPosition
- the column position of the cellrowPosition
- the row position of the cellnull
if there are no valid boundspublic String getDisplayModeByPosition(int columnPosition, int rowPosition)
getDisplayModeByPosition
in interface ILayer
columnPosition
- the column position of the cellrowPosition
- the row position of the cellDisplayMode
for the cell at the given position.
The DisplayMode
affects the settings out of the ConfigRegistry
.
Display mode is NORMAL by default.
Example: SelectionLayer
overrides this to return the SELECT
label for cells which are selected.
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
getConfigLabelsByPosition
in interface ILayer
public Object getDataValueByPosition(int columnPosition, int rowPosition)
getDataValueByPosition
in interface ILayer
public ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry)
getCellPainter
in interface ILayer
public LabelStack getRegionLabelsByXY(int x, int y)
ILayer
getRegionLabelsByXY
in interface ILayer
x
- the x pixel coordinatey
- the y pixel coordinatepublic ILayer getUnderlyingLayerByPosition(int columnPosition, int rowPosition)
getUnderlyingLayerByPosition
in interface ILayer
public IClientAreaProvider getClientAreaProvider()
getClientAreaProvider
in interface ILayer
public void setClientAreaProvider(IClientAreaProvider clientAreaProvider)
setClientAreaProvider
in interface ILayer
public void addDragSupport(int operations, org.eclipse.swt.dnd.Transfer[] transferTypes, org.eclipse.swt.dnd.DragSourceListener listener)
operations
- a bitwise OR of the supported drag and drop operation types (
DROP_COPY
,DROP_LINK
, and
DROP_MOVE
)transferTypes
- the transfer types that are supported by the drag operationlistener
- the callback that will be invoked to set the drag data and to
cleanup after the drag and drop operation finishesDND
public void addDropSupport(int operations, org.eclipse.swt.dnd.Transfer[] transferTypes, org.eclipse.swt.dnd.DropTargetListener listener)
operations
- a bitwise OR of the supported drag and drop operation types (
DROP_COPY
,DROP_LINK
, and
DROP_MOVE
)transferTypes
- the transfer types that are supported by the drop operationlistener
- the callback that will be invoked after the drag and drop
operation finishesDND
Copyright © 2013. All Rights Reserved.