Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java	(revision 9)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java	(revision 9)
@@ -0,0 +1,106 @@
+package de.ugoe.cs.swe.bnftools.ui.formatter;
+
+import org.eclipse.emf.ecore.EObject;
+
+import com.sun.xml.internal.bind.v2.schemagen.xmlschema.Import;
+
+import de.ugoe.cs.swe.bnftools.ebnf.Atom;
+import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList;
+import de.ugoe.cs.swe.bnftools.ebnf.EtsiBnf;
+import de.ugoe.cs.swe.bnftools.ebnf.ExtRule;
+import de.ugoe.cs.swe.bnftools.ebnf.GlobalCombinator;
+import de.ugoe.cs.swe.bnftools.ebnf.GroupedSequence;
+import de.ugoe.cs.swe.bnftools.ebnf.HookCombinator;
+import de.ugoe.cs.swe.bnftools.ebnf.MergeRule;
+import de.ugoe.cs.swe.bnftools.ebnf.OptionalSequence;
+import de.ugoe.cs.swe.bnftools.ebnf.RepeatedSequence;
+import de.ugoe.cs.swe.bnftools.ebnf.Rule;
+import de.ugoe.cs.swe.bnftools.ebnf.RuleCombinator;
+import de.ugoe.cs.swe.bnftools.ebnf.RuleReference;
+import de.ugoe.cs.swe.bnftools.ebnf.SectionHeading;
+import de.ugoe.cs.swe.bnftools.ebnf.SingleDefinition;
+import de.ugoe.cs.swe.bnftools.ebnf.StringRule;
+import de.ugoe.cs.swe.bnftools.ebnf.Term;
+import de.ugoe.cs.swe.bnftools.ebnf.impl.EtsiBnfImpl;
+import de.ugoe.cs.swe.bnftools.visitor.EbnfVisitor;
+
+public class EbnfFormatterVisitor extends EbnfVisitor {
+	private StringBuffer buf;
+	private FormatterConfig config;
+
+	public EbnfFormatterVisitor(EObject rootNode, FormatterConfig config) {
+		super(rootNode);
+		this.config = config;
+		buf = new StringBuffer();
+	}
+
+	public EbnfFormatterVisitor(FormatterConfig config) {
+		this.config = config;
+		buf = new StringBuffer();
+	}
+
+	public StringBuffer getBuf() {
+		return buf;
+	}
+
+	// -----------------------------------------------------------------------------
+
+	protected void visit(EtsiBnf node) {
+		buf.append("grammar " + node.getName());
+		if (node.getType() != null)
+			buf.append(node.getType());
+		buf.append(";");
+	}
+
+	protected void visit(Atom node) {
+	}
+
+	protected void visit(DefinitionList node) {
+	}
+
+	protected void visit(ExtRule node) {
+	}
+
+	protected void visit(GlobalCombinator node) {
+	}
+
+	protected void visit(GroupedSequence node) {
+	}
+
+	protected void visit(HookCombinator node) {
+	}
+
+	protected void visit(Import node) {
+	}
+
+	protected void visit(MergeRule node) {
+	}
+
+	protected void visit(OptionalSequence node) {
+	}
+
+	protected void visit(RepeatedSequence node) {
+	}
+
+	protected void visit(Rule node) {
+	}
+
+	protected void visit(RuleCombinator node) {
+	}
+
+	protected void visit(RuleReference node) {
+	}
+
+	protected void visit(SectionHeading node) {
+	}
+
+	protected void visit(SingleDefinition node) {
+	}
+
+	protected void visit(StringRule node) {
+	}
+
+	protected void visit(Term node) {
+	}
+
+}
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/FormatterConfig.java
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/FormatterConfig.java	(revision 9)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/FormatterConfig.java	(revision 9)
@@ -0,0 +1,60 @@
+package de.ugoe.cs.swe.bnftools.ui.formatter;
+
+public class FormatterConfig {
+	private boolean useSpaces = true; // false=tabs, true=whitespaces
+	private int lineWrap = 80; // line in which the output should be wrapped
+	private boolean emptyLineBetweenRules = false;
+	private boolean emptyLineAfterMultiLineRule = false;
+	private boolean emptyLineBeforeSection = true;
+	private boolean emptyLineAfterSection = true;
+
+	public boolean isUseSpaces() {
+		return useSpaces;
+	}
+
+	public void setUseSpaces(boolean useSpaces) {
+		this.useSpaces = useSpaces;
+	}
+
+	public int getLineWrap() {
+		return lineWrap;
+	}
+
+	public void setLineWrap(int lineWrap) {
+		this.lineWrap = lineWrap;
+	}
+
+	public boolean isEmptyLineBetweenRules() {
+		return emptyLineBetweenRules;
+	}
+
+	public void setEmptyLineBetweenRules(boolean emptyLineBetweenRules) {
+		this.emptyLineBetweenRules = emptyLineBetweenRules;
+	}
+
+	public boolean isEmptyLineAfterMultiLineRule() {
+		return emptyLineAfterMultiLineRule;
+	}
+
+	public void setEmptyLineAfterMultiLineRule(
+			boolean emptyLineAfterMultiLineRule) {
+		this.emptyLineAfterMultiLineRule = emptyLineAfterMultiLineRule;
+	}
+
+	public boolean isEmptyLineBeforeSection() {
+		return emptyLineBeforeSection;
+	}
+
+	public void setEmptyLineBeforeSection(boolean emptyLineBeforeSection) {
+		this.emptyLineBeforeSection = emptyLineBeforeSection;
+	}
+
+	public boolean isEmptyLineAfterSection() {
+		return emptyLineAfterSection;
+	}
+
+	public void setEmptyLineAfterSection(boolean emptyLineAfterSection) {
+		this.emptyLineAfterSection = emptyLineAfterSection;
+	}
+
+}
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/FormatterProcessor.java
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/FormatterProcessor.java	(revision 8)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/FormatterProcessor.java	(revision 9)
@@ -103,7 +103,9 @@
 		compositeChange.add(fileChange);
 		
-		String newText = "foobar";
+		FormatterConfig config = new FormatterConfig();
+		EbnfFormatterVisitor visitor = new EbnfFormatterVisitor(rootNode.getElement(), config);
+		visitor.accept();
 		
-		ReplaceEdit replaceEdit = new ReplaceEdit(0, document.getLength(), newText);
+		ReplaceEdit replaceEdit = new ReplaceEdit(0, document.getLength(), visitor.getBuf().toString());
 		multiEdit.addChild(replaceEdit);
 		
