A. Perri wrote:
>  
> i finally was able to embed your supper dupper ditac converter into our Java
> application. I even found a solution for the "Cannot find
> CatalogManager.properties" problem below.
>  
> Now i am really really stumped. I would like to cancel the converter
> process after it is launched via a dialog. Is there a means you know of
> to do this?
> I believe i need a thread that monitors your ditac thread to send it a
> message or notification when specified to do so to terminate it.  
> 

This level of support is reserved to the customers of XMLmind products.
However I'll answer your question because the answer is quite simple:

No, you don't necessarily need a separate thread. However you may want
to use one in case you want [1] to keep the UI responsive [2] to
forcibly stop the conversion using Thread.stop in an emergency case
(i.e. because the conversion loops forever)

In all cases, pass a Console

http://www.xmlmind.com/ditac/_distrib/doc/api/com/xmlmind/util/Console.html

to the Converter using

http://www.xmlmind.com/ditac/_distrib/doc/api/com/xmlmind/ditac/convert/Converter.html#setConsole(com.xmlmind.util.Console)

When you want to cancel the conversion, do it from the code of your
Console.

That is, throw a special kind of exception (e.g.
ConversionCanceledException) from

http://www.xmlmind.com/ditac/_distrib/doc/api/com/xmlmind/util/Console.html#showMessage(java.lang.String,%20com.xmlmind.util.Console.MessageType)

Excerpts from our own code:

---
    public void run() {
        progressMonitor.start();

        conversionStatus = Status.RUNNING;

        // Used by Saxon to load its extensions.
        Thread.currentThread().setContextClassLoader(
            getClass().getClassLoader());

        try {
            doRun();
            conversionStatus = Status.DONE;
        } catch (ConversionCanceledException e) {
            progressMonitor.message(Msg.msg("conversionCanceled"),
                                    MessageType.INFO);
            conversionStatus = Status.CANCELED;
        } catch (Exception e) {
            progressMonitor.message(runErrorReason(e),
                                    MessageType.ERROR);
            conversionStatus = Status.FAILED;
        } finally {
            progressMonitor.stop();
        }
    }
---

The implementation of Console looks like:

---
    public void showMessage(String message, MessageType messageType) {
        if (cancelConversion) {
            throw new ConversionCanceledException();
        }
        // Otherwise, display message here.
        ...
    }
---
 
--
XMLmind DITA Converter Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/ditac-support

Reply via email to