ca.sqlpower.architect.swingui
Class Relationship

java.lang.Object
  extended by ca.sqlpower.architect.swingui.PlayPenComponent
      extended by ca.sqlpower.architect.swingui.Relationship
All Implemented Interfaces:
LayoutEdge, SQLObjectListener, Selectable

public class Relationship
extends PlayPenComponent
implements SQLObjectListener, LayoutEdge


Nested Class Summary
protected static class Relationship.RelationshipDecorationMover
          The RelationshipDecorationMover responds to mouse events on the relationship by moving either the PK or FK connection point so it is near the mouse's current position.
 
Field Summary
 
Fields inherited from class ca.sqlpower.architect.swingui.PlayPenComponent
backgroundColor, componentPreviouslySelected, foregroundColor
 
Constructor Summary
Relationship(SQLRelationship model, PlayPenContentPane parent)
          This constructor simply creates a Relationship component for the given SQLRelationship and adds it to the playpen.
 
Method Summary
protected  void createPopup()
           
 void dbChildrenInserted(SQLObjectEvent e)
           
 void dbChildrenRemoved(SQLObjectEvent e)
           
 void dbObjectChanged(SQLObjectEvent e)
           
 void dbStructureChanged(SQLObjectEvent e)
           
 java.awt.Point getFkConnectionPoint()
           
 TablePane getFkTable()
           
 LayoutNode getHeadNode()
          Returns the node whose inbound edge list includes this edge.
 SQLRelationship getModel()
           
 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.awt.Point getPkConnectionPoint()
           
 TablePane getPkTable()
           
 javax.swing.JPopupMenu getPopup()
          Returns a component specific popup menu.
 java.awt.Point getPreferredLocation()
          The revalidate() call uses this to determine the component's correct location.
 LayoutNode getTailNode()
          Returns the node whose outbound edge list includes this edge.
 java.lang.String getUIClassID()
           
 void handleMouseEvent(java.awt.event.MouseEvent evt)
          Performs the component specific actions for the given MouseEvent.
 boolean intersects(java.awt.Rectangle region)
          Determines if the given rectangle is visibly touching this component.
 boolean isSelected()
          See PlayPenComponent.selected.
 boolean isStraightLine()
           
 void setConnectionPoints(java.awt.Point[] connectionPoints)
          Sets the connectionPoints of the relationship from an array of points.
 void setFkConnectionPoint(java.awt.Point p)
           
 void setFkTable(TablePane tp)
           
 void setPkConnectionPoint(java.awt.Point p)
           
 void setPkTable(TablePane tp)
           
 void setSelected(boolean isSelected, int multiSelectType)
          Tells this component it is selected or deselected.
protected  void setup()
          All constructors have to call this after setting pp, model, pkTable, and fkTable.
 java.lang.String toString()
           
 void updateUI()
           
 
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, getPreferredSize, getSize, getToolTipText, getUI, getWidth, getX, getY, isOpaque, 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
 

Constructor Detail

Relationship

public Relationship(SQLRelationship model,
                    PlayPenContentPane parent)
             throws ArchitectException
This constructor simply creates a Relationship component for the given SQLRelationship and adds it to the playpen. It doesn't maniuplate the model at all.

Throws:
ArchitectException
Method Detail

setup

protected void setup()
All constructors have to call this after setting pp, model, pkTable, and fkTable.


createPopup

protected void createPopup()

getPreferredLocation

public java.awt.Point getPreferredLocation()
Description copied from class: PlayPenComponent
The revalidate() call uses this to determine the component's correct location. This implementation just returns the current location. Override it if you need to be moved during validation.

Overrides:
getPreferredLocation in class PlayPenComponent

toString

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

updateUI

public void updateUI()

setSelected

public void setSelected(boolean isSelected,
                        int multiSelectType)
Description copied from class: PlayPenComponent
Tells this component it is selected or deselected. If isSelected is different from the current selection state for this component, a SelectionEvent will be fired to all selection listeners.

See PlayPenComponent.selected.

Specified by:
setSelected in interface Selectable
Overrides:
setSelected in class PlayPenComponent
Parameters:
isSelected - The new selection state for this component
multiSelectType - One of the type codes from SelectionEvent.

isSelected

public boolean isSelected()
Description copied from class: PlayPenComponent
See PlayPenComponent.selected.

Specified by:
isSelected in interface Selectable
Overrides:
isSelected in class PlayPenComponent

getUIClassID

public java.lang.String getUIClassID()

getModel

public SQLRelationship getModel()
Specified by:
getModel in class PlayPenComponent

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

setPkTable

public void setPkTable(TablePane tp)

getPkTable

public TablePane getPkTable()

setFkTable

public void setFkTable(TablePane tp)

getFkTable

public TablePane getFkTable()

getPkConnectionPoint

public java.awt.Point getPkConnectionPoint()

getFkConnectionPoint

public java.awt.Point getFkConnectionPoint()

setPkConnectionPoint

public void setPkConnectionPoint(java.awt.Point p)

setFkConnectionPoint

public void setFkConnectionPoint(java.awt.Point p)

dbChildrenInserted

public void dbChildrenInserted(SQLObjectEvent e)
Specified by:
dbChildrenInserted in interface SQLObjectListener

dbChildrenRemoved

public void dbChildrenRemoved(SQLObjectEvent e)
Specified by:
dbChildrenRemoved in interface SQLObjectListener

dbObjectChanged

public void dbObjectChanged(SQLObjectEvent e)
Specified by:
dbObjectChanged in interface SQLObjectListener

dbStructureChanged

public void dbStructureChanged(SQLObjectEvent e)
Specified by:
dbStructureChanged in interface SQLObjectListener

intersects

public boolean intersects(java.awt.Rectangle region)
Determines if the given rectangle is visibly touching this component.

Parameters:
region - The region to test.
Returns:
Whether or not this Relationship visibly intersects the given region

getHeadNode

public LayoutNode getHeadNode()
Description copied from interface: LayoutEdge
Returns the node whose inbound edge list includes this edge.

Specified by:
getHeadNode in interface LayoutEdge

getTailNode

public LayoutNode getTailNode()
Description copied from interface: LayoutEdge
Returns the node whose outbound edge list includes this edge.

Specified by:
getTailNode in interface LayoutEdge

getPopup

public javax.swing.JPopupMenu getPopup()
Description copied from class: PlayPenComponent
Returns a component specific popup menu. Defaulted here to null so components that have popup menus must override this class.

Overrides:
getPopup in class PlayPenComponent

isStraightLine

public boolean isStraightLine()

setConnectionPoints

public void setConnectionPoints(java.awt.Point[] connectionPoints)
Sets the connectionPoints of the relationship from an array of points. Currently, it's only accessed when undo/redo movement of relationship connection points.

Parameters:
connectionPoints, - size of 2. The first element is a point representing the pk connection point, and the second element is a point representing the fk connection point.

handleMouseEvent

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

Specified by:
handleMouseEvent in class PlayPenComponent


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