public class ExportHTMLAction extends javax.swing.AbstractAction implements HTMLExportable, WebExporter
WebExportable
that have been inserted at
the top level of the current Configuration
.
The model may customize both the web page content and
the actions in the image map by inserting into the model
instances of WebExportable
.
If the model contains an instance of
WebExportParameters
, then that instance
defines parameters of the export. If not, but
the current configuration contains one, then that
instance defines the the parameters. Otherwise,
the defaults in WebExportParameters
are used.
The following JVM properties affect the output:
sanitizedModelName.jnlp
file.Typically, JVM properties are set when Java is invoked.
ExportModel
can be called with these
properties set to create Ptolemy website specific web pages.
See http://chess.eecs.berkeley.edu/ptexternal/wiki/Main/HTMLExport for detailed instructions about how to create web pages on the Ptolemy website for models.
Red (eal) |
Yellow (eal) |
Modifier and Type | Field and Description |
---|---|
protected BasicGraphFrame |
_basicGraphFrame
The associated Vergil frame.
|
(package private) static java.lang.String[] |
FILENAMES
List of filenames needed by jquery and fancybox.
|
Constructor and Description |
---|
ExportHTMLAction(BasicGraphFrame basicGraphFrame)
Create a new action to export HTML.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
_createImageMap(java.io.File directory)
Create the image map.
|
protected java.util.List<ptolemy.vergil.basic.export.html.ExportHTMLAction.IconVisibleLocation> |
_getIconVisibleLocations()
Return a list of data structures with one entry for each visible
entity and attribute.
|
protected void |
_provideDefaultContent()
Provide default HTML content by cloning any
default WebExportable attributes provided by
the configuration into the model.
|
protected void |
_removeDefaultContent()
Remove default HTML content, which includes all instances of
WebExportable that are not persistent.
|
void |
actionPerformed(java.awt.event.ActionEvent event)
Export a web page.
|
static boolean |
copyJavaScriptFilesIfNeeded(BasicGraphFrame graphFrame,
ExportParameters parameters)
If parameters.copyJavaScriptFiles is true and the Java
property ptolemy.ptII.exportHTML.usePtWebsite is false,
then copy the required JavaScript files into the target directory
given in the parameters argument.
|
boolean |
defineAttribute(WebAttribute webAttribute,
boolean overwrite)
Define an attribute to be included in the HTML area element
corresponding to the region of the image map covered by
the specified object.
|
void |
defineElement(WebElement webElement,
boolean onceOnly)
Define an element.
|
static void |
exportToWeb(BasicGraphFrame graphFrame,
ExportParameters parameters)
Export an HTML page and associated subpages for the specified
graph frame as given by the parameters.
|
ExportParameters |
getExportParameters()
During invocation of
writeHTML(ExportParameters, Writer) ,
return the parameters being used. |
PtolemyFrame |
getFrame()
The frame (window) being exported to HTML.
|
static void |
openRunAndWriteHTML(BasicGraphFrame graphFrame,
ExportParameters parameters,
java.io.File indexFile,
java.io.Writer writer,
boolean waitForCompletion)
Depending on the export parameters (see
ExportParameters ),
open submodels, run the model, and export HTML. |
void |
setTitle(java.lang.String title,
boolean showInHTML)
Set the title to be used for the page being exported.
|
static void |
waitForExportToComplete()
Wait for the current invocation of
exportToWeb(BasicGraphFrame, ExportParameters)
to complete. |
void |
writeHTML(ExportParameters parameters,
java.io.Writer writer)
Write an HTML page based on the current view of the model
to the specified destination directory.
|
static final java.lang.String[] FILENAMES
protected final BasicGraphFrame _basicGraphFrame
public ExportHTMLAction(BasicGraphFrame basicGraphFrame)
basicGraphFrame
- The Vergil window to export.public void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed
in interface java.awt.event.ActionListener
event
- The event that triggered this action.public static boolean copyJavaScriptFilesIfNeeded(BasicGraphFrame graphFrame, ExportParameters parameters)
graphFrame
- The frame being exported.parameters
- The export parameters.public boolean defineAttribute(WebAttribute webAttribute, boolean overwrite)
This method is a callback method that may be performed
by attributes of class
WebExportable
when their
WebExportable.provideContent(WebExporter)
method is called by this exporter.
defineAttribute
in interface WebExporter
webAttribute
- The attribute to be included.overwrite
- If true, overwrite any previously defined value for
the specified attribute. If false, then do nothing if there is already
an attribute with the specified name.public void defineElement(WebElement webElement, boolean onceOnly)
defineElement
in interface WebExporter
webElement
- The element.onceOnly
- True to prevent duplicate content.public static void exportToWeb(BasicGraphFrame graphFrame, ExportParameters parameters)
BasicGraphFrame.writeHTML(ExportParameters, Writer)
method, which in turn will delegate back to an instance of this class, ExportHTMLAction.
This method should be invoked in the swing thread.
It will invoke a separate thread to run the model (if so
specified in the parameters).
When that thread completes the run, it will delegate
back to the swing thread to do the export.
Note that this method will return before the export
is completed. If another thread needs to wait for
this complete, then it can call waitForExportToComplete()
.
This is synchronized to ensure that only one export can be in progress at a time.
graphFrame
- The frame containing a model to export.parameters
- The parameters that control the export.
making the exported web page independent of the ptolemy.org site.public ExportParameters getExportParameters()
writeHTML(ExportParameters, Writer)
,
return the parameters being used.getExportParameters
in interface WebExporter
public PtolemyFrame getFrame()
getFrame
in interface WebExporter
public static void openRunAndWriteHTML(BasicGraphFrame graphFrame, ExportParameters parameters, java.io.File indexFile, java.io.Writer writer, boolean waitForCompletion) throws IllegalActionException
ExportParameters
),
open submodels, run the model, and export HTML.graphFrame
- The frame being exported.parameters
- The export parameters.indexFile
- If you wish to show the exported page in a browser,
then this parameter must specify the file to which the write occurs
and parameters.showInBrowser must be true. Otherwise, this parameter
should be null.writer
- The writer to write to, or null to write to the default
index.html file.waitForCompletion
- If true, then do not return until the export
is complete. In this case, everything is run in the calling thread,
which is required to be the Swing event thread.IllegalActionException
- If something goes wrong.public void setTitle(java.lang.String title, boolean showInHTML)
setTitle
in interface WebExporter
title
- The title.showInHTML
- True to produce an HTML title prior to the model image.public static void waitForExportToComplete()
exportToWeb(BasicGraphFrame, ExportParameters)
to complete. If there is not one in progress, return immediately.public void writeHTML(ExportParameters parameters, java.io.Writer writer) throws java.awt.print.PrinterException, java.io.IOException, IllegalActionException
WebExportable
in the configuration are first
cloned into the model, so these provide default behavior,
for example defining links to any open composite actors
or plot windows.
If the "ptolemy.ptII.exportHTML.usePtWebsite" property is set to true, e.g. by invoking with -Dptolemy.ptII.usePtWebsite=true, then the html files will have Ptolemy website specific Server Side Includes (SSI) code and use the JavaScript and fancybox files from the Ptolemy website. In addition, a toc.htm file will be created to aid in navigation. This facility is not likely to be portable to other websites.
writeHTML
in interface HTMLExportable
parameters
- The parameters that control the export.writer
- The writer to use the write the HTML. If this is null,
then create an index.html file in the
directory given by the directoryToExportTo field of the parameters.java.io.IOException
- If unable to write associated files.java.awt.print.PrinterException
- If unable to write associated files.IllegalActionException
- If reading parameters fails.protected java.lang.String _createImageMap(java.io.File directory) throws IllegalActionException, java.io.IOException, java.awt.print.PrinterException
directory
- The directory into which to write any HTML
that is created as a side effect.java.awt.print.PrinterException
- If writing to the toc file fails.java.io.IOException
- If IO fails.IllegalActionException
- If reading parameters fails.protected java.util.List<ptolemy.vergil.basic.export.html.ExportHTMLAction.IconVisibleLocation> _getIconVisibleLocations()
protected void _provideDefaultContent() throws IllegalActionException
DefaultIconScript
and DefaultIconLink
objects, if the model contains one with the same event
type, then the one from the configuration is not used.IllegalActionException
- If cloning a configuration attribute fails.protected void _removeDefaultContent() throws IllegalActionException
IllegalActionException
- If removing the attribute fails.