ca.sqlpower.architect.swingui
Class PlayPen

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by ca.sqlpower.architect.swingui.PlayPen
All Implemented Interfaces:
SQLObjectListener, SelectionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.Scrollable

public class PlayPen
extends javax.swing.JPanel
implements java.io.Serializable, SQLObjectListener, SelectionListener, javax.swing.Scrollable

The PlayPen is the main GUI component of the SQL*Power Architect.

See Also:
Serialized Form

Nested Class Summary
protected  class PlayPen.AddObjectsTask
           
static class PlayPen.BringToFrontAction
           
static interface PlayPen.CancelableListener
           
 class PlayPen.CursorManager
          A simple class that encapsulates the logic for making the cursor image look correct for the current activity.
static class PlayPen.FloatingContainerPaneListener
          Listens to mouse motion and moves the given component so it follows the mouse.
static class PlayPen.MouseModeType
           
 class PlayPen.PlayPenDropListener
          Tracks incoming objects and adds successfully dropped objects at the current mouse position.
protected  class PlayPen.PPMouseListener
          The PPMouseListener class receives all mouse and mouse motion events in the PlayPen.
static class PlayPen.SendToBackAction
           
 class PlayPen.TablePaneDragGestureListener
           
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.Action bringToFrontAction
          This action brings the selected TablePane or Relationship to the front/top of the component stack.
protected  java.util.LinkedList<PlayPen.CancelableListener> cancelableListeners
           
protected  PlayPenContentPane contentPane
          Contains the child components of this playpen.
protected  javax.swing.JDialog dbcsDialog
          This dialog box is for editting the PlayPen's DB Connection spec.
protected  boolean draggingTablePanes
          used by mouseReleased to figure out if a DND operation just took place in the playpen, so it can make a good choice about leaving a group of things selected or deselecting everything except the TablePane that was clicked on.
protected  java.awt.dnd.DropTarget dt
          Links this PlayPen with an instance of PlayPenDropListener so users can drop stuff on the playpen.
protected  PlayPen.PPMouseListener ppMouseListener
          This object receives all mouse and mouse motion events in the PlayPen.
protected  java.awt.Component ppScrollPane
          The component that is used my the mouse listener to be scrolled.
protected  java.awt.Rectangle rubberBand
          The RubberBand allows the user to select multiple ppcomponents by click-and-drag across a region.
protected  java.awt.Color rubberBandColor
          This is the colour that the rubber band will be painted with.
protected  java.util.LinkedList selectionListeners
           
protected  javax.swing.Action sendToBackAction
          This action sends the selected TablePane or Relationship to the back/bottom of the component stack.
protected  java.util.Set<java.lang.String> tableNames
          Maps table names (Strings) to Integers.
protected  java.util.LinkedList undoEventListeners
           
protected  double zoom
          The visual magnification factor for this playpen.
protected  javax.swing.Action zoomInAction
          The zoom in action used by the mouse listener.
protected  javax.swing.Action zoomOutAction
          The zoom out action used by the mouse listener.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PlayPen(ArchitectSwingSession session)
          Creates a play pen with reasonable defaults.
PlayPen(ArchitectSwingSession session, PlayPen pp)
          Creates a new PlayPen with similar contents to the given PlayPen.
 
Method Summary
 void addCancelableListener(PlayPen.CancelableListener l)
           
protected  void addImpl(java.awt.Component c, java.lang.Object constraints, int index)
           
protected  void addImpl(PlayPenComponent c, java.lang.Object constraints, int index)
          Adds the given component to this PlayPen's content pane.
 void addObjects(java.util.List list, java.awt.Point preferredLocation, ca.sqlpower.swingui.SPSwingWorker nextProcess)
          Calls importTableCopy(ca.sqlpower.architect.SQLTable, java.awt.Point) for each table contained in the given schema.
 void addPlayPenComponent(PlayPenComponent ppc, java.awt.Point point)
          This method is primarily for loading project files.
 void addPlayPenLifecycleListener(PlayPenLifecycleListener ppll)
           
 void addRelationship(Relationship r)
           
 void addSelectionListener(SelectionListener l)
           
 void addTablePane(TablePane tp, java.awt.Point point)
          This method is primarily for loading project files.
 void addUndoEventListener(UndoCompoundEventListener l)
           
 void dbChildrenInserted(SQLObjectEvent e)
          Listens for property changes in the model (tables added).
 void dbChildrenRemoved(SQLObjectEvent e)
          Listens for property changes in the model (columns removed).
 void dbObjectChanged(SQLObjectEvent e)
          Listens for property changes in the model (table properties modified).
 void dbStructureChanged(SQLObjectEvent e)
          Listens for property changes in the model (significant structure change).
 void destroy()
          Disconnects this play pen from everything it's listening to.
 void endCompoundEdit(java.lang.String message)
           
 PlayPenComponent findPPComponent(java.lang.Object model)
          Searches this PlayPen's children for a PlayPenComponent with the given model.
 Relationship findRelationship(SQLRelationship r)
          Deprecated. 
 TablePane findTablePane(SQLTable t)
          Deprecated. 
 TablePane findTablePaneByName(java.lang.String name)
          Returns a TablePane in this PlayPen whose name is name.
 void fireCancel()
           
protected  void fireSelectionEvent(SelectionEvent e)
           
 java.awt.Component getComponent(int i)
          Deprecated. Calling this method from Architect code is almost certainly a mistake, but it needs to exist for Swing to function correctly. You probably want to use findTablePane(ca.sqlpower.architect.SQLTable), getRelationships(), or getTablePanes() instead.
 int getComponentCount()
          Deprecated. Calling this method from Architect code is almost certainly a mistake, but it needs to exist for Swing to function correctly. You probably want to use getPPComponentCount instead.
 PlayPenContentPane getContentPane()
           
 PlayPen.CursorManager getCursorManager()
           
 java.awt.font.FontRenderContext getFontRenderContext()
           
 PlayPen.MouseModeType getMouseMode()
           
 javax.swing.Action getMouseZoomInAction()
          Returns the zoom in action that the mouse uses for this PlayPen.
 javax.swing.Action getMouseZoomOutAction()
          Returns the zoom out action that the mouse uses for this PlayPen.
 java.util.List<PlayPenComponent> getPlayPenComponents()
          Returns a list of the playpen components in this playpen.
 PlayPenContentPane getPlayPenContentPane()
           
 PopupMenuFactory getPopupFactory()
           
 int getPPComponentCount()
          Returns the number of components in this PlayPen's PlayPenContentPane.
 java.awt.Dimension getPreferredScrollableViewportSize()
           
 java.awt.Dimension getPreferredSize()
          Calculates the smallest rectangle that will completely enclose the visible components.
 java.util.List<Relationship> getRelationships()
          Returns a list of the Relationship gui components in this playpen.
 java.awt.Rectangle getRubberBand()
           
 int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
           
 boolean getScrollableTracksViewportHeight()
           
 boolean getScrollableTracksViewportWidth()
           
 int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
           
 java.awt.Component getScrollPane()
          Returns the scrollPane used in this PlayPen.
 java.util.List<ContainerPane<?,?>> getSelectedContainers()
          Returns a read-only view of the set of selected ContainerPane's in the PlayPen.
 java.util.List<PlayPenComponent> getSelectedItems()
          Returns a read-only view of the set of selected children in the PlayPen.
 java.util.List<Relationship> getSelectedRelationShips()
          Returns a read-only view of the set of selected relationships in the PlayPen.
 ArchitectSwingSession getSession()
           
 java.util.Set<java.lang.String> getTableNames()
          Returns the already in use table names.
 java.util.List<TablePane> getTablePanes()
          Returns a list of the TablePane components in this playpen.
 java.util.List<SQLTable> getTables()
          Returns a new list of all tables in this play pen.
 java.lang.String getToolTipText(java.awt.event.MouseEvent e)
          Delegates to the content pane.
 java.awt.Dimension getUsedArea()
           
 java.awt.Dimension getViewportSize()
           
 java.awt.Point getViewPosition()
           
 double getZoom()
           
 boolean ignoreTreeSelection()
           
 TablePane importTableCopy(SQLTable source, java.awt.Point preferredLocation)
          Adds a copy of the given source table to this playpen, using preferredLocation as the layout constraint.
 boolean isDebugEnabled()
          Tells whether or not this PlayPen instance is in debugging mode.
 boolean isDraggingTablePanes()
           
 boolean isPaintingEnabled()
          See paintingEnabled.
 boolean isRenderingAntialiased()
           
 boolean isSelectionInProgress()
          Returns true if there is a multi-select operation in progress.
 void itemDeselected(SelectionEvent e)
          Forwards the selection event e to all PlayPen selection listeners.
 void itemSelected(SelectionEvent e)
          Forwards the selection event e to all PlayPen selection listeners.
protected  void normalize()
          If some playPen components get dragged into a negative range all tables are then shifted so that the lowest x and y values are 0.
 void paintComponent(java.awt.Graphics g)
           
 void removeCancelableListener(PlayPen.CancelableListener l)
           
 void removeSelectionListener(SelectionListener l)
           
 void removeSelectionListener(UndoCompoundEventListener l)
           
 void selectAll()
          Selects all selectable items in the PlayPen.
 void selectNone()
          Deselects all selectable items in the PlayPen.
 void selectObjects(java.util.List<OLAPObject> selections, OLAPTree tree)
          Selects the playpen component that represents the given OLAPObjects.
 void selectObjects(java.util.List<SQLObject> selections)
          Selects the playpen component that represents the given SQLObject.
 void setChildPosition(PlayPenComponent child, int x, int y)
          Calls setChildPositionImpl(child, x, y).
 void setChildPosition(PlayPenComponent child, java.awt.Point p)
          Calls setChildPositionImpl(child, p.x, p.y).
protected  void setChildPositionImpl(PlayPenComponent child, int x, int y)
          Scales the given X and Y co-ords from the visible point (x,y) to the actual internal location, and sets child's position accordingly.
protected  void setDatabaseConnection(ca.sqlpower.sql.SPDataSource dbcs)
           
 void setDraggingTablePanes(boolean draggingTablePanes)
           
 void setFontRenderContext(java.awt.font.FontRenderContext frc)
           
 void setIgnoreTreeSelection(boolean value)
           
 void setInitialViewPosition()
           
 void setMouseMode(PlayPen.MouseModeType mouseMode)
           
 void setMouseZoomInAction(javax.swing.Action zoomInAction)
          Sets the zoom in action for which the mouse uses for this PlayPen.
 void setMouseZoomOutAction(javax.swing.Action zoomOutAction)
          Sets the zoom out action for which the mouse uses for this PlayPen.
 void setPaintingEnabled(boolean paintingEnabled)
          See paintingEnabled.
 void setPopupFactory(PopupMenuFactory popupFactory)
           
 void setRenderingAntialiased(boolean v)
           
 void setScrollPane(java.awt.Component ppScrollPane)
          Sets the scrollPane that will be scrolled when the mouse wheel is moved for this PlayPen.
 void setupKeyboardActions()
          Sets up the generic keyboard actions for this playpen.
 void setViewportSize(int width, int height)
           
 void setViewPosition(java.awt.Point p)
           
 void setZoom(double newZoom)
           
 void showSelected()
          Scrolls the playpen to show the selected objects.
 void startCompoundEdit(java.lang.String message)
           
 java.awt.Point unzoomPoint(java.awt.Point p)
          Modifies the given point p from apparent position in screen space to model space.
 java.awt.Rectangle unzoomRect(java.awt.Rectangle r)
          Modifies the given rect r from apparent position in screen space to model space.
 void updateHiddenColumns()
           
 java.awt.Point zoomPoint(java.awt.Point p)
          Modifies the given point p in model space to apparent position in screen space.
 java.awt.Rectangle zoomRect(java.awt.Rectangle r)
          Modifies the given rect p in model space to apparent position in screen space.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponentAt, getComponentAt, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dt

protected java.awt.dnd.DropTarget dt
Links this PlayPen with an instance of PlayPenDropListener so users can drop stuff on the playpen.


tableNames

protected java.util.Set<java.lang.String> tableNames
Maps table names (Strings) to Integers. Useful for making up new table names if two tables of the same name are added todrag this playpen.


ppMouseListener

protected PlayPen.PPMouseListener ppMouseListener
This object receives all mouse and mouse motion events in the PlayPen. It tries to dispatch them to the ppcomponents, and also handles playpen-specific behaviour like rubber band selection and popup menu triggering.


rubberBand

protected java.awt.Rectangle rubberBand
The RubberBand allows the user to select multiple ppcomponents by click-and-drag across a region.


rubberBandColor

protected java.awt.Color rubberBandColor
This is the colour that the rubber band will be painted with.


zoom

protected double zoom
The visual magnification factor for this playpen.


contentPane

protected PlayPenContentPane contentPane
Contains the child components of this playpen.


bringToFrontAction

protected javax.swing.Action bringToFrontAction
This action brings the selected TablePane or Relationship to the front/top of the component stack.


sendToBackAction

protected javax.swing.Action sendToBackAction
This action sends the selected TablePane or Relationship to the back/bottom of the component stack.


zoomInAction

protected javax.swing.Action zoomInAction
The zoom in action used by the mouse listener.


zoomOutAction

protected javax.swing.Action zoomOutAction
The zoom out action used by the mouse listener.


ppScrollPane

protected java.awt.Component ppScrollPane
The component that is used my the mouse listener to be scrolled. Will always be a JScrollPane, but since the ArchitectFrame returns it as a Component this field is also a Component.


dbcsDialog

protected javax.swing.JDialog dbcsDialog
This dialog box is for editting the PlayPen's DB Connection spec.


draggingTablePanes

protected boolean draggingTablePanes
used by mouseReleased to figure out if a DND operation just took place in the playpen, so it can make a good choice about leaving a group of things selected or deselecting everything except the TablePane that was clicked on.


selectionListeners

protected java.util.LinkedList selectionListeners

cancelableListeners

protected java.util.LinkedList<PlayPen.CancelableListener> cancelableListeners

undoEventListeners

protected java.util.LinkedList undoEventListeners
Constructor Detail

PlayPen

public PlayPen(ArchitectSwingSession session)
Creates a play pen with reasonable defaults. If you are creating this PlayPen for temporary use (as opposed to creating a session's main PlayPen), don't forget to call destroy() when you are done with it.

Parameters:
session - The session this play pen belongs to. Null is not allowed.

PlayPen

public PlayPen(ArchitectSwingSession session,
               PlayPen pp)
Creates a new PlayPen with similar contents to the given PlayPen. The new copy will have fresh copies of all the contained PlayPenComponents, but will share the same model as the original play pen. This was originally intended for use by the print preview panel, but it may end up useful for other things too.

Remember to call destroy() when you are done with this playpen!

Parameters:
session - The session that this new copy should live in. If you specify a session other than the session that the given playpen lives in, it should still produce a usable copy, however be aware that the underlying SQLObjects will be shared between the two sessions.
pp - The playpen to duplicate.
Method Detail

destroy

public void destroy()
Disconnects this play pen from everything it's listening to. It is important to do this whenever you make a temporary PlayPen instance for some specific purpose (for example, print preview and the column mapping editor panel create temporary play pens). The primary play pen of the session itself doesn't really need to be destroyed, because all of the listener interconnections are contained within the session, and the whole tangled mess can just go away together.

As the method name implies, once you have called this method, this PlayPen instance will not function properly, so you should stop using it.


getTables

public java.util.List<SQLTable> getTables()
                                   throws ArchitectException
Returns a new list of all tables in this play pen. The list returned will be your own private (shallow) copy, so you are free to modify it.

Throws:
ArchitectException

setDatabaseConnection

protected void setDatabaseConnection(ca.sqlpower.sql.SPDataSource dbcs)

setupKeyboardActions

public void setupKeyboardActions()
Sets up the generic keyboard actions for this playpen. This should only be called once, which is normally done at the time the playpen is created. If no keyboard actions (zoom, delete selected, cursor up/down for item selection) are desired, just don't call this when creating your playpen.


isDebugEnabled

public boolean isDebugEnabled()
Tells whether or not this PlayPen instance is in debugging mode. Currently, this is controlled by log4j settings, but that may change in the future.


setChildPosition

public void setChildPosition(PlayPenComponent child,
                             java.awt.Point p)
Calls setChildPositionImpl(child, p.x, p.y).


setChildPosition

public void setChildPosition(PlayPenComponent child,
                             int x,
                             int y)
Calls setChildPositionImpl(child, x, y).


setChildPositionImpl

protected void setChildPositionImpl(PlayPenComponent child,
                                    int x,
                                    int y)
Scales the given X and Y co-ords from the visible point (x,y) to the actual internal location, and sets child's position accordingly.

Parameters:
child - a component in this PlayPen's content pane.
x - the apparent visible X co-ordinate
y - the apparent visible Y co-ordinate

getMouseZoomInAction

public javax.swing.Action getMouseZoomInAction()
Returns the zoom in action that the mouse uses for this PlayPen. If none has been set, it returns the default zoom in action from the ArchitectFrame.


setMouseZoomInAction

public void setMouseZoomInAction(javax.swing.Action zoomInAction)
Sets the zoom in action for which the mouse uses for this PlayPen.

Parameters:
zoomInAction - The zoom in action for the mouse to use in this PlayPen.

getMouseZoomOutAction

public javax.swing.Action getMouseZoomOutAction()
Returns the zoom out action that the mouse uses for this PlayPen. If none has been set, it returns the default zoom in action from the ArchitectFrame.


setMouseZoomOutAction

public void setMouseZoomOutAction(javax.swing.Action zoomOutAction)
Sets the zoom out action for which the mouse uses for this PlayPen.

Parameters:
zoomOutAction - The zoom out action for the mouse to use in this PlayPen.

getScrollPane

public java.awt.Component getScrollPane()
Returns the scrollPane used in this PlayPen. If none has been set, it returns the default scrollPane from the ArchitectFrame


setScrollPane

public void setScrollPane(java.awt.Component ppScrollPane)
Sets the scrollPane that will be scrolled when the mouse wheel is moved for this PlayPen.

Parameters:
ppScrollPane - The scrollPane to be scrolled when the mouse wheel is moved

zoomPoint

public java.awt.Point zoomPoint(java.awt.Point p)
Modifies the given point p in model space to apparent position in screen space.

Parameters:
p - The point in model space (the space where the actual components of the content pane live). THIS PARAMETER IS MODIFIED.
Returns:
The given point p, which has been modified.

unzoomPoint

public java.awt.Point unzoomPoint(java.awt.Point p)
Modifies the given point p from apparent position in screen space to model space.

Parameters:
p - The point in visible screen space (the space where mouse events are reported). THIS PARAMETER IS MODIFIED.
Returns:
The given point p, which has been modified.

zoomRect

public java.awt.Rectangle zoomRect(java.awt.Rectangle r)
Modifies the given rect p in model space to apparent position in screen space.

Parameters:
r - The rectangle in model space (the space where the actual components of the content pane live). THIS PARAMETER IS MODIFIED.
Returns:
The given rect p, which has been modified.

unzoomRect

public java.awt.Rectangle unzoomRect(java.awt.Rectangle r)
Modifies the given rect r from apparent position in screen space to model space.

Parameters:
r - The rectangle in visible screen space (the space where mouse events are reported). THIS PARAMETER IS MODIFIED.
Returns:
The given rect p, which has been modified.

setZoom

public void setZoom(double newZoom)

getZoom

public double getZoom()

setRenderingAntialiased

public void setRenderingAntialiased(boolean v)

isRenderingAntialiased

public boolean isRenderingAntialiased()

getContentPane

public PlayPenContentPane getContentPane()

getPreferredSize

public java.awt.Dimension getPreferredSize()
Calculates the smallest rectangle that will completely enclose the visible components. This is then compared to the viewport size, one dimension at a time. To ensure the whole playpen is "live", always choose the larger number in each Dimension. There is also a lower bound on how small the playpen can get. The layout manager returns a preferred size of (100,100) when asked.

Overrides:
getPreferredSize in class javax.swing.JComponent

getUsedArea

public java.awt.Dimension getUsedArea()

getViewportSize

public java.awt.Dimension getViewportSize()

setViewportSize

public void setViewportSize(int width,
                            int height)

normalize

protected void normalize()
If some playPen components get dragged into a negative range all tables are then shifted so that the lowest x and y values are 0. The tables will retain their relative location. If this function is moved into a layout manager it causes problems with undo because we do no know when this gets called.


getViewPosition

public java.awt.Point getViewPosition()

setViewPosition

public void setViewPosition(java.awt.Point p)

setInitialViewPosition

public void setInitialViewPosition()

setPaintingEnabled

public void setPaintingEnabled(boolean paintingEnabled)
See paintingEnabled.


isPaintingEnabled

public boolean isPaintingEnabled()
See paintingEnabled.


paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

addImpl

protected void addImpl(java.awt.Component c,
                       java.lang.Object constraints,
                       int index)
Overrides:
addImpl in class java.awt.Container

addImpl

protected void addImpl(PlayPenComponent c,
                       java.lang.Object constraints,
                       int index)
Adds the given component to this PlayPen's content pane. Does NOT add it to the Swing containment hierarchy. The playpen is a leaf in the hierarchy as far as swing is concerned.

Parameters:
c - The component to add. The PlayPen only accepts Relationship and ContainerPane components.
constraints - The Point at which to add the component
index - ignored for now, but would normally specify the index of insertion for c in the child list.

addRelationship

public void addRelationship(Relationship r)

addTablePane

public void addTablePane(TablePane tp,
                         java.awt.Point point)
This method is primarily for loading project files. Use at your own risk!

Parameters:
tp -
point -

addPlayPenComponent

public void addPlayPenComponent(PlayPenComponent ppc,
                                java.awt.Point point)
This method is primarily for loading project files. Use at your own risk!

Parameters:
ppc - The component to add.
point - The location to add the component at, in logical coordinates. If you don't care where the component lands, or the component's position is constrained by other factors (Relationships are positioned relative to the two table panes they connect) then this argument can be null.

getComponentCount

public int getComponentCount()
Deprecated. Calling this method from Architect code is almost certainly a mistake, but it needs to exist for Swing to function correctly. You probably want to use getPPComponentCount instead.

Returns 0 because this PlayPen contains no Swing components directly.

Overrides:
getComponentCount in class java.awt.Container

getComponent

public java.awt.Component getComponent(int i)
Deprecated. Calling this method from Architect code is almost certainly a mistake, but it needs to exist for Swing to function correctly. You probably want to use findTablePane(ca.sqlpower.architect.SQLTable), getRelationships(), or getTablePanes() instead.

Throws IndexOutOfBoundsException becuase the PlayPen contains no Swing components directly.

Overrides:
getComponent in class java.awt.Container

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
Delegates to the content pane.

Important Note: If you want tooltips to be active on this PlayPen instance, you have to call ToolTipManager.sharedInstance().registerComponent(pp) on this instance (where pp is whatever your reference to this playpen is called).

Overrides:
getToolTipText in class javax.swing.JComponent

findTablePane

@Deprecated
public TablePane findTablePane(SQLTable t)
Deprecated. 

Searches this PlayPen's children for a TablePane whose model is t.

Returns:
A reference to the TablePane that has t as a model, or null if no such TablePane is in the play pen.

findPPComponent

public PlayPenComponent findPPComponent(java.lang.Object model)
Searches this PlayPen's children for a PlayPenComponent with the given model.

Returns:
A reference to the PlayPenComponent with the given model, or null if no such PlayPenComponent is in the play pen

findTablePaneByName

public TablePane findTablePaneByName(java.lang.String name)
Returns a TablePane in this PlayPen whose name is name.

Warning: Unique names are not currently enforced in the PlayPen's database; results will be unpredictable if there is more than one table with the name you are searching for.

Implementation note: This method may benefit from a Map-based lookup rather than the current linear search algorithm.

Returns:
A reference to the TablePane whose model name is name, or null if no such TablePane is in the play pen.

findRelationship

@Deprecated
public Relationship findRelationship(SQLRelationship r)
Deprecated. 

Searches this PlayPen's children for a Relationship whose model is r.

Returns:
A reference to the Relationsip that has r as a model, or null if no such Relationship is in the play pen.

getRelationships

public java.util.List<Relationship> getRelationships()
Returns a list of the Relationship gui components in this playpen.


getTablePanes

public java.util.List<TablePane> getTablePanes()
Returns a list of the TablePane components in this playpen.


getPlayPenComponents

public java.util.List<PlayPenComponent> getPlayPenComponents()
Returns a list of the playpen components in this playpen.


getTableNames

public java.util.Set<java.lang.String> getTableNames()
Returns the already in use table names. Useful for deleting tables so it can be removed from this list as well.


getPPComponentCount

public int getPPComponentCount()
Returns the number of components in this PlayPen's PlayPenContentPane.


importTableCopy

public TablePane importTableCopy(SQLTable source,
                                 java.awt.Point preferredLocation)
                          throws ArchitectException
Adds a copy of the given source table to this playpen, using preferredLocation as the layout constraint. Tries to avoid adding two tables with identical names.

Returns:
A reference to the newly-created TablePane.
Throws:
ArchitectException
See Also:
SQLTable.inherit(ca.sqlpower.architect.SQLTable), PlayPenLayout#addLayoutComponent(Component,Object)

addObjects

public void addObjects(java.util.List list,
                       java.awt.Point preferredLocation,
                       ca.sqlpower.swingui.SPSwingWorker nextProcess)
                throws ArchitectException
Calls importTableCopy(ca.sqlpower.architect.SQLTable, java.awt.Point) for each table contained in the given schema.

Throws:
ArchitectException

dbChildrenInserted

public void dbChildrenInserted(SQLObjectEvent e)
Listens for property changes in the model (tables added). If this change affects the appearance of this widget, we will notify all change listeners (the UI delegate) with a ChangeEvent.

Specified by:
dbChildrenInserted in interface SQLObjectListener

dbChildrenRemoved

public void dbChildrenRemoved(SQLObjectEvent e)
Listens for property changes in the model (columns removed). If this change affects the appearance of this widget, we will notify all change listeners (the UI delegate) with a ChangeEvent.

Specified by:
dbChildrenRemoved in interface SQLObjectListener

dbObjectChanged

public void dbObjectChanged(SQLObjectEvent e)
Listens for property changes in the model (table properties modified). If this change affects the appearance of this widget, we will notify all change listeners (the UI delegate) with a ChangeEvent.

Specified by:
dbObjectChanged in interface SQLObjectListener

dbStructureChanged

public void dbStructureChanged(SQLObjectEvent e)
Listens for property changes in the model (significant structure change). If this change affects the appearance of this widget, we will notify all change listeners (the UI delegate) with a ChangeEvent.

NOTE: This is not currently implemented.

Specified by:
dbStructureChanged in interface SQLObjectListener

selectNone

public void selectNone()
Deselects all selectable items in the PlayPen.


selectAll

public void selectAll()
Selects all selectable items in the PlayPen.


getSelectedItems

public java.util.List<PlayPenComponent> getSelectedItems()
Returns a read-only view of the set of selected children in the PlayPen.


getSelectedContainers

public java.util.List<ContainerPane<?,?>> getSelectedContainers()
Returns a read-only view of the set of selected ContainerPane's in the PlayPen.


getSelectedRelationShips

public java.util.List<Relationship> getSelectedRelationShips()
Returns a read-only view of the set of selected relationships in the PlayPen.


itemSelected

public void itemSelected(SelectionEvent e)
Forwards the selection event e to all PlayPen selection listeners.

Specified by:
itemSelected in interface SelectionListener

itemDeselected

public void itemDeselected(SelectionEvent e)
Forwards the selection event e to all PlayPen selection listeners.

Specified by:
itemDeselected in interface SelectionListener

addSelectionListener

public void addSelectionListener(SelectionListener l)

removeSelectionListener

public void removeSelectionListener(SelectionListener l)

fireSelectionEvent

protected void fireSelectionEvent(SelectionEvent e)

addCancelableListener

public void addCancelableListener(PlayPen.CancelableListener l)

removeCancelableListener

public void removeCancelableListener(PlayPen.CancelableListener l)

fireCancel

public void fireCancel()

addUndoEventListener

public void addUndoEventListener(UndoCompoundEventListener l)

removeSelectionListener

public void removeSelectionListener(UndoCompoundEventListener l)

startCompoundEdit

public void startCompoundEdit(java.lang.String message)

endCompoundEdit

public void endCompoundEdit(java.lang.String message)

getRubberBand

public java.awt.Rectangle getRubberBand()

isSelectionInProgress

public boolean isSelectionInProgress()
Returns true if there is a multi-select operation in progress. This method is useful for selection listeners such as the selection synchronizer that should not update their state while a selection is in progress.


isDraggingTablePanes

public boolean isDraggingTablePanes()

setDraggingTablePanes

public void setDraggingTablePanes(boolean draggingTablePanes)

getPreferredScrollableViewportSize

public java.awt.Dimension getPreferredScrollableViewportSize()
Specified by:
getPreferredScrollableViewportSize in interface javax.swing.Scrollable

getScrollableBlockIncrement

public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Specified by:
getScrollableBlockIncrement in interface javax.swing.Scrollable

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Specified by:
getScrollableTracksViewportHeight in interface javax.swing.Scrollable

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Specified by:
getScrollableTracksViewportWidth in interface javax.swing.Scrollable

getScrollableUnitIncrement

public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Specified by:
getScrollableUnitIncrement in interface javax.swing.Scrollable

getFontRenderContext

public java.awt.font.FontRenderContext getFontRenderContext()
Returns:
The font render context at the current zoom setting or the font render context defined by the setter.

setFontRenderContext

public void setFontRenderContext(java.awt.font.FontRenderContext frc)

selectObjects

public void selectObjects(java.util.List<SQLObject> selections)
                   throws ArchitectException
Selects the playpen component that represents the given SQLObject. If the given SQL Object isn't in the playpen, this method has no effect.

Parameters:
selection - A list of SQLObjects, should only have SQLColumn, SQLTable or SQLRelationship.
Throws:
ArchitectException

selectObjects

public void selectObjects(java.util.List<OLAPObject> selections,
                          OLAPTree tree)
                   throws ArchitectException
Selects the playpen component that represents the given OLAPObjects. If the given OLAPObjects aren't in the playpen, this method has no effect.

Parameters:
selection - A list of OLAPObjects.
Throws:
ArchitectException

getPlayPenContentPane

public PlayPenContentPane getPlayPenContentPane()

setMouseMode

public void setMouseMode(PlayPen.MouseModeType mouseMode)

getMouseMode

public PlayPen.MouseModeType getMouseMode()

getSession

public ArchitectSwingSession getSession()

getCursorManager

public PlayPen.CursorManager getCursorManager()

getPopupFactory

public PopupMenuFactory getPopupFactory()

setPopupFactory

public void setPopupFactory(PopupMenuFactory popupFactory)

setIgnoreTreeSelection

public void setIgnoreTreeSelection(boolean value)

ignoreTreeSelection

public boolean ignoreTreeSelection()

showSelected

public void showSelected()
Scrolls the playpen to show the selected objects. The most left component takes precedence if multiple objects are selected.


updateHiddenColumns

public void updateHiddenColumns()

addPlayPenLifecycleListener

public void addPlayPenLifecycleListener(PlayPenLifecycleListener ppll)


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