ptolemy.actor.gui
Class HTMLAbout

java.lang.Object
  extended by ptolemy.actor.gui.HTMLAbout

public class HTMLAbout
extends java.lang.Object

This class contains static methods that are called by when HTMLViewer.hyperlinkUpdate() is invoked on a hyperlink that starts with about:. This facility is primarily used for testing.

Since:
Ptolemy II 3.0
Version:
$Id: HTMLAbout.java 59488 2010-10-12 07:03:18Z cxh $
Author:
Christopher Hylands
See Also:
HTMLViewer.hyperlinkUpdate(HyperlinkEvent)
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Field Summary
private static java.util.List _demosURLs
           
 
Constructor Summary
HTMLAbout()
           
 
Method Summary
private static java.lang.String _aboutHTML(java.lang.String fileName)
           
private static java.lang.String _checkCompleteDemos(java.lang.String completeDemos, java.util.List otherDemos)
          Check that all the demos in otherDemos are in complete Demos
private static boolean _configurationExists(java.lang.String configurationName)
           
static java.net.URL _expandLibrary(java.lang.String regexp, Configuration configuration)
          Expand the left hand library pane.
private static java.net.URL _getDemoURL(java.lang.String demosFileName)
           
private static java.util.List _getURLs(java.net.URL demosURL, java.lang.String regexp)
          Open up a file, return a list of relative URLs that match a regexp.
private static java.util.List _getURLs(java.net.URL demosURL, java.lang.String regexp, boolean absoluteURLs, int depth)
          Open up a file, return a list of relative or absolute URLs that match a regexp.
private static java.net.URL _temporaryHTMLFile(java.lang.String prefix, java.lang.String suffix, java.lang.String contents)
           
static java.lang.String about(Configuration configuration)
          Return a string containing HTML that describes the about: features.
static java.net.URL generateLinks(java.lang.String demosFileName, java.lang.String regexp, Configuration configuration)
          Call Configuration.openModel() on relative URLs that match a regexp.
static java.net.URL hyperlinkUpdate(javax.swing.event.HyperlinkEvent event, Configuration configuration)
          Process an "about:" HyperlinkEvent.
static void main(java.lang.String[] args)
          Generate a file that contains urls of models.
static java.net.URL runAllDemos(java.lang.String demosFileName, Configuration configuration)
          Run all the local .xml files that are linked to from an HTML file.
static void writeDemoURLs(java.lang.String demosFileName, java.lang.String outputFileName)
          Write the urls of the demo urls.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_demosURLs

private static java.util.List _demosURLs
Constructor Detail

HTMLAbout

public HTMLAbout()
Method Detail

about

public static java.lang.String about(Configuration configuration)
Return a string containing HTML that describes the about: features.

If the configuration contains an _applicationName attribute then that attribute is used as the name of the application in the generated text. If _applicationName is not present, then the default name is "Ptolemy II".

If the configuration contains an _applicationDemos Parameter then that parameter is assumed to be an array of strings name naming HTML files that should be searched for demos and expanded.

Parameters:
configuration - The configuration to look for the _applicationName attribute in
Returns:
A string containing HTML that describes the about: features.

generateLinks

public static java.net.URL generateLinks(java.lang.String demosFileName,
                                         java.lang.String regexp,
                                         Configuration configuration)
                                  throws java.lang.Exception
Call Configuration.openModel() on relative URLs that match a regexp. files are linked to from an HTML file.

Parameters:
demosFileName - The name of the HTML file that contains links to the .xml, .htm and .html files. If this argument is the empty string, then "ptolemy/configs/doc/completeDemos.htm" is used.
regexp - The regular expression of the links we are interested in.
configuration - The configuration to open the files in.
Returns:
the URL of the HTML file that was searched.
Throws:
java.lang.Exception - If there is a problem opening a model.

hyperlinkUpdate

public static java.net.URL hyperlinkUpdate(javax.swing.event.HyperlinkEvent event,
                                           Configuration configuration)
                                    throws java.lang.Throwable
Process an "about:" HyperlinkEvent.

Parameters:
event - The HyperlinkEvent to process. The description of the event should start with "about:". If there are no specific matches for the description, then a general usage message is returned.
configuration - The configuration in which we are operating.
Returns:
A URL that points to the results.
Throws:
java.lang.Throwable - If there is a problem invoking the about task.

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Generate a file that contains urls of models.

Parameters:
args - The optional name of the file containing the demos followed by the optional name of the output file. The default demo file is ptolemy/configs/doc/completeDemos.htm, the default output file is models.txt.
Throws:
java.io.IOException - If there is a problem reading the demo file or writing the model file.

runAllDemos

public static java.net.URL runAllDemos(java.lang.String demosFileName,
                                       Configuration configuration)
                                throws java.lang.Exception
Run all the local .xml files that are linked to from an HTML file.

Parameters:
demosFileName - The name of the HTML file that contains links to the .xml files. If this argument is the empty string, then "ptolemy/configs/doc/completeDemos.htm" is used.
configuration - The configuration to run the files in.
Returns:
the URL of the HTML file that was searched.
Throws:
java.lang.Exception - If there is a problem running a demo.

writeDemoURLs

public static void writeDemoURLs(java.lang.String demosFileName,
                                 java.lang.String outputFileName)
                          throws java.io.IOException
Write the urls of the demo urls. The HTML file referred to by demoURLName is scanned for links to .xml files and for links to other .htm* files. The children of demoURLName are scanned, but not the grandchildren. The names of the demos will have $CLASSPATH/ prepended. This method is used to generate a list of all demos in ptolemy/configs/doc/models.txt.

Parameters:
demosFileName - The name of the demo file.
outputFileName - The name of the file that is generated.
Throws:
java.io.IOException - If there is a problem reading the demo file or writing the output file.

_aboutHTML

private static java.lang.String _aboutHTML(java.lang.String fileName)

_expandLibrary

public static java.net.URL _expandLibrary(java.lang.String regexp,
                                          Configuration configuration)
                                   throws java.lang.Exception
Expand the left hand library pane. We search for a model, first in the intro.htm file, then the complete demos page and then on the Ptolemy website. The model is opened and then the left hand library pane is expanded. This test is useful for looking for problem with icons, such as icons that cause ChangeRequests.

Parameters:
regexp - The regular expression of the links we are interested in.
configuration - The configuration to open the files in.
Returns:
the URL of the HTML file that was searched.
Throws:
java.lang.Exception - If there is a problem opening a model.

_getDemoURL

private static java.net.URL _getDemoURL(java.lang.String demosFileName)
                                 throws java.io.IOException
Throws:
java.io.IOException

_checkCompleteDemos

private static java.lang.String _checkCompleteDemos(java.lang.String completeDemos,
                                                    java.util.List otherDemos)
                                             throws java.io.IOException
Check that all the demos in otherDemos are in complete Demos

Parameters:
completeDemos - A URL pointing to the completeDemos.htm file
otherDemos - A list of Strings where each string names a demo.
Returns:
HTML listing demos in otherDemos that are not in completeDemos.
Throws:
java.io.IOException

_getURLs

private static java.util.List _getURLs(java.net.URL demosURL,
                                       java.lang.String regexp)
                                throws java.io.IOException
Open up a file, return a list of relative URLs that match a regexp.

Parameters:
demosURL - The URL of the file containing URLs.
regexp - The regular expression, for example ".*.xml$".
Returns:
a list of relative URLS
Throws:
java.io.IOException

_getURLs

private static java.util.List _getURLs(java.net.URL demosURL,
                                       java.lang.String regexp,
                                       boolean absoluteURLs,
                                       int depth)
                                throws java.io.IOException
Open up a file, return a list of relative or absolute URLs that match a regexp.

Parameters:
demosURL - The URL of the file containing URLs.
regexp - The regular expression, for example ".*.xml$".
absoluteURLs - True if we should return absolute URLs.
depth - Depth to recurse. Depth of 0 do not recurse. Recursing only makes sense if the regexp argument includes .htm* files: ".*(.htm|.html|.xml)"
Returns:
a list of Strings naming absolute or relative URLs.
Throws:
java.io.IOException

_configurationExists

private static boolean _configurationExists(java.lang.String configurationName)

_temporaryHTMLFile

private static java.net.URL _temporaryHTMLFile(java.lang.String prefix,
                                               java.lang.String suffix,
                                               java.lang.String contents)
                                        throws java.io.IOException
Throws:
java.io.IOException