Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Command on Tree Editor
Command on Tree Editor [message #1018695] Thu, 14 March 2013 10:20 Go to next message
Valerian Merkling is currently offline Valerian MerklingFriend
Messages: 71
Registered: May 2011
Member
Hi !

Right now, i've my simple editor generated from my ecore mode, which works fine.

One of the Eclass of my model have an operation, and i would like to be able to run it from the editor.

What is the best way to do it ?

My problem

I tried to just copy-past code from on of my old GMF project with another custom action, but there's something wrong here :

<extension
      id="%extension.id.0"
      point="org.eclipse.ui.popupMenus">
   <objectContribution
         adaptable="false"
         id="test.diagram.ui.objectContribution.RouteEditPart1"
         objectClass="test.diagram.edit.parts.RouteEditPart">
      <action


Now, i've no more edit.parts classes, so what am I supposed to use for
objectClass="test.diagram.edit.parts.RouteEditPart" ?

Thanks for your help !

Regards,

Valerian

Re: Command on Tree Editor [message #1018738 is a reply to message #1018695] Thu, 14 March 2013 11:40 Go to previous messageGo to next message
Eclipse UserFriend
recently I did it with a command:

<extension
point="org.eclipse.ui.commands">
<command
categoryId="categoryID"
description="Description"
id="yourCommandID"
name="Name">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="your.CommandHandler"
commandId="yourCommandID">
<enabledWhen>
<with
variable="selection">
<iterate
operator="or">
<instanceof

value="org.eclipse.emf.codegen.ecore.genmodel.GenClass">
</instanceof>
</iterate>
</with></enabledWhen>
</handler>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command
commandId="yourCommandID"
label="Customize generated EMF Code"
style="push">
<visibleWhen
checkEnabled="false">
<count
value="1">
</count>
</visibleWhen>
</command>
</menuContribution>
</extension>

This makes the popup available for a selected GenClass in the genmodel
tree editor. Just take the desired generated model class as the value
for instanceof and not the EditPart class.

best regards,
Gilbert

Valerian Merkling wrote:
> Hi !
>
> Right now, i've my simple editor generated from my ecore mode, which
> works fine.
>
> One of the Eclass of my model have an operation, and i would like to be
> able to run it from the editor.
>
> What is the best way to do it ?
> My problem
> I tried to just copy-past code from on of my old GMF project with
> another custom action, but there's something wrong here :
>
> <extension
> id="%extension.id.0"
> point="org.eclipse.ui.popupMenus">
> <objectContribution
> adaptable="false"
> id="test.diagram.ui.objectContribution.RouteEditPart1"
> objectClass="test.diagram.edit.parts.RouteEditPart">
> <action
>
> Now, i've no more edit.parts classes, so what am I supposed to use for
> objectClass="test.diagram.edit.parts.RouteEditPart" ?
>
> Thanks for your help !
>
> Regards,
> Valerian
>
>
Re: Command on Tree Editor [message #1018771 is a reply to message #1018738] Thu, 14 March 2013 12:47 Go to previous messageGo to next message
Valerian Merkling is currently offline Valerian MerklingFriend
Messages: 71
Registered: May 2011
Member
Nice ! It works, thank you very much !

[Updated on: Thu, 14 March 2013 13:27]

Report message to a moderator

Re: Command on Tree Editor [message #1018887 is a reply to message #1018695] Thu, 14 March 2013 16:11 Go to previous messageGo to next message
Valerian Merkling is currently offline Valerian MerklingFriend
Messages: 71
Registered: May 2011
Member
Ok there still is a problem i can't solve ...

How can I, in my command, access to my model ? I need to read some properties of my EObjects.

Re: Command on Tree Editor [message #1019282 is a reply to message #1018887] Fri, 15 March 2013 11:10 Go to previous message
Eclipse UserFriend
In your handler:

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
if(currentSelection instanceof IStructuredSelection){
Object firstElement = ((IStructuredSelection)
currentSelection).getFirstElement();
if(firstElement instanceof GenClass){
process((GenClass) firstElement);
}
}
return null;
}

Instead of GenClass you take your domain class.

best regards,
Gilbert

Valerian Merkling wrote:
> Ok there still is a problem i can't solve ...
>
> How can I, in my command, access to my model ? I need to read some
> properties of my EObjects.
>
>
Previous Topic:running the Library example under RAP 1.5 and org.JSON package not found
Next Topic:[CDO] Derby - Table/View 'CDO_PROPERTIES' does not exist
Goto Forum:
  


Current Time: Mon Dec 22 18:02:51 GMT 2014

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

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