Bug #823

RCP: 0.7.5, when giving the focus to some editor parts, the toolbar and the RCP "Tools" menu don't update themselves leading to some null exceptions

Added by Sebastien Jacquot over 5 years ago. Updated over 4 years ago.

Status:Feedback Start date:05/21/2014
Priority:Normal Due date:
Assignee:- % Done:

90%

Category:UI / Interaction Spent time: -
Target version:TXM 0.7.7

Description

When giving the focus to some editor parts, the toolbar and the RCP "Tools" menu don't update themselves leading to some null exceptions.
Step to reproduce:
1) create a partition, e.g. "VOEUX_text_annee"
2) left click on this partition and create some Specificities
3) the new Specificities tab opens and becomes active
4) click on the toolbar button linked to the partition : Specificities, CA, etc. (or through the "Tools" menu)
5) it raises an exception

It also occurs when manually clicking in an editor and after it became active.

log:

org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:243)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:224)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
    at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:167)
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
    at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
    at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:850)
    at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:743)
    at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$7(HandledContributionItem.java:727)
    at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:662)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.txm.rcpapplication.Application.run(Application.java:134)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: java.lang.NullPointerException
    at org.txm.rcpapplication.commands.function.ComputeCorrespondanceAnalysis.execute(ComputeCorrespondanceAnalysis.java:112)
    at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290)
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
    at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
    ... 42 more
no selection
no selection
no selection

Solution:
Change the way to get the active selection and replace

(IStructuredSelection) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();

with
(IStructuredSelection) HandlerUtil.getCurrentSelection(event);

The old way could not manage : active editor with no selection and view with active selection at the same time

Warning: be carefull with TextSelection that depends on the current editor

Validation test

Test all Functions and Links commands that uses a selection

MD: OK Linux64

History

#1 Updated by Matthieu Decorde about 5 years ago

  • % Done changed from 0 to 80

I changed the way to get the active selection
(IStructuredSelection) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
>>>
(IStructuredSelection) HandlerUtil.getCurrentSelection(event);

The old way could not manage : active editor with no selection and view with active selection at the same time

#2 Updated by Matthieu Decorde about 5 years ago

  • Description updated (diff)

#3 Updated by Matthieu Decorde about 5 years ago

  • Description updated (diff)

#4 Updated by Matthieu Decorde about 5 years ago

  • Target version changed from TXM 0.7.7 to TXM 0.7.6

#5 Updated by Matthieu Decorde about 5 years ago

  • Description updated (diff)

#6 Updated by Sebastien Jacquot about 5 years ago

  • Target version changed from TXM 0.7.6 to TXM 0.7.7

#7 Updated by Matthieu Decorde almost 5 years ago

  • Status changed from New to Feedback

#8 Updated by Sebastien Jacquot almost 5 years ago

If I understand well, this issue has been fixed like this: the selection mechanism has been changed so when clicking on a main tool bar button even if the Corpus view has not the focus (is not active), the command gets the selected node result from the tree?
Actually, shouldn't it be fixed by updating the main tool bar/main menu when clicking outside of the corpus view and by removing the buttons/menus linked to the tree node selection?
At this moment, there are 2 different behaviors according to the type of editor becoming active:
- clicking on a text editor, as groovy script, or a table editor, as Index, etc. => updates the main tool bar/menu and remove the entries linked to the tree node selection
- clicking on a chart editor or a Specificities table editor => does not remove the main tool bar/menu entries linked to the tree node selection

See also: https://forge.cbp.ens-lyon.fr/redmine/issues/1005

#9 Updated by Matthieu Decorde over 4 years ago

  • Description updated (diff)

#10 Updated by Matthieu Decorde over 4 years ago

  • Description updated (diff)
  • % Done changed from 80 to 90

Also available in: Atom PDF