Configuration changes event ?

Post here questions and problems related to oXygen frameworks/document types.
Vince
Posts: 64
Joined: Wed Dec 03, 2014 11:25 am

Configuration changes event ?

Post by Vince »

Hello,

Is there a configuration changes event emitted ?

My use case is to detect proxy settings changes in order to rebuild plugin http client according to this new settings.

Regards,
Vincent
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Configuration changes event ?

Post by Radu »

Hi Vincent,
We do not have such callbacks, does the client change the HTTP proxy configuration from inside Oxygen or from the operating system?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Vince
Posts: 64
Joined: Wed Dec 03, 2014 11:25 am

Re: Configuration changes event ?

Post by Vince »

Hi Radu,

Our plugin load the HTTP proxy configuration from inside Oxygen.
If the settings are modified from preferences pages, we need to restart oXygen to force rebuild the HTTP client and load the new settings.
If an event or callback was sent, we could intercept it to rebuild the client without restarting oXygen.

Thx
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Configuration changes event ?

Post by Radu »

Hi,

Maybe you can try something like:

Code: Select all

        PluginWorkspaceProvider.getPluginWorkspace().addGlobalOptionListener(new OptionListener() {
          @Override
          public void optionValueChanged(OptionChangedEvent event) {
            if(event.getOptionKey() != null && event.getOptionKey().startsWith("http.proxy")) {
              //Proxy setting changed
            }
          }
        });
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Vince
Posts: 64
Joined: Wed Dec 03, 2014 11:25 am

Re: Configuration changes event ?

Post by Vince »

I try your suggestion but it doesn't work. No event is recieved.
Regards,
Vicnent
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Configuration changes event ?

Post by Radu »

Hi,

Could you tell me exactly what setting you changed in the Oxygen Preferences->"Network Connection Settings / Proxy" page to see if change events are received in the plugin? I could try to test this on my side.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Vince
Posts: 64
Joined: Wed Dec 03, 2014 11:25 am

Re: Configuration changes event ?

Post by Vince »

In proxy settings page, I changed from direct connection to manual proxy configuration.
I set Web proxy http address and port.
Finally, i saved preferences.

Regards,
Vincent
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Configuration changes event ?

Post by Radu »

Hi Vincent,

I tested on my side and the code should look something like this:

Code: Select all

      String[] proxyKeys = new String[] {
	  "http.proxy.direct",
          "http.proxy.system",
          "http.proxy.set",
          "http.proxy.manual",
          "http.proxy.port",
          "http.proxy.host",
          "http.proxy.user",
          "http.proxy.password",
      };
      for (int i = 0; i < proxyKeys.length; i++) {
        PluginWorkspaceProvider.getPluginWorkspace().addGlobalOptionListener(new OptionListener(proxyKeys[i]) {
          @Override
          public void optionValueChanged(OptionChangedEvent event) {
            System.err.println(event.getOptionKey());
          }
        });
      }
So you need to add a separate option listener for each Oxygen specific option key related to the proxy.
If you change multiple fields in the preferences, you will receive notifications for each of the changed values.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Vince
Posts: 64
Joined: Wed Dec 03, 2014 11:25 am

Re: Configuration changes event ?

Post by Vince »

Hello,
Thank you for sharing this code. That works.
Regards,
Post Reply