Skip to content

Add Basic Support for Named Command Handlers #1317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

N1k145
Copy link
Contributor

@N1k145 N1k145 commented Nov 20, 2023

Fixes Regression: #1314

With this a basic support for named handlers is introduced, currently this is for compatibility between ActionHandlers and E4.

Copy link
Contributor

github-actions bot commented Nov 20, 2023

Test Results

   918 files  ±0     918 suites  ±0   1h 8m 34s ⏱️ + 17m 9s
 7 439 tests ±0   7 287 ✅ ±0  152 💤 ±0  0 ❌ ±0 
23 466 runs  ±0  22 958 ✅ ±0  508 💤 ±0  0 ❌ ±0 

Results for commit 9ae6bd7. ± Comparison against base commit 04a9884.

♻️ This comment has been updated with latest results.

@pcdavid
Copy link

pcdavid commented Nov 20, 2023

I fetched this in my env, but any action in a plain text editor gives me stack overflows:

	at org.eclipse.core.commands.Command.setEnabled(Command.java:856)
	at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:933)
	at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:536)
	at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:486)
	at org.eclipse.ui.menus.CommandContributionItem.lambda$2(CommandContributionItem.java:325)
	at org.eclipse.ui.menus.CommandContributionItem.updateCommandProperties(CommandContributionItem.java:329)
	at org.eclipse.ui.menus.CommandContributionItem.lambda$1(CommandContributionItem.java:296)
	at org.eclipse.core.commands.Command$1.run(Command.java:529)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522)
	at org.eclipse.core.commands.Command.lambda$0(Command.java:1002)
	at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:189)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.switchHandler(HandlerServiceHandler.java:269)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.isEnabled(HandlerServiceHandler.java:62)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.switchHandler(HandlerServiceHandler.java:269)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:82)
	at org.eclipse.core.commands.Command.setEnabled(Command.java:856)

@N1k145
Copy link
Contributor Author

N1k145 commented Nov 20, 2023

@pcdavid I can't reproduce the Overflow in the normal text editor, but I found a way by opening the new dialog.
I added a change, hopefully this also fixes the issue for you

@pcdavid
Copy link

pcdavid commented Nov 20, 2023

No more stack overflow with the new version.
I get the "Undo Typing" after a change in the text editor, but when I select any field in the properties view:

java.lang.NullPointerException: Cannot invoke "String.lastIndexOf(int)" because "text" is null
	at org.eclipse.jface.action.LegacyActionTools.removeAcceleratorText(LegacyActionTools.java:717)
	at org.eclipse.jface.commands.ActionHandler.getHandlerName(ActionHandler.java:176)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.getHandlerName(E4HandlerProxy.java:234)
	at org.eclipse.ui.internal.WorkbenchHandlerServiceHandler.getHandlerName(WorkbenchHandlerServiceHandler.java:57)
	at java.base/java.util.Optional.map(Optional.java:260)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.legacyActionLabelSupport(HandledContributionItem.java:343)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.getToolTipText(HandledContributionItem.java:322)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.updateToolItem(HandledContributionItem.java:307)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.update(AbstractContributionItem.java:131)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.update(AbstractContributionItem.java:122)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.lambda$1(HandledContributionItem.java:174)
	at org.eclipse.core.commands.Command$1.run(Command.java:529)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522)
	at org.eclipse.core.commands.Command.lambda$0(Command.java:1002)
	at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:189)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.switchHandler(HandlerServiceHandler.java:269)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:82)
	at org.eclipse.core.commands.Command.setEnabled(Command.java:856)
	at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:933)
	at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:536)
	at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:486)
	at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858)
	at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858)
	at org.eclipse.ui.internal.Workbench.updateActiveWorkbenchWindowMenuManager(Workbench.java:3224)
	at org.eclipse.ui.internal.Workbench.lambda$0(Workbench.java:3206)
	at org.eclipse.jface.bindings.BindingManager.fireBindingManagerChanged(BindingManager.java:901)
	at org.eclipse.jface.bindings.BindingManager.setActiveBindings(BindingManager.java:2181)
	at org.eclipse.jface.bindings.BindingManager.recomputeBindings(BindingManager.java:1742)
	at org.eclipse.jface.bindings.BindingManager.contextManagerChanged(BindingManager.java:691)
	at org.eclipse.core.commands.contexts.ContextManager.fireContextManagerChanged(ContextManager.java:164)
	at org.eclipse.core.commands.contexts.ContextManager.setEventCaching(ContextManager.java:323)
	at org.eclipse.core.commands.contexts.ContextManager.deferUpdates(ContextManager.java:85)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:787)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:686)
	at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97)
	at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.lambda$0(ContributedPartRenderer.java:63)

I checked, I don't have this when using unpatched versions of the platform plug-ins.

@N1k145
Copy link
Contributor Author

N1k145 commented Nov 21, 2023

@pcdavid thanks for checking out, I don't know how I missed that.
I retested now:
Switching between views (E3 and E4)
Properties View
Opening Search and Searching
Opening Various Dialogs
Text Editor
Manifest Editor
(While doing this, I noticed that they have issues reverting the creation of a list, but that was already the case for 2023-03)

@pcdavid
Copy link

pcdavid commented Nov 21, 2023

Thanks! This seems to work much better. I've just launched a subset of our (Sirius) tests suite with that, and most of them are OK (13 failures out of 3095 tests).

It looks like some of the 13 failures could be related.
I get 6 instances of this:

java.lang.AssertionError: Error(s) raised during test : org.eclipse.sirius.tests.unit.diagram.tools.palette.PaletteManagerWithLayersTest
. Log Plugin : org.eclipse.core.runtime
  . Error from plugin:org.eclipse.core.commands, message: Problems occurred when invoking code from plug-in: "org.eclipse.core.commands"., info: org.eclipse.swt.SWTException: Invalid thread access
   . Stack trace: org.eclipse.swt.SWTException: Invalid thread access
	at org.eclipse.swt.SWT.error(SWT.java:4918)
	at org.eclipse.swt.SWT.error(SWT.java:4833)
	at org.eclipse.swt.SWT.error(SWT.java:4804)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:565)
	at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:481)
	at org.eclipse.swt.widgets.Widget.getData(Widget.java:619)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.updateIcons(AbstractContributionItem.java:172)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.update(AbstractContributionItem.java:127)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.update(AbstractContributionItem.java:122)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.lambda$1(HandledContributionItem.java:174)
	at org.eclipse.core.commands.Command$1.run(Command.java:529)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522)
	at org.eclipse.core.commands.Command.lambda$0(Command.java:1002)
	at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:189)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.handlerChanged(E4HandlerProxy.java:118)
	at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77)
	at org.eclipse.jface.commands.ActionHandler.lambda$0(ActionHandler.java:85)
	at org.eclipse.jface.action.AbstractAction.firePropertyChange(AbstractAction.java:52)
	at org.eclipse.jface.action.AbstractAction.firePropertyChange(AbstractAction.java:75)
	at org.eclipse.gmf.runtime.common.ui.action.actions.global.GlobalUndoAction.access$0(GlobalUndoAction.java:1)
	at org.eclipse.gmf.runtime.common.ui.action.actions.global.GlobalUndoAction$1.propertyChange(GlobalUndoAction.java:133)
	at org.eclipse.jface.action.AbstractAction.firePropertyChange(AbstractAction.java:52)
	at org.eclipse.jface.action.AbstractAction.firePropertyChange(AbstractAction.java:75)
	at org.eclipse.jface.action.Action.setText(Action.java:615)
	at org.eclipse.ui.operations.OperationHistoryActionHandler.update(OperationHistoryActionHandler.java:456)
	at org.eclipse.gmf.runtime.common.ui.action.actions.global.GlobalUndoAction.refresh(GlobalUndoAction.java:259)
	at org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler.historyNotification(AbstractActionHandler.java:603)
	at org.eclipse.core.commands.operations.DefaultOperationHistory$2.run(DefaultOperationHistory.java:876)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.notifyListeners(DefaultOperationHistory.java:865)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.notifyAdd(DefaultOperationHistory.java:920)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.add(DefaultOperationHistory.java:196)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513)
	at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:203)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:160)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:214)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.actions.LayersActivationAction$1.run(LayersActivationAction.java:69)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)

  . Error from plugin:org.eclipse.core.commands, message: Problems occurred when invoking code from plug-in: "org.eclipse.core.commands"., info: org.eclipse.swt.SWTException: Invalid thread access
   . Stack trace: org.eclipse.swt.SWTException: Invalid thread access
	at org.eclipse.swt.SWT.error(SWT.java:4918)
	at org.eclipse.swt.SWT.error(SWT.java:4833)
	at org.eclipse.swt.SWT.error(SWT.java:4804)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:565)
	at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:481)
	at org.eclipse.swt.widgets.Widget.getData(Widget.java:619)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.updateIcons(AbstractContributionItem.java:172)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.update(AbstractContributionItem.java:127)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.update(AbstractContributionItem.java:122)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.lambda$1(HandledContributionItem.java:174)
	at org.eclipse.core.commands.Command$1.run(Command.java:529)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522)
	at org.eclipse.core.commands.Command.lambda$0(Command.java:1002)
	at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:189)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.handlerChanged(E4HandlerProxy.java:118)
	at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77)
	at org.eclipse.jface.commands.ActionHandler.lambda$0(ActionHandler.java:85)
	at org.eclipse.jface.action.AbstractAction.firePropertyChange(AbstractAction.java:52)
	at org.eclipse.jface.action.AbstractAction.firePropertyChange(AbstractAction.java:75)
	at org.eclipse.gmf.runtime.common.ui.action.actions.global.GlobalUndoAction.access$0(GlobalUndoAction.java:1)
	at org.eclipse.gmf.runtime.common.ui.action.actions.global.GlobalUndoAction$1.propertyChange(GlobalUndoAction.java:133)
	at org.eclipse.jface.action.AbstractAction.firePropertyChange(AbstractAction.java:52)
	at org.eclipse.jface.action.AbstractAction.firePropertyChange(AbstractAction.java:75)
	at org.eclipse.jface.action.Action.setToolTipText(Action.java:635)
	at org.eclipse.ui.operations.OperationHistoryActionHandler.update(OperationHistoryActionHandler.java:457)
	at org.eclipse.gmf.runtime.common.ui.action.actions.global.GlobalUndoAction.refresh(GlobalUndoAction.java:259)
	at org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler.historyNotification(AbstractActionHandler.java:603)
	at org.eclipse.core.commands.operations.DefaultOperationHistory$2.run(DefaultOperationHistory.java:876)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.notifyListeners(DefaultOperationHistory.java:865)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.notifyAdd(DefaultOperationHistory.java:920)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.add(DefaultOperationHistory.java:196)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513)
	at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:203)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:160)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:214)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.actions.LayersActivationAction$1.run(LayersActivationAction.java:69)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)

  . Error from plugin:org.eclipse.core.commands, message: Problems occurred when invoking code from plug-in: "org.eclipse.core.commands"., info: org.eclipse.swt.SWTException: Invalid thread access
   . Stack trace: org.eclipse.swt.SWTException: Invalid thread access
	at org.eclipse.swt.SWT.error(SWT.java:4918)
	at org.eclipse.swt.SWT.error(SWT.java:4833)
	at org.eclipse.swt.SWT.error(SWT.java:4804)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:565)
	at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:481)
	at org.eclipse.swt.widgets.Widget.getData(Widget.java:619)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.updateIcons(AbstractContributionItem.java:172)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.update(AbstractContributionItem.java:127)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.update(AbstractContributionItem.java:122)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.lambda$1(HandledContributionItem.java:174)
	at org.eclipse.core.commands.Command$1.run(Command.java:529)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522)
	at org.eclipse.core.commands.Command.lambda$0(Command.java:1002)
	at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:189)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.handlerChanged(E4HandlerProxy.java:118)
	at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77)
	at org.eclipse.jface.commands.ActionHandler.lambda$0(ActionHandler.java:85)
	at org.eclipse.jface.action.AbstractAction.firePropertyChange(AbstractAction.java:52)
	at org.eclipse.jface.action.AbstractAction.firePropertyChange(AbstractAction.java:75)
	at org.eclipse.jface.action.Action.setText(Action.java:615)
	at org.eclipse.gmf.runtime.common.ui.action.actions.global.GlobalUndoAction.refresh(GlobalUndoAction.java:261)
	at org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler.historyNotification(AbstractActionHandler.java:603)
	at org.eclipse.core.commands.operations.DefaultOperationHistory$2.run(DefaultOperationHistory.java:876)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.notifyListeners(DefaultOperationHistory.java:865)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.notifyAdd(DefaultOperationHistory.java:920)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.add(DefaultOperationHistory.java:196)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513)
	at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:203)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:160)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:214)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.actions.LayersActivationAction$1.run(LayersActivationAction.java:69)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)


@N1k145
Copy link
Contributor Author

N1k145 commented Nov 21, 2023

@pcdavid I added a DisplayAsyncExec around the update, this should solve the issue.
Somehow you changed the handler on a background thread, but now the menu/toolitem reacts on those changes and needs to do this in the GUI Thread

@pcdavid
Copy link

pcdavid commented Nov 21, 2023

Thanks, I'll test this version later.
Not sure exactly what's hapenning in the code in question, it's old GMF Runtime code. Maybe it's technically wrong, but all I know is that it used to work.

@N1k145
Copy link
Contributor Author

N1k145 commented Nov 21, 2023

Not sure exactly what's hapenning in the code in question, it's old GMF Runtime code. Maybe it's technically wrong, but all I know is that it used to work.

I did not want to say that this is wrong, that I don't know either. But yes, it should work afterwards.

@pcdavid
Copy link

pcdavid commented Nov 21, 2023

Not sure exactly what's hapenning in the code in question, it's old GMF Runtime code. Maybe it's technically wrong, but all I know is that it used to work.

I did not want to say that this is wrong, that I don't know either.

I understand. Sorry if my wording sounded harsh, that was not the intent.

@N1k145
Copy link
Contributor Author

N1k145 commented Nov 21, 2023

Not sure exactly what's hapenning in the code in question, it's old GMF Runtime code. Maybe it's technically wrong, but all I know is that it used to work.

I did not want to say that this is wrong, that I don't know either.

I understand. Sorry if my wording sounded harsh, that was not the intent.

No offense taken. I just hope that we can get this fixed while still supporting E4 Handlers.

@merks can you take a look at the version number complains from Jenkins? I don't understand what is needed there as it looks like Jenkins wants an increase to the version that is already set.

@pcdavid
Copy link

pcdavid commented Nov 22, 2023

FYI, I don't see the "Invalid thread access" anymore with the latest version of the PR (e5ee308).

@N1k145 N1k145 marked this pull request as ready for review November 22, 2023 12:42
@pcdavid
Copy link

pcdavid commented Nov 22, 2023

I suppose there is no chance to get this in 2023-12 even if the code itself is reviewed and accepted soon?

@mickaelistria
Copy link
Contributor

I suppose there is no chance to get this in 2023-12 even if the code itself is reviewed and accepted soon?

That's right. The regression is not new and the issue is not critical enough to fix it in a release candidate.

@mickaelistria mickaelistria added this to the 4.31 M1 milestone Nov 23, 2023
@N1k145 N1k145 force-pushed the issue1314 branch 2 times, most recently from 84b06e7 to 6985a2a Compare December 1, 2023 11:47
@BeckerWdf
Copy link
Contributor

What's the state of this change. Master is open again. Can this be merged?

@N1k145
Copy link
Contributor Author

N1k145 commented Dec 1, 2023

@BeckerWdf From my side it should work, but somebody should look at the code and maybe test again.
Also with the failing tests I'm not sure if they are related.

@BeckerWdf
Copy link
Contributor

Also with the failing tests I'm not sure if they are related.
Test failures are not related and already reported in #1351

@BeckerWdf
Copy link
Contributor

BeckerWdf commented Dec 4, 2023

From my side it should work, but somebody should look at the code and maybe test again.

@pcdavid or @mickaelistria: Do you want to test again?

@pcdavid
Copy link

pcdavid commented Dec 4, 2023

From my side it should work, but somebody should look at the code and maybe test again.

@pcdavid or @mickaelistria: Do you want to test again?

I ran some tests (both basic manual tests and a subset of our test suite) and it seems OK.
Thanks.

@BeckerWdf
Copy link
Contributor

Can we merge this @mickaelistria ?

Copy link
Contributor

@mickaelistria mickaelistria left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see nothing wrong with this change now; however there is 1 question/proposal that popped out of my head which I think it worth discussing before merging.

*
* @return name of the Handler
*/
String getHandlerName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I already asked this, but was it considered to add this as a default method in IHandler directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I implemented this my intention was to not add it to the IHandler interface directly as this is a somewhat niche use case and not supported everywhere where the IHandler is used.

What I think is open for discussion is that if this feature is something that should be generally supported, then also a proper E4 support is needed with an annotation (Named?) that provides this name.

But this should probably be handled in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this should probably be handled in a separate PR.

As this is API, we unfortunately won't be able to roll back if we add it.
As I'm looking more to #1314, I'm wondering why do we need labels on handlers here. Don't we already have a name on the command? Or is it that some operations have handlers without commands? (sorry for joining the discussion late and probably bugging with questions that were already considered)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handler can override the label from the command in some special cases, only in e3.

In E4 this is not possible, and we switched the Undo Redo handler to an E4 based handler bridge. (iirc)

There are a few cases where this is used and one case is the undo/redo. So the label basically says "Undo Typing" and not only "Undo" which is the name of the command.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, got it. And indeed, if we want some dynamic label, only the handler can provide it.
However, I don't think it's so much of a "niche use-case" or at least that it's a use-case that we want to keep as "niche". I find it interesting that handlers enrich the action label to make it more precise. It's a good practice that should be kind of recommended.
So I think it's better to make it a new default method to encourage and make it easier for implementors in enriching the label.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should this stay in a separate interface as it is optional?

default methods are optional to implement as well.

We don't strongly care about implementation here, we care more about APIs (which we can't easily change later).
I would still recommend that you make it a new default method in IHandler if possible, because it actually seems to provide more value than the current extension interface.
While you do that, I think it'd be better to remame the method to getHandlerLabel() because the name can be interpreted as an "id" which is not the case here. (Thinking more about it, it could be just getLabel() but there would be too high risks of conflicts so let's stick to getHandlerLabel(), and this makes me think that we might instead of a new API it might be possible to try relying on ILabelProvider and adapters, but this would be more complicated for no strong value and also less encouraging than a new default method in API, so let's stick to a default method).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the method like you suggested but this seems to be classified as an API breaking change, so I have to bump the version to 4.0.0.

How should I handle the other dependent projects that do not require the new method?
(3.50,5.0.0] or bump the min version also 4.0.0?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add an API filter. Only the minor version should be increased. All hell will break loose if you increment the major version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@merks Thanks, I already noticed this. I will figure out how this works with an API filter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a quick fix that does the work for you. 👍

*
* @return name of the Handler
*/
String getHandlerName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should this stay in a separate interface as it is optional?

default methods are optional to implement as well.

We don't strongly care about implementation here, we care more about APIs (which we can't easily change later).
I would still recommend that you make it a new default method in IHandler if possible, because it actually seems to provide more value than the current extension interface.
While you do that, I think it'd be better to remame the method to getHandlerLabel() because the name can be interpreted as an "id" which is not the case here. (Thinking more about it, it could be just getLabel() but there would be too high risks of conflicts so let's stick to getHandlerLabel(), and this makes me think that we might instead of a new API it might be possible to try relying on ILabelProvider and adapters, but this would be more complicated for no strong value and also less encouraging than a new default method in API, so let's stick to a default method).

@N1k145 N1k145 force-pushed the issue1314 branch 4 times, most recently from e0657d7 to b1c44ec Compare January 30, 2024 12:07
/**
* Called by the framework to allow the handler to specify a label.
*
* @return name of the Handler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to document here, "can be null`

@@ -90,4 +91,14 @@ public interface IHandler {
* performed.
*/
void removeHandlerListener(IHandlerListener handlerListener);

/**
* Called by the framework to allow the handler to specify a label.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Called by" is an implementation detail. The Javadoc should state more the goal of this method per se. "Return the label for this handler. The handler can implement this method to provide a more dynamic label according to the actual action it performend. When returning null, callers may instead use the invoking command label or a generic label."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hint, I updated the java doc

Copy link
Contributor

@mickaelistria mickaelistria left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. This version looks good to me, as it's very simple for clients to leverage it and the API "cost" is pretty small.

Fixes Regression: eclipse-platform#1314

With this a basic support for named handlers is introduced, currently this is for compatibility between ActionHandlers and E4.
@N1k145
Copy link
Contributor Author

N1k145 commented Jan 31, 2024

@mickaelistria @BeckerWdf Thank you for taking a look and for the review.
I don't have write access, so feel free to merge this PR.
With the last push, I only fixed a typo in the java doc

@mickaelistria mickaelistria merged commit 225925a into eclipse-platform:master Jan 31, 2024
@mickaelistria
Copy link
Contributor

Thank you

@merks
Copy link
Contributor

merks commented Jan 31, 2024

@mickaelistria

I have these errors in my workspace now:

image

It should be 3.12, right? It's an API change so there should be an version increment, right?

@mickaelistria
Copy link
Contributor

@merks You're right. But aren't API tools supposed to run in the CI builds (cc @laeubi )? I usually only checks the CI executions + a code review before merging. I was expecting such error would surface automatically.
But it did not...

@merks
Copy link
Contributor

merks commented Jan 31, 2024

No problem, I'm creating a PR.

@mickaelistria
Copy link
Contributor

Or maybe the issue was just that hte patch wasn't on top of master and the auto-rebase is what made the error surface
@N1k145 Can you please verify the issue found by @merks and fix the version appropriately?

@merks
Copy link
Contributor

merks commented Jan 31, 2024

This should address the issue:

#1602

@N1k145
Copy link
Contributor Author

N1k145 commented Jan 31, 2024

@mickaelistria the API check did not want me to increase the version, as we ignored the change. And the commit before this one increased the version. So bad luck in merging and not being up to date with master

@N1k145 N1k145 deleted the issue1314 branch January 31, 2024 13:41
deepika-u added a commit to deepika-u/eclipse.platform.ui that referenced this pull request Aug 13, 2024
deepika-u added a commit to deepika-u/eclipse.platform.ui that referenced this pull request Oct 23, 2024
deepika-u added a commit to deepika-u/eclipse.platform.ui that referenced this pull request Oct 24, 2024
Fixes eclipse-platform#1317

Moving TabFolderLayout into SWT. Incorporated review comments.

Fixes eclipse-platform/eclipse.platform.swt#1317
deepika-u added a commit to deepika-u/eclipse.platform.ui that referenced this pull request Oct 24, 2024
Fixes eclipse-platform#1317

Moving TabFolderLayout into SWT. Incorporated review comments.

Fixes eclipse-platform/eclipse.platform.swt#1317
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants