com.tensegrity.skeleton.swt
Class SwtApplicationFrame

java.lang.Object
  extended bycom.tensegrity.application.ApplicationFrame
      extended bycom.tensegrity.skeleton.swt.SwtApplicationFrame
All Implemented Interfaces:
DocumentListener, Evaluable, EventListenerTag

public abstract class SwtApplicationFrame
extends ApplicationFrame

This is the SWT-based implementation of ApplicationFrame.

A single constructor is provided for this class, which requires a valid Display and parent ExtendedShell as parameter.

Notice that at this point in time a single SWT-based MDIComponent implementation is currently available and is returned by the getMDIComponent() method. See SwtTabbedMDIComponent for more information.

The following Container are currently available through this ApplicationFrame:

At this stage of development, no SWT-based OutlinerContainer is available, therefore getOutlinerContainer() returns null.

It is the application developer's responsability to organize the layout of the MDI Component and of the containers. The launch task SwtInitGUILaunchTask sets a default layout but is intended to be extended by application developers wishing to customize it. It allows them to modify the layout of the application Shell as well as the layout data of all Containers. Notice that a good understanding of layouts in SWT is required in order to modify the default layout. Refer to http://www.eclipse.org/articles/Understanding%20Layouts/Understanding%20Layouts.htm for more information regarding layouts in SWT.

In order to avoid having the splashscreen beeing displayed, which is typically the case for Eclipse Plug-ins, one should overwrite the getSplashScreenImage() method and make it return null. null.

One should call the exit() method before terminating the application (that is, before the parent ExtendedShell is closed). This method handles the closing of documents and ensures that preferences are saved as well as releasing locally held resources.

Version:
$Id: SwtApplicationFrame.java,v 1.131 2006/05/09 09:33:58 MichaelKegel Exp $
Author:
S�bastien Guyon

Nested Class Summary
 class SwtApplicationFrame.NavigatorUpdater
          The NavigatorUpdater is an Observer which updates the Navigator of an ApplicationFrame.
 
Field Summary
static org.eclipse.jface.resource.ColorRegistry colorRegistry
          ColorRegistry used in order to efficiently manage Colors in the plug-in
protected  org.eclipse.swt.widgets.Display display
          This is the
protected  SwtLayoutToolsContainer layoutTools
          The LayoutTools of this application.
protected  MDIDelegate mdicomponent
          instance variable for the opened graph views
protected  ExtendedShell shell
          When being in application(non-applet-) mode, this instance represents the outer Shell instance.
 
Fields inherited from class com.tensegrity.application.ApplicationFrame
application, EAST, NORTH, NORTHEAST, NORTHWEST, SOUTH, SOUTHEAST, SOUTHWEST, TYPE_CLONED_DOCUMENT, TYPE_LOADED_DOCUMENT, TYPE_NEW_DOCUMENT, UNDEFINED, WEST
 
Constructor Summary
SwtApplicationFrame(org.eclipse.swt.widgets.Display display, ExtendedShell frame)
          Deprecated. Use SwtApplicationFrame(GraphApplication, Display, ExtendedShell) instead!
SwtApplicationFrame(GraphApplication application, org.eclipse.swt.widgets.Display display, ExtendedShell frame)
          Creates a SwtApplicationFrame based on the given Display and ExtendedShell.
 
Method Summary
 void applyEvList()
          Tells the component to apply its UIItemEvaluationList.
 void configureDocumentView(Document document, int documenttype)
          This method is called from configureNewDocument(Document).
 void configureEmptyDocument(Document document)
          Does nothing.
 void configureNewDocument(Document document)
          This method performs post-creation configuration of the passed document.
protected  boolean doValidateDocument(GraphDocument document)
          This method is called, whenever a document is opened.
 boolean dropDocument(java.io.File file)
           
 boolean exit()
          Cleanup method that is called when the application will be closed to free all resources from the application frame and store all contained documents, etc.
 Applet getApplet()
          Returns null since Applets are not relevant in the SWT-context.
protected  org.eclipse.swt.graphics.Image getApplicationIconImage()
          Returns null.
 AttributeEditorContainer getAttributeEditorContainer()
          This method creates and returns the internal instance of SwtAttributeTreeContainer which is currently the only SWT-based implementation of the AttributeEditorContainer interface.
 Container getCustomContainer()
          At the current state of development of the SWT part of the library this method inherited from ApplicationFrame is not relevant and therefore always returns null.
 org.eclipse.swt.widgets.Display getDisplay()
          Returns the Display used within this SWT application
 Frame getFrame()
          Returns either the awt.Frame of this ApplicationFrame or null if this ApplicationFrame is running as Applet.
protected  GraphApplication getGraphApplication()
           Returns the GraphApplication.
 GraphDocumentReader getGraphDocumentReader()
          Returns the GraphDocumentReader to use for reading documents.
 GraphDocumentWriter getGraphDocumentWriter()
           Returns a GraphDocumentWriter instance
 JPopupMenuSourceWithUpdateUI getGraphPanelPopupMenuSource()
           Returns the local JPopupMenuSourceWithUpdateUI
protected  LaunchTask[] getLauncherTasks()
          Returns all the LaunchTasks to be executed while starting the application.
 int getLayoutConstraint(Container container)
          At the current state of development of the SWT part of the library this method inherited from ApplicationFrame is not relevant and therefore always returns 0.
 LayoutToolsContainer getLayoutToolsContainer()
          Returns the LayoutToolsContainer of this Application or null if no such Container is used.
 MDIComponent getMDIComponent()
          Returns the MDIComponent of the this ApplicationFrame.
 MenuBar getMenuBar()
          Returns the MenuBar of this ApplicationFrame.
 NavigatorContainer getNavigatorContainer()
          Returns the NavigatorContainer of this Application or null if no such Container is used.
 OutlinerContainer getOutlinerContainer()
          Is intended to return the ObjectTreeContainer of this Application but since there is currently no such component for SWT applications, it returns null.
 SwtPreferenceHelper getPreferenceHelper()
          Returns the preference helper of this application.
 RepositoryContainer getRepositoryContainer()
          Creates and returns an instance of SwtRepositoryContainer.
 java.lang.String getResourceName()
          Deprecated. Use ApplicationFrame.getResourceNames() instead.
protected  org.eclipse.swt.graphics.Image getSplashScreenImage()
          Returns Tensegrity's default splashscreen image.
 StatusBar getStatusBar()
          At this point in time no status bar is provided by the framework for SWT applications therefore this method returns null.
 ToolBar[] getToolBars()
          Returns the ToolBar instances used within this ApplicationFrame, the default one being at index 0 of the returned array.
 void init()
          Initializes the ApplicationFrame.
protected  void initServices()
          Utility method called from the constructor of this SwtApplicationFrame.
 void installEvList()
          Creates a new UIItemEvaluationList
 boolean isApplet()
          Returns false since we do not have applets within the SWT context.
protected  void launchTasks()
          Retrieves all the launcher tasks for this application and starts them.
 Document newDocument()
          Sublcasses may override it to specify the creation of new documents.
 Document openDocument(java.io.File file)
          This method is responsible to load a document from a specified file location.
 Document openDocument(java.io.InputStream is, java.lang.String name)
          This method is responsible to load a document from a specified input stream.
protected  void postLaunch()
          This method will be invoked right after the last launch task has been executed.
 void saveDocument_org(Document document, java.io.File file)
           
 void saveDocument(Document document, java.io.File file)
          This method is responsible to save a given document to a specified file location.
 void saveDocument(Document document, java.io.OutputStream os)
          This method is responsible to save a given document to a specified output stream.
 void savePreferences()
          Saves the currently stored Preferences of this application.
protected  void setApplicationIcon()
          The method setApplicationIcon sets the image icon at the internal Decorations instance.
 void setGraphPanelPopupMenuSource(JPopupMenuSourceWithUpdateUI graphPanelPopupMenuSource)
           Sets the local JPopupMenuSourceWithUpdateUI
 void setPreferenceHelper(SwtPreferenceHelper helper)
          Sets the preference helper of this application.
 
Methods inherited from class com.tensegrity.application.ApplicationFrame
addKeyCommand, addPostLaunchTask, documentAdded, documentModelChanged, documentPreAdd, documentPreRemove, documentRemoved, documentSelected, documentUnselected, getApplication, getAttributeEditorTranslator, getAttributeEditorTranslatorPool, getAutomaticLayoutContextName, getCommandRegistry, getCompositeViewListener, getCustomContainers, getDefaultLayoutController, getDocumentDropContext, getDragContext, getKeyStrokeProvider, getLayoutEditorTranslator, getLocale, getPreferenceAttributeEditorTranslator, getPreferences, getResourceNames, getRootFrame, getRuleRegistry, getTitle, getUIManager, getUiMap, installClipboard, installInteractionSettings, installKeyboardCommands, installLayoutController, installListeners, registerDragRepresentation, registerHighlightRepresentation, removePostLaunchTask, runPostLaunchTasks, setAutomaticLayoutContextName, setLocale, setPreferences, setRuleRegistry, updateResources, updateStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colorRegistry

public static org.eclipse.jface.resource.ColorRegistry colorRegistry
ColorRegistry used in order to efficiently manage Colors in the plug-in


layoutTools

protected SwtLayoutToolsContainer layoutTools
The LayoutTools of this application.


shell

protected ExtendedShell shell
When being in application(non-applet-) mode, this instance represents the outer Shell instance.


display

protected org.eclipse.swt.widgets.Display display
This is the


mdicomponent

protected MDIDelegate mdicomponent
instance variable for the opened graph views

Constructor Detail

SwtApplicationFrame

public SwtApplicationFrame(org.eclipse.swt.widgets.Display display,
                           ExtendedShell frame)
Deprecated. Use SwtApplicationFrame(GraphApplication, Display, ExtendedShell) instead!

Creates a SwtApplicationFrame based on the given Display and ExtendedShell. Note that this constructor internally calls the initServices() method.

Parameters:
display - the Display used for the SWT application
frame - the ExtendedShell to place this application into.

SwtApplicationFrame

public SwtApplicationFrame(GraphApplication application,
                           org.eclipse.swt.widgets.Display display,
                           ExtendedShell frame)
Creates a SwtApplicationFrame based on the given Display and ExtendedShell. Note that this constructor internally calls the initServices() method.

Parameters:
application - The graph application this application frame belongs to
display - the Display used for the SWT application
frame - the ExtendedShell to place this application into.
Method Detail

getDisplay

public final org.eclipse.swt.widgets.Display getDisplay()
Returns the Display used within this SWT application

Returns:
the Display used within this SWT application

initServices

protected void initServices()
Utility method called from the constructor of this SwtApplicationFrame. Users of this class may use this method, to install services or make any other initialization which must happen in the constructor of this class. NOTE: You also may use a custom LaunchTask instead of the initServices method.


configureNewDocument

public void configureNewDocument(Document document)
This method performs post-creation configuration of the passed document. It is called when creating a new document, opening a previously saved document and when cloning a document. The passed document's SwtGraphPaneland VisualGraphView are initialized as follow: This method delegates its code to configureEmptyDocument(Document) and configureNewDocument(Document).

Specified by:
configureNewDocument in class ApplicationFrame
Parameters:
document - The document to configure.
See Also:
ApplicationFrame.configureNewDocument(com.tensegrity.gui.document.Document), SwtNewDocumentCommand, OpenCommand, CloneDocumentCommand

configureEmptyDocument

public void configureEmptyDocument(Document document)
Does nothing. This is called from configureNewDocument(Document).

Specified by:
configureEmptyDocument in class ApplicationFrame
Parameters:
document - The document to configure
See Also:
ApplicationFrame.configureEmptyDocument(com.tensegrity.gui.document.Document)

configureDocumentView

public void configureDocumentView(Document document,
                                  int documenttype)
This method is called from configureNewDocument(Document). The passed document's SwtGraphPaneland VisualGraphView are initialized as follow:

Specified by:
configureDocumentView in class ApplicationFrame
Parameters:
document - The document to configure
documenttype - A constant describing the source of this document, one of these constants: ApplicationFrame.TYPE_NEW_DOCUMENT ApplicationFrame.TYPE_CLONED_DOCUMENT ApplicationFrame.TYPE_LOADED_DOCUMENT
See Also:
ApplicationFrame.configureDocumentView(com.tensegrity.gui.document.Document, int)

getCustomContainer

public Container getCustomContainer()
At the current state of development of the SWT part of the library this method inherited from ApplicationFrame is not relevant and therefore always returns null.

Specified by:
getCustomContainer in class ApplicationFrame
Returns:
null.

getFrame

public Frame getFrame()
Description copied from class: ApplicationFrame
Returns either the awt.Frame of this ApplicationFrame or null if this ApplicationFrame is running as Applet.

Specified by:
getFrame in class ApplicationFrame
Returns:
Frame either an instance of java.awt.Frame or null.

getLayoutConstraint

public int getLayoutConstraint(Container container)
At the current state of development of the SWT part of the library this method inherited from ApplicationFrame is not relevant and therefore always returns 0.

Specified by:
getLayoutConstraint in class ApplicationFrame
Parameters:
container - A container to retrieve the layout constraint for.
Returns:
0 since this is currently not relevant in the SWT context.
See Also:
ApplicationFrame.getLayoutConstraint(com.tensegrity.gui.container.Container)

getMDIComponent

public MDIComponent getMDIComponent()
Description copied from class: ApplicationFrame
Returns the MDIComponent of the this ApplicationFrame.

Specified by:
getMDIComponent in class ApplicationFrame
Returns:
the MDIComponent of the this ApplicationFrame.

getMenuBar

public MenuBar getMenuBar()
Description copied from class: ApplicationFrame
Returns the MenuBar of this ApplicationFrame.

Specified by:
getMenuBar in class ApplicationFrame
Returns:
an instance of the MenuBar interface.

getStatusBar

public StatusBar getStatusBar()
At this point in time no status bar is provided by the framework for SWT applications therefore this method returns null.

Specified by:
getStatusBar in class ApplicationFrame
Returns:
null.
See Also:
ApplicationFrame.getStatusBar()

init

public void init()
Initializes the ApplicationFrame. Sets the frame title, icon and starts the launchTasks. Must be called before showing the ApplicationFrame!

Specified by:
init in class ApplicationFrame

launchTasks

protected void launchTasks()
Retrieves all the launcher tasks for this application and starts them. In order to avoid having the splashscreen being displayed one should overwrite the getSplashScreenImage() method and make it return null.

See Also:
getLauncherTasks()

postLaunch

protected void postLaunch()
This method will be invoked right after the last launch task has been executed. Subclasses may do further actions to initialize the application. This class does by intention nothing in the postLaunch.


isApplet

public boolean isApplet()
Returns false since we do not have applets within the SWT context.

Overrides:
isApplet in class ApplicationFrame
Returns:
false

getLauncherTasks

protected LaunchTask[] getLauncherTasks()
Returns all the LaunchTasks to be executed while starting the application. Subclasses may either alter this list or use their custom versions of Task implementations.

Returns:
An array of LaunchTasks containing the following tasks in the specified order:

newDocument

public Document newDocument()
Sublcasses may override it to specify the creation of new documents. This method is not made abstract to avoid unecessary code for non-using classes.

Specified by:
newDocument in class ApplicationFrame
Returns:
null
See Also:
ApplicationFrame.newDocument()

getGraphApplication

protected GraphApplication getGraphApplication()

Returns the GraphApplication.

Returns:
the GraphApplication.

openDocument

public Document openDocument(java.io.InputStream is,
                             java.lang.String name)
Description copied from class: ApplicationFrame
This method is responsible to load a document from a specified input stream.

Specified by:
openDocument in class ApplicationFrame
Parameters:
is - the input stream to load the document from.
name - the name for the loaded document
Returns:
the document that has been read.

saveDocument

public void saveDocument(Document document,
                         java.io.OutputStream os)
Description copied from class: ApplicationFrame
This method is responsible to save a given document to a specified output stream.

Specified by:
saveDocument in class ApplicationFrame
Parameters:
document - the document to save.
os - the OutputStream to save the document to.

openDocument

public Document openDocument(java.io.File file)
Description copied from class: ApplicationFrame
This method is responsible to load a document from a specified file location. Internally calls ApplicationFrame.openDocument(InputStream, String).

Specified by:
openDocument in class ApplicationFrame
Parameters:
file - the location to load the document from.
Returns:
the document that has been read.

getGraphDocumentReader

public GraphDocumentReader getGraphDocumentReader()
Description copied from class: ApplicationFrame
Returns the GraphDocumentReader to use for reading documents.

Specified by:
getGraphDocumentReader in class ApplicationFrame
Returns:
the GraphDocumentReader to use for reading documents.

getGraphDocumentWriter

public GraphDocumentWriter getGraphDocumentWriter()

Returns a GraphDocumentWriter instance

Specified by:
getGraphDocumentWriter in class ApplicationFrame
Returns:
a GraphDocumentWriter instance

saveDocument

public void saveDocument(Document document,
                         java.io.File file)
Description copied from class: ApplicationFrame
This method is responsible to save a given document to a specified file location. Internally calls ApplicationFrame.saveDocument(Document, OutputStream).

Specified by:
saveDocument in class ApplicationFrame
Parameters:
document - the document to save.
file - the location to save the document to.

saveDocument_org

public void saveDocument_org(Document document,
                             java.io.File file)

exit

public boolean exit()
Description copied from class: ApplicationFrame
Cleanup method that is called when the application will be closed to free all resources from the application frame and store all contained documents, etc.

Overrides:
exit in class ApplicationFrame
Returns:
true if the exit was successful, false if the shutdown should be canceled

getAttributeEditorContainer

public AttributeEditorContainer getAttributeEditorContainer()
This method creates and returns the internal instance of SwtAttributeTreeContainer which is currently the only SWT-based implementation of the AttributeEditorContainer interface.

Specified by:
getAttributeEditorContainer in class ApplicationFrame
Returns:
the internal instance of SwtAttributeTreeContainer.
See Also:
com.tensegrity.application.Application#getAttributeEditorContainer()

getLayoutToolsContainer

public LayoutToolsContainer getLayoutToolsContainer()
Description copied from class: ApplicationFrame
Returns the LayoutToolsContainer of this Application or null if no such Container is used.

Specified by:
getLayoutToolsContainer in class ApplicationFrame
Returns:
the LayoutToolsContainer of this Application or null.

getNavigatorContainer

public NavigatorContainer getNavigatorContainer()
Description copied from class: ApplicationFrame
Returns the NavigatorContainer of this Application or null if no such Container is used.

Specified by:
getNavigatorContainer in class ApplicationFrame
Returns:
the NavigatorContainer of this Application or null.

getOutlinerContainer

public OutlinerContainer getOutlinerContainer()
Is intended to return the ObjectTreeContainer of this Application but since there is currently no such component for SWT applications, it returns null.

Specified by:
getOutlinerContainer in class ApplicationFrame
Returns:
null.
See Also:
com.tensegrity.application.Application#getOutlinerContainer()

getRepositoryContainer

public RepositoryContainer getRepositoryContainer()
Creates and returns an instance of SwtRepositoryContainer.

Specified by:
getRepositoryContainer in class ApplicationFrame
Returns:
an instance of SwtRepositoryContainer.
See Also:
com.tensegrity.application.Application#getRepositoryContainer()

getResourceName

public java.lang.String getResourceName()
Deprecated. Use ApplicationFrame.getResourceNames() instead.

Returns the complete name for the resource file. This method returns an empty string. Subclasses may overwrite it, to specify their custom resource file.

Overrides:
getResourceName in class ApplicationFrame
Returns:
an empty String.

dropDocument

public boolean dropDocument(java.io.File file)

applyEvList

public void applyEvList()
Description copied from interface: Evaluable
Tells the component to apply its UIItemEvaluationList.


installEvList

public void installEvList()
Creates a new UIItemEvaluationList

See Also:
Evaluable.installEvList()

setApplicationIcon

protected final void setApplicationIcon()
The method setApplicationIcon sets the image icon at the internal Decorations instance.


getApplicationIconImage

protected org.eclipse.swt.graphics.Image getApplicationIconImage()
Returns null. Subclasses may override this method to specify their own icon. If this method is not specified by a subclass, the frame will use the java standard icon.

Returns:
null.

getSplashScreenImage

protected org.eclipse.swt.graphics.Image getSplashScreenImage()
Returns Tensegrity's default splashscreen image. Subclasses may override this method to specify a custom splashscreen image or to return null if no splashscreen should be displayed, which is typically the case for Eclipse plug-ins.

Returns:
Tensegrity's default splashscreen image.

getToolBars

public ToolBar[] getToolBars()
Description copied from class: ApplicationFrame
Returns the ToolBar instances used within this ApplicationFrame, the default one being at index 0 of the returned array.

Specified by:
getToolBars in class ApplicationFrame
Returns:
array of ToolBar instances used within this ApplicationFrame.

getGraphPanelPopupMenuSource

public JPopupMenuSourceWithUpdateUI getGraphPanelPopupMenuSource()

Returns the local JPopupMenuSourceWithUpdateUI

Specified by:
getGraphPanelPopupMenuSource in class ApplicationFrame
Returns:
the local JPopupMenuSourceWithUpdateUI

setGraphPanelPopupMenuSource

public void setGraphPanelPopupMenuSource(JPopupMenuSourceWithUpdateUI graphPanelPopupMenuSource)

Sets the local JPopupMenuSourceWithUpdateUI

Specified by:
setGraphPanelPopupMenuSource in class ApplicationFrame
Parameters:
graphPanelPopupMenuSource - the JPopupMenuSourceWithUpdateUI to set

getApplet

public Applet getApplet()
Returns null since Applets are not relevant in the SWT-context.

Overrides:
getApplet in class ApplicationFrame
Returns:
null.
See Also:
ApplicationFrame.getApplet()

doValidateDocument

protected boolean doValidateDocument(GraphDocument document)
This method is called, whenever a document is opened. The openDocument(File) method calls this method to allow a validation of the document. Subclasses may override this method to apply a detailed validation process on the given document.

Parameters:
document - the Document instance to validate
Returns:
true to indicate a successful validation, false otherwise.

savePreferences

public void savePreferences()
Saves the currently stored Preferences of this application. This method does nothing if ApplicationFrame.getPreferences() returns null.

Specified by:
savePreferences in class ApplicationFrame

getPreferenceHelper

public SwtPreferenceHelper getPreferenceHelper()
Returns the preference helper of this application.

Returns:
PreferenceHelper

setPreferenceHelper

public void setPreferenceHelper(SwtPreferenceHelper helper)
Sets the preference helper of this application.

Parameters:
helper - the PreferenceHelper to set.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.