ca.sqlpower.wabit.swingui
Class WabitSwingSessionImpl

java.lang.Object
  extended by ca.sqlpower.wabit.swingui.WabitSwingSessionImpl
All Implemented Interfaces:
ca.sqlpower.swingui.SwingWorkerRegistry, ca.sqlpower.util.SPSession, WabitSwingSession, WabitSession

public class WabitSwingSessionImpl
extends java.lang.Object
implements WabitSwingSession

The Main Window for the Wabit Application.


Nested Class Summary
 class WabitSwingSessionImpl.TreeTabDropTargetListener
          This is the droplistener on the tabbed pane which controls importing and exporting between workspaces
 
Constructor Summary
protected WabitSwingSessionImpl(WabitSwingSessionContext context, WabitSession delegateSession)
          Creates a new session that belongs to the given context and delegates some of its work to the given delegate session.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void addSessionLifecycleListener(ca.sqlpower.swingui.event.SessionLifecycleListener<WabitSession> l)
           
 boolean close()
          Ends this session, disposing its frame and releasing any system resources that were obtained explicitly by this session.
 ca.sqlpower.util.UserPrompter createDatabaseUserPrompter(java.lang.String question, java.util.List<java.lang.Class<? extends ca.sqlpower.sql.SPDataSource>> dsTypes, ca.sqlpower.util.UserPrompter.UserPromptOptions optionType, ca.sqlpower.util.UserPrompter.UserPromptResponse defaultResponseType, java.lang.Object defaultResponse, ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource> dsCollection, java.lang.String... buttonNames)
           
 ca.sqlpower.util.UserPrompter createUserPrompter(java.lang.String question, ca.sqlpower.util.UserPrompterFactory.UserPromptType responseType, ca.sqlpower.util.UserPrompter.UserPromptOptions optionType, ca.sqlpower.util.UserPrompter.UserPromptResponse defaultResponseType, java.lang.Object defaultResponse, java.lang.String... buttonNames)
           
 void delete()
           
 WabitSwingSessionContext getContext()
          Returns the context this session belongs to.
 java.net.URI getCurrentURI()
          Returns the URI that this session was most recently loaded from or saved to.
 java.io.File getCurrentURIAsFile()
          Returns the current URI as a File object, if the current URI is not null and it actually represents a file on a locally-accessible filesystem.
 ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource> getDataSources()
          Returns a collection of all the data sources that are available to this session.
 ca.sqlpower.swingui.db.DatabaseConnectionManager getDbConnectionManager()
          Returns a DatabaseConnectionManager that allows modifying the data source collection of the given session.
 ca.sqlpower.enterprise.client.SPServerInfo getEnterpriseServerInfos()
          Returns the server infos if this session's delegate is a server session.
 WabitWorkspace getSystemWorkspace()
          This method might return a WabitWorkspace, the system one, located on the Wabit server, if the current session is backed by a remote server session.
 javax.swing.JTree getTree()
          Returns the JTree that describes the given session.
 WabitWorkspace getWorkspace()
          Returns the workspace associated with this session.
 WorkspaceTreeModel getWorkspaceTreeModel()
          Returns the tree model that is used to define the JTree in WabitSwingSession.getTree().
 boolean hasUnsavedChanges()
          Reports whether or not any changes have been detected in this workspace since it was opened or last saved.
 boolean isEnterpriseServerSession()
          Returns true if the current session is in fact a remote session with the wabit enterprise server.
 boolean isForegroundThread()
           
 void refresh()
           
 void registerSwingWorker(ca.sqlpower.swingui.SPSwingWorker worker)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void removeSessionLifecycleListener(ca.sqlpower.swingui.event.SessionLifecycleListener<WabitSession> l)
           
 void removeSwingWorker(ca.sqlpower.swingui.SPSwingWorker worker)
           
 void runInBackground(java.lang.Runnable runner)
          Starts this runner on a worker thread that is registered with this swing session.
 void runInForeground(java.lang.Runnable runner)
          The runner will be executed on the event dispatch thread.
 void setCurrentURI(java.net.URI uri)
          Updates the current URI this session's workspace was last loaded from or saved to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WabitSwingSessionImpl

protected WabitSwingSessionImpl(WabitSwingSessionContext context,
                                WabitSession delegateSession)
Creates a new session that belongs to the given context and delegates some of its work to the given delegate session.

To create an instance of this class, use WabitSwingSessionContextImpl.createSession().

Parameters:
context - The context this session belongs to.
delegateSession - The session to delegate some WabitSession operations to.
Method Detail

getDataSources

public ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource> getDataSources()
Description copied from interface: WabitSession
Returns a collection of all the data sources that are available to this session. The data sources do not have to be in the session's workspace. All of the data sources in the session's workspace will be in this collection.

Specified by:
getDataSources in interface WabitSession

getTree

public javax.swing.JTree getTree()
Description copied from interface: WabitSwingSession
Returns the JTree that describes the given session.

Specified by:
getTree in interface WabitSwingSession

addSessionLifecycleListener

public void addSessionLifecycleListener(ca.sqlpower.swingui.event.SessionLifecycleListener<WabitSession> l)
Specified by:
addSessionLifecycleListener in interface WabitSession

removeSessionLifecycleListener

public void removeSessionLifecycleListener(ca.sqlpower.swingui.event.SessionLifecycleListener<WabitSession> l)
Specified by:
removeSessionLifecycleListener in interface WabitSession

close

public boolean close()
Description copied from interface: WabitSession
Ends this session, disposing its frame and releasing any system resources that were obtained explicitly by this session. Also fires a sessionClosing lifecycle event, so any resources used up by subsystems dependent on this session can be freed by the appropriate parties.

Specified by:
close in interface WabitSession
Returns:
True if the session was successfully closed. False if the session did not close due to an error or user intervention.

getWorkspace

public WabitWorkspace getWorkspace()
Description copied from interface: WabitSession
Returns the workspace associated with this session.

Specified by:
getWorkspace in interface ca.sqlpower.util.SPSession
Specified by:
getWorkspace in interface WabitSession

getContext

public WabitSwingSessionContext getContext()
Description copied from interface: WabitSession
Returns the context this session belongs to.

Specified by:
getContext in interface WabitSwingSession
Specified by:
getContext in interface WabitSession

getDbConnectionManager

public ca.sqlpower.swingui.db.DatabaseConnectionManager getDbConnectionManager()
Returns a DatabaseConnectionManager that allows modifying the data source collection of the given session.

Specified by:
getDbConnectionManager in interface WabitSwingSession

createUserPrompter

public ca.sqlpower.util.UserPrompter createUserPrompter(java.lang.String question,
                                                        ca.sqlpower.util.UserPrompterFactory.UserPromptType responseType,
                                                        ca.sqlpower.util.UserPrompter.UserPromptOptions optionType,
                                                        ca.sqlpower.util.UserPrompter.UserPromptResponse defaultResponseType,
                                                        java.lang.Object defaultResponse,
                                                        java.lang.String... buttonNames)

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Specified by:
addPropertyChangeListener in interface WabitSession

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Specified by:
removePropertyChangeListener in interface WabitSession

getWorkspaceTreeModel

public WorkspaceTreeModel getWorkspaceTreeModel()
Description copied from interface: WabitSwingSession
Returns the tree model that is used to define the JTree in WabitSwingSession.getTree().

Specified by:
getWorkspaceTreeModel in interface WabitSwingSession

createDatabaseUserPrompter

public ca.sqlpower.util.UserPrompter createDatabaseUserPrompter(java.lang.String question,
                                                                java.util.List<java.lang.Class<? extends ca.sqlpower.sql.SPDataSource>> dsTypes,
                                                                ca.sqlpower.util.UserPrompter.UserPromptOptions optionType,
                                                                ca.sqlpower.util.UserPrompter.UserPromptResponse defaultResponseType,
                                                                java.lang.Object defaultResponse,
                                                                ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource> dsCollection,
                                                                java.lang.String... buttonNames)

getCurrentURI

public java.net.URI getCurrentURI()
Description copied from interface: WabitSwingSession
Returns the URI that this session was most recently loaded from or saved to.

Specified by:
getCurrentURI in interface WabitSwingSession

setCurrentURI

public void setCurrentURI(java.net.URI uri)
Updates the current URI this session's workspace was last loaded from or saved to. Also clears the unsaved changes state.

Specified by:
setCurrentURI in interface WabitSwingSession

getCurrentURIAsFile

public java.io.File getCurrentURIAsFile()
Description copied from interface: WabitSwingSession
Returns the current URI as a File object, if the current URI is not null and it actually represents a file on a locally-accessible filesystem. Otherwise, returns null (for example, if the current URI is an HTTP URI or represents a Java system resource).

Specified by:
getCurrentURIAsFile in interface WabitSwingSession
See Also:
WabitSwingSession.getCurrentURI()

hasUnsavedChanges

public boolean hasUnsavedChanges()
Description copied from interface: WabitSwingSession
Reports whether or not any changes have been detected in this workspace since it was opened or last saved.

Specified by:
hasUnsavedChanges in interface WabitSwingSession
See Also:
WabitSwingSession.setCurrentURI(URI)

registerSwingWorker

public void registerSwingWorker(@NonNull
                                ca.sqlpower.swingui.SPSwingWorker worker)
Specified by:
registerSwingWorker in interface ca.sqlpower.swingui.SwingWorkerRegistry

removeSwingWorker

public void removeSwingWorker(@NonNull
                              ca.sqlpower.swingui.SPSwingWorker worker)
Specified by:
removeSwingWorker in interface ca.sqlpower.swingui.SwingWorkerRegistry

runInBackground

public void runInBackground(java.lang.Runnable runner)
Description copied from interface: WabitSwingSession
Starts this runner on a worker thread that is registered with this swing session. This helps enforce large running processes occur on a separate thread than the current one if the current thread is the event dispatch thread.

Specified by:
runInBackground in interface ca.sqlpower.util.SPSession
Specified by:
runInBackground in interface WabitSwingSession

runInForeground

public void runInForeground(java.lang.Runnable runner)
Description copied from interface: WabitSwingSession
The runner will be executed on the event dispatch thread. This will block the UI from responding as long as the runner is running. If a process is running in the background and we need to fire events or do other work on the event dispatch thread it can be wrapped in a runnable and passed to here. The background thread will not block and wait for the runner to complete.

Specified by:
runInForeground in interface ca.sqlpower.util.SPSession
Specified by:
runInForeground in interface WabitSwingSession

isForegroundThread

public boolean isForegroundThread()
Specified by:
isForegroundThread in interface ca.sqlpower.util.SPSession

isEnterpriseServerSession

public boolean isEnterpriseServerSession()
Description copied from interface: WabitSession
Returns true if the current session is in fact a remote session with the wabit enterprise server.

Specified by:
isEnterpriseServerSession in interface WabitSession
Returns:

getEnterpriseServerInfos

public ca.sqlpower.enterprise.client.SPServerInfo getEnterpriseServerInfos()
Returns the server infos if this session's delegate is a server session. Returns null otherwise.


getSystemWorkspace

public WabitWorkspace getSystemWorkspace()
Description copied from interface: WabitSession
This method might return a WabitWorkspace, the system one, located on the Wabit server, if the current session is backed by a remote server session. It will return null if it is not a server session or the user doesn't have access to the system workspace. One can also use isEnterpriseSession() to verify if this call will return null beforehand.

Specified by:
getSystemWorkspace in interface WabitSession
Returns:

refresh

public void refresh()

delete

public void delete()
            throws org.apache.http.client.ClientProtocolException,
                   java.net.URISyntaxException,
                   java.io.IOException
Throws:
org.apache.http.client.ClientProtocolException
java.net.URISyntaxException
java.io.IOException


Copyright © 2009. All Rights Reserved.