RE : How to stop a render FOP ?

2003-02-10 Thread Philippe PITHON
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]



RE: How to stop a render FOP ?

2003-02-10 Thread Patrick Dean Rusk
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:[EMAIL PROTECTED]
Sent: Monday, February 10, 2003 3:11 AM
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: How to stop a render FOP ?

2003-02-07 Thread Patrick Dean Rusk
 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]