|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectJSCoreMethods
org.faceless.pdf2.viewer2.JSManager
public class JSManager
Handles the Event
s - primarily JavaScript events - raised during the lifetime of
the viewer. This class will raise the PDF lifetime events defined in the
Acrobat JavaScript Scripting Reference, which may have PDFAction
objects
associated with them. These are unrelated to Swing events and to the
DocumentPanelEvent
, PagePanelEvent
and similar.
Since 2.11.18 is it possible to configure custom JavaScript that will run on certain
events. This can be done by either calling the addCustomJavaScript(java.lang.String, java.net.URL)
method,
or by setting a System property. As an example, here's how to run one custom scripts
on App/Init and Doc/Open events:
from an applet;
<applet code="org.faceless.pdf2.viewer2.PDFViewerApplet" name="pdfapplet" archive="bfopdf.jar, bfopdf-cmap.jar" mayscript> <param name="JSManager.AppInit" value="myscripts/appinit.js" /> <param name="JSManager.DocOpen" value="myscripts/docopen.js" /> </applet>The
value
attribute is the path to a JavaScript file, the contents
of which will be executed on the specified event
With the exception of the above, we recommend developers and those working with the viewer steer well clear of calling into this class, as the API is subject to change without notice.
Method Summary | |
---|---|
void |
addCustomJavaScript(String event,
String script)
Add some custom JavaScript to the viewer. |
void |
addCustomJavaScript(String event,
URL url)
Add some custom JavaScript to the viewer. |
int |
appAlert(String message,
int nIcon,
int nType,
String cTitle,
Object oDoc,
Object oCheckbox)
An implementation of the App.alert JavaScript method |
void |
appBeep()
An implementation of the App.beep JavaScript method |
String |
appResponse(String message,
String cTitle,
String cDefault,
boolean bPassword,
String cLabel)
An implementation of the App.response JavaScript method |
void |
consoleClear()
An implementation of the Console.clear JavaScript method |
void |
consoleHide()
An implementation of the Console.hide JavaScript method |
void |
consolePrintln(String message)
An implementation of the Console.println JavaScript method |
void |
consoleShow()
An implementation of the Console.show JavaScript method |
boolean |
getAppFocusRect()
Return the value set by setAppFocusRect(boolean) |
boolean |
getAppRuntimeHighlight()
Return the value set by setAppRuntimeHighlight(boolean) |
Color |
getAppRuntimeHighlightColor()
Return the value set by setAppRuntimeHighlightColor(java.awt.Color) |
Object |
getComponent(PDFAnnotation annot)
Return the JComponent matchin the specified PDFAnnotation |
String |
getCustomJavaScript(String type,
String name)
Return any Custom JavaScript to be run when the specified event is received. |
DocumentPanel |
getDocumentPanel(PDF pdf)
Return the DocumentPanel that contains the specified PDF |
String |
getImplementationDescription()
Return a description of the JavaScript implementation in use |
Point2D |
getLastMousePosition(PDF pdf)
Get the point in PDF space where the last mouse event (MouseEnter, MouseExit, MouseUp, MouseDown) occurred |
PDFViewer |
getViewer()
Return the PDFViewer this JSManager is a part of |
void |
runEventAppInit()
Raise the App/Init JavaScript method |
JSEvent |
runEventBatchExec(DocumentPanel panel,
PDF pdf,
String javascript)
Raise the Batch/Exec JavaScript method |
JSEvent |
runEventBookmarkMouseUp(DocumentPanel panel,
PDFBookmark bookmark)
Raise the Bookmark/MouseUp JavaScript method |
JSEvent |
runEventConsoleExec(DocumentPanel panel,
String javascript)
Raise the Console/Exec JavaScript method |
JSEvent |
runEventDocDidPrint(DocumentPanel panel)
Raise the Doc/DidPrint JavaScript method |
JSEvent |
runEventDocDidSave(DocumentPanel panel)
Raise the Doc/DidSave JavaScript method |
JSEvent |
runEventDocOpen(DocumentPanel panel,
String targetName)
Raise the Doc/Open JavaScript method |
JSEvent |
runEventDocWillClose(DocumentPanel panel)
Raise the Doc/WillClose JavaScript method |
JSEvent |
runEventDocWillPrint(DocumentPanel panel)
Raise the Doc/WillPrint JavaScript method |
JSEvent |
runEventDocWillSave(DocumentPanel panel)
Raise the Doc/WillSave JavaScript method |
JSEvent |
runEventExternalExec(DocumentPanel panel,
String javascript)
Raise the External/Exec JavaScript method |
JSEvent |
runEventFieldBlur(DocumentPanel panel,
WidgetAnnotation annot,
boolean shift,
boolean modifier)
Raise the Field/Blur JavaScript method |
JSEvent |
runEventFieldCalculate(DocumentPanel panel,
WidgetAnnotation target,
WidgetAnnotation source)
Raise the Field/Calculate JavaScript method |
JSEvent |
runEventFieldFocus(DocumentPanel panel,
WidgetAnnotation annot,
boolean shift,
boolean modifier)
Raise the Field/Focus JavaScript method |
JSEvent |
runEventFieldFormat(DocumentPanel panel,
WidgetAnnotation annot,
int commitKey,
boolean willCommit)
Raise the Field/Format JavaScript method |
JSEvent |
runEventFieldKeystroke(DocumentPanel panel,
WidgetAnnotation annot,
int commitKey,
String change,
String changeEx,
boolean fieldFull,
boolean keyDown,
boolean modifier,
int selStart,
int selEnd,
boolean shift,
String value,
boolean willCommit)
Raise the Field/Keystroke JavaScript method |
JSEvent |
runEventFieldMouseDown(DocumentPanel panel,
WidgetAnnotation annot,
MouseEvent mevent)
Raise the Field/Mouse Down JavaScript method |
JSEvent |
runEventFieldMouseEnter(DocumentPanel panel,
WidgetAnnotation annot,
MouseEvent mevent)
Raise the Field/Mouse Enter JavaScript method |
JSEvent |
runEventFieldMouseExit(DocumentPanel panel,
WidgetAnnotation annot,
MouseEvent mevent)
Raise the Field/Mouse Exit JavaScript method |
JSEvent |
runEventFieldMouseUp(DocumentPanel panel,
WidgetAnnotation annot,
MouseEvent mevent)
Raise the Field/Mouse Up JavaScript method |
JSEvent |
runEventFieldValidate(DocumentPanel panel,
WidgetAnnotation annot,
String value,
boolean shift,
boolean modifier,
String change,
String changeEx,
boolean keyDown)
Raise the Field/Validate JavaScript method |
JSEvent |
runEventLinkMouseUp(DocumentPanel panel,
AnnotationLink annot)
Raise the Link/Mouse Up JavaScript method |
JSEvent |
runEventPageClose(DocumentPanel panel,
PDFPage page)
Raise the Page/Close JavaScript method |
JSEvent |
runEventPageOpen(DocumentPanel panel,
PDFPage page)
Raise the Page/Open JavaScript method |
void |
setAppFocusRect(boolean value)
Sets whether to mark form fields with focus with a dotted rectangle. |
void |
setAppRuntimeHighlight(boolean highlight)
Sets whether to highlight form fields displayed in the viewer using the color from getAppRuntimeHighlightColor() . |
void |
setAppRuntimeHighlightColor(Color c)
Sets the color to highlight form fields if setAppRuntimeHighlight(boolean)
returns true. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public final PDFViewer getViewer()
public final DocumentPanel getDocumentPanel(PDF pdf)
public String getImplementationDescription()
public final Object getComponent(PDFAnnotation annot)
public Point2D getLastMousePosition(PDF pdf)
public void appBeep()
App.beep
JavaScript method
public void consoleShow()
Console.show
JavaScript method
public void consoleHide()
Console.hide
JavaScript method
public void consolePrintln(String message)
Console.println
JavaScript method
public void consoleClear()
Console.clear
JavaScript method
public int appAlert(String message, int nIcon, int nType, String cTitle, Object oDoc, Object oCheckbox)
App.alert
JavaScript method
public String appResponse(String message, String cTitle, String cDefault, boolean bPassword, String cLabel)
App.response
JavaScript method
public void runEventAppInit()
App/Init
JavaScript method
public JSEvent runEventBatchExec(DocumentPanel panel, PDF pdf, String javascript)
Batch/Exec
JavaScript method
public JSEvent runEventBookmarkMouseUp(DocumentPanel panel, PDFBookmark bookmark)
Bookmark/MouseUp
JavaScript method
public JSEvent runEventConsoleExec(DocumentPanel panel, String javascript)
Console/Exec
JavaScript method
public JSEvent runEventDocDidPrint(DocumentPanel panel)
Doc/DidPrint
JavaScript method
public JSEvent runEventDocDidSave(DocumentPanel panel)
Doc/DidSave
JavaScript method
public JSEvent runEventDocOpen(DocumentPanel panel, String targetName)
Doc/Open
JavaScript method
public JSEvent runEventDocWillClose(DocumentPanel panel)
Doc/WillClose
JavaScript method
public JSEvent runEventDocWillPrint(DocumentPanel panel)
Doc/WillPrint
JavaScript method
public JSEvent runEventDocWillSave(DocumentPanel panel)
Doc/WillSave
JavaScript method
public JSEvent runEventExternalExec(DocumentPanel panel, String javascript)
External/Exec
JavaScript method
public JSEvent runEventFieldBlur(DocumentPanel panel, WidgetAnnotation annot, boolean shift, boolean modifier)
Field/Blur
JavaScript method
public JSEvent runEventFieldCalculate(DocumentPanel panel, WidgetAnnotation target, WidgetAnnotation source)
Field/Calculate
JavaScript method
public JSEvent runEventFieldFocus(DocumentPanel panel, WidgetAnnotation annot, boolean shift, boolean modifier)
Field/Focus
JavaScript method
public JSEvent runEventFieldFormat(DocumentPanel panel, WidgetAnnotation annot, int commitKey, boolean willCommit)
Field/Format
JavaScript method
public JSEvent runEventFieldKeystroke(DocumentPanel panel, WidgetAnnotation annot, int commitKey, String change, String changeEx, boolean fieldFull, boolean keyDown, boolean modifier, int selStart, int selEnd, boolean shift, String value, boolean willCommit)
Field/Keystroke
JavaScript method
public JSEvent runEventFieldMouseDown(DocumentPanel panel, WidgetAnnotation annot, MouseEvent mevent)
Field/Mouse Down
JavaScript method
public JSEvent runEventFieldMouseEnter(DocumentPanel panel, WidgetAnnotation annot, MouseEvent mevent)
Field/Mouse Enter
JavaScript method
public JSEvent runEventFieldMouseExit(DocumentPanel panel, WidgetAnnotation annot, MouseEvent mevent)
Field/Mouse Exit
JavaScript method
public JSEvent runEventFieldMouseUp(DocumentPanel panel, WidgetAnnotation annot, MouseEvent mevent)
Field/Mouse Up
JavaScript method
public JSEvent runEventFieldValidate(DocumentPanel panel, WidgetAnnotation annot, String value, boolean shift, boolean modifier, String change, String changeEx, boolean keyDown)
Field/Validate
JavaScript method
public JSEvent runEventLinkMouseUp(DocumentPanel panel, AnnotationLink annot)
Link/Mouse Up
JavaScript method
public JSEvent runEventPageOpen(DocumentPanel panel, PDFPage page)
Page/Open
JavaScript method
public JSEvent runEventPageClose(DocumentPanel panel, PDFPage page)
Page/Close
JavaScript method
public String getCustomJavaScript(String type, String name)
Features
in the PDFViewer for custom JavaScript, and returns the concatenation
of all of them.
ViewerFeature.getCustomJavaScript(java.lang.String, java.lang.String)
public void addCustomJavaScript(String event, URL url) throws IOException
event
- the event type, eg "App/Init" or "Doc/Open"url
- the URL to load the JavaScript from
IOException
public void addCustomJavaScript(String event, String script)
event
- the event type, eg "App/Init" or "Doc/Open"script
- the JavaScript to execute on that eventpublic void setAppRuntimeHighlight(boolean highlight)
getAppRuntimeHighlightColor()
.
The default value can be set by the JavaScript.app.runtimeHighlight
property, which can be set to "true" to enable this by default.
highlight
- true to highlight form fieldspublic boolean getAppRuntimeHighlight()
setAppRuntimeHighlight(boolean)
public void setAppRuntimeHighlightColor(Color c)
setAppRuntimeHighlight(boolean)
returns true.
The default value can be set by the JavaScript.app.runtimeHighlightColor
property, which may be an HTML-style color (eg "#FF0000").
c
- the highlight colorpublic Color getAppRuntimeHighlightColor()
setAppRuntimeHighlightColor(java.awt.Color)
public void setAppFocusRect(boolean value)
JavaScript.app.focusRect
property, which can be set to "false" to disable this by default.
value
- true to highlight form fieldspublic boolean getAppFocusRect()
setAppFocusRect(boolean)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |