howto: "The chosen operation is not currently available" [message #420857] |
Mon, 14 July 2008 14:19 |
Rene Ladan 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--
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04247 seconds