Changeset 72 in default for v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui
- Timestamp:
- 06/15/14 08:59:05 (10 years ago)
- Location:
- v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/plugin.xml
r71 r72 248 248 </extension> 249 249 250 <!-- 250 <!-- --> 251 251 252 <extension 252 253 point="org.eclipse.xtext.builder.participant"> … … 255 256 </participant> 256 257 </extension> 257 --> 258 259 <!--this is for using a button for generation -->258 259 260 <!--this is for using a button for generation 260 261 <extension 261 262 point="org.eclipse.ui.handlers"> … … 291 292 </menuContribution> 292 293 </extension> 293 294 --> 294 295 295 296 … … 433 434 </provider> 434 435 </extension> 436 <!-- 437 <extension 438 point="org.eclipse.ui.commands"> 439 <command 440 defaultHandler="de.ugoe.cs.swe.bnftools.ui.EbnfExecutableExtensionFactory:de.ugoe.cs.swe.bnftools.ui.handler.BT_GenerationHandler" 441 id="de.ugoe.cs.swe.bnftools.ebnf.ui.cmdgenerate" 442 name="button_generate"> 443 </command> 444 </extension> 445 <extension 446 point="org.eclipse.ui.menus"> 447 <menuContribution 448 allPopups="false" 449 locationURI="toolbar:org.eclipse.ui.main.toolbar"> 450 <command 451 commandId="de.ugoe.cs.swe.bnftools.ebnf.ui.cmdgenerate" 452 icon="lrun_obj.gif" 453 style="push" 454 tooltip="Generate Code"> 455 </command> 456 </menuContribution> 457 </extension> 458 --> 459 <extension 460 id="product" 461 point="org.eclipse.core.runtime.products"> 462 <product 463 application="de.ugoe.cs.swe.bnftools.product.application" 464 name="bnf"> 465 <property 466 name="appName" 467 value="bnf"> 468 </property> 469 </product> 470 </extension> 435 471 436 472 </plugin> -
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.