Bug 309076 - [design] java.lang.IllegalArgumentException when adding commands to view toolbar
Summary: [design] java.lang.IllegalArgumentException when adding commands to view toolbar
Status: RESOLVED WORKSFORME
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2010-04-14 04:23 EDT by Holger Staudacher CLA
Modified: 2010-05-03 04:01 EDT (History)
2 users (show)

See Also:


Attachments
Example application to reproduce the error (32.35 KB, application/zip)
2010-04-19 05:47 EDT, Raj Saini CLA
no flags Details
example application to re-produce the bug (32.35 KB, application/zip)
2010-04-19 05:50 EDT, Raj Saini CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Staudacher CLA 2010-04-14 04:23:19 EDT
There is a problem while adding a command to a view's tool bar. Same command works fine when it's added to the main tool bar and menu. Stack trace and relevant part of the plugin.xml are below:

==================plugin.xml================================
    <extension
          point="org.eclipse.ui.views">
       <view
             name="Example List"
             icon="icons/sample3.gif"
             class="com.viithiisys.example.views.ExampleListView"
             id="com.viithiisys.example.views.exampleListView">
       </view>
    </extension>

    <extension
          point="org.eclipse.ui.commands">
       <category
             name="Example"
             id="com.viithiisys.example.category">
       </category>
       <command
             name="Edit Example"
             description="Opens Example editor"
             categoryId="com.viithiisys.example.category"
             id="com.viithiisys.example.commands.openExampleEditor"
 defaultHandler="com.viithiisys.example.actions.OpenEditorHandler">
       </command>
    </extension>
    <extension
          point="org.eclipse.ui.menus">
    		<menuContribution
 locationURI="toolbar:com.viithiisys.example.views.exampleListView">
          <toolbar
                id="menu-contribution.toolbars.sampleToolbar">
             <command
 commandId="com.viithiisys.example.commands.openExampleEditor"
                   icon="icons/sample.gif"
                   tooltip="Say hello world"
                   id="menu-contribution.toolbars.sampleCommand">
             </command>
          </toolbar>
       </menuContribution>
    </extension>

=======================stack trace==========================
!STACK 0
java.lang.IllegalArgumentException: Index out of bounds
	at org.eclipse.swt.SWT.error(SWT.java:3084)
	at org.eclipse.swt.SWT.error(SWT.java:3018)
	at org.eclipse.swt.SWT.error(SWT.java:2989)
	at org.eclipse.swt.internal.widgets.ItemHolder.getItem(ItemHolder.java:102)
	at org.eclipse.swt.widgets.ToolBar.getItem(ToolBar.java:132)
	at org.eclipse.rap.internal.design.example.managers.ViewToolBarManager.update(ViewToolBarManager.java:161)
	at org.eclipse.ui.internal.ViewPane.updateActionBars(ViewPane.java:462)
	at org.eclipse.ui.internal.ViewActionBars.updateActionBars(ViewActionBars.java:59)
	at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:419)
	at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:230)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:594)
	at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:312)
	at org.eclipse.ui.internal.ViewPane.setVisible(ViewPane.java:544)
	at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:185)
	at org.eclipse.rap.internal.design.example.stacks.ViewStackPresentation.selectPart(ViewStackPresentation.java:957)
	at org.eclipse.rap.ui.interactiondesign.internal.ConfigurableStackProxy.selectPart(ConfigurableStackProxy.java:425)
	at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1267)
	at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1220)
	at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1619)
	at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:659)
	at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:585)
	at org.eclipse.ui.internal.PartSashContainer.createControl(PartSashContainer.java:569)
	at org.eclipse.ui.internal.PerspectiveHelper.activate(PerspectiveHelper.java:267)
	at org.eclipse.ui.internal.Perspective.onActivate(Perspective.java:930)
	at org.eclipse.ui.internal.WorkbenchPage.onActivate(WorkbenchPage.java:2494)
	at org.eclipse.ui.internal.WorkbenchWindow$22.run(WorkbenchWindow.java:2926)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:66)
	at org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:2907)
	at org.eclipse.ui.internal.WorkbenchWindow.busyOpenPage(WorkbenchWindow.java:720)
	at org.eclipse.ui.internal.Workbench$18.runWithException(Workbench.java:976)
	at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:32)
	at org.eclipse.rwt.internal.lifecycle.UICallBackManager.addSync(UICallBackManager.java:115)
	at org.eclipse.swt.widgets.Display$2.run(Display.java:931)
	at org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler.runNonUIThreadWithFakeContext(UICallBackServiceHandler.java:460)
	at org.eclipse.rwt.lifecycle.UICallBack.runNonUIThreadWithFakeContext(UICallBack.java:44)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:929)
	at org.eclipse.ui.internal.StartupThreading.runWithWorkbenchExceptions(StartupThreading.java:55)
	at org.eclipse.ui.internal.Workbench.busyOpenWorkbenchWindow(Workbench.java:972)
	at org.eclipse.ui.internal.Workbench.doOpenFirstTimeWindow(Workbench.java:1799)
	at org.eclipse.ui.internal.Workbench.openFirstTimeWindow(Workbench.java:1735)
	at org.eclipse.ui.internal.WorkbenchConfigurer.openFirstTimeWindow(WorkbenchConfigurer.java:188)
	at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:790)
	at org.eclipse.ui.internal.Workbench$25.runWithException(Workbench.java:1341)
	at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:32)
	at org.eclipse.rwt.internal.lifecycle.UICallBackManager.addSync(UICallBackManager.java:115)
	at org.eclipse.swt.widgets.Display$2.run(Display.java:931)
	at org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler.runNonUIThreadWithFakeContext(UICallBackServiceHandler.java:460)
	at org.eclipse.rwt.lifecycle.UICallBack.runNonUIThreadWithFakeContext(UICallBack.java:44)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:929)
	at org.eclipse.ui.internal.StartupThreading.runWithoutExceptions(StartupThreading.java:110)
	at org.eclipse.ui.internal.Workbench.init(Workbench.java:1336)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2317)
	at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:2206)
	at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:424)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.jface.internal.databinding.realmadapter.RealmAdapter.run(RealmAdapter.java:44)
	at org.eclipse.rap.ui.internal.RealmAdapterHook.runWithDefault(RealmAdapterHook.java:48)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:427)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:157)
	at com.viithiisys.example.Application.start(Application.java:20)
	at org.eclipse.rap.ui.internal.application.EntrypointApplicationWrapper.createUI(EntrypointApplicationWrapper.java:27)
	at org.eclipse.rwt.internal.lifecycle.EntryPointManager.createUI(EntryPointManager.java:92)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:253)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:117)
	at java.lang.Thread.run(Thread.java:619)
	at org.eclipse.rwt.internal.lifecycle.UIThread.run(UIThread.java:80)
Comment 1 Raj Saini CLA 2010-04-14 15:24:31 EDT
There are also problem with the viewmenu. If I add a command, it works fine for the first time. However, when I close the server and restart, following exception is thrown.

java.lang.IllegalArgumentException: The control was not added to this control holder.
	at org.eclipse.swt.widgets.ControlHolder.remove(ControlHolder.java:62)
	at org.eclipse.swt.widgets.ControlHolder.removeControl(ControlHolder.java:116)
	at org.eclipse.swt.widgets.Control.moveAbove(Control.java:1401)
	at org.eclipse.rap.internal.design.example.stacks.ViewStackPresentation.layoutToolBar(ViewStackPresentation.java:320)
	at org.eclipse.rap.internal.design.example.stacks.ViewStackPresentation.setBounds(ViewStackPresentation.java:1199)
	at org.eclipse.rap.internal.design.example.stacks.ViewStackPresentation.selectPart(ViewStackPresentation.java:971)
	at org.eclipse.rap.ui.interactiondesign.internal.ConfigurableStackProxy.selectPart(ConfigurableStackProxy.java:425)
	at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1267)
	at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1220)
	at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1619)
	at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:659)
	at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:585)
	at org.eclipse.ui.internal.PartSashContainer.createControl(PartSashContainer.java:569)
	at org.eclipse.ui.internal.PerspectiveHelper.activate(PerspectiveHelper.java:267)
	at org.eclipse.ui.internal.Perspective.onActivate(Perspective.java:930)
	at org.eclipse.ui.internal.WorkbenchPage.onActivate(WorkbenchPage.java:2494)
	at org.eclipse.ui.internal.WorkbenchWindow$22.run(WorkbenchWindow.java:2926)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:66)
	at org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:2907)
	at org.eclipse.ui.internal.WorkbenchWindow.busyOpenPage(WorkbenchWindow.java:720)
	at org.eclipse.ui.internal.Workbench$18.runWithException(Workbench.java:976)
	at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:32)
	at org.eclipse.rwt.internal.lifecycle.UICallBackManager.addSync(UICallBackManager.java:115)
	at org.eclipse.swt.widgets.Display$2.run(Display.java:931)
	at org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler.runNonUIThreadWithFakeContext(UICallBackServiceHandler.java:460)
	at org.eclipse.rwt.lifecycle.UICallBack.runNonUIThreadWithFakeContext(UICallBack.java:44)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:929)
	at org.eclipse.ui.internal.StartupThreading.runWithWorkbenchExceptions(StartupThreading.java:55)
	at org.eclipse.ui.internal.Workbench.busyOpenWorkbenchWindow(Workbench.java:972)
	at org.eclipse.ui.internal.Workbench.doOpenFirstTimeWindow(Workbench.java:1799)
	at org.eclipse.ui.internal.Workbench.openFirstTimeWindow(Workbench.java:1735)
	at org.eclipse.ui.internal.WorkbenchConfigurer.openFirstTimeWindow(WorkbenchConfigurer.java:188)
	at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:790)
	at org.eclipse.ui.internal.Workbench$25.runWithException(Workbench.java:1341)
	at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:32)
	at org.eclipse.rwt.internal.lifecycle.UICallBackManager.addSync(UICallBackManager.java:115)
	at org.eclipse.swt.widgets.Display$2.run(Display.java:931)
	at org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler.runNonUIThreadWithFakeContext(UICallBackServiceHandler.java:460)
	at org.eclipse.rwt.lifecycle.UICallBack.runNonUIThreadWithFakeContext(UICallBack.java:44)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:929)
	at org.eclipse.ui.internal.StartupThreading.runWithoutExceptions(StartupThreading.java:110)
	at org.eclipse.ui.internal.Workbench.init(Workbench.java:1336)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2317)
	at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:2206)
	at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:424)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.jface.internal.databinding.realmadapter.RealmAdapter.run(RealmAdapter.java:44)
	at org.eclipse.rap.ui.internal.RealmAdapterHook.runWithDefault(RealmAdapterHook.java:48)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:427)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:157)
	at com.viithiisys.example.Application.start(Application.java:20)
	at org.eclipse.rap.ui.internal.application.EntrypointApplicationWrapper.createUI(EntrypointApplicationWrapper.java:27)
	at org.eclipse.rwt.internal.lifecycle.EntryPointManager.createUI(EntryPointManager.java:92)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:253)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:117)
	at java.lang.Thread.run(Thread.java:619)
	at org.eclipse.rwt.internal.lifecycle.UIThread.run(UIThread.java:80)
!SESSION 2010-04-15 00:52:22.992 ---------------------------------
Comment 2 Raj Saini CLA 2010-04-14 15:25:29 EDT
This is the relevant part of plugin.xml

 <menuContribution
            locationURI="menu:com.viithiisys.example.views.exampleListView?after=additions">
         <menu
               label="Sample Menu"
               mnemonic="M"
               id="menu-contribution.menus.sampleMenu">
            <command
                  commandId="com.viithiisys.example.commands.createExampleCommand"
                  mnemonic="S"
                  id="com.viithiisys.example.views.menu.createExampleCommand">
            </command>
         </menu>
      </menuContribution>
Comment 3 Raj Saini CLA 2010-04-14 15:36:43 EDT
viewmenu problem is tricky one and I will explain a bit about it. Adding command to view menu does not show even I have the "viewActionVisibility" attribute of presentationFactory is set to true.

If I configure the viewmenu through configuration icon on view, it would show the action on view. Now, if I stop the server and restart it, IllegalArgumentException is thrown mentioned in the previous comment. If I delete the stuff from workspace/.metadata/, view will show again but without the viewmenu visible. Below is the relevant part plugin.xml  branding and menu contribution



  <extension
         point="org.eclipse.rap.ui.branding">
      <branding
            servletName="example"
            themeId="org.eclipse.rap.design.example.business.theme"
            defaultEntrypointId="com.viithiisys.example.Application"
            title="Example demo"
            id="com.viithiisys.mail.branding">
         <presentationFactory
               defaultLayoutId="org.eclipse.rap.design.example.business.layout"
               name="Business PresentationFactory" 
               id="org.eclipse.rap.design.example.business.factory"
               viewActionVisibility="true">
            <defaultStackPresentation
                  id="org.eclipse.rap.design.example.stack.view">
            </defaultStackPresentation>
         </presentationFactory>
      </branding>
   </extension>

<menuContribution
            locationURI="menu:com.viithiisys.example.views.exampleListView?after=additions">
         <menu
               label="Sample Menu"
               mnemonic="M"
               id="menu-contribution.menus.sampleMenu">
            <command
                  commandId="com.viithiisys.example.commands.createExampleCommand"
                  mnemonic="S"
                  id="com.viithiisys.example.views.menu.createExampleCommand">
            </command>
         </menu>
      </menuContribution>
Comment 4 Holger Staudacher CLA 2010-04-19 05:10:37 EDT
Raj,
I can't reproduce the error. Can you provide a sample bundle which provokes the error please?

Regards Holger
Comment 5 Raj Saini CLA 2010-04-19 05:47:49 EDT
Created attachment 165253 [details]
Example application to reproduce the error

Holger,

I have attached the sample application. I have commented the server side calling code and you should be able to run it as plain RAP application. My RAP target platform is RAP 1.3M6 and development environment is Eclipse 3.6M6

Steps to re-produce for view tool bar

1. Unzip the application in your workspace and import as "Existing project"
2. Run the application is RAP application.
3. While application loads in the browser you should see the java.lang.IllegalArgumentException: Index out of bounds and browser page remains blank.
4. Change the menu contribution back to Eclipse main menu and command will appear in the Coolbar.

Steps to re-produce for view menu:

(Even though viewActionVisibility attribute is set to true, view menu is not visible by default.)

1. Enable the view menu by enabling it in the configuration setting of the view.
2. View menu will be visible.
3. Stop the application.
4. Restart the application and exception will be thrown as mentioned comment #1
5. Remove the workspace and application will be back but without the view menu.
Comment 6 Raj Saini CLA 2010-04-19 05:50:48 EDT
Created attachment 165255 [details]
example application to re-produce the bug

Holger,

I have attached the sample application. I have commented the server side calling code and you should be able to run it as plain RAP application. My RAP target platform is RAP 1.3M6 and development environment is Eclipse 3.6M6

Steps to re-produce for view tool bar

1. Unzip the application in your workspace and import as "Existing project"
2. Run the application is RAP application.
3. While application loads in the browser you should see the java.lang.IllegalArgumentException: Index out of bounds and browser page remains blank.
4. Change the menu contribution back to Eclipse main menu and command will appear in the Coolbar.

Steps to re-produce for view menu:

(Even though viewActionVisibility attribute is set to true, view menu is not visible by default.)

1. Enable the view menu by enabling it in the configuration setting of the view.
2. View menu will be visible.
3. Stop the application.
4. Restart the application and exception will be thrown as mentioned comment #1
5. Remove the workspace and application will be back but without the view menu.

To me it looks the problem is with Business theme. Anyway, you will need the business theme to make the example work as example application is using the business theme.
Comment 7 Holger Staudacher CLA 2010-04-19 07:18:19 EDT
Sorry Raj but when I start your application I got no Exceptions. Do I have to add something?
Comment 8 Raj Saini CLA 2010-04-19 07:41:49 EDT
Hi Holger,

It is strange. I tried it more than 10 times and I get the exactly same problem.

If it is working for you, do you see the command icon on view tool bar and in view menu? Also did you try deleting your workspace/.metadata?

I tested it with M6 and with the business theme. Are you sure you are using M6 with business theme from M6?

Also let me know your target platform and I will try to re-produce on that.

One more thing though I am not sure it is going to make difference. My dev environment is Ubuntu 10.04 running 64 bit Eclipse.

Regards,

Raj
Comment 9 Holger Staudacher CLA 2010-04-19 10:04:56 EDT
Hey Raj,
I tried it again with M6 and HEAD. I got no errors. I used your command tom make a menuContribution (see bellow) and everything works fine. So, can you provide a bundle which provides the menuContributions as well as the commands? Thanks in advance.

Regards Holger

created menuContribution:
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="toolbar:com.viithiisys.example.view?after=additions">
         <command
               commandId="com.viithiisys.example.open"
               icon="icons/sample3.gif"
               id="aId"
               label="command"
               style="push">
         </command>
      </menuContribution>
   </extension>
Comment 10 Raj Saini CLA 2010-04-19 11:05:30 EDT
Hi Holger,

The example code attached to this application has every thing needed. It has view, commands and command contribution. You should be able to run this as RAP application.
Comment 11 Raj Saini CLA 2010-04-19 11:09:14 EDT
> to this application 

Read "to this bug"
Comment 12 Ivan Furnadjiev CLA 2010-04-30 05:52:00 EDT
Raj, there is no menuContribution in the attached project. With the menuContribution from comment#9 everything is working as expected.
Comment 13 Holger Staudacher CLA 2010-05-03 04:01:03 EDT
Hey Raj, seems that Ivan can't reproduce the bug too. So, I will close the bug now. If you run into the problem again, please feel free to reopen the bug with further information. Thanks.