add a popup to table viewer [message #61193] |
Tue, 20 November 2007 07:13  |
Eclipse User |
|
|
|
Hi
I am willing to add a popup menu filled from the plugin extensions to
a table viewer.
I get a NPE when running in the file
org.eclipse.ui.internal.ObjectContributorManager in this piece of code :
// Optimization: if n==1 (or if all objects are of the same
class), then the common class is the object's class,
// and the common adapters are the adapters cached for that
class in the adapter manager
// See bug 177592 for more details.
if (allSameClass(objects)) {
Class clazz = objects.get(0).getClass();
commonAdapters.addAll(Arrays.asList(Platform.getAdapterManag er().computeAdapterTypes(clazz)));
List result = new ArrayList(1);
result.add(clazz);
return result;
}
the NPE comes from code objects.get(0) cause it has a null object at index 0
The menu was registered on the table viewer like this :
MenuManager ordersMenuManager = new MenuManager("#orders");
//$NON-NLS-1$
ordersMenuManager.setRemoveAllWhenShown(false);
ordersMenuManager.add(new
Separator(IWorkbenchActionConstants.MB_ADDITIONS));
Menu menu =
ordersMenuManager.createContextMenu(ordersViewer.getControl( ));
ordersViewer.getControl().setMenu(menu);
getSite().registerContextMenu(ordersMenuManager, ordersViewer);
ant in the plugin file I have the following popup extension :
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="false"
id="at.niwa.webhosting.db.mappings.TOrder"
objectClass="at.niwa.webhosting.db.mappings.TOrder">
<action
class=" at.niwa.webhosting.admintool.actions.ModifyOrderActionDelega te "
enablesFor="1"
icon="icons/sample.gif"
id=" at.niwa.webhosting.admintool.actions.ModifyOrderActionDelega te "
label="Modify"
menubarPath="additions"
tooltip="Modify tooltip">
</action>
</objectContribution>
</extension>
Hope the info is enough to help me
Thanks,
Val
|
|
|
|
|
|
Re: add a popup to table viewer [message #62768 is a reply to message #62334] |
Sun, 25 November 2007 05:26  |
Eclipse User |
|
|
|
Hi
I just found out my problem is, I use the table viewer on an editor
part which has no input attached. After I have stored the input on the
editor setInput(input) the popup showed and no NPE.
May I close the bug I created for this? I do not know if this behavior
is the right one, to have a NPE on an open popup when u do not set the
input of the editor (but still u must not have an editor wich have no
inputEditor saved :) )
It would be much easier to not have an editor showed when the input is
null, like this we would not get to such peculiar behaviour.
Cheers,
Val
Val wrote:
> I have added bug 210693 to reproduce the error on demo application
>
> Benjamin Muskalla wrote:
>> Hi Val,
>>
>> it would be great if you can file a bug for this issue with a little
>> snippet the reproduce. I think the best way is to get the demo
>> application, change it to reproduce the NPE and attach the diff to the
>> according bugzilla entry.
>>
>> Thanks!
>>
>> Greets
>> Benny
>>
>> Val wrote:
>>> Hi
>>>
>>> I am willing to add a popup menu filled from the plugin extensions to
>>> a table viewer.
>>> I get a NPE when running in the file
>>> org.eclipse.ui.internal.ObjectContributorManager in this piece of code :
>>>
>>> // Optimization: if n==1 (or if all objects are of the same
>>> class), then the common class is the object's class,
>>> // and the common adapters are the adapters cached for that
>>> class in the adapter manager
>>> // See bug 177592 for more details.
>>> if (allSameClass(objects)) {
>>>
>>> Class clazz = objects.get(0).getClass();
>>>
>>> commonAdapters.addAll(Arrays.asList(Platform.getAdapterManag er().computeAdapterTypes(clazz)));
>>>
>>> List result = new ArrayList(1);
>>> result.add(clazz);
>>> return result;
>>> }
>>>
>>> the NPE comes from code objects.get(0) cause it has a null object at
>>> index 0
>>>
>>> The menu was registered on the table viewer like this :
>>>
>>> MenuManager ordersMenuManager = new MenuManager("#orders");
>>> //$NON-NLS-1$
>>> ordersMenuManager.setRemoveAllWhenShown(false);
>>> ordersMenuManager.add(new
>>> Separator(IWorkbenchActionConstants.MB_ADDITIONS));
>>> Menu menu =
>>> ordersMenuManager.createContextMenu(ordersViewer.getControl( ));
>>> ordersViewer.getControl().setMenu(menu);
>>> getSite().registerContextMenu(ordersMenuManager, ordersViewer);
>>>
>>> ant in the plugin file I have the following popup extension :
>>>
>>> <extension
>>> point="org.eclipse.ui.popupMenus">
>>> <objectContribution
>>> adaptable="false"
>>> id="at.niwa.webhosting.db.mappings.TOrder"
>>> objectClass="at.niwa.webhosting.db.mappings.TOrder">
>>> <action
>>>
>>> class=" at.niwa.webhosting.admintool.actions.ModifyOrderActionDelega te "
>>> enablesFor="1"
>>> icon="icons/sample.gif"
>>>
>>> id=" at.niwa.webhosting.admintool.actions.ModifyOrderActionDelega te "
>>> label="Modify"
>>> menubarPath="additions"
>>> tooltip="Modify tooltip">
>>> </action>
>>> </objectContribution>
>>> </extension>
>>>
>>> Hope the info is enough to help me
>>>
>>> Thanks,
>>> Val
|
|
|
Powered by
FUDForum. Page generated in 0.03242 seconds