Bug 58476 - [Workbench] Scrollbars in popups
Summary: [Workbench] Scrollbars in popups
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.0 RC4   Edit
Assignee: Michael Van Meekeren CLA
QA Contact:
URL:
Whiteboard:
Keywords: polish
: 61262 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-04-14 10:27 EDT by Matthew Conway CLA
Modified: 2004-06-24 14:54 EDT (History)
2 users (show)

See Also:


Attachments
new version of CyclePartAction (16.90 KB, application/octet-stream)
2004-06-23 14:23 EDT, Michael Van Meekeren CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Conway CLA 2004-04-14 10:27:42 EDT
In Build 200404131323, all the next/previous editor/view/perspective popups have
a tiny size and scrollbars which make them VERY uncomfortable to use.
Comment 1 Matthew Conway CLA 2004-06-21 10:32:02 EDT
This is still here in RC4 - is anything going to be done for this for 3.0?
Its a pretty glaring bug - especially if you only have a few files open, then
the scrollbars hide the name of the file on the bottom of the list.
On windows there are no scorllbars on these popups.
Comment 2 Michael Van Meekeren CLA 2004-06-21 14:12:53 EDT
maybe we can consider using a slightly larger height for these by default
Comment 3 Michael Van Meekeren CLA 2004-06-21 15:00:19 EDT
oops.. edited wrong bug
Comment 4 Michael Van Meekeren CLA 2004-06-22 15:30:59 EDT
patch to CyclePartAction:


Index: CyclePartAction.java
============================================================
=======
RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/
CyclePartAction.java,v
retrieving revision 1.49
diff -u -r1.49 CyclePartAction.java
--- CyclePartAction.java	26 Apr 2004 18:49:10 -0000	1.49
+++ CyclePartAction.java	22 Jun 2004 19:25:33 -0000
@@ -24,6 +24,7 @@
 import org.eclipse.swt.events.MouseListener;
 import org.eclipse.swt.events.TraverseEvent;
 import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.widgets.Display;
@@ -366,9 +367,15 @@
 		tc.pack();
 		table.pack();
 		Rectangle tableBounds = table.getBounds();
+		Rectangle tableClientArea = table.getClientArea();
+		int scrollbarheight = tableBounds.height - tableClientArea.height - 
table.getHeaderHeight();
+		tableBounds.height += scrollbarheight;
 		tableBounds.height = Math.min(tableBounds.height, table.getItemHeight() * MAX_ITEMS);
 		table.setBounds(tableBounds);
+		tc.setWidth(table.getClientArea().width);
+		
 		dialog.pack();
+		dialog.setSize(dialog.getSize().x , dialog.getSize().y + scrollbarheight);
 
 		tc.setWidth(table.getClientArea().width);
 		table.setFocus();
Comment 5 Michael Van Meekeren CLA 2004-06-23 10:37:03 EDT
simple test for table bounds.

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

/*
 * Created on Jun 23, 2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author MVM
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class TableTest {

	/**
	 *  
	 */
	public TableTest() {
	}

	public static void main(String[] args) {

		final int MAX_ITEMS = 22;

		Display display = new Display();
		Shell parent = new Shell(display, SWT.SHELL_TRIM);
		parent.setSize(555,555);
		parent.open();
		
		
		final Shell dialog = new Shell(parent, SWT.MODELESS);
		dialog.setLayout(new FillLayout());

		final Table table = new Table(dialog, SWT.SINGLE | 
SWT.FULL_SELECTION);
		table.setHeaderVisible(true);
		table.setLinesVisible(true);
		TableColumn tc = new TableColumn(table, SWT.NONE);
		tc.setResizable(false);
		tc.setText("Views");
		for (int i = 0; i < 5; i++) {
			TableItem item = new TableItem(table, SWT.NONE);
			item.setText("Package Explorer" + i);
		}
		int tableItemCount = table.getItemCount();
		table.setSelection(0);

		tc.pack();
		table.pack();
		Rectangle tableBounds = table.getBounds();
		tableBounds.height = Math.min(tableBounds.height, 
table.getItemHeight() * MAX_ITEMS);
		table.setBounds(tableBounds);
		dialog.pack();
		tc.setWidth(table.getClientArea().width);
		
		System.out.println("Before table bounds -> " + table.getBounds
());
		System.out.println("Before table client area -> " + 
table.getClientArea());
		table.setFocus();
		table.addFocusListener(new FocusListener() {
			public void focusGained(FocusEvent e) {
				// Do nothing
			}

			public void focusLost(FocusEvent e) {
				dialog.close();
			}
		});

		Rectangle dialogBounds = dialog.getBounds();
		Rectangle displayBounds = display.getClientArea();
		Rectangle parentBounds = dialog.getParent().getBounds();

		//Place it in the center of its parent;
		dialogBounds.x = parentBounds.x + ((parentBounds.width - 
dialogBounds.width) / 2);
		dialogBounds.y = parentBounds.y + ((parentBounds.height - 
dialogBounds.height) / 2);
		if (!displayBounds.contains(dialogBounds.x, dialogBounds.y)
			|| !displayBounds.contains(
				dialogBounds.x + dialogBounds.width,
				dialogBounds.y + dialogBounds.height)) {
			//Place it in the center of the display if it is not 
visible
			//when placed in the center of its parent;
			dialogBounds.x = (displayBounds.width - 
dialogBounds.width) / 2;
			dialogBounds.y = (displayBounds.height - 
dialogBounds.height) / 2;
		}

		try {
			dialog.open();

			System.out.println("Before table bounds -> " + 
table.getBounds());
			System.out.println("Before table client area -> " + 
table.getClientArea());
			
			while (!dialog.isDisposed())
				if (!display.readAndDispatch())
					display.sleep();
		} finally {
			if (!dialog.isDisposed())
				dialog.close();
		}
	

		while (!parent.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}

Comment 6 Matthew Conway CLA 2004-06-23 11:14:36 EDT
I applied the patch, but it didn't seem to help.
The popup window is still not taking into account the prescence of a scrollbar,
and thus the scrollbar is hiding the last entry in the list.  The scrollbars are
present even when a single editor with a short name (Foo.java) is open.

Comment 7 Michael Van Meekeren CLA 2004-06-23 11:24:33 EDT
as a workaround, modified the following two lines in CyclePartAction

OLD
dialogBounds.height = dialogBounds.height + 3 table.getHorizontalBar().getSize().y;

NEW
dialogBounds.height = dialogBounds.height + 5;
dialogBounds.width = dialogBounds.width + 3;


Comment 8 Matthew Conway CLA 2004-06-23 11:55:53 EDT
Had to do the following to get it exactly right:

        dialogBounds.height = dialogBounds.height + 14;
Comment 9 Michael Van Meekeren CLA 2004-06-23 14:23:05 EDT
Created attachment 12739 [details]
new version of CyclePartAction
Comment 10 Matthew Conway CLA 2004-06-23 14:34:03 EDT
That works pretty good.  Only problem is that now there is a white area at the
bottom of the popup - i.e. now the popup is too big =)

Hating me yet? =)

Comment 11 Michael Van Meekeren CLA 2004-06-23 14:42:28 EDT
the extra area is because the table is slightly inconsistent in it's sizing on 
some platforms you don't know whether there will/will not be scrollbars. 

the next patch is less hokey.  trying it on all platforms now.
Comment 12 Michael Van Meekeren CLA 2004-06-23 15:15:08 EDT
fixed in HEAD, reviewed with TC, tested on GTK, MOTIF, Win XP, MacOS
Comment 13 Matthew Conway CLA 2004-06-23 15:27:13 EDT
FYI, I just fetched Head (org.eclipse.ui.workbench only) and tried it out, but
the white area still seems to be there.  If you fixed this in some other plugin,
then let me know and I'll give it a shot, if not, then I figured I'd let you
know that its not completely fixed.
Comment 14 Michael Van Meekeren CLA 2004-06-23 16:46:54 EDT
nope, the white area is a known issue that is not going to be solved by this 
patch.  The scrollbars cutting off text is.

Thanks for your help and quick reviews here.
Comment 15 Michael Van Meekeren CLA 2004-06-23 16:50:21 EDT
*** Bug 61262 has been marked as a duplicate of this bug. ***
Comment 16 Matthew Conway CLA 2004-06-23 17:22:36 EDT
Ok, this fix is still a major improvement over the way it was before - the white
area is pretty trivial as defects go, so I'm happy with whats there, thanks. =)

Glad I could help.
Comment 17 Michael Van Meekeren CLA 2004-06-24 14:48:49 EDT
verified on build I20040624 on MOTIF
Comment 18 Michael Van Meekeren CLA 2004-06-24 14:54:58 EDT
verified on GTK