Dukascopy Support Board

getLastActiveChart problem
Page 1 of 1

Author:  pminc74 [ Sun 03 Oct, 2021, 20:01 ]
Post subject:  getLastActiveChart problem


In my plugin code, I'd like to determine the current (active) chart.
For context variable of type IPluginContext I call getLastActiveChart().

As a result I get the active tab chart object - this is OK.

But when this code is run just after starting the platform (without clicking on any tab) - accessing the chart object is not possible - it ends with IllegalStateException (until I click on any tab).

Best regards,

Author:  pminc74 [ Sun 03 Oct, 2021, 20:21 ]
Post subject:  Re: getLastActiveChart problem

The workaround for this case is to set programmaticaly one of the existing tabs as active.

private IChart getActiveChart() {

IChart ret = context.getLastActiveChart();

if (!ret.isAlive()) { // we've got non-accessible chart object

Set<IChart> currentCharts=context.getCharts();

if ((currentCharts==null)||(currentCharts.isEmpty())) return null;

IChart chart = currentCharts.iterator().next();
chart.setFocus(); // switch to this tab
return chart;

return ret;

  Page 1 of 1