Multiple Sort Contributions (or Comparators) in Outline [message #1770617] |
Tue, 15 August 2017 08:17 |
|
Hi,
I want to add a contribution to the outline view sorting the elements of the outline differently from the default alphabetic sort.
The following classes are involved in the implementation:
- org.eclipse.xtext.ui.editor.outline.actions.SortOutlineContribution
- org.eclipse.xtext.ui.editor.outline.impl.OutlineFilterAndSorter.IComparator
- my.language.UIModule: binding or configuring the contributions or comparators
I have already written some filter contributions, they are all implemented by subclassing
org.eclipse.xtext.ui.editor.outline.actions.AbstractFilterOutlineContribution. But how to I add a new sort contribution, based on the SortOutlineContribution?
Ideally I want to only write a new comparator. I already did that and using
@Override
public Class<? extends IComparator> bindOutlineFilterAndSorter$IComparator() {
return MyComparator.class;
}
I can replace the default (pure lexicographic) comparator. But I don't want to replace it, I want to add it.
Apparently I need to write a new contribution, since a text, description and icon are required not provided by the comparator only. Unfortunately the SortOutlineContribution doesn't look like being designed for re-use.
For filter contributions, I need to bind them as follows in the UIModule:
public void configureMyFilterOutlineContribution(Binder binder) {
binder.bind(IOutlineContribution.class).annotatedWith(
Names.named("MyFilterOutlineContribution")
).to(MyFilterOutlineContribution.class);
}
Is there something similar for sorting? But where do the text and icon come from then?
What do you recommend?
Cheers,
Jens
|
|
|
|
|
|
Re: Multiple Sort Contributions (or Comparators) in Outline [message #1770622 is a reply to message #1770619] |
Tue, 15 August 2017 08:49 |
|
Actually, the framework does not support multiple comparators, cf org.eclipse.xtext.ui.editor.outline.impl.OutlineFilterAndSorter:
It is possible to add (or remove) filters (plural!), but only one comparator can be set.
So it may be possible to write a special comparator that can be configured by multiple contributions, but I'm not sure its worth the effort (at least for me). So I will stick to simply replacing the original comparator.
But if someone has a better (or already working solution), I would be very interested in that.
Cheers,
Jens
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.37577 seconds