Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

How to check if Plugin is already activated?
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=57236
Page 1 of 1

Author:  pminc74 [ Sun 29 Dec, 2019, 19:49 ]
Post subject:  How to check if Plugin is already activated?

Hi,

I've implemented simple plugin, which has to be assigned to last activated chart and creates widget on that chart.

What is the proper (and simplest) way to check, if there is an instance of my plugin class already activated and assigned to the chart?
When the plugin is activated second time on the same chart I want to cancel further processing. Or even better - to prevent creating second instance of the plugin.


I've tried to use static attribute (set od IChart) to save charts with widget activated, but it seems to every instance be created "separate" from other instances.

Regards,
Marcin

Author:  vadim_berezhnoj [ Wed 19 Feb, 2020, 11:15 ]
Post subject:  Re: How to check if Plugin is already activated?

Hello.

Plugin can try to find widget which was added by another instance of plugin and stop itself if widget already exists on chart.
Use this method from IChart interface:

/**
* Returns <code>IChartObject</code> instance by key if any exist on this panel.
*
* @param chartObjectKey unique id
* @return IChartObject or null if no object was found by specified key
*/
IChartObject get(String chartObjectKey);
To stop plugin use IContext.stop() method

Kind regards, Support Team.

  Page 1 of 1