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

Bug 339334

Summary: View toolbar menuContribution not visible on first run
Product: [RT] RAP Reporter: Andrew Mising name <avyaborov>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 1.4 M7   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Images
none
Patch that fixes the issue none

Description Andrew Mising name CLA 2011-03-09 05:56:42 EST
Build Identifier: 20100617-1415

Linux, rap 1.4 M5.
When you first start app with a view that have some commands in toolbar then not all commands shows in toolbar.

Reproducible: Always

Steps to Reproduce:
1. Create plugin project from template "rap with a view" - z.testToolbar
2. Add new view - View2 (Copy existing view and change it id) and registr it in plugin.xml with allowMultiple="true"
3. Change Perspective.java

public class Perspective implements IPerspectiveFactory {

	public void createInitialLayout(IPageLayout layout) {
		String editorArea = layout.getEditorArea();
		layout.setEditorAreaVisible(false);
		layout.setFixed(true);
		
		layout.addStandaloneView(View.ID, false, IPageLayout.LEFT, 0.25f,
				editorArea);

		IFolderLayout folder = layout.createFolder("views", IPageLayout.TOP, 0.5f, editorArea);
		folder.addPlaceholder(View2.ID + ":*");
		folder.addView(View2.ID);
		
		
	}
}

4. Add 2 commands to plugin.xml and handler
 <extension
         point="org.eclipse.ui.commands">
      <command
            id="z.testToolbar.command1"
            name="name1">
      </command>
      <command
            id="z.testToolbar.command2"
            name="name2">
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.handlers">
      <handler
            class="z.testtoolbar.Handler"
            commandId="z.testToolbar.command1">
      </handler>
      <handler
            class="z.testtoolbar.Handler"
            commandId="z.testToolbar.command2">
      </handler>
   </extension>
  <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="toolbar:z.testToolbar.view2?after=additions">
         <command
               commandId="z.testToolbar.command1"
               label="Command1"
               style="push"
               tooltip="Command1">
         </command>
         <command
               commandId="z.testToolbar.command2"
               label="Command2"
               style="push"
               tooltip="Command2">
         </command>
      </menuContribution>
   </extension>

Handler.java:
public class Handler extends AbstractHandler {

	private int instanceNum = 0;

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		IWorkbenchWindow workbench = HandlerUtil
				.getActiveWorkbenchWindow(event);

		try {
			workbench.getActivePage().showView(View2.ID,
					Integer.toString(instanceNum++),
					IWorkbenchPage.VIEW_ACTIVATE);
		} catch (PartInitException e) {
			MessageDialog.openError(workbench.getShell(), "Error",
					"Error opening view:" + e.getMessage());
		}		
		return null;
	}

}
5. Launch app. Now you can see that only one command visible in toolbar of View2 (only when first time launch). If you exec command1 (open other instance of View2 then command2 appears). And if you refresh app in browser then command2 will be visible.
Comment 1 Ivan Furnadjiev CLA 2011-03-10 04:25:25 EST
Andrew, I can't reproduce it under Windows - tested with FF and Chrome. Frequently, problems related to the first launch only after the server startup are text size determination issues. Could you provide a screenshot? Are the commands overlap each other?
Comment 2 Andrew Mising name CLA 2011-03-10 06:54:21 EST
Created attachment 190844 [details]
Images
Comment 3 Andrew Mising name CLA 2011-03-14 00:21:56 EDT
Ivan, I can't check it under Windows(. Only last command in toolbar invisible (see screenshot's). I've got this problem in early rap versions on linux too.
Don't know is it important for testing, but I noticed that when you start app in eclipse in internal or external browser then in this browser you've got this problem. But if you copy link for app and open it in other browser then all ok with toolbar.
Comment 4 Ivan Furnadjiev CLA 2011-03-14 04:04:04 EDT
Hi Andrew, before I had an icons assigned to the menuContributions and it worked fine (maybe you can use it the same as a workaround). If I remove the icons, and make the toolbar items text-based.... your issue is reproducible.
Comment 5 Ivan Furnadjiev CLA 2011-03-15 05:16:21 EDT
This is a typical text size determination issue - the toolbar is not re-layouted with the real text dimensions.
Comment 6 Ivan Furnadjiev CLA 2011-03-18 07:06:52 EDT
Created attachment 191500 [details]
Patch that fixes the issue

The fix is to call layout(true) instead of layout(false) in PaneFolder titleAreaProxy resize listener. Thus, cache is flushed on resize.
Comment 7 Ivan Furnadjiev CLA 2011-03-18 08:38:10 EDT
Applied patch to CVS HEAD.