ca.sqlpower.architect.swingui.olap
Class OLAPPane<T extends OLAPObject,C extends OLAPObject>

java.lang.Object
  extended by ca.sqlpower.architect.swingui.PlayPenComponent
      extended by ca.sqlpower.architect.swingui.ContainerPane<T,C>
          extended by ca.sqlpower.architect.swingui.olap.OLAPPane<T,C>
Type Parameters:
T - The model's type
C - The item type. If there are mixed item types, this will be OLAPObject.
All Implemented Interfaces:
LayoutNode, Selectable, java.awt.dnd.DragSourceListener, java.util.EventListener
Direct Known Subclasses:
CubePane, DimensionPane, VirtualCubePane

public abstract class OLAPPane<T extends OLAPObject,C extends OLAPObject>
extends ContainerPane<T,C>

A class that provides all the generic behaviour applicable to OLAP playpen components that have titles and sections of selectable items.


Field Summary
protected  java.util.List<PaneSection<? extends C>> sections
          The sections of this OLAP Pane.
protected  java.util.Set<PaneSection<? extends C>> selectedSections
          Tracks which scetions in this container are currently selected.
 
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
protected OLAPPane(PlayPenContentPane parent)
           
 
Method Summary
 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.
abstract  ca.sqlpower.swingui.DataEntryPanel createEditDialog(PlayPenCoordinate<T,C> coord)
          Creates a edit dialog for the OLAPObject that is at the location represented by the given coordinate.
 java.awt.datatransfer.Transferable createTransferableForSelection()
          Creates a Transferable representation of the currently-selected items.
 void deselectSection(PaneSection<? extends C> sect)
          Deselects the given section.
protected  int dndRemoveAndAdd(PaneSection<OLAPObject> insertSection, int insertIndex, C item)
          This will remove the item being dragged and dropped from its parent before adding it to the new insertSection.
 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.
protected abstract  java.util.List<C> filterDroppableItems(java.util.List<OLAPObject> items)
          Accepts a clump of items that have been dragged from elsewhere (normally the tree or another pane).
 java.util.List<LayoutEdge> getInboundEdges()
          Returns all the UsageComponents in the play pen that this pane is the "pane2" for.
 PlayPenCoordinate<T,C> getInsertionPoint()
          Returns the current insertion point.
protected  java.util.List<OLAPObject> getItemsFromCoordinates(java.util.List<PlayPenCoordinate<? extends OLAPObject,? extends OLAPObject>> coords)
          Returns a list of OLAPObjects that correspond to the given PlayPenCoordinates.
 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()
          Returns all the UsageComponents in the play pen that this pane is the "pane1" for.
 javax.swing.JPopupMenu getPopup()
          Returns a component specific popup menu.
 java.util.List<PaneSection<? extends C>> getSections()
          Returns this pane's list of sections.
 java.util.List<PlayPenCoordinate<T,C>> getSelectedCoordinates()
          Returns a list of the sections that are currently in the selection that also currently exist in the model.
 java.util.List<PaneSection<? extends C>> getSelectedSections()
          Returns a list of the sections that are currently in the selection that also currently exist in the model.
 OLAPPaneUI<T,C> getUI()
           
 void handleMouseEvent(java.awt.event.MouseEvent evt)
          Performs the component specific actions for the given MouseEvent.
 boolean isSectionSelected(PaneSection<? extends C> sect)
          Returns true if the given section was selected in this olap pane.
 int pointToItemIndex(java.awt.Point p)
          Deprecated. 
 PlayPenCoordinate<T,C> pointToPPCoordinate(java.awt.Point p)
          Translates the given point into a PlayPenCoordinate.
 void selectNone()
          Deselects all items in this ContainerPane.
 void selectSection(PaneSection<? extends C> sect)
          Selects the section.
 void setInsertionPoint(PlayPenCoordinate<T,C> newIP)
          Changes the insertion point and fires a property change to that effect.
protected  void transferInvalidIndexItem(OLAPObject item, PaneSection<OLAPObject> insertSection)
          Handle Drag and Drop transfer for items with invalid index.
 
Methods inherited from class ca.sqlpower.architect.swingui.ContainerPane
addItemSelectionListener, deSelectEverythingElse, deselectItem, deselectItem, dragDropEnd, dragEnter, dragExit, dragOver, dropActionChanged, fireItemsDeselected, fireItemsSelected, getItems, getLocationOnScreen, getMargin, getModel, getNodeName, getSelectedItemIndex, getSelectedItems, isDashed, isItemSelected, isItemSelected, isRounded, removeItemSelectionListener, selectItem, selectItem, 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, 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, toString, wait, wait, wait
 
Methods inherited from interface ca.sqlpower.architect.layout.LayoutNode
getBounds, getBounds, getHeight, getLocation, getWidth, getX, getY, setBounds, setLocation, setLocation
 

Field Detail

sections

protected final java.util.List<PaneSection<? extends C extends OLAPObject>> sections
The sections of this OLAP Pane. There must always be at least one section. The set of sections is allowed to change at any time, but an appropriate event will be fired when it does change.


selectedSections

protected final java.util.Set<PaneSection<? extends C extends OLAPObject>> selectedSections
Tracks which scetions in this container are currently selected.

Constructor Detail

OLAPPane

protected OLAPPane(PlayPenContentPane parent)
Method Detail

getSections

public java.util.List<PaneSection<? extends C>> getSections()
Returns this pane's list of sections.


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

pointToItemIndex

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

Specified by:
pointToItemIndex in class ContainerPane<T extends OLAPObject,C extends OLAPObject>

pointToPPCoordinate

public PlayPenCoordinate<T,C> pointToPPCoordinate(java.awt.Point p)
Translates the given point into a PlayPenCoordinate.

Parameters:
p - The point to be translated.
Returns:
The PlayPenCoordinate that represents the point.

getUI

public OLAPPaneUI<T,C> getUI()
Overrides:
getUI in class PlayPenComponent

createEditDialog

public abstract ca.sqlpower.swingui.DataEntryPanel createEditDialog(PlayPenCoordinate<T,C> coord)
                                                             throws ArchitectException
Creates a edit dialog for the OLAPObject that is at the location represented by the given coordinate.

Parameters:
coord - Containas information about the OLAPObject that the edit dialog should be created for.
Returns:
A DataEntryPanel for editting the OLAPObject, null if location is invalid.
Throws:
ArchitectException - If creating an edit dialog failed.

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<T extends OLAPObject,C extends OLAPObject>

deselectSection

public void deselectSection(PaneSection<? extends C> sect)
Deselects the given section.

Parameters:
sect - the section to deselect.

selectSection

public void selectSection(PaneSection<? extends C> sect)
Selects the section.


isSectionSelected

public boolean isSectionSelected(PaneSection<? extends C> sect)
Returns true if the given section was selected in this olap pane.

Parameters:
sect - The section to check
Returns:
true if section is currently selected.

getSelectedSections

public java.util.List<PaneSection<? extends C>> getSelectedSections()
Returns a list of the sections that are currently in the selection that also currently exist in the model.


getSelectedCoordinates

public java.util.List<PlayPenCoordinate<T,C>> getSelectedCoordinates()
Returns a list of the sections that are currently in the selection that also currently exist in the model. If a section title is selected, the selection state of its items is not considered; the section itself will be in the returned list and none of its items will. This is consistent with other multi-select GUIs we looked at.


selectNone

public void selectNone()
Description copied from class: ContainerPane
Deselects all items in this ContainerPane.

Overrides:
selectNone in class ContainerPane<T extends OLAPObject,C extends OLAPObject>

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

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<T extends OLAPObject,C extends OLAPObject>

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<T extends OLAPObject,C extends OLAPObject>

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<T extends OLAPObject,C extends OLAPObject>

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<T extends OLAPObject,C extends OLAPObject>

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<T extends OLAPObject,C extends OLAPObject>

dndRemoveAndAdd

protected int dndRemoveAndAdd(PaneSection<OLAPObject> insertSection,
                              int insertIndex,
                              C item)
This will remove the item being dragged and dropped from its parent before adding it to the new insertSection. Some panes need to do special actions before or during the remove and add.


getItemsFromCoordinates

protected java.util.List<OLAPObject> getItemsFromCoordinates(java.util.List<PlayPenCoordinate<? extends OLAPObject,? extends OLAPObject>> coords)
Returns a list of OLAPObjects that correspond to the given PlayPenCoordinates.

Parameters:
coords - The list of PlayPenCoordinates to convert.
Returns:
A list of OLAPObjects that correspond to the given PlayPenCoordinates.

transferInvalidIndexItem

protected void transferInvalidIndexItem(OLAPObject item,
                                        PaneSection<OLAPObject> insertSection)
Handle Drag and Drop transfer for items with invalid index.

Parameters:
item - The item to be transferred.
insertSection - The section to be inserted into.

filterDroppableItems

protected abstract java.util.List<C> filterDroppableItems(java.util.List<OLAPObject> items)
Accepts a clump of items that have been dragged from elsewhere (normally the tree or another pane). Implementations of this method are free to pick and choose which items to import.

This method will always be called by the superclass in the context of a compound edit on the schema this pane's model belongs to.

Parameters:
items - The items that were dropped.
Returns:
The list of items that can be dropped on this pane. It will be some subset of the given list of items.

dropActionChanged

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

Overrides:
dropActionChanged in class ContainerPane<T extends OLAPObject,C extends OLAPObject>

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.

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

setInsertionPoint

public void setInsertionPoint(PlayPenCoordinate<T,C> newIP)
Changes the insertion point and fires a property change to that effect.

Parameters:
newIP - The new insertion point. Null is allowed, and means there shouldn't be a visible insertion point.

getInsertionPoint

public PlayPenCoordinate<T,C> getInsertionPoint()
Returns the current insertion point. The insertion point is the point directly above the item at the returned coordinate. Therefore, the coordinate might be one item index beyond the last item in the section.


getInboundEdges

public final java.util.List<LayoutEdge> getInboundEdges()
Returns all the UsageComponents in the play pen that this pane is the "pane2" for. This is part of the LayoutNode interface.


getOutboundEdges

public final java.util.List<LayoutEdge> getOutboundEdges()
Returns all the UsageComponents in the play pen that this pane is the "pane1" for. This is part of the LayoutNode interface.



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