Thank you for your answer!  

therefore, the only means of stopping a render, it's to put FOP in
Thread (and to stop the Thread)

But, how did you make to redirect the logger towards a dialog box?

Philippe.

-----Message d'origine-----
De : Patrick Dean Rusk [mailto:[EMAIL PROTECTED] 
Envoyé : vendredi 7 février 2003 18:00
À : [EMAIL PROTECTED]
Objet : RE: How to stop a render FOP ?

> How to stop a render FOP ?

Philippe,

        I'm going to assume that you want a human or a program to stop a
FOP run
that is embedded in a program that should otherwise remain running.  If
you
mean the command line, you can, of course, use ^C or whatever interrupt
command is appropriate to your shell.

        It would be preferable to be able to run FOP in a separate
thread, and then
set some flag from the main thread that FOP would notice and abort on.
If
such a simple, programmatic mechanism for doing this exists, I don't
know of
it.

        I have been able to implement the following though....

        I wanted to put up a modal progress dialog that would indicate
how many
pages have been rendered thus far.  I did this by creating
ProgressDialogLogger, an implementation of the
org.apache.avalon.framework.logger.Logger interface, and set it as the
logger for the rendering run.

        Then, from the main thread I put up the modal progress dialog
with an
initial message of "Initializing...".  Then I launch FOP in a separate
thread.

        Every time FOP logs a message, particularly the INFO messages
counting off
the rendered pages, I update the message in the progress dialog.  When
FOP
finishes, the dialog is disposed of.

        That all worked fine.  Then I wanted to put a "Cancel" button on
the
dialog.

        The Cancel button sets a flag on the ProgressDialogLogger.  The
next time
that FOP attempts to log a message, the ProgressDialogLogger notices
this
flag and throws a "CancelError", a subclass of Error.  I chose an Error
subclass on the assumption that FOP would not have any "catch (Error
error)"
blocks, which appears correct.

        Then, my background thread running FOP catches the CancelError,
closes the
streams it opened for FOP, disposes of the progress dialog, and exits.

        Hope this helps.

Patrick Rusk


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to