You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2011/08/01 16:38:36 UTC

svn commit: r1152804 [12/15] - in /uima/sandbox/trunk/TextMarker: org.apache.uima.tm.dltk.debug.ui/ org.apache.uima.tm.dltk.debug.ui/META-INF/ org.apache.uima.tm.dltk.debug.ui/bin/ org.apache.uima.tm.dltk.debug.ui/icons/ org.apache.uima.tm.dltk.debug.u...

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerSourceViewerConfiguration.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerSourceViewerConfiguration.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerSourceViewerConfiguration.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerSourceViewerConfiguration.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,251 @@
+package org.apache.uima.tm.dltk.internal.ui.text;
+
+import org.apache.uima.tm.dltk.internal.ui.hierarchy.TextMarkerHierarchyInformationControl;
+import org.apache.uima.tm.dltk.internal.ui.text.completion.TextMarkerContentAssistPreference;
+import org.apache.uima.tm.dltk.internal.ui.text.completion.TextMarkerScriptCompletionProcessor;
+import org.apache.uima.tm.dltk.ui.text.TextMarkerPartitions;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.dltk.internal.ui.editor.EditorUtility;
+import org.eclipse.dltk.internal.ui.editor.ScriptSourceViewer;
+import org.eclipse.dltk.internal.ui.text.ScriptElementProvider;
+import org.eclipse.dltk.ui.CodeFormatterConstants;
+import org.eclipse.dltk.ui.text.AbstractScriptScanner;
+import org.eclipse.dltk.ui.text.IColorManager;
+import org.eclipse.dltk.ui.text.ScriptPresentationReconciler;
+import org.eclipse.dltk.ui.text.ScriptSourceViewerConfiguration;
+import org.eclipse.dltk.ui.text.completion.ContentAssistPreference;
+import org.eclipse.dltk.ui.text.completion.ContentAssistProcessor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.AbstractInformationControlManager;
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.jface.text.information.IInformationPresenter;
+import org.eclipse.jface.text.information.IInformationProvider;
+import org.eclipse.jface.text.information.InformationPresenter;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+
+public class TextMarkerSourceViewerConfiguration extends ScriptSourceViewerConfiguration {
+
+  private TextMarkerTextTools fTextTools;
+
+  private TextMarkerCodeScanner fCodeScanner;
+
+  private AbstractScriptScanner fStringScanner;
+
+  private AbstractScriptScanner fCommentScanner;
+
+  public TextMarkerSourceViewerConfiguration(IColorManager colorManager,
+          IPreferenceStore preferenceStore, ITextEditor editor, String partitioning) {
+    super(colorManager, preferenceStore, editor, partitioning);
+  }
+
+  @Override
+  public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
+    return TextMarkerPartitions.TM_PARTITION_TYPES;
+  }
+
+  @Override
+  public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
+    return new String[] { "\t", "    " };
+  }
+
+  /*
+   * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getTabWidth(org
+   * .eclipse.jface.text.source.ISourceViewer)
+   */
+  @Override
+  public int getTabWidth(ISourceViewer sourceViewer) {
+    if (fPreferenceStore == null)
+      return super.getTabWidth(sourceViewer);
+    return fPreferenceStore.getInt(CodeFormatterConstants.FORMATTER_TAB_SIZE);
+  }
+
+  @Override
+  protected void initializeScanners() {
+    Assert.isTrue(isNewSetup());
+    fCodeScanner = new TextMarkerCodeScanner(getColorManager(), fPreferenceStore);
+    fStringScanner = new TextMarkerStringScanner(getColorManager(), fPreferenceStore);
+    fCommentScanner = createCommentScanner(TextMarkerColorConstants.TM_SINGLE_LINE_COMMENT,
+            TextMarkerColorConstants.TM_TODO_TAG);
+    // fCommentScanner = new SingleTokenScriptScanner(getColorManager(),
+    // fPreferenceStore,
+    // TextMarkerColorConstants.TM_SINGLE_LINE_COMMENT);
+  }
+
+  @Override
+  protected void alterContentAssistant(ContentAssistant assistant) {
+    // IDocument.DEFAULT_CONTENT_TYPE
+    IContentAssistProcessor scriptProcessor = new TextMarkerScriptCompletionProcessor(getEditor(),
+            assistant, IDocument.DEFAULT_CONTENT_TYPE);
+    assistant.setContentAssistProcessor(scriptProcessor, IDocument.DEFAULT_CONTENT_TYPE);
+
+    // TextMarkerPartitions.TM_COMMENT
+    ContentAssistProcessor singleLineProcessor = new TextMarkerScriptCompletionProcessor(
+            getEditor(), assistant, TextMarkerPartitions.TM_COMMENT);
+    assistant.setContentAssistProcessor(singleLineProcessor, TextMarkerPartitions.TM_COMMENT);
+
+    // TextMarkerPartitions.TM_STRING
+    ContentAssistProcessor stringProcessor = new TextMarkerScriptCompletionProcessor(getEditor(),
+            assistant, TextMarkerPartitions.TM_STRING);
+    assistant.setContentAssistProcessor(stringProcessor, TextMarkerPartitions.TM_STRING);
+  }
+
+  private boolean isNewSetup() {
+    return fTextTools == null;
+  }
+
+  protected RuleBasedScanner getStringScanner() {
+    return fStringScanner;
+  }
+
+  @Override
+  public String getCommentPrefix() {
+    return "//";
+  }
+
+  protected RuleBasedScanner getCommentScanner() {
+    return fCommentScanner;
+  }
+
+  @Override
+  public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
+    PresentationReconciler reconciler = new ScriptPresentationReconciler();
+    reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+
+    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(this.fCodeScanner);
+    reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+    reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+
+    dr = new DefaultDamagerRepairer(getStringScanner());
+    reconciler.setDamager(dr, TextMarkerPartitions.TM_STRING);
+    reconciler.setRepairer(dr, TextMarkerPartitions.TM_STRING);
+
+    dr = new DefaultDamagerRepairer(getCommentScanner());
+    reconciler.setDamager(dr, TextMarkerPartitions.TM_COMMENT);
+    reconciler.setRepairer(dr, TextMarkerPartitions.TM_COMMENT);
+
+    return reconciler;
+  }
+
+  @Override
+  public void handlePropertyChangeEvent(PropertyChangeEvent event) {
+    Assert.isTrue(isNewSetup());
+    if (fCodeScanner.affectsBehavior(event))
+      fCodeScanner.adaptToPreferenceChange(event);
+    if (fStringScanner.affectsBehavior(event))
+      fStringScanner.adaptToPreferenceChange(event);
+    if (fCommentScanner.affectsBehavior(event)) {
+      fCommentScanner.adaptToPreferenceChange(event);
+    }
+  }
+
+  @Override
+  public boolean affectsTextPresentation(PropertyChangeEvent event) {
+    return fCodeScanner.affectsBehavior(event) || fStringScanner.affectsBehavior(event)
+            || fCommentScanner.affectsBehavior(event);
+  }
+
+  private IInformationControlCreator getHierarchyPresenterControlCreator(ISourceViewer sourceViewer) {
+    return new IInformationControlCreator() {
+      public IInformationControl createInformationControl(Shell parent) {
+        int shellStyle = SWT.RESIZE;
+        int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
+        return new TextMarkerHierarchyInformationControl(parent, shellStyle, treeStyle);
+      }
+    };
+  }
+
+  @Override
+  public IInformationPresenter getHierarchyPresenter(ScriptSourceViewer sourceViewer,
+          boolean doCodeResolve) {
+    // Do not create hierarchy presenter if there's no CU.
+    if (getEditor() != null && getEditor().getEditorInput() != null
+            && EditorUtility.getEditorInputModelElement(getEditor(), true) == null)
+      return null;
+
+    InformationPresenter presenter = new InformationPresenter(
+            getHierarchyPresenterControlCreator(sourceViewer));
+    presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+    presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL);
+    IInformationProvider provider = new ScriptElementProvider(getEditor(), doCodeResolve);
+    presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
+
+    presenter.setSizeConstraints(50, 20, true, false);
+    return presenter;
+  }
+
+  public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
+    if (!fPreferenceStore
+            .getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED))
+      return null;
+
+    IHyperlinkDetector[] inheritedDetectors = super.getHyperlinkDetectors(sourceViewer);
+
+    if (getEditor() == null) {
+      return inheritedDetectors;
+    }
+
+    int inheritedDetectorsLength = inheritedDetectors != null ? inheritedDetectors.length : 0;
+    IHyperlinkDetector[] detectors = new IHyperlinkDetector[inheritedDetectorsLength + 1];
+
+    for (int i = 0; i < inheritedDetectorsLength; i++)
+      detectors[i] = inheritedDetectors[i];
+    detectors[inheritedDetectorsLength] = new ExternalTypeHyperlinkDetector(getEditor());
+
+    return detectors;
+  }
+
+  @Override
+  protected IInformationControlCreator getOutlinePresenterControlCreator(
+          ISourceViewer sourceViewer, final String commandId) {
+    return new IInformationControlCreator() {
+      public IInformationControl createInformationControl(Shell parent) {
+        int shellStyle = SWT.RESIZE;
+        int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
+        return new TextMarkerOutlineInformationControl(parent, shellStyle, treeStyle, commandId);
+      }
+    };
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAutoEditStrategies
+   * (org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
+   */
+  @Override
+  public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
+    // TODO: check contentType. think, do we really need it? :)
+    String partitioning = getConfiguredDocumentPartitioning(sourceViewer);
+    // return new IAutoEditStrategy[] { new DefaultAutoIndentStrategy() };
+    return new IAutoEditStrategy[] { new TextMarkerAutoEditStrategy(fPreferenceStore, partitioning) };
+  }
+
+  @Override
+  protected void initializeQuickOutlineContexts(InformationPresenter presenter,
+          IInformationProvider provider) {
+    presenter.setInformationProvider(provider, TextMarkerPartitions.TM_COMMENT);
+    presenter.setInformationProvider(provider, TextMarkerPartitions.TM_STRING);
+  }
+
+  @Override
+  protected ContentAssistPreference getContentAssistPreference() {
+    return TextMarkerContentAssistPreference.getDefault();
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerSourceViewerConfiguration.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerSourceViewerConfiguration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerStringScanner.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerStringScanner.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerStringScanner.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerStringScanner.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,40 @@
+package org.apache.uima.tm.dltk.internal.ui.text;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.dltk.ui.text.AbstractScriptScanner;
+import org.eclipse.dltk.ui.text.IColorManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.rules.WhitespaceRule;
+
+public class TextMarkerStringScanner extends AbstractScriptScanner {
+
+  private static final String[] tokenProperties = new String[] {
+      TextMarkerColorConstants.TM_STRING, TextMarkerColorConstants.TM_NUMBER,
+      TextMarkerColorConstants.TM_VARIABLE };
+
+  public TextMarkerStringScanner(IColorManager manager, IPreferenceStore store) {
+    super(manager, store);
+
+    initialize();
+  }
+
+  @Override
+  protected String[] getTokenProperties() {
+    return tokenProperties;
+  }
+
+  @Override
+  protected List createRules() {
+    List/* <IRule> */rules = new ArrayList/* <IRule> */();
+
+    // Add generic whitespace rule.
+    rules.add(new WhitespaceRule(new TextMarkerWhitespaceDetector()));
+
+    setDefaultReturnToken(getToken(TextMarkerColorConstants.TM_STRING));
+
+    return rules;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerStringScanner.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerStringScanner.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerTextTools.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerTextTools.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerTextTools.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerTextTools.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,139 @@
+package org.apache.uima.tm.dltk.internal.ui.text;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.uima.tm.dltk.internal.ui.TextMarkerSemanticPositionUpdater;
+import org.apache.uima.tm.dltk.internal.ui.TextMarkerUI;
+import org.apache.uima.tm.dltk.ui.semantichighlighting.ISemanticHighlightingExtension;
+import org.apache.uima.tm.dltk.ui.text.TextMarkerPartitions;
+import org.eclipse.dltk.core.SimpleClassDLTKExtensionManager;
+import org.eclipse.dltk.ui.editor.highlighting.ISemanticHighlighter;
+import org.eclipse.dltk.ui.editor.highlighting.SemanticHighlighting;
+import org.eclipse.dltk.ui.text.ScriptSourceViewerConfiguration;
+import org.eclipse.dltk.ui.text.ScriptTextTools;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.rules.IPartitionTokenScanner;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+
+public class TextMarkerTextTools extends ScriptTextTools {
+
+  private IPartitionTokenScanner fPartitionScanner;
+
+  private SimpleClassDLTKExtensionManager extensions = new SimpleClassDLTKExtensionManager(
+          TextMarkerUI.PLUGIN_ID + ".tmSemanticHighlighting"); //$NON-NLS-1$
+
+  private final static String[] LEGAL_CONTENT_TYPES = new String[] {
+      TextMarkerPartitions.TM_STRING, TextMarkerPartitions.TM_COMMENT };
+
+  public TextMarkerTextTools(boolean autoDisposeOnDisplayDispose) {
+    super(TextMarkerPartitions.TM_PARTITIONING, LEGAL_CONTENT_TYPES, autoDisposeOnDisplayDispose);
+    fPartitionScanner = new TextMarkerPartitionScanner();
+  }
+
+  @Override
+  public ScriptSourceViewerConfiguration createSourceViewerConfiguraton(
+          IPreferenceStore preferenceStore, ITextEditor editor, String partitioning) {
+    return new TextMarkerSourceViewerConfiguration(getColorManager(), preferenceStore, editor,
+            partitioning);
+  }
+
+  @Override
+  public IPartitionTokenScanner getPartitionScanner() {
+    return fPartitionScanner;
+  }
+
+  private ISemanticHighlightingExtension[] getExtensions() {
+    Object[] objects = extensions.getObjects();
+    ISemanticHighlightingExtension[] exts = new ISemanticHighlightingExtension[objects.length];
+
+    for (int i = 0; i < objects.length; i++) {
+      exts[i] = ((ISemanticHighlightingExtension) objects[i]);
+    }
+    return exts;
+  }
+
+  @Override
+  public SemanticHighlighting[] getSemanticHighlightings() {
+    List highlightings = new ArrayList();
+    ISemanticHighlightingExtension[] exts = getExtensions();
+    for (int i = 0; i < exts.length; i++) {
+      SemanticHighlighting[] hl = exts[i].getHighlightings();
+      if (hl != null) {
+        highlightings.addAll(Arrays.asList(hl));
+      }
+    }
+    SemanticHighlighting[] ret = new SemanticHighlighting[highlightings.size()];
+    for (int i = 0; i < highlightings.size(); i++)
+      ret[i] = (SemanticHighlighting) highlightings.get(i);
+
+    return ret;
+  }
+
+  @Override
+  public ISemanticHighlighter getSemanticPositionUpdater() {
+    return new TextMarkerSemanticPositionUpdater(getExtensions());
+  }
+
+  public final static class SH extends SemanticHighlighting {
+
+    private final String preferenceKey;
+
+    private final String bgColor;
+
+    private final String description;
+
+    public SH(String editorXmlTagNameColor, String bgColor, String desc) {
+      this.preferenceKey = editorXmlTagNameColor;
+      this.bgColor = bgColor;
+      this.description = desc;
+    }
+
+    @Override
+    public boolean isSemanticOnly() {
+      return description != null;
+    }
+
+    @Override
+    public String getPreferenceKey() {
+      return preferenceKey;
+    }
+
+    @Override
+    public String getBackgroundPreferenceKey() {
+      return bgColor;
+    }
+
+    @Override
+    public int hashCode() {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((preferenceKey == null) ? 0 : preferenceKey.hashCode());
+      return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+      if (this == obj)
+        return true;
+      if (obj == null)
+        return false;
+      if (getClass() != obj.getClass())
+        return false;
+      final SH other = (SH) obj;
+      if (preferenceKey == null) {
+        if (other.preferenceKey != null)
+          return false;
+      } else if (!preferenceKey.equals(other.preferenceKey))
+        return false;
+      return true;
+    }
+
+    @Override
+    public String getDisplayName() {
+      return description;
+    }
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerTextTools.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerTextTools.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWhitespaceDetector.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWhitespaceDetector.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWhitespaceDetector.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWhitespaceDetector.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,13 @@
+package org.apache.uima.tm.dltk.internal.ui.text;
+
+import org.eclipse.jface.text.rules.IWhitespaceDetector;
+
+public class TextMarkerWhitespaceDetector implements IWhitespaceDetector {
+
+  /*
+   * (non-Javadoc) Method declared on IWhitespaceDetector
+   */
+  public boolean isWhitespace(char character) {
+    return Character.isWhitespace(character);
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWhitespaceDetector.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWhitespaceDetector.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWordDetector.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWordDetector.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWordDetector.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWordDetector.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,20 @@
+package org.apache.uima.tm.dltk.internal.ui.text;
+
+import org.eclipse.jface.text.rules.IWordDetector;
+
+public class TextMarkerWordDetector implements IWordDetector {
+
+  /*
+   * (non-Javadoc) Method declared on IWordDetector.
+   */
+  public boolean isWordPart(char character) {
+    return Character.isJavaIdentifierPart(character);
+  }
+
+  /*
+   * (non-Javadoc) Method declared on IWordDetector.
+   */
+  public boolean isWordStart(char character) {
+    return Character.isJavaIdentifierStart(character);
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWordDetector.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWordDetector.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWordRule.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWordRule.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWordRule.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWordRule.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,159 @@
+package org.apache.uima.tm.dltk.internal.ui.text;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IPredicateRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.Token;
+
+public class TextMarkerWordRule implements IPredicateRule {
+
+  /** Internal setting for the un-initialized column constraint */
+  protected static final int UNDEFINED = -1;
+
+  /** The word detector used by this rule */
+  protected IWordDetector fDetector;
+
+  /**
+   * The default token to be returned on success and if nothing else has been specified.
+   */
+  protected IToken fDefaultToken;
+
+  /** The column constraint */
+  protected int fColumn = UNDEFINED;
+
+  /** The table of predefined words and token for this rule */
+  protected Map fWords = new HashMap();
+
+  /** Buffer used for pattern detection */
+  private StringBuffer fBuffer = new StringBuffer();
+
+  // private IToken classNameToken;
+
+  // private IToken funcNameToken;
+
+  /**
+   * Creates a rule which, with the help of a word detector, will return the token associated with
+   * the detected word. If no token has been associated, the specified default token will be
+   * returned.
+   * 
+   * @param detector
+   *          the word detector to be used by this rule, may not be <code>null</code>
+   * @param defaultToken
+   *          the default token to be returned on success if nothing else is specified, may not be
+   *          <code>null</code>
+   * @param funcNameToken
+   * @param classNameToken
+   * 
+   * @see #addWord(String, IToken)
+   */
+  public TextMarkerWordRule(IWordDetector detector, IToken defaultToken, IToken classNameToken) {
+
+    Assert.isNotNull(detector);
+    Assert.isNotNull(defaultToken);
+
+    fDetector = detector;
+    fDefaultToken = defaultToken;
+    // this.classNameToken = classNameToken;
+    // this.funcNameToken = funcNameToken;
+  }
+
+  /**
+   * Adds a word and the token to be returned if it is detected.
+   * 
+   * @param word
+   *          the word this rule will search for, may not be <code>null</code>
+   * @param token
+   *          the token to be returned if the word has been found, may not be <code>null</code>
+   */
+  public void addWord(String word, IToken token) {
+    Assert.isNotNull(word);
+    Assert.isNotNull(token);
+
+    fWords.put(word, token);
+  }
+
+  /**
+   * Sets a column constraint for this rule. If set, the rule's token will only be returned if the
+   * pattern is detected starting at the specified column. If the column is smaller then 0, the
+   * column constraint is considered removed.
+   * 
+   * @param column
+   *          the column in which the pattern starts
+   */
+  public void setColumnConstraint(int column) {
+    if (column < 0)
+      column = UNDEFINED;
+    fColumn = column;
+  }
+
+  private String lastFound = "";
+
+  public IToken evaluate(ICharacterScanner scanner) {
+    int c = scanner.read();
+    fBuffer.setLength(0);
+
+    // special for '->'
+    if (c == '-') {
+      fBuffer.append((char) c);
+      c = scanner.read();
+      if (c == '>') {
+        fBuffer.append((char) c);
+        String str = fBuffer.toString();
+        IToken token = (IToken) fWords.get(str);
+        if (token != null) {
+          lastFound = str;
+          return token;
+        }
+      } else {
+        // scanner.unread();
+
+        fBuffer.setLength(0);
+      }
+    }
+    // the rest
+    if (fDetector.isWordStart((char) c)) {
+      if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
+        fBuffer.setLength(0);
+
+        do {
+          fBuffer.append((char) c);
+          c = scanner.read();
+        } while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c));
+        scanner.unread();
+
+        String str = fBuffer.toString();
+        IToken token = (IToken) fWords.get(str);
+        if (token != null) {
+          lastFound = str;
+          return token;
+        }
+
+        if (fDefaultToken.isUndefined())
+          unreadBuffer(scanner);
+
+        return fDefaultToken;
+      }
+    }
+
+    scanner.unread();
+    return Token.UNDEFINED;
+  }
+
+  protected void unreadBuffer(ICharacterScanner scanner) {
+    for (int i = fBuffer.length() - 1; i >= 0; i--)
+      scanner.unread();
+  }
+
+  public IToken evaluate(ICharacterScanner scanner, boolean resume) {
+    return evaluate(scanner);
+  }
+
+  public IToken getSuccessToken() {
+    return this.fDefaultToken;
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWordRule.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/TextMarkerWordRule.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerCompletionProposalCollector.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerCompletionProposalCollector.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerCompletionProposalCollector.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerCompletionProposalCollector.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,77 @@
+package org.apache.uima.tm.dltk.internal.ui.text.completion;
+
+import org.eclipse.dltk.core.CompletionProposal;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.ui.text.completion.CompletionProposalLabelProvider;
+import org.eclipse.dltk.ui.text.completion.IScriptCompletionProposal;
+import org.eclipse.dltk.ui.text.completion.ScriptCompletionProposal;
+import org.eclipse.dltk.ui.text.completion.ScriptCompletionProposalCollector;
+import org.eclipse.dltk.ui.text.completion.ScriptContentAssistInvocationContext;
+import org.eclipse.swt.graphics.Image;
+
+public class TextMarkerCompletionProposalCollector extends ScriptCompletionProposalCollector {
+
+  protected final static char[] VAR_TRIGGER = new char[] { '\t', ' ', '=', ';', '.' };
+
+  @Override
+  protected char[] getVarTrigger() {
+    return VAR_TRIGGER;
+  }
+
+  public TextMarkerCompletionProposalCollector(ISourceModule module) {
+    super(module);
+  }
+
+  // Label provider
+  @Override
+  protected CompletionProposalLabelProvider createLabelProvider() {
+    return new TextMarkerCompletionProposalLabelProvider();
+  }
+
+  // Invocation context
+  @Override
+  protected ScriptContentAssistInvocationContext createScriptContentAssistInvocationContext(
+          ISourceModule sourceModule) {
+    return new ScriptContentAssistInvocationContext(sourceModule) {
+      @Override
+      protected CompletionProposalLabelProvider createLabelProvider() {
+        return new TextMarkerCompletionProposalLabelProvider();
+      }
+    };
+  }
+
+  // Specific proposals creation. May be use factory?
+  @Override
+  protected ScriptCompletionProposal createScriptCompletionProposal(String completion,
+          int replaceStart, int length, Image image, String displayString, int i) {
+    return new TextMarkerScriptCompletionProposal(displayString, replaceStart, length, image,
+            displayString, i);
+  }
+
+  @Override
+  protected ScriptCompletionProposal createScriptCompletionProposal(String completion,
+          int replaceStart, int length, Image image, String displayString, int i, boolean isInDoc) {
+    return new TextMarkerScriptCompletionProposal(displayString, replaceStart, length, image,
+            displayString, i, isInDoc);
+  }
+
+  @Override
+  protected ScriptCompletionProposal createOverrideCompletionProposal(IScriptProject scriptProject,
+          ISourceModule compilationUnit, String name, String[] paramTypes, int start, int length,
+          String displayName, String completionProposal) {
+    return new TextMarkerOverrideCompletionProposal(scriptProject, compilationUnit, name,
+            paramTypes, start, length, displayName, completionProposal);
+  }
+
+  @Override
+  protected IScriptCompletionProposal createKeywordProposal(CompletionProposal proposal) {
+    String completion = String.valueOf(proposal.getCompletion());
+    int start = proposal.getReplaceStart();
+    int length = getLength(proposal);
+    String label = getLabelProvider().createSimpleLabel(proposal);
+    Image img = getImage(getLabelProvider().createMethodImageDescriptor(proposal));
+    int relevance = computeRelevance(proposal);
+    return createScriptCompletionProposal(completion, start, length, img, label, relevance);
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerCompletionProposalCollector.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerCompletionProposalCollector.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerCompletionProposalLabelProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerCompletionProposalLabelProvider.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerCompletionProposalLabelProvider.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerCompletionProposalLabelProvider.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,36 @@
+package org.apache.uima.tm.dltk.internal.ui.text.completion;
+
+import org.eclipse.dltk.core.CompletionProposal;
+import org.eclipse.dltk.ui.text.completion.CompletionProposalLabelProvider;
+
+public class TextMarkerCompletionProposalLabelProvider extends CompletionProposalLabelProvider {
+  @Override
+  protected String createMethodProposalLabel(CompletionProposal methodProposal) {
+    StringBuffer nameBuffer = new StringBuffer();
+
+    // method name
+    nameBuffer.append(methodProposal.getName());
+
+    // parameters
+    nameBuffer.append('(');
+    appendUnboundedParameterList(nameBuffer, methodProposal);
+    nameBuffer.append(')');
+
+    return nameBuffer.toString();
+  }
+
+  @Override
+  protected String createOverrideMethodProposalLabel(CompletionProposal methodProposal) {
+    StringBuffer nameBuffer = new StringBuffer();
+
+    // method name
+    nameBuffer.append(methodProposal.getName());
+
+    // parameters
+    nameBuffer.append('(');
+    appendUnboundedParameterList(nameBuffer, methodProposal);
+    nameBuffer.append(")  "); //$NON-NLS-1$
+
+    return nameBuffer.toString();
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerCompletionProposalLabelProvider.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerCompletionProposalLabelProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerContentAssistPreference.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerContentAssistPreference.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerContentAssistPreference.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerContentAssistPreference.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,22 @@
+package org.apache.uima.tm.dltk.internal.ui.text.completion;
+
+import org.apache.uima.tm.dltk.internal.ui.TextMarkerUI;
+import org.eclipse.dltk.ui.text.ScriptTextTools;
+import org.eclipse.dltk.ui.text.completion.ContentAssistPreference;
+
+
+public class TextMarkerContentAssistPreference extends ContentAssistPreference {
+  static TextMarkerContentAssistPreference sDefault;
+
+  @Override
+  protected ScriptTextTools getTextTools() {
+    return TextMarkerUI.getDefault().getTextTools();
+  }
+
+  public static ContentAssistPreference getDefault() {
+    if (sDefault == null) {
+      sDefault = new TextMarkerContentAssistPreference();
+    }
+    return sDefault;
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerContentAssistPreference.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerContentAssistPreference.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerNoTypeCompletionProposalComputer.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerNoTypeCompletionProposalComputer.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerNoTypeCompletionProposalComputer.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerNoTypeCompletionProposalComputer.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,45 @@
+package org.apache.uima.tm.dltk.internal.ui.text.completion;
+
+import org.apache.uima.tm.dltk.internal.ui.TextMarkerUI;
+import org.apache.uima.tm.dltk.internal.ui.templates.TextMarkerTemplateCompletionProcessor;
+import org.eclipse.dltk.core.CompletionProposal;
+import org.eclipse.dltk.ui.text.completion.ScriptCompletionProposalCollector;
+import org.eclipse.dltk.ui.text.completion.ScriptCompletionProposalComputer;
+import org.eclipse.dltk.ui.text.completion.ScriptContentAssistInvocationContext;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.templates.TemplateCompletionProcessor;
+
+
+public class TextMarkerNoTypeCompletionProposalComputer extends ScriptCompletionProposalComputer {
+
+  @Override
+  protected ScriptCompletionProposalCollector createCollector(
+          ScriptContentAssistInvocationContext context) {
+    ScriptCompletionProposalCollector collector = new TextMarkerCompletionProposalCollector(context
+            .getSourceModule());
+
+    collector.setIgnored(CompletionProposal.FIELD_REF, false);
+    collector.setIgnored(CompletionProposal.KEYWORD, false);
+    collector.setIgnored(CompletionProposal.PACKAGE_REF, false);
+    collector.setIgnored(CompletionProposal.LABEL_REF, false);
+    collector.setIgnored(CompletionProposal.LOCAL_VARIABLE_REF, false);
+    collector.setIgnored(CompletionProposal.METHOD_DECLARATION, false);
+    collector.setIgnored(CompletionProposal.METHOD_NAME_REFERENCE, false);
+    collector.setIgnored(CompletionProposal.METHOD_REF, false);
+    collector.setIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION, false);
+    collector.setIgnored(CompletionProposal.VARIABLE_DECLARATION, false);
+
+    // collector.setIgnored(CompletionProposal.TYPE_REF, true);
+    collector.setIgnored(CompletionProposal.TYPE_REF, false);
+    IPreferenceStore preferenceStore = TextMarkerUI.getDefault().getPreferenceStore();
+
+    return collector;
+  }
+
+  @Override
+  protected TemplateCompletionProcessor createTemplateProposalComputer(
+          ScriptContentAssistInvocationContext context) {
+    return new TextMarkerTemplateCompletionProcessor(context);
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerNoTypeCompletionProposalComputer.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerNoTypeCompletionProposalComputer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerOverrideCompletionProposal.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerOverrideCompletionProposal.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerOverrideCompletionProposal.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerOverrideCompletionProposal.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,69 @@
+package org.apache.uima.tm.dltk.internal.ui.text.completion;
+
+import org.apache.uima.tm.dltk.internal.ui.TextMarkerUI;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.ui.PreferenceConstants;
+import org.eclipse.dltk.ui.text.completion.ScriptTypeCompletionProposal;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ContextInformation;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension4;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+
+
+public class TextMarkerOverrideCompletionProposal extends ScriptTypeCompletionProposal implements
+        ICompletionProposalExtension4 {
+
+  private String methodName;
+
+  public TextMarkerOverrideCompletionProposal(IScriptProject project, ISourceModule cu,
+          String methodName, String[] paramTypes, int start, int length, String displayName,
+          String completionProposal) {
+    super(completionProposal, cu, start, length, null, displayName, 0);
+    Assert.isNotNull(project);
+    Assert.isNotNull(methodName);
+    Assert.isNotNull(paramTypes);
+    Assert.isNotNull(cu);
+
+    this.methodName = methodName;
+
+    setReplacementString(completionProposal);
+  }
+
+  @Override
+  public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) {
+    return methodName;
+  }
+
+  @Override
+  protected boolean updateReplacementString(IDocument document, char trigger, int offset)
+          throws CoreException, BadLocationException {
+    final IDocument buffer = new Document(document.get());
+    int index = offset - 1;
+    while (index >= 0 && Character.isJavaIdentifierPart(buffer.getChar(index)))
+      index--;
+    final int length = offset - index - 1;
+    buffer.replace(index + 1, length, " "); //$NON-NLS-1$
+    return true;
+  }
+
+  public boolean isAutoInsertable() {
+    return false;
+  }
+
+  @Override
+  public IContextInformation getContextInformation() {
+    return new ContextInformation(getDisplayString(), getDisplayString());
+  }
+
+  @Override
+  protected boolean insertCompletion() {
+    IPreferenceStore preference = TextMarkerUI.getDefault().getPreferenceStore();
+    return preference.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerOverrideCompletionProposal.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerOverrideCompletionProposal.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerScriptCompletionProcessor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerScriptCompletionProcessor.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerScriptCompletionProcessor.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerScriptCompletionProcessor.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,78 @@
+package org.apache.uima.tm.dltk.internal.ui.text.completion;
+
+import org.apache.uima.tm.dltk.core.TextMarkerNature;
+import org.apache.uima.tm.dltk.internal.ui.TextMarkerUI;
+import org.eclipse.dltk.ui.text.completion.CompletionProposalLabelProvider;
+import org.eclipse.dltk.ui.text.completion.ContentAssistInvocationContext;
+import org.eclipse.dltk.ui.text.completion.ScriptCompletionProcessor;
+import org.eclipse.dltk.ui.text.completion.ScriptContentAssistInvocationContext;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.eclipse.ui.IEditorPart;
+
+
+public class TextMarkerScriptCompletionProcessor extends ScriptCompletionProcessor {
+  public TextMarkerScriptCompletionProcessor(IEditorPart editor, ContentAssistant assistant,
+          String partition) {
+    super(editor, assistant, partition);
+  }
+
+  @Override
+  protected IPreferenceStore getPreferenceStore() {
+    return TextMarkerUI.getDefault().getPreferenceStore();
+  }
+
+  @Override
+  protected ContentAssistInvocationContext createContext(ITextViewer viewer, int offset) {
+    return new ScriptContentAssistInvocationContext(viewer, offset, fEditor,
+            TextMarkerNature.NATURE_ID) {
+      @Override
+      protected CompletionProposalLabelProvider createLabelProvider() {
+        return new TextMarkerCompletionProposalLabelProvider();
+      }
+    };
+  }
+
+  @Override
+  protected String getNatureId() {
+    return TextMarkerNature.NATURE_ID;
+  }
+
+  protected static class Validator implements IContextInformationValidator,
+          IContextInformationPresenter {
+
+    private int initialOffset;
+
+    public boolean isContextInformationValid(int offset) {
+      return Math.abs(offset - initialOffset) < 5;
+    }
+
+    public void install(IContextInformation info, ITextViewer viewer, int offset) {
+      initialOffset = offset;
+    }
+
+    public boolean updatePresentation(int documentPosition, TextPresentation presentation) {
+      return false;
+    }
+  }
+
+  @Override
+  protected CompletionProposalLabelProvider getProposalLabelProvider() {
+    return new TextMarkerCompletionProposalLabelProvider();
+  }
+
+  private IContextInformationValidator validator;
+
+  @Override
+  public IContextInformationValidator getContextInformationValidator() {
+    if (validator == null) {
+      validator = new Validator();
+    }
+    return validator;
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerScriptCompletionProcessor.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerScriptCompletionProcessor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerScriptCompletionProposal.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerScriptCompletionProposal.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerScriptCompletionProposal.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerScriptCompletionProposal.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,41 @@
+package org.apache.uima.tm.dltk.internal.ui.text.completion;
+
+import org.apache.uima.tm.dltk.internal.ui.TextMarkerUI;
+import org.eclipse.dltk.ui.PreferenceConstants;
+import org.eclipse.dltk.ui.text.completion.ScriptCompletionProposal;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.graphics.Image;
+
+
+public class TextMarkerScriptCompletionProposal extends ScriptCompletionProposal {
+
+  public TextMarkerScriptCompletionProposal(String replacementString, int replacementOffset,
+          int replacementLength, Image image, String displayString, int relevance) {
+    super(replacementString, replacementOffset, replacementLength, image, displayString, relevance);
+  }
+
+  public TextMarkerScriptCompletionProposal(String replacementString, int replacementOffset,
+          int replacementLength, Image image, String displayString, int relevance, boolean isInDoc) {
+    super(replacementString, replacementOffset, replacementLength, image, displayString, relevance,
+            isInDoc);
+  }
+
+  @Override
+  protected boolean isSmartTrigger(char trigger) {
+    if (trigger == '.') {
+      return true;
+    }
+    return false;
+  }
+
+  @Override
+  protected boolean isCamelCaseMatching() {
+    return true;
+  }
+
+  @Override
+  protected boolean insertCompletion() {
+    IPreferenceStore preference = TextMarkerUI.getDefault().getPreferenceStore();
+    return preference.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerScriptCompletionProposal.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerScriptCompletionProposal.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerTypeCompletionProposalComputer.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerTypeCompletionProposalComputer.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerTypeCompletionProposalComputer.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerTypeCompletionProposalComputer.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,43 @@
+package org.apache.uima.tm.dltk.internal.ui.text.completion;
+
+import org.apache.uima.tm.dltk.internal.ui.TextMarkerUI;
+import org.apache.uima.tm.dltk.internal.ui.templates.TextMarkerTemplateCompletionProcessor;
+import org.eclipse.dltk.core.CompletionProposal;
+import org.eclipse.dltk.ui.text.completion.ScriptCompletionProposalCollector;
+import org.eclipse.dltk.ui.text.completion.ScriptCompletionProposalComputer;
+import org.eclipse.dltk.ui.text.completion.ScriptContentAssistInvocationContext;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.templates.TemplateCompletionProcessor;
+
+
+public class TextMarkerTypeCompletionProposalComputer extends ScriptCompletionProposalComputer {
+
+  @Override
+  protected ScriptCompletionProposalCollector createCollector(
+          ScriptContentAssistInvocationContext context) {
+    ScriptCompletionProposalCollector collector = new TextMarkerCompletionProposalCollector(context
+            .getSourceModule());
+
+    collector.setIgnored(CompletionProposal.FIELD_REF, true);
+    collector.setIgnored(CompletionProposal.KEYWORD, true);
+    collector.setIgnored(CompletionProposal.LABEL_REF, true);
+    collector.setIgnored(CompletionProposal.LOCAL_VARIABLE_REF, true);
+    collector.setIgnored(CompletionProposal.METHOD_DECLARATION, true);
+    collector.setIgnored(CompletionProposal.METHOD_NAME_REFERENCE, true);
+    collector.setIgnored(CompletionProposal.METHOD_REF, true);
+    collector.setIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION, true);
+    collector.setIgnored(CompletionProposal.VARIABLE_DECLARATION, true);
+
+    collector.setIgnored(CompletionProposal.TYPE_REF, false);
+
+    IPreferenceStore preferenceStore = TextMarkerUI.getDefault().getPreferenceStore();
+
+    return collector;
+  }
+
+  @Override
+  protected TemplateCompletionProcessor createTemplateProposalComputer(
+          ScriptContentAssistInvocationContext context) {
+    return new TextMarkerTemplateCompletionProcessor(context);
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerTypeCompletionProposalComputer.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/completion/TextMarkerTypeCompletionProposalComputer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingMessages.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingMessages.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingMessages.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingMessages.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,45 @@
+package org.apache.uima.tm.dltk.internal.ui.text.folding;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class TextMarkerFoldingMessages extends NLS {
+
+  private static final String BUNDLE_NAME = "org.apache.uima.tm.dltk.internal.ui.text.folding.TextMarkerFoldingMessages";//$NON-NLS-1$
+
+  private TextMarkerFoldingMessages() {
+  }
+
+  public static String DefaultFoldingPreferenceBlock_headers;
+
+  public static String DefaultFoldingPreferenceBlock_innerTypes;
+
+  public static String DefaultFoldingPreferenceBlock_methods;
+
+  public static String TextMarkerFoldingPreferenceBlock_0;
+
+  public static String TextMarkerFoldingPreferenceBlock_10;
+
+  public static String TextMarkerFoldingPreferenceBlock_11;
+
+  public static String TextMarkerFoldingPreferenceBlock_12;
+
+  public static String TextMarkerFoldingPreferenceBlock_13;
+
+  public static String TextMarkerFoldingPreferenceBlock_14;
+
+  public static String TextMarkerFoldingPreferenceBlock_15;
+
+  public static String TextMarkerFoldingPreferenceBlock_16;
+
+  public static String TextMarkerFoldingPreferenceBlock_2;
+
+  public static String TextMarkerFoldingPreferenceBlock_3;
+
+  public static String TextMarkerFoldingPreferenceBlock_4;
+
+  public static String TextMarkerFoldingPreferenceBlock_6;
+
+  static {
+    NLS.initializeMessages(BUNDLE_NAME, TextMarkerFoldingMessages.class);
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingMessages.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingMessages.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingMessages.properties
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingMessages.properties?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingMessages.properties (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingMessages.properties Mon Aug  1 14:37:34 2011
@@ -0,0 +1,15 @@
+TextMarkerFoldingPreferenceBlock_0=Add
+TextMarkerFoldingPreferenceBlock_2=You may use only english letters and _.
+TextMarkerFoldingPreferenceBlock_3=Add block
+TextMarkerFoldingPreferenceBlock_4=Enter name of block ("if" for example)
+TextMarkerFoldingPreferenceBlock_6=Remove
+TextMarkerFoldingPreferenceBlock_10=Block folding
+TextMarkerFoldingPreferenceBlock_11=Off
+TextMarkerFoldingPreferenceBlock_12=Fold all blocks except following:
+TextMarkerFoldingPreferenceBlock_13=Fold only following blocks:
+TextMarkerFoldingPreferenceBlock_14=Comments
+TextMarkerFoldingPreferenceBlock_15=Join comments divided by empty lines
+TextMarkerFoldingPreferenceBlock_16=Initially fold
+DefaultFoldingPreferenceBlock_methods=&Procedures and other blocks
+DefaultFoldingPreferenceBlock_innerTypes=&Namespaces
+DefaultFoldingPreferenceBlock_headers=&Header Comments

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingMessages.properties
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingMessages.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingPreferenceBlock.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingPreferenceBlock.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingPreferenceBlock.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingPreferenceBlock.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,299 @@
+package org.apache.uima.tm.dltk.internal.ui.text.folding;
+
+import java.util.ArrayList;
+
+import org.apache.uima.tm.dltk.ui.TextMarkerPreferenceConstants;
+import org.eclipse.dltk.ui.PreferenceConstants;
+import org.eclipse.dltk.ui.preferences.AbstractConfigurationBlock;
+import org.eclipse.dltk.ui.preferences.OverlayPreferenceStore;
+import org.eclipse.dltk.ui.preferences.PreferencesMessages;
+import org.eclipse.dltk.ui.preferences.OverlayPreferenceStore.OverlayKey;
+import org.eclipse.dltk.ui.text.folding.IFoldingPreferenceBlock;
+import org.eclipse.dltk.ui.util.PixelConverter;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.window.Window;
+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.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;
+
+
+public class TextMarkerFoldingPreferenceBlock extends AbstractConfigurationBlock implements
+        IFoldingPreferenceBlock {
+
+  protected class ListBlock {
+    private ListViewer fList;
+
+    private String fKey;
+
+    private Button fAddButton;
+
+    private Button fRemoveButton;
+
+    public ListBlock(Composite parent, String key) {
+      fKey = key;
+      createControl(parent);
+    }
+
+    private 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);
+      fList = new ListViewer(comp);
+      gd = new GridData(GridData.FILL_BOTH);
+      gd.heightHint = 6;
+      fList.getControl().setLayoutData(gd);
+      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,
+              TextMarkerFoldingMessages.TextMarkerFoldingPreferenceBlock_0);
+      fAddButton.addSelectionListener(new SelectionListener() {
+        public void widgetDefaultSelected(SelectionEvent e) {
+        }
+
+        public void widgetSelected(SelectionEvent e) {
+          IInputValidator validator = new IInputValidator() {
+            public String isValid(String newText) {
+              if (newText.trim().length() > 0 && newText.matches("[_a-zA-Z]*")) //$NON-NLS-1$
+                return null;
+              return TextMarkerFoldingMessages.TextMarkerFoldingPreferenceBlock_2;
+            }
+          };
+          InputDialog dlg = new InputDialog(null,
+                  TextMarkerFoldingMessages.TextMarkerFoldingPreferenceBlock_3,
+                  TextMarkerFoldingMessages.TextMarkerFoldingPreferenceBlock_4, "", validator);
+          if (dlg.open() == Window.OK) {
+            fList.add(dlg.getValue());
+            save();
+          }
+        }
+      });
+      fRemoveButton = createPushButton(pathButtonComp,
+              TextMarkerFoldingMessages.TextMarkerFoldingPreferenceBlock_6);
+      fRemoveButton.addSelectionListener(new SelectionListener() {
+        public void widgetDefaultSelected(SelectionEvent e) {
+        }
+
+        public void widgetSelected(SelectionEvent e) {
+          ISelection s = fList.getSelection();
+          if (s instanceof IStructuredSelection) {
+            IStructuredSelection sel = (IStructuredSelection) s;
+            fList.remove(sel.toArray());
+            save();
+          }
+        }
+      });
+      return comp;
+    }
+
+    protected Button createPushButton(Composite parent, String label) {
+      Button button = new Button(parent, SWT.PUSH);
+      button.setFont(parent.getFont());
+      if (label != null) {
+        button.setText(label);
+      }
+      GridData gd = new GridData();
+      button.setLayoutData(gd);
+      gd.widthHint = getButtonWidthHint(button);
+      gd.horizontalAlignment = GridData.FILL;
+      return button;
+    }
+
+    /**
+     * Returns a width hint for a button control.
+     */
+    public int getButtonWidthHint(Button button) {
+      button.setFont(JFaceResources.getDialogFont());
+      PixelConverter converter = new PixelConverter(button);
+      int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+      return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
+    }
+
+    private String[] getEntries() {
+      return fList.getList().getItems();
+    }
+
+    private void setEntries(String items[]) {
+      fList.remove(fList.getList().getItems());
+      for (int i = 0; i < items.length; i++) {
+        if (items[i].trim().length() > 0)
+          fList.add(items[i]);
+      }
+    }
+
+    public void save() {
+      String items[] = getEntries();
+      StringBuffer buf = new StringBuffer();
+      for (int i = 0; i < items.length; i++) {
+        buf.append(items[i]);
+        if (i != items.length - 1)
+          buf.append(","); //$NON-NLS-1$
+      }
+      getPreferenceStore().setValue(fKey, buf.toString());
+    }
+
+    public void initialize() {
+      String val = getPreferenceStore().getString(fKey);
+      if (val != null) {
+        String items[] = val.split(","); //$NON-NLS-1$
+        setEntries(items);
+      }
+
+    }
+
+    public void performDefault() {
+      String val = getPreferenceStore().getDefaultString(fKey);
+      if (val != null) {
+        String items[] = val.split(","); //$NON-NLS-1$
+        setEntries(items);
+      }
+    }
+  }
+
+  private ListBlock fExcludePatterns;
+
+  private ListBlock fIncludePatterns;
+
+  private OverlayPreferenceStore fOverlayStore;
+
+  private OverlayKey[] fKeys;
+
+  public TextMarkerFoldingPreferenceBlock(OverlayPreferenceStore store,
+          PreferencePage mainPreferencePage) {
+    super(store, mainPreferencePage);
+    fOverlayStore = store;
+    fKeys = createKeys();
+    fOverlayStore.addKeys(fKeys);
+  }
+
+  private OverlayKey[] createKeys() {
+    ArrayList overlayKeys = new ArrayList();
+    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_BLOCKS));
+    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
+            PreferenceConstants.EDITOR_FOLDING_LINES_LIMIT));
+    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_INCLUDE_LIST));
+    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_EXCLUDE_LIST));
+    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_INIT_BLOCKS));
+    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_INIT_COMMENTS));
+    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_INIT_NAMESPACES));
+    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+            PreferenceConstants.EDITOR_COMMENTS_FOLDING_ENABLED));
+    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_COMMENTS_WITH_NEWLINES));
+    OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys
+            .size()];
+    overlayKeys.toArray(keys);
+    return keys;
+  }
+
+  public Control createControl(Composite composite) {
+    Composite inner = new Composite(composite, SWT.NONE);
+    GridLayout layout = new GridLayout();
+    layout.numColumns = 1;
+    inner.setLayout(layout);
+
+    Composite blockFolding = createSubsection(inner, null,
+            TextMarkerFoldingMessages.TextMarkerFoldingPreferenceBlock_10);
+    blockFolding.setLayout(new GridLayout());
+
+    addRadioButton(blockFolding, TextMarkerFoldingMessages.TextMarkerFoldingPreferenceBlock_11,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_BLOCKS,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_BLOCKS_OFF);
+    addRadioButton(blockFolding, TextMarkerFoldingMessages.TextMarkerFoldingPreferenceBlock_12,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_BLOCKS,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_BLOCKS_EXCLUDE);
+    fExcludePatterns = new ListBlock(blockFolding,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_EXCLUDE_LIST);
+    addRadioButton(blockFolding, TextMarkerFoldingMessages.TextMarkerFoldingPreferenceBlock_13,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_BLOCKS,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_BLOCKS_INCLUDE);
+    fIncludePatterns = new ListBlock(blockFolding,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_INCLUDE_LIST);
+
+    IInputValidator val = new IInputValidator() {
+
+      public String isValid(String number) {
+        if (number.length() == 0) {
+          return PreferencesMessages.DLTKEditorPreferencePage_empty_input;
+        } else {
+          try {
+            int value = Integer.parseInt(number);
+            if (value < 2)
+              return "You may input numbers >= 2.";
+          } catch (NumberFormatException e) {
+            return "Input is not a number";
+          }
+        }
+        return null;
+      }
+
+    };
+
+    addLabelledTextField(blockFolding, "Minimal amount of lines to be folded(>=2):",
+            PreferenceConstants.EDITOR_FOLDING_LINES_LIMIT, 3, 1, true, val);
+
+    Composite commentFolding = createSubsection(inner, null,
+            TextMarkerFoldingMessages.TextMarkerFoldingPreferenceBlock_14);
+    commentFolding.setLayout(new GridLayout());
+
+    addCheckBox(commentFolding, TextMarkerFoldingMessages.TextMarkerFoldingPreferenceBlock_15,
+            PreferenceConstants.EDITOR_COMMENTS_FOLDING_ENABLED, 0);
+
+    Composite initialFolding = createSubsection(inner, null,
+            TextMarkerFoldingMessages.TextMarkerFoldingPreferenceBlock_16);
+    initialFolding.setLayout(new GridLayout());
+
+    addCheckBox(initialFolding, TextMarkerFoldingMessages.DefaultFoldingPreferenceBlock_headers,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_INIT_COMMENTS, 0);
+    addCheckBox(initialFolding, TextMarkerFoldingMessages.DefaultFoldingPreferenceBlock_innerTypes,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_INIT_NAMESPACES, 0);
+    addCheckBox(initialFolding, TextMarkerFoldingMessages.DefaultFoldingPreferenceBlock_methods,
+            TextMarkerPreferenceConstants.EDITOR_FOLDING_INIT_BLOCKS, 0);
+
+    return inner;
+  }
+
+  @Override
+  public void initialize() {
+    super.initialize();
+    fExcludePatterns.initialize();
+    fIncludePatterns.initialize();
+  }
+
+  @Override
+  public void performDefaults() {
+    super.performDefaults();
+    fExcludePatterns.performDefault();
+    fIncludePatterns.performDefault();
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingPreferenceBlock.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingPreferenceBlock.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingStructureProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingStructureProvider.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingStructureProvider.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingStructureProvider.java Mon Aug  1 14:37:34 2011
@@ -0,0 +1,285 @@
+package org.apache.uima.tm.dltk.internal.ui.text.folding;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.uima.tm.dltk.core.TextMarkerNature;
+import org.apache.uima.tm.dltk.internal.ui.TextMarkerUI;
+import org.apache.uima.tm.dltk.internal.ui.text.TextMarkerPartitionScanner;
+import org.apache.uima.tm.dltk.parser.ast.TextMarkerStatement;
+import org.apache.uima.tm.dltk.ui.TextMarkerPreferenceConstants;
+import org.apache.uima.tm.dltk.ui.text.TextMarkerPartitions;
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.dltk.ast.ASTNode;
+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.parser.ISourceParser;
+import org.eclipse.dltk.ast.references.SimpleReference;
+import org.eclipse.dltk.ast.statements.Statement;
+import org.eclipse.dltk.core.DLTKLanguageManager;
+import org.eclipse.dltk.ui.text.folding.AbstractASTFoldingStructureProvider;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.rules.IPartitionTokenScanner;
+
+
+public class TextMarkerFoldingStructureProvider extends AbstractASTFoldingStructureProvider {
+
+  // ~ Instance fields
+
+  private List fBlockExcludeList = new ArrayList();
+
+  /* preferences */
+  private int fBlockFolding = 0;
+
+  private List fBlockIncludeList = new ArrayList();
+
+  private boolean fInitCollapseBlocks = true;
+
+  private boolean fInitCollapseComments = true;
+
+  private boolean fInitCollapseNamespaces = true;
+
+  // ~ Methods
+
+  @Override
+  protected CodeBlock[] getCodeBlocks(String code, int offset) {
+    /*
+     * if an ASTVisitor implementation is created for this, just override getFoldingVisitor() and
+     * remove this method
+     */
+    ISourceParser pp = null;
+    pp = DLTKLanguageManager.getSourceParser(TextMarkerNature.NATURE_ID);
+    ModuleDeclaration md = pp.parse(null, code.toCharArray(), null);
+    List statements = md.getStatements();
+    if (statements == null) {
+      return new CodeBlock[0];
+    }
+
+    List result = new ArrayList();
+    traverse(result, statements, offset, code);
+
+    return (CodeBlock[]) result.toArray(new CodeBlock[result.size()]);
+  }
+
+  private void checkStatement(String code, int offset, List result, Statement sst) {
+    if (sst instanceof TextMarkerStatement) {
+      TextMarkerStatement statement = (TextMarkerStatement) sst;
+      result.add(new CodeBlock(statement, new Region(offset + statement.sourceStart(), statement
+              .sourceEnd()
+              - statement.sourceStart())));
+
+      Iterator si = statement.getExpressions().iterator();
+      // while (si.hasNext()) {
+      // Expression ex = (Expression) si.next();
+      // if (ex instanceof BlockDeclaration) {
+      // BlockDeclaration be = (BlockDeclaration) ex;
+      // try {
+      // String newContents = code.substring(
+      // be.sourceStart() + 1, be.sourceEnd() - 1);
+      // CodeBlock[] cb = getCodeBlocks(newContents, offset
+      // + be.sourceStart() + 1);
+      // for (int j = 0; j < cb.length; j++) {
+      // result.add(cb[j]);
+      // }
+      // } catch (StringIndexOutOfBoundsException e) {
+      // }
+      // }
+      // }
+    }
+  }
+
+  private void traverse(List result, List statements, int offset, String code) {
+    for (Iterator iterator = statements.iterator(); iterator.hasNext();) {
+      ASTNode node = (ASTNode) iterator.next();
+      if (node instanceof TextMarkerStatement) {
+        checkStatement(code, offset, result, (Statement) node);
+      } else if (node instanceof TypeDeclaration) {
+        TypeDeclaration statement = (TypeDeclaration) node;
+        result.add(new CodeBlock(statement, new Region(offset + statement.sourceStart(), statement
+                .sourceEnd()
+                - statement.sourceStart())));
+        traverse(result, statement.getStatements(), offset, code);
+      } else if (node instanceof MethodDeclaration) {
+        MethodDeclaration statement = (MethodDeclaration) node;
+        result.add(new CodeBlock(statement, new Region(offset + statement.sourceStart(), statement
+                .sourceEnd()
+                - statement.sourceStart())));
+        traverse(result, statement.getStatements(), offset, code);
+      }
+    }
+  }
+
+  /*
+   * @see org.eclipse.dltk.ui.text.folding.AbstractASTFoldingStructureProvider#getCommentPartition()
+   */
+  @Override
+  protected String getCommentPartition() {
+    return TextMarkerPartitions.TM_COMMENT;
+  }
+
+  /*
+   * @see org.eclipse.dltk.ui.text.folding.AbstractASTFoldingStructureProvider#getLog()
+   */
+  @Override
+  protected ILog getLog() {
+    return TextMarkerUI.getDefault().getLog();
+  }
+
+  /*
+   * @see org.eclipse.dltk.ui.text.folding.AbstractASTFoldingStructureProvider#getPartition()
+   */
+  @Override
+  protected String getPartition() {
+    return TextMarkerPartitions.TM_PARTITIONING;
+  }
+
+  /*
+   * @see org.eclipse.dltk.ui.text.folding.AbstractASTFoldingStructureProvider#getPartitionScanner()
+   */
+  @Override
+  protected IPartitionTokenScanner getPartitionScanner() {
+    return new TextMarkerPartitionScanner();
+  }
+
+  /*
+   * @see org.eclipse.dltk.ui.text.folding.AbstractASTFoldingStructureProvider#getPartitionTypes()
+   */
+  @Override
+  protected String[] getPartitionTypes() {
+    return TextMarkerPartitions.TM_PARTITION_TYPES;
+  }
+
+  /*
+   * @see org.eclipse.dltk.ui.text.folding.AbstractASTFoldingStructureProvider#getNatureId()
+   */
+  @Override
+  protected String getNatureId() {
+    return TextMarkerNature.NATURE_ID;
+  }
+
+  /*
+   * @see
+   * org.eclipse.dltk.ui.text.folding.AbstractASTFoldingStructureProvider#initializePreferences(
+   * org.eclipse.jface.preference.IPreferenceStore)
+   */
+  @Override
+  protected void initializePreferences(IPreferenceStore store) {
+    super.initializePreferences(store);
+    fBlockFolding = store.getInt(TextMarkerPreferenceConstants.EDITOR_FOLDING_BLOCKS);
+
+    String t = store.getString(TextMarkerPreferenceConstants.EDITOR_FOLDING_EXCLUDE_LIST);
+    String[] items = t.split(",");
+    fBlockExcludeList.clear();
+    for (int i = 0; i < items.length; i++) {
+      if (items[i].trim().length() > 0) {
+        fBlockExcludeList.add(items[i]);
+      }
+    }
+
+    t = store.getString(TextMarkerPreferenceConstants.EDITOR_FOLDING_INCLUDE_LIST);
+    items = t.split(",");
+    fBlockIncludeList.clear();
+    for (int i = 0; i < items.length; i++) {
+      if (items[i].trim().length() > 0) {
+        fBlockIncludeList.add(items[i]);
+      }
+    }
+
+    fFoldNewLines = store
+            .getBoolean(TextMarkerPreferenceConstants.EDITOR_FOLDING_COMMENTS_WITH_NEWLINES);
+    fInitCollapseBlocks = store
+            .getBoolean(TextMarkerPreferenceConstants.EDITOR_FOLDING_INIT_BLOCKS);
+    fInitCollapseComments = store
+            .getBoolean(TextMarkerPreferenceConstants.EDITOR_FOLDING_INIT_COMMENTS);
+    fInitCollapseNamespaces = store
+            .getBoolean(TextMarkerPreferenceConstants.EDITOR_FOLDING_INIT_NAMESPACES);
+  }
+
+  @Override
+  protected boolean initiallyCollapse(ASTNode s, FoldingStructureComputationContext ctx) {
+    if (s instanceof TextMarkerStatement) {
+      TextMarkerStatement statement = (TextMarkerStatement) s;
+      if (!(statement.getAt(0) instanceof SimpleReference)) {
+        return false;
+      }
+
+      String name = null;
+      name = ((SimpleReference) statement.getAt(0)).getName();
+      if (name.equals("namespace")) {
+        return ctx.allowCollapsing() && fInitCollapseNamespaces;
+      }
+
+      return ctx.allowCollapsing() && fInitCollapseBlocks;
+    }
+
+    return false;
+  }
+
+  /*
+   * @see
+   * org.eclipse.dltk.ui.text.folding.AbstractASTFoldingStructureProvider#initiallyCollapseComments
+   * (org.eclipse.dltk.ui.text.folding.AbstractASTFoldingStructureProvider.
+   * FoldingStructureComputationContext)
+   */
+  protected boolean initiallyCollapseComments(FoldingStructureComputationContext ctx) {
+    return ctx.allowCollapsing() && fInitCollapseComments;
+  }
+
+  /*
+   * @see
+   * org.eclipse.dltk.ui.text.folding.AbstractASTFoldingStructureProvider#mayCollapse(org.eclipse
+   * .dltk.ast.statements.Statement,
+   * org.eclipse.dltk.ui.text.folding.AbstractASTFoldingStructureProvider
+   * .FoldingStructureComputationContext)
+   */
+  protected boolean canFold(String name) {
+    switch (fBlockFolding) {
+      case TextMarkerPreferenceConstants.EDITOR_FOLDING_BLOCKS_OFF: {
+        if (name.equals("proc") || name.equals("namespace")) {
+          return true;
+        }
+
+        return false;
+      }
+      case TextMarkerPreferenceConstants.EDITOR_FOLDING_BLOCKS_INCLUDE: {
+        if (fBlockIncludeList.contains(name)) {
+          return true;
+        }
+
+        return false;
+      }
+      case TextMarkerPreferenceConstants.EDITOR_FOLDING_BLOCKS_EXCLUDE: {
+        if (fBlockExcludeList.contains(name)) {
+          return false;
+        }
+
+        return true;
+      }
+    }
+    return false;
+  }
+
+  @Override
+  protected boolean mayCollapse(ASTNode s, FoldingStructureComputationContext ctx) {
+    if (s instanceof TypeDeclaration) {
+      return canFold("namespace");
+    } else if (s instanceof MethodDeclaration) {
+      return canFold("proc");
+    } else if (s instanceof TextMarkerStatement) {
+      TextMarkerStatement statement = (TextMarkerStatement) s;
+      if (!(statement.getAt(0) instanceof SimpleReference)) {
+        return false;
+      }
+
+      String name = null;
+      name = ((SimpleReference) statement.getAt(0)).getName();
+      return canFold(name);
+    }
+
+    return false;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingStructureProvider.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/folding/TextMarkerFoldingStructureProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/messages.properties
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/messages.properties?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/messages.properties (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/internal/ui/text/messages.properties Mon Aug  1 14:37:34 2011
@@ -0,0 +1 @@
+TclRequirePackageMarkerResolution_addPackageToBuildpath=Add package {0} to buildpath.