- Timestamp:
- 11/30/10 11:37:47 (14 years ago)
- Location:
- trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfHtmlFormatterVisitor.java
r42 r43 10 10 import org.eclipse.xtext.parsetree.NodeUtil; 11 11 12 import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList; 12 13 import de.ugoe.cs.swe.bnftools.ebnf.EtsiBnf; 13 14 import de.ugoe.cs.swe.bnftools.ebnf.Import; … … 15 16 import de.ugoe.cs.swe.bnftools.ebnf.RuleReference; 16 17 import de.ugoe.cs.swe.bnftools.ebnf.SectionHeading; 18 import de.ugoe.cs.swe.bnftools.ebnf.SingleDefinition; 17 19 import de.ugoe.cs.swe.bnftools.ebnf.StringRule; 18 20 … … 193 195 isParagraphOpen = false; 194 196 } 195 197 openParagraph(); 198 196 199 if ((ruleSpacingStack != null) && (!ruleSpacingStack.empty())) { 197 200 newLineOffsetCounter = ruleSpacingStack.peek(); … … 215 218 metaText("</span>"); 216 219 } 220 221 protected void wrap() { 222 if ((config.isWrapAfterThreshold()) && (newLineOffsetCounter > config.getWrapThreshold())) { 223 char last = buf.toString().charAt(buf.toString().length()-1); 224 if (!((last == '(' || last == '[' || last == '{' ))) { 225 newLine(); 226 newLine(); 227 if (ruleSpacingStack.size() > 1) 228 spaces(ruleSpacingStack.peek() + 1); 229 else 230 spaces(ruleSpacingStack.peek()); 231 } 232 } 233 } 234 235 private void closeOpenParagraph() { 236 if (isParagraphOpen) { 237 metaText("\n</p>\n"); 238 isParagraphOpen = false; 239 } 240 } 241 242 private void openParagraph() { 243 if (!isParagraphOpen) { 244 metaText("\n<p class=PL style='mso-pagination:widow-orphan lines-together;page-break-after: avoid'>\n"); 245 isParagraphOpen = true; 246 } 247 } 217 248 // ----------------------------------------------------------------------------- 218 249 … … 223 254 originalTextNoWhitespaces = originalText.replaceAll("[ \t\n\r]", ""); 224 255 225 textTransformed("grammar " + node.getName(), "");256 textTransformed("grammar " + node.getName(), ""); 226 257 if (node.getType() != null) 227 textTransformed(node.getType(),""); 228 textTransformed(";",""); 229 metaText("<body lang=EN-US link=blue vlink=purple style='tab-interval:14.15pt'>\n"); 230 metaText("<div class=WordSection1>\n"); 258 textTransformed(node.getType(), ""); 259 textTransformed(";", ""); 260 // metaText("<body lang=EN-US link=blue vlink=purple style='tab-interval:14.15pt'>"); 261 // metaText("<div class=WordSection1>"); 262 // System.out.println("call!!!"); 231 263 232 264 // newLine(); … … 235 267 236 268 protected void visitAfter(EtsiBnf node) { 269 closeOpenParagraph(); 270 237 271 metaText("</div>\n"); 238 272 metaText("</body>\n"); … … 268 302 269 303 protected void visitAfter(SectionHeading node) { 270 } 271 304 // newLine(); 305 closeOpenParagraph(); 306 } 307 272 308 protected void visitBefore(RuleReference node) { 273 309 wrap(); 274 310 275 metaText("<u><span style='color:blue'><a href=\"#T" + node.getRuleref().getName() + "\">"); 276 text(node.getRuleref().getName()); 277 metaText("</a></span></u>"); 311 metaText("<u><span style='color:blue'><a href=\"#T" + node.getRuleref().getName().replaceAll("[ \t\n\r]","") + "\">"); 312 textTransformed(node.getRuleref().getName(), node.getRuleref().getName().replaceAll("[ \t\n\r]", "") + "</a></span></u>"); 278 313 } 279 314 … … 283 318 protected void visitBefore(Rule node) { 284 319 // if (lastWasSectionHeading) 285 newLine(); 320 321 newLine(); 286 322 287 323 lastWasSectionHeading=false; … … 292 328 text(node.getRulenumber() + ". "); 293 329 294 metaText("<span lang=EN-GB style='mso-no-proof:no'>\n<a name=\"#T" + node.getName() + "\">"); 330 metaText("<span lang=EN-GB style='mso-no-proof:no'>"); 331 metaText("<a name=\"T" + node.getName() + "\">"); 295 332 textTransformed(node.getName(), node.getName().replaceAll("[ \t\r\n]", "")); 296 333 metaText("</a>"); -
trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/HtmlFormatterHandler.java
r41 r43 1 1 package de.ugoe.cs.swe.bnftools.ui.formatter; 2 2 3 import java.io.BufferedInputStream;4 import java.io.BufferedReader;5 3 import java.io.BufferedWriter; 6 4 import java.io.File; … … 8 6 import java.io.FileWriter; 9 7 import java.io.IOException; 10 import java.net.URISyntaxException;11 import java.net.URL;12 8 13 9 import org.eclipse.core.commands.AbstractHandler; … … 15 11 import org.eclipse.core.commands.ExecutionException; 16 12 import org.eclipse.core.resources.IContainer; 17 import org.eclipse.core.resources.IWorkspace;18 import org.eclipse.core.resources.IWorkspaceRoot;19 import org.eclipse.core.resources.ResourcesPlugin;20 import org.eclipse.core.runtime.IPath;21 13 import org.eclipse.core.runtime.Platform; 22 14 import org.eclipse.emf.ecore.EObject; … … 63 55 result = result + visitor.getBuf(); 64 56 65 System.out.println(visitor.getBuf());57 // System.out.println(visitor.getBuf()); 66 58 67 writeFile(result, editor.getResource().getLocation().toPortableString().toString() + ".html"); 59 String filename = editor.getResource().getLocation().toPortableString().toString() + ".html"; 60 // System.out.println(filename); 61 writeFile(result, filename); 68 62 69 63 return null;
Note: See TracChangeset
for help on using the changeset viewer.