Page 1 of 1

Oxygen plugin problem

Posted: Mon Jun 08, 2009 3:07 am
by leachuser
I have written an application that opens a URL connection and writes data to it using an outputstream. My application can run standalone or as an Oxygen editor plugin. When run standalone, my application works correctly. When invoked as a plugin from within oxygen, data does not get written to the server - it's not being flushed, even if I explicitly call flush and close the stream. Is anyone aware of any problems regarding this aspect of oxygen.

This is an extract of my code:
=============================

URL url = new URL(...........
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
out.write(data);
out.close();

DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
Document root = domBuilder.parse(connection.getInputStream());
.....

Re: Oxygen plugin problem

Posted: Tue Jun 09, 2009 11:13 am
by sorin_ristache
Hello,
leachuser wrote:When invoked as a plugin from within oxygen, data does not get written to the server - it's not being flushed, even if I explicitly call flush and close the stream.
If you want to write to a URL in an Oxygen plugin it must be a custom protocol plugin. This is the only way of registering a URL handler in Oxygen. You can details about creating a custom protocol plugin in the User Manual.


Regards,
Sorin

Re: Oxygen plugin problem

Posted: Tue Jun 09, 2009 1:05 pm
by leachuser
Thanks for the suggestion, Sorin.

Currently, my plugin implements SelectionPluginExtension. In the Oxygen editor, the user highlights a piece of text, then invokes the plugin, which brings up a dialog box. The dialog box has two main functions:

(1) Allows the user to select from a a list of items. On selecting the item, the dialog box closes and the text that was highlighted in the Oxygen editor is replaced accordingly. (Thus, the reason for implementing SelectionPluginExtension).

(2) The dialog box also allows the user to create a new item on the server. It opens a url connection, gets an outputstream from the connection and writes data to it.

According to your suggestion, to get (2) to work, my plugin would have to be a custom protocol plugin, which according to the manual, it would have to implement URLStreamHandlerPluginExtension or URLChooserPluginExtension. I just need to figure out how to make this fit in with (1) above.

Kind Regards,
Leachuser.

Re: Oxygen plugin problem

Posted: Tue Jun 09, 2009 2:16 pm
by sorin_ristache
Hello,

For creating a new item on the server you need a new plugin (a custom protocol plugin). This plugin will add a new entry to the File menu and you can display in this plugin the file browser dialog that shows also the server content. The sample included in the Plugins SDK on the Developer page is an example.

After adding the custom protocol plugin you can use also the dialog box of the selection plugin for creating a new item on the server accessed through the custom protocol implemented by the custom protocol plugin. But I think usually the content of a server that is accessed through a custom protocol is displayed in a separate dialog box.


Regards,
Sorin