Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 289181 - [JFace] initial size & location of Window is never set if a menu bar is displayed
Summary: [JFace] initial size & location of Window is never set if a menu bar is displ...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: 4.3 M6   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-11 05:20 EDT by Michael Seele CLA
Modified: 2013-03-12 13:45 EDT (History)
5 users (show)

See Also:


Attachments
Snippet of the problem (1.79 KB, text/x-java)
2009-09-11 05:20 EDT, Michael Seele CLA
no flags Details
Patch which fixes the bug (962 bytes, patch)
2010-09-09 03:34 EDT, Michael Seele CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Seele CLA 2009-09-11 05:20:10 EDT
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)
Build Identifier: 

If you create a ApplicationWindow with a menu bar, the initializeBounds() breaks before it calls getInitialSize() and getInitialLocation(). 
Please see the attached snippet:
It first shows an ApplicationWindow without menu bar. initializeBounds() runs correct.
After closing this window, it shows an ApplicationWindow with menu bar. Now initializeBounds() breaks to early and don't call getInitialSize() and getInitialLocation(). 

The problem is that createTrimWidgets() in ApplicationWindow create a shell resize event which lets initializeBounds() break.

Reproducible: Always
Comment 1 Michael Seele CLA 2009-09-11 05:20:51 EDT
Created attachment 146935 [details]
Snippet of the problem
Comment 2 Remy Suen CLA 2009-09-11 19:22:53 EDT
This can be worked around by overriding the create() method and setting the location and size of the shell after the fact.

The problem itself can be fixed by moving the menu construction code out of createTrimWidgets(Shell) method and into, like above, a new overridden create() method defined in ApplicationWindow. This can however break clients if they were expecting a menu bar to have been set on the shell, say, by the time createContents(Composite) is called.
Comment 3 Susan McCourt CLA 2009-09-21 14:07:25 EDT
I don't see us changing the control flow here if there is a workaround.  Let us know if Remy's suggested workaround is sufficient.  (thanks, Remy).
Comment 4 Michael Seele CLA 2009-09-22 02:06:08 EDT
(In reply to comment #3)
> I don't see us changing the control flow here if there is a workaround.  Let us
> know if Remy's suggested workaround is sufficient.  (thanks, Remy).

Yes the workaround works, but this is a bug! And there is an easy fix for this. I Can't understand why you don't wana fix this.
Yes, it maybe breaks with some current implementations. But this is a major release. If you want to migrate to another major release with you application, you have to test it.
Comment 5 Susan McCourt CLA 2009-09-22 11:37:52 EDT
I agree this is a bug.  

For some of the most mature parts of the SDK (such as JFace), the ease of the fix isn't the only criteria for fixing in the 3.x stream.  The possibility of breaking long-standing consumers of the code is also important.  Changing the widget creation sequence likely won't happen without votes on this bug to raise the priority.  

Now, this is the kind of thing that could get fixed in the e4 timeframe, since that release introduces major structural changes in the implementation of the UI.
Comment 6 Markus Keller CLA 2009-09-22 13:04:57 EDT
> Changing the widget creation sequence likely won't happen without votes [..]

That would be a breaking change that should never happen, especially since there are easy other ways to fix this. You could e.g. make Window#resizeHasOccurred package-visible and just add code in ApplicationWindow#createTrimWidgets(Shell) around shell.setMenuBar(..) that restores the value from before setMenuBar(..).

You could also add a protected hook method Window#blocksInitializeBounds(Event) and call it from the Resize listener. That would also allow to remove the hack in WorkbenchWindow#initializeBounds().
Comment 7 Michael Seele CLA 2010-08-20 03:24:47 EDT
is there a chance that you fix this in the release 4 branch?
Comment 8 Roman Dawydkin CLA 2010-09-03 09:50:48 EDT
In current state, getInititalSize() method is practically totally useless. We still need some fix.
Comment 9 Susan McCourt CLA 2010-09-08 16:01:17 EDT
removing milestone (since we didn't look at this for 4.0).
We currently have not had to branch JFace for the 4.x stream.

If you want to submit a patch and test cases along the lines of comment #6, then that would help things along.
Comment 10 Michael Seele CLA 2010-09-09 03:34:00 EDT
Created attachment 178488 [details]
Patch which fixes the bug

Here is a patch which fixes the bug the way is was described in comment#6
Comment 11 Mikael Hakman CLA 2013-02-01 19:20:17 EST
As of today in Eclipse 4.2 this bug is still there. Another workaround is to set shell size in configureShell:

...
Point size = this.getInitialSize();
newShell.setSize(size);
...

Thanks.
Comment 13 Paul Webster CLA 2013-03-12 13:45:20 EDT
In 4.3.0.I20130311-2000

Please be sure to test it in your own configurations.

PW