|
Re: Command on Tree Editor [message #1018738 is a reply to message #1018695] |
Thu, 14 March 2013 11:40 |
Eclipse User |
|
|
|
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 #1019282 is a reply to message #1018887] |
Fri, 15 March 2013 11:10 |
Eclipse User |
|
|
|
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.
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02897 seconds