ca.sqlpower.architect.swingui
Class ArchitectSwingSessionContextImpl

java.lang.Object
  extended by ca.sqlpower.architect.swingui.ArchitectSwingSessionContextImpl
All Implemented Interfaces:
ArchitectSessionContext, ArchitectSwingSessionContext

public class ArchitectSwingSessionContextImpl
extends java.lang.Object
implements ArchitectSwingSessionContext

Instances of this class provide the basic global (non-project-specific) settings and facilities to an invocation of the Architect's Swing user interface. You need an instance of one of these in order to start the Architect's Swing UI.

It may one day be desirable for this to be an interface, but there didn't seem to be a need for it when we first created this class.


Field Summary
 
Fields inherited from interface ca.sqlpower.architect.swingui.ArchitectSwingSessionContext
ICON_SIZE
 
Fields inherited from interface ca.sqlpower.architect.ArchitectSessionContext
DRIVERS_URL
 
Method Summary
 void closeAll()
          Attempts to close all sessions that were created by this context.
 ArchitectSwingSession createSession()
          Creates a new session within this parent context.
 ArchitectSwingSession createSession(ArchitectSwingSession openingSession)
          Creates a new session that will have its GUI components positioned relative to the GUI components of the given ArchitectSwingSession.
 ArchitectSwingSession createSession(boolean showGUI)
          Creates a new session within this parent context.
 ArchitectSwingSession createSession(java.io.InputStream in)
          Creates a new session by loading the Architect XML project description from the given input stream.
 ArchitectSwingSession createSession(java.io.InputStream in, boolean showGUI)
          Loads the XML project description from the input stream, optionally creating the GUI for you.
 java.util.List<ca.sqlpower.sql.SPDataSource> getConnections()
           
 boolean getExitAfterAllSessionsClosed()
          Returns the current session for exiting after all sessions are closed.
 ca.sqlpower.sql.DataSourceCollection getPlDotIni()
          Tries to read the plDotIni if it hasn't been done already.
 java.lang.String getPlDotIniPath()
           
 java.util.prefs.Preferences getPrefs()
          Returns the user preferences node associated with this context.
 java.util.Collection<ArchitectSession> getSessions()
          Returns a collection containing all the sessions from this context.
 CoreUserSettings getUserSettings()
          Gets the user settings for this session
 boolean isMacOSX()
          Returns true iff this context is running on a Mac OS X machine.
 void setExitAfterAllSessionsClosed(boolean allowExit)
          Optional setting which will have the context call System.exit() after there are no open sessions remaining.
 void setPlDotIniPath(java.lang.String plDotIniPath)
          Sets the plDotIniPath property, and nulls out the current plDotIni if the given value differs from the existing one.
 void showConnectionManager(java.awt.Window owner)
          Shows the connection manager dialog for this context's data source collection.
 void showPreferenceDialog(java.awt.Window owner)
          Shows the user preferences dialog for this application context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createSession

public ArchitectSwingSession createSession(java.io.InputStream in,
                                           boolean showGUI)
                                    throws ArchitectException,
                                           java.io.IOException
Loads the XML project description from the input stream, optionally creating the GUI for you.

Important Note: If you set showGUI to true, this method must be called on the Swing Event Dispatch Thread. If this is not possible or practical, call this method with showGUI false, then call ArchitectSwingSession.initGUI() on the returned session using the event dispatch thread some time later on.

Specified by:
createSession in interface ArchitectSwingSessionContext
Parameters:
in - The input stream to read the XML data from
showGUI - True if you want this session to have its own (visible)\ ArchitectFrame instance; false for an invisible session.
Returns:
The new session
Throws:
java.io.IOException - If the file is not found or can't be read.
ArchitectException - if there is some problem with the file
java.lang.IllegalStateException - if showGUI==true and this method was not called on the Event Dispatch Thread.

createSession

public ArchitectSwingSession createSession()
                                    throws ArchitectException
Description copied from interface: ArchitectSessionContext
Creates a new session within this parent context.

Specified by:
createSession in interface ArchitectSessionContext
Specified by:
createSession in interface ArchitectSwingSessionContext
Throws:
ArchitectException

createSession

public ArchitectSwingSession createSession(boolean showGUI)
                                    throws ArchitectException
Description copied from interface: ArchitectSwingSessionContext
Creates a new session within this parent context. This will cause an Architect Frame to appear on the user's desktop with a new empty project in it.

Important note: If showGUI is true, this method must be called on the Swing Event Dispatch Thread. See SwingUtilities.invokeLater() for a way of ensuring this method is called on the proper thread.

Specified by:
createSession in interface ArchitectSwingSessionContext
Parameters:
showGUI - True if you want this session to have its own (visible)\ ArchitectFrame instance; false for an invisible session.
Returns:
The new session
Throws:
ArchitectException

createSession

public ArchitectSwingSession createSession(java.io.InputStream in)
                                    throws ArchitectException,
                                           java.io.IOException
Description copied from interface: ArchitectSessionContext
Creates a new session by loading the Architect XML project description from the given input stream.

Specified by:
createSession in interface ArchitectSessionContext
Parameters:
in - The input stream to read the XML data from
Returns:
The new session
Throws:
ArchitectException
java.io.IOException

createSession

public ArchitectSwingSession createSession(ArchitectSwingSession openingSession)
                                    throws ArchitectException
Description copied from interface: ArchitectSwingSessionContext
Creates a new session that will have its GUI components positioned relative to the GUI components of the given ArchitectSwingSession. Typically, the given ArchitectSwingSession is the session from where the call to create a new session was made. (ex. the given session's 'Open Project' button was pressed). If the given session is null, then it will default to using the most recently saved GUI component positions in the user preferences in ArchitectSwingUserSettings.

Specified by:
createSession in interface ArchitectSwingSessionContext
Returns:
Throws:
ArchitectException

isMacOSX

public boolean isMacOSX()
Description copied from interface: ArchitectSwingSessionContext
Returns true iff this context is running on a Mac OS X machine. Some UI features are different under that platform to increase the illusion that the Architect is a native application.

Specified by:
isMacOSX in interface ArchitectSwingSessionContext

getPrefs

public java.util.prefs.Preferences getPrefs()
Description copied from interface: ArchitectSessionContext
Returns the user preferences node associated with this context.

Specified by:
getPrefs in interface ArchitectSessionContext

getUserSettings

public CoreUserSettings getUserSettings()
Description copied from interface: ArchitectSwingSessionContext
Gets the user settings for this session

Specified by:
getUserSettings in interface ArchitectSwingSessionContext

getSessions

public java.util.Collection<ArchitectSession> getSessions()
Description copied from interface: ArchitectSessionContext
Returns a collection containing all the sessions from this context.

Specified by:
getSessions in interface ArchitectSessionContext

showConnectionManager

public void showConnectionManager(java.awt.Window owner)
Description copied from interface: ArchitectSwingSessionContext
Shows the connection manager dialog for this context's data source collection.

Specified by:
showConnectionManager in interface ArchitectSwingSessionContext
Parameters:
owner - The owner of the dialog.

showPreferenceDialog

public void showPreferenceDialog(java.awt.Window owner)
Description copied from interface: ArchitectSwingSessionContext
Shows the user preferences dialog for this application context.

Specified by:
showPreferenceDialog in interface ArchitectSwingSessionContext
Parameters:
owner - The owner of the dialog

closeAll

public void closeAll()
Attempts to close all sessions that were created by this context. The user might abort some or all of the session closes by choosing to cancel when the "prompt for unsaved modifications" step happens.

Specified by:
closeAll in interface ArchitectSwingSessionContext

getExitAfterAllSessionsClosed

public boolean getExitAfterAllSessionsClosed()
Description copied from interface: ArchitectSwingSessionContext
Returns the current session for exiting after all sessions are closed. See ArchitectSwingSessionContext.setExitAfterAllSessionsClosed(boolean) for details.

Specified by:
getExitAfterAllSessionsClosed in interface ArchitectSwingSessionContext

setExitAfterAllSessionsClosed

public void setExitAfterAllSessionsClosed(boolean allowExit)
Description copied from interface: ArchitectSwingSessionContext
Optional setting which will have the context call System.exit() after there are no open sessions remaining. This option is useful for a full single-user Architect application, but not a good idea for embedded use of the Architect, since it will quit your app when you're finished with the Architect API.

The default behaviour for all context implementations must be not to terminate the VM.

Specified by:
setExitAfterAllSessionsClosed in interface ArchitectSwingSessionContext
Parameters:
allowExit - True will allow the context to terminate the VM; false means the context will never call System.exit().

getConnections

public java.util.List<ca.sqlpower.sql.SPDataSource> getConnections()
Specified by:
getConnections in interface ArchitectSessionContext

getPlDotIni

public ca.sqlpower.sql.DataSourceCollection getPlDotIni()
Description copied from interface: ArchitectSessionContext
Tries to read the plDotIni if it hasn't been done already. If it can't be read, returns null and leaves the plDotIni property as null as well. See #plDotIni.

Specified by:
getPlDotIni in interface ArchitectSessionContext

getPlDotIniPath

public java.lang.String getPlDotIniPath()
Specified by:
getPlDotIniPath in interface ArchitectSessionContext

setPlDotIniPath

public void setPlDotIniPath(java.lang.String plDotIniPath)
Description copied from interface: ArchitectSessionContext
Sets the plDotIniPath property, and nulls out the current plDotIni if the given value differs from the existing one. See #plDotIniPath.

Specified by:
setPlDotIniPath in interface ArchitectSessionContext


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