Oxygen plugin problem

Having trouble installing Oxygen? Got a bug to report? Post it all here.
leachuser
Posts: 2
Joined: Mon Jun 08, 2009 2:59 am

Oxygen plugin problem

Post 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());
.....
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Oxygen plugin problem

Post 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
leachuser
Posts: 2
Joined: Mon Jun 08, 2009 2:59 am

Re: Oxygen plugin problem

Post 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.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Oxygen plugin problem

Post 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
Post Reply