eclipse plugin: Test with getting the WML Grammar parsed...

...out of an IFile instance
This commit is contained in:
Timotei Dolean 2011-07-05 08:53:59 +00:00
parent 3a9d463062
commit d3750307b3
2 changed files with 13 additions and 5 deletions

View file

@ -544,13 +544,11 @@
id="org.wesnoth.commands.reloadFiles"
name="reloadFiles">
</command>
<!--
<command
defaultHandler="org.wesnoth.handlers.TestHandler"
id="org.wesnoth.commands.test"
name="test command">
</command>
-->
</extension>
<extension
point="org.eclipse.ui.menus">
@ -617,13 +615,11 @@
name="separator3"
visible="true">
</separator>
<!--
<command
commandId="org.wesnoth.commands.test"
label="Test (FOR DEBUG ONLY!!)"
style="push">
</command>
-->
</menu>
</menuContribution>
</extension>

View file

@ -11,6 +11,13 @@ package org.wesnoth.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.wesnoth.utils.WorkspaceUtils;
/**
* Here it goes testing stuff in the plugin ( For DEBUG ONLY!)
@ -21,7 +28,12 @@ public class TestHandler extends AbstractHandler
@Override
public Object execute(ExecutionEvent event) throws ExecutionException
{
IFile file = WorkspaceUtils.getSelectedFile( );
URI uri = URI.createPlatformResourceURI( file.getFullPath( ).toString( ), true );
ResourceSet resSet = new ResourceSetImpl( );
Resource res = resSet.getResource( uri, true );
EObject obj = res.getContents( ).get( 0 );
System.out.println( obj);
// IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path("E:\\work\\java\\runtime-EclipseApplication\\A_Simple_Campaign\\scenarios\\atemplate.cfg"));
// try