Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » How to store SWT window size and view distribution
How to store SWT window size and view distribution [message #1011267] Tue, 19 February 2013 07:53 Go to next message
Urs Beeli is currently offline Urs Beeli
Messages: 330
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Here comes my next question Smile

If I change the window size of my Swing client or change the width of the outline tree view and then close my client, these values are retained: When I next start the Swing client, the window and the views have the same size as when the client was last closed.

This does not work with the SWT client. No matter what size I change the window to before closing the client, after a restart the window always has the same default size.

Also, the relative size of the views is not persistent across program starts. In the SWT client I can drag any form into a different view, but upon restart they are again shown in their default view.

It seems that the default placement of forms is defined in the plugin.xml file in the "org.eclipse.ui.perspectiveExtensions" extension point.

I am wondering what I would need to do to persist the following things across program starts:

  • window size
  • relative sizes of views
  • assignment of forms to views


At least for the last points I assume I will need to do something RCP-specific (but have no clue what it could be), is this also necessary for the first two things? Or is there a Scout way to persist these settings?
Re: How to store SWT window size and view distribution [message #1013866 is a reply to message #1011267] Sun, 24 February 2013 14:50 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat Schwarzentrub
Messages: 43
Registered: November 2010
Member
Urs,

I'm not too deep into the subject, but have a look at that discussion:
http://www.eclipsezone.com/eclipse/forums/t31381.html

The mentioned approach (setSaveAndRestore=true) seems to work. However, I don't know if this is the "right way" to do it, and I can't give you an answer, why Scout does not activate that behaviour by default (as it does for the Swing client). Maybe, someone who knows a bit more about the Eclipse Workbench can give a more elaborate answer?

Beat
Re: How to store SWT window size and view distribution [message #1014166 is a reply to message #1013866] Mon, 25 February 2013 09:31 Go to previous messageGo to next message
Urs Beeli is currently offline Urs Beeli
Messages: 330
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Beat

Thanks a lot for this link. Adding
  @Override
  public void initialize(IWorkbenchConfigurer configurer) {
    super.initialize(configurer);
    configurer.setSaveAndRestore(true);
  }

to my org.eclipse.minicrm.ui.swt.application.ApplicationWorkbenchAdvisor does indeed solve all I wanted to do.
Re: How to store SWT window size and view distribution [message #1014196 is a reply to message #1011267] Mon, 25 February 2013 10:46 Go to previous messageGo to next message
Urs Beeli is currently offline Urs Beeli
Messages: 330
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 Go to previous message
Urs Beeli is currently offline Urs Beeli
Messages: 330
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
Previous Topic:Expanding the outline tree
Next Topic:Draw a shape on a SVG Field
Goto Forum:
  


Current Time: Tue Sep 23 08:36:00 GMT 2014

Powered by FUDForum. Page generated in 0.02702 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software