com.tensegrity.gui.graphdocument.persistence
Class GraphDocumentReader

java.lang.Object
  extended bycom.tensegrity.gui.graphdocument.persistence.GraphDocumentReader
All Implemented Interfaces:
DocumentReader
Direct Known Subclasses:
SwingGraphDocumentReader, SwtGraphDocumentReader

public abstract class GraphDocumentReader
extends java.lang.Object
implements DocumentReader

Base implementation of the DocumentReader interface for reading GraphDocuments.

Version:
$Id: GraphDocumentReader.java,v 1.92 2006/03/02 11:40:57 BurkhardWick Exp $
Author:
BurkhardWick, MKegel

Field Summary
protected  ApplicationFrame appFrame
           
protected  java.util.List conflict_geometrydescriptors
           
protected  java.util.List conflict_geometryitems
           
protected  java.util.List conflict_images
           
protected  java.util.List conflict_layout
           
protected  java.util.List conflict_rules
           
protected  java.util.List conflict_styledescriptornames
           
protected  java.util.List conflict_styledescriptors
           
protected  java.util.List conflict_styleitemnames
           
protected  java.util.List conflict_styleitems
           
protected  GraphDocumentReaderConflictHandler conflictHandler
           
protected  LayoutController defaultLayoutController
           
protected  RuleRegistry defaultRegistry
           
protected  AttributeList geometries
           
protected  AttributeList images
           
protected  AttributeSet layoutConfiguration
           
protected  AttributeList list
           
protected  Frame mainFrame
           
protected  MDIComponent mdiComponent
           
protected  Preferences preferences
           
protected  RepositoryContainer repositoryContainer
           
protected  AttributeList rules
           
protected  boolean showGeometryConflict
           
protected  boolean showImageConflict
           
protected  boolean showLayoutConflict
           
protected  boolean showRulesConflict
           
protected  boolean showStyleNamesConflict
           
protected  boolean showStylesConflict
           
protected  AttributeList styles
           
protected  UIManager uiManager
           
 
Constructor Summary
GraphDocumentReader(ApplicationFrame appFrame, RuleRegistry defaultRegistry, LayoutController defaultLayoutController, GraphDocumentReaderConflictHandler conflictHandler)
          Constructor
GraphDocumentReader(Frame rootFrame, UIManager uiManager, MDIComponent mdiComponent, RepositoryContainer repositoryContainer, Preferences preferences, RuleRegistry defaultRegistry, LayoutController defaultLayoutController, GraphDocumentReaderConflictHandler conflictHandler)
          Constructor.
 
Method Summary
protected  void applyLayoutContext(VisualGraphView vgv, java.lang.String recentNLC, java.lang.String recentELC, int apply_what)
          Whenever a document is loaded, we might need to handle a previously stored LayoutContext.
protected  void configureNewDocument(GraphDocument gd)
          Configures a newly loaded document.
protected  boolean doValidateDocument(GraphDocument document)
          This method is called, whenever a document is opened.
 void enableAddingUnconflictingRules(boolean enable)
          Enables disables the automatic adding of unconflicting rules to the defaults and all open documents
 Attribute getLayoutContextAttribute()
          Reads the LayoutContexts attribute from the internal layoutConfiguration field.
protected  java.lang.String getNewGeometryDescName(java.lang.String oldName)
          Returns the new name for a geometry when the option RENAME_LOADED loaded has been chosen.
protected  java.lang.String getNewGeometryItemName(java.lang.String oldName)
          Returns the new name for a geometry when the option RENAME_LOADED loaded has been chosen.
protected  java.lang.String getNewImageName(java.lang.String oldName)
          Returns the new name for a image when the option RENAME_LOADED loaded has been chosen.
protected  java.lang.String getNewLayoutContextName(java.lang.String oldName)
          Returns the new name for a layout context when the option RENAME_LOADED loaded has been chosen.
protected  java.lang.String getNewRuleName(java.lang.String oldName)
          Returns the new name for a rule when the option RENAME_LOADED loaded has been chosen.
protected  java.lang.String getNewStyleDescName(java.lang.String oldName)
          Returns the new name for a style when the option RENAME_LOADED loaded has been chosen.
protected  java.lang.String getNewStyleItemName(java.lang.String oldName)
          Returns the new name for a style when the option RENAME_LOADED loaded has been chosen.
protected  java.util.List getOpenedVisualGraphViewList()
          Returns the list of all currently used VisualGraphView instances of the currently open documents.
 boolean isAddingUnconflictingRules()
          Returns true, if the reader is adding unconflicting rules to the defaults and open documents
protected  void loadData(GraphDocument graphdocument, java.io.InputStream input)
          Method loadData reads a VisualGraphView from a given file by using the appropriate Builder instances.
protected  VisualGraphView loadVisualGraphView(GraphDocument graphdocument)
          Method openXMLFile reads a VisualGraphView from a given file by using the appropriate Builder instances.
 boolean readDocument(Document doc, java.io.InputStream input)
          Reads data from the input stream to build the contents of the given (empty) document.
protected abstract  void showError(java.lang.String message, java.lang.String title)
          Displays an error message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

appFrame

protected final ApplicationFrame appFrame

uiManager

protected final UIManager uiManager

defaultRegistry

protected final RuleRegistry defaultRegistry

defaultLayoutController

protected LayoutController defaultLayoutController

list

protected AttributeList list

geometries

protected AttributeList geometries

styles

protected AttributeList styles

layoutConfiguration

protected AttributeSet layoutConfiguration

images

protected AttributeList images

rules

protected AttributeList rules

conflict_geometryitems

protected java.util.List conflict_geometryitems

conflict_geometrydescriptors

protected java.util.List conflict_geometrydescriptors

conflict_styleitems

protected java.util.List conflict_styleitems

conflict_styledescriptors

protected java.util.List conflict_styledescriptors

conflict_styleitemnames

protected java.util.List conflict_styleitemnames

conflict_styledescriptornames

protected java.util.List conflict_styledescriptornames

conflict_rules

protected java.util.List conflict_rules

conflict_layout

protected java.util.List conflict_layout

showLayoutConflict

protected boolean showLayoutConflict

showStylesConflict

protected boolean showStylesConflict

showStyleNamesConflict

protected boolean showStyleNamesConflict

showGeometryConflict

protected boolean showGeometryConflict

showRulesConflict

protected boolean showRulesConflict

conflict_images

protected java.util.List conflict_images

showImageConflict

protected boolean showImageConflict

mdiComponent

protected final MDIComponent mdiComponent

repositoryContainer

protected final RepositoryContainer repositoryContainer

preferences

protected final Preferences preferences

mainFrame

protected final Frame mainFrame

conflictHandler

protected final GraphDocumentReaderConflictHandler conflictHandler
Constructor Detail

GraphDocumentReader

public GraphDocumentReader(ApplicationFrame appFrame,
                           RuleRegistry defaultRegistry,
                           LayoutController defaultLayoutController,
                           GraphDocumentReaderConflictHandler conflictHandler)
Constructor

Parameters:
appFrame - The application frame
defaultRegistry - The default rule registry
defaultLayoutController - The default layout controller
conflictHandler - The handler for conflicts that may appear while opening graph documents. Must not be null!

GraphDocumentReader

public GraphDocumentReader(Frame rootFrame,
                           UIManager uiManager,
                           MDIComponent mdiComponent,
                           RepositoryContainer repositoryContainer,
                           Preferences preferences,
                           RuleRegistry defaultRegistry,
                           LayoutController defaultLayoutController,
                           GraphDocumentReaderConflictHandler conflictHandler)
Constructor. Use this constructor if the application has no ApplicationFrame.

Parameters:
rootFrame - The root frame of the gui
uiManager - The UIManager of the application
mdiComponent - The MDIComponent of the gui
repositoryContainer - The RepositoryContainer of the gui
preferences - The Preferences of the application
defaultRegistry - The default rule registry
defaultLayoutController - The default layout controller
conflictHandler - The handler for conflicts that may appear while opening graph documents. Must not be null!
Method Detail

readDocument

public boolean readDocument(Document doc,
                            java.io.InputStream input)
                     throws ReadException,
                            BuildException
Description copied from interface: DocumentReader
Reads data from the input stream to build the contents of the given (empty) document.

Specified by:
readDocument in interface DocumentReader
Parameters:
doc - The document to build
input - The input stream containing the data
Returns:
true, if loading was successful
Throws:
ReadException - this is thrown if reading the data from the input stream failed
BuildException - this is thrown if building the document from the data failed

getLayoutContextAttribute

public Attribute getLayoutContextAttribute()
Reads the LayoutContexts attribute from the internal layoutConfiguration field. If the LayoutContexts could be found, the first value from the resulting AttributeSet is returned.

Returns:
an Attribute containing the LayoutContextAttribute or null.

doValidateDocument

protected boolean doValidateDocument(GraphDocument document)
This method is called, whenever a document is opened. The readDocument(Document, InputStream) 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.

configureNewDocument

protected void configureNewDocument(GraphDocument gd)
Configures a newly loaded document. Usually sets the layout controller, etc.

Parameters:
gd - The GraphDocument to configure

loadData

protected final void loadData(GraphDocument graphdocument,
                              java.io.InputStream input)
                       throws ReadException,
                              BuildException
Method loadData reads a VisualGraphView from a given file by using the appropriate Builder instances.

Parameters:
graphdocument -
input -
Throws:
ReadException
BuildException

loadVisualGraphView

protected final VisualGraphView loadVisualGraphView(GraphDocument graphdocument)
                                             throws BuildException
Method openXMLFile reads a VisualGraphView from a given file by using the appropriate Builder instances.

Parameters:
graphdocument -
Returns:
VisualGraphView
Throws:
java.lang.Exception
BuildException

applyLayoutContext

protected void applyLayoutContext(VisualGraphView vgv,
                                  java.lang.String recentNLC,
                                  java.lang.String recentELC,
                                  int apply_what)
Whenever a document is loaded, we might need to handle a previously stored LayoutContext. This method compares the parameters of the context with existing contexts of the given VisualGraphView.

Parameters:
vgv -
recentNLC -
recentELC -
apply_what -

getOpenedVisualGraphViewList

protected final java.util.List getOpenedVisualGraphViewList()
Returns the list of all currently used VisualGraphView instances of the currently open documents.

Returns:
List of VisualGraphView instances.

enableAddingUnconflictingRules

public final void enableAddingUnconflictingRules(boolean enable)
Enables disables the automatic adding of unconflicting rules to the defaults and all open documents

Parameters:
enable - True to enable

isAddingUnconflictingRules

public final boolean isAddingUnconflictingRules()
Returns true, if the reader is adding unconflicting rules to the defaults and open documents

Returns:
true, if the reader is adding unconflicting rules to the defaults and open documents

getNewLayoutContextName

protected final java.lang.String getNewLayoutContextName(java.lang.String oldName)
Returns the new name for a layout context when the option RENAME_LOADED loaded has been chosen.

Parameters:
oldName - The old name of the layout context that had a conflict
Returns:
The new name for the layout conflict

getNewStyleDescName

protected final java.lang.String getNewStyleDescName(java.lang.String oldName)
Returns the new name for a style when the option RENAME_LOADED loaded has been chosen.

Parameters:
oldName - The old name of the style that had a conflict
Returns:
The new name for the style

getNewStyleItemName

protected final java.lang.String getNewStyleItemName(java.lang.String oldName)
Returns the new name for a style when the option RENAME_LOADED loaded has been chosen.

Parameters:
oldName - The old name of the style that had a conflict
Returns:
The new name for the style

getNewGeometryDescName

protected final java.lang.String getNewGeometryDescName(java.lang.String oldName)
Returns the new name for a geometry when the option RENAME_LOADED loaded has been chosen.

Parameters:
oldName - The old name of the geometry that had a conflict
Returns:
The new name for the geometry

getNewGeometryItemName

protected final java.lang.String getNewGeometryItemName(java.lang.String oldName)
Returns the new name for a geometry when the option RENAME_LOADED loaded has been chosen.

Parameters:
oldName - The old name of the geometry that had a conflict
Returns:
The new name for the geometry

getNewRuleName

protected final java.lang.String getNewRuleName(java.lang.String oldName)
Returns the new name for a rule when the option RENAME_LOADED loaded has been chosen.

Parameters:
oldName - The old name of the rule that had a conflict
Returns:
The new name for the rule

getNewImageName

protected final java.lang.String getNewImageName(java.lang.String oldName)
Returns the new name for a image when the option RENAME_LOADED loaded has been chosen.

Parameters:
oldName - The old name of the image that had a conflict
Returns:
The new name for the image conflict

showError

protected abstract void showError(java.lang.String message,
                                  java.lang.String title)
Displays an error message

Parameters:
message - The message to display
title - The title of the dialog to display


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