Author: truesweetman
Date: Mon Aug 25 08:10:57 2008
New Revision: 2602
Modified:
trunk/regress/ca/sqlpower/architect/swingui/TestPlayPen.java
trunk/src/ca/sqlpower/architect/swingui/PlayPen.java
trunk/src/ca/sqlpower/architect/swingui/olap/OLAPEditSession.java
trunk/src/ca/sqlpower/architect/swingui/olap/OLAPPlayPenFactory.java
Log:
Fixed mouse scrolling for OLAPPlayPens.
Previously, the mouseWheelMoved action in PlayPen got the zoomInAction,
zoomOutAction and the PlayPen's scrollPane directly from the
ArchitectFrame. hen you scrolled on an OLAPPlayPen, it would actually
scroll the RelationalPlayPen. Now when the GUI is initialized, zoom in/out
action and the PlayPen's scroll scrollPane are setup (similar to keyboard
actions). If these 3 fields are not setup, the playPen get the information
directly from ArchitectFrame as it did before.
Modified: trunk/regress/ca/sqlpower/architect/swingui/TestPlayPen.java
==============================================================================
--- trunk/regress/ca/sqlpower/architect/swingui/TestPlayPen.java
(original)
+++ trunk/regress/ca/sqlpower/architect/swingui/TestPlayPen.java Mon Aug 25
08:10:57 2008
@@ -340,6 +340,13 @@
copyIgnoreProperties.add("draggingTablePanes");
copyIgnoreProperties.add("rubberBand");
+ // These should not be copied because any new PlayPen needs
+ // different values or else it will not work on the new
+ // PlayPen.
+ copyIgnoreProperties.add("mouseZoomInAction");
+ copyIgnoreProperties.add("mouseZoomOutAction");
+ copyIgnoreProperties.add("scrollPane");
+
// we're not sure if zoom should be duplicated...
// it might mess up printing?!?!?
copyIgnoreProperties.add("zoom");
Modified: trunk/src/ca/sqlpower/architect/swingui/PlayPen.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/PlayPen.java (original)
+++ trunk/src/ca/sqlpower/architect/swingui/PlayPen.java Mon Aug 25
08:10:57 2008
@@ -262,6 +262,23 @@
protected Action sendToBackAction;
/**
+ * The zoom in action used by the mouse listener.
+ */
+ protected Action zoomInAction;
+
+ /**
+ * The zoom out action used by the mouse listener.
+ */
+ protected Action zoomOutAction;
+
+ /**
+ * 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.
+ */
+ protected Component ppScrollPane;
+
+ /**
* This dialog box is for editting the PlayPen's DB Connection spec.
*/
protected JDialog dbcsDialog;
@@ -613,6 +630,73 @@
}
/**
+ * 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.
+ */
+ public Action getMouseZoomInAction(){
+ if (zoomInAction == null) {
+ System.out.println("Don't you DARE Zoom In!");
+ return session.getArchitectFrame().getZoomInAction();
+ }
+ return zoomInAction;
+ }
+
+ /**
+ * Sets the zoom in action for which the mouse uses for this PlayPen.
+ *
+ * @param zoomInAction
+ * The zoom in action for the mouse to use in this PlayPen.
+ */
+ public void setMouseZoomInAction(Action zoomInAction){
+ this.zoomInAction = zoomInAction;
+ }
+
+ /**
+ * 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.
+ */
+ public Action getMouseZoomOutAction(){
+ if (zoomOutAction == null) {
+ return session.getArchitectFrame().getZoomOutAction();
+ }
+ return zoomOutAction;
+ }
+
+ /**
+ * Sets the zoom out action for which the mouse uses for this PlayPen.
+ *
+ * @param zoomOutAction
+ * The zoom out action for the mouse to use in this PlayPen.
+ */
+ public void setMouseZoomOutAction(Action zoomOutAction){
+ this.zoomOutAction = zoomOutAction;
+ }
+
+ /**
+ * Returns the scrollPane used in this PlayPen. If none has been set,
it
+ * returns the default scrollPane from the ArchitectFrame
+ */
+ public Component getScrollPane(){
+ if (ppScrollPane == null) {
+ return
session.getArchitectFrame().splitPane.getRightComponent();
+ }
+ return ppScrollPane;
+ }
+
+ /**
+ * Sets the scrollPane that will be scrolled when the mouse wheel is
moved
+ * for this PlayPen.
+ *
+ * @param ppScrollPane
+ * The scrollPane to be scrolled when the mouse wheel is
moved
+ */
+ public void setScrollPane(Component ppScrollPane){
+ this.ppScrollPane = ppScrollPane;
+ }
+
+ /**
* Modifies the given point p in model space to apparent position
* in screen space.
*
@@ -2254,13 +2338,15 @@
public void mouseWheelMoved(MouseWheelEvent e) {
if ( (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK)
!= 0 ) {
- if ( e.getWheelRotation() > 0 )
-
session.getArchitectFrame().getZoomInAction().actionPerformed(null);
- else
-
session.getArchitectFrame().getZoomOutAction().actionPerformed(null);
+ if ( e.getWheelRotation() > 0 ) {
+
getMouseZoomInAction().actionPerformed(null);
+ }
+ else {
+
getMouseZoomOutAction().actionPerformed(null);
+ }
}
else {
- MouseWheelListener[] ml =
session.getArchitectFrame().splitPane.getRightComponent().getMouseWheelListeners();
+ MouseWheelListener[] ml =
getScrollPane().getMouseWheelListeners();
for ( MouseWheelListener m : ml )
m.mouseWheelMoved(e);
}
Modified: trunk/src/ca/sqlpower/architect/swingui/olap/OLAPEditSession.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/olap/OLAPEditSession.java
(original)
+++ trunk/src/ca/sqlpower/architect/swingui/olap/OLAPEditSession.java Mon
Aug 25 08:10:57 2008
@@ -66,6 +66,11 @@
private JDialog d;
/**
+ * The scroll pane of which the PlayPen is in.
+ */
+ private JScrollPane ppScrollPane;
+
+ /**
* OLAPSession associated with the schema that this edit session edits.
*/
private final OLAPSession olapSession;
@@ -167,12 +172,13 @@
toolbar.add(exportSchemaAction);
+ ppScrollPane = new JScrollPane(pp);
JPanel panel = new JPanel(new BorderLayout());
panel.add(
new JSplitPane(
JSplitPane.HORIZONTAL_SPLIT,
new JScrollPane(tree),
- new JScrollPane(pp)),
+ ppScrollPane),
BorderLayout.CENTER);
panel.add(toolbar, BorderLayout.EAST);
@@ -187,6 +193,7 @@
d.setContentPane(panel);
d.pack();
+ OLAPPlayPenFactory.setupOLAPMouseWheelActions(pp, this);
OLAPPlayPenFactory.setupOLAPKeyboardActions(pp, this);
}
@@ -199,6 +206,13 @@
public OLAPTree getOlapTree() {
return tree;
+ }
+
+ /**
+ * Returns the scroll pane that the PlayPen is in.
+ */
+ public JScrollPane getPPScrollPane() {
+ return ppScrollPane;
}
/**
Modified:
trunk/src/ca/sqlpower/architect/swingui/olap/OLAPPlayPenFactory.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/olap/OLAPPlayPenFactory.java
(original)
+++ trunk/src/ca/sqlpower/architect/swingui/olap/OLAPPlayPenFactory.java
Mon Aug 25 08:10:57 2008
@@ -124,6 +124,23 @@
}
/**
+ * Sets up scroll wheel actions on the playpen. This is done
+ * separately because the wheelMouseMoved event requires the scroll
pane be
+ * built before it can work. The ZoomIn and ZoomOut actions also need a
+ * playpen before the actions can be created.
+ *
+ * @param pp
+ * The playpen to register the mouse wheel actions on.
+ * @param oSession
+ * The session pp belongs to, also the session that owns the
+ * actions to register and ScrollPane.
+ */
+ public static void setupOLAPMouseWheelActions(PlayPen pp,
OLAPEditSession oSession) {
+ pp.setMouseZoomInAction(oSession.getZoomInAction());
+ pp.setMouseZoomOutAction(oSession.getZoomOutAction());
+ pp.setScrollPane(oSession.getPPScrollPane());
+ }
+ /**
* An instance of this OLAPChildListener will listen to tree model
structural
* changes.
* <p>