Changeset 84 in default
- Timestamp:
- 07/02/14 13:59:44 (10 years ago)
- Location:
- v2/trunk
- Files:
-
- 1 added
- 1 deleted
- 5 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.product/bnf.product
r81 r84 11 11 </launcherArgs> 12 12 13 <launcher name="BNF ">13 <launcher name="BNF Tools"> 14 14 <solaris/> 15 15 <win useIco="false"> … … 31 31 <plugin id="javax.annotation"/> 32 32 <plugin id="javax.inject"/> 33 <plugin id="javax.servlet"/> 33 34 <plugin id="javax.xml"/> 35 <plugin id="lpg.runtime.java"/> 34 36 <plugin id="org.antlr.runtime"/> 37 <plugin id="org.apache.ant"/> 35 38 <plugin id="org.apache.batik.css"/> 36 39 <plugin id="org.apache.batik.util"/> 37 40 <plugin id="org.apache.batik.util.gui"/> 41 <plugin id="org.apache.commons.cli"/> 38 42 <plugin id="org.apache.commons.lang"/> 39 43 <plugin id="org.apache.commons.logging"/> 40 44 <plugin id="org.apache.log4j"/> 45 <plugin id="org.eclipse.ant.core"/> 41 46 <plugin id="org.eclipse.compare"/> 42 47 <plugin id="org.eclipse.compare.core"/> … … 78 83 <plugin id="org.eclipse.e4.ui.workbench.swt"/> 79 84 <plugin id="org.eclipse.e4.ui.workbench3"/> 85 <plugin id="org.eclipse.emf.codegen"/> 86 <plugin id="org.eclipse.emf.codegen.ecore"/> 80 87 <plugin id="org.eclipse.emf.common"/> 81 88 <plugin id="org.eclipse.emf.common.ui"/> 82 89 <plugin id="org.eclipse.emf.ecore"/> 83 90 <plugin id="org.eclipse.emf.ecore.change"/> 91 <plugin id="org.eclipse.emf.ecore.edit"/> 92 <plugin id="org.eclipse.emf.ecore.editor"/> 84 93 <plugin id="org.eclipse.emf.ecore.xmi"/> 85 94 <plugin id="org.eclipse.emf.edit"/> 86 95 <plugin id="org.eclipse.emf.edit.ui"/> 96 <plugin id="org.eclipse.emf.mwe.core"/> 97 <plugin id="org.eclipse.emf.mwe.utils"/> 98 <plugin id="org.eclipse.emf.mwe2.language"/> 99 <plugin id="org.eclipse.emf.mwe2.launch"/> 100 <plugin id="org.eclipse.emf.mwe2.lib"/> 101 <plugin id="org.eclipse.emf.mwe2.runtime"/> 87 102 <plugin id="org.eclipse.equinox.app"/> 88 103 <plugin id="org.eclipse.equinox.bidi"/> … … 101 116 <plugin id="org.eclipse.equinox.util"/> 102 117 <plugin id="org.eclipse.help"/> 118 <plugin id="org.eclipse.jdt.annotation"/> 103 119 <plugin id="org.eclipse.jdt.compiler.apt" fragment="true"/> 104 120 <plugin id="org.eclipse.jdt.compiler.tool" fragment="true"/> … … 106 122 <plugin id="org.eclipse.jdt.core.manipulation"/> 107 123 <plugin id="org.eclipse.jdt.debug"/> 124 <plugin id="org.eclipse.jdt.debug.ui"/> 108 125 <plugin id="org.eclipse.jdt.launching"/> 109 126 <plugin id="org.eclipse.jdt.ui"/> … … 113 130 <plugin id="org.eclipse.ltk.core.refactoring"/> 114 131 <plugin id="org.eclipse.ltk.ui.refactoring"/> 132 <plugin id="org.eclipse.ocl"/> 133 <plugin id="org.eclipse.ocl.common"/> 134 <plugin id="org.eclipse.ocl.ecore"/> 115 135 <plugin id="org.eclipse.osgi"/> 116 136 <plugin id="org.eclipse.osgi.services"/> … … 134 154 <plugin id="org.eclipse.ui.workbench"/> 135 155 <plugin id="org.eclipse.ui.workbench.texteditor"/> 156 <plugin id="org.eclipse.xpand"/> 157 <plugin id="org.eclipse.xtend"/> 136 158 <plugin id="org.eclipse.xtend.lib"/> 159 <plugin id="org.eclipse.xtend.typesystem.emf"/> 137 160 <plugin id="org.eclipse.xtext"/> 138 161 <plugin id="org.eclipse.xtext.builder"/> 139 162 <plugin id="org.eclipse.xtext.common.types"/> 163 <plugin id="org.eclipse.xtext.common.types.edit"/> 140 164 <plugin id="org.eclipse.xtext.common.types.ui"/> 165 <plugin id="org.eclipse.xtext.ecore"/> 166 <plugin id="org.eclipse.xtext.generator"/> 141 167 <plugin id="org.eclipse.xtext.junit4"/> 142 168 <plugin id="org.eclipse.xtext.logging" fragment="true"/> 169 <plugin id="org.eclipse.xtext.smap"/> 143 170 <plugin id="org.eclipse.xtext.ui"/> 144 171 <plugin id="org.eclipse.xtext.ui.codetemplates"/> -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/META-INF/MANIFEST.MF
r61 r84 16 16 org.eclipse.xtext.common.types.ui, 17 17 org.eclipse.xtext.ui.codetemplates.ui, 18 org.eclipse.compare 19 Import-Package: org.apache.log4j, 18 org.eclipse.compare, 19 org.eclipse.core.resources, 20 org.eclipse.ui.workbench, 21 org.eclipse.equinox.registry, 22 org.eclipse.emf.common, 23 com.google.inject, 24 org.eclipse.xtext 25 Import-Package: com.ibm.icu.util;version="50.1.1", 26 org.apache.log4j, 27 org.eclipse.xtext.generator, 20 28 org.eclipse.xtext.xbase.lib 21 29 Bundle-RequiredExecutionEnvironment: J2SE-1.5 22 Export-Package: de.ugoe.cs.swe.bnftools.ui.quickfix, 23 de.ugoe.cs.swe.bnftools.ui.contentassist, 24 de.ugoe.cs.swe.bnftools.ui.contentassist.antlr, 25 de.ugoe.cs.swe.bnftools.ui.internal 30 Export-Package: de.ugoe.cs.swe.bnftools.ui.contentassist, 31 de.ugoe.cs.swe.bnftools.ui.contentassist.antlr; 32 uses:="org.eclipse.xtext, 33 de.ugoe.cs.swe.bnftools.services, 34 org.eclipse.xtext.ui.editor.contentassist.antlr.internal, 35 org.eclipse.xtext.ui.codetemplates.ui.partialEditing, 36 org.eclipse.xtext.ui.editor.contentassist.antlr, 37 de.ugoe.cs.swe.bnftools.ui.contentassist.antlr.internal", 38 de.ugoe.cs.swe.bnftools.ui.handler;uses:="org.eclipse.xtext.ui.resource,org.eclipse.xtext.resource,org.eclipse.core.commands", 39 de.ugoe.cs.swe.bnftools.ui.internal;uses:="org.eclipse.ui.plugin,org.osgi.framework,com.google.inject", 40 de.ugoe.cs.swe.bnftools.ui.quickfix;uses:="org.eclipse.xtext.ui.editor.quickfix,org.eclipse.xtext.validation" 26 41 Bundle-Activator: de.ugoe.cs.swe.bnftools.ui.internal.EbnfActivator 42 Bundle-ClassPath: src/, 43 . -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/build.properties
r67 r84 4 4 bin.includes = META-INF/,\ 5 5 .,\ 6 plugin.xml 7 src.includes = .settings/6 plugin.xml,\ 7 src/ -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/handler/BT_GenerationHandlerPDF.java
r72 r84 26 26 import org.eclipse.emf.ecore.xml.type.SimpleAnyType; 27 27 import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; 28 import org.eclipse.jface.dialogs.MessageDialog; 28 29 import org.eclipse.ui.IEditorInput; 29 30 import org.eclipse.ui.IEditorPart; … … 32 33 import org.eclipse.ui.IWorkbenchWindow; 33 34 import org.eclipse.ui.PlatformUI; 35 import org.eclipse.ui.handlers.HandlerUtil; 34 36 import org.eclipse.ui.part.FileEditorInput; 35 37 import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2; … … 42 44 import com.google.inject.Provider; 43 45 44 public class BT_GenerationHandler extends AbstractHandler implements IHandler { 46 import de.ugoe.cs.swe.bnftools.generator.EbnfGenerator; 47 48 public class BT_GenerationHandlerPDF extends AbstractHandler implements IHandler { 45 49 46 50 @Inject … … 56 60 IResourceSetProvider resourceSetProvider; 57 61 62 63 58 64 @Override 65 public boolean isEnabled() { 66 return true; 67 } 68 69 70 71 59 72 public Object execute(ExecutionEvent event) throws ExecutionException { 60 73 MessageDialog.openInformation(HandlerUtil.getActiveShell(event), 74 "Hello", "Generating PDF"); 75 76 61 77 //used to save the command name (defined in extensions) 62 78 String mode = ""; … … 65 81 mode = event.getCommand().getName(); 66 82 } catch (NotDefinedException e1) { 67 // TODO Auto-generated catch block68 83 e1.printStackTrace(); 69 84 } … … 127 142 wrapper.setValue(mode); 128 143 // 129 144 EbnfGenerator gen = (EbnfGenerator)generator; 130 145 // add string to resource 131 146 r.getContents().add(wrapper); 132 133 generator.doGenerate(r, fsa);134 147 gen.doGenerate(r, fsa,false); 148 //generator.doGenerate(r, fsa); 149 135 150 return null; 136 151 137 152 } 138 139 @Override140 public boolean isEnabled() {141 return true;142 }143 144 153 } -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/labeling/EbnfLabelProvider.xtend
r68 r84 5 5 6 6 import com.google.inject.Inject 7 import de.ugoe.cs.swe.bnftools.ebnf.Atom 8 import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry 9 import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList 7 10 import de.ugoe.cs.swe.bnftools.ebnf.ImportSection 8 11 import de.ugoe.cs.swe.bnftools.ebnf.Rule 9 import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry10 import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList11 12 import de.ugoe.cs.swe.bnftools.ebnf.SingleDefinition 12 13 import de.ugoe.cs.swe.bnftools.ebnf.Term 13 import de.ugoe.cs.swe.bnftools.ebnf.Atom14 import de.ugoe.cs.swe.bnftools.ebnf.StringRule14 import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider 15 import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider 15 16 16 17 /** … … 19 20 * see http://www.eclipse.org/Xtext/documentation.html#labelProvider 20 21 */ 21 class EbnfLabelProvider extends org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider {22 class EbnfLabelProvider extends DefaultEObjectLabelProvider { 22 23 23 24 @Inject 24 new( org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider delegate) {25 new(AdapterFactoryLabelProvider delegate) { 25 26 super(delegate); 26 27 } … … 31 32 32 33 def text(BnfEntry entry){ 33 ' BnfEntry'34 }34 'Rule: '+entry.rule.name 35 } 35 36 36 37 def text(Rule rule){ 37 'Rule: '+rule.name38 38 39 } 39 40 -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/generator/EbnfGenerator.xtend
r82 r84 4 4 package de.ugoe.cs.swe.bnftools.generator 5 5 6 import de.ugoe.cs.swe.bnftools.ebnf.Atom 7 import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry 8 import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList 9 import de.ugoe.cs.swe.bnftools.ebnf.EtsiBnf 10 import de.ugoe.cs.swe.bnftools.ebnf.GroupedSequence 11 import de.ugoe.cs.swe.bnftools.ebnf.OptionalSequence 12 import de.ugoe.cs.swe.bnftools.ebnf.RepeatedSequence 13 import de.ugoe.cs.swe.bnftools.ebnf.Rule 14 import de.ugoe.cs.swe.bnftools.ebnf.RuleReference 15 import de.ugoe.cs.swe.bnftools.ebnf.SingleDefinition 16 import de.ugoe.cs.swe.bnftools.ebnf.StringRule 17 import de.ugoe.cs.swe.bnftools.ebnf.Term 18 import java.io.File 6 19 import org.eclipse.emf.ecore.resource.Resource 20 import org.eclipse.xtext.generator.IFileSystemAccess 21 import org.eclipse.xtext.generator.IFileSystemAccessExtension2 7 22 import org.eclipse.xtext.generator.IGenerator 8 import org.eclipse.xtext.generator.IFileSystemAccess9 import de.ugoe.cs.swe.bnftools.ebnf.EtsiBnf10 import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry11 import de.ugoe.cs.swe.bnftools.ebnf.Rule12 import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList13 import de.ugoe.cs.swe.bnftools.ebnf.SingleDefinition14 import de.ugoe.cs.swe.bnftools.ebnf.Term15 import de.ugoe.cs.swe.bnftools.ebnf.GroupedSequence16 import de.ugoe.cs.swe.bnftools.ebnf.Atom17 import de.ugoe.cs.swe.bnftools.ebnf.RepeatedSequence18 import de.ugoe.cs.swe.bnftools.ebnf.OptionalSequence19 import de.ugoe.cs.swe.bnftools.ebnf.RuleReference20 import de.ugoe.cs.swe.bnftools.ebnf.StringRule21 import java.io.File22 import org.eclipse.xtext.generator.IFileSystemAccessExtension223 import org.eclipse.emf.common.util.URI;24 import org.eclipse.xtext.generator.IFileSystemAccessExtension25 import java.io.PrintWriter26 23 27 24 /** … … 32 29 class EbnfGenerator implements IGenerator { 33 30 34 //generation of the xsl-file 35 override void doGenerate(Resource resource, IFileSystemAccess fsa) {31 32 def void doGenerate(Resource resource, IFileSystemAccess fsa,boolean mode) { 36 33 var String workspacePath = WorkspaceResolver.getWorkspace(); 37 34 for (e : resource.allContents.toIterable.filter(EtsiBnf)) { … … 45 42 46 43 if (file.exists) { 44 //true -> pdf, false -> rtf 47 45 48 foToPdf.createPdfFromFo(fullUri.substring(0, fullUri.length - 3)); 46 if(mode){ 47 FoToPdfOrRtf.createRtfFromFo(fullUri.substring(0, fullUri.length - 3)); 48 }else{ 49 FoToPdfOrRtf.createPdfFromFo(fullUri.substring(0, fullUri.length - 3)); 50 } 51 52 // fsa.deleteFile(e.name + ".fo"); 53 } 54 } 55 } 56 } 57 58 override void doGenerate(Resource resource, IFileSystemAccess fsa) { 59 var String workspacePath = WorkspaceResolver.getWorkspace(); 60 for (e : resource.allContents.toIterable.filter(EtsiBnf)) { 61 if (e.bnfEntry.size != 0) { 62 fsa.generateFile(e.name + ".fo", e.compile) 63 System.out.println("fo generated"); 64 //generate pdf 65 var uri = (fsa as IFileSystemAccessExtension2).getURI(e.name + ".fo"); 66 var String fullUri = workspacePath + uri.path.substring(10, uri.path.length); 67 var File file = new File(fullUri); 68 69 if (file.exists) { 70 71 FoToPdfOrRtf.createPdfFromFo(fullUri.substring(0, fullUri.length - 3)); 49 72 // fsa.deleteFile(e.name + ".fo"); 50 73 } … … 84 107 ''' 85 108 86 def compile(Rule rule) ''' <fo:block><fo:inline id="«rule.name»" color="purple">«IF rule.rulenumber != 0»«rule.109 def compile(Rule rule) '''«System.out.println(rule.name)»<fo:block><fo:inline id="«rule.name»" color="purple">«IF rule.rulenumber != 0»«rule. 87 110 rulenumber». «ENDIF»«rule.name»</fo:inline> ::= «rule.definitionList.compile»</fo:block>''' 88 111 89 def compile(DefinitionList dList) '''« FOR sDef : dList.singleDefinition»«sDef.compile»«IF !sDef.equals(90 dList.singleDefinition.last)» | «ENDIF»«ENDFOR» '''112 def compile(DefinitionList dList) '''«IF dList!= null»«FOR sDef : dList.singleDefinition»«sDef.compile»«IF !sDef.equals( 113 dList.singleDefinition.last)» | «ENDIF»«ENDFOR»«ENDIF»''' 91 114 92 115 def compile(SingleDefinition sDefinition) '''«FOR term : sDefinition.terms»«term.compile»«ENDFOR»''' … … 110 133 111 134 def compile(StringRule sRule) '''«IF sRule.colon != null»«sRule.colon»«ENDIF»«IF sRule.literal != null»«sRule. 112 literal » «ENDIF»'''135 literal.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")» «ENDIF»''' 113 136 114 137 } -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/generator/FoToPdfOrRtf.java
r82 r84 23 23 24 24 25 public class foToPdf {25 public class FoToPdfOrRtf { 26 26 27 27 … … 33 33 } 34 34 35 private static void createfoFromPdf(String foFileName, String pdfFileName)throws IOException, FOPException, 35 public static void createRtfFromFo(String fileName) throws IOException, FOPException, 36 TransformerException{ 37 38 createRtfFromFo(fileName,fileName); 39 } 40 41 private static void createRtfFromFo(String foFileName, String pdfFileName)throws IOException, FOPException, 36 42 TransformerException{ 37 43 File file = new File(foFileName+".fo"); … … 45 51 // Step 3: Construct fop with desired output format 46 52 Fop fop = fopFactory.newFop(MimeConstants.MIME_RTF, out); 53 54 // Step 4: Setup JAXP using identity transformer 55 TransformerFactory factory = TransformerFactory.newInstance(); 56 Transformer transformer = factory.newTransformer(); 57 58 // Step 5: Setup input and output for XSLT transformation 59 Source src = new StreamSource(file); 60 61 // Resulting SAX events (the generated FO) must be piped through to FOP 62 Result res = new SAXResult(fop.getDefaultHandler()); 63 64 // Step 6: Start XSLT transformation and FOP processing 65 transformer.transform(src, res); 66 } finally { 67 out.close(); 68 } 69 } 70 71 72 private static void createfoFromPdf(String foFileName, String pdfFileName)throws IOException, FOPException, 73 TransformerException{ 74 File file = new File(foFileName+".fo"); 75 // Step 1: Construct a FopFactory 76 FopFactory fopFactory = FopFactory.newInstance(); 77 78 // Step 2: Set up output stream. 79 OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(pdfFileName+".pdf"))); 80 81 try { 82 // Step 3: Construct fop with desired output format 83 Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out); 47 84 48 85 // Step 4: Setup JAXP using identity transformer
Note: See TracChangeset
for help on using the changeset viewer.