Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

getLastActiveChart problem
 Post subject: getLastActiveChart problem Post rating: 0   New post Posted: Sun 03 Oct, 2021, 20:01 

User rating: 3
Joined: Fri 15 Nov, 2019, 12:54
Posts: 12
Location: Poland,
Hi,

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,
Marcin


 
 Post subject: Re: getLastActiveChart problem Post rating: 0   New post Posted: Sun 03 Oct, 2021, 20:21 

User rating: 3
Joined: Fri 15 Nov, 2019, 12:54
Posts: 12
Location: Poland,
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;
}


 

Jump to:  

cron
  © 1998-2011 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com