Bug 256651 - [FieldAssist] Wrong location calculation of proposal popup shell if content control is near bottom in the screen
Summary: [FieldAssist] Wrong location calculation of proposal popup shell if content ...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M3   Edit
Assignee: Susan McCourt CLA
QA Contact:
URL:
Whiteboard:
Keywords: polish
Depends on:
Blocks:
 
Reported: 2008-11-26 10:14 EST by Michael Seele CLA
Modified: 2009-10-27 14:53 EDT (History)
2 users (show)

See Also:


Attachments
snippet that shows the problem (1.77 KB, text/x-java)
2008-11-26 10:14 EST, Michael Seele CLA
no flags Details
screenshot 1 (wrong) (8.15 KB, image/png)
2008-11-26 10:15 EST, Michael Seele CLA
no flags Details
screenshot 2 (correct) (9.27 KB, image/png)
2008-11-26 10:15 EST, Michael Seele CLA
no flags Details
Field assist popup location patch v1 (1.50 KB, patch)
2009-05-09 08:56 EDT, Remy Suen 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 2008-11-26 10:14:51 EST
Created attachment 118794 [details]
snippet that shows the problem

If the content control's location of the proposal popup is near the bottom of the screen, the shell location calculation is wrong (over the content control).
Please move the popup shell over the top of the content control if the popup shell is to close to the bottom of the screen.

Please see the attached snippet and screenshots.
Comment 1 Michael Seele CLA 2008-11-26 10:15:21 EST
Created attachment 118796 [details]
screenshot 1  (wrong)
Comment 2 Michael Seele CLA 2008-11-26 10:15:47 EST
Created attachment 118797 [details]
screenshot 2 (correct)
Comment 3 Michael Seele CLA 2008-11-26 10:27:17 EST
dirty hack as workaround for this problem:

adapter.addContentProposalListener(new IContentProposalListener2() {

			/*
			 * Copy and paste from ContentProposalAdapter
			 */
			private static final int POPUP_OFFSET = 3;

			public void proposalPopupClosed(ContentProposalAdapter adapter) {
				// do nothing
			}

			public void proposalPopupOpened(ContentProposalAdapter adapter) {
				try {
					Field popupField = adapter.getClass().getDeclaredField("popup"); //$NON-NLS-1$
					popupField.setAccessible(true);
					PopupDialog popupDialog = (PopupDialog) popupField.get(adapter);
					Shell shell = popupDialog.getShell();
					Rectangle popupBounds = shell.getBounds();
					Control control = adapter.getControl();
					Rectangle controlBounds = control.getDisplay().map(control.getParent(), null, control.getBounds());
					if (popupBounds.intersects(controlBounds)) {
						int x = popupBounds.x;
						int y = (controlBounds.y - popupBounds.height) - POPUP_OFFSET;
						shell.setLocation(x, y);
					}
				} catch (SecurityException e) {
					// do nothing
				} catch (NoSuchFieldException e) {
					// do nothing
				} catch (IllegalArgumentException e) {
					// do nothing
				} catch (IllegalAccessException e) {
					// do nothing
				}
			}

		});
Comment 4 Markus Keller CLA 2009-01-11 14:09:53 EST
It should work line in the Java editor: First you should try to reduce the height of the popup to just show less proposals. If reducing the height results in a very small number of proposals shown (e.g. less than 10), then resort to opening the popup on top of the field, upwards, and in full height.
Comment 5 Boris Bokowski CLA 2009-05-06 16:50:06 EDT
Removing 3.5 target milestone. We are in the end-game now. Please have a look and decide if this should be targeted at 3.6.
Comment 6 Susan McCourt CLA 2009-05-06 20:13:34 EDT
This will have to wait, sorry.  My bad, it was a tracking/report problem and this feel through the cracks.
Comment 7 Remy Suen CLA 2009-05-09 08:56:27 EDT
Created attachment 135051 [details]
Field assist popup location patch v1

This patch should resolve the problem described. With regards to reducing the number of proposals being shown per comment 4, the code seems to be hard coded to show ten proposals at the moment.
Comment 8 Susan McCourt CLA 2009-10-15 20:19:54 EDT
Fixed in HEAD >20091015.  The patch was too aggressive in deciding to move the popup above the target control.  It was using the control's height in conjunction with the control height to determine what to do, but this means that a very tall control (taller than the popup) would always show the popup on top even when there was plenty of room for the popup.

Added test cases for the "normal" case and the "move above" case.
Comment 9 Susan McCourt CLA 2009-10-27 14:53:54 EDT
verified in WinXP, Build id: I20091027-0100 using find/replace dialog.