Index: v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/plugin.xml
===================================================================
--- v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/plugin.xml	(revision 71)
+++ v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/plugin.xml	(revision 72)
@@ -248,5 +248,6 @@
 	</extension>
 
-<!--
+<!--   -->
+   
    <extension
          point="org.eclipse.xtext.builder.participant">
@@ -255,7 +256,7 @@
       </participant>
    </extension>
-   -->
-   
-   <!--this is for using a button for generation -->
+
+   
+   <!--this is for using a button for generation 
    <extension
         point="org.eclipse.ui.handlers">
@@ -291,5 +292,5 @@
     </menuContribution>
     </extension>
-
+-->
    
    
@@ -433,4 +434,39 @@
     </provider>
   </extension>
+  <!--
+  <extension
+        point="org.eclipse.ui.commands">
+     <command
+           defaultHandler="de.ugoe.cs.swe.bnftools.ui.EbnfExecutableExtensionFactory:de.ugoe.cs.swe.bnftools.ui.handler.BT_GenerationHandler"
+           id="de.ugoe.cs.swe.bnftools.ebnf.ui.cmdgenerate"
+           name="button_generate">
+     </command>
+  </extension>
+  <extension
+        point="org.eclipse.ui.menus">
+     <menuContribution
+           allPopups="false"
+           locationURI="toolbar:org.eclipse.ui.main.toolbar">
+        <command
+              commandId="de.ugoe.cs.swe.bnftools.ebnf.ui.cmdgenerate"
+              icon="lrun_obj.gif"
+              style="push"
+              tooltip="Generate Code">
+        </command>
+     </menuContribution>
+  </extension>
+  -->
+  <extension
+        id="product"
+        point="org.eclipse.core.runtime.products">
+     <product
+           application="de.ugoe.cs.swe.bnftools.product.application"
+           name="bnf">
+        <property
+              name="appName"
+              value="bnf">
+        </property>
+     </product>
+  </extension>
 
 </plugin>
Index: v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/handler/BT_GenerationHandler.java
===================================================================
--- v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/handler/BT_GenerationHandler.java	(revision 72)
+++ v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/handler/BT_GenerationHandler.java	(revision 72)
@@ -0,0 +1,144 @@
+package de.ugoe.cs.swe.bnftools.ui.handler;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.xml.type.SimpleAnyType;
+import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2;
+import org.eclipse.xtext.generator.IGenerator;
+import org.eclipse.xtext.generator.OutputConfiguration;
+import org.eclipse.xtext.resource.IResourceDescriptions;
+import org.eclipse.xtext.ui.resource.IResourceSetProvider;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+public class BT_GenerationHandler  extends AbstractHandler implements IHandler {
+
+	@Inject
+    private IGenerator generator;
+ 
+    @Inject
+    private Provider<EclipseResourceFileSystemAccess2> fileAccessProvider;
+     
+    @Inject
+    IResourceDescriptions resourceDescriptions;
+     
+    @Inject
+    IResourceSetProvider resourceSetProvider;
+     
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+    	 
+    	  //used to save the command name (defined in extensions)
+    	  String mode = "";
+    	 
+    	  try {
+    	     mode = event.getCommand().getName();
+    	  } catch (NotDefinedException e1) {
+    	  // TODO Auto-generated catch block
+    	    e1.printStackTrace();
+    	  }
+    	 
+    	  // stuff to get the workbench and current file
+    	  IWorkbench wb = PlatformUI.getWorkbench();
+    	  IWorkbenchWindow window = wb.getActiveWorkbenchWindow();
+    	  IWorkbenchPage page = window.getActivePage();
+    	  IEditorPart editor = page.getActiveEditor();
+    	  IEditorInput input = editor.getEditorInput();
+    	  IPath path = ((FileEditorInput) input).getPath();
+    	 
+    	  String name = path.toString();
+    	  File myfile = new File(name);
+    	 
+    	  IWorkspace workspace= ResourcesPlugin.getWorkspace();
+    	  IPath location= Path.fromOSString(myfile.getAbsolutePath());
+    	  IFile file= workspace.getRoot().getFileForLocation(location);
+    	 
+    	  IProject project = file.getProject();
+    	  IFolder srcGenFolder = project.getFolder("src-gen");
+    	  if (!srcGenFolder.exists()) {
+    	    try {
+    	      srcGenFolder.create(true, true, new NullProgressMonitor());
+    	    } catch (CoreException e) {
+    	    return null;
+    	    }
+    	  }
+    	 
+    	  final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get();
+    	 
+    	  fsa.setProject(project);
+    	 
+    	  //same stuff
+    	  //fsa.setOutputPath("src-gen");
+    	  fsa.setOutputPath(srcGenFolder.getName().toString());
+    	 
+    	  fsa.setMonitor(new NullProgressMonitor());
+    	  Map<String, OutputConfiguration> teste = fsa.getOutputConfigurations();
+    	 
+    	  Iterator<Entry<String, OutputConfiguration>> it = teste.entrySet().iterator();
+    	 
+    	  //make a new Outputconfiguration <- needed
+    	  while(it.hasNext()){
+    	 
+    	    Entry<String, OutputConfiguration> next = it.next();
+    	    OutputConfiguration out = next.getValue();
+    	    out.isOverrideExistingResources();
+    	    out.setCreateOutputDirectory(true); // <--- do not touch this
+    	 
+    	  }
+    	  // ----->
+    	 
+    	  URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
+    	  ResourceSet rs = resourceSetProvider.get(project);
+    	  Resource r = rs.getResource(uri, true);
+    	 
+    	  // to pass a String inside a resource i have to wrap it in a EOBject
+    	  SimpleAnyType wrapper = XMLTypeFactory.eINSTANCE.createSimpleAnyType();
+    	  wrapper.setInstanceType(EcorePackage.eINSTANCE.getEString());
+    	  wrapper.setValue(mode);
+    	  //
+    	 
+    	  // add string to resource
+    	  r.getContents().add(wrapper);
+    	 
+    	  generator.doGenerate(r, fsa);
+    	 
+    	  return null;
+    	 
+    	}
+    
+    @Override
+    public boolean isEnabled() {
+        return true;
+    }
+ 
+}
Index: v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/handler/GenerationHandler.java
===================================================================
--- v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/handler/GenerationHandler.java	(revision 71)
+++ v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/handler/GenerationHandler.java	(revision 72)
@@ -1,3 +1,7 @@
 package de.ugoe.cs.swe.bnftools.ui.handler;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
 
 import org.eclipse.core.commands.AbstractHandler;
@@ -5,4 +9,5 @@
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.common.NotDefinedException;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
@@ -11,11 +16,15 @@
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EcorePackage;
 import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.xml.type.SimpleAnyType;
+import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess;
+import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2;
 import org.eclipse.xtext.generator.IGenerator;
+import org.eclipse.xtext.generator.OutputConfiguration;
 import org.eclipse.xtext.resource.IResourceDescriptions;
 import org.eclipse.xtext.ui.resource.IResourceSetProvider;
@@ -30,5 +39,5 @@
  
     @Inject
-    private Provider<EclipseResourceFileSystemAccess> fileAccessProvider;
+    private Provider<EclipseResourceFileSystemAccess2> fileAccessProvider;
      
     @Inject
@@ -40,5 +49,15 @@
     @Override
     public Object execute(ExecutionEvent event) throws ExecutionException {
-         
+    	String mode = "";
+ 
+    	try {
+			mode = event.getCommand().getName();
+		} catch (NotDefinedException e1) {
+			// catch block
+			e1.printStackTrace();
+		}
+    		 
+
+    	 
         ISelection selection = HandlerUtil.getCurrentSelection(event);
         if (selection instanceof IStructuredSelection) {
@@ -58,10 +77,36 @@
                 }
  
-                final EclipseResourceFileSystemAccess fsa = fileAccessProvider.get();
+                final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get();
                 fsa.setOutputPath(srcGenFolder.getFullPath().toString());
+                
+                //complete the filesystemaccess 
+                fsa.setMonitor(new NullProgressMonitor());
+                Map<String, OutputConfiguration> teste = fsa.getOutputConfigurations();
+        		
+                Iterator<Entry<String, OutputConfiguration>> it = teste.entrySet().iterator();
+                
+                while(it.hasNext()){
+                	 
+                    Entry<String, OutputConfiguration> next = it.next();
+                    OutputConfiguration out = next.getValue();
+                    out.isOverrideExistingResources();
+                    out.setCreateOutputDirectory(true); // <--- do not touch this
                  
+                  }
+                  // ----->
+                
                 URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
                 ResourceSet rs = resourceSetProvider.get(project);
                 Resource r = rs.getResource(uri, true);
+                
+                // to pass a String inside a resource i have to wrap it in a EOBject
+                SimpleAnyType wrapper = XMLTypeFactory.eINSTANCE.createSimpleAnyType();
+                wrapper.setInstanceType(EcorePackage.eINSTANCE.getEString());
+                wrapper.setValue(mode);
+                //
+               
+                // add string to resource
+                r.getContents().add(wrapper);
+            
                 generator.doGenerate(r, fsa);
                  
