Changeset 69 in default


Ignore:
Timestamp:
05/26/14 11:48:28 (10 years ago)
Author:
hkaulbersch
Message:

added the functions to generate a .pdf from .fo.
Still Not accessible.

Location:
v2/trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/plugin.xml

    r68 r69  
    248248        </extension> 
    249249 
    250 <!-- 
     250<!----> 
    251251   <extension 
    252252         point="org.eclipse.xtext.builder.participant"> 
     
    255255      </participant> 
    256256   </extension> 
    257    --> 
    258     
    259    <!--this is for using a button for generation--> 
     257    
     258    
     259   <!--this is for using a button for generation 
    260260   <extension 
    261261        point="org.eclipse.ui.handlers"> 
    262262     <handler 
    263            class="de.ugoe.cs.swe.bnftools.ui.EbnfExecutableExtensionFactory:de.ugoe.cs.swe.bnftools.ui.helper.GenerationHandler" 
     263           class="de.ugoe.cs.swe.bnftools.ui.EBnfExecutableExtensionFactory:de.ugoe.cs.swe.bnftools.ui.helper.GenerationHandler" 
    264264           commandId="de.ugoe.cs.swe.bnftools.ui.handler.GenerationCommand"> 
    265265     </handler> 
     
    291291    </menuContribution> 
    292292    </extension> 
    293  <!----> 
     293 --> 
    294294    
    295295    
  • v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/handler/GenerationHandler.java

    r68 r69  
    6666                generator.doGenerate(r, fsa); 
    6767                  
     68                 
    6869            } 
    6970        } 
  • v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/quickfix/EbnfQuickfixProvider.xtend

    r66 r69  
    4242        //***************************************************************************************** 
    4343        //works but only in one file 
    44                 @Fix(EbnfValidator.ruleReferencedOneDescription) 
    45                 def void fixInlineRuleReferencedOnce(Issue issue, IssueResolutionAcceptor acceptor) { 
    46                         acceptor.accept( 
    47                                 issue, 
    48                                 "Inline the rule", 
    49                                 "Delete the rule and replace its single reference by the rule's right side", 
    50                                 "upcase.png" 
    51                         ) [ element, context | 
    52                                 var Rule rule = element as Rule; 
    53                                 var IXtextDocument xtextDocument = context.getXtextDocument(); 
    54                                 var ICompositeNode node = NodeModelUtils.findActualNodeFor(rule); 
    55                                 var String nodeText = node.text; 
    56                                 var int textLength = nodeText.length - 2; 
    57                                 var int offset = node.textRegion.offset; 
    58                                 //rename references 
    59                                 var ICompositeNode dList = NodeModelUtils.findActualNodeFor(rule.definitionList); 
    60                                 var String refText = "(" + dList.text + ")"; 
    61                                 var int refLength = rule.name.length; 
    62                                 var List<RuleReference> references = EbnfAnalysisUtils.findReferences(rule); 
    63                                 //********************************* 
    64                                 //is the reference in the rule itself? 
    65                                 var boolean foundRule = false; 
    66                                 var EObject r = references.get(0) as EObject; 
    67                                 var Rule containingRule = null; 
    68                                 while (!foundRule) { 
    69                                         r = r.eContainer; 
    70                                         if (r instanceof Rule) { 
    71                                                 containingRule = r as Rule; 
    72                                                 foundRule = true; 
    73                                         } 
    74                                 } 
    75                                 if (!rule.equals(containingRule)) { 
    76          
    77                                                                         for (ruleRef : references) { 
    78                                                                                 var ICompositeNode refNode = NodeModelUtils.findActualNodeFor(ruleRef); 
    79                                                                                 var int refOffset = refNode.textRegion.offset; 
    80                                          
    81                                                                                 xtextDocument.replace(refOffset, refLength, refText); 
    82                                                                                 if (refOffset < offset) { 
    83                                                                                         offset += refText.length - refLength; 
    84                                                                                 } 
    85                                                                         } 
    86                                                                          
    87                                 // delete rule 
    88                                 } 
    89                                  
    90                                 xtextDocument.replace(offset, textLength, ""); 
    91                         ] 
    92          
    93                 } 
     44//              @Fix(EbnfValidator.ruleReferencedOneDescription) 
     45//              def void fixInlineRuleReferencedOnce(Issue issue, IssueResolutionAcceptor acceptor) { 
     46//                      acceptor.accept( 
     47//                              issue, 
     48//                              "Inline the rule", 
     49//                              "Delete the rule and replace its single reference by the rule's right side", 
     50//                              "upcase.png" 
     51//                      ) [ element, context | 
     52//                              var Rule rule = element as Rule; 
     53//                              var IXtextDocument xtextDocument = context.getXtextDocument(); 
     54//                              var ICompositeNode node = NodeModelUtils.findActualNodeFor(rule); 
     55//                              var String nodeText = node.text; 
     56//                              var int textLength = nodeText.length - 2; 
     57//                              var int offset = node.textRegion.offset; 
     58//                              //rename references 
     59//                              var ICompositeNode dList = NodeModelUtils.findActualNodeFor(rule.definitionList); 
     60//                              var String refText = "(" + dList.text + ")"; 
     61//                              var int refLength = rule.name.length; 
     62//                              var List<RuleReference> references = EbnfAnalysisUtils.findReferences(rule); 
     63//                              //********************************* 
     64//                              //is the reference in the rule itself? 
     65//                              var boolean foundRule = false; 
     66//                              var EObject r = references.get(0) as EObject; 
     67//                              var Rule containingRule = null; 
     68//                              while (!foundRule) { 
     69//                                      r = r.eContainer; 
     70//                                      if (r instanceof Rule) { 
     71//                                              containingRule = r as Rule; 
     72//                                              foundRule = true; 
     73//                                      } 
     74//                              } 
     75//                              if (!rule.equals(containingRule)) { 
     76//       
     77//                                                                      for (ruleRef : references) { 
     78//                                                                              var ICompositeNode refNode = NodeModelUtils.findActualNodeFor(ruleRef); 
     79//                                                                              var int refOffset = refNode.textRegion.offset; 
     80//                                       
     81//                                                                              xtextDocument.replace(refOffset, refLength, refText); 
     82//                                                                              if (refOffset < offset) { 
     83//                                                                                      offset += refText.length - refLength; 
     84//                                                                              } 
     85//                                                                      } 
     86//                                                                       
     87//                              // delete rule 
     88//                              } 
     89//                               
     90//                              xtextDocument.replace(offset, textLength, ""); 
     91//                      ] 
     92//       
     93//              } 
    9494         
    9595//      // this is not working by unknown reasons  
    9696//      @Fix(EbnfValidator.ruleReferencedOneDescription) 
    9797//      def void fixInlineRuleReferencedOnce(Issue issue, IssueResolutionAcceptor acceptor) { 
     98//              System.out.println("test"); 
    9899//              acceptor.accept( 
    99100//                      issue, 
     
    105106//                      var DefinitionList dlist = rule.definitionList; 
    106107//                      var List<Rule> rules=EbnfAnalysisUtils.getAllRules(rule.eContainer().eContainer() as EtsiBnf); 
    107 //                      var SingleDefinition sDef = rules.get(1).definitionList.singleDefinition.get(1); 
     108//                      var SingleDefinition sDef = rules.get(0).definitionList.singleDefinition.get(0); 
     109//                       
     110//                      System.out.println(dlist.singleDefinition); 
    108111//                      dlist.singleDefinition.add(sDef); 
     112//                      System.out.println(dlist.singleDefinition); 
     113//                       
    109114//                      rule.name="bla"; 
    110 //              ] 
    111 // 
     115//                      ] 
     116 
    112117//      } 
    113118 
  • v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/.classpath

    r61 r69  
    66        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> 
    77        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> 
     8        <classpathentry kind="lib" path="C:/Users/hauke/Desktop/Uni/Hiwijob bnf tools/fop-1.1/lib/avalon-framework-4.2.0.jar"/> 
     9        <classpathentry kind="lib" path="C:/Users/hauke/Desktop/Uni/Hiwijob bnf tools/fop-1.1/lib/batik-all-1.7.jar"/> 
     10        <classpathentry kind="lib" path="C:/Users/hauke/Desktop/Uni/Hiwijob bnf tools/fop-1.1/lib/commons-io-1.3.1.jar"/> 
     11        <classpathentry kind="lib" path="C:/Users/hauke/Desktop/Uni/Hiwijob bnf tools/fop-1.1/lib/commons-logging-1.0.4.jar"/> 
     12        <classpathentry kind="lib" path="C:/Users/hauke/Desktop/Uni/Hiwijob bnf tools/fop-1.1/lib/serializer-2.7.0.jar"/> 
     13        <classpathentry kind="lib" path="C:/Users/hauke/Desktop/Uni/Hiwijob bnf tools/fop-1.1/lib/xalan-2.7.0.jar"/> 
     14        <classpathentry kind="lib" path="C:/Users/hauke/Desktop/Uni/Hiwijob bnf tools/fop-1.1/lib/xercesImpl-2.7.1.jar"/> 
     15        <classpathentry kind="lib" path="C:/Users/hauke/Desktop/Uni/Hiwijob bnf tools/fop-1.1/lib/xml-apis-1.3.04.jar"/> 
     16        <classpathentry kind="lib" path="C:/Users/hauke/Desktop/Uni/Hiwijob bnf tools/fop-1.1/lib/xml-apis-ext-1.3.04.jar"/> 
     17        <classpathentry kind="lib" path="C:/Users/hauke/Desktop/Uni/Hiwijob bnf tools/fop-1.1/lib/xmlgraphics-commons-1.5.jar"/> 
     18        <classpathentry kind="lib" path="C:/Users/hauke/Desktop/Uni/Hiwijob bnf tools/fop-1.1/build/fop.jar"/> 
    819        <classpathentry kind="output" path="bin"/> 
    920</classpath> 
  • v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/generator/EbnfGenerator.xtend

    r65 r69  
    2020import de.ugoe.cs.swe.bnftools.ebnf.StringRule 
    2121import java.io.File 
     22import org.eclipse.xtext.generator.IFileSystemAccessExtension2 
     23import org.eclipse.emf.common.util.URI; 
    2224 
    2325/** 
     
    3234                        if (e.bnfEntry.size!=0) { 
    3335                                 fsa.generateFile(e.name + ".fo", e.compile) 
     36                                  
     37                                 //generate pdf 
     38//                               var uri = (fsa as IFileSystemAccessExtension2).getURI(e.name+".fo"); 
     39//                               (fsa as IFileSystemAccessExtension2). 
     40//                               
     41//                               System.out.println(uri.hasAbsolutePath()); 
     42//                               System.out.println(uri.path.substring(0,uri.path.length-3)); 
     43//                               System.out.println(uri.file); 
     44//                               System.out.println(uri.toString()); 
     45//                               var File file = new File(uri.path).absoluteFile; 
     46//                               System.out.println(file.exists); 
     47//                               var String aPath = file.absolutePath; 
     48//                                
     49//                               foToPdf.createPdfFromFo(file,aPath.substring(0,aPath.length-3)); 
    3450                        } 
    3551                } 
Note: See TracChangeset for help on using the changeset viewer.