|
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 |
pminc74
|
Post subject: getLastActiveChart problem |
Post rating: 0
|
Posted: Sun 03 Oct, 2021, 20:01
|
|
User rating: 3
Joined: Fri 15 Nov, 2019, 12:54 Posts: 16 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
|
|
|
|
![](images/spacer.gif) |
pminc74
|
Post subject: Re: getLastActiveChart problem |
Post rating: 0
|
Posted: Sun 03 Oct, 2021, 20:21
|
|
User rating: 3
Joined: Fri 15 Nov, 2019, 12:54 Posts: 16 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; }
|
|
|
|
![](images/spacer.gif) |
|
Pages: [
1
]
|
|
|
|
|