ca.sqlpower.architect.swingui
Class ArchitectSwingSessionImpl

java.lang.Object
  extended by ca.sqlpower.architect.swingui.ArchitectSwingSessionImpl
All Implemented Interfaces:
ArchitectSession, ArchitectSwingSession, UserPrompterFactory, ca.sqlpower.swingui.SwingWorkerRegistry

public class ArchitectSwingSessionImpl
extends java.lang.Object
implements ArchitectSwingSession


Field Summary
 
Fields inherited from interface ca.sqlpower.architect.ArchitectSession
PREFS_PL_INI_PATH
 
Method Summary
 void addSessionLifecycleListener(ca.sqlpower.swingui.event.SessionLifecycleListener<ArchitectSwingSession> listener)
          Adds the given listener to the list of interested parties who want to be notified when this session is about to close.
 void close()
          This is a common handler for all actions that must occur when switching projects, e.g., prompting to save any unsaved changes, disposing dialogs, shutting down running threads, and so on.
 UserPrompter createUserPrompter(java.lang.String question, java.lang.String okText, java.lang.String notOkText, java.lang.String cancelText)
          Creates a new user prompter that uses a modal dialog to pose the given question.
 void fireSessionClosing()
           
 ArchitectFrame getArchitectFrame()
          Returns the ArchitectFrame created in this session.
 CompareDMSettings getCompareDMSettings()
           
 ArchitectSwingSessionContext getContext()
          Returns the context that created this session.
 DDLGenerator getDDLGenerator()
          The DDL Generator currently in use for this session.
 KettleJob getKettleJob()
           
 java.lang.String getName()
          Gets the value of name
 OLAPEditSession getOLAPEditSession(OLAPSession olapSession)
          Returns the OLAPEditSession that is associated with editing the given OLAPSession.
 java.util.List<OLAPEditSession> getOLAPEditSessions()
          Returns a list of the OLAPEditSessions associated with this session's OLAP Schemas.
 OLAPRootObject getOLAPRootObject()
          Returns the OLAP root object, which contains all the OLAP sessions that are part of this Architect session.
 PlayPen getPlayPen()
          Gets the value of playPen
 javax.swing.JDialog getProfileDialog()
          Returns the JDialog containing the ProfileManagerView
 ProfileManager getProfileManager()
           
 SwingUIProject getProject()
          Returns the project associated with this session.
 RecentMenu getRecentMenu()
          Gets the recent menu list
 boolean getRelationshipLinesDirect()
          Relationship line style: True means direct lines; false means only horizontal and vertical lines.
 SQLObjectRoot getRootObject()
          Returns the top level object in the SQLObject hierarchy.
 DBTree getSourceDatabases()
          Gets the value of sourceDatabases
 SQLDatabase getTargetDatabase()
          Gets the target database in the playPen.
 UndoManager getUndoManager()
          Gets the UndoManager keeping track of changes in this session
 CoreUserSettings getUserSettings()
          See #userSettings.
 void initGUI()
          Initializes the GUI components for this session.
 void initGUI(ArchitectSwingSession openingSession)
          Like initGUI(), this method initializes the GUI components for this session, with the exception that the GUI components will get positioned relative to the GUI component of the given ArchitectSwingSession.
 boolean isNew()
          Returns true if the session contains a completely new and unmodified project.
 boolean isRelationshipLinesDirect()
           
 boolean isSavingEntireSource()
          See savingEntireSource.
 boolean isShowAkTag()
          Returns whether the AK Tags will be shown
 boolean isShowFkTag()
          Returns whether the FK Tags will be shown
 boolean isShowForeign()
          Indicates whether FK Columns will be shown.
 boolean isShowIndexed()
          Indicates whether Indexed Columns will be shown.
 boolean isShowPkTag()
          Returns whether the PK Tags will be shown
 boolean isShowPrimary()
          Indicates whether PK Columns will be shown.
 boolean isShowTheRest()
          Indicates whether Columns that are not PK, FK, Unique or Indexed will be shown.
 boolean isShowUnique()
          Indicates whether Unique Columns will be shown.
protected  boolean promptForUnsavedModifications()
          Checks if the project is modified, and if so presents the user with the option to save the existing project.
 void registerSwingWorker(ca.sqlpower.swingui.SPSwingWorker worker)
           
 void removeSessionLifecycleListener(ca.sqlpower.swingui.event.SessionLifecycleListener<ArchitectSwingSession> listener)
          Removes the given listener from the lifecycle event list.
 void removeSwingWorker(ca.sqlpower.swingui.SPSwingWorker worker)
           
 boolean saveOrSaveAs(boolean showChooser, boolean separateThread)
          Condition the Model to save the project, showing a file chooser when appropriate.
 void setCompareDMSettings(CompareDMSettings compareDMSettings)
           
 void setDDLGenerator(DDLGenerator generator)
          Sets the new DDL Generator currently in use for this session.
 void setKettleJob(KettleJob kettleJob)
           
 void setName(java.lang.String argName)
          Sets the value of name
 void setProject(CoreProject project)
          This method is only used to create the correct type of project for an ArchitectSwingSessionImpl and should not be called anywhere else.
 void setRelationshipLinesDirect(boolean relationshipLinesDirect)
          Relationship line style: True means direct lines; false means only horizontal and vertical lines.
 void setSavingEntireSource(boolean argSavingEntireSource)
          See savingEntireSource.
 void setShowAkTag(boolean showAkTag)
          Sets whether the AK Tags will be shown
 void setShowFkTag(boolean showFkTag)
          Sets whether the FK Tags will be shown
 void setShowForeign(boolean showForeign)
          Sets whether FK Columns should be shown.
 void setShowIndexed(boolean showIndexed)
          Sets whether Indexed Columns should be shown.
 void setShowPkTag(boolean showPkTag)
          Sets whether the PK Tags will be shown
 void setShowPrimary(boolean showPrimary)
          Sets whether PK Columns should be shown.
 void setShowTheRest(boolean showTheRest)
          Sets whether Columns that are not PK, FK, Unique or Indexed should be shown.
 void setShowUnique(boolean showUnique)
          Sets whether Unique Columns should be shown.
 void setSourceDatabaseList(java.util.List<SQLDatabase> databases)
          Replaces the entire list of source databases for this session.
 void setSourceDatabases(DBTree argSourceDatabases)
          Sets the value of sourceDatabases
 void showOLAPSchemaManager(java.awt.Window owner)
          Shows the schema manager dialog for this session's OLAP Schemas.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initGUI

public void initGUI()
             throws ArchitectException
Description copied from interface: ArchitectSwingSession
Initializes the GUI components for this session. Call this only if you need a GUI. This method must be called on the Swing Event Dispatch Thread.

Specified by:
initGUI in interface ArchitectSwingSession
Throws:
ArchitectException

initGUI

public void initGUI(ArchitectSwingSession openingSession)
             throws ArchitectException
Description copied from interface: ArchitectSwingSession
Like initGUI(), this method initializes the GUI components for this session, with the exception that the GUI components will get positioned relative to the GUI component of the given ArchitectSwingSession. As with initGUI(), call this only if you need a GUI. This method must be called on the Swing Event Dispatch Thread.

Specified by:
initGUI in interface ArchitectSwingSession
Parameters:
openingSession - The ArchitectSwingSession to which this session's GUI components will be positioned relative to
Throws:
ArchitectException

getProject

public SwingUIProject getProject()
Description copied from interface: ArchitectSession
Returns the project associated with this session. The project holds the playpen objects, and can save and load itself in an XML format.

Specified by:
getProject in interface ArchitectSession
Specified by:
getProject in interface ArchitectSwingSession

setProject

public void setProject(CoreProject project)
Description copied from interface: ArchitectSession
This method is only used to create the correct type of project for an ArchitectSwingSessionImpl and should not be called anywhere else.

Specified by:
setProject in interface ArchitectSession

getUserSettings

public CoreUserSettings getUserSettings()
Description copied from interface: ArchitectSwingSession
See #userSettings.

Specified by:
getUserSettings in interface ArchitectSwingSession
Returns:
the value of userSettings

getContext

public ArchitectSwingSessionContext getContext()
Description copied from interface: ArchitectSession
Returns the context that created this session.

Specified by:
getContext in interface ArchitectSession
Specified by:
getContext in interface ArchitectSwingSession

getArchitectFrame

public ArchitectFrame getArchitectFrame()
Description copied from interface: ArchitectSwingSession
Returns the ArchitectFrame created in this session.

Specified by:
getArchitectFrame in interface ArchitectSwingSession

promptForUnsavedModifications

protected boolean promptForUnsavedModifications()
Checks if the project is modified, and if so presents the user with the option to save the existing project. This is useful to use in actions that are about to get rid of the currently open project.

Returns:
True if the project can be closed; false if the project should remain open.

saveOrSaveAs

public boolean saveOrSaveAs(boolean showChooser,
                            boolean separateThread)
Condition the Model to save the project, showing a file chooser when appropriate.

Specified by:
saveOrSaveAs in interface ArchitectSwingSession
Parameters:
showChooser - If true, a chooser will always be shown; otherwise a chooser will only be shown if the project has no file associated with it (this is usually because it has never been saved before).
separateThread - If true, the (possibly lengthy) save operation will be executed in a separate thread and this method will return immediately. Otherwise, the save operation will proceed on the current thread.
Returns:
True if the project was saved successfully; false otherwise. If saving on a separate thread, a result of true is just an optimistic guess, and there is no way to discover if the save operation has eventually succeeded or failed.

close

public void close()
This is a common handler for all actions that must occur when switching projects, e.g., prompting to save any unsaved changes, disposing dialogs, shutting down running threads, and so on.

Specified by:
close in interface ArchitectSwingSession

getSourceDatabases

public DBTree getSourceDatabases()
Gets the value of sourceDatabases

Specified by:
getSourceDatabases in interface ArchitectSwingSession
Returns:
the value of sourceDatabases

setSourceDatabases

public void setSourceDatabases(DBTree argSourceDatabases)
Sets the value of sourceDatabases

Parameters:
argSourceDatabases - Value to assign to this.sourceDatabases

setSourceDatabaseList

public void setSourceDatabaseList(java.util.List<SQLDatabase> databases)
                           throws ArchitectException
Description copied from interface: ArchitectSession
Replaces the entire list of source databases for this session. This method is used reflectively by the code that does loading and saving, so DON'T DELETE THIS METHOD even if it looks like it's unused.

Specified by:
setSourceDatabaseList in interface ArchitectSession
Throws:
ArchitectException

getTargetDatabase

public SQLDatabase getTargetDatabase()
Gets the target database in the playPen.

Specified by:
getTargetDatabase in interface ArchitectSession

getName

public java.lang.String getName()
Gets the value of name

Specified by:
getName in interface ArchitectSession
Returns:
the value of name

setName

public void setName(java.lang.String argName)
Sets the value of name

Specified by:
setName in interface ArchitectSession
Parameters:
argName - Value to assign to this.name

getPlayPen

public PlayPen getPlayPen()
Gets the value of playPen

Specified by:
getPlayPen in interface ArchitectSwingSession
Returns:
the value of playPen

getRecentMenu

public RecentMenu getRecentMenu()
Gets the recent menu list

Specified by:
getRecentMenu in interface ArchitectSwingSession
Returns:
the recent menu

getCompareDMSettings

public CompareDMSettings getCompareDMSettings()
Specified by:
getCompareDMSettings in interface ArchitectSwingSession

setCompareDMSettings

public void setCompareDMSettings(CompareDMSettings compareDMSettings)

getUndoManager

public UndoManager getUndoManager()
Description copied from interface: ArchitectSwingSession
Gets the UndoManager keeping track of changes in this session

Specified by:
getUndoManager in interface ArchitectSwingSession

getProfileManager

public ProfileManager getProfileManager()
Specified by:
getProfileManager in interface ArchitectSession

getProfileDialog

public javax.swing.JDialog getProfileDialog()
Description copied from interface: ArchitectSwingSession
Returns the JDialog containing the ProfileManagerView

Specified by:
getProfileDialog in interface ArchitectSwingSession

isSavingEntireSource

public boolean isSavingEntireSource()
See savingEntireSource.

Specified by:
isSavingEntireSource in interface ArchitectSwingSession
Returns:
the value of savingEntireSource

setSavingEntireSource

public void setSavingEntireSource(boolean argSavingEntireSource)
See savingEntireSource.

Specified by:
setSavingEntireSource in interface ArchitectSwingSession
Parameters:
argSavingEntireSource - Value to assign to this.savingEntireSource

getKettleJob

public KettleJob getKettleJob()
Specified by:
getKettleJob in interface ArchitectSwingSession

setKettleJob

public void setKettleJob(KettleJob kettleJob)
Specified by:
setKettleJob in interface ArchitectSwingSession

addSessionLifecycleListener

public void addSessionLifecycleListener(ca.sqlpower.swingui.event.SessionLifecycleListener<ArchitectSwingSession> listener)
Description copied from interface: ArchitectSwingSession
Adds the given listener to the list of interested parties who want to be notified when this session is about to close. Being a lifecycle listener is an excellent way to make a session shutdown hook for your subsystem.

Specified by:
addSessionLifecycleListener in interface ArchitectSwingSession

removeSessionLifecycleListener

public void removeSessionLifecycleListener(ca.sqlpower.swingui.event.SessionLifecycleListener<ArchitectSwingSession> listener)
Description copied from interface: ArchitectSwingSession
Removes the given listener from the lifecycle event list. Once removed, the listener will not receive a sessionClosing notification when this session closes.

Specified by:
removeSessionLifecycleListener in interface ArchitectSwingSession

fireSessionClosing

public void fireSessionClosing()

registerSwingWorker

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

removeSwingWorker

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

isNew

public boolean isNew()
Description copied from interface: ArchitectSwingSession
Returns true if the session contains a completely new and unmodified project. Otherwise, it returns false.

Note: that this property is different from the SwingUIProject.isModified() property in that the isNew property is persisted when the project is saved, and refers to whether the project was ever modified since it was first created, whereas, the isModified property refers to whether the project was modified ever since the project was last loaded.

Specified by:
isNew in interface ArchitectSwingSession

isRelationshipLinesDirect

public boolean isRelationshipLinesDirect()

setRelationshipLinesDirect

public void setRelationshipLinesDirect(boolean relationshipLinesDirect)
Description copied from interface: ArchitectSwingSession
Relationship line style: True means direct lines; false means only horizontal and vertical lines. Updating this preference will cause all of the relationships in this session's play pen to have their line style updated.

Specified by:
setRelationshipLinesDirect in interface ArchitectSwingSession

getRelationshipLinesDirect

public boolean getRelationshipLinesDirect()
Description copied from interface: ArchitectSwingSession
Relationship line style: True means direct lines; false means only horizontal and vertical lines.

Specified by:
getRelationshipLinesDirect in interface ArchitectSwingSession

getRootObject

public SQLObjectRoot getRootObject()
Description copied from interface: ArchitectSession
Returns the top level object in the SQLObject hierarchy. It has no parent and its children are SQLDatabase's.

Specified by:
getRootObject in interface ArchitectSession

getDDLGenerator

public DDLGenerator getDDLGenerator()
Description copied from interface: ArchitectSession
The DDL Generator currently in use for this session.

Specified by:
getDDLGenerator in interface ArchitectSession

setDDLGenerator

public void setDDLGenerator(DDLGenerator generator)
Description copied from interface: ArchitectSession
Sets the new DDL Generator currently in use for this session.

Specified by:
setDDLGenerator in interface ArchitectSession

getOLAPRootObject

public OLAPRootObject getOLAPRootObject()
Description copied from interface: ArchitectSession
Returns the OLAP root object, which contains all the OLAP sessions that are part of this Architect session.

Note: We would prefer not to let ArchitectSession reference anything in the OLAP editor, since we do not want the core Architect API to include OLAP support. We are currently trying to come up with a way to put this somewhere else.

Specified by:
getOLAPRootObject in interface ArchitectSession

createUserPrompter

public UserPrompter createUserPrompter(java.lang.String question,
                                       java.lang.String okText,
                                       java.lang.String notOkText,
                                       java.lang.String cancelText)
Creates a new user prompter that uses a modal dialog to pose the given question.

Specified by:
createUserPrompter in interface ArchitectSession
Specified by:
createUserPrompter in interface UserPrompterFactory
Parameters:
question - The question the new prompter will pose when solociting a response from the user. This question string is not exactly plain text: it is formatted according to to rules laid out in the MessageFormat class. The most important implications are that the single quote (') character and the open curly brace ({) characters are special and have to be escaped in order to appear in the message. The other important thing (the benefit, that is) is that constructions of the form {0} are placeholders that will be substituted every time the question is asked via the UserPrompter.promptUser(Object[]) method is called. See MessageFormat for details.

Also, UserPrompter implementations will ensure that newline characters (\n) show up as new lines when the question is presented to the user.

okText - The text to associate with the OK response. Try to use a word or phrase from the question instead of a generic word like "OK" or "Yes".
notOkText - The text to associate with the "not OK" response. Try to use a word or phrase from the question instead of a generic word like "No".
cancelText - The text to associate with response that cancels the whole operation.
See Also:
ModalDialogUserPrompter

isShowPkTag

public boolean isShowPkTag()
Description copied from interface: ArchitectSwingSession
Returns whether the PK Tags will be shown

Specified by:
isShowPkTag in interface ArchitectSwingSession

setShowPkTag

public void setShowPkTag(boolean showPkTag)
Description copied from interface: ArchitectSwingSession
Sets whether the PK Tags will be shown

Specified by:
setShowPkTag in interface ArchitectSwingSession

isShowFkTag

public boolean isShowFkTag()
Description copied from interface: ArchitectSwingSession
Returns whether the FK Tags will be shown

Specified by:
isShowFkTag in interface ArchitectSwingSession

setShowFkTag

public void setShowFkTag(boolean showFkTag)
Description copied from interface: ArchitectSwingSession
Sets whether the FK Tags will be shown

Specified by:
setShowFkTag in interface ArchitectSwingSession

isShowAkTag

public boolean isShowAkTag()
Description copied from interface: ArchitectSwingSession
Returns whether the AK Tags will be shown

Specified by:
isShowAkTag in interface ArchitectSwingSession

setShowAkTag

public void setShowAkTag(boolean showAkTag)
Description copied from interface: ArchitectSwingSession
Sets whether the AK Tags will be shown

Specified by:
setShowAkTag in interface ArchitectSwingSession

isShowPrimary

public boolean isShowPrimary()
Description copied from interface: ArchitectSwingSession
Indicates whether PK Columns will be shown.

Specified by:
isShowPrimary in interface ArchitectSwingSession

setShowPrimary

public void setShowPrimary(boolean showPrimary)
Description copied from interface: ArchitectSwingSession
Sets whether PK Columns should be shown.

Specified by:
setShowPrimary in interface ArchitectSwingSession

isShowForeign

public boolean isShowForeign()
Description copied from interface: ArchitectSwingSession
Indicates whether FK Columns will be shown.

Specified by:
isShowForeign in interface ArchitectSwingSession

setShowForeign

public void setShowForeign(boolean showForeign)
Description copied from interface: ArchitectSwingSession
Sets whether FK Columns should be shown.

Specified by:
setShowForeign in interface ArchitectSwingSession

isShowIndexed

public boolean isShowIndexed()
Description copied from interface: ArchitectSwingSession
Indicates whether Indexed Columns will be shown.

Specified by:
isShowIndexed in interface ArchitectSwingSession

setShowIndexed

public void setShowIndexed(boolean showIndexed)
Description copied from interface: ArchitectSwingSession
Sets whether Indexed Columns should be shown.

Specified by:
setShowIndexed in interface ArchitectSwingSession

isShowUnique

public boolean isShowUnique()
Description copied from interface: ArchitectSwingSession
Indicates whether Unique Columns will be shown.

Specified by:
isShowUnique in interface ArchitectSwingSession

setShowUnique

public void setShowUnique(boolean showUnique)
Description copied from interface: ArchitectSwingSession
Sets whether Unique Columns should be shown.

Specified by:
setShowUnique in interface ArchitectSwingSession

isShowTheRest

public boolean isShowTheRest()
Description copied from interface: ArchitectSwingSession
Indicates whether Columns that are not PK, FK, Unique or Indexed will be shown.

Specified by:
isShowTheRest in interface ArchitectSwingSession

setShowTheRest

public void setShowTheRest(boolean showTheRest)
Description copied from interface: ArchitectSwingSession
Sets whether Columns that are not PK, FK, Unique or Indexed should be shown.

Specified by:
setShowTheRest in interface ArchitectSwingSession

showOLAPSchemaManager

public void showOLAPSchemaManager(java.awt.Window owner)
Description copied from interface: ArchitectSwingSession
Shows the schema manager dialog for this session's OLAP Schemas.

Specified by:
showOLAPSchemaManager in interface ArchitectSwingSession
Parameters:
owner - The owner of the dialog.

getOLAPEditSessions

public java.util.List<OLAPEditSession> getOLAPEditSessions()
Description copied from interface: ArchitectSwingSession
Returns a list of the OLAPEditSessions associated with this session's OLAP Schemas.

Specified by:
getOLAPEditSessions in interface ArchitectSwingSession
Returns:
the list of edit sessions.

getOLAPEditSession

public OLAPEditSession getOLAPEditSession(OLAPSession olapSession)
Description copied from interface: ArchitectSwingSession
Returns the OLAPEditSession that is associated with editing the given OLAPSession.

Specified by:
getOLAPEditSession in interface ArchitectSwingSession
Parameters:
olapSession - the OLAPSession in question, must not be null.
Returns:
the associated OLAPEditSession, creates a new one if none found.


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