Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 284719

Summary: ToolItem writes unnecessary JS
Product: [RT] RAP Reporter: Stefan Röck <stefan.roeck>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 1.3   
Target Milestone: 1.3 M1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Stefan Röck CLA 2009-07-27 07:27:12 EDT
The very popular and often used widget "ToolItem" causes some unnecessary JS written by the LCA DropDownToolItemLCA.
This snippet shows that the contextMenu and some bounds are send with every request although nothing has changed:

public class ToolItemTest implements IEntryPoint {

	public int createUI() {
		final Display display = new Display();
		final Shell shell = new Shell(display, SWT.DIALOG_TRIM | SWT.RESIZE);
		shell.setMaximized(true);
		shell.setLayout(new FillLayout());

		createContent(shell);
		shell.layout();
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return 0;
	}

	private void createContent(final Composite parent) {
		final Composite container = new Composite(parent, SWT.NONE);
		container.setLayout(new RowLayout(SWT.HORIZONTAL));

		final ToolBar filterToolbar = new ToolBar(container, SWT.HORIZONTAL
				| SWT.RIGHT);
		final ToolItem dropDownItem = new ToolItem(filterToolbar, SWT.DROP_DOWN);
		dropDownItem.setText("test");
		dropDownItem.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				System.out.println("Click");
			}
		});

		final Menu filterDropDownMenu = new Menu(filterToolbar);
		filterToolbar.setMenu(filterDropDownMenu);
	}

}
Comment 1 Stefan Röck CLA 2009-07-27 07:40:14 EDT
Created attachment 142643 [details]
Proposed patch

Fixes two issues:
- menu is now preserved
- special handling for bounds are preserved to make has-changed-check in render phase work
Comment 2 Benjamin Muskalla CLA 2009-08-07 06:16:17 EDT
Stefan, thanks for the detailed report and patch. The problem is not scoped to DROP_DOWN tool items but for all toolitems. Background is that we need to attach the menu of the toolbar to every toolitem as qooxdoo doesn't delegate the stuff from the toolitem to the toolbar if there is no context menu set on the item.
Regarding the bounds: i used your patch but renamed the method to getItemBounds
I introduced the menu preserve in the ToolItemLCAUtil#preserveValues so we catch every tool item.
Also added some tests to ToolItemLCA_Test.