You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Philippe PITHON <pp...@sigal.fr> on 2003/02/10 09:11:25 UTC

RE : How to stop a render FOP ?

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:PatrickRusk@attbi.com] 
Envoyé : vendredi 7 février 2003 18:00
À : fop-user@xml.apache.org
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: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


RE: How to stop a render FOP ?

Posted by Patrick Dean Rusk <Pa...@attbi.com>.
Be careful when you say "stop the Thread".  Threads are no longer supposed
to be directly stopped.  I am, instead, throwing an Error in the thread,
catching it in the same thread, and exiting the thread cleanly.

The log messages are only going to System.out in the first place because the
default implementation of the org.apache.avalon.framework.logger.Logger used
by FOP responds to the debug(), info(), warn(), error(), and fatalError()
methods by writing the messages to System.out.  If you create your own
implementation and set is as the logger for the FOP run, you can do whatever
you want, including a setText() on a JTextField found in a dialog that was
already put on screen by another thread.

Pat


-----Original Message-----
From: Philippe PITHON [mailto:ppithon@sigal.fr]
Sent: Monday, February 10, 2003 3:11 AM
To: fop-user@xml.apache.org
Subject: RE : How to stop a render FOP ?


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.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org