ca.sqlpower.architect.swingui
Class TablePane

java.lang.Object
  extended by ca.sqlpower.architect.swingui.PlayPenComponent
      extended by ca.sqlpower.architect.swingui.ContainerPane<SQLTable,SQLColumn>
          extended by ca.sqlpower.architect.swingui.TablePane
All Implemented Interfaces:
LayoutNode, Selectable, java.awt.dnd.DragSourceListener, java.util.EventListener

public class TablePane
extends ContainerPane<SQLTable,SQLColumn>


Field Summary
static int COLUMN_INDEX_END_OF_PK
          A special column index that represents the gap between the last PK column and the PK line.
static int COLUMN_INDEX_START_OF_NON_PK
          A special column index that represents the gap between the PK line and the first non-PK column.
protected  java.util.Map<SQLColumn,java.util.List<java.awt.Color>> columnHighlight
          Tracks current highlight colours of the columns in this table.
protected  SQLColumn draggingColumn
          During a drag operation where a column is being dragged from this TablePane, this variable points to the column being dragged.
protected  java.util.Set<SQLColumn> hiddenColumns
          Tracks which columns in this table are currently hidden.
protected  int insertionPoint
          This is the column index at which to the insertion point is currently rendered.
 
Fields inherited from class ca.sqlpower.architect.swingui.ContainerPane
ITEM_INDEX_NONE, ITEM_INDEX_TITLE, margin, model, selectedItems
 
Fields inherited from class ca.sqlpower.architect.swingui.PlayPenComponent
backgroundColor, componentPreviouslySelected, foregroundColor, selected
 
Constructor Summary
TablePane(SQLTable m, PlayPenContentPane parent)
           
TablePane(TablePane tp, PlayPenContentPane parent)
           
 
Method Summary
 void addColumnHighlight(SQLColumn column, java.awt.Color colour)
          Changes the foreground colour of a column.
 java.awt.datatransfer.DataFlavor bestImportFlavor(javax.swing.JComponent c, java.awt.datatransfer.DataFlavor[] flavors)
          Chooses the best import flavour from the flavors array for importing into c.
 boolean canImport(javax.swing.JComponent c, java.awt.datatransfer.DataFlavor[] flavors)
          This is set up this way because this DropTargetListener was derived from a TransferHandler.
 int columnIndexToCentreY(int colidx)
          Returns the centre Y coordinate of the given column index.
 java.awt.datatransfer.Transferable createTransferableForSelection()
          Creates a Transferable representation of the currently-selected items.
 void destroy()
          You must call this method when you are done with a TablePane component.
 void dragEnter(java.awt.dnd.DropTargetDragEvent dtde)
          Called while a drag operation is ongoing, when the mouse pointer enters the operable part of the drop site for the DropTarget registered with this listener.
 void dragExit(java.awt.dnd.DropTargetEvent dte)
          Called while a drag operation is ongoing, when the mouse pointer has exited the operable part of the drop site for the DropTarget registered with this listener.
 void dragOver(java.awt.dnd.DropTargetDragEvent dtde)
          Called when a drag operation is ongoing, while the mouse pointer is still over the operable part of the drop site for the DropTarget registered with this listener.
 void drop(java.awt.dnd.DropTargetDropEvent dtde)
          Called when the drag operation has terminated with a drop on the operable part of the drop site for the DropTarget registered with this listener.
 void dropActionChanged(java.awt.dnd.DropTargetDragEvent dtde)
          Called if the user has modified the current drop gesture.
 java.awt.Color getColumnHighlight(int i)
          Returns the current highlight colour for a particular column.
 java.awt.Color getColumnHighlight(SQLColumn column)
           
 java.util.Set<SQLColumn> getHiddenColumns()
           
 int getHiddenPkCount()
          Returns the number of hidden primary key columns
 java.util.List<LayoutEdge> getInboundEdges()
           
 int getInsertionPoint()
          See insertionPoint.
protected  java.util.List<SQLColumn> getItems()
          Returns a list of the items to be displayed with the model.
 java.lang.String getName()
          Returns the user-visible name for this component--often the same as getModel().getName(), but this depends entirely on the subclass's idea of what in the model constitutes its name.
 java.util.List<LayoutEdge> getOutboundEdges()
           
 javax.swing.JPopupMenu getPopup()
          Returns an instance of the popup menu with menu items exclusive to manipulating tablepanes.
 void handleMouseEvent(java.awt.event.MouseEvent evt)
          Performs the component specific actions for the given MouseEvent.
 boolean insertObjects(java.util.List<? extends SQLObject> items, int insertionPoint)
          Inserts the list of SQLObjects into this table at the specified location.
 boolean isFullyQualifiedNameInHeader()
           
 boolean isShowAkTag()
           
 boolean isShowFkTag()
           
 boolean isShowPkTag()
           
 int pointToItemIndex(java.awt.Point p)
          Deprecated. 
 void removeColumnHighlight(SQLColumn column, java.awt.Color colour)
          Removes the given colour highlight from the given column.
 void setFullyQualifiedNameInHeader(boolean fullyQualifiedNameInHeader)
           
 void setInsertionPoint(int ip)
          See insertionPoint.
 java.lang.String toString()
           
 void updateHiddenColumns()
           
 void updateUI()
           
 
Methods inherited from class ca.sqlpower.architect.swingui.ContainerPane
addItemSelectionListener, deSelectEverythingElse, deselectItem, deselectItem, dragDropEnd, dragEnter, dragExit, dragOver, dropActionChanged, fireItemsDeselected, fireItemsSelected, getLocationOnScreen, getMargin, getModel, getNodeName, getSelectedItemIndex, getSelectedItems, isDashed, isItemSelected, isItemSelected, isRounded, removeItemSelectionListener, selectItem, selectItem, selectNone, setDashed, setMargin, setRounded, setSelected
 
Methods inherited from class ca.sqlpower.architect.swingui.PlayPenComponent
addPropertyChangeListener, addPropertyChangeListener, addSelectionListener, contains, firePropertyChange, firePropertyChange, fireSelectionEvent, getBackgroundColor, getBounds, getBounds, getFont, getFontMetrics, getFontRenderContext, getForegroundColor, getHeight, getInsets, getLocation, getLocation, getParent, getPlayPen, getPreferredLocation, getPreferredSize, getSize, getToolTipText, getUI, getWidth, getX, getY, isOpaque, isSelected, paint, removePropertyChangeListener, removeSelectionListener, repaint, repaint, repaint, revalidate, setBackgroundColor, setBounds, setBoundsImpl, setForegroundColor, setInsets, setLocation, setLocation, setOpaque, setSize, setToolTipText, setUI, showPopup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ca.sqlpower.architect.layout.LayoutNode
getBounds, getBounds, getHeight, getLocation, getWidth, getX, getY, setBounds, setLocation, setLocation
 

Field Detail

COLUMN_INDEX_END_OF_PK

public static final int COLUMN_INDEX_END_OF_PK
A special column index that represents the gap between the last PK column and the PK line.

See Also:
Constant Field Values

COLUMN_INDEX_START_OF_NON_PK

public static final int COLUMN_INDEX_START_OF_NON_PK
A special column index that represents the gap between the PK line and the first non-PK column.

See Also:
Constant Field Values

insertionPoint

protected int insertionPoint
This is the column index at which to the insertion point is currently rendered. Columns will be added after this column. If it is COLUMN_INDEX_NONE, no insertion point will be rendered and columns will be added at the bottom.


hiddenColumns

protected java.util.Set<SQLColumn> hiddenColumns
Tracks which columns in this table are currently hidden.


columnHighlight

protected java.util.Map<SQLColumn,java.util.List<java.awt.Color>> columnHighlight
Tracks current highlight colours of the columns in this table.


draggingColumn

protected SQLColumn draggingColumn
During a drag operation where a column is being dragged from this TablePane, this variable points to the column being dragged. At all other times, it should be null.

Constructor Detail

TablePane

public TablePane(TablePane tp,
                 PlayPenContentPane parent)

TablePane

public TablePane(SQLTable m,
                 PlayPenContentPane parent)
Method Detail

getItems

protected java.util.List<SQLColumn> getItems()
Description copied from class: ContainerPane
Returns a list of the items to be displayed with the model.

Specified by:
getItems in class ContainerPane<SQLTable,SQLColumn>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

updateUI

public void updateUI()

destroy

public void destroy()
You must call this method when you are done with a TablePane component. It unregisters this instance (and its UI delegate) on all event listener lists on which it was previously registered.

FIXME: this should be done automatically when the SQLTable model is removed, because the TablePane shouldn't have to be destroyed separately of the model.


getName

public java.lang.String getName()
Description copied from class: PlayPenComponent
Returns the user-visible name for this component--often the same as getModel().getName(), but this depends entirely on the subclass's idea of what in the model constitutes its name.

Specified by:
getName in class PlayPenComponent

getInsertionPoint

public int getInsertionPoint()
See insertionPoint.


setInsertionPoint

public void setInsertionPoint(int ip)
See insertionPoint.


updateHiddenColumns

public void updateHiddenColumns()

pointToItemIndex

@Deprecated
public int pointToItemIndex(java.awt.Point p)
Deprecated. 

Specified by:
pointToItemIndex in class ContainerPane<SQLTable,SQLColumn>

columnIndexToCentreY

public int columnIndexToCentreY(int colidx)
Returns the centre Y coordinate of the given column index. The special #COLUMN_INDEX_TITLE value for colidx will produce the central Y coordinate for the title bar.

Parameters:
colidx - the column number to get the central Y coordinate of.
Returns:
The Y coordinate at the visual centre point of the given column. If the requested column index is out of range, the value -1 is returned.

insertObjects

public boolean insertObjects(java.util.List<? extends SQLObject> items,
                             int insertionPoint)
                      throws ArchitectException
Inserts the list of SQLObjects into this table at the specified location.

Parameters:
items - A list of SQLTable and/or SQLColumn objects. Other types are not allowed.
insertionPoint - The position that the first item in the item list should go into. This can be a nonnegative integer to specify a position in the column list, or one of the constants COLUMN_INDEX_END_OF_PK or COLUMN_INDEX_START_OF_NON_PK to indicate a special position.
Returns:
True if the insert worked; false otherwise
Throws:
ArchitectException - If there are problems in the business model

addColumnHighlight

public void addColumnHighlight(SQLColumn column,
                               java.awt.Color colour)
Changes the foreground colour of a column. This is useful when outside forces want to colour in a column.

When highlighting for the given column is no longer desired, remove the highlight with a call to removeColumnHighlight(SQLColumn, Color).

Parameters:
i - The column index to recolour
colour - The new colour to show the column in.

removeColumnHighlight

public void removeColumnHighlight(SQLColumn column,
                                  java.awt.Color colour)
Removes the given colour highlight from the given column. This method should be called once and only once for each corresponding invocation of addColumnHighlight(SQLColumn, Color) with the same arguments.


getColumnHighlight

public java.awt.Color getColumnHighlight(int i)
                                  throws ArchitectException
Returns the current highlight colour for a particular column.

Parameters:
i - The index of the column in question
Returns:
The current highlight colour for the column at index i in this table. null indicates the current tablepane foreground colour will be used.
Throws:
ArchitectException

getColumnHighlight

public java.awt.Color getColumnHighlight(SQLColumn column)

setFullyQualifiedNameInHeader

public void setFullyQualifiedNameInHeader(boolean fullyQualifiedNameInHeader)

isFullyQualifiedNameInHeader

public boolean isFullyQualifiedNameInHeader()

dragEnter

public void dragEnter(java.awt.dnd.DropTargetDragEvent dtde)
Called while a drag operation is ongoing, when the mouse pointer enters the operable part of the drop site for the DropTarget registered with this listener.

NOTE: This method is expected to be called from the PlayPen's dragOver method (not directly by Swing), and as such the DropTargetContext (and the mouse co-ordinates) will be of the PlayPen.

Overrides:
dragEnter in class ContainerPane<SQLTable,SQLColumn>

dragExit

public void dragExit(java.awt.dnd.DropTargetEvent dte)
Called while a drag operation is ongoing, when the mouse pointer has exited the operable part of the drop site for the DropTarget registered with this listener.

NOTE: This method is expected to be called from the PlayPen's dragOver method (not directly by Swing), and as such the DropTargetContext (and the mouse co-ordinates) will be of the PlayPen.

Overrides:
dragExit in class ContainerPane<SQLTable,SQLColumn>

dragOver

public void dragOver(java.awt.dnd.DropTargetDragEvent dtde)
Called when a drag operation is ongoing, while the mouse pointer is still over the operable part of the drop site for the DropTarget registered with this listener.

NOTE: This method is expected to be called from the PlayPen's dragOver method (not directly by Swing), and as such the DropTargetContext (and the mouse co-ordinates) will be of the PlayPen.

Overrides:
dragOver in class ContainerPane<SQLTable,SQLColumn>

drop

public void drop(java.awt.dnd.DropTargetDropEvent dtde)
Called when the drag operation has terminated with a drop on the operable part of the drop site for the DropTarget registered with this listener.

NOTE: This method is expected to be called from the PlayPen's dragOver method (not directly by Swing), and as such the DropTargetContext (and the mouse co-ordinates) will be of the PlayPen.

Overrides:
drop in class ContainerPane<SQLTable,SQLColumn>

dropActionChanged

public void dropActionChanged(java.awt.dnd.DropTargetDragEvent dtde)
Called if the user has modified the current drop gesture.

Overrides:
dropActionChanged in class ContainerPane<SQLTable,SQLColumn>

bestImportFlavor

public java.awt.datatransfer.DataFlavor bestImportFlavor(javax.swing.JComponent c,
                                                         java.awt.datatransfer.DataFlavor[] flavors)
Chooses the best import flavour from the flavors array for importing into c. The current implementation actually just chooses the first acceptable flavour.

Overrides:
bestImportFlavor in class ContainerPane<SQLTable,SQLColumn>
Returns:
The first acceptable DataFlavor in the flavors list, or null if no acceptable flavours are present.

canImport

public boolean canImport(javax.swing.JComponent c,
                         java.awt.datatransfer.DataFlavor[] flavors)
This is set up this way because this DropTargetListener was derived from a TransferHandler. It works, so no sense in changing it.


getInboundEdges

public java.util.List<LayoutEdge> getInboundEdges()

getOutboundEdges

public java.util.List<LayoutEdge> getOutboundEdges()

getHiddenPkCount

public int getHiddenPkCount()
Returns the number of hidden primary key columns


isShowPkTag

public boolean isShowPkTag()

isShowFkTag

public boolean isShowFkTag()

isShowAkTag

public boolean isShowAkTag()

getHiddenColumns

public java.util.Set<SQLColumn> getHiddenColumns()

getPopup

public javax.swing.JPopupMenu getPopup()
Returns an instance of the popup menu with menu items exclusive to manipulating tablepanes.

Overrides:
getPopup in class PlayPenComponent

handleMouseEvent

public void handleMouseEvent(java.awt.event.MouseEvent evt)
Description copied from class: PlayPenComponent
Performs the component specific actions for the given MouseEvent.

Overrides:
handleMouseEvent in class ContainerPane<SQLTable,SQLColumn>

createTransferableForSelection

public java.awt.datatransfer.Transferable createTransferableForSelection()
Description copied from class: ContainerPane
Creates a Transferable representation of the currently-selected items. If there is nothing transferable selected, returns null.

Specified by:
createTransferableForSelection in class ContainerPane<SQLTable,SQLColumn>


Copyright © 2003-2007 SQL Power Group Inc. www.sqlpower.ca