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/04/29 16:51:06 UTC

svn commit: r1477113 [12/18] - in /uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide: ./ core/ core/builder/ core/codeassist/ core/extensions/ core/packages/ core/parser/ core/search/ debug/ debug/ui/ debug/ui/handlers/ debug/u...

Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaFileHyperlink.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaFileHyperlink.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaFileHyperlink.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaFileHyperlink.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,230 @@
+/*
+ * 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.ui.console;
+
+import java.text.MessageFormat;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.dltk.debug.ui.DLTKDebugUIPlugin;
+import org.eclipse.dltk.internal.ui.editor.EditorUtility;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.console.IHyperlink;
+import org.eclipse.ui.console.TextConsole;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * A hyperlink from a stack trace line of the form "(file "*.*")"
+ */
+public class RutaFileHyperlink implements IHyperlink {
+
+  private TextConsole fConsole;
+
+  public RutaFileHyperlink(TextConsole console) {
+    fConsole = console;
+  }
+
+  public void linkEntered() {
+  }
+
+  public void linkExited() {
+  }
+
+  public void linkActivated() {
+    try {
+      String fileName;
+      int lineNumber;
+      try {
+        String linkText = getLinkText();
+        fileName = getFileName(linkText);
+        lineNumber = getLineNumber(linkText);
+      } catch (CoreException e1) {
+        ErrorDialog.openError(DLTKDebugUIPlugin.getActiveWorkbenchShell(),
+                ConsoleMessages.RutaFileHyperlink_Error,
+                ConsoleMessages.RutaFileHyperlink_Error, e1.getStatus());
+        return;
+      }
+
+      // documents start at 0
+      if (lineNumber > 0) {
+        lineNumber--;
+      }
+      Object sourceElement = getSourceModule(fileName);
+      if (sourceElement != null) {
+        IEditorPart part = EditorUtility.openInEditor(sourceElement);
+        IEditorPart editorPart = EditorUtility.openInEditor(sourceElement);
+        if (editorPart instanceof ITextEditor && lineNumber >= 0) {
+          ITextEditor textEditor = (ITextEditor) editorPart;
+          IDocumentProvider provider = textEditor.getDocumentProvider();
+          IEditorInput input = part.getEditorInput();
+          provider.connect(input);
+          IDocument document = provider.getDocument(input);
+          try {
+            IRegion line = document.getLineInformation(lineNumber);
+            textEditor.selectAndReveal(line.getOffset(), line.getLength());
+          } catch (BadLocationException e) {
+
+          }
+          provider.disconnect(input);
+        }
+        return;
+      }
+      // did not find source
+      MessageDialog.openInformation(DLTKDebugUIPlugin.getActiveWorkbenchShell(),
+              ConsoleMessages.RutaFileHyperlink_Information_1, MessageFormat.format(
+                      ConsoleMessages.RutaFileHyperlink_Source_not_found_for__0__2,
+                      new String[] { fileName }));
+    } catch (CoreException e) {
+      DLTKDebugUIPlugin
+              .errorDialog(
+                      ConsoleMessages.RutaFileHyperlink_An_exception_occurred_while_following_link__3,
+                      e);
+      return;
+    }
+  }
+
+  public String getEditorId(IEditorInput input, Object inputObject) {
+    try {
+      IEditorDescriptor descriptor = IDE.getEditorDescriptor(input.getName());
+      return descriptor.getId();
+    } catch (PartInitException e) {
+      return null;
+    }
+  }
+
+  public IEditorInput getEditorInput(Object item) {
+    try {
+      return EditorUtility.getEditorInput(item);
+    } catch (CoreException e) {
+      DLTKDebugUIPlugin.log(e);
+      return null;
+    }
+  }
+
+  protected Object getSourceModule(String fileName) {
+    IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
+    return f;
+  }
+
+  /**
+   * Returns the fully qualified name of the type to open
+   * 
+   * @return fully qualified type name
+   * @exception CoreException
+   *              if unable to parse the type name
+   */
+  protected String getFileName(String linkText) throws CoreException {
+    Pattern p = Pattern.compile("\\(file \"(.*)\"");
+    Matcher m = p.matcher(linkText);
+    if (m.find()) {
+      String name = m.group(1);
+      return name;
+    }
+    IStatus status = new Status(IStatus.ERROR, DLTKDebugUIPlugin.getUniqueIdentifier(), 0,
+            ConsoleMessages.RutaFileHyperlink_Unable_to_parse_type_name_from_hyperlink__5,
+            null);
+    throw new CoreException(status);
+  }
+
+  /**
+   * Returns the line number associated with the stack trace or -1 if none.
+   * 
+   * @exception CoreException
+   *              if unable to parse the number
+   */
+  protected int getLineNumber(String linkText) throws CoreException {
+    Pattern p = Pattern.compile("line (\\d*)");
+    Matcher m = p.matcher(linkText);
+    if (m.find()) {
+      String lineText = m.group(1);
+      try {
+        return Integer.parseInt(lineText);
+      } catch (NumberFormatException e) {
+        IStatus status = new Status(
+                IStatus.ERROR,
+                DLTKDebugUIPlugin.getUniqueIdentifier(),
+                0,
+                ConsoleMessages.RutaFileHyperlink_Unable_to_parse_line_number_from_hyperlink__6,
+                e);
+        throw new CoreException(status);
+      }
+    }
+    IStatus status = new Status(IStatus.ERROR, DLTKDebugUIPlugin.getUniqueIdentifier(), 0,
+            ConsoleMessages.RutaFileHyperlink_Unable_to_parse_line_number_from_hyperlink__7,
+            null);
+    throw new CoreException(status);
+  }
+
+  /**
+   * Returns the console this link is contained in.
+   * 
+   * @return console
+   */
+  protected TextConsole getConsole() {
+    return fConsole;
+  }
+
+  /**
+   * Returns this link's text
+   * 
+   * @exception CoreException
+   *              if unable to retrieve the text
+   */
+  protected String getLinkText() throws CoreException {
+    try {
+      IDocument document = getConsole().getDocument();
+      IRegion region = getConsole().getRegion(this);
+      int regionOffset = region.getOffset();
+
+      int lineNumber = document.getLineOfOffset(regionOffset);
+      IRegion lineInformation = document.getLineInformation(lineNumber);
+      int lineOffset = lineInformation.getOffset();
+      String line = document.get(lineOffset, lineInformation.getLength());
+
+      int regionOffsetInLine = regionOffset - lineOffset;
+
+      int linkEnd = line.indexOf(')', regionOffsetInLine);
+      int linkStart = line.lastIndexOf(' ', regionOffsetInLine);
+
+      return line.substring(linkStart == -1 ? 0 : linkStart + 1, linkEnd + 1);
+    } catch (BadLocationException e) {
+      IStatus status = new Status(IStatus.ERROR, DLTKDebugUIPlugin.getUniqueIdentifier(), 0,
+              ConsoleMessages.RutaFileHyperlink_Unable_to_retrieve_hyperlink_text__8, e);
+      throw new CoreException(status);
+    }
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaInterpreter.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaInterpreter.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaInterpreter.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaInterpreter.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,109 @@
+/*
+ * 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.ui.console;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+import org.eclipse.dltk.console.ConsoleRequest;
+import org.eclipse.dltk.console.IScriptConsoleIO;
+import org.eclipse.dltk.console.IScriptExecResult;
+import org.eclipse.dltk.console.IScriptInterpreter;
+import org.eclipse.dltk.console.InterpreterResponse;
+import org.eclipse.dltk.console.ScriptExecResult;
+import org.eclipse.dltk.console.ShellResponse;
+
+public class RutaInterpreter implements IScriptInterpreter, ConsoleRequest {
+
+  private static final String COMPLETE_COMMAND = "complete";
+
+  private static final String DESCRIBE_COMMAND = "describe";
+
+  private static final String CLOSE_COMMAND = "close";
+
+  private IScriptConsoleIO protocol;
+
+  private String content;
+
+  private int state;
+
+  public IScriptExecResult exec(String command) throws IOException {
+    InterpreterResponse response = protocol.execInterpreter(command);
+    state = response.getState();
+    return new ScriptExecResult(response.getContent());
+  }
+
+  public String getOutput() {
+    return content;
+  }
+
+  public int getState() {
+    return state;
+  }
+
+  // IScriptInterpreterShell
+  public List getCompletions(String commandLine, int position) throws IOException {
+
+    String[] args = new String[] { commandLine, Integer.toString(position) };
+
+    ShellResponse response = protocol.execShell(COMPLETE_COMMAND, args);
+
+    return response.getCompletions();
+  }
+
+  public String getDescription(String commandLine, int position) throws IOException {
+    String[] args = new String[] { commandLine, Integer.toString(position) };
+
+    ShellResponse response = protocol.execShell(DESCRIBE_COMMAND, args);
+
+    return response.getDescription();
+  }
+
+  public String[] getNames(String type) throws IOException {
+    return null;
+  }
+
+  public void close() throws IOException {
+    protocol.execShell(CLOSE_COMMAND, new String[] {});
+    protocol.close();
+  }
+
+  // IScriptConsoleProtocol
+  public void consoleConnected(IScriptConsoleIO protocol) {
+    this.protocol = protocol;
+  }
+
+  public String getInitialOuput() {
+    return null;
+  }
+
+  public void addInitialListenerOperation(Runnable runnable) {
+
+  }
+
+  public InputStream getInitialOutputStream() {
+    return null;
+  }
+
+  public boolean isValid() {
+    return protocol != null;
+  }
+}

Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/console/ShowFunctionsAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/console/ShowFunctionsAction.java?rev=1477113&r1=1477112&r2=1477113&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/console/ShowFunctionsAction.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/console/ShowFunctionsAction.java Mon Apr 29 14:50:56 2013
@@ -17,7 +17,7 @@
  * under the License.
 */
 
-package org.apache.uima.textmarker.ide.ui.console;
+package org.apache.uima.ruta.ide.ui.console;
 
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.dltk.core.DLTKCore;

Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/AbstractLanguageElementDocumentationProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/AbstractLanguageElementDocumentationProvider.java?rev=1477113&r1=1477112&r2=1477113&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/AbstractLanguageElementDocumentationProvider.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/AbstractLanguageElementDocumentationProvider.java Mon Apr 29 14:50:56 2013
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.uima.textmarker.ide.ui.documentation;
+package org.apache.uima.ruta.ide.ui.documentation;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -28,7 +28,7 @@ import java.io.StringReader;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.uima.textmarker.ide.TextMarkerIdePlugin;
+import org.apache.uima.ruta.ide.RutaIdePlugin;
 import org.eclipse.dltk.core.IMember;
 import org.eclipse.dltk.ui.documentation.IScriptDocumentationProvider;
 import org.htmlparser.Parser;
@@ -84,7 +84,7 @@ public abstract class AbstractLanguageEl
       list.visitAllNodesWith(visitor);
       map.putAll(visitor.getMap());
     } catch (Exception e) {
-      TextMarkerIdePlugin.error(e);
+      RutaIdePlugin.error(e);
     }
 
   }

Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/HtmlDocumentationVisitor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/HtmlDocumentationVisitor.java?rev=1477113&r1=1477112&r2=1477113&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/HtmlDocumentationVisitor.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/HtmlDocumentationVisitor.java Mon Apr 29 14:50:56 2013
@@ -17,7 +17,7 @@
  * under the License.
 */
 
-package org.apache.uima.textmarker.ide.ui.documentation;
+package org.apache.uima.ruta.ide.ui.documentation;
 
 import java.util.Map;
 import java.util.TreeMap;

Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/HtmlRutaPagesLocation.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/HtmlRutaPagesLocation.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/HtmlRutaPagesLocation.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/HtmlRutaPagesLocation.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,76 @@
+/*
+ * 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.ui.documentation;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.Reader;
+
+public class HtmlRutaPagesLocation implements IRutaPagesLocation {
+
+  private File fLocation;
+
+  /**
+   * @param location
+   *          directory(!)
+   */
+  public HtmlRutaPagesLocation(File location) {
+    if (!location.isDirectory()) {
+      throw new IllegalArgumentException();
+    }
+
+    fLocation = location;
+  }
+
+  public Reader getHtmlInfo(String keyword) {
+    final String pattern = keyword + ".htm";
+    File[] result = fLocation.listFiles(new FilenameFilter() {
+
+      public boolean accept(File dir, String name) {
+        if (name.equals(pattern))
+          return true;
+        return false;
+      }
+
+    });
+    if (result != null && result.length >= 1 && result[0] != null) {
+      try {
+        FileReader reader = new FileReader(result[0]);
+        return reader;
+      } catch (FileNotFoundException e) {
+        // hmmm! but nothing to do.
+      }
+    }
+    return null;
+  }
+
+  public File getLocation() {
+    return fLocation;
+  }
+
+  public void setLocation(File location) {
+    if (!location.isDirectory())
+      return;
+    fLocation = location;
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/IRutaPagesLocation.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/IRutaPagesLocation.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/IRutaPagesLocation.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/IRutaPagesLocation.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,34 @@
+/*
+ * 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.ui.documentation;
+
+import java.io.Reader;
+
+public interface IRutaPagesLocation {
+
+  /**
+   * Should find inside location for an information about keyword
+   * 
+   * @param keyword
+   * @return Reader with html code
+   */
+  public Reader getHtmlInfo(String keyword);
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaActionDocumentationProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaActionDocumentationProvider.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaActionDocumentationProvider.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaActionDocumentationProvider.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,29 @@
+/*
+ * 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.ui.documentation;
+
+public class RutaActionDocumentationProvider extends
+        AbstractLanguageElementDocumentationProvider {
+
+  public RutaActionDocumentationProvider() {
+    super("Actions.html");
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaCommentDocumentationProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaCommentDocumentationProvider.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaCommentDocumentationProvider.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaCommentDocumentationProvider.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,138 @@
+/*
+ * 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.ui.documentation;
+
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.eclipse.dltk.core.IBuffer;
+import org.eclipse.dltk.core.IField;
+import org.eclipse.dltk.core.IMember;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.ISourceRange;
+import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.ui.documentation.IScriptDocumentationProvider;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+
+public class RutaCommentDocumentationProvider extends ScriptDocumentationProvider implements
+        IScriptDocumentationProvider {
+
+  @Override
+  protected String getLine(Document d, int line) throws BadLocationException {
+    return d.get(d.getLineOffset(line), d.getLineLength(line));
+  }
+
+  protected String getHeaderComment(IMember member) {
+    if (member instanceof IField) {
+      return null;
+    }
+    try {
+      ISourceRange range = member.getSourceRange();
+      if (range == null)
+        return null;
+
+      IBuffer buf = null;
+
+      ISourceModule compilationUnit = member.getSourceModule();
+      if (!compilationUnit.isConsistent()) {
+        return null;
+      }
+
+      buf = compilationUnit.getBuffer();
+
+      final int start = range.getOffset();
+
+      String contents = buf.getContents();
+
+      String result = "";
+
+      Document doc = new Document(contents);
+      try {
+        int line = doc.getLineOfOffset(start);
+        line--;
+        if (line < 0)
+          return null;
+        boolean emptyEnd = true;
+        while (line >= 0) {
+          String curLine = getLine(doc, line);
+          String curLineTrimmed = curLine.trim();
+          if ((curLineTrimmed.length() == 0 && emptyEnd) || curLineTrimmed.startsWith("#")) {
+            if (curLineTrimmed.length() != 0)
+              emptyEnd = false;
+            result = curLine + result;
+          } else
+            break;
+
+          line--;
+        }
+      } catch (BadLocationException e) {
+        return null;
+      }
+
+      return result;
+
+    } catch (ModelException e) {
+    }
+    return null;
+  }
+
+  public Reader getInfo(IMember member, boolean lookIntoParents, boolean lookIntoExternal) {
+    String header = getHeaderComment(member);
+    return new StringReader(convertToHTML(header));
+  }
+
+  @Override
+  protected String convertToHTML(String header) {
+    StringBuffer result = new StringBuffer();
+    // result.append("<p>\n");
+    Document d = new Document(header);
+    for (int line = 0;; line++) {
+      try {
+        String str = getLine(d, line).trim();
+        if (str == null)
+          break;
+        while (str.length() > 0 && str.startsWith("#"))
+          str = str.substring(1);
+        while (str.length() > 0 && str.endsWith("#"))
+          str = str.substring(0, str.length() - 1);
+        if (str.length() == 0)
+          result.append("<p>");
+        else {
+          if (str.trim().matches("\\w*:")) {
+            result.append("<h4>");
+            result.append(str);
+            result.append("</h4>");
+          } else
+            result.append(str + "<br>");
+        }
+      } catch (BadLocationException e) {
+        break;
+      }
+
+    }
+    // result.append("</p>\n");
+    return result.toString();
+  }
+
+  public Reader getInfo(String content) {
+    return null;
+  }
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaCommentReader.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaCommentReader.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaCommentReader.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaCommentReader.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,98 @@
+/*
+ * 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.ui.documentation;
+
+import org.eclipse.dltk.core.IBuffer;
+import org.eclipse.dltk.corext.documentation.SingleCharReader;
+
+public class RutaCommentReader extends SingleCharReader {
+
+  private IBuffer fBuffer;
+
+  private int fCurrPos;
+
+  private int fStartPos;
+
+  private int fEndPos;
+
+  private boolean fWasNewLine;
+
+  public RutaCommentReader(IBuffer buf, int start, int end) {
+    fBuffer = buf;
+    fStartPos = start;
+    fEndPos = end;
+
+    reset();
+  }
+
+  /**
+   * @see java.io.Reader#read()
+   */
+  @Override
+  public int read() {
+    if (fCurrPos < fEndPos) {
+      char ch;
+      if (fWasNewLine) {
+        do {
+          ch = fBuffer.getChar(fCurrPos++);
+        } while (fCurrPos < fEndPos && Character.isWhitespace(ch));
+        if (ch == '#') {
+          if (fCurrPos < fEndPos) {
+            do {
+              ch = fBuffer.getChar(fCurrPos++);
+            } while (ch == '#');
+          } else {
+            return -1;
+          }
+        }
+      } else {
+        ch = fBuffer.getChar(fCurrPos++);
+      }
+      fWasNewLine = (ch == '\n' || ch == '\r');
+
+      return ch;
+    }
+    return -1;
+  }
+
+  /**
+   * @see java.io.Reader#close()
+   */
+  @Override
+  public void close() {
+    fBuffer = null;
+  }
+
+  /**
+   * @see java.io.Reader#reset()
+   */
+  @Override
+  public void reset() {
+    fCurrPos = fStartPos;
+    fWasNewLine = true;
+  }
+
+  /**
+   * Returns the offset of the last read character in the passed buffer.
+   */
+  public int getOffset() {
+    return fCurrPos;
+  }
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaConditionDocumentationProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaConditionDocumentationProvider.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaConditionDocumentationProvider.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaConditionDocumentationProvider.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,29 @@
+/*
+ * 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.ui.documentation;
+
+public class RutaConditionDocumentationProvider extends
+        AbstractLanguageElementDocumentationProvider {
+
+  public RutaConditionDocumentationProvider() {
+    super("Conditions.html");
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaFunctionDocumentationProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaFunctionDocumentationProvider.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaFunctionDocumentationProvider.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaFunctionDocumentationProvider.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,29 @@
+/*
+ * 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.ui.documentation;
+
+public class RutaFunctionDocumentationProvider extends
+        AbstractLanguageElementDocumentationProvider {
+
+  public RutaFunctionDocumentationProvider() {
+    super(null);
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaPageFolder.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaPageFolder.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaPageFolder.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaPageFolder.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,139 @@
+/*
+ * 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.ui.documentation;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class RutaPageFolder {
+  private String path;
+
+  private HashMap pages = new HashMap();
+
+  public RutaPageFolder(String path) {
+    super();
+    this.path = path;
+  }
+
+  public void addPage(String keyword, String file) {
+    pages.put(keyword, file);
+  }
+
+  public boolean verify() {
+    if (path == null)
+      return false;
+    File file = new File(path);
+    if (file.exists() && file.isDirectory())
+      return true;
+    return false;
+  }
+
+  public String getPath() {
+    return path;
+  }
+
+  public HashMap getPages() {
+    return pages;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (!(obj instanceof RutaPageFolder))
+      return false;
+    if (obj == this)
+      return true;
+    RutaPageFolder f = (RutaPageFolder) obj;
+    if (!f.path.equals(this.path))
+      return false;
+    if (!f.pages.equals(this.pages))
+      return false;
+    return true;
+  }
+
+  public static List readXML(String data) throws IOException {
+    // Wrapper the stream for efficient parsing
+    InputStream stream = new ByteArrayInputStream(data.getBytes());
+
+    // Do the parsing and obtain the top-level node
+    Element config = null;
+    try {
+      DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+      parser.setErrorHandler(new DefaultHandler());
+      config = parser.parse(new InputSource(stream)).getDocumentElement();
+    } catch (SAXException e) {
+      throw new IOException("Bad XML format");
+    } catch (ParserConfigurationException e) {
+      stream.close();
+      throw new IOException("Bad XML format");
+    } finally {
+      stream.close();
+    }
+
+    if (!config.getNodeName().equalsIgnoreCase("manPages")) {
+      throw new RuntimeException("Bad top level node");
+    }
+
+    List folders = new ArrayList();
+
+    NodeList list = config.getChildNodes();
+    int length = list.getLength();
+    for (int i = 0; i < length; ++i) {
+      Node node = list.item(i);
+      short type = node.getNodeType();
+      if (type == Node.ELEMENT_NODE && node.getNodeName().equalsIgnoreCase("location")) {
+        Element location = (Element) node;
+        String path = location.getAttribute("path");
+        RutaPageFolder folder = new RutaPageFolder(path);
+        NodeList locationChilds = location.getChildNodes();
+        int pages = locationChilds.getLength();
+        for (int j = 0; j < pages; ++j) {
+          node = locationChilds.item(j);
+          type = node.getNodeType();
+          if (type == Node.ELEMENT_NODE && node.getNodeName().equalsIgnoreCase("page")) {
+            Element word = (Element) node;
+            String kw = word.getAttribute("keyword");
+            String file = word.getAttribute("file");
+            folder.addPage(kw, file);
+          }
+        }
+        folders.add(folder);
+      }
+    }
+
+    return folders;
+  }
+
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaPagesDocumentationProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaPagesDocumentationProvider.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaPagesDocumentationProvider.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaPagesDocumentationProvider.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,100 @@
+/*
+ * 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.ui.documentation;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.uima.ruta.ide.RutaIdePlugin;
+import org.apache.uima.ruta.ide.ui.RutaPreferenceConstants;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.dltk.core.IMember;
+import org.eclipse.dltk.ui.documentation.IScriptDocumentationProvider;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+public class RutaPagesDocumentationProvider implements IScriptDocumentationProvider {
+
+  private List folders = null;
+
+  public Reader getInfo(IMember element, boolean lookIntoParents, boolean lookIntoExternal) {
+    return null;
+  }
+
+  public Reader getInfo(String content) {
+    initalizeLocations(false);
+
+    if (folders != null) {
+      for (Iterator iterator = folders.iterator(); iterator.hasNext();) {
+        RutaPageFolder f = (RutaPageFolder) iterator.next();
+        HashMap pages = f.getPages();
+        String ans = (String) pages.get(content);
+        if (ans != null) {
+          IPath filePath = new Path(f.getPath()).append(ans);
+          File file = filePath.toFile();
+          if (file != null && file.isFile()) {
+            try {
+              return new FileReader(file);
+            } catch (FileNotFoundException e) {
+              e.printStackTrace();
+            }
+          }
+          break;
+        }
+      }
+    }
+
+    return null;
+  }
+
+  private void initalizeLocations(boolean force) {
+    if (!force && this.folders != null)
+      return;
+
+    RutaIdePlugin.getDefault().getPreferenceStore()
+            .addPropertyChangeListener(new IPropertyChangeListener() {
+
+              public void propertyChange(PropertyChangeEvent event) {
+                initalizeLocations(true);
+              }
+
+            });
+
+    String value = RutaIdePlugin.getDefault().getPreferenceStore()
+            .getString(RutaPreferenceConstants.DOC_TM_PAGES_LOCATIONS);
+
+    try {
+      if (!StringUtils.isEmpty(value)) {
+        // value = "<Pages></Pages>";
+        this.folders = RutaPageFolder.readXML(value);
+      }
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+  }
+}

Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaPagesLocationsBlock.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaPagesLocationsBlock.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaPagesLocationsBlock.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/RutaPagesLocationsBlock.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,558 @@
+/*
+ * 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.ui.documentation;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.uima.ruta.ide.ui.RutaPreferenceConstants;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.dltk.ui.DLTKPluginImages;
+import org.eclipse.dltk.ui.dialogs.TimeTriggeredProgressMonitorDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+
+public class RutaPagesLocationsBlock implements SelectionListener, ISelectionChangedListener {
+
+  protected static final String LAST_PATH_SETTING = "LAST_PATH_SETTING"; //$NON-NLS-1$
+
+  protected static final String DIALOG_SETTINGS_PREFIX = "RutaPagesLocationsBlock"; //$NON-NLS-1$
+
+  protected boolean fInCallback = false;
+
+  protected File fHome;
+
+  // widgets
+  protected TreeViewer fLocationsViewer;
+
+  private Button fClearButton;
+
+  private Button fRemoveButton;
+
+  private Button fAddButton;
+
+  protected Button fDefaultButton;
+
+  private ManLocationsContentProvider fLocationsContentProvider;
+
+  private PreferencePage fPage;
+
+  private IPreferenceStore fStore;
+
+  public RutaPagesLocationsBlock(IPreferenceStore store, PreferencePage page) {
+    fPage = page;
+    fStore = store;
+  }
+
+  protected IBaseLabelProvider getLabelProvider() {
+    return new LabelProvider() {
+
+      @Override
+      public Image getImage(Object element) {
+        if (element instanceof RutaPageFolder) {
+          return DLTKPluginImages.DESC_OBJS_LIBRARY.createImage();
+        }
+        return DLTKPluginImages.DESC_OBJS_INFO_OBJ.createImage();
+      }
+
+      @Override
+      public String getText(Object element) {
+        if (element instanceof RutaPageFolder) {
+          RutaPageFolder folder = (RutaPageFolder) element;
+          return folder.getPath();
+        }
+        return super.getText(element);
+      }
+
+    };
+  }
+
+  private List folders = null;
+
+  private String getFoldersAsXML() {
+    if (folders == null)
+      return null;
+
+    // Create the Document and the top-level node
+    DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
+    DocumentBuilder docBuilder;
+    try {
+      docBuilder = dfactory.newDocumentBuilder();
+    } catch (ParserConfigurationException e1) {
+      e1.printStackTrace();
+      return null;
+    }
+    Document doc = docBuilder.newDocument();
+
+    Element topElement = doc.createElement("manPages");
+    doc.appendChild(topElement);
+
+    for (Iterator iterator = folders.iterator(); iterator.hasNext();) {
+      RutaPageFolder f = (RutaPageFolder) iterator.next();
+      Element location = doc.createElement("location");
+      topElement.appendChild(location);
+      location.setAttribute("path", f.getPath());
+      for (Iterator iterator2 = f.getPages().keySet().iterator(); iterator2.hasNext();) {
+        String name = (String) iterator2.next();
+        String file = (String) f.getPages().get(name);
+        Element page = doc.createElement("page");
+        location.appendChild(page);
+        page.setAttribute("keyword", name);
+        page.setAttribute("file", file);
+      }
+    }
+
+    ByteArrayOutputStream s = new ByteArrayOutputStream();
+
+    try {
+      TransformerFactory factory = TransformerFactory.newInstance();
+      Transformer transformer;
+      transformer = factory.newTransformer();
+      transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
+      transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+
+      DOMSource source = new DOMSource(doc);
+      StreamResult outputTarget = new StreamResult(s);
+      transformer.transform(source, outputTarget);
+    } catch (TransformerConfigurationException e) {
+      e.printStackTrace();
+    } catch (TransformerException e) {
+      e.printStackTrace();
+    }
+
+    String result = null;
+    try {
+      result = s.toString("UTF8");
+    } catch (UnsupportedEncodingException e) {
+      e.printStackTrace();
+    }
+
+    return result;
+  }
+
+  private class ManLocationsContentProvider implements ITreeContentProvider {
+
+    public Object[] getChildren(Object parentElement) {
+      if (parentElement instanceof RutaPageFolder) {
+        RutaPageFolder folder = (RutaPageFolder) parentElement;
+        String[] ch = new String[folder.getPages().size()];
+        int i = 0;
+        for (Iterator iterator = folder.getPages().keySet().iterator(); iterator.hasNext();) {
+          String kw = (String) iterator.next();
+          String file = (String) folder.getPages().get(kw);
+          ch[i++] = kw + " (" + file + ")";
+        }
+        return ch;
+      }
+      return new Object[0];
+    }
+
+    public Object getParent(Object element) {
+      return null;
+    }
+
+    public boolean hasChildren(Object element) {
+      if (element instanceof RutaPageFolder)
+        return true;
+      return false;
+    }
+
+    public Object[] getElements(Object inputElement) {
+      if (folders == null)
+        return new Object[0];
+      return folders.toArray(new Object[folders.size()]);
+    }
+
+    public void dispose() {
+    }
+
+    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+    }
+
+  }
+
+  /**
+   * Creates and returns the source lookup control.
+   * 
+   * @param parent
+   *          the parent widget of this control
+   */
+  public Control createControl(Composite parent) {
+    Font font = parent.getFont();
+
+    Composite comp = new Composite(parent, SWT.NONE);
+    GridLayout topLayout = new GridLayout();
+    topLayout.numColumns = 2;
+    topLayout.marginHeight = 0;
+    topLayout.marginWidth = 0;
+    comp.setLayout(topLayout);
+    GridData gd = new GridData(GridData.FILL_BOTH);
+    comp.setLayoutData(gd);
+
+    fLocationsViewer = new TreeViewer(comp);
+    gd = new GridData(GridData.FILL_BOTH);
+    gd.heightHint = 6;
+    fLocationsViewer.getControl().setLayoutData(gd);
+    fLocationsContentProvider = new ManLocationsContentProvider();
+    fLocationsViewer.setSorter(new ViewerSorter());
+    fLocationsViewer.setContentProvider(fLocationsContentProvider);
+    fLocationsViewer.setLabelProvider(getLabelProvider());
+    fLocationsViewer.setInput(this);
+    fLocationsViewer.addSelectionChangedListener(this);
+
+    Composite pathButtonComp = new Composite(comp, SWT.NONE);
+    GridLayout pathButtonLayout = new GridLayout();
+    pathButtonLayout.marginHeight = 0;
+    pathButtonLayout.marginWidth = 0;
+    pathButtonComp.setLayout(pathButtonLayout);
+    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
+    pathButtonComp.setLayoutData(gd);
+    pathButtonComp.setFont(font);
+
+    fAddButton = createPushButton(pathButtonComp, "Add folder...");
+    fAddButton.addSelectionListener(this);
+
+    fRemoveButton = createPushButton(pathButtonComp, "Remove");
+    fRemoveButton.addSelectionListener(this);
+
+    fClearButton = createPushButton(pathButtonComp, "Remove All");
+    fClearButton.addSelectionListener(this);
+
+    return comp;
+  }
+
+  /**
+   * Creates and returns a button
+   * 
+   * @param parent
+   *          parent widget
+   * @param label
+   *          label
+   * @return Button
+   */
+  protected Button createPushButton(Composite parent, String label) {
+    Button button = new Button(parent, SWT.PUSH);
+    button.setFont(parent.getFont());
+    button.setText(label);
+    setButtonLayoutData(button);
+    return button;
+  }
+
+  protected void setButtonLayoutData(Button button) {
+    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+    int widthHint = 80;
+    Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+    data.widthHint = Math.max(widthHint, minSize.x);
+    button.setLayoutData(data);
+  }
+
+  /**
+   * Create some empty space
+   */
+  protected void createVerticalSpacer(Composite comp, int colSpan) {
+    Label label = new Label(comp, SWT.NONE);
+    GridData gd = new GridData();
+    gd.horizontalSpan = colSpan;
+    label.setLayoutData(gd);
+  }
+
+  /**
+   * Updates buttons and status based on current mans
+   */
+  public void update() {
+    updateButtons();
+
+    if (folders != null) {
+      for (Iterator iterator = folders.iterator(); iterator.hasNext();) {
+        RutaPageFolder v = (RutaPageFolder) iterator.next();
+        if (!v.verify()) {
+          iterator.remove();
+        }
+      }
+    }
+
+    fLocationsViewer.refresh();
+
+    updatePageStatus(Status.OK_STATUS);
+  }
+
+  public void setDefaults() {
+    String res = fStore.getDefaultString(RutaPreferenceConstants.DOC_TM_PAGES_LOCATIONS);
+    fStore.setValue(RutaPreferenceConstants.DOC_TM_PAGES_LOCATIONS, res);
+    initialize();
+  }
+
+  protected void updatePageStatus(IStatus status) {
+    if (fPage == null)
+      return;
+    fPage.setValid(status.isOK());
+    if (!status.isOK())
+      fPage.setErrorMessage(status.getMessage());
+    else
+      fPage.setErrorMessage(null);
+  }
+
+  public void initialize() {
+    String value = fStore.getString(RutaPreferenceConstants.DOC_TM_PAGES_LOCATIONS);
+    try {
+      this.folders = RutaPageFolder.readXML(value);
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+
+    update();
+  }
+
+  /**
+   * Saves settings
+   */
+  public void performApply() {
+    String xml = this.getFoldersAsXML();
+    if (xml != null)
+      fStore.setValue(RutaPreferenceConstants.DOC_TM_PAGES_LOCATIONS, xml);
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see
+   * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+   */
+  public void widgetSelected(SelectionEvent e) {
+    Object source = e.getSource();
+    if (source == fClearButton) {
+      folders.clear();
+    } else if (source == fRemoveButton) {
+      IStructuredSelection selection = (IStructuredSelection) fLocationsViewer.getSelection();
+      Object[] array = selection.toArray();
+      for (int i = 0; i < array.length; i++) {
+        if (array[i] instanceof RutaPageFolder) {
+          for (Iterator iterator = folders.iterator(); iterator.hasNext();) {
+            RutaPageFolder f = (RutaPageFolder) iterator.next();
+            if (f == array[i]) {
+              iterator.remove();
+              break;
+            }
+          }
+        }
+      }
+    } else if (source == fAddButton) {
+      add();
+    }
+
+    update();
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @seeorg.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.
+   * SelectionEvent)
+   */
+  public void widgetDefaultSelected(SelectionEvent e) {
+  }
+
+  /**
+   * Open the file selection dialog, and add the return locations.
+   */
+  protected void add() {
+    DirectoryDialog dialog = new DirectoryDialog(fLocationsViewer.getControl().getShell());
+    dialog.setMessage("Select directory to search into");
+    String result = dialog.open();
+    if (result != null) {
+      final File file = new File(result);
+      if (this.folders == null)
+        this.folders = new ArrayList();
+      if (file != null && file.isDirectory()) {
+        ProgressMonitorDialog dialog2 = new TimeTriggeredProgressMonitorDialog(null, 500);
+        try {
+          dialog2.run(true, true, new IRunnableWithProgress() {
+            public void run(IProgressMonitor monitor) {
+              monitor.beginTask("Searching for man pages", 1);
+              performSearch(file);
+              monitor.done();
+            }
+          });
+        } catch (InvocationTargetException e) {
+          e.printStackTrace();
+        } catch (InterruptedException e) {
+          e.printStackTrace();
+        }
+
+      }
+    }
+  }
+
+  private void performSearch(File dir) {
+    if (!dir.isDirectory())
+      return;
+
+    String name = dir.getName();
+
+    if (name.equals("TkLib") || name.equals("RutaLib") || name.equals("Keywords")
+            || name.equals("UserCmd"))
+      return;
+
+    File[] childs = dir.listFiles(new FileFilter() {
+
+      public boolean accept(File file) {
+        if (file.isDirectory())
+          return true;
+        if (file.getName().startsWith("contents.htm"))
+          return true;
+        return false;
+      }
+
+    });
+    for (int i = 0; i < childs.length; i++) {
+      if (childs[i].isDirectory()) {
+        performSearch(childs[i]);
+      }
+      if (childs[i].getName().startsWith("contents.htm")) {
+        RutaPageFolder folder = new RutaPageFolder(dir.getAbsolutePath());
+        parseContentsFile(childs[i], folder);
+        if (folder.getPages().size() > 0 && !folders.contains(folder)) {
+          this.folders.add(folder);
+        }
+      }
+    }
+  }
+
+  private void parseContentsFile(File c, RutaPageFolder folder) {
+    FileReader reader;
+    try {
+      reader = new FileReader(c);
+    } catch (FileNotFoundException e) {
+      return;
+    }
+    StringBuffer buf = new StringBuffer();
+    while (true) {
+      char cbuf[] = new char[1024];
+      try {
+        int read = reader.read(cbuf);
+        if (read >= 0) {
+          buf.append(cbuf, 0, read);
+        } else
+          break;
+      } catch (IOException e) {
+        break;
+      }
+    }
+    String result = buf.toString();
+    Pattern pattern = Pattern.compile("<a\\s+href=\"([a-zA-Z_0-9]+\\.html?)\"\\s*>(\\w+)</a>",
+            Pattern.CASE_INSENSITIVE);
+    Matcher matcher = pattern.matcher(result);
+    while (matcher.find()) {
+      String file = matcher.group(1);
+      if (file.equalsIgnoreCase("Copyright.htm"))
+        continue;
+      String word = matcher.group(2);
+      folder.addPage(word, file);
+    }
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see
+   * org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers
+   * .SelectionChangedEvent)
+   */
+  public void selectionChanged(SelectionChangedEvent event) {
+    updateButtons();
+  }
+
+  /**
+   * Refresh the enable/disable state for the buttons.
+   */
+  private void updateButtons() {
+    fClearButton.setEnabled(folders != null && folders.size() > 0);
+    IStructuredSelection selection = (IStructuredSelection) fLocationsViewer.getSelection();
+
+    boolean canRemove = true;
+    if (folders == null)
+      canRemove = false;
+    else {
+      List list = selection.toList();
+      for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+        Object o = iterator.next();
+        if (!folders.contains(o))
+          canRemove = false;
+        break;
+      }
+      if (selection.isEmpty())
+        canRemove = false;
+    }
+
+    fRemoveButton.setEnabled(canRemove);
+  }
+
+}

Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/ScriptDocumentationProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/ScriptDocumentationProvider.java?rev=1477113&r1=1477112&r2=1477113&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/ScriptDocumentationProvider.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/documentation/ScriptDocumentationProvider.java Mon Apr 29 14:50:56 2013
@@ -17,7 +17,7 @@
  * under the License.
 */
 
-package org.apache.uima.textmarker.ide.ui.documentation;
+package org.apache.uima.ruta.ide.ui.documentation;
 
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.Document;

Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/editor/ActionMessages.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/editor/ActionMessages.java?rev=1477113&r1=1477112&r2=1477113&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/editor/ActionMessages.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/editor/ActionMessages.java Mon Apr 29 14:50:56 2013
@@ -17,13 +17,13 @@
  * under the License.
  */
 
-package org.apache.uima.textmarker.ide.ui.editor;
+package org.apache.uima.ruta.ide.ui.editor;
 
 import org.eclipse.osgi.util.NLS;
 
 public final class ActionMessages extends NLS {
 
-  private static final String BUNDLE_NAME = "org.apache.uima.textmarker.ide.ui.editor.ActionMessages";//$NON-NLS-1$
+  private static final String BUNDLE_NAME = "org.apache.uima.ruta.ide.ui.editor.ActionMessages";//$NON-NLS-1$
 
   private ActionMessages() {
     // Do not instantiate

Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/editor/ReferenceFinder.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/editor/ReferenceFinder.java?rev=1477113&r1=1477112&r2=1477113&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/editor/ReferenceFinder.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/editor/ReferenceFinder.java Mon Apr 29 14:50:56 2013
@@ -17,16 +17,16 @@
  * under the License.
 */
 
-package org.apache.uima.textmarker.ide.ui.editor;
+package org.apache.uima.ruta.ide.ui.editor;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.uima.textmarker.ide.parser.ast.ComponentDeclaration;
-import org.apache.uima.textmarker.ide.parser.ast.ComponentReference;
-import org.apache.uima.textmarker.ide.parser.ast.TextMarkerAction;
-import org.apache.uima.textmarker.ide.parser.ast.TextMarkerCondition;
-import org.apache.uima.textmarker.ide.parser.ast.TextMarkerVariableReference;
+import org.apache.uima.ruta.ide.parser.ast.ComponentDeclaration;
+import org.apache.uima.ruta.ide.parser.ast.ComponentReference;
+import org.apache.uima.ruta.ide.parser.ast.RutaAction;
+import org.apache.uima.ruta.ide.parser.ast.RutaCondition;
+import org.apache.uima.ruta.ide.parser.ast.RutaVariableReference;
 import org.eclipse.dltk.ast.ASTNode;
 import org.eclipse.dltk.ast.ASTVisitor;
 import org.eclipse.dltk.ast.expressions.Expression;
@@ -45,9 +45,9 @@ public class ReferenceFinder extends AST
 
   @Override
   public boolean visit(Expression s) throws Exception {
-    if (s instanceof TextMarkerVariableReference && node instanceof TextMarkerVariableReference) {
-      TextMarkerVariableReference vr0 = (TextMarkerVariableReference) node;
-      TextMarkerVariableReference vr1 = (TextMarkerVariableReference) s;
+    if (s instanceof RutaVariableReference && node instanceof RutaVariableReference) {
+      RutaVariableReference vr0 = (RutaVariableReference) node;
+      RutaVariableReference vr1 = (RutaVariableReference) s;
       if (vr1.getStringRepresentation().equals(vr0.getStringRepresentation())
               && vr1.getType() == vr0.getType()) {
         result.add(s);
@@ -60,15 +60,15 @@ public class ReferenceFinder extends AST
       if (cr1.getName().equals(cr2.getName())) {
         result.add(s);
       }
-    } else if (s instanceof TextMarkerAction && node instanceof TextMarkerAction) {
-      TextMarkerAction a1 = (TextMarkerAction) node;
-      TextMarkerAction a2 = (TextMarkerAction) s;
+    } else if (s instanceof RutaAction && node instanceof RutaAction) {
+      RutaAction a1 = (RutaAction) node;
+      RutaAction a2 = (RutaAction) s;
       if (a1.getName().equals(a2.getName())) {
         result.add(s);
       }
-    } else if (s instanceof TextMarkerCondition && node instanceof TextMarkerCondition) {
-      TextMarkerCondition c1 = (TextMarkerCondition) node;
-      TextMarkerCondition c2 = (TextMarkerCondition) s;
+    } else if (s instanceof RutaCondition && node instanceof RutaCondition) {
+      RutaCondition c1 = (RutaCondition) node;
+      RutaCondition c2 = (RutaCondition) s;
       if (c1.getName().equals(c2.getName())) {
         result.add(s);
       }

Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/editor/RutaDocumentSetupParticipant.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/editor/RutaDocumentSetupParticipant.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/editor/RutaDocumentSetupParticipant.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/ui/editor/RutaDocumentSetupParticipant.java Mon Apr 29 14:50:56 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.ui.editor;
+
+import org.apache.uima.ruta.ide.RutaIdePlugin;
+import org.apache.uima.ruta.ide.ui.RutaPartitions;
+import org.apache.uima.ruta.ide.ui.text.RutaTextTools;
+import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
+import org.eclipse.jface.text.IDocument;
+
+public class RutaDocumentSetupParticipant implements IDocumentSetupParticipant {
+
+  public RutaDocumentSetupParticipant() {
+  }
+
+  /*
+   * @see
+   * org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
+   */
+  public void setup(IDocument document) {
+    RutaTextTools tools = RutaIdePlugin.getDefault().getTextTools();
+    tools.setupDocumentPartitioner(document, RutaPartitions.TM_PARTITIONING);
+  }
+}