net.sourceforge.spedit.core
Class XMLViewFactory

java.lang.Object
  |
  +--net.sourceforge.spedit.core.XMLViewFactory
All Implemented Interfaces:
ViewFactory

public class XMLViewFactory
extends Object
implements ViewFactory

The XMLViewFactory associates a View to each element of the document. These views can be configured using an XML configuration file, as well as XMLInformation that are created with each element.


Field Summary
protected  Hashtable configs
           
protected  Hashtable elementViews
           
protected  Hashtable stylesheets
           
protected  Hashtable views
           
 
Constructor Summary
XMLViewFactory()
           
 
Method Summary
 View create(Element elt)
          This creates a View object bound to the given Swing element.
 View create(Element elt, String name)
           
 Styleable.StyleSheet createStyleSheet(org.jdom.Element elem)
           
 Object[] createViewInformation(org.jdom.Element elt)
          Returns an array of two objects.
 XMLInformation createXMLInformation(org.jdom.Element elt)
           
protected  void genStyle(Styleable.StyleSheet stylesheet, String prefix, org.jdom.Element elem)
           
 XMLInformation getElementInformation(Element e)
           
 View getElementView(Element e)
           
 void loadConfiguration(String filename)
          Loads an XML configuration file and parses its content, merging it to the current XMLViewFactory.
 void setConfiguration(org.jdom.Element elt)
          Sets the configuration that contains the given element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configs

protected Hashtable configs

stylesheets

protected Hashtable stylesheets

views

protected Hashtable views

elementViews

protected Hashtable elementViews
Constructor Detail

XMLViewFactory

public XMLViewFactory()
Method Detail

create

public View create(Element elt)

This creates a View object bound to the given Swing element. This view is then wrapped around a WrapperView which adds CSS-like visual properties to the embedded views.

When the new wrapper view is created it is registred as representing the given element. This allows to keep the association from elements to views.

Specified by:
create in interface ViewFactory
Parameters:
elt - The element that the view will display.
Returns:
A new wrapped and registered view.
See Also:
getElementView(javax.swing.text.Element)

create

public View create(Element elt,
                   String name)

getElementView

public View getElementView(Element e)

getElementInformation

public XMLInformation getElementInformation(Element e)

loadConfiguration

public void loadConfiguration(String filename)
Loads an XML configuration file and parses its content, merging it to the current XMLViewFactory.

setConfiguration

public void setConfiguration(org.jdom.Element elt)
Sets the configuration that contains the given element. This element must be named Configuration.

createViewInformation

public Object[] createViewInformation(org.jdom.Element elt)
Returns an array of two objects. The first one contains the reference to the view class described by the given JDOM Element, and the second the initialization attributes of this new view class.

createXMLInformation

public XMLInformation createXMLInformation(org.jdom.Element elt)

createStyleSheet

public Styleable.StyleSheet createStyleSheet(org.jdom.Element elem)

genStyle

protected void genStyle(Styleable.StyleSheet stylesheet,
                        String prefix,
                        org.jdom.Element elem)