ca.sqlpower.architect.swingui
Class ASUtils

java.lang.Object
  extended by ca.sqlpower.architect.swingui.ASUtils

public class ASUtils
extends java.lang.Object

ASUtils is a container class for static utility methods used throughout the Swing user interface. "ASUtils" is short for "ArchitectSwingUtils" which is too long to use frequently.


Method Summary
static void breakLongMenu(java.awt.Window frame, javax.swing.JMenu input)
          Update a potentially-long JMenu with the nth-last items replaced by sub-menus.
static ca.sqlpower.swingui.DataEntryPanel createDataSourceOptionsPanel(ca.sqlpower.sql.SPDataSource ds)
          Creates a tabbed panel for editing various aspects of the given data source.
static double distance(java.awt.Point p1, java.awt.Point p2)
          Returns the length of the shortest line from p1 to p2.
static ArchitectSwingSessionContext getContext()
          Deprecated. Use ArchitectSwingSession.getContext() to get your session context. This method should only be called when launching the app (in main()), and when picking up the pieces while handling an uncaught exception.
static java.awt.Image getFrameIconImage()
          Returns an icon that is suitable for use as a frame icon image in the Architect.
static java.util.List<java.awt.geom.Point2D.Double> getIntersectPoints(java.awt.Shape s1, java.awt.Shape s2)
           
static boolean getLineLineIntersection(java.awt.geom.Line2D.Double l1, java.awt.geom.Line2D.Double l2, java.awt.geom.Point2D.Double intersection)
          calculate the intersection point of 2 lines, copy from http://persistent.info/archives/2004/03/08/java_lineline_intersections
static java.lang.String lineToString(java.awt.geom.Line2D.Double l)
           
static void setupTargetDBComboBox(ArchitectSwingSession session, javax.swing.JComboBox targetDB)
          This method sets up the combo box passed as targetDB to contain all of the source connections.
static javax.swing.JDialog showDbcsDialog(java.awt.Window parentWindow, ca.sqlpower.sql.SPDataSource dataSource, java.lang.Runnable onAccept)
          Pops up a dialog box that lets the user inspect and change the given db's connection spec.
static void showExceptionDialog(ArchitectSwingSession session, java.lang.String message, java.lang.Throwable t)
          Displays a dialog box with the given message and exception, allowing the user to examine the stack trace.
static void showExceptionDialogNoReport(java.awt.Component parent, java.lang.String message, java.lang.Throwable t)
          Displays a dialog box with the given message and exception, allowing the user to examine the stack trace.
static void showExceptionDialogNoReport(java.lang.String message, java.lang.Throwable t)
          Deprecated. This method will create a dialog, but because it has no parent component, it will stay over everything including ArchitectFrames from other sessions.
static void showTargetDbcsDialog(java.awt.Window parentWindow, ArchitectSwingSession session, javax.swing.JComboBox targetDB)
          Pops up a dialog box that lets the user inspect and change the target db's connection spec.
 void startFocusDebugger()
          Creates and starts a thread that prints the keyboard focus owner to System.out once per second.
 void stopFocusDebugger()
          Signals for the focus debugger thread(s) to terminate itself (themselves).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

distance

public static double distance(java.awt.Point p1,
                              java.awt.Point p2)
Returns the length of the shortest line from p1 to p2.


stopFocusDebugger

public void stopFocusDebugger()
Signals for the focus debugger thread(s) to terminate itself (themselves).


startFocusDebugger

public void startFocusDebugger()
Creates and starts a thread that prints the keyboard focus owner to System.out once per second. There is no check to stop multiple such threads from running in parallel, but a single call to stopFocusDebugger() should termainate all such threads within 1 second.


setupTargetDBComboBox

public static void setupTargetDBComboBox(ArchitectSwingSession session,
                                         javax.swing.JComboBox targetDB)
This method sets up the combo box passed as targetDB to contain all of the source connections. The combo box will also contain the additional connection of "(Target Database)" if it is customized or it will make sure that only one copy of the target's connection is in the list


showTargetDbcsDialog

public static void showTargetDbcsDialog(java.awt.Window parentWindow,
                                        ArchitectSwingSession session,
                                        javax.swing.JComboBox targetDB)
Pops up a dialog box that lets the user inspect and change the target db's connection spec. Create from scratch every time just in case the user changed the Target Database from the DBTree.


showDbcsDialog

public static javax.swing.JDialog showDbcsDialog(java.awt.Window parentWindow,
                                                 ca.sqlpower.sql.SPDataSource dataSource,
                                                 java.lang.Runnable onAccept)
Pops up a dialog box that lets the user inspect and change the given db's connection spec.

Parameters:
parentWindow - The window that owns the dialog
session - the current session
dataSource - the data source to edit (null not allowed)
onAccept - this runnable will be invoked if the user OKs the dialog and validation succeeds. If you don't need to do anything in this situation, just pass in null for this parameter.

createDataSourceOptionsPanel

public static ca.sqlpower.swingui.DataEntryPanel createDataSourceOptionsPanel(ca.sqlpower.sql.SPDataSource ds)
Creates a tabbed panel for editing various aspects of the given data source. Currently, the tabs are for General Options and Kettle Options.

Parameters:
ds - The data source to edit

lineToString

public static java.lang.String lineToString(java.awt.geom.Line2D.Double l)

getIntersectPoints

public static java.util.List<java.awt.geom.Point2D.Double> getIntersectPoints(java.awt.Shape s1,
                                                                              java.awt.Shape s2)

getLineLineIntersection

public static boolean getLineLineIntersection(java.awt.geom.Line2D.Double l1,
                                              java.awt.geom.Line2D.Double l2,
                                              java.awt.geom.Point2D.Double intersection)
calculate the intersection point of 2 lines, copy from http://persistent.info/archives/2004/03/08/java_lineline_intersections

Parameters:
l1 -
l2 -
intersection -
Returns:

breakLongMenu

public static void breakLongMenu(java.awt.Window frame,
                                 javax.swing.JMenu input)
Update a potentially-long JMenu with the nth-last items replaced by sub-menus. If the menu seems to fit the current frame, it is unchanged.

Parameters:
frame - The parent Frame or JFrame, used to compute insets and to listen for resizes (neither of these is implemented at present).
input - The JMenu.

getFrameIconImage

public static java.awt.Image getFrameIconImage()
Returns an icon that is suitable for use as a frame icon image in the Architect.


getContext

public static ArchitectSwingSessionContext getContext()
Deprecated. Use ArchitectSwingSession.getContext() to get your session context. This method should only be called when launching the app (in main()), and when picking up the pieces while handling an uncaught exception.

Returns the single instance of the swing session context for this app. The reason we need a singleton is because the error reporting mechanism needs to be able to pick up the pieces, even for an uncaught exception.

Under all other circumstances, you should be extremely hesitant to treat the session context as a singleton. We don't really want it to be a singleton. It's more of a dirty little secret that we've let you in on here. If you need the session context for the current session, always always use Session.getContext(), which will give you the context in a much better way.


showExceptionDialogNoReport

public static void showExceptionDialogNoReport(java.lang.String message,
                                               java.lang.Throwable t)
Deprecated. This method will create a dialog, but because it has no parent component, it will stay over everything including ArchitectFrames from other sessions.

Displays a dialog box with the given message and exception, allowing the user to examine the stack trace. The dialog will not have a parent component so it will be displayed on top of everything.

Parameters:
message - A user visible string that should explain the problem
t - The exception that warranted a dialog

showExceptionDialogNoReport

public static void showExceptionDialogNoReport(java.awt.Component parent,
                                               java.lang.String message,
                                               java.lang.Throwable t)
Displays a dialog box with the given message and exception, allowing the user to examine the stack trace. The dialog will use the provided component as its parent.

Parameters:
parent - The parent component that will own the dialog
message - A user-visible message that describes what went wrong
t - The exception that warranted a dialog

showExceptionDialog

public static void showExceptionDialog(ArchitectSwingSession session,
                                       java.lang.String message,
                                       java.lang.Throwable t)
Displays a dialog box with the given message and exception, allowing the user to examine the stack trace. The dialog will use the architect frame in the provided session as its parent.

Also attempts to post an anonymous description of the error to a central reporting server.

Parameters:
session - The session that the exception occurred in
message - A user visible string that should describe the problem
t - The exception that warranted a dialog


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