|
|
|
Re: How to store SWT window size and view distribution [message #1014196 is a reply to message #1011267] |
Mon, 25 February 2013 10:46 |
Urs Beeli Messages: 573 Registered: October 2012 Location: Bern, Switzerland |
Senior Member |
|
|
It seems that my enthusiasm was a bit premature. While the above does indeed all of what I asked for, it also breaks my Coolbar/Toolbar. When I launch my SWT app for the first time, my three buttons (two outline buttons and one tool button) correctly show on the toolbar.
When I exit my client, the workbench.xml file is written. When I restart the SWT client again, that XML file is read and most things restored, except for my buttons. Only the first button is shown, the other two are missing.
I guess that I will need to overwrite the saveState() and restoreState() methods in ApplicationActionBarAdvisor but haven't yet figured out what exactly I need to do there.
I'll keep looking, but if anyone can give me some advice on how to do it, I'd appreciate it.
|
|
|
Re: How to store SWT window size and view distribution [message #1020542 is a reply to message #1014196] |
Mon, 18 March 2013 12:19 |
Urs Beeli Messages: 573 Registered: October 2012 Location: Bern, Switzerland |
Senior Member |
|
|
Ok, while digging into the possibility of adding "view toolbars" (see http://www.eclipse.org/forums/index.php/mv/msg/450899/1018279/#msg_1018279), found out that the view toolbars have the same problem and how to solve it.
The problem is that when a workbench.xml file exists, the elements of the workbench are created much sooner (when the XML file is read) than when they are usually created. One big difference is, that with an existing workbench.xml the various methods to create UI elements are called before the client has been initialised. The mechanism to support a Coolbar already takes this into account by preparing dummy buttons in the fillCoolBar() method and then calling initViewButtons() once the client and SwtEnvironemt have been started. However, this only configures the pre-created buttons on the coolbar, but does not force a redraw of the coolbar.
We need to get and store the configurer when the ApplicationActionBarAdvisor is created:
private IActionBarConfigurer m_configurer;
public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
super(configurer);
m_configurer = configurer;
((SwtEnvironment) Activator.getDefault().getEnvironment()).setAdvisor(this);
}
and then after updating the coolbar buttons in initViewButtons(), the following call must be made:
m_configurer.getCoolBarManager().update(true);
A similar mechanism is needed for the "view toolbars", which I describe in this post: http://www.eclipse.org/forums/index.php/mv/msg/450899/1020541/#msg_1020541
|
|
|
Powered by
FUDForum. Page generated in 0.03969 seconds