You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2013/07/17 10:28:08 UTC

svn commit: r1504047 [5/17] - in /uima/sandbox/ruta/trunk/ruta-ep-ide-ui: ./ icons/ schema/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/uima/ src/main/java/org/apache/uima/ruta/ src/main/java/org/...

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/debugger/preferences/RutaDebuggerPreferencePage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/debugger/preferences/RutaDebuggerPreferencePage.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/debugger/preferences/RutaDebuggerPreferencePage.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/debugger/preferences/RutaDebuggerPreferencePage.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.debugger.preferences;
+
+import org.apache.uima.ruta.ide.RutaIdeUIPlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPropertyAndPreferencePage;
+import org.eclipse.dltk.ui.preferences.AbstractOptionsBlock;
+import org.eclipse.dltk.ui.preferences.PreferenceKey;
+import org.eclipse.dltk.ui.util.IStatusChangeListener;
+import org.eclipse.dltk.ui.util.SWTFactory;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+
+public class RutaDebuggerPreferencePage extends AbstractConfigurationBlockPropertyAndPreferencePage {
+
+  private static String PREFERENCE_PAGE_ID = "org.apache.uima.ruta.ide.preferences.debug.engines.debugger";
+
+  private static String PROPERTY_PAGE_ID = "org.apache.uima.ruta.ide.propertyPage.debug.engines.debugger";
+
+  /*
+   * @seeorg.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPropertyAndPreferencePage#
+   * createOptionsBlock(org.eclipse.dltk.ui.util.IStatusChangeListener,
+   * org.eclipse.core.resources.IProject, org.eclipse.ui.preferences.IWorkbenchPreferenceContainer)
+   */
+  @Override
+  protected AbstractOptionsBlock createOptionsBlock(IStatusChangeListener newStatusChangedListener,
+          IProject project, IWorkbenchPreferenceContainer container) {
+    return new AbstractOptionsBlock(newStatusChangedListener, project, new PreferenceKey[] {},
+            container) {
+
+      @Override
+      protected Control createOptionsBlock(Composite parent) {
+        Composite composite = SWTFactory.createComposite(parent, parent.getFont(), 1, 1,
+                GridData.FILL);
+        SWTFactory.createLabel(composite, PreferenceMessages.NoSettingsAvailable, 1);
+        return composite;
+      }
+    };
+  }
+
+  /*
+   * @see
+   * org.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPropertyAndPreferencePage#getHelpId()
+   */
+  @Override
+  protected String getHelpId() {
+    return null;
+  }
+
+  /*
+   * @see org.eclipse.dltk.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageId()
+   */
+  @Override
+  protected String getPreferencePageId() {
+    return PREFERENCE_PAGE_ID;
+  }
+
+  /*
+   * @seeorg.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPropertyAndPreferencePage#
+   * getProjectHelpId()
+   */
+  @Override
+  protected String getProjectHelpId() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /*
+   * @see org.eclipse.dltk.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageId()
+   */
+  @Override
+  protected String getPropertyPageId() {
+    return PROPERTY_PAGE_ID;
+  }
+
+  /*
+   * @see
+   * org.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPropertyAndPreferencePage#setDescription
+   * ()
+   */
+  @Override
+  protected void setDescription() {
+    setDescription(PreferenceMessages.PreferencesDescription);
+  }
+
+  /*
+   * @seeorg.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPropertyAndPreferencePage#
+   * setPreferenceStore()
+   */
+  @Override
+  protected void setPreferenceStore() {
+    setPreferenceStore(RutaIdeUIPlugin.getDefault().getPreferenceStore());
+  }
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/Messages.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/Messages.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/Messages.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/Messages.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.formatter;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+  private static final String BUNDLE_NAME = "org.apache.uima.ruta.ide.formatter.internal.messages"; //$NON-NLS-1$
+
+  public static String RutaFormatter_contentCorrupted;
+  static {
+    // initialize resource bundle
+    NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+  }
+
+  private Messages() {
+  }
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormattedPrinter.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormattedPrinter.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormattedPrinter.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormattedPrinter.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,862 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.formatter;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.antlr.runtime.CommonToken;
+import org.apache.uima.ruta.ide.core.RutaConstants;
+import org.apache.uima.ruta.ide.parser.ast.ActionFactory;
+import org.apache.uima.ruta.ide.parser.ast.ComposedRuleElement;
+import org.apache.uima.ruta.ide.parser.ast.ConditionFactory;
+import org.apache.uima.ruta.ide.parser.ast.RutaAbstractDeclaration;
+import org.apache.uima.ruta.ide.parser.ast.RutaAction;
+import org.apache.uima.ruta.ide.parser.ast.RutaBinaryArithmeticExpression;
+import org.apache.uima.ruta.ide.parser.ast.RutaBlock;
+import org.apache.uima.ruta.ide.parser.ast.RutaBooleanNumberExpression;
+import org.apache.uima.ruta.ide.parser.ast.RutaCondition;
+import org.apache.uima.ruta.ide.parser.ast.RutaConditionConstants;
+import org.apache.uima.ruta.ide.parser.ast.RutaDeclarationsStatement;
+import org.apache.uima.ruta.ide.parser.ast.RutaDeclareDeclarationsStatement;
+import org.apache.uima.ruta.ide.parser.ast.RutaExpression;
+import org.apache.uima.ruta.ide.parser.ast.RutaFeatureDeclaration;
+import org.apache.uima.ruta.ide.parser.ast.RutaListExpression;
+import org.apache.uima.ruta.ide.parser.ast.RutaLogAction;
+import org.apache.uima.ruta.ide.parser.ast.RutaPackageDeclaration;
+import org.apache.uima.ruta.ide.parser.ast.RutaQuantifierLiteralExpression;
+import org.apache.uima.ruta.ide.parser.ast.RutaRegExpRule;
+import org.apache.uima.ruta.ide.parser.ast.RutaRule;
+import org.apache.uima.ruta.ide.parser.ast.RutaRuleElement;
+import org.apache.uima.ruta.ide.parser.ast.RutaStringExpression;
+import org.apache.uima.ruta.ide.parser.ast.RutaStructureAction;
+import org.apache.uima.ruta.ide.parser.ast.RutaTypeConstants;
+import org.apache.uima.ruta.ide.parser.ast.RutaTypeDeclaration;
+import org.apache.uima.ruta.ide.parser.ast.RutaVariableReference;
+import org.eclipse.dltk.ast.ASTListNode;
+import org.eclipse.dltk.ast.ASTNode;
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.declarations.Declaration;
+import org.eclipse.dltk.ast.declarations.MethodDeclaration;
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.ast.declarations.TypeDeclaration;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.expressions.StringLiteral;
+import org.eclipse.dltk.ast.statements.Block;
+import org.eclipse.dltk.ast.statements.Statement;
+import org.eclipse.dltk.formatter.FormatterDocument;
+import org.eclipse.dltk.formatter.IFormatterIndentGenerator;
+
+/**
+ * Formats a document.<br>
+ * Use the append methods within the visit methods to preserve the comments.
+ * 
+ * 
+ */
+public class RutaFormattedPrinter extends ASTVisitor {
+
+  private FormatterDocument document;
+
+  private String lineDelimiter;
+
+  private static final String SEMI = ";";
+
+  private static final String CONCAT = " + ";
+
+  private static final String COMMA = ",";
+
+  private static final int NL_DECLS_COUNT = 2;
+
+  private static final String CURLY_OPEN = "{";
+
+  private static final String CURLY_CLOSE = "}";
+
+  private static final String BRACK_OPEN = "[";
+
+  private static final String BRACK_CLOSE = "]";
+
+  private static final String THEN = "->";
+
+  private static final String PAR_OPEN = "(";
+
+  private static final String PAR_CLOSE = ")";
+
+  private static final String EQUALS = " = ";
+
+  private IFormatterIndentGenerator indentGenerator;
+
+  private StringBuilder output;
+
+  private List<CommonToken> comments;
+
+  private Iterator<CommonToken> iterator;
+
+  private CommonToken currentComment;
+
+  private int indentLevel = 0;
+
+  private int lines_before_long_declarations;
+
+  private int maxLineLength;
+
+  private boolean inBlockDeclaration = false;
+
+  private Map<Integer, Object> lastStatements = new HashMap<Integer, Object>();
+
+  private int commentLineSince = 0;
+
+  // hotfix: 0 = false, 1 = first rule element, 3 = not first rule element
+  private int inLargeRule = 0;
+
+  private boolean retainLB = true;
+
+  public RutaFormattedPrinter(FormatterDocument document, String lineDelimiter,
+          IFormatterIndentGenerator indentGenerator, List<CommonToken> comments, RutaFormatter tmf) {
+    this.document = document;
+    this.lineDelimiter = lineDelimiter;
+    this.indentGenerator = indentGenerator;
+    this.output = new StringBuilder();
+
+    // read format preferences
+    this.lines_before_long_declarations = tmf
+            .getInt(RutaFormatterConstants.LINES_BEFORE_LONG_DECLARATIONS);
+    this.maxLineLength = tmf.getInt(RutaFormatterConstants.MAX_LINE_LENGTH);
+
+    // comments
+    this.comments = comments == null ? new ArrayList<CommonToken>() : comments;
+    iterator = this.comments.iterator();
+    this.currentComment = iterator.hasNext() ? iterator.next() : null;
+  }
+
+  public String getOutput() {
+    appendLeftComments();
+    return this.output.toString();
+  }
+
+  @Override
+  public boolean visit(Statement s) throws Exception {
+
+    appendComments(s);
+    fillNewLines(s);
+
+    if (s instanceof RutaDeclarationsStatement) {
+      // append new lines before LONG DECLARATIONS
+      RutaDeclarationsStatement decls = (RutaDeclarationsStatement) s;
+      // if (decls.getDeclarationsCount() > NL_DECLS_COUNT) {
+      // for (int i = 0; i < lines_before_long_declarations; i++) {
+      // appendNewLine();
+      // }
+      // }
+      // format declarations:
+      // print type token
+      appendIntoNewLine(document.get(decls.getTypeTokenStart(), decls.getTypeTokenEnd()) + " ");
+      // print parent if available
+      if (s instanceof RutaDeclareDeclarationsStatement) {
+        RutaDeclareDeclarationsStatement dds = (RutaDeclareDeclarationsStatement) s;
+        ASTNode p = dds.getParent();
+        if (p != null) {
+          append(p);
+          append(" ");
+        }
+      }
+      // print identifiers
+      List<RutaAbstractDeclaration> declarations = decls.getDeclarations();
+      traverseAstNodes(declarations);
+      // print init expr
+      if (decls.getInitExpr() != null) {
+        append(EQUALS);
+        decls.getInitExpr().traverse(this);
+      }
+      appendStatementEnd();
+      return false;
+    }
+    if (s instanceof RutaRegExpRule) {
+      // traverse into container RutaRule to format RuleElements
+      if (!inBlockDeclaration) {
+        appendNewLine();
+      }
+      // Rules always just consists of RuleElements: whitespace separation
+      if (s.sourceEnd() - s.sourceStart() > 2 * maxLineLength) {
+        inLargeRule = 1;
+        indentLevel++;
+      }
+      RutaRule rule = (RutaRule) s;
+      List<Expression> expressions = rule.getExpressions();
+      if (expressions != null && !expressions.isEmpty()) {
+        append(expressions.get(0));
+        append(" " + THEN + " ");
+        if (expressions.size() > 1) {
+          for (int i = 1; i < expressions.size(); i++) {
+            Expression expression = expressions.get(i);
+            if (expression.getKind() == RutaTypeConstants.RUTA_TYPE_N && i < expressions.size() - 1) {
+              append(expression);
+              append(EQUALS);
+              append(expressions.get(++i));
+            } else {
+              append(expression);
+            }
+            if (i < expressions.size() - 1) {
+              append(COMMA + " ");
+            }
+          }
+        }
+      }
+      if (!inBlockDeclaration) {
+        appendStatementEnd();
+      }
+      if (inLargeRule > 0) {
+        indentLevel--;
+        inLargeRule = 0;
+      }
+      return false;
+    }
+
+    if (s instanceof RutaRule) {
+      // traverse into container RutaRule to format RuleElements
+      if (!inBlockDeclaration) {
+        appendNewLine();
+      }
+      // Rules always just consists of RuleElements: whitespace separation
+      if (s.sourceEnd() - s.sourceStart() > 2 * maxLineLength) {
+        inLargeRule = 1;
+        indentLevel++;
+      }
+      RutaRule rule = (RutaRule) s;
+      List<Expression> expressions = rule.getExpressions();
+      String sep = "";
+      traverseAstNodes(expressions, sep);
+      if (!inBlockDeclaration) {
+        appendStatementEnd();
+      }
+      if (inLargeRule > 0) {
+        indentLevel--;
+        inLargeRule = 0;
+      }
+      return false;
+      // return true;
+    }
+    if (s instanceof RutaTypeDeclaration) {
+      append(s);
+      List<RutaFeatureDeclaration> features = ((RutaTypeDeclaration) s).getFeatures();
+      if (features != null && !features.isEmpty()) {
+        append(PAR_OPEN);
+        for (RutaFeatureDeclaration each : features) {
+          append(each.getType());
+          append(" ");
+          append(each.getName());
+          if (features.indexOf(each) < features.size() - 1) {
+            append(COMMA + " ");
+          }
+        }
+        append(PAR_CLOSE);
+      }
+      return false;
+    }
+
+    if (s instanceof Declaration && !(s instanceof RutaPackageDeclaration)) {
+      append(s);
+      return false;
+    }
+    if (s instanceof RutaPackageDeclaration) {
+      append(s);
+      appendStatementEnd();
+      return false;
+    }
+    // append SEMIs for all other statements
+    appendIntoNewLine(s);
+    appendStatementEnd();
+    return false;
+  }
+
+  private void fillNewLines(Object s) {
+    Object last = lastStatements.get(indentLevel);
+    // if (last == null && indentLevel > 0) {
+    // last = lastStatements.get(indentLevel - 1);
+    // }
+    if (last != null && retainLB) {
+      int start = 0;
+      int end = 0;
+      if (s instanceof Statement) {
+        end = ((ASTNode) s).sourceStart();
+      } else if (s instanceof CommonToken) {
+        end = ((CommonToken) s).getStartIndex();
+      }
+      if (last instanceof Statement) {
+        start = ((ASTNode) last).sourceEnd() + 1;
+      } else if (last instanceof CommonToken) {
+        start = ((CommonToken) last).getStopIndex();
+      }
+
+      if (start < end) {
+        String string = document.get(start, end);
+        String replaceAll = string.replaceAll(lineDelimiter, "");
+        double d = (string.length() - replaceAll.length()) / lineDelimiter.length()
+                - commentLineSince;
+        if (s instanceof CommonToken && commentLineSince == 0) {
+          d++;
+        }
+        for (int i = 1; i < d; i++) {
+          appendNewLine();
+        }
+        if (d < 2 && s instanceof RutaDeclarationsStatement && !(last instanceof Declaration)) {
+          appendNewLine();
+        }
+        commentLineSince = 0;
+      }
+    } else if (inBlockDeclaration || s instanceof CommonToken) {
+      appendNewLine();
+    }
+    lastStatements.put(indentLevel, s);
+  }
+
+  @Override
+  public boolean endvisit(Statement s) throws Exception {
+    // if (s instanceof RutaRule) {
+    // append(SEMI);
+    // return true;
+    // }
+    return super.endvisit(s);
+  }
+
+  @Override
+  public boolean visit(Expression s) throws Exception {
+    // traverse Block (first child of root element:
+    if (s instanceof Block) {
+      return true;
+    }
+    if (s instanceof ComposedRuleElement) {
+      ComposedRuleElement cre = (ComposedRuleElement) s;
+      List<Expression> elements = cre.getElements();
+      // int length = cre.sourceEnd() - cre.sourceStart();
+      if (inLargeRule == 2) {
+        inLargeRule = 4;
+      }
+      append(PAR_OPEN);
+      traverseAstNodes(elements, cre.isDisjunctive() ? " |" : "");
+      append(PAR_CLOSE);
+      appendRuleElement(cre);
+      if (inLargeRule == 4) {
+        inLargeRule = 1;
+      }
+      return false;
+    }
+    // special format for RuleElements:
+    if (s instanceof RutaRuleElement) {
+      RutaRuleElement ruleEl = (RutaRuleElement) s;
+      if (inLargeRule == 2) {
+        appendNewLine();
+      } else if (inLargeRule == 1) {
+        inLargeRule = 2;
+      }
+      appendRuleElement(ruleEl);
+      return false;
+    }
+    // special format for actions
+    if (s instanceof RutaAction) {
+      RutaAction a = (RutaAction) s;
+      String name = document.get(a.getNameStart(), a.getNameEnd());
+      append(name);
+      List<? extends ASTNode> childs = a.getChilds();
+      if (childs != null && !childs.isEmpty()) {
+        boolean addPar = !a.getName().equals(ActionFactory.IMPLICIT);
+        if (addPar) {
+          append(PAR_OPEN);
+        }
+        // special format for create
+        if (a instanceof RutaStructureAction) {
+          if (name.equals("TRIE")) {
+            printStructureAction2(a);
+          } else {
+            printStructureAction(a);
+          }
+        } else {
+          traverseAstNodes(childs);
+        }
+        // special format for log
+        if (a instanceof RutaLogAction && ((RutaLogAction) a).isLogLevelAssigned()) {
+          appendSeparator(COMMA);
+          RutaLogAction logAction = (RutaLogAction) a;
+          append(logAction.getLogLevelStart(), logAction.getLogLevelEnd());
+        }
+        if (addPar) {
+          append(PAR_CLOSE);
+        }
+      }
+      return false;
+    }
+    // special format for conditions
+    if (s instanceof RutaCondition) {
+      RutaCondition c = (RutaCondition) s;
+      append(document.get(c.getNameStart(), c.getNameEnd()));
+      List<? extends ASTNode> childs = c.getChilds();
+      // minus is a condition without parameter parantheses:
+      boolean addPar = !c.getName().equals(ConditionFactory.IMPLICIT)
+              && s.getKind() != RutaConditionConstants.COND_MINUS && childs != null
+              && !childs.isEmpty();
+      if (addPar) {
+        append(PAR_OPEN);
+      }
+      traverseAstNodes(childs);
+      if (addPar) {
+        append(PAR_CLOSE);
+      }
+      return false;
+    }
+    // special format for boolean number expressions
+    if (s instanceof RutaBooleanNumberExpression) {
+      RutaBooleanNumberExpression tmbne = (RutaBooleanNumberExpression) s;
+      append(PAR_OPEN);
+      if (tmbne.getE1() != null) {
+        tmbne.getE1().traverse(this);
+      }
+      append(tmbne.getOperator());
+      if (tmbne.getE2() != null) {
+        tmbne.getE2().traverse(this);
+      }
+      append(PAR_CLOSE);
+      return false;
+    }
+    // special format for string expressions
+    if (s instanceof RutaStringExpression && ((RutaExpression) s).getExpression() != null) {
+      RutaStringExpression tmse = (RutaStringExpression) s;
+      List<?> childs = tmse.getExpression().getChilds();
+      Object object2 = childs.get(0);
+      if (object2 instanceof ASTNode) {
+        ASTNode astnode = (ASTNode) object2;
+        List<?> childs2 = astnode.getChilds();
+        for (Object object : childs2) {
+          if (object instanceof RutaExpression) {
+            RutaExpression expr = (RutaExpression) object;
+            // if (expr.isInParantheses()) {
+            // append(PAR_OPEN);
+            // append(expr);
+            // append(PAR_CLOSE);
+            // } else {
+            append(expr);
+            // }
+          } else if (object instanceof StringLiteral) {
+            StringLiteral sl = (StringLiteral) object;
+            String value = sl.getValue();
+            append(value);
+          } else if (object instanceof RutaVariableReference) {
+            RutaVariableReference vr = (RutaVariableReference) object;
+            append(vr.getName());
+          }
+          if (childs2.indexOf(object) < childs2.size() - 1) {
+            append(CONCAT);
+          }
+        }
+      } else {
+        append(s);
+      }
+      return false;
+    }
+    if (s instanceof RutaListExpression) {
+      RutaListExpression le = (RutaListExpression) s;
+      append(CURLY_OPEN);
+      ASTListNode exprs = le.getExprs();
+      traverseAstNodes(exprs.getChilds());
+      append(CURLY_CLOSE);
+      return false;
+    }
+
+    // special format for paranthesed expressions: (expression)
+    // if (s instanceof RutaExpression && ((RutaExpression) s).isInParantheses()) {
+    // append(PAR_OPEN);
+    // append(s);
+    // append(PAR_CLOSE);
+    // return false;
+    // }
+    if (s instanceof RutaBinaryArithmeticExpression) {
+      RutaBinaryArithmeticExpression ba = (RutaBinaryArithmeticExpression) s;
+      String operator = ba.getOperator();
+      append(operator);
+      append(PAR_OPEN);
+      traverseAstNodes(ba.getChilds());
+      append(PAR_CLOSE);
+    }
+    append(s);
+    return false;
+  }
+
+  /**
+   * structure actions like CREATE, FILL with assignments.
+   * 
+   * @param a
+   */
+  private void printStructureAction(RutaAction a) {
+    RutaStructureAction tmca = (RutaStructureAction) a;
+    // structure
+    if (tmca.getStructure() != null) {
+      append(tmca.getStructure());
+    }
+    append(COMMA);
+    append(" ");
+    // number expressions
+    List<Expression> indices = tmca.getExpressions();
+    if (indices != null) {
+      traverseAstNodes(indices);
+    }
+    if (!indices.isEmpty()) {
+      append(COMMA);
+      append(" ");
+    }
+    // assignments
+    Map<Expression, Expression> assignments = tmca.getAssignments();
+    Iterator it = assignments.entrySet().iterator();
+    while (it.hasNext()) {
+      if (assignments.size() > 3) {
+        appendNewLineAndIndent();
+      }
+      Map.Entry pairs = (Map.Entry) it.next();
+      try {
+        ((Expression) pairs.getKey()).traverse(this);
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+      append(EQUALS);
+      try {
+        ((Expression) pairs.getValue()).traverse(this);
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+      if (it.hasNext()) {
+        output.append(COMMA);
+        append(" ");
+      }
+    }
+  }
+
+  private void printStructureAction2(RutaAction a) {
+    RutaStructureAction tmca = (RutaStructureAction) a;
+
+    Map<Expression, Expression> assignments = tmca.getAssignments();
+    Iterator it = assignments.entrySet().iterator();
+    while (it.hasNext()) {
+      if (assignments.size() > 3) {
+        appendNewLineAndIndent();
+      }
+      Map.Entry pairs = (Map.Entry) it.next();
+      try {
+        ((Expression) pairs.getKey()).traverse(this);
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+      append(EQUALS);
+      try {
+        ((Expression) pairs.getValue()).traverse(this);
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+      output.append(COMMA);
+      append(" ");
+    }
+    // structure
+    if (tmca.getStructure() != null) {
+      append(tmca.getStructure());
+    }
+    append(COMMA);
+    append(" ");
+    // number expressions
+    List<Expression> indices = tmca.getExpressions();
+    if (indices != null) {
+      traverseAstNodes(indices);
+    }
+    // assignments
+
+  }
+
+  @Override
+  public boolean endvisit(Expression s) throws Exception {
+    return super.endvisit(s);
+  }
+
+  /**
+   * @param ruleEl
+   * @param conditions
+   * @param actions
+   */
+  private void appendRuleElement(RutaRuleElement ruleEl) {
+    // if (ruleEl instanceof ComposedRuleElement) {
+    // ComposedRuleElement cre = (ComposedRuleElement) ruleEl;
+    // List<Expression> elements = cre.getElements();
+    // append(PAR_OPEN);
+    // for (Expression expression : elements) {
+    //
+    // if (expression instanceof RutaRuleElement) {
+    // RutaRuleElement re = (RutaRuleElement) expression;
+    // appendRuleElement(re);
+    // }
+    // if (elements.indexOf(expression) < elements.size() - 1) {
+    // append(" ");
+    // }
+    //
+    // }
+    // append(PAR_CLOSE);
+    // } else
+    if (ruleEl.getHead() != null) {
+      append(ruleEl.getHead());
+    }
+    List<RutaCondition> conditions = ruleEl.getConditions();
+    List<RutaAction> actions = ruleEl.getActions();
+    // don't print {->} for empty rule elements
+
+    // print Quantifiers
+    List<? extends ASTNode> quantifierExpressions = ruleEl.getQuantifierExpressions();
+    if (quantifierExpressions != null && !quantifierExpressions.isEmpty()) {
+      if (quantifierExpressions.size() == 1) {
+        ASTNode astNode = quantifierExpressions.get(0);
+        if (astNode instanceof RutaQuantifierLiteralExpression) {
+          append(astNode);
+        } else {
+          append(BRACK_OPEN);
+          append(astNode);
+          append(BRACK_CLOSE);
+        }
+      } else if (quantifierExpressions.size() == 2) {
+        if (quantifierExpressions.get(1) instanceof RutaQuantifierLiteralExpression) {
+          append(BRACK_OPEN);
+          append(quantifierExpressions.get(0));
+          append(BRACK_CLOSE);
+          append(quantifierExpressions.get(1));
+        } else {
+          append(BRACK_OPEN);
+          append(quantifierExpressions.get(0));
+          append(COMMA + " ");
+          append(quantifierExpressions.get(1));
+          append(BRACK_CLOSE);
+        }
+      } else if (quantifierExpressions.size() == 3) {
+        append(BRACK_OPEN);
+        append(quantifierExpressions.get(0));
+        append(COMMA + " ");
+        append(quantifierExpressions.get(1));
+        append(BRACK_CLOSE);
+        append(quantifierExpressions.get(2));
+      }
+    }
+    if (!inBlockDeclaration && conditions == null && actions == null) {
+      return;
+    }
+
+    if (!inBlockDeclaration
+            && ((conditions == null && actions.isEmpty()) || actions == null
+                    && (conditions != null) && conditions.isEmpty())) {
+      return;
+    }
+    append(CURLY_OPEN);
+    // print Conditions
+    if (conditions != null && !conditions.isEmpty()) {
+      traverseAstNodes(conditions);
+    }
+    if (conditions != null && !conditions.isEmpty()) {
+    }
+    // print Actions
+    if (actions != null && !actions.isEmpty()) {
+      if (conditions != null && !conditions.isEmpty()) {
+        append(" " + THEN + " ");
+      } else {
+        append(THEN + " ");
+      }
+      traverseAstNodes(actions);
+    }
+    append(CURLY_CLOSE);
+  }
+
+  /**
+   * @param astnodes
+   */
+  @SuppressWarnings("unchecked")
+  private void traverseAstNodes(List<? extends ASTNode> astnodes) {
+    traverseAstNodes(astnodes, COMMA);
+  }
+
+  /**
+   * @param astnodes
+   */
+  @SuppressWarnings("unchecked")
+  private void traverseAstNodes(List<? extends ASTNode> astnodes, String separator) {
+    if (astnodes == null) {
+      return;
+    }
+    Iterator iterator2 = astnodes.iterator();
+    while (iterator2.hasNext()) {
+      ASTNode node = (ASTNode) iterator2.next();
+      try {
+        node.traverse(this);
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+      if (iterator2.hasNext()) {
+        appendSeparator(separator);
+      }
+    }
+  }
+
+  private void appendSeparator(String separator) {
+    output.append(separator);
+    append(" ");
+  }
+
+  @Override
+  public boolean visit(MethodDeclaration s) throws Exception {
+    appendComments(s);
+    fillNewLines(s);
+
+    // Statement last = lastStatements.get(indentLevel);
+    // // if (last == null && indentLevel > 0) {
+    // // last = lastStatements.get(indentLevel - 1);
+    // // }
+    // if (last != null && retainLB) {
+    // int start = last.sourceEnd() + 1;
+    // int end = s.sourceStart();
+    // if (start < end) {
+    // String string = document.get(start, end);
+    // String replaceAll = string.replaceAll(lineDelimiter, "");
+    // double d = (string.length() - replaceAll.length()) / lineDelimiter.length()
+    // - commentLineSince;
+    // for (int i = 1; i < d; i++) {
+    // appendNewLine();
+    // }
+    // commentLineSince = 0;
+    // }
+    // }
+
+    if (s instanceof RutaBlock) {
+      RutaBlock b = (RutaBlock) s;
+      appendIntoNewLine("BLOCK(");
+      append(b.getName());
+      append(") ");
+      this.inBlockDeclaration = true;
+      if (b.getRule() != null) {
+        b.getRule().traverse(this);
+      }
+      this.inBlockDeclaration = false;
+      append(" {");
+      indentLevel++;
+      b.getBody().traverse(this);
+      lastStatements.put(indentLevel, null);
+      indentLevel--;
+      lastStatements.put(indentLevel, s);
+      appendIntoNewLine("}");
+      appendNewLine();
+      return false;
+    }
+    return super.visit(s);
+  }
+
+  @Override
+  public boolean visit(ModuleDeclaration s) throws Exception {
+    return true;
+  }
+
+  @Override
+  public boolean visit(TypeDeclaration s) throws Exception {
+    return super.visit(s);
+  }
+
+  @Override
+  public boolean visitGeneral(ASTNode node) throws Exception {
+    return super.visitGeneral(node);
+  }
+
+  private void append(int begin, int end) {
+    append(document.get(begin, end));
+  }
+
+  private void append(String string) {
+    if (outputPosInLine() + string.length() > maxLineLength) {
+      appendNewLine();
+      indentGenerator.generateIndent(1, output);
+    }
+    output.append(string);
+  }
+
+  private void appendIntoNewLine(String string) {
+    appendNewLine();
+    output.append(string);
+  }
+
+  private void append(ASTNode s) {
+    appendComments(s);
+    // this.output.
+    append(document.get(s.sourceStart(), s.sourceEnd()));
+  }
+
+  private void appendIntoNewLine(ASTNode s) {
+    appendComments(s);
+    appendNewLine();
+    append(s);
+  }
+
+  private void appendNewLine() {
+    output.append(lineDelimiter);
+    indentGenerator.generateIndent(indentLevel, output);
+  }
+
+  private void appendNewLineAndIndent() {
+    output.append(lineDelimiter);
+    indentGenerator.generateIndent(indentLevel + 1, output);
+  }
+
+  private void appendStatementEnd() {
+    output.append(SEMI);
+  }
+
+  /**
+   * @param s
+   * @return
+   */
+  private int appendComments(ASTNode s) {
+    return appendComments(s.sourceStart());
+  }
+
+  /**
+   * @param start
+   * @return
+   */
+  private int appendComments(int start) {
+    while (currentComment != null && currentComment.getStartIndex() < start) {
+      String text = currentComment.getText().trim();
+      fillNewLines(currentComment);
+      append("" + text);
+      currentComment = iterator.hasNext() ? iterator.next() : null;
+      commentLineSince++;
+    }
+    return start;
+  }
+
+  private void appendLeftComments() {
+    while (currentComment != null) {
+      append(currentComment.getText());
+      currentComment = iterator.hasNext() ? iterator.next() : null;
+    }
+  }
+
+  private int outputPosInLine() {
+    String out = output.toString();
+    int lastIndexOf = out.lastIndexOf("\n");
+    return out.length() - lastIndexOf;
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatter.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatter.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatter.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatter.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.formatter;
+
+import java.io.IOException;
+import java.io.LineNumberReader;
+import java.io.Reader;
+import java.util.List;
+import java.util.Map;
+
+import org.antlr.runtime.BitSet;
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.CommonTokenStream;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.uima.ruta.engine.RutaEngine;
+import org.apache.uima.ruta.ide.core.parser.RutaSourceParser;
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.ast.parser.IModuleDeclaration;
+import org.eclipse.dltk.compiler.problem.IProblem;
+import org.eclipse.dltk.compiler.problem.IProblemReporter;
+import org.eclipse.dltk.formatter.AbstractScriptFormatter;
+import org.eclipse.dltk.formatter.FormatterDocument;
+import org.eclipse.dltk.ui.formatter.FormatterException;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
+
+public class RutaFormatter extends AbstractScriptFormatter {
+
+  class DummyReporter implements IProblemReporter {
+
+    private boolean gotProblems = false;
+
+    public void reportProblem(IProblem problem) {
+      setProblems(true);
+    }
+
+    public void setProblems(boolean gotProblems) {
+      this.gotProblems = gotProblems;
+    }
+
+    public boolean gotProblems() {
+      return gotProblems;
+    }
+  };
+
+  protected static final String[] INDENTING = { RutaFormatterConstants.INDENT_BLOCK,
+      RutaFormatterConstants.INDENT_STRUCTURE };
+
+  // protected static final String[] BLANK_LINES = { };
+
+  private final String lineDelimiter;
+
+  public RutaFormatter(String lineDelimiter, Map preferences) {
+    super(preferences);
+    this.lineDelimiter = lineDelimiter;
+  }
+
+  public TextEdit format(String source, int offset, int length, int indent)
+          throws FormatterException {
+    String input = source;
+    // TODO implement useful format for code snippets
+    // final String input = source.substring(offset, offset + length);
+    if (StringUtils.isEmpty(input)) {
+      return null;
+    }
+    RutaSourceParser tmsp = new RutaSourceParser();
+
+    DummyReporter reporter = new DummyReporter();
+    IModuleDeclaration md = tmsp.parse("format" + RutaEngine.SCRIPT_FILE_EXTENSION, source,
+            reporter);
+    CommonTokenStream tokenStream = tmsp.getTokenStream();
+
+    if (!reporter.gotProblems()) {
+
+      BitSet bs = new BitSet();
+      bs.add(org.apache.uima.ruta.parser.RutaParser.LINE_COMMENT);
+      bs.add(org.apache.uima.ruta.parser.RutaParser.COMMENT);
+      List<CommonToken> comments = tokenStream.getTokens(0, tokenStream.size(), bs);
+
+      final String output = format(input, (ModuleDeclaration) md, comments, indent);
+      if (output != null) {
+        if (!input.equals(output)) {
+          return new ReplaceEdit(0, source.length(), output);
+          // return new ReplaceEdit(offset, length, output);
+          // if (!equalsIgnoreBlanks(new StringReader(input), new StringReader(output))) {
+          // // return new MultiTextEdit();
+          // return new ReplaceEdit(offset, length, output);
+          // } else {
+          // // TODO reset throwing exception
+          // return new MultiTextEdit();
+          // // throw new IllegalArgumentException("illegal format context");
+          // // System.err.println("illegal format context");
+          // }
+        } else {
+          return new MultiTextEdit();
+        }
+      }
+    }
+    return null;
+  }
+
+  /**
+   * @param input
+   * @param md
+   * @param indent
+   * @return the formatted code
+   */
+  private String format(String input, ModuleDeclaration md, List<CommonToken> comments, int indent) {
+    final FormatterDocument document = createDocument(input);
+
+    // compute new (formatted) document structure
+    RutaFormattedPrinter tmfp = new RutaFormattedPrinter(document, lineDelimiter,
+            createIndentGenerator(), comments, this);
+    try {
+      md.traverse(tmfp);
+    } catch (Exception e) {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+    return tmfp.getOutput();
+
+    // // compute new (formatted) document structure
+    // final RutaFormatterNodeBuilder builder = new RutaFormatterNodeBuilder();
+    // IFormatterContainerNode root = builder.build(md, document);
+    // // new RutaFormatterNodeRewriter(result, document).rewrite(root);
+    // IFormatterContext context = new FormatterContext(indent);
+    // FormatterWriter writer = new FormatterWriter(document, lineDelimiter,
+    // createIndentGenerator());
+    // try {
+    // root.accept(context, writer);
+    // writer.flush(context);
+    // return writer.getOutput();
+    // } catch (Exception e) {
+    // e.printStackTrace();
+    // return null;
+    // }
+  }
+
+  /**
+   * Factory method for FormatterDocuments that represent the content with formatting options.<br>
+   * No formatting operations done in this method and no formatting done with the content of the
+   * formatterDocument in general.
+   * 
+   * @param input
+   * @return
+   */
+  private FormatterDocument createDocument(String input) {
+    FormatterDocument document = new FormatterDocument(input);
+    for (int i = 0; i < INDENTING.length; ++i) {
+      document.setBoolean(INDENTING[i], getBoolean(INDENTING[i]));
+    }
+    document.setInt(RutaFormatterConstants.FORMATTER_TAB_SIZE,
+            getInt(RutaFormatterConstants.FORMATTER_TAB_SIZE));
+    return document;
+  }
+
+  private boolean equalsIgnoreBlanks(Reader inputReader, Reader outputReader) {
+    LineNumberReader input = new LineNumberReader(inputReader);
+    LineNumberReader output = new LineNumberReader(outputReader);
+    for (;;) {
+      final String inputLine = readLine(input);
+      final String outputLine = readLine(output);
+      if (inputLine == null) {
+        if (outputLine == null) {
+          return true;
+        } else {
+          return false;
+        }
+      } else if (outputLine == null) {
+        return false;
+      } else if (!inputLine.equals(outputLine)) {
+        return false;
+      }
+    }
+  }
+
+  private String readLine(LineNumberReader reader) {
+    String line;
+    do {
+      try {
+        line = reader.readLine();
+      } catch (IOException e) {
+        return null; // just doing sth.
+      }
+      if (line == null) {
+        return line;
+      }
+      line = line.trim();
+    } while (line.length() == 0);
+    return line;
+  }
+
+  @Override
+  public int getInt(String key) {
+    return super.getInt(key);
+  }
+
+  @Override
+  protected boolean getBoolean(String key) {
+    return super.getBoolean(key);
+  }
+
+  @Override
+  protected String getString(String key) {
+    return super.getString(key);
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatterConstants.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatterConstants.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatterConstants.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatterConstants.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.formatter;
+
+import org.eclipse.dltk.ui.CodeFormatterConstants;
+
+public class RutaFormatterConstants {
+
+  public static final String FORMATTER_TAB_CHAR = CodeFormatterConstants.FORMATTER_TAB_CHAR;
+
+  public static final String FORMATTER_TAB_SIZE = CodeFormatterConstants.FORMATTER_TAB_SIZE;
+
+  public static final String FORMATTER_INDENTATION_SIZE = CodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
+
+  public static final String FORMATTER_PROFILES = "formatter.profiles"; //$NON-NLS-1$
+
+  public static final String FORMATTER_ACTIVE_PROFILE = "formatter.profiles.active"; //$NON-NLS-1$
+
+  public static final String INDENT_BLOCK = "indent.block";
+
+  public static final String INDENT_STRUCTURE = "indent.structure";
+
+  // TODO implement smarter format options, first just indentation...
+  public static final String LINES_BEFORE_LONG_DECLARATIONS = "lines.before.long.declarations";
+
+  public static final String MAX_LINE_LENGTH = "wrapping.max.line.length";
+
+  // public static final String LINES_FILE_AFTER_GLOBAL =
+  // "line.file.global.after";
+  // public static final String LINES_FILE_BEFORE_FIRST_ =
+  // "line.file.block.between";
+  // public static final String LINES_FILE_BETWEEN_BLOCK =
+  // "line.file.block.between";
+  // public static final String LINES_FILE_BETWEEN_BLOCK =
+  // "line.file.block.between";
+  // public static final String LINES_FILE_BETWEEN_BLOCK =
+  // "line.file.block.between";
+  // public static final String LINES_FILE_BETWEEN_BLOCK =
+  // "line.file.block.between";
+  // public static final String LINES_FILE_BETWEEN_BLOCK =
+  // "line.file.block.between";
+
+  public static final String LINES_PRESERVE = "lines.preserve";
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatterFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatterFactory.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatterFactory.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatterFactory.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.formatter;
+
+import java.net.URL;
+import java.util.Map;
+
+import org.apache.uima.ruta.engine.RutaEngine;
+import org.apache.uima.ruta.ide.RutaIdeUIPlugin;
+import org.apache.uima.ruta.ide.formatter.preferences.RutaFormatterModifyDialog;
+import org.eclipse.dltk.formatter.AbstractScriptFormatterFactory;
+import org.eclipse.dltk.ui.formatter.IFormatterModifyDialog;
+import org.eclipse.dltk.ui.formatter.IFormatterModifyDialogOwner;
+import org.eclipse.dltk.ui.formatter.IScriptFormatter;
+import org.eclipse.dltk.ui.preferences.PreferenceKey;
+
+public class RutaFormatterFactory extends AbstractScriptFormatterFactory {
+
+  private static final String[] KEYS = {
+      // RutaUI.PLUGIN_ID :
+      RutaFormatterConstants.FORMATTER_TAB_CHAR, RutaFormatterConstants.FORMATTER_INDENTATION_SIZE,
+      RutaFormatterConstants.FORMATTER_TAB_SIZE,
+      // RutaFormatterPlugin.PLUGIN_ID :
+      RutaFormatterConstants.INDENT_BLOCK, RutaFormatterConstants.INDENT_STRUCTURE,
+      RutaFormatterConstants.LINES_BEFORE_LONG_DECLARATIONS, RutaFormatterConstants.MAX_LINE_LENGTH };
+
+  public PreferenceKey[] getPreferenceKeys() {
+    final PreferenceKey[] result = new PreferenceKey[KEYS.length];
+    for (int i = 0; i < KEYS.length; ++i) {
+      final String key = KEYS[i];
+      final String qualifier;
+      if (RutaFormatterConstants.FORMATTER_TAB_CHAR.equals(key)
+              || RutaFormatterConstants.FORMATTER_INDENTATION_SIZE.equals(key)
+              || RutaFormatterConstants.FORMATTER_TAB_SIZE.equals(key)) {
+        qualifier = RutaIdeUIPlugin.PLUGIN_ID;
+      } else {
+        qualifier = RutaIdeUIPlugin.PLUGIN_ID;
+      }
+      result[i] = new PreferenceKey(qualifier, key);
+    }
+    return result;
+  }
+
+  @Override
+  public PreferenceKey getProfilesKey() {
+    return new PreferenceKey(RutaIdeUIPlugin.PLUGIN_ID, RutaFormatterConstants.FORMATTER_PROFILES);
+  }
+
+  public PreferenceKey getActiveProfileKey() {
+    return new PreferenceKey(RutaIdeUIPlugin.PLUGIN_ID,
+            RutaFormatterConstants.FORMATTER_ACTIVE_PROFILE);
+  }
+
+  public IScriptFormatter createFormatter(String lineDelimiter, Map preferences) {
+    return new RutaFormatter(lineDelimiter, preferences);
+  }
+
+  @Override
+  public URL getPreviewContent() {
+    return getClass().getResource("formatPreviewScript" + RutaEngine.SCRIPT_FILE_EXTENSION); //$NON-NLS-1$
+  }
+
+  public IFormatterModifyDialog createDialog(IFormatterModifyDialogOwner dialogOwner) {
+    return new RutaFormatterModifyDialog(dialogOwner, this);
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatterPreferenceInitializer.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatterPreferenceInitializer.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatterPreferenceInitializer.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormatterPreferenceInitializer.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.formatter;
+
+import org.apache.uima.ruta.ide.RutaIdeUIPlugin;
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+public class RutaFormatterPreferenceInitializer extends AbstractPreferenceInitializer {
+
+  public void initializeDefaultPreferences() {
+    RutaIdeUIPlugin plugin = RutaIdeUIPlugin.getDefault();
+    IPreferenceStore store = plugin.getPreferenceStore();
+
+    store.setDefault(RutaFormatterConstants.INDENT_BLOCK, true);
+    store.setDefault(RutaFormatterConstants.INDENT_STRUCTURE, true);
+
+    store.setDefault(RutaFormatterConstants.LINES_BEFORE_LONG_DECLARATIONS, 1);
+
+    store.setDefault(RutaFormatterConstants.LINES_PRESERVE, 1);
+
+    store.setDefault(RutaFormatterConstants.MAX_LINE_LENGTH, 100);
+  }
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/Messages.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/Messages.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/Messages.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/Messages.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.formatter.preferences;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+  private static final String BUNDLE_NAME = "org.apache.uima.ruta.ide.formatter.preferences.messages"; //$NON-NLS-1$
+
+  // public static String RutaFormatterBlankLinesPage_afterGlobalStatements;
+  // public static String RutaFormatterBlankLinesPage_befireFirstDeclaration;
+  // public static String RutaFormatterBlankLinesPage_beforeBlockDeclarations;
+  // public static String RutaFormatterBlankLinesPage_betweenBlocks;
+  public static String RutaFormatterBlankLinesPage_blankLinesBeforeDeclarations;
+
+  public static String RutaFormatterBlankLinesPage_beforeDeclarations;
+
+  // public static String RutaFormatterBlankLinesPage_existingBlankLines;
+  // public static String RutaFormatterBlankLinesPage_numberOfEmptyLinesToPreserve;
+  // public static String RutaFormatterCommentsPage_commentFormatting;
+  // public static String RutaFormatterCommentsPage_enableCommentWrapping;
+  // public static String RutaFormatterCommentsPage_maximumLineWidthForComments;
+  public static String RutaFormatterLineWrappingPage_maximumLineLenght;
+
+  public static String RutaFormatterLineWrappingPage_generalWrapping;
+
+  public static String RutaFormatterIndentationTabPage_statementsWithinBlockBody;
+
+  public static String RutaFormatterIndentationTabPage_assignmentsWithinCreateAction;
+
+  public static String RutaFormatterIndentationTabPage_generalSettings;
+
+  public static String RutaFormatterIndentationTabPage_indentationCharacter;
+
+  public static String RutaFormatterIndentationTabPage_indentationSize;
+
+  public static String RutaFormatterIndentationTabPage_indentWithinBlocks;
+
+  public static String RutaFormatterIndentationTabPage_indentWithinCreateActions;
+
+  public static String RutaFormatterIndentationTabPage_tabSize;
+
+  public static String RutaFormatterModifyDialog_blankLines;
+
+  // public static String RutaFormatterModifyDialog_comments;
+  public static String RutaFormatterModifyDialog_indentation;
+
+  public static String RutaFormatterModifyDialog_lineWrapping;
+
+  public static String RutaFormatterModifyDialog_RutaFormatter;
+  static {
+    // initialize resource bundle
+    NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+  }
+
+  private Messages() {
+  }
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterBlankLinesPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterBlankLinesPage.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterBlankLinesPage.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterBlankLinesPage.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.formatter.preferences;
+
+import java.net.URL;
+
+import org.apache.uima.ruta.engine.RutaEngine;
+import org.apache.uima.ruta.ide.formatter.RutaFormatterConstants;
+import org.eclipse.dltk.ui.formatter.FormatterModifyTabPage;
+import org.eclipse.dltk.ui.formatter.IFormatterControlManager;
+import org.eclipse.dltk.ui.formatter.IFormatterModifyDialog;
+import org.eclipse.dltk.ui.util.SWTFactory;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+public class RutaFormatterBlankLinesPage extends FormatterModifyTabPage {
+
+  /**
+   * @param dialog
+   */
+  public RutaFormatterBlankLinesPage(IFormatterModifyDialog dialog) {
+    super(dialog);
+  }
+
+  @Override
+  protected void createOptions(IFormatterControlManager manager, Composite parent) {
+    Group emptyLinesGroup = SWTFactory.createGroup(parent,
+            Messages.RutaFormatterBlankLinesPage_blankLinesBeforeDeclarations, 2, 1,
+            GridData.FILL_HORIZONTAL);
+    manager.createNumber(emptyLinesGroup, RutaFormatterConstants.LINES_BEFORE_LONG_DECLARATIONS,
+            Messages.RutaFormatterBlankLinesPage_beforeDeclarations);
+    // manager.createNumber(emptyLinesGroup,
+    // RutaFormatterConstants.LINES_FILE_BETWEEN_BLOCK,
+    // Messages.RutaFormatterBlankLinesPage_betweenBlocks);
+    // manager.createNumber(emptyLinesGroup,
+    // RutaFormatterConstants.LINES_FILE_BETWEEN_CLASS,
+    // Messages.RutaFormatterBlankLinesPage_betweenClasses);
+    // manager.createNumber(emptyLinesGroup,
+    // RutaFormatterConstants.LINES_FILE_BETWEEN_METHOD,
+    // Messages.RutaFormatterBlankLinesPage_betweenMethods);
+    // //
+    // Group emptyLinesInternalGroup = SWTFactory.createGroup(parent,
+    // Messages.RutaFormatterBlankLinesPage_blankLinesWithingClassModuleDeclarations, 2, 1,
+    // GridData.FILL_HORIZONTAL);
+    // manager.createNumber(emptyLinesInternalGroup,
+    // RutaFormatterConstants.LINES_BEFORE_FIRST,
+    // Messages.RutaFormatterBlankLinesPage_befireFirstDeclaration);
+    // manager.createNumber(emptyLinesInternalGroup,
+    // RutaFormatterConstants.LINES_BEFORE_MODULE,
+    // Messages.RutaFormatterBlankLinesPage_beforeNestedModuleDeclarations);
+    // manager.createNumber(emptyLinesInternalGroup,
+    // RutaFormatterConstants.LINES_BEFORE_CLASS,
+    // Messages.RutaFormatterBlankLinesPage_beforeNestedClassDeclarations);
+    // manager.createNumber(emptyLinesInternalGroup,
+    // RutaFormatterConstants.LINES_BEFORE_METHOD,
+    // Messages.RutaFormatterBlankLinesPage_beforeMethodDeclarations);
+    // //
+    // Group preserveGroup = SWTFactory.createGroup(parent,
+    // Messages.RutaFormatterBlankLinesPage_existingBlankLines, 2, 1,
+    // GridData.FILL_HORIZONTAL);
+    // manager.createNumber(preserveGroup,
+    // RutaFormatterConstants.LINES_PRESERVE,
+    // Messages.RutaFormatterBlankLinesPage_numberOfEmptyLinesToPreserve);
+  }
+
+  @Override
+  protected URL getPreviewContent() {
+    return getClass().getResource("blank-lines-preview" + RutaEngine.SCRIPT_FILE_EXTENSION); //$NON-NLS-1$
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterIndentationTabPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterIndentationTabPage.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterIndentationTabPage.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterIndentationTabPage.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.formatter.preferences;
+
+import java.net.URL;
+
+import org.apache.uima.ruta.engine.RutaEngine;
+import org.apache.uima.ruta.ide.formatter.RutaFormatterConstants;
+import org.eclipse.dltk.ui.CodeFormatterConstants;
+import org.eclipse.dltk.ui.formatter.FormatterModifyTabPage;
+import org.eclipse.dltk.ui.formatter.IFormatterControlManager;
+import org.eclipse.dltk.ui.formatter.IFormatterModifyDialog;
+import org.eclipse.dltk.ui.preferences.FormatterMessages;
+import org.eclipse.dltk.ui.util.SWTFactory;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
+
+public class RutaFormatterIndentationTabPage extends FormatterModifyTabPage {
+
+  /**
+   * @param dialog
+   */
+  public RutaFormatterIndentationTabPage(IFormatterModifyDialog dialog) {
+    super(dialog);
+  }
+
+  private Combo tabPolicy;
+
+  private Text indentSize;
+
+  private Text tabSize;
+
+  private final String[] tabPolicyItems = new String[] { CodeFormatterConstants.SPACE,
+      CodeFormatterConstants.TAB, CodeFormatterConstants.MIXED };
+
+  private class TabPolicyListener extends SelectionAdapter implements
+          IFormatterControlManager.IInitializeListener {
+
+    private final IFormatterControlManager manager;
+
+    public TabPolicyListener(IFormatterControlManager manager) {
+      this.manager = manager;
+    }
+
+    @Override
+    public void widgetSelected(SelectionEvent e) {
+      int index = tabPolicy.getSelectionIndex();
+      if (index >= 0) {
+        final boolean tabMode = CodeFormatterConstants.TAB.equals(tabPolicyItems[index]);
+        manager.enableControl(indentSize, !tabMode);
+      }
+    }
+
+    public void initialize() {
+      final boolean tabMode = CodeFormatterConstants.TAB.equals(manager
+              .getString(RutaFormatterConstants.FORMATTER_TAB_CHAR));
+      manager.enableControl(indentSize, !tabMode);
+    }
+
+  }
+
+  private TabPolicyListener tabPolicyListener;
+
+  @Override
+  protected void createOptions(final IFormatterControlManager manager, Composite parent) {
+    Group tabPolicyGroup = SWTFactory.createGroup(parent,
+            Messages.RutaFormatterIndentationTabPage_generalSettings, 2, 1,
+            GridData.FILL_HORIZONTAL);
+    tabPolicy = manager.createCombo(tabPolicyGroup, RutaFormatterConstants.FORMATTER_TAB_CHAR,
+            FormatterMessages.IndentationTabPage_general_group_option_tab_policy, tabPolicyItems);
+    tabPolicyListener = new TabPolicyListener(manager);
+    tabPolicy.addSelectionListener(tabPolicyListener);
+    manager.addInitializeListener(tabPolicyListener);
+    indentSize = manager.createNumber(tabPolicyGroup,
+            RutaFormatterConstants.FORMATTER_INDENTATION_SIZE,
+            FormatterMessages.IndentationTabPage_general_group_option_indent_size);
+    tabSize = manager.createNumber(tabPolicyGroup, RutaFormatterConstants.FORMATTER_TAB_SIZE,
+            FormatterMessages.IndentationTabPage_general_group_option_tab_size);
+    tabSize.addModifyListener(new ModifyListener() {
+      public void modifyText(ModifyEvent e) {
+        int index = tabPolicy.getSelectionIndex();
+        if (index >= 0) {
+          final boolean tabMode = CodeFormatterConstants.TAB.equals(tabPolicyItems[index]);
+          if (tabMode) {
+            indentSize.setText(tabSize.getText());
+          }
+        }
+      }
+    });
+    //
+    Group indentGroup = SWTFactory.createGroup(parent,
+            Messages.RutaFormatterIndentationTabPage_indentWithinBlocks, 1, 1,
+            GridData.FILL_HORIZONTAL);
+    manager.createCheckbox(indentGroup, RutaFormatterConstants.INDENT_BLOCK,
+            Messages.RutaFormatterIndentationTabPage_statementsWithinBlockBody);
+    Group indentBlocks = SWTFactory.createGroup(parent,
+            Messages.RutaFormatterIndentationTabPage_indentWithinCreateActions, 1, 1,
+            GridData.FILL_HORIZONTAL);
+    manager.createCheckbox(indentBlocks, RutaFormatterConstants.INDENT_STRUCTURE,
+            Messages.RutaFormatterIndentationTabPage_assignmentsWithinCreateAction);
+  }
+
+  @Override
+  protected URL getPreviewContent() {
+    return getClass().getResource("indentation-preview" + RutaEngine.SCRIPT_FILE_EXTENSION);
+  }
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterLineWrappingPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterLineWrappingPage.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterLineWrappingPage.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterLineWrappingPage.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.formatter.preferences;
+
+import java.net.URL;
+
+import org.apache.uima.ruta.engine.RutaEngine;
+import org.apache.uima.ruta.ide.formatter.RutaFormatterConstants;
+import org.eclipse.dltk.ui.formatter.FormatterModifyTabPage;
+import org.eclipse.dltk.ui.formatter.IFormatterControlManager;
+import org.eclipse.dltk.ui.formatter.IFormatterModifyDialog;
+import org.eclipse.dltk.ui.util.SWTFactory;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+public class RutaFormatterLineWrappingPage extends FormatterModifyTabPage {
+
+  /**
+   * @param dialog
+   */
+  public RutaFormatterLineWrappingPage(IFormatterModifyDialog dialog) {
+    super(dialog);
+  }
+
+  @Override
+  protected void createOptions(IFormatterControlManager manager, Composite parent) {
+    Group emptyLinesGroup = SWTFactory.createGroup(parent,
+            Messages.RutaFormatterLineWrappingPage_generalWrapping, 2, 1, GridData.FILL_HORIZONTAL);
+    manager.createNumber(emptyLinesGroup, RutaFormatterConstants.MAX_LINE_LENGTH,
+            Messages.RutaFormatterLineWrappingPage_maximumLineLenght);
+    // manager.createNumber(emptyLinesGroup,
+    // RutaFormatterConstants.LINES_FILE_BETWEEN_BLOCK,
+    // Messages.RutaFormatterBlankLinesPage_betweenBlocks);
+    // manager.createNumber(emptyLinesGroup,
+    // RutaFormatterConstants.LINES_FILE_BETWEEN_CLASS,
+    // Messages.RutaFormatterBlankLinesPage_betweenClasses);
+    // manager.createNumber(emptyLinesGroup,
+    // RutaFormatterConstants.LINES_FILE_BETWEEN_METHOD,
+    // Messages.RutaFormatterBlankLinesPage_betweenMethods);
+    // //
+    // Group emptyLinesInternalGroup = SWTFactory.createGroup(parent,
+    // Messages.RutaFormatterBlankLinesPage_blankLinesWithingClassModuleDeclarations, 2, 1,
+    // GridData.FILL_HORIZONTAL);
+    // manager.createNumber(emptyLinesInternalGroup,
+    // RutaFormatterConstants.LINES_BEFORE_FIRST,
+    // Messages.RutaFormatterBlankLinesPage_befireFirstDeclaration);
+    // manager.createNumber(emptyLinesInternalGroup,
+    // RutaFormatterConstants.LINES_BEFORE_MODULE,
+    // Messages.RutaFormatterBlankLinesPage_beforeNestedModuleDeclarations);
+    // manager.createNumber(emptyLinesInternalGroup,
+    // RutaFormatterConstants.LINES_BEFORE_CLASS,
+    // Messages.RutaFormatterBlankLinesPage_beforeNestedClassDeclarations);
+    // manager.createNumber(emptyLinesInternalGroup,
+    // RutaFormatterConstants.LINES_BEFORE_METHOD,
+    // Messages.RutaFormatterBlankLinesPage_beforeMethodDeclarations);
+    // //
+    // Group preserveGroup = SWTFactory.createGroup(parent,
+    // Messages.RutaFormatterBlankLinesPage_existingBlankLines, 2, 1,
+    // GridData.FILL_HORIZONTAL);
+    // manager.createNumber(preserveGroup,
+    // RutaFormatterConstants.LINES_PRESERVE,
+    // Messages.RutaFormatterBlankLinesPage_numberOfEmptyLinesToPreserve);
+  }
+
+  @Override
+  protected URL getPreviewContent() {
+    return getClass().getResource("wrapping-preview" + RutaEngine.SCRIPT_FILE_EXTENSION); //$NON-NLS-1$
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterModifyDialog.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterModifyDialog.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterModifyDialog.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterModifyDialog.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.formatter.preferences;
+
+import org.eclipse.dltk.ui.formatter.FormatterModifyDialog;
+import org.eclipse.dltk.ui.formatter.IFormatterModifyDialogOwner;
+import org.eclipse.dltk.ui.formatter.IScriptFormatterFactory;
+
+public class RutaFormatterModifyDialog extends FormatterModifyDialog {
+
+  /**
+   * @param parent
+   */
+  public RutaFormatterModifyDialog(IFormatterModifyDialogOwner dialogOwner,
+          IScriptFormatterFactory formatterFactory) {
+    super(dialogOwner, formatterFactory);
+    setTitle(Messages.RutaFormatterModifyDialog_RutaFormatter);
+  }
+
+  @Override
+  protected void addPages() {
+    addTabPage(Messages.RutaFormatterModifyDialog_indentation, new RutaFormatterIndentationTabPage(
+            this));
+    addTabPage(Messages.RutaFormatterModifyDialog_blankLines, new RutaFormatterBlankLinesPage(this));
+    addTabPage(Messages.RutaFormatterModifyDialog_lineWrapping, new RutaFormatterLineWrappingPage(
+            this));
+    // addTabPage(Messages.RutaFormatterModifyDialog_comments,
+    // new RutaFormatterCommentsPage(this));
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstall.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstall.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstall.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstall.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.launching;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.uima.ruta.engine.RutaEngine;
+import org.apache.uima.ruta.ide.RutaIdeUIPlugin;
+import org.apache.uima.ruta.ide.core.RutaNature;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.dltk.launching.AbstractInterpreterInstall;
+import org.eclipse.dltk.launching.IInterpreterInstallType;
+import org.eclipse.dltk.launching.IInterpreterRunner;
+
+public class GenericRutaInstall extends AbstractInterpreterInstall {
+
+  public GenericRutaInstall(IInterpreterInstallType type, String id) {
+    super(type, id);
+  }
+
+  @Override
+  public String getBuiltinModuleContent(String name) {
+    InputStream stream = GenericRutaInstall.class.getResourceAsStream("builtins"
+            + RutaEngine.SCRIPT_FILE_EXTENSION);
+    if (stream == null) {
+      return "PACKAGE org.apache.uima.ruta;\n";
+    }
+    BufferedReader br = new BufferedReader(new InputStreamReader(stream));
+    StringBuffer buf = new StringBuffer();
+    try {
+      String line = null;
+      while ((line = br.readLine()) != null) {
+        buf.append(line);
+        buf.append('\n');
+      }
+    } catch (IOException e) {
+      RutaIdeUIPlugin.error(e);
+    }
+    return buf.toString();
+  }
+
+  @Override
+  public String[] getBuiltinModules() {
+    return new String[] { "builtins" + RutaEngine.SCRIPT_FILE_EXTENSION };
+  }
+
+  @Override
+  public IInterpreterRunner getInterpreterRunner(String mode) {
+    IInterpreterRunner runner = super.getInterpreterRunner(mode);
+    if (runner != null) {
+      return runner;
+    }
+
+    if (mode.equals(ILaunchManager.RUN_MODE)) {
+      return new RutaInterpreterRunner(this);
+    }
+    return null;
+  }
+
+  public String getNatureId() {
+    return RutaNature.NATURE_ID;
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstallType.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstallType.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstallType.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstallType.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.launching;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Map;
+
+import org.apache.uima.ruta.ide.RutaIdeUIPlugin;
+import org.apache.uima.ruta.ide.core.RutaNature;
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.dltk.core.environment.IDeployment;
+import org.eclipse.dltk.core.environment.IFileHandle;
+import org.eclipse.dltk.internal.launching.AbstractInterpreterInstallType;
+import org.eclipse.dltk.launching.EnvironmentVariable;
+import org.eclipse.dltk.launching.IInterpreterInstall;
+import org.eclipse.dltk.launching.LibraryLocation;
+
+public class GenericRutaInstallType extends AbstractInterpreterInstallType {
+
+  public static final String DBGP_FOR_RUTA_BUNDLE_ID = "org.apache.uima.ruta.ide.interpreter.dbgp";
+
+  public static final String EMBEDDED_RUTA_BUNDLE_ID = "org.apache.uima.ruta.ide.interpreter";
+
+  public String getNatureId() {
+    return RutaNature.NATURE_ID;
+  }
+
+  public String getName() {
+    return "Generic Ruta Install";
+  }
+
+  @Override
+  public LibraryLocation[] getDefaultLibraryLocations(IFileHandle installLocation,
+          EnvironmentVariable[] variables, IProgressMonitor monitor) {
+    return new LibraryLocation[0];
+  }
+
+  private static String[] possibleExes = { "ruta" };
+
+  @Override
+  protected String getPluginId() {
+    return RutaIdeUIPlugin.PLUGIN_ID;
+  }
+
+  @Override
+  protected String[] getPossibleInterpreterNames() {
+    return possibleExes;
+  }
+
+  @Override
+  protected IInterpreterInstall doCreateInterpreterInstall(String id) {
+    return new GenericRutaInstall(this, id);
+  }
+
+  @Override
+  protected void filterEnvironment(Map environment) {
+    environment.remove("TMLIBPATH");
+    environment.remove("DISPLAY");
+  }
+
+  @Override
+  public IStatus validateInstallLocation(IFileHandle installLocation) {
+    return Status.OK_STATUS;
+  }
+
+  @Override
+  protected IPath createPathFile(IDeployment deployment) throws IOException {
+    throw new RuntimeException("This method should not be used");
+  }
+
+  @Override
+  protected String[] parsePaths(String result) {
+    ArrayList<String> paths = new ArrayList<String>();
+    String subs = null;
+    int index = 0;
+    while (index < result.length()) {
+      while (index < result.length() && Character.isWhitespace(result.charAt(index)))
+        index++;
+      if (index == result.length())
+        break;
+
+      if (result.charAt(index) == '{') {
+        int start = index;
+        while (index < result.length() && result.charAt(index) != '}')
+          index++;
+        if (index == result.length())
+          break;
+        subs = result.substring(start + 1, index);
+      } else {
+        int start = index;
+        while (index < result.length() && result.charAt(index) != ' ')
+          index++;
+        subs = result.substring(start, index);
+      }
+
+      paths.add(subs);
+      index++;
+    }
+
+    return (String[]) paths.toArray(new String[paths.size()]);
+  }
+
+  @Override
+  protected ILog getLog() {
+    return RutaIdeUIPlugin.getDefault().getLog();
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/IConfigurableRunner.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/IConfigurableRunner.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/IConfigurableRunner.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/IConfigurableRunner.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.launching;
+
+public interface IConfigurableRunner {
+
+  public void setRunnerConfig(IRutaInterpreterRunnerConfig config);
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/IRutaInterpreterRunnerConfig.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/IRutaInterpreterRunnerConfig.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/IRutaInterpreterRunnerConfig.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/IRutaInterpreterRunnerConfig.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.launching;
+
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.dltk.launching.InterpreterConfig;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.launching.VMRunnerConfiguration;
+
+public interface IRutaInterpreterRunnerConfig {
+
+  public String getRunnerClassName(InterpreterConfig config, ILaunch launch, IJavaProject project);
+
+  public String[] computeClassPath(InterpreterConfig config, ILaunch launch, IJavaProject project)
+          throws Exception;
+
+  public String[] getProgramArguments(InterpreterConfig config, ILaunch launch, IJavaProject project);
+
+  public void adjustRunnerConfiguration(VMRunnerConfiguration vconfig, InterpreterConfig iconfig,
+          ILaunch launch, IJavaProject project);
+}