treebolic.generator
Class Controller

java.lang.Object
  extended by treebolic.generator.Controller
All Implemented Interfaces:
PickListener, java.util.EventListener, javax.swing.event.CellEditorListener, javax.swing.event.ChangeListener, javax.swing.event.HyperlinkListener, IContext, IProviderContext

public class Controller
extends java.lang.Object
implements IContext, IProviderContext, PickListener, javax.swing.event.ChangeListener, javax.swing.event.CellEditorListener, javax.swing.event.HyperlinkListener

Controller

Author:
Bernard Bou

Nested Class Summary
static class Controller.Code
          Command code
static class Controller.Mode
          Command code
 
Field Summary
private  java.lang.String[] theArgs
          Command line arguments
private  org.w3c.dom.Document theDocument
          Document
private  DomTreeView theDomTreeView
          Dom tree view
private  javax.swing.JFrame theFrame
          Frame
private  java.util.Map<java.lang.String,MutableNode> theIdToNodeMap
          Id to node map
private  Controller.Mode theMode
          Document mode
 Model theModel
          Treebolic model
private  PropertyView thePropertyView
           
private  int theSelectedTabIndex
          Tabbed pane selection index
private  java.util.Properties theSettings
          Settings
private  javax.swing.JTabbedPane theTabbedPane
          Tabbed pane
private  TextView theTextView
          Text view
 javax.swing.tree.TreeModel theTreeModel
          Tree model
private  TreeView theTreeView
          Tree view
 java.util.Map<java.awt.Component,java.lang.Runnable> theUpdateMap
          Map component to update action
private  java.net.URL theUrl
          Document url
private  IWidget theWidget
          Treebolic widget
static boolean validate
          XML validate
 
Constructor Summary
Controller(java.lang.String[] theseArgs)
          Constructor
 
Method Summary
private  void about()
          About
private  java.lang.String ask(java.lang.String thisMessage, java.lang.String thisInitial)
          Ask
private  void base()
          Get base
private  void checkSave()
          Check if save is needed
private  boolean confirm(java.lang.String[] thisMessage)
          Confirm
 void connect(DomTreeView thisDomTreeView)
          Connect to Dom tree view
 void connect(IWidget thisWidget)
          Connect to widget
 void connect(javax.swing.JFrame thisFrame)
          Connect to frame
 void connect(javax.swing.JTabbedPane thisTabbedPane)
          Connect to tabbed pane
 void connect(PropertyView thisPropertyView)
          Connect to property view
 void connect(TextView thisTextView)
          Connect to text view
 void connect(TreeView thisTreeView)
          Connect to tree view
 void dtd()
          Get Dtd
 void editingCanceled(javax.swing.event.ChangeEvent thisEvent)
           
 void editingStopped(javax.swing.event.ChangeEvent thisEvent)
           
 void execute(Controller.Code thisCode, int thisValue)
           
 void exit()
          Exit hook
private  void exportDocument()
          Export document
private  void exportSettings()
          Export settings
 java.net.URL getBase()
          Get base URL
private static java.io.File getFile(java.lang.String thisUrlString)
          Get file from Url
private static java.io.File getFile(java.net.URL thisUrl)
          Get file from Url
 java.net.URL getHtmlDocumentBase()
          Get embedding HTML document base URL
 java.awt.Image getImage(java.net.URL thisURL)
          Get image
 java.net.URL getImagesBase()
          Get images base URL
 Model getModel()
          Get model
 java.lang.String getParameter(java.lang.String thisName)
          Get parameter
private  void help()
          Help
 void hyperlinkUpdate(javax.swing.event.HyperlinkEvent thisEvent)
           
private  void importProvider()
          Import document from provider
private  void importXsl()
          Import document through Xsl
 boolean linkTo(java.lang.String thisLinkUrl, java.lang.String thisUrlTarget)
          Navigate to link
private  void listIds()
          List mounts
private  void listImages()
          List images
private  void listLinks()
          List links
private  void listMounts()
          List mounts
private  java.net.URL makeBasedURL(java.lang.String thisSubPath, java.lang.String thisFilename)
          Make based Url
private  org.w3c.dom.Document makeDocument(Model thisModel)
          Make document
protected  org.xml.sax.EntityResolver makeEntityResolver()
          Make entity resolver (for validation)
private  HtmlView makeHtmlView(Controller thisController)
          Make the Html view
 java.net.URL makeImageRepositoryURL()
          Make image repository Url
private  IProvider makeProvider(java.lang.String thisProviderName)
          Make provider
private  void makeSite()
          Make site
private  TextView makeTextView()
          Make the text view
 java.net.URL makeURL(java.lang.String thisSource)
          Make Url
private  void newDocument()
          New command
private  void newElement()
          New element
private  void normalizeIds()
          Normalize ids
private  void open()
          Open
 void open(java.lang.String thisUrlString)
          Open Url string
private  void open(java.net.URL thisUrl)
          Open Url
private  void openUrl()
          Open Http
private  void optionFocusParent()
          Toggle focus parent behaviour in tree view
private  void optionTreebolicRenderer()
          Toggle treebolic rendering in Dom tree view
private  void optionValidateXml()
          Toggle XML validation
 void picked(java.lang.Object thisObject)
          Pick event listener
 void putMessage(java.lang.String thisString)
          Put status string (such as error)
 void putProgress(java.lang.String thisString, boolean thisFail)
          Put progress
private  void removeElement()
          Remove element
private  void runSite()
          Run site
private  void save()
          Save
private  void save(java.io.File thisFile)
          Save as file
private  void saveAs()
          Save as
private  void select(java.lang.String thisClassName)
          Select tree node
private  void setDocument(org.w3c.dom.Document thisDocument, java.net.URL thisURL)
          Set document
private  void setModel(Model thisModel, java.util.Map<java.lang.String,MutableNode> thisIdToNodeMap)
          Set model
private  void settings()
          Persist
 void showStatus(java.lang.String thisString)
          Show status
 void stateChanged(javax.swing.event.ChangeEvent thisEvent)
           
 void transformToFile(java.lang.String thisExportUrl, java.lang.String thisXsltUrlString, java.lang.String thisOutputFileUrl)
          Transform to file
 void transformToView(java.lang.String thisExportUrl, java.lang.String thisXsltUrlString)
          Transform to view
 void update(Controller.Mode thisMode)
          Update
 void updateDom()
          Update Dom view
 void updateText()
          Update xml text view
 void updateTree()
          Update tree view
 void updateView()
          Update current view
 void updateWidget()
          Update widget view
private  void url()
          Get Url
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theWidget

private IWidget theWidget
Treebolic widget


theModel

public Model theModel
Treebolic model


theIdToNodeMap

private java.util.Map<java.lang.String,MutableNode> theIdToNodeMap
Id to node map


theDocument

private org.w3c.dom.Document theDocument
Document


theUrl

private java.net.URL theUrl
Document url


theMode

private Controller.Mode theMode
Document mode


validate

public static boolean validate
XML validate


theTreeModel

public javax.swing.tree.TreeModel theTreeModel
Tree model


theTreeView

private TreeView theTreeView
Tree view


thePropertyView

private PropertyView thePropertyView

theTextView

private TextView theTextView
Text view


theDomTreeView

private DomTreeView theDomTreeView
Dom tree view


theFrame

private javax.swing.JFrame theFrame
Frame


theTabbedPane

private javax.swing.JTabbedPane theTabbedPane
Tabbed pane


theSelectedTabIndex

private int theSelectedTabIndex
Tabbed pane selection index


theArgs

private java.lang.String[] theArgs
Command line arguments


theUpdateMap

public java.util.Map<java.awt.Component,java.lang.Runnable> theUpdateMap
Map component to update action


theSettings

private java.util.Properties theSettings
Settings

Constructor Detail

Controller

public Controller(java.lang.String[] theseArgs)
Constructor

Parameters:
theseArgs - command line arguments
Method Detail

connect

public void connect(javax.swing.JFrame thisFrame)
Connect to frame

Parameters:
thisFrame - frame

connect

public void connect(TreeView thisTreeView)
Connect to tree view

Parameters:
thisTreeView - treeview

connect

public void connect(PropertyView thisPropertyView)
Connect to property view

Parameters:
thisPropertyView - property view

connect

public void connect(TextView thisTextView)
Connect to text view

Parameters:
thisTextView - text view

connect

public void connect(DomTreeView thisDomTreeView)
Connect to Dom tree view

Parameters:
thisDomTreeView - DOM tree view

connect

public void connect(IWidget thisWidget)
Connect to widget

Parameters:
thisWidget - widget

connect

public void connect(javax.swing.JTabbedPane thisTabbedPane)
Connect to tabbed pane

Parameters:
thisTabbedPane - tabbed pane

makeDocument

private org.w3c.dom.Document makeDocument(Model thisModel)
Make document

Returns:
document

setDocument

private void setDocument(org.w3c.dom.Document thisDocument,
                         java.net.URL thisURL)
Set document

Parameters:
thisDocument - document
thisURL - url

getModel

public Model getModel()
Get model

Returns:
model

setModel

private void setModel(Model thisModel,
                      java.util.Map<java.lang.String,MutableNode> thisIdToNodeMap)
Set model

Parameters:
thisModel - model
thisIdToNodeMap - id to node map

picked

public void picked(java.lang.Object thisObject)
Description copied from interface: PickListener
Pick event listener

Specified by:
picked in interface PickListener
Parameters:
thisObject - parameter

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent thisEvent)
Specified by:
stateChanged in interface javax.swing.event.ChangeListener

editingStopped

public void editingStopped(javax.swing.event.ChangeEvent thisEvent)
Specified by:
editingStopped in interface javax.swing.event.CellEditorListener

editingCanceled

public void editingCanceled(javax.swing.event.ChangeEvent thisEvent)
Specified by:
editingCanceled in interface javax.swing.event.CellEditorListener

hyperlinkUpdate

public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent thisEvent)
Specified by:
hyperlinkUpdate in interface javax.swing.event.HyperlinkListener

execute

public void execute(Controller.Code thisCode,
                    int thisValue)

exit

public void exit()
Exit hook


newDocument

private void newDocument()
New command


open

private void open()
Open


openUrl

private void openUrl()
Open Http


open

public void open(java.lang.String thisUrlString)
Open Url string

Parameters:
thisUrlString - Url string

open

private void open(java.net.URL thisUrl)
Open Url

Parameters:
thisUrl - Url

makeEntityResolver

protected org.xml.sax.EntityResolver makeEntityResolver()
Make entity resolver (for validation)

Returns:
treebolic entity resolver

getFile

private static java.io.File getFile(java.net.URL thisUrl)
Get file from Url

Parameters:
thisUrl - Url
Returns:
file

getFile

private static java.io.File getFile(java.lang.String thisUrlString)
Get file from Url

Parameters:
thisUrlString - url string
Returns:
file

save

private void save()
Save


saveAs

private void saveAs()
Save as


save

private void save(java.io.File thisFile)
Save as file

Parameters:
thisFile - file

checkSave

private void checkSave()
Check if save is needed


importXsl

private void importXsl()
Import document through Xsl


importProvider

private void importProvider()
Import document from provider


exportDocument

private void exportDocument()
Export document


exportSettings

private void exportSettings()
Export settings


newElement

private void newElement()
New element


removeElement

private void removeElement()
Remove element


normalizeIds

private void normalizeIds()
Normalize ids


listImages

private void listImages()
List images


listLinks

private void listLinks()
List links


listMounts

private void listMounts()
List mounts


listIds

private void listIds()
List mounts


dtd

public void dtd()
Get Dtd


optionTreebolicRenderer

private void optionTreebolicRenderer()
Toggle treebolic rendering in Dom tree view


optionValidateXml

private void optionValidateXml()
Toggle XML validation


optionFocusParent

private void optionFocusParent()
Toggle focus parent behaviour in tree view


transformToView

public void transformToView(java.lang.String thisExportUrl,
                            java.lang.String thisXsltUrlString)
Transform to view


transformToFile

public void transformToFile(java.lang.String thisExportUrl,
                            java.lang.String thisXsltUrlString,
                            java.lang.String thisOutputFileUrl)
Transform to file


makeSite

private void makeSite()
Make site


runSite

private void runSite()
Run site


settings

private void settings()
Persist


base

private void base()
Get base


url

private void url()
Get Url


help

private void help()
Help


about

private void about()
About


confirm

private boolean confirm(java.lang.String[] thisMessage)
Confirm

Parameters:
thisMessage - message
Returns:
true if confirmed

ask

private java.lang.String ask(java.lang.String thisMessage,
                             java.lang.String thisInitial)
Ask

Parameters:
thisMessage - message
Returns:
input

select

private void select(java.lang.String thisClassName)
Select tree node

Parameters:
thisClassName - class name of tree node to select

update

public void update(Controller.Mode thisMode)
Update

Parameters:
thisMode - mode

updateView

public void updateView()
Update current view


updateTree

public void updateTree()
Update tree view


updateWidget

public void updateWidget()
Update widget view


updateText

public void updateText()
Update xml text view


updateDom

public void updateDom()
Update Dom view


makeHtmlView

private HtmlView makeHtmlView(Controller thisController)
Make the Html view

Returns:
Html view

makeTextView

private TextView makeTextView()
Make the text view

Returns:
text view

makeImageRepositoryURL

public java.net.URL makeImageRepositoryURL()
Make image repository Url

Returns:
image repository Url

makeBasedURL

private java.net.URL makeBasedURL(java.lang.String thisSubPath,
                                  java.lang.String thisFilename)
Make based Url

Parameters:
thisSubPath - if not null this this the extra path to add to the base
thisFilename - filename
Returns:
url

makeURL

public java.net.URL makeURL(java.lang.String thisSource)
Make Url

Specified by:
makeURL in interface IProviderContext
Parameters:
thisSource -
Returns:
url
See Also:
IProviderContext.getParameter(java.lang.String)

makeProvider

private IProvider makeProvider(java.lang.String thisProviderName)
Make provider

Parameters:
thisProviderName - provider name
Returns:
provider

getBase

public java.net.URL getBase()
Description copied from interface: IContext
Get base URL

Specified by:
getBase in interface IContext
Returns:
base url

getHtmlDocumentBase

public java.net.URL getHtmlDocumentBase()
Description copied from interface: IContext
Get embedding HTML document base URL

Specified by:
getHtmlDocumentBase in interface IContext
Returns:
base url

getImagesBase

public java.net.URL getImagesBase()
Description copied from interface: IContext
Get images base URL

Specified by:
getImagesBase in interface IContext
Returns:
images base url

getImage

public java.awt.Image getImage(java.net.URL thisURL)
Description copied from interface: IContext
Get image

Specified by:
getImage in interface IContext
Parameters:
thisURL - url
Returns:
image

getParameter

public java.lang.String getParameter(java.lang.String thisName)
Description copied from interface: IContext
Get parameter

Specified by:
getParameter in interface IContext
Specified by:
getParameter in interface IProviderContext
Parameters:
thisName - parameter name
Returns:
parameter value

linkTo

public boolean linkTo(java.lang.String thisLinkUrl,
                      java.lang.String thisUrlTarget)
Description copied from interface: IContext
Navigate to link

Specified by:
linkTo in interface IContext
Parameters:
thisLinkUrl - link url
thisUrlTarget - link target
Returns:
true if the context handles the link, false means the current provider will re-init () with the link as source

showStatus

public void showStatus(java.lang.String thisString)
Description copied from interface: IContext
Show status

Specified by:
showStatus in interface IContext
Parameters:
thisString - message

putMessage

public void putMessage(java.lang.String thisString)
Description copied from interface: IProviderContext
Put status string (such as error)

Specified by:
putMessage in interface IProviderContext
Parameters:
thisString - message

putProgress

public void putProgress(java.lang.String thisString,
                        boolean thisFail)
Description copied from interface: IProviderContext
Put progress

Specified by:
putProgress in interface IProviderContext
Parameters:
thisString - message