Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » View construction without making them active first
View construction without making them active first [message #1828958] Tue, 23 June 2020 08:33 Go to next message
Ari Hannula is currently offline Ari HannulaFriend
Messages: 2
Registered: June 2020
Junior Member
Hello, I have a problem in the following situation:

I have an Eclipse 4 plugin, where I have a custom perspective with many view Parts and Part Stacks etc. When the perspective is loaded, many views are brought visible but many are also stacked under those visible view parts. Those (hidden) views use ESelectionService and are supposed to be listening to other views' selections. Those selection events fill the views with data.

The problem is that since the views are hidden under the stack of other (visible) views, their constructors are not run when the perspective is activated, therefore any events coming from ESelectionService is not working (since the ESelectionService.addSelectionListener() is called in the @PostConstruct). So the views are empty when first activated. Of course, after I click those views and make them visible, constructor is called and all is fine after that. In my fragment.e4xmi the Parts have To Be Rendered and Visible checked.

How could I make those views be constructed even when they are not first clicked visible, so that they will always get the selection events? Or is that even possible? Or maybe there is some workaround?

Re: View construction without making them active first [message #1828972 is a reply to message #1828958] Tue, 23 June 2020 13:24 Go to previous messageGo to next message
Rolf Theunissen is currently offline Rolf TheunissenFriend
Messages: 191
Registered: April 2012
Senior Member
Instead of start listing to selection changes from the start of the workbench, you could get the active selection when the view is opened, i.e. ESelectionService.getSelection()

But you are using injection, instead of listening to selection changes you should be able to have the selection injected for you:
@Inject
private void setSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) MyClass selection) {
    this.selection = selection;
}


If you really want to have the non-visible parts created, you have to take a look at EPartService#showPart(myPart, PartState.CREATE);
Re: View construction without making them active first [message #1829053 is a reply to message #1828972] Wed, 24 June 2020 11:26 Go to previous message
Ari Hannula is currently offline Ari HannulaFriend
Messages: 2
Registered: June 2020
Junior Member
Yes thank you for the tip. Now the code is cleaner and the views always get the selection data when opened.
Previous Topic:Different look and feel in Linux
Next Topic:IStatusLineManger
Goto Forum:
  


Current Time: Wed Apr 21 03:02:55 GMT 2021

Powered by FUDForum. Page generated in 0.01776 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top