Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Active Perspective Core Expression(Correct core expression to get the Active Perspective Id in e4)
Active Perspective Core Expression [message #1219011] Fri, 29 November 2013 15:34 Go to next message
Ozgur Cagdas is currently offline Ozgur CagdasFriend
Messages: 32
Registered: May 2013
Member
Hi,

I've already got around this in a different way but is there a core expression to get the Active Perspective Id in pure e4?

I have found below expression online but 'activeWorkbenchWindow.activePerspective' seems not to contain the Active Perspective Id. Is this known to be broken in e4?

<extension point="org.eclipse.core.expressions.definitions">
      <definition id="onValidationPerspective">
         <with variable="activeWorkbenchWindow.activePerspective">
               <equals value="com.sample.perspective1"/>
          </with>
      </definition>
</extension>


I also did try querying the variable with context.get("activeWorkbenchWindow.activePerspective") but it always returns 'null'.

Is there any other core expression that replaces this in e4?

Regards,

Ozgur.
Re: Active Perspective Core Expression [message #1219974 is a reply to message #1219011] Sat, 07 December 2013 20:23 Go to previous messageGo to next message
J. Michael Dean, M.D. is currently offline J. Michael Dean, M.D.Friend
Messages: 218
Registered: July 2009
Senior Member
On 11/29/13, 8:34 AM, Ozgur Cagdas wrote:
> Hi,
>
> I've already got around this in a different way but is there a core
> expression to get the Active Perspective Id in pure e4?
>
> I have found below expression online but
> 'activeWorkbenchWindow.activePerspective' seems not to contain the
> Active Perspective Id. Is this known to be broken in e4?
>
> <extension point="org.eclipse.core.expressions.definitions">
> <definition id="onValidationPerspective">
> <with variable="activeWorkbenchWindow.activePerspective">
> <equals value="com.sample.perspective1"/>
> </with>
> </definition>
> </extension>
>
>
> I also did try querying the variable with
> context.get("activeWorkbenchWindow.activePerspective") but it always
> returns 'null'.
>
> Is there any other core expression that replaces this in e4?
>
> Regards,
>
> Ozgur.
>
Did this ever get answered? I have similar question about how to write
a core expression to define a perspective BEFORE I have actually written
any code - I am working with the application model and would like to
make menu items visible based on perspectives.
Re: Active Perspective Core Expression [message #1221040 is a reply to message #1219974] Mon, 16 December 2013 18:57 Go to previous messageGo to next message
Eric Moffatt is currently offline Eric MoffattFriend
Messages: 118
Registered: July 2009
Senior Member

Pure e4 apps don't have a 'WorkbenchWindow' from which the 'activePerspective' could be determined. In e4 you work against the model;

- Find the MPerspectiveStack using the EModelService's 'findElements' API
- It's 'selectedElement' is the currently active perspective

BTW, if you're doing a pure e4 app you're likely better off to orient your command implementation towards the DI mechanisms (POJO with @CanExecute and @Execute) methods rather than relying on core expressions since they're created through injection and therefore have access everything in the current context.
Re: Active Perspective Core Expression [message #1221291 is a reply to message #1221040] Tue, 17 December 2013 10:19 Go to previous messageGo to next message
Ozgur Cagdas is currently offline Ozgur CagdasFriend
Messages: 32
Registered: May 2013
Member
Eric,

Thanks very much for the direction. However, let's say for Handled Popup Menu Items, if we use @CanExecute rather than Visible-When, this just grays out the menu item instead of totally hiding it. So, I think we cannot achieve the exactly same behaviour.

Also, using @CanExecute means handling this at the command handler level, however, where the required functionality is modifying the visibility of the menu item, this should be handled at a central location regardless of individual handlers I think. So, this is where we need Visible-When. However, I appreciate why you are in favour of POJOs and DI as opposed to using core expressions, so maybe we need a new mechanism to be able to accommodate POJOs as Visible-When handlers. Does that make sense? Either an existing annotation like @CanExecute can be used or a new one (i.e. @IsVisible) can be appointed for this purpose.

I personally feel that current Core Expression definition mechanism is a bit lengthy anyway, so, replacing this with (or extending to) POJOs for Visible-When can also simplify the process.

Regards,

Ozgur.
Re: Active Perspective Core Expression [message #1221444 is a reply to message #1221291] Tue, 17 December 2013 18:13 Go to previous message
Eric Moffatt is currently offline Eric MoffattFriend
Messages: 118
Registered: July 2009
Senior Member

If you want the heuristic to be that the menu / tb item only appears when it's active you could set the model element's 'toBeRendered' flag to whatever value you're going to return from your @CanExecute. I agree though that we might want some more formal pattern for visibility.

The reason we use the complex core expression in the IDE is mostly to allow our menus / tbs and context menus to show the correct state *without* loading / activating any bundles (quite a trick really...Wink. In most RCP apps this is an unnecessary constraint since they usually have far fewer command contributions and there's no reason not to instantiate the handler itself.
Previous Topic:MMenuItem.setSelected is not reflected in the GUI
Next Topic:Reinjection on object removal
Goto Forum:
  


Current Time: Fri Apr 26 05:19:13 GMT 2024

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

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

Back to the top