com.tensegrity.skeleton.swt.commands
Class SwtNewDocumentCommand

java.lang.Object
  extended bycom.tensegrity.generic.command.BaseCommand
      extended bycom.tensegrity.skeleton.commands.CommonBaseCommand
          extended bycom.tensegrity.skeleton.swt.commands.SwtCommonBaseCommand
              extended bycom.tensegrity.skeleton.swt.commands.SwtNewDocumentCommand
All Implemented Interfaces:
Command

public class SwtNewDocumentCommand
extends SwtCommonBaseCommand

This command, to be used within applications in a SWT context, creates a new GraphDocument and adds it to the MDIComponent. Most of the new GraphDocument configuration is delegated to the application's ApplicationFrame.

Once created, the new GraphDocument is configured through a call to the SwtApplicationFrame.configureNewDocument(Document) method. Also, if a SwtPreferenceHelper can be retrieved from the SwtApplicationFrame the preferred ruler and grid settings are applied on the new GraphDocument.

Overwrite the getDocumentName() method in order to customize the default name of the newly created GraphDocument.

Version:
$Id: SwtNewDocumentCommand.java,v 1.12 2005/08/03 07:43:12 SebastienGuyon Exp $
Author:
S�bastien Guyon

Constructor Summary
SwtNewDocumentCommand(ApplicationFrame applicationFrame, java.lang.String command)
          Creates a new SwtNewDocumentCommand.
 
Method Summary
protected  VisualGraphView createDefaultVisualGraph(GraphController controller)
           Creates and returns a new VisualGraphView given the passed GraphController.
protected  java.lang.String getDocumentName()
           Returns a default document name.
protected  GraphDocument newDocument()
           This routine creates a new VisualGraphView (see newVisualGraphView()) then creates and returns a corresponding GraphDocument.
protected  GraphDocument newDocument(java.lang.String name, GraphController controller, VisualGraphView visualgraphview)
          Creates and returns a new GraphDocument.
protected  GraphDocument newDocument(VisualGraphView visualgraphview)
          This methods creates a new GraphDocument.
protected  VisualGraphView newVisualGraphView()
           This routine creates a new Graph from the GraphModelFactory instance then creates and returns the associated VisualGraphView.
protected  VisualGraphView newVisualGraphView(Graph graph)
           Creates and returns a new VisualGRaphView given the passed Graph.
 void perform(java.lang.Object args)
          This method creates a new Document, configures it (See ApplicationFrame.configureNewDocument(Document)) then adds it to the application MDIComponent.
 
Methods inherited from class com.tensegrity.skeleton.swt.commands.SwtCommonBaseCommand
getGraphApplication, newGraphDocumentFromFactory
 
Methods inherited from class com.tensegrity.skeleton.commands.CommonBaseCommand
getApplicationFrame, getTitle
 
Methods inherited from class com.tensegrity.generic.command.BaseCommand
getDescription, getId, getPerformDescription, isEnabled, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwtNewDocumentCommand

public SwtNewDocumentCommand(ApplicationFrame applicationFrame,
                             java.lang.String command)
Creates a new SwtNewDocumentCommand.

Parameters:
applicationFrame - Application context for this command.
command - the ID of this command.
Method Detail

perform

public void perform(java.lang.Object args)
This method creates a new Document, configures it (See ApplicationFrame.configureNewDocument(Document)) then adds it to the application MDIComponent.

Specified by:
perform in interface Command
Overrides:
perform in class CommonBaseCommand
See Also:
Command.perform(java.lang.Object)

newDocument

protected GraphDocument newDocument()

This routine creates a new VisualGraphView (see newVisualGraphView()) then creates and returns a corresponding GraphDocument.

Returns:
a new GraphDocument

newDocument

protected GraphDocument newDocument(java.lang.String name,
                                    GraphController controller,
                                    VisualGraphView visualgraphview)
Creates and returns a new GraphDocument. This method delegates its call to SwtCommonBaseCommand.newGraphDocumentFromFactory(String, GraphApplication, GraphController, VisualGraphView)

Parameters:
name - the initial name for the document
controller - the GraphController instance that keeps the model.
visualgraphview - the VisualGraphView instance to show in the document.
Returns:
a new GraphDocument

newDocument

protected GraphDocument newDocument(VisualGraphView visualgraphview)
This methods creates a new GraphDocument. The name of the document is retrieved from the getDocumentName() method. This method will invoke the more general newDocument(String, GraphController, VisualGraphView) method.

Parameters:
visualgraphview - the VisualGraphView instance to show in the document.
Returns:
a new GraphDocument

getDocumentName

protected java.lang.String getDocumentName()

Returns a default document name. The name is automatically determined by the current suffix number which is incremented afterwards.

Returns:
a new document name

newVisualGraphView

protected VisualGraphView newVisualGraphView()

This routine creates a new Graph from the GraphModelFactory instance then creates and returns the associated VisualGraphView.

Returns:
a new VisualGraphView

newVisualGraphView

protected VisualGraphView newVisualGraphView(Graph graph)

Creates and returns a new VisualGRaphView given the passed Graph. See createDefaultVisualGraph(GraphController).

Parameters:
graph - a Graph from which the return VisualGraphView is returned.
Returns:
a new VisualGraphView

createDefaultVisualGraph

protected VisualGraphView createDefaultVisualGraph(GraphController controller)

Creates and returns a new VisualGraphView given the passed GraphController. The view is initialized with several default values. For instance, clipping is enabled, select pasted elements is set to true, ports are enabled, loops are allowed, the rule registry is set using the one provided by the SwtApplicationFrame, default edge style and geometry are set.

Parameters:
controller - the GraphController used to create the returned VisualGraphView
Returns:
a new, initialized, VisualGraphView


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