Bug 472806 - Toggle Split Editor commands appear with the same name / don't render parameter any more
Summary: Toggle Split Editor commands appear with the same name / don't render paramet...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.6 M2   Edit
Assignee: Dirk Fauth CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 486258 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-07-16 05:37 EDT by Anton Leherbauer CLA
Modified: 2016-02-03 08:07 EST (History)
8 users (show)

See Also:
Lars.Vogel: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Leherbauer CLA 2015-07-16 05:37:18 EDT
The commands "Toggle Split Editor (Vertical)" and "Toggle Split Editor (Horizontal)" appear under the same name "Toggle Split Editor" in the Window > Editor menu.
In Luna the command names were different.
Comment 1 Markus Keller CLA 2015-07-28 13:19:36 EDT
These parameterized org.eclipse.ui.window.splitEditor commands are added to the menu in org.eclipse.ui.ide.application/plugin.xml.

The contribution has not been touched. The bug must be somewhere in the rendering of parameterized commands (parameter is lost now).
Comment 2 Brian de Alwis CLA 2015-07-30 17:11:10 EDT
This is caused by bug 461026 where HandledContributionItem#updateMenuItem() no longer calls ParameterizedCommand#getName(), which would return the name with a parameterization.

Dirk, my thoughts are that either HandleItemImpl should implement getLocalizedLabel(), and do the right thing, or LocalizationHelper should have some special support for MHandledItems.  I don't know what the right solution is for handling localization of values from an IParameterValues instance.
Comment 3 Dirk Fauth CLA 2015-08-03 15:24:07 EDT
IMHO the correct solution would be to implement the same logic in ParameterizedCommand#getName() to HandledContributionItem, so we don't need to mix up the concepts. Unfortunately the possible values are lost when transforming the Eclipse 3 command to the application model.

In short, the application does not know about the possible parameter values as specified in commandParameter#values.

As long as we have this mix up, we either don't support locale changes at runtime or no parameterized menu items.

A quick fix could be to add a method ParameterizedCommand#getName(String), where the parameter could be the base name (e.g. command.getName()). This would at least fix the parameterized menu items. Only the locale change at runtime would not work for the parameters. For SR1 I think this could be a suitable workaround.

The correct solution should be to introduce the values in the application model aswell. So it could be transferred and inspected in the application model correctly.

Any thoughts on that? The first change could be applied quite easily if introducing new public methods is allowed for SR1. The second modification looks like some bigger change as the application model has to evolve. So I think that is nothing for SR1.
Comment 4 Eclipse Genie CLA 2015-08-04 15:44:49 EDT
New Gerrit change created: https://git.eclipse.org/r/53180
Comment 5 Dirk Fauth CLA 2015-08-04 15:47:42 EDT
(In reply to Brian de Alwis from comment #2)
> Dirk, my thoughts are that either HandleItemImpl should implement
> getLocalizedLabel(), and do the right thing, or LocalizationHelper should
> have some special support for MHandledItems.  I don't know what the right
> solution is for handling localization of values from an IParameterValues
> instance.

I'm against adding special support for MHandledItems in LocalizationHelper. Creating a getLocalizedLabel() for the impls seem to be the right choice. But as I said in the previous comment, we would need the ParameterValues in the application model so we can remove the inspection of ParamterizedCommand.

The patch I provided now is the workaround that might be suitable for SR1.
Comment 6 Brian de Alwis CLA 2015-08-05 12:10:01 EDT
Commands do have MCommandParameters, but we don't do two-way synchronizing of MCommands to the command framework.
Comment 7 Dirk Fauth CLA 2015-08-05 12:17:56 EDT
(In reply to Brian de Alwis from comment #6)
> Commands do have MCommandParameters, but we don't do two-way synchronizing
> of MCommands to the command framework.

But we don't have the parameter values or am I missing something. We would need those in order to also localize those values.
Comment 8 Brian de Alwis CLA 2015-08-06 14:36:16 EDT
(In reply to Dirk Fauth from comment #7)
> (In reply to Brian de Alwis from comment #6)
> > Commands do have MCommandParameters, but we don't do two-way synchronizing
> > of MCommands to the command framework.
> 
> But we don't have the parameter values or am I missing something. We would
> need those in order to also localize those values.

You're right.  The real problem here is the IParameterValues whites independent of the localization framework.
Comment 9 Dirk Fauth CLA 2015-08-06 15:19:25 EDT
The more I think about this the more I wonder.

Why do we use such a heavy-weight mechanism to automatically calculate the menu label via parameters when it would be easier, less error prone and potentially less time consuming if we would specify the correct label in the contribution (extension point or application model)?

What I mean is, do we really need such a mechanism that calculates the label dependent on the parameters or could we switch to specifying the correct label at the contribution itself?
Comment 10 Dirk Fauth CLA 2015-08-13 18:40:20 EDT
Any opinions on this? I personally would prefer to simply specify the correct menu item labels in the plugin.xml rather than modifying the code. I personally never used the automatic way of determining the menu item label via parameter values. But I'm not sure how many people are aware of that feature and are using it.

As it is a regression we should fix it for 4.5.1, especially because possible solutions are identified. I just need some opinions on the solution to merge.
Comment 11 Markus Keller CLA 2015-08-14 08:13:28 EDT
The actual arguments for parameterized commands are not always known upfront.

The menuContribution for the splitEditor command could be hacked to hardcode labels. But this doesn't work in general. See e.g. the org.eclipse.ui.views.showView command, whose parameters are computed dynamically in org.eclipse.ui.internal.registry.ViewParameterValues.

Since the org.eclipse.ui.menus extension point is API, requiring clients to specify a label for each parameterized command contribution would be a breaking change.
Comment 12 Dirk Fauth CLA 2015-08-14 14:04:14 EDT
(In reply to Markus Keller from comment #11)
> The actual arguments for parameterized commands are not always known upfront.
> 
> The menuContribution for the splitEditor command could be hacked to hardcode
> labels. But this doesn't work in general. See e.g. the
> org.eclipse.ui.views.showView command, whose parameters are computed
> dynamically in org.eclipse.ui.internal.registry.ViewParameterValues.
> 
> Since the org.eclipse.ui.menus extension point is API, requiring clients to
> specify a label for each parameterized command contribution would be a
> breaking change.

Good point. Therefore my Gerrit patch should be reviewed, as for me this seems to be the way to go for the dynamic approach.
Comment 13 Brian de Alwis CLA 2015-09-01 16:19:49 EDT
What if we added an IParameterValues2 (or ITranslatableParameterValues) that somehow provided support for translation?
Comment 14 Thomas Schindl CLA 2015-09-01 17:40:00 EDT
(In reply to Brian de Alwis from comment #13)
> What if we added an IParameterValues2 (or ITranslatableParameterValues) that
> somehow provided support for translation?

Don't for get that you now have java8 so you can easily add a a default method like

interface IParameterValue {
   String getName();
   default String getLocalizedName() {
     return getName();
   }
}
Comment 15 Dirk Fauth CLA 2015-09-01 17:52:48 EDT
(In reply to Brian de Alwis from comment #13)
> What if we added an IParameterValues2 (or ITranslatableParameterValues) that
> somehow provided support for translation?

The missing part regarding the new localization mechanism is the ability to change the label value at runtime. Therefore, on changing the locale at runtime, the parameter values won't change.

AFAIK the IParameterValues are not part of the application model and there is no representation in Eclipse 4 for that. Please correct me if I'm wrong, but I didn't find anything.

Since Eclipse 3 doesn't support locale changes at runtime, I don't know what and how you would achieve providing the translation support. Which in fact is the support for locale changes at runtime.
Comment 16 Brian de Alwis CLA 2015-09-01 20:52:12 EDT
I'm wondering if there's any value to providing an alternative form of IParameterValues that could use the TranslationService and Do The Right Thing.
Comment 17 Dirk Fauth CLA 2015-09-02 00:24:18 EDT
(In reply to Brian de Alwis from comment #16)
> I'm wondering if there's any value to providing an alternative form of
> IParameterValues that could use the TranslationService and Do The Right
> Thing.

Since the IParameterValue is implemented by a user, it seems to be the users choice whether to support locale changes at runtime or not. The framework expects the value to use. A change would imply that a user needs to specify translation keys. 

In short, I don't see a reason for adding such a support, nor do I really see a way of doing this.
Comment 19 Lars Vogel CLA 2015-09-08 07:57:25 EDT
(In reply to Eclipse Genie from comment #18)
> Gerrit change https://git.eclipse.org/r/53180 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=14efff7cade7722d24e25afc451676f3513280de

Thanks Dirk. I will test with tomorrows I-Build.
Comment 20 Martin Oberhuber CLA 2015-10-06 03:57:52 EDT
Hi Lars, did the test succeed and can this perhaps be marked Fixed ?

CQ:WIND00-WB4-6171
Comment 21 Lars Vogel CLA 2015-10-06 04:13:57 EDT
(In reply to Martin Oberhuber from comment #20)
> Hi Lars, did the test succeed and can this perhaps be marked Fixed ?
> 
> CQ:WIND00-WB4-6171

Thanks for the reminder Martin. In Build id: N20150927-2000 I see different names, so this is fixed.

@Dirk, should the commands also be available in the Quick Access? I do not see them there. If that was not part of this fix, I think we can go ahead and downport this on to 4.5.2.
Comment 22 Dirk Fauth CLA 2015-10-06 15:52:11 EDT
> @Dirk, should the commands also be available in the Quick Access? I do not
> see them there. If that was not part of this fix, I think we can go ahead
> and downport this on to 4.5.2.

I am not aware of anything regarding the Quick Access. The contributed fix just ensures that the parameter values are added again.
Comment 23 Lars Vogel CLA 2016-01-21 08:15:44 EST
+1 from component lead for downport. 

@Dirk you need another committer to review this for the downport.
Comment 24 Lars Vogel CLA 2016-01-21 08:16:02 EST
*** Bug 486258 has been marked as a duplicate of this bug. ***
Comment 25 Dani Megert CLA 2016-02-03 08:07:33 EST
Too late for 4.5.2.