Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-dev] Platform SWT/JFace: Window.getInitialSize()/getInitialLocation() not being called if ToolBarManager is used

	JFace 3.22.100
	SWT 3.116.0 (win32.x64_86)



I have a strange effect when I add a toolbar to a JFace application
window. It is a standalone JFace application, not an Eclipse plugin.

The problem occurs when I add at least one action to the ToolBarManager.
It works fine when the ToolBarManager is empty.

	protected ToolBarManager createToolBarManager(int style) {

		ToolBarManager tbm = new ToolBarManager(style);
		tbm.add(new NewProjectAction()); // will cause problem
		return tbm;

If the action has been created, my overridden application window
functions getInitialSize() and getInitialLocation() will not be called
by the framework.

This is because the variable Window.resizeHasOccurred is true so the
function Window.initializeBounds() exits.

	protected void initializeBounds() {
		if (resizeListener != null) {
			shell.removeListener(SWT.Resize, resizeListener);
		if (resizeHasOccurred) { // Check if shell size has been set already.
			return; // ** exiting here

		Point size = getInitialSize();
		Point location = getInitialLocation(size);
		shell.setBounds(getConstrainedShellBounds(new Rectangle(location.x,
				location.y, size.x, size.y)));

As a workaround, I may override initializeBounds(). If not, the window
will be opened in minimal size at a random location.

But even if I implement initializeBounds(), I also notice the window
being opened in minimal size and random location, then disappearing and
being shown again in the required size and location.


Back to the top