Changeset 72 in default for v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de
- Timestamp:
- 06/15/14 08:59:05 (10 years ago)
- Location:
- v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/handler
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/handler/GenerationHandler.java
r71 r72 1 1 package de.ugoe.cs.swe.bnftools.ui.handler; 2 3 import java.util.Iterator; 4 import java.util.Map; 5 import java.util.Map.Entry; 2 6 3 7 import org.eclipse.core.commands.AbstractHandler; … … 5 9 import org.eclipse.core.commands.ExecutionException; 6 10 import org.eclipse.core.commands.IHandler; 11 import org.eclipse.core.commands.common.NotDefinedException; 7 12 import org.eclipse.core.resources.IFile; 8 13 import org.eclipse.core.resources.IFolder; … … 11 16 import org.eclipse.core.runtime.NullProgressMonitor; 12 17 import org.eclipse.emf.common.util.URI; 18 import org.eclipse.emf.ecore.EcorePackage; 13 19 import org.eclipse.emf.ecore.resource.Resource; 14 20 import org.eclipse.emf.ecore.resource.ResourceSet; 21 import org.eclipse.emf.ecore.xml.type.SimpleAnyType; 22 import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; 15 23 import org.eclipse.jface.viewers.ISelection; 16 24 import org.eclipse.jface.viewers.IStructuredSelection; 17 25 import org.eclipse.ui.handlers.HandlerUtil; 18 import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess ;26 import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2; 19 27 import org.eclipse.xtext.generator.IGenerator; 28 import org.eclipse.xtext.generator.OutputConfiguration; 20 29 import org.eclipse.xtext.resource.IResourceDescriptions; 21 30 import org.eclipse.xtext.ui.resource.IResourceSetProvider; … … 30 39 31 40 @Inject 32 private Provider<EclipseResourceFileSystemAccess > fileAccessProvider;41 private Provider<EclipseResourceFileSystemAccess2> fileAccessProvider; 33 42 34 43 @Inject … … 40 49 @Override 41 50 public Object execute(ExecutionEvent event) throws ExecutionException { 42 51 String mode = ""; 52 53 try { 54 mode = event.getCommand().getName(); 55 } catch (NotDefinedException e1) { 56 // catch block 57 e1.printStackTrace(); 58 } 59 60 61 43 62 ISelection selection = HandlerUtil.getCurrentSelection(event); 44 63 if (selection instanceof IStructuredSelection) { … … 58 77 } 59 78 60 final EclipseResourceFileSystemAccess fsa = fileAccessProvider.get();79 final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get(); 61 80 fsa.setOutputPath(srcGenFolder.getFullPath().toString()); 81 82 //complete the filesystemaccess 83 fsa.setMonitor(new NullProgressMonitor()); 84 Map<String, OutputConfiguration> teste = fsa.getOutputConfigurations(); 85 86 Iterator<Entry<String, OutputConfiguration>> it = teste.entrySet().iterator(); 87 88 while(it.hasNext()){ 89 90 Entry<String, OutputConfiguration> next = it.next(); 91 OutputConfiguration out = next.getValue(); 92 out.isOverrideExistingResources(); 93 out.setCreateOutputDirectory(true); // <--- do not touch this 62 94 95 } 96 // -----> 97 63 98 URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true); 64 99 ResourceSet rs = resourceSetProvider.get(project); 65 100 Resource r = rs.getResource(uri, true); 101 102 // to pass a String inside a resource i have to wrap it in a EOBject 103 SimpleAnyType wrapper = XMLTypeFactory.eINSTANCE.createSimpleAnyType(); 104 wrapper.setInstanceType(EcorePackage.eINSTANCE.getEString()); 105 wrapper.setValue(mode); 106 // 107 108 // add string to resource 109 r.getContents().add(wrapper); 110 66 111 generator.doGenerate(r, fsa); 67 112
Note: See TracChangeset
for help on using the changeset viewer.