User intercation in custom protocol handler

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
dangkhoa
Posts: 1

User intercation in custom protocol handler

Thu Sep 28, 2017 5:08 pm

I don't believe what I am about to describe is possible, but I'vbe been asked to try and implement it anyway, so a definative answer from you guys would be great.

I have a custom protocol handler that loads a file via a webservice when oxygen is opened with an appropriate URL. When the file is saved the custom protocol handler attepts to write the content back to the webservice. This will sometimes fail, e.g. if the server has gone down between openeidn and saving ghrt edocument. In these casees the handler creates a temporary local file and saves the updated document here. If the same document is later opened from the web service the the content of this local file is used by preference. This all worksa fine and has ssuccesfully be through test.

The users have now requested that when this local file is created, or used when opening a document, that a warning dialog be shown to the user. I don't believe that this is possible; can you either confirm this or give me some idea how I might go about it?

Many thanks,
Radu
Posts: 5088

Re: User intercation in custom protocol handler

Fri Sep 29, 2017 9:06 am

Hi,

From the protocol handler you can show a warning dialog, for example you can do something like:

Code: Select all

          SwingUtilities.invokeLater(new Runnable() {
           
            @Override
            public void run() {
              ro.sync.exml.workspace.api.PluginWorkspaceProvider.getPluginWorkspace().showWarningMessage("Some message here");
            }
          });


or use the usual swing "JOptionPane" to show the message. I used " SwingUtilities.invokeLater" because I did not want the dialog popping up and blocking the current thread operation.

Another possibility (only for the save operation) would be that when the save operation fails, you throw an IOException in your implementation of OutputStream in which Oxygen is writing content. And Oxygen will show an error when it catches the IOException on its side.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “Common Problems”

Who is online

Users browsing this forum: No registered users and 1 guest