Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » GMF custom action, IOException unable to resolve plugin
GMF custom action, IOException unable to resolve plugin [message #630704] Mon, 04 October 2010 15:52 Go to next message
masija . is currently offline masija .Friend
Messages: 59
Registered: July 2010
Member
Hi @ all,
I am currently trying to add a custom action to my gmf editor.
I added an objectContribution to the popup menu extension point.
In this the implementation class of the action is called.
After this point in the run method, i try to get the workflow file location with this piece of code:
URL url = FileLocator.toFileURL(new URL("platform:/plugin/testplugin/templates/workflowfile.mwe "));


At this point, when i want to thest the action, i get an IOException with the error code:
unable to resolve plugin "platform:/plugin/testplugin/templates/workflowfile.mwe"

I adaprted this code from the dsl-book and the cvs, so in general it should work...
If anybody knows what i am doing wrong, please help me Wink
any help would be apreciated.

Best regards,
Masija


The Code from the cvs mentioned above:
package org.eclipse.amalgam.examples.requirements.actions;

import java.net.URL;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;

import org.eclipse.amalgam.examples.requirements.ui.Messages;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
//import org.eclipse.emf.mwe.core.WorkflowRunner;
//import org.eclipse.emf.mwe.core.monitor.NullProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;

public class TransformRequirements2HTML implements IObjectActionDelegate {

    private IWorkbenchPart targetPart;
    private IFile file;

    public void setActivePart(IAction action, IWorkbenchPart targetPart) {
        this.targetPart = targetPart;
    }

    public void selectionChanged(IAction action, ISelection selection) {
        action.setEnabled(false);
        if (selection instanceof IStructuredSelection == false || selection.isEmpty()) {
            return;
        }
        file = (IFile) ((IStructuredSelection) selection).getFirstElement();
        action.setEnabled(true);
    }

    public void run(IAction action) {
        try {
            EObject source = getInput();
            if (source == null) {
                String title = Messages.RunTransformationAction_title;
                String message = Messages.RunTransformationAction_message;

                MessageDialog.openInformation(getShell(), title, NLS.bind(message, file.getFullPath()));
            } else {
                URL url = FileLocator.toFileURL(new URL("platform:/plugin/org.eclipse.amalgam.examples.requirements.ui/templates/requirements2html.mwe"));
                Map<String, String> properties = new HashMap<String, String>();
                properties.put("model", URI.createPlatformResourceURI(file.getFullPath().toString(), true).toString());
                properties.put("out", Platform.getLocation().toOSString() + file.getParent().getFullPath());
//                new WorkflowRunner().run(url.getPath(), new NullProgressMonitor(), properties, null);
//                file.getParent().refreshLocal(IResource.DEPTH_ONE, new org.eclipse.core.runtime.NullProgressMonitor());
            }
        } catch (Exception ex) {
            handleError(ex);
        }
    }

    private EObject getInput() {
        ResourceSetImpl rs = new ResourceSetImpl();
        return rs.getEObject(URI.createPlatformResourceURI(file.getFullPath().toString(), true).appendFragment("/"), true);
    }

    private void handleError(Throwable ex) {
        MessageDialog.openError(getShell(), "Transformation failed", MessageFormat.format("{0}: {1}", ex.getClass().getSimpleName(), ex.getMessage() == null ? "no message" : ex.getMessage()));
    }

    private Shell getShell() {
        return targetPart.getSite().getShell();
    }
}

[Updated on: Mon, 04 October 2010 15:53]

Report message to a moderator

Re: GMF custom action, IOException unable to resolve plugin [message #630835 is a reply to message #630704] Tue, 05 October 2010 08:47 Go to previous message
masija . is currently offline masija .Friend
Messages: 59
Registered: July 2010
Member
perhaps this occurs, because i did just run my gmf-editor as an eclipse application from within eclipse?

But unfortunately i still have no clue to get the URL of my workflow in order to run it as an action :/

Previous Topic:make an editor from uml profile.. problem with inherited attributes
Next Topic:In GMF 2.3 xxxCreateCommand extends EditElementCommand, not CreateElementCommand
Goto Forum:
  


Current Time: Thu May 09 03:57:54 GMT 2024

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

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

Back to the top