Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » howto: "The chosen operation is not currently available"
howto: "The chosen operation is not currently available" [message #420857] Mon, 14 July 2008 14:19 Go to next message
Rene Ladan is currently offline Rene LadanFriend
Messages: 51
Registered: July 2009
Member
This is a multi-part message in MIME format.
--------------080507040705070404000408
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

how to avoid the message "The chosen operation is not currently available" when
selecting an action from a self-defined menu extension? From the GMF archives
I understand it has something to do with the interface which the class listed
in plugin->extension->action->@class in plugin.xml implements, i.e. that it has
to implement the correct interface. I tried IActionDelegate, IObjectActionDelegate,
and IEditorActionDelegate without success.

The backtrace of the error message says that it cannot find
org.eclipse.emf.workspace.AbstractEMFOperation, but that
package is imported by the invoked class.

I've attached the plugin.xml and the invoked class.

Thanks,
Rene

--------------080507040705070404000408
Content-Type: text/xml;
name="plugin.xml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="plugin.xml"

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
id="meta.custom.contribution1"
objectClass="org.eclipse.emf.ecore.EObject">
<menu
id="meta.custom.menu1"
label="Meta Actions"
path="additions">
<separator
name="group1">
</separator>
</menu>
<action
class="meta.custom.MetaEditor"
enablesFor="1"
id="meta.custom.newAction"
label="Analyze"
menubarPath="meta.custom.menu1/group1">
</action>
</objectContribution>
</extension>
</plugin>

--------------080507040705070404000408
Content-Type: text/plain;
name="MetaEditor.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="MetaEditor.java"

package meta.custom;

import java.io.IOException;

import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.OperationHistoryFactory ;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.actions.ActionDelegate;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.workspace.AbstractEMFOperation;
import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;

/**
* This class provides the hooks between the analyze/transformation/PISA engines and the EMF code.
* @author rladan
*/
public class MetaEditor extends ActionDelegate implements IObjectActionDelegate {

/**
* @see ActionDelegate
*/
public MetaEditor() {
super();
}
/** This contains the current selection of the editor. */
private EObject sel;

private TransactionalEditingDomain editingDomain = WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain() ;

private Variator var = new Variator();

/**
* @see IActionDelegate#run(IAction)
*/
@Override
public void run(IAction action) {
// Find out what is selected. Note that child nodes are *not*
// automatically selected when their parents are selected.
final AbstractEMFOperation aeo = new AbstractEMFOperation(this.editingDomain, "domain") {
@Override
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) {
try {
MetaEditor.this.var.doVariate(MetaEditor.this.sel);
} catch (IOException ioe) {
ioe.printStackTrace();
}
return null;
}
};
try {
OperationHistoryFactory.getOperationHistory().execute(aeo, null, null);
} catch (final ExecutionException ee) {
ee.printStackTrace();
}
}

/**
* <!--begin-user-doc-->
* method from org.eclipse.emf.ecore.action.CreateDynamicInstanceAction.jav a via post from Ed Merks
* <!--end-user-doc-->
* @see IActionDelegate#selectionChanged(IAction, ISelection)
*/
@Override
public void selectionChanged(IAction action, ISelection selection) {
//activated by selecting "Analyzed" from the pop-up menu
if (selection instanceof IStructuredSelection) {
action.setEnabled(true);
this.sel = (EObject)((IStructuredSelection)selection).getFirstElement() ;
} else {
action.setEnabled(false);
this.sel = null;
}
}

@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
// TODO Auto-generated method stub

}
}

--------------080507040705070404000408--
Re: howto: "The chosen operation is not currently available" [message #420858 is a reply to message #420857] Mon, 14 July 2008 14:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30687
Registered: July 2009
Senior Member
Rene,

It sounds like a class loader failure which is typically caused by not
having the proper dependencies listed in the MANIFEST.MF. A common
cause of such a problem is editing the classpath properties of the
project directly rather than using the Dependencies tab of the
MANIFEST.MF editor.


Rene Ladan wrote:
> Hi,
>
> how to avoid the message "The chosen operation is not currently
> available" when
> selecting an action from a self-defined menu extension? From the GMF
> archives
> I understand it has something to do with the interface which the class
> listed
> in plugin->extension->action->@class in plugin.xml implements, i.e.
> that it has
> to implement the correct interface. I tried IActionDelegate,
> IObjectActionDelegate,
> and IEditorActionDelegate without success.
>
> The backtrace of the error message says that it cannot find
> org.eclipse.emf.workspace.AbstractEMFOperation, but that
> package is imported by the invoked class.
>
> I've attached the plugin.xml and the invoked class.
>
> Thanks,
> Rene
Re: howto: "The chosen operation is not currently available" [message #1248297 is a reply to message #420857] Mon, 17 February 2014 05:35 Go to previous message
lali devamanthri is currently offline lali devamanthriFriend
Messages: 1
Registered: December 2013
Junior Member
I hit the same bump. Solve it by implementing requested interfaces (look in to error console).
Previous Topic:An interesting master-detail-scenario
Next Topic:Modifying EMF createPages()
Goto Forum:
  


Current Time: Tue Dec 10 11:02:38 GMT 2019

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

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

Back to the top