wxtpages
Class unitPage

java.lang.Object
  extended byjavax.swing.tree.DefaultMutableTreeNode
      extended bywxtpages.unit
          extended bywxtpages.unitPage
All Implemented Interfaces:
java.lang.Cloneable, javax.swing.tree.MutableTreeNode, java.io.Serializable, javax.swing.tree.TreeNode

public class unitPage
extends unit

Instances of unitPage holds the structure that merges a template and a series of content units. Each instance of unitPage matches a page element in the script.

See Also:
Serialized Form

Field Summary
protected  java.util.Vector m_allURIs
          All contributing URIs, including direct imports, template and all content.
protected  java.util.Vector m_contentFileIndex
          Index for this pages content objects
protected  boolean m_keepDOM
          Flag to keep DOMstructure after build, ready for second phase
protected  int m_pageNo
          number of this page, counted preorderwise within group
protected  java.lang.String m_templateID
          The ID for this page's one and only template
 
Fields inherited from class wxtpages.unit
CONTENT_TYPE, DBCONTENT_TYPE, GROUP_TYPE, m_absoluteUri, m_description, m_Doc, m_GroupMaster, m_lastTimeUsed, m_myElement, m_name, m_optionMap, m_originalUri, m_parameterMap, m_propertyMap, m_txtContent, m_type, PAGE_TYPE, TEMPLATE_TYPE, TEXTCONTENT_TYPE, TRANSFORMATION_TYPE, UNIT_TYPE
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
unitPage(unitGroup master, org.w3c.dom.Element elt, int pno)
          Creates a new instance of unitPage.
 
Method Summary
 void appendToAddresses(java.net.URI theUri)
          Append an URI to this page's list of all contributing URIs template, direct imports, content, groupanchor Used for recalculation of addresses
protected  void assembleAllContent()
          Assemble all content, all types in the order they have been spesified We are only interested in imports that have noe URI, that is they are part of the structure as given in the script
 boolean atleastOneComponentChanged()
          Try to find out if any of the components are updated from an other program since the last build.
 boolean build()
          Build this page
protected  void buildSecondPhase()
          Build second phase.
protected  org.w3c.dom.DocumentFragment collectFromPages(command cmd)
          Collect from a lot of pages which may be distributed on more groups.
 void collectFromScript()
          Pick up data from script Attributes: name location templateid transformationid Children: description content textcontent dbcontent thumb properties options
 void displayProperties(javax.swing.JFrame dialogOwner)
          Show the properties of this unitPage in a dialog box
protected  void fetchResources()
          Fetch resources referenced by the addressing mechanism with http-addresses.
 java.net.URI getAbsoluteThumbUri()
          Get the absolute URI for the thumb of this page, if any
 java.util.Vector getAllAddresses()
          Get all URI's that contribute to this apge template, direct imports, content, groupanchor Used for recalculation of addresses
 java.util.Vector getContentListAsStrings()
          Get the URI's of all content units of this page
 int getPageNo()
          Get the page number within the group, counted preorderwise.
 java.lang.String getPageNoAsString()
          Get the page number as string, counted preorderwise.
protected  java.util.Vector getPageTocEntries(org.w3c.dom.Node theN, int lo, int max, java.lang.String header)
          Find all entries of a given level below the given node
 unitTemplate getTemplate()
          Get the template for this page
 java.lang.String getTemplateID()
          Get the id for this pages template
 java.lang.String getTemplateURIAsString()
          Get the absolute URI of template for this page as a String
 boolean isSameAs(unitPage u)
          Comparing this unitPage to another unitPage, equality in the sense that they have the same absolute location
 void killDocument()
          Take this page down: Release all involved components
protected  org.w3c.dom.DocumentFragment makeMenuToc(command cmd)
          Produce a menu toc, typically left column toc Following are optional parameters in command: cols: number of columns, default 1 left: string to the left of each entry, default is the empty string right: string to the right of each entry, default is the empty string divider: string between each entry, default is the empty string
protected  java.util.Vector makePageListByDirectNaming(java.lang.String pages)
          Find a list of pages based on a string naming those pages An alternative to picking pages by an xpath on the script, See scripthandler::makePagelistByXPath
protected  org.w3c.dom.DocumentFragment makePageRef(command cmd)
          Make a reference to another page in the group.
protected  org.w3c.dom.DocumentFragment makePageToc(command cmd)
          Make a toc for this page This function does not exercise any intelligent as to where in the logical (as seen from the author) structure of the page the toc is based.
protected  org.w3c.dom.DocumentFragment makePopup(command cmd)
          Make a call to a javascript which pops a page in a separate window Relies on the existance of a javascript Expect to find in command parameter: uri: name of the file to show text: the text in the reference style: the style to set for the fragment image: alternative to text popname: the name of the window that pops Only file is mandatory
protected  org.w3c.dom.DocumentFragment makeSimpleToc(command cmd)
          Produce a simple toc, children or siblings Following are optional parameters in command: cols: number of columns, default 0 left: string to the left of each entry, default is "[" right: string to the right of each entry, default is "]" divider: string between each entry, default the empty string
protected  org.w3c.dom.DocumentFragment makeTotalGroupToc(command cmd)
          Produce a total toc for the entire group Following are optional parameters in command: cols: number of columns, default 1 left: string to the left of each entry, default is the empty string right: string to the right of each entry, default is the empty string divider: string between each entry, default is the empty string lo: lowest pagelevel to take into account, default is 1 hi: highest pagelevel to take into account, default is highest level defined
protected  org.w3c.dom.DocumentFragment makeTrailToc(command cmd)
          Produce a trail, that is references to all ancestors and home Following are optional parameters in command: cols: number of columns, default 0 left: string to the left of each entry, default is the empty string right: string to the right of each entry, default is the empty string divider: string between each entry, default is ">"
 boolean prepare(unit p, java.lang.String theCommonName, java.lang.String theCommonValue)
          Prepare this unitPage with imports from non-content files.
protected  org.w3c.dom.DocumentFragment publishToc(java.util.Vector refList, int cols, java.lang.String leftpar, java.lang.String rightpar, java.lang.String divider)
          Produce a DocumentFragment for a general toc
protected  void removeNodes(org.w3c.dom.Node theN, java.lang.String xp)
          Remove all nodes identifed by an xpath in a fragment
 javax.swing.JPopupMenu setUpPopMenu(javax.swing.JPopupMenu theMenu, javax.swing.JFrame main)
          Set up a popupMenu for this unitPage.
 java.lang.String toString()
          Let the page be identified with name as string
 
Methods inherited from class wxtpages.unit
addTransformationParameters, browseUnit, calculateAbsoluteAddress, controlLinks, correctAllAddressingInDocument, correctAllAddressingInFragment, correctOneCommonLink, correctStyleAttributes, correctStyleElements, correctStyleString, editUnit, establishDom, getAbsoluteUri, getAbsoluteUriAsString, getAsText, getDescription, getDoc, getDocCopy, getEncoding, getFileName, getName, getNodeList, getOption, getOptions, getOriginalAsString, getOriginalUri, getProperties, getReporter, getTransformation, getTransformationAsString, getTransformationID, getTransformationParameterMap, getType, getURItoAsString, isSameAs, isUpdatedAfterUse, loadAsText, makeComment, makeImageRefToPage, makeRefToPage, saveFromDOM, setEncoding, setNowAsLastTimeUsed, setReporter, setTransformationFromString, setTransformationId
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_templateID

protected java.lang.String m_templateID
The ID for this page's one and only template


m_contentFileIndex

protected java.util.Vector m_contentFileIndex
Index for this pages content objects


m_pageNo

protected int m_pageNo
number of this page, counted preorderwise within group


m_allURIs

protected java.util.Vector m_allURIs
All contributing URIs, including direct imports, template and all content. Used in addresscalculations


m_keepDOM

protected boolean m_keepDOM
Flag to keep DOMstructure after build, ready for second phase

Constructor Detail

unitPage

public unitPage(unitGroup master,
                org.w3c.dom.Element elt,
                int pno)
         throws java.lang.Exception
Creates a new instance of unitPage. Note that this does not involve opening template or contentfiles. This are done when we start building, build

Parameters:
master - The unitGroup object that owns this page
elt - The element in the script that defines this page
pno - The number of the page in a preorder traversal
Throws:
java.lang.Exception - When something goes wrong in establishing the structure for this page
Method Detail

isSameAs

public boolean isSameAs(unitPage u)
Comparing this unitPage to another unitPage, equality in the sense that they have the same absolute location

Parameters:
u - The unitPage we will compare to
Returns:
true if absolute URI is the same, false otherwise

appendToAddresses

public void appendToAddresses(java.net.URI theUri)
Append an URI to this page's list of all contributing URIs template, direct imports, content, groupanchor Used for recalculation of addresses

Parameters:
theUri - The URI we append

getAllAddresses

public java.util.Vector getAllAddresses()
Get all URI's that contribute to this apge template, direct imports, content, groupanchor Used for recalculation of addresses

Returns:
A Vector with all the URI's

getAbsoluteThumbUri

public java.net.URI getAbsoluteThumbUri()
Get the absolute URI for the thumb of this page, if any

Returns:
The URI if a thumb exists, null otherwise

collectFromScript

public void collectFromScript()
                       throws java.lang.Exception
Pick up data from script Attributes: name location templateid transformationid Children: description content textcontent dbcontent thumb properties options

Throws:
java.lang.Exception - when we have problems finding a location

killDocument

public void killDocument()
Take this page down: Release all involved components

Overrides:
killDocument in class unit

getTemplateID

public java.lang.String getTemplateID()
Get the id for this pages template

Returns:
The id of the template that is used to build this page, m_templateID

getTemplate

public unitTemplate getTemplate()
Get the template for this page

Returns:
The template object found

getTemplateURIAsString

public java.lang.String getTemplateURIAsString()
Get the absolute URI of template for this page as a String

Returns:
The found URI of the template as string

getContentListAsStrings

public java.util.Vector getContentListAsStrings()
Get the URI's of all content units of this page

Returns:
The absolute URIs as a Vector of Strings

getPageNo

public int getPageNo()
Get the page number within the group, counted preorderwise. Sequence as in script

Returns:
The page number, m_pageNo

getPageNoAsString

public java.lang.String getPageNoAsString()
Get the page number as string, counted preorderwise. As string for convenience.

Returns:
The pageno as a string

toString

public java.lang.String toString()
Let the page be identified with name as string

Overrides:
toString in class unit
Returns:
The pagename, m_name

displayProperties

public void displayProperties(javax.swing.JFrame dialogOwner)
Show the properties of this unitPage in a dialog box

Overrides:
displayProperties in class unit
Parameters:
dialogOwner - The frame that will own this dialog.

setUpPopMenu

public javax.swing.JPopupMenu setUpPopMenu(javax.swing.JPopupMenu theMenu,
                                           javax.swing.JFrame main)
Set up a popupMenu for this unitPage. Will offer user options to edit, browse or inspect properties, all depending on available programs.

Overrides:
setUpPopMenu in class unit
Parameters:
theMenu - The menu we will prepare
main - The frame that owns the menu
Returns:
A popupMenu customized for this page

atleastOneComponentChanged

public boolean atleastOneComponentChanged()
Try to find out if any of the components are updated from an other program since the last build. Only template, content and transformation objects are checked. Not possible imports of other type directly from PI's

Returns:
true if at least one component has changed, false otherwise

build

public boolean build()
Build this page

Overrides:
build in class unit
Returns:
true if we have success building the page at all, false otherwise

buildSecondPhase

protected void buildSecondPhase()
Build second phase. Collections, indexes and final tocs.


assembleAllContent

protected void assembleAllContent()
Assemble all content, all types in the order they have been spesified We are only interested in imports that have noe URI, that is they are part of the structure as given in the script


fetchResources

protected void fetchResources()
Fetch resources referenced by the addressing mechanism with http-addresses. Only images at the moment. If we have images referenced by the addressing mechanism that have an absolute URI of type HTTP, they will be copied the to a local catalog and have their addresses changed accordingly


makePopup

protected org.w3c.dom.DocumentFragment makePopup(command cmd)
Make a call to a javascript which pops a page in a separate window Relies on the existance of a javascript

Expect to find in command parameter: uri: name of the file to show text: the text in the reference style: the style to set for the fragment image: alternative to text popname: the name of the window that pops Only file is mandatory

Parameters:
cmd - An instance of type command that describes what we want to do
Returns:
a DocumentFragment that contains the necessary XHTML-code

makePageRef

protected org.w3c.dom.DocumentFragment makePageRef(command cmd)
Make a reference to another page in the group.

Expect to find in command parameter: pageid: name or location for the page to refer to, with or without groupname prefix text: the text in the reference image: the image in the ref

text and image may be omitted

Parameters:
cmd - An instance of type command that describes what we want to do
Returns:
a DocumentFragment that contains the reference

makeMenuToc

protected org.w3c.dom.DocumentFragment makeMenuToc(command cmd)
                                            throws java.lang.Exception
Produce a menu toc, typically left column toc

Following are optional parameters in command: cols: number of columns, default 1 left: string to the left of each entry, default is the empty string right: string to the right of each entry, default is the empty string divider: string between each entry, default is the empty string

Parameters:
cmd - An instance of type command that describes what we want to do
Returns:
A fragment containing the toc
Throws:
java.lang.Exception - When we have problems with DOM

makeTotalGroupToc

protected org.w3c.dom.DocumentFragment makeTotalGroupToc(command cmd)
                                                  throws java.lang.Exception
Produce a total toc for the entire group

Following are optional parameters in command: cols: number of columns, default 1 left: string to the left of each entry, default is the empty string right: string to the right of each entry, default is the empty string divider: string between each entry, default is the empty string lo: lowest pagelevel to take into account, default is 1 hi: highest pagelevel to take into account, default is highest level defined

Parameters:
cmd - An instance of type command thatdescribes what we want to do
Returns:
A DocumentFragment containing the toc
Throws:
java.lang.Exception - When we cannot make the table of content

makeTrailToc

protected org.w3c.dom.DocumentFragment makeTrailToc(command cmd)
                                             throws java.lang.Exception
Produce a trail, that is references to all ancestors and home

Following are optional parameters in command: cols: number of columns, default 0 left: string to the left of each entry, default is the empty string right: string to the right of each entry, default is the empty string divider: string between each entry, default is ">"

Parameters:
cmd - An instance of type command thatdescribes what we want to do
Returns:
A fragment containing the toc
Throws:
java.lang.Exception - When we cannot make the table of content

makeSimpleToc

protected org.w3c.dom.DocumentFragment makeSimpleToc(command cmd)
                                              throws java.lang.Exception
Produce a simple toc, children or siblings

Following are optional parameters in command: cols: number of columns, default 0 left: string to the left of each entry, default is "[" right: string to the right of each entry, default is "]" divider: string between each entry, default the empty string

Parameters:
cmd - An instance of type command thatdescribes what we want to do
Returns:
A DocumentFragment containing the toc
Throws:
java.lang.Exception - When we cannot make the table of content

makePageToc

protected org.w3c.dom.DocumentFragment makePageToc(command cmd)
                                            throws java.lang.Exception
Make a toc for this page

This function does not exercise any intelligent as to where in the logical (as seen from the author) structure of the page the toc is based. Local, distributed, tocs are thus not supported.

Following are optional parameters in command: cols: number of columns, default 1 left: string to the left of each entry, default is the empty string right: string to the right of each entry, default is the empty string divider: string between each entry, default is the empty string lo: lowest heading level to take into account, default is 1 hi: highest heading level to take into account, default is 3 header: the style of the heading elements, default is "h"

Parameters:
cmd - An instance of type command thatdescribes what we want to do
Returns:
a DocumentFragment containing the toc
Throws:
java.lang.Exception - When we cannot make the table of content

getPageTocEntries

protected java.util.Vector getPageTocEntries(org.w3c.dom.Node theN,
                                             int lo,
                                             int max,
                                             java.lang.String header)
Find all entries of a given level below the given node

Parameters:
theN - A node which definins the subtree
header - What we are looking for here, typically h
lo - The lower version, typically 1
max - The high version, typically 3
Returns:
The list of entries we are building

publishToc

protected org.w3c.dom.DocumentFragment publishToc(java.util.Vector refList,
                                                  int cols,
                                                  java.lang.String leftpar,
                                                  java.lang.String rightpar,
                                                  java.lang.String divider)
                                           throws java.lang.Exception
Produce a DocumentFragment for a general toc

Parameters:
refList - The references to display, tocEntry
cols - The number of columns we want
leftpar - The string we want to display left of each entry
rightpar - The he string we want to display right of each entry
divider - The string we want to display between each entry
Returns:
A DocumentFragment with the complete toc within it
Throws:
java.lang.Exception - When we cannot format the table of content

collectFromPages

protected org.w3c.dom.DocumentFragment collectFromPages(command cmd)
Collect from a lot of pages which may be distributed on more groups.

The command is supposed to have parameter: pages: a commasepareted list of pagedids xpath: what to select from each page

A pageid may be a pagename or part of a pagepath. A pageid may be prefixed with: groupname#, to allow collections from other groups. A pageid may be suffixed with +, indicating this page and all children of this page

Parameters:
cmd - The command that describes the collection
Returns:
A Documentfragment holding copies of the collected items as children

makePageListByDirectNaming

protected java.util.Vector makePageListByDirectNaming(java.lang.String pages)
Find a list of pages based on a string naming those pages An alternative to picking pages by an xpath on the script, See scripthandler::makePagelistByXPath

Parameters:
pages - The string holding the pages
Returns:
a Vector with selected pages

removeNodes

protected void removeNodes(org.w3c.dom.Node theN,
                           java.lang.String xp)
Remove all nodes identifed by an xpath in a fragment

Parameters:
xp - An xpath-expression that identifies the nodes to remove
theN - The node defining the fragment

prepare

public boolean prepare(unit p,
                       java.lang.String theCommonName,
                       java.lang.String theCommonValue)
Prepare this unitPage with imports from non-content files. Does necessary address calculations Calls supers (unit) prepare

Overrides:
prepare in class unit
Parameters:
p - The unit that will use this unit as content, may not be null but may be this unitPage
theCommonName - The name used for common resources in the material
theCommonValue - The value that we will use
Returns:
false if a fatal error occurs during preparation, true otherwise