You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2013/07/17 10:28:08 UTC
svn commit: r1504047 [7/17] - in /uima/sandbox/ruta/trunk/ruta-ep-ide-ui: ./
icons/ schema/ src/ src/main/ src/main/java/ src/main/java/org/
src/main/java/org/apache/ src/main/java/org/apache/uima/
src/main/java/org/apache/uima/ruta/ src/main/java/org/...
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaPreferenceConstants.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaPreferenceConstants.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaPreferenceConstants.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaPreferenceConstants.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,318 @@
+/*
+ * 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;
+
+import org.apache.uima.ruta.ide.ui.text.RutaColorConstants;
+import org.eclipse.dltk.ui.CodeFormatterConstants;
+import org.eclipse.dltk.ui.PreferenceConstants;
+import org.eclipse.dltk.ui.preferences.NewScriptProjectPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.swt.graphics.RGB;
+
+public class RutaPreferenceConstants extends PreferenceConstants {
+
+ public static final String EDITOR_FOLDING_IMPORTS = "editor_folding_default_imports"; //$NON-NLS-1$
+
+ public static final String EDITOR_FOLDING_BLOCKS = "editor_folding_blocks"; //$NON-NLS-1$
+
+ public static final int EDITOR_FOLDING_BLOCKS_OFF = 0;
+
+ public static final int EDITOR_FOLDING_BLOCKS_INCLUDE = 1;
+
+ public static final int EDITOR_FOLDING_BLOCKS_EXCLUDE = 2;
+
+ public static final String EDITOR_FOLDING_INCLUDE_LIST = "editor_folding_include_list"; //$NON-NLS-1$
+
+ public static final String EDITOR_FOLDING_EXCLUDE_LIST = "editor_folding_exclude_list"; //$NON-NLS-1$
+
+ public static final String EDITOR_FOLDING_INIT_COMMENTS = "editor_folding_init_comments"; //$NON-NLS-1$
+
+ public static final String EDITOR_FOLDING_INIT_NAMESPACES = "editor_folding_init_namespaces"; //$NON-NLS-1$
+
+ public static final String EDITOR_FOLDING_INIT_BLOCKS = "editor_folding_init_blocks"; //$NON-NLS-1$
+
+ public static final String EDITOR_FOLDING_COMMENTS_WITH_NEWLINES = "editor_folding_comments_lines"; //$NON-NLS-1$
+
+ public static final String DOC_MAN_PAGES_LOCATIONS = "doc_man_pages_locations";
+
+ public static final String EDITOR_FOLDING_COMMENTS_FOLDING = "editor_folding_comments";
+
+ public final static String EDITOR_SINGLE_LINE_COMMENT_COLOR = RutaColorConstants.RUTA_SINGLE_LINE_COMMENT;
+
+ public final static String EDITOR_SINGLE_LINE_COMMENT_BOLD = RutaColorConstants.RUTA_SINGLE_LINE_COMMENT
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_SINGLE_LINE_COMMENT_ITALIC = RutaColorConstants.RUTA_SINGLE_LINE_COMMENT
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_SINGLE_LINE_COMMENT_STRIKETHROUGH = RutaColorConstants.RUTA_SINGLE_LINE_COMMENT
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_SINGLE_LINE_COMMENT_UNDERLINE = RutaColorConstants.RUTA_SINGLE_LINE_COMMENT
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_NUMBER_COLOR = RutaColorConstants.RUTA_NUMBER;
+
+ public final static String EDITOR_NUMBER_BOLD = RutaColorConstants.RUTA_NUMBER
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_NUMBER_ITALIC = RutaColorConstants.RUTA_NUMBER
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_NUMBER_STRIKETHROUGH = RutaColorConstants.RUTA_NUMBER
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_NUMBER_UNDERLINE = RutaColorConstants.RUTA_NUMBER
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_STRING_COLOR = RutaColorConstants.RUTA_STRING;
+
+ public final static String EDITOR_STRING_BOLD = RutaColorConstants.RUTA_STRING
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_STRING_ITALIC = RutaColorConstants.RUTA_STRING
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_STRING_STRIKETHROUGH = RutaColorConstants.RUTA_STRING
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_STRING_UNDERLINE = RutaColorConstants.RUTA_STRING
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_FUNCTION_COLOR = RutaColorConstants.RUTA_FUNCTION;
+
+ public final static String EDITOR_FUNCTION_COLOR_BOLD = RutaColorConstants.RUTA_FUNCTION
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_FUNCTION_COLOR_ITALIC = RutaColorConstants.RUTA_FUNCTION
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_FUNCTION_COLOR_STRIKETHROUGH = RutaColorConstants.RUTA_FUNCTION
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_FUNCTION_COLOR_UNDERLINE = RutaColorConstants.RUTA_FUNCTION
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_CONDITION_COLOR = RutaColorConstants.RUTA_CONDITION;
+
+ public final static String EDITOR_CONDITION_COLOR_BOLD = RutaColorConstants.RUTA_CONDITION
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_CONDITION_COLOR_ITALIC = RutaColorConstants.RUTA_CONDITION
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_CONDITION_COLOR_STRIKETHROUGH = RutaColorConstants.RUTA_CONDITION
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_CONDITION_COLOR_UNDERLINE = RutaColorConstants.RUTA_CONDITION
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_ACTION_COLOR = RutaColorConstants.RUTA_ACTION;
+
+ public final static String EDITOR_ACTION_COLOR_BOLD = RutaColorConstants.RUTA_ACTION
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_ACTION_COLOR_ITALIC = RutaColorConstants.RUTA_ACTION
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_ACTION_COLOR_STRIKETHROUGH = RutaColorConstants.RUTA_ACTION
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_ACTION_COLOR_UNDERLINE = RutaColorConstants.RUTA_ACTION
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_THEN_COLOR = RutaColorConstants.RUTA_THEN;
+
+ public final static String EDITOR_THEN_COLOR_BOLD = RutaColorConstants.RUTA_THEN
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_THEN_COLOR_ITALIC = RutaColorConstants.RUTA_THEN
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_THEN_COLOR_STRIKETHROUGH = RutaColorConstants.RUTA_THEN
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_THEN_COLOR_UNDERLINE = RutaColorConstants.RUTA_THEN
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_DECLARATION_DEFINITION_COLOR = RutaColorConstants.RUTA_DECLARATION;
+
+ public final static String EDITOR_DECLARATION_DEFINITION_COLOR_BOLD = RutaColorConstants.RUTA_DECLARATION
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_DECLARATION_DEFINITION_COLOR_ITALIC = RutaColorConstants.RUTA_DECLARATION
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_DECLARATION_DEFINITION_COLOR_STRIKETHROUGH = RutaColorConstants.RUTA_DECLARATION
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_DECLARATION_DEFINITION_COLOR_UNDERLINE = RutaColorConstants.RUTA_DECLARATION
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_BASICSYMBOL_DEFINITION_COLOR = RutaColorConstants.RUTA_BASICSYMBOL;
+
+ public final static String EDITOR_BASICSYMBOL_DEFINITION_COLOR_BOLD = RutaColorConstants.RUTA_BASICSYMBOL
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_BASICSYMBOL_DEFINITION_COLOR_ITALIC = RutaColorConstants.RUTA_BASICSYMBOL
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_BASICSYMBOL_DEFINITION_COLOR_STRIKETHROUGH = RutaColorConstants.RUTA_BASICSYMBOL
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_BASICSYMBOL_DEFINITION_COLOR_UNDERLINE = RutaColorConstants.RUTA_BASICSYMBOL
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_DOC_COMMENT_COLOR = RutaColorConstants.RUTA_DOC_COMMENT;
+
+ public final static String EDITOR_DOC_COMMENT_COLOR_BOLD = RutaColorConstants.RUTA_DOC_COMMENT
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_DOC_COMMENT_COLOR_ITALIC = RutaColorConstants.RUTA_DOC_COMMENT
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_DOC_COMMENT_COLOR_STRIKETHROUGH = RutaColorConstants.RUTA_DOC_COMMENT
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_DOC_COMMENT_COLOR_UNDERLINE = RutaColorConstants.RUTA_DOC_COMMENT
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_VARIABLE_COLOR = RutaColorConstants.RUTA_DOC_COMMENT;
+
+ public final static String EDITOR_VARIABLE_COLOR_BOLD = RutaColorConstants.RUTA_DOC_COMMENT
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_VARIABLE_COLOR_ITALIC = RutaColorConstants.RUTA_DOC_COMMENT
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_VARIABLE_COLOR_STRIKETHROUGH = RutaColorConstants.RUTA_DOC_COMMENT
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_VARIABLE_COLOR_UNDERLINE = RutaColorConstants.RUTA_DOC_COMMENT
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_SMART_PASTE_MODE = "smartPasteMode"; //$NON-NLS-1$
+
+ public final static int EDITOR_SMART_PASTE_MODE_SIMPLE = 1;
+
+ public final static int EDITOR_SMART_PASTE_MODE_FULL = 2;
+
+ public static final String DOC_RUTA_PAGES_LOCATIONS = "doc_ruta_pages_location";
+
+ public static final String COMMENT_TASK_TAGS = RutaColorConstants.RUTA_TODO_TAG;// RutaColorConstants
+
+ public static final String COMMENT_TASK_TAGS_BOLD = COMMENT_TASK_TAGS + EDITOR_BOLD_SUFFIX;
+
+ /**
+ * A preference that controls the selected formatter.
+ */
+ public static final String FORMATTER_ID = "formatterId"; //$NON-NLS-1$
+
+ public static void initializeDefaultValues(IPreferenceStore store) {
+ PreferenceConstants.initializeDefaultValues(store);
+
+ PreferenceConverter.setDefault(store, COMMENT_TASK_TAGS, new RGB(127, 159, 191));
+ store.setDefault(COMMENT_TASK_TAGS_BOLD, true);
+
+ PreferenceConverter.setDefault(store, RutaPreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR,
+ new RGB(63, 127, 95));
+ store.setDefault(RutaPreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD, false);
+ store.setDefault(RutaPreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_ITALIC, false);
+
+ PreferenceConverter.setDefault(store, RutaPreferenceConstants.EDITOR_DOC_COMMENT_COLOR,
+ new RGB(63, 127, 95));
+
+ PreferenceConverter.setDefault(store, RutaPreferenceConstants.EDITOR_STRING_COLOR, new RGB(42,
+ 0, 255));
+ PreferenceConverter.setDefault(store, RutaPreferenceConstants.EDITOR_NUMBER_COLOR, new RGB(128,
+ 0, 0));
+
+ PreferenceConverter.setDefault(store, RutaPreferenceConstants.EDITOR_VARIABLE_COLOR, new RGB(
+ 200, 0, 0));
+
+ // Functions
+ PreferenceConverter.setDefault(store, RutaPreferenceConstants.EDITOR_FUNCTION_COLOR, new RGB(
+ 50, 50, 200));
+ store.setDefault(RutaPreferenceConstants.EDITOR_FUNCTION_COLOR_BOLD, true);
+
+ // Conditions
+ PreferenceConverter.setDefault(store, RutaPreferenceConstants.EDITOR_CONDITION_COLOR, new RGB(
+ 0, 128, 0));
+ store.setDefault(RutaPreferenceConstants.EDITOR_CONDITION_COLOR_BOLD, true);
+
+ // Actions
+ PreferenceConverter.setDefault(store, RutaPreferenceConstants.EDITOR_ACTION_COLOR, new RGB(0,
+ 0, 128));
+ store.setDefault(RutaPreferenceConstants.EDITOR_ACTION_COLOR_BOLD, true);
+
+ // Then
+ PreferenceConverter.setDefault(store, RutaPreferenceConstants.EDITOR_THEN_COLOR, new RGB(0, 0,
+ 0));
+ store.setDefault(RutaPreferenceConstants.EDITOR_THEN_COLOR_BOLD, true);
+
+ // Declarations
+ PreferenceConverter.setDefault(store,
+ RutaPreferenceConstants.EDITOR_DECLARATION_DEFINITION_COLOR, new RGB(128, 0, 0));
+ store.setDefault(RutaPreferenceConstants.EDITOR_DECLARATION_DEFINITION_COLOR_BOLD, true);
+
+ // basic tokens
+ PreferenceConverter.setDefault(store,
+ RutaPreferenceConstants.EDITOR_BASICSYMBOL_DEFINITION_COLOR, new RGB(128, 128, 128));
+ store.setDefault(RutaPreferenceConstants.EDITOR_BASICSYMBOL_DEFINITION_COLOR_BOLD, true);
+
+ store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS, false);
+ store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACKETS, true);
+ store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACES, true);
+ store.setDefault(PreferenceConstants.EDITOR_SMART_TAB, true);
+ store.setDefault(PreferenceConstants.EDITOR_SMART_PASTE, true);
+ store.setDefault(PreferenceConstants.EDITOR_SMART_HOME_END, true);
+ store.setDefault(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, true);
+ store.setDefault(PreferenceConstants.EDITOR_TAB_WIDTH, 4);
+ store.setDefault(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, true);
+
+ // folding
+ store.setDefault(PreferenceConstants.EDITOR_FOLDING_ENABLED, true);
+ store.setDefault(PreferenceConstants.EDITOR_COMMENTS_FOLDING_ENABLED, true);
+ store.setDefault(RutaPreferenceConstants.EDITOR_FOLDING_BLOCKS,
+ RutaPreferenceConstants.EDITOR_FOLDING_BLOCKS_EXCLUDE);
+ store.setDefault(RutaPreferenceConstants.EDITOR_FOLDING_INCLUDE_LIST, "BLOCK");
+ store.setDefault(RutaPreferenceConstants.EDITOR_FOLDING_EXCLUDE_LIST, "");
+ store.setDefault(RutaPreferenceConstants.EDITOR_FOLDING_COMMENTS_WITH_NEWLINES, true);
+ store.setDefault(RutaPreferenceConstants.EDITOR_FOLDING_INIT_COMMENTS, true);
+ store.setDefault(PreferenceConstants.EDITOR_FOLDING_LINES_LIMIT, 5);
+
+ store.setDefault(CodeFormatterConstants.FORMATTER_TAB_CHAR, CodeFormatterConstants.SPACE);
+ store.setDefault(CodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
+ store.setDefault(CodeFormatterConstants.FORMATTER_INDENTATION_SIZE, "4");
+
+ NewScriptProjectPreferencePage.initDefaults(store);
+
+ store.setDefault(PreferenceConstants.APPEARANCE_COMPRESS_PACKAGE_NAMES, false);
+ store.setDefault(PreferenceConstants.APPEARANCE_METHOD_RETURNTYPE, false);
+ store.setDefault(PreferenceConstants.APPEARANCE_METHOD_TYPEPARAMETERS, true);
+ store.setDefault(PreferenceConstants.APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW, ""); //$NON-NLS-1$
+
+ store.setDefault(PreferenceConstants.SHOW_SOURCE_MODULE_CHILDREN, true);
+
+ store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS, ".");
+
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaProjectDecorator.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaProjectDecorator.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaProjectDecorator.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaProjectDecorator.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+import org.apache.uima.ruta.ide.core.RutaNature;
+import org.eclipse.dltk.ui.AbstractScriptProjectDecorator;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+public class RutaProjectDecorator extends AbstractScriptProjectDecorator {
+
+ /*
+ * @see org.eclipse.dltk.ui.AbstractScriptProjectDecorator#getNatureId()
+ */
+ @Override
+ protected String getNatureId() {
+ return RutaNature.NATURE_ID;
+ }
+
+ /*
+ * @see org.eclipse.dltk.ui.AbstractScriptProjectDecorator#getProjectDecorator()
+ */
+ @Override
+ protected ImageDescriptor getProjectDecorator() {
+ return RutaImages.PROJECT_DECARATOR;
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaSemanticPositionUpdater.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaSemanticPositionUpdater.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaSemanticPositionUpdater.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaSemanticPositionUpdater.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.ui;
+
+import org.apache.uima.ruta.ide.core.RutaNature;
+import org.apache.uima.ruta.ide.ui.text.RutaTextTools;
+import org.eclipse.dltk.compiler.env.IModuleSource;
+import org.eclipse.dltk.ui.editor.highlighting.ASTSemanticHighlighter;
+import org.eclipse.dltk.ui.editor.highlighting.ISemanticHighlightingRequestor;
+import org.eclipse.dltk.ui.editor.highlighting.SemanticHighlighting;
+
+public class RutaSemanticPositionUpdater extends ASTSemanticHighlighter {
+
+ private final ISemanticHighlightingExtension[] extensions;
+
+ private final ISemanticHighlightingRequestor[] requestors;
+
+ private static class SemanticPositionRequestorExtension implements ISemanticHighlightingRequestor {
+
+ private final ISemanticHighlightingRequestor requestor;
+
+ private final int offset;
+
+ /**
+ * @param requestor
+ * @param offset
+ */
+ public SemanticPositionRequestorExtension(ISemanticHighlightingRequestor requestor, int offset) {
+ this.offset = offset;
+ this.requestor = requestor;
+ }
+
+ public void addPosition(int start, int end, String highlightingKey) {
+ requestor.addPosition(start, end, highlightingKey);
+
+ }
+
+ }
+
+ public RutaSemanticPositionUpdater(ISemanticHighlightingExtension[] extensions) {
+ this.extensions = extensions;
+ this.requestors = new ISemanticHighlightingRequestor[extensions.length];
+ int offset = 0;
+ for (int i = 0; i < extensions.length; ++i) {
+ requestors[i] = new SemanticPositionRequestorExtension(this, offset);
+ offset += extensions[i].getHighlightings().length;
+ }
+ }
+
+ @Override
+ protected String getNature() {
+ return RutaNature.NATURE_ID;
+ }
+
+ public SemanticHighlighting[] getSemanticHighlightings() {
+ return new SemanticHighlighting[] {
+ new RutaTextTools.SH(RutaPreferenceConstants.EDITOR_DECLARATION_DEFINITION_COLOR, null,
+ null),
+ new RutaTextTools.SH(RutaPreferenceConstants.EDITOR_FUNCTION_COLOR, null, null),
+ new RutaTextTools.SH(RutaPreferenceConstants.EDITOR_ACTION_COLOR, null, null),
+ new RutaTextTools.SH(RutaPreferenceConstants.EDITOR_CONDITION_COLOR, null, null),
+ new RutaTextTools.SH(RutaPreferenceConstants.EDITOR_STRING_COLOR, null, null),
+ new RutaTextTools.SH(RutaPreferenceConstants.EDITOR_VARIABLE_COLOR,
+ RutaPreferenceConstants.EDITOR_CONDITION_COLOR, null) };
+ }
+
+ @Override
+ protected boolean doHighlighting(IModuleSource code) throws Exception {
+ return false;
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaUILanguageToolkit.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaUILanguageToolkit.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaUILanguageToolkit.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaUILanguageToolkit.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,151 @@
+/*
+ * 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;
+
+import org.apache.uima.ruta.ide.RutaIdeUIPlugin;
+import org.apache.uima.ruta.ide.core.RutaConstants;
+import org.apache.uima.ruta.ide.core.RutaLanguageToolkit;
+import org.apache.uima.ruta.ide.core.parser.RutaParseUtils;
+import org.apache.uima.ruta.ide.parser.ast.RutaTypeConstants;
+import org.apache.uima.ruta.ide.ui.editor.RutaEditor;
+import org.apache.uima.ruta.ide.ui.text.SimpleRutaSourceViewerConfiguration;
+import org.eclipse.dltk.core.IDLTKLanguageToolkit;
+import org.eclipse.dltk.core.IField;
+import org.eclipse.dltk.core.IScriptFolder;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.ui.AbstractDLTKUILanguageToolkit;
+import org.eclipse.dltk.ui.IDLTKUILanguageToolkit;
+import org.eclipse.dltk.ui.ScriptElementLabels;
+import org.eclipse.dltk.ui.text.ScriptSourceViewerConfiguration;
+import org.eclipse.dltk.ui.text.ScriptTextTools;
+import org.eclipse.dltk.ui.viewsupport.ScriptUILabelProvider;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+public class RutaUILanguageToolkit extends AbstractDLTKUILanguageToolkit {
+
+ private static RutaUILanguageToolkit toolkit = null;
+
+ public static IDLTKUILanguageToolkit getInstance() {
+ if (toolkit == null) {
+ toolkit = new RutaUILanguageToolkit();
+ }
+ return toolkit;
+ }
+
+ private static ScriptElementLabels sInstance = new ScriptElementLabels() {
+ @Override
+ protected void getScriptFolderLabel(IScriptFolder folder, StringBuffer buf) {
+ String name = folder.getElementName();
+ name = name.replace(IScriptFolder.PACKAGE_DELIMITER, '.');
+ buf.append(name);
+ }
+
+ @Override
+ protected void getFieldLabel(IField field, long flags, StringBuffer buf) {
+ super.getFieldLabel(field, flags, buf);
+ int i = RutaParseUtils.getTypeOfIModelElement(field);
+ String type = RutaTypeConstants.typeStringOfInt.get(i);
+ if (type != null) {
+ type = type.toLowerCase();
+ buf.append(" : ");
+ buf.append(type);
+ }
+ }
+ };
+
+ @Override
+ public ScriptElementLabels getScriptElementLabels() {
+ return sInstance;
+ }
+
+ public IPreferenceStore getPreferenceStore() {
+ return RutaIdeUIPlugin.getDefault().getPreferenceStore();
+ }
+
+ public IDLTKLanguageToolkit getCoreToolkit() {
+ return RutaLanguageToolkit.getDefault();
+ }
+
+ public IDialogSettings getDialogSettings() {
+ return RutaIdeUIPlugin.getDefault().getDialogSettings();
+ }
+
+ @Override
+ public String getPartitioningId() {
+ return RutaConstants.RUTA_PARTITIONING;
+ }
+
+ @Override
+ public String getEditorId(Object inputElement) {
+ return RutaEditor.EDITOR_ID;
+ }
+
+ @Override
+ public String getInterpreterContainerId() {
+ return "org.apache.uima.ruta.ide.launching.INTERPRETER_CONTAINER";
+ }
+
+ @Override
+ public ScriptUILabelProvider createScriptUILabelProvider() {
+ return null;
+ }
+
+ @Override
+ public boolean getProvideMembers(ISourceModule element) {
+ return true;
+ }
+
+ @Override
+ public ScriptTextTools getTextTools() {
+ return RutaIdeUIPlugin.getDefault().getTextTools();
+ }
+
+ @Override
+ public ScriptSourceViewerConfiguration createSourceViewerConfiguration() {
+ return new SimpleRutaSourceViewerConfiguration(getTextTools().getColorManager(),
+ getPreferenceStore(), null, getPartitioningId(), false);
+ }
+
+ private static final String INTERPRETERS_PREFERENCE_PAGE_ID = "org.apache.uima.ruta.ide.preferences.interpreters";
+
+ private static final String DEBUG_PREFERENCE_PAGE_ID = "org.apache.uima.ruta.ide.preferences.debug";
+
+ @Override
+ public String getInterpreterPreferencePage() {
+ return INTERPRETERS_PREFERENCE_PAGE_ID;
+ }
+
+ @Override
+ public String getDebugPreferencePage() {
+ return DEBUG_PREFERENCE_PAGE_ID;
+ }
+
+ private static final String[] EDITOR_PREFERENCE_PAGES_IDS = {
+ "org.apache.uima.ruta.ide.preferences.editor",
+ "org.apache.uima.ruta.ide.ui.editor.SyntaxColoring",
+ "org.apache.uima.ruta.ide.ui.editor.SmartTyping",
+ "org.apache.uima.ruta.ide.ui.editor.RutaFolding" };
+
+ @Override
+ public String[] getEditorPreferencePages() {
+ return EDITOR_PREFERENCE_PAGES_IDS;
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaUIPreferenceInitializer.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaUIPreferenceInitializer.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaUIPreferenceInitializer.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/RutaUIPreferenceInitializer.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import org.apache.uima.ruta.ide.RutaIdeUIPlugin;
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.dltk.compiler.util.Util;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.ui.editors.text.EditorsUI;
+
+public class RutaUIPreferenceInitializer extends AbstractPreferenceInitializer {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences
+ * ()
+ */
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = RutaIdeUIPlugin.getDefault().getPreferenceStore();
+
+ EditorsUI.useAnnotationsPreferencePage(store);
+ EditorsUI.useQuickDiffPreferencePage(store);
+ RutaPreferenceConstants.initializeDefaultValues(store);
+ store.setDefault(RutaPreferenceConstants.FORMATTER_ID, Util.EMPTY_STRING);
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/OpenRutaSearchPageAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/OpenRutaSearchPageAction.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/OpenRutaSearchPageAction.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/OpenRutaSearchPageAction.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,64 @@
+/*
+ * 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.actions;
+
+import org.eclipse.dltk.ui.DLTKUIPlugin;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.search.ui.NewSearchUI;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+public class OpenRutaSearchPageAction implements IWorkbenchWindowActionDelegate {
+
+ private static final String RUTA_SEARCH_PAGE_ID = "org.apache.uima.ruta.ide.ui.RutaSearchPage";
+
+ private IWorkbenchWindow window;
+
+ public OpenRutaSearchPageAction() {
+ }
+
+ public void init(IWorkbenchWindow window) {
+ this.window = window;
+ }
+
+ public void run(IAction action) {
+ if (window == null || window.getActivePage() == null) {
+ beep();
+ return;
+ }
+
+ NewSearchUI.openSearchDialog(window, RUTA_SEARCH_PAGE_ID);
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+ public void dispose() {
+ window = null;
+ }
+
+ protected void beep() {
+ Shell shell = DLTKUIPlugin.getActiveWorkbenchShell();
+ if (shell != null && shell.getDisplay() != null)
+ shell.getDisplay().beep();
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaGenerateActionGroup.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaGenerateActionGroup.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaGenerateActionGroup.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaGenerateActionGroup.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.ui.actions;
+
+import org.apache.uima.ruta.ide.ui.editor.RutaEditor;
+import org.eclipse.dltk.internal.ui.editor.DLTKEditorMessages;
+import org.eclipse.dltk.ui.actions.DLTKActionConstants;
+import org.eclipse.dltk.ui.actions.GenerateActionGroup;
+import org.eclipse.dltk.ui.actions.IScriptEditorActionDefinitionIds;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.texteditor.TextOperationAction;
+
+public class RutaGenerateActionGroup extends GenerateActionGroup {
+ public RutaGenerateActionGroup(RutaEditor editor, String groupName) {
+ super(editor, groupName);
+ Action action = new TextOperationAction(DLTKEditorMessages.getBundleForConstructedKeys(),
+ "Format.", editor, ISourceViewer.FORMAT); //$NON-NLS-1$
+ action.setActionDefinitionId(IScriptEditorActionDefinitionIds.FORMAT);
+ editor.setAction(DLTKActionConstants.FORMAT, action);
+ editor.markAsStateDependentAction(DLTKActionConstants.FORMAT, true);
+ editor.markAsSelectionDependentAction(DLTKActionConstants.FORMAT, true);
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaOpenTypeAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaOpenTypeAction.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaOpenTypeAction.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaOpenTypeAction.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,31 @@
+/*
+ * 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.actions;
+
+import org.apache.uima.ruta.ide.ui.RutaUILanguageToolkit;
+import org.eclipse.dltk.ui.IDLTKUILanguageToolkit;
+import org.eclipse.dltk.ui.actions.OpenTypeAction;
+
+public class RutaOpenTypeAction extends OpenTypeAction {
+ @Override
+ protected IDLTKUILanguageToolkit getUILanguageToolkit() {
+ return RutaUILanguageToolkit.getInstance();
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaOpenTypeInHierarchyAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaOpenTypeInHierarchyAction.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaOpenTypeInHierarchyAction.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaOpenTypeInHierarchyAction.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,31 @@
+/*
+ * 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.actions;
+
+import org.apache.uima.ruta.ide.ui.RutaUILanguageToolkit;
+import org.eclipse.dltk.ui.IDLTKUILanguageToolkit;
+import org.eclipse.dltk.ui.actions.OpenTypeInHierarchyAction;
+
+public class RutaOpenTypeInHierarchyAction extends OpenTypeInHierarchyAction {
+ @Override
+ protected IDLTKUILanguageToolkit getLanguageToolkit() {
+ return RutaUILanguageToolkit.getInstance();
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaSelectAnnotationRulerAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaSelectAnnotationRulerAction.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaSelectAnnotationRulerAction.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaSelectAnnotationRulerAction.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,195 @@
+/*
+ * 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.actions;
+
+import java.util.Iterator;
+import java.util.ResourceBundle;
+
+import org.apache.uima.ruta.ide.RutaIdeUIPlugin;
+import org.apache.uima.ruta.ide.ui.text.RutaCorrectionProcessor;
+import org.eclipse.dltk.ui.PreferenceConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationAccessExtension;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
+import org.eclipse.ui.texteditor.AnnotationPreference;
+import org.eclipse.ui.texteditor.AnnotationPreferenceLookup;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorExtension;
+import org.eclipse.ui.texteditor.SelectMarkerRulerAction;
+
+public class RutaSelectAnnotationRulerAction extends SelectMarkerRulerAction {
+
+ private ITextEditor fTextEditor;
+
+ private Position fPosition;
+
+ private Annotation fAnnotation;
+
+ private AnnotationPreferenceLookup fAnnotationPreferenceLookup;
+
+ private IPreferenceStore fStore;
+
+ private boolean fHasCorrection;
+
+ private ResourceBundle fBundle;
+
+ public RutaSelectAnnotationRulerAction(ResourceBundle bundle, String prefix, ITextEditor editor,
+ IVerticalRulerInfo ruler) {
+ super(bundle, prefix, editor, ruler);
+ fBundle = bundle;
+ fTextEditor = editor;
+
+ fAnnotationPreferenceLookup = EditorsUI.getAnnotationPreferenceLookup();
+ fStore = RutaIdeUIPlugin.getDefault().getPreferenceStore();
+
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
+ // IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION);
+ }
+
+ @Override
+ public void run() {
+ if (fStore.getBoolean(PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER))
+ return;
+
+ runWithEvent(null);
+ }
+
+ /*
+ * @see org.eclipse.jface.action.IAction#runWithEvent(org.eclipse.swt.widgets.Event)
+ *
+ * @since 3.2
+ */
+ @Override
+ public void runWithEvent(Event event) {
+ // if (fAnnotation instanceof
+ // OverrideIndicatorManager.OverrideIndicator) {
+ // ((OverrideIndicatorManager.OverrideIndicator)fAnnotation).open();
+ // return;
+ // }
+
+ if (fHasCorrection) {
+ ITextOperationTarget operation = (ITextOperationTarget) fTextEditor
+ .getAdapter(ITextOperationTarget.class);
+ final int opCode = ISourceViewer.QUICK_ASSIST;
+ if (operation != null && operation.canDoOperation(opCode)) {
+ fTextEditor.selectAndReveal(fPosition.getOffset(), fPosition.getLength());
+ operation.doOperation(opCode);
+ }
+ return;
+ }
+
+ super.run();
+ }
+
+ @Override
+ public void update() {
+ findJavaAnnotation();
+ setEnabled(true); // super.update() might change this later
+
+ // if (fAnnotation instanceof
+ // OverrideIndicatorManager.OverrideIndicator) {
+ // initialize(fBundle,
+ // "JavaSelectAnnotationRulerAction.OpenSuperImplementation.");
+ // //$NON-NLS-1$
+ // return;
+ // }
+ if (fHasCorrection) {
+ // if (fAnnotation instanceof AssistAnnotation)
+ // initialize(fBundle,
+ // "JavaSelectAnnotationRulerAction.QuickAssist."); //$NON-NLS-1$
+ // else
+ initialize(fBundle, "JavaSelectAnnotationRulerAction.QuickFix."); //$NON-NLS-1$
+ return;
+ }
+
+ initialize(fBundle, "JavaSelectAnnotationRulerAction.GotoAnnotation."); //$NON-NLS-1$;
+ super.update();
+ }
+
+ private void findJavaAnnotation() {
+ fPosition = null;
+ fAnnotation = null;
+ fHasCorrection = false;
+
+ AbstractMarkerAnnotationModel model = getAnnotationModel();
+ IAnnotationAccessExtension annotationAccess = getAnnotationAccessExtension();
+
+ IDocument document = getDocument();
+ if (model == null)
+ return;
+
+ boolean hasAssistLightbulb = false;
+ // fStore.getBoolean(RutaPreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB);
+
+ Iterator iter = model.getAnnotationIterator();
+ int layer = Integer.MIN_VALUE;
+
+ while (iter.hasNext()) {
+ Annotation annotation = (Annotation) iter.next();
+ if (annotation.isMarkedDeleted())
+ continue;
+
+ int annotationLayer = layer;
+ if (annotationAccess != null) {
+ annotationLayer = annotationAccess.getLayer(annotation);
+ if (annotationLayer < layer)
+ continue;
+ }
+
+ Position position = model.getPosition(annotation);
+ if (!includesRulerLine(position, document))
+ continue;
+
+ boolean isReadOnly = fTextEditor instanceof ITextEditorExtension
+ && ((ITextEditorExtension) fTextEditor).isEditorInputReadOnly();
+ if (!isReadOnly && ((RutaCorrectionProcessor.hasCorrections(annotation)))) {
+ fPosition = position;
+ fAnnotation = annotation;
+ fHasCorrection = true;
+ layer = annotationLayer;
+ continue;
+ } else {
+ AnnotationPreference preference = fAnnotationPreferenceLookup
+ .getAnnotationPreference(annotation);
+ if (preference == null)
+ continue;
+
+ String key = preference.getVerticalRulerPreferenceKey();
+ if (key == null)
+ continue;
+
+ if (fStore.getBoolean(key)) {
+ fPosition = position;
+ fAnnotation = annotation;
+ fHasCorrection = false;
+ layer = annotationLayer;
+ }
+ }
+ }
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaSelectRulerAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaSelectRulerAction.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaSelectRulerAction.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/actions/RutaSelectRulerAction.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.ui.actions;
+
+import org.eclipse.dltk.internal.ui.editor.DLTKEditorMessages;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.ui.texteditor.AbstractRulerActionDelegate;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+public class RutaSelectRulerAction extends AbstractRulerActionDelegate {
+
+ @Override
+ protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) {
+ return new RutaSelectAnnotationRulerAction(DLTKEditorMessages.getBundleForConstructedKeys(),
+ "SelectAnnotationRulerAction.", editor, rulerInfo); //$NON-NLS-1$
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/ConsoleMessages.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/ConsoleMessages.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/ConsoleMessages.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/ConsoleMessages.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,54 @@
+/*
+ * 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 org.eclipse.osgi.util.NLS;
+
+public class ConsoleMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.apache.uima.ruta.ide.debug.ui.console.ConsoleMessages";
+
+ public static String RutaFileHyperlink_Information_1;
+
+ public static String RutaFileHyperlink_Error;
+
+ public static String ScriptStackTraceConsoleFactory_0;
+
+ public static String ScriptStackTraceConsole_0;
+
+ public static String RutaFileHyperlink_Source_not_found_for__0__2;
+
+ public static String RutaFileHyperlink_An_exception_occurred_while_following_link__3;
+
+ public static String RutaFileHyperlink_Unable_to_parse_type_name_from_hyperlink__5;
+
+ public static String RutaFileHyperlink_Unable_to_parse_line_number_from_hyperlink__6;
+
+ public static String RutaFileHyperlink_Unable_to_parse_line_number_from_hyperlink__7;
+
+ public static String RutaFileHyperlink_Unable_to_retrieve_hyperlink_text__8;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, ConsoleMessages.class);
+ }
+
+ public static String RutaFileHyperlink_0;
+
+ public static String RutaFileHyperlink_1;
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/PasteRutaTextToConsoleAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/PasteRutaTextToConsoleAction.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/PasteRutaTextToConsoleAction.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/PasteRutaTextToConsoleAction.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,70 @@
+/*
+ * 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 org.eclipse.dltk.console.ui.IScriptConsole;
+import org.eclipse.dltk.console.ui.ScriptConsoleManager;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+public class PasteRutaTextToConsoleAction implements IEditorActionDelegate {
+
+ private ISelection selection;
+
+ private IEditorPart targetEditor;
+
+ protected IDocument getDocument() {
+ if (!(targetEditor instanceof ITextEditor))
+ return null;
+
+ ITextEditor editor = (ITextEditor) targetEditor;
+ IDocumentProvider dp = editor.getDocumentProvider();
+ return dp.getDocument(editor.getEditorInput());
+ }
+
+ public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+ this.targetEditor = targetEditor;
+ }
+
+ public void run(IAction action) {
+ ScriptConsoleManager manager = ScriptConsoleManager.getInstance();
+
+ IScriptConsole console = manager.getActiveScriptConsole(RutaConsole.CONSOLE_TYPE);
+
+ if (console == null) {
+ return;
+ }
+
+ if (selection instanceof ITextSelection) {
+ String text = ((ITextSelection) selection).getText();
+ console.insertText(text);
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ this.selection = selection;
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/PasteRutaToConsole.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/PasteRutaToConsole.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/PasteRutaToConsole.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/PasteRutaToConsole.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,42 @@
+/*
+ * 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 org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class PasteRutaToConsole implements IObjectActionDelegate {
+
+ private ISelection selection;
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+
+ }
+
+ public void run(IAction action) {
+ // TODO: implement
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ this.selection = selection;
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsole.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsole.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsole.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsole.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.ui.console;
+
+import org.eclipse.dltk.console.ui.ScriptConsole;
+
+public class RutaConsole extends ScriptConsole {
+ public static final String CONSOLE_TYPE = "ruta_console";
+
+ public static final String CONSOLE_NAME = "Ruta Console";
+
+ public RutaConsole(RutaInterpreter interpreter, String id) {
+ super(CONSOLE_NAME + " [" + id + "]", CONSOLE_TYPE);
+
+ setInterpreter(interpreter);
+ setTextHover(new RutaConsoleTextHover(interpreter));
+ setContentAssistProcessor(new RutaConsoleCompletionProcessor(interpreter));
+
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleCompletionProcessor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleCompletionProcessor.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleCompletionProcessor.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleCompletionProcessor.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,122 @@
+/*
+ * 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.util.List;
+
+import org.eclipse.dltk.console.IScriptConsoleShell;
+import org.eclipse.dltk.console.ScriptConsoleCompletionProposal;
+import org.eclipse.dltk.console.ui.IScriptConsoleViewer;
+import org.eclipse.dltk.console.ui.ScriptConsoleCompletionProcessor;
+import org.eclipse.dltk.ui.DLTKPluginImages;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.eclipse.swt.graphics.Image;
+
+public class RutaConsoleCompletionProcessor extends ScriptConsoleCompletionProcessor {
+
+ protected static class Validator implements IContextInformationValidator,
+ IContextInformationPresenter {
+
+ protected int installOffset;
+
+ public boolean isContextInformationValid(int offset) {
+ return Math.abs(installOffset - offset) < 5;
+ }
+
+ public void install(IContextInformation info, ITextViewer viewer, int offset) {
+ installOffset = offset;
+ }
+
+ public boolean updatePresentation(int documentPosition, TextPresentation presentation) {
+ return false;
+ }
+ }
+
+ protected IProposalDecorator tmDecorator = new IProposalDecorator() {
+ public String formatProposal(ScriptConsoleCompletionProposal c) {
+ return c.getDisplay();
+ }
+
+ public Image getImage(ScriptConsoleCompletionProposal c) {
+ String type = c.getType();
+ if (type.equals("var")) {
+ return DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_LOCAL_VARIABLE);
+ } else if (type.equals("proc")) {
+ return DLTKPluginImages.get(DLTKPluginImages.IMG_METHOD_PUBLIC);
+ } else if (type.equals("command")) {
+ return DLTKPluginImages.get(DLTKPluginImages.IMG_METHOD_PRIVATE);
+ } else if (type.equals("func")) {
+ return DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_FIELD);
+ }
+
+ return null;
+ }
+ };
+
+ private IContextInformationValidator validator;
+
+ public RutaConsoleCompletionProcessor(IScriptConsoleShell interpreterShell) {
+ super(interpreterShell);
+ }
+
+ @Override
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ return new char[] { '$' };
+ }
+
+ @Override
+ protected ICompletionProposal[] computeCompletionProposalsImpl(IScriptConsoleViewer viewer,
+ int offset) {
+
+ try {
+ String commandLine = viewer.getCommandLine();
+ int cursorPosition = offset - viewer.getCommandLineOffset();
+
+ List list = getInterpreterShell().getCompletions(commandLine, cursorPosition);
+
+ List proposals = createProposalsFromString(list, offset, tmDecorator);
+
+ return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return new ICompletionProposal[] {};
+ }
+
+ @Override
+ protected IContextInformation[] computeContextInformationImpl(ITextViewer viewer, int offset) {
+ return null;
+ }
+
+ public IContextInformationValidator getContextInformationValidator() {
+ if (validator == null) {
+ validator = new Validator();
+ }
+
+ return validator;
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleConstants.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleConstants.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleConstants.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleConstants.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+public final class RutaConsoleConstants {
+ private RutaConsoleConstants() {
+ }
+
+ public static final String PREF_NEW_PROMPT = "tmconsole.new_invitation";
+
+ public static final String PREF_CONTINUE_PROMPT = "tmconsole.continue_invitation";
+
+ public static final String DEFAULT_NEW_PROMPT = "=>";
+
+ public static final String DEFAULT_CONTINUE_PROMPT = "->";
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleFactory.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleFactory.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleFactory.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.ui.console;
+
+import org.apache.uima.ruta.ide.RutaIdeUIPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.dltk.console.IScriptInterpreter;
+import org.eclipse.dltk.console.ScriptConsolePrompt;
+import org.eclipse.dltk.console.ui.IScriptConsole;
+import org.eclipse.dltk.console.ui.IScriptConsoleFactory;
+import org.eclipse.dltk.console.ui.ScriptConsole;
+import org.eclipse.dltk.console.ui.ScriptConsoleFactoryBase;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+public class RutaConsoleFactory extends ScriptConsoleFactoryBase implements IScriptConsoleFactory {
+ protected IPreferenceStore getPreferenceStore() {
+ return RutaIdeUIPlugin.getDefault().getPreferenceStore();
+ }
+
+ protected ScriptConsolePrompt makeInvitation() {
+ IPreferenceStore store = getPreferenceStore();
+ return new ScriptConsolePrompt(store.getString(RutaConsoleConstants.PREF_NEW_PROMPT),
+ store.getString(RutaConsoleConstants.PREF_CONTINUE_PROMPT));
+ }
+
+ protected RutaConsole makeConsole(RutaInterpreter interpreter, String id) {
+ RutaConsole console = new RutaConsole(interpreter, id);
+ console.setPrompt(makeInvitation());
+ return console;
+ }
+
+ private RutaConsole createConsoleInstance(IScriptInterpreter interpreter, String id) {
+ if (interpreter == null) {
+ try {
+ id = "default";
+ interpreter = new RutaInterpreter();
+ // RutaConsoleUtil.runDefaultRutaInterpreter((RutaInterpreter)
+ // interpreter);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ return makeConsole((RutaInterpreter) interpreter, id);
+ }
+
+ @Override
+ protected ScriptConsole createConsoleInstance() {
+ return createConsoleInstance(null, null);
+ }
+
+ public RutaConsoleFactory() {
+ super();
+ }
+
+ public void openConsole(IScriptInterpreter interpreter, String id) {
+ registerAndOpenConsole(createConsoleInstance(interpreter, id));
+ }
+
+ public IScriptConsole openConsole(IScriptInterpreter interpreter, String id, ILaunch launch) {
+ RutaConsole tmConsole = createConsoleInstance(interpreter, id);
+ tmConsole.setLaunch(launch);
+ registerAndOpenConsole(tmConsole);
+ return tmConsole;
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleTextHover.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleTextHover.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleTextHover.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleTextHover.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,51 @@
+/*
+ * 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 org.eclipse.dltk.console.IScriptConsoleShell;
+import org.eclipse.dltk.console.ui.IScriptConsoleViewer;
+import org.eclipse.dltk.console.ui.ScriptConsoleTextHover;
+import org.eclipse.jface.text.IRegion;
+
+public class RutaConsoleTextHover extends ScriptConsoleTextHover {
+
+ private IScriptConsoleShell interpreterShell;
+
+ public RutaConsoleTextHover(IScriptConsoleShell interpreterShell) {
+ this.interpreterShell = interpreterShell;
+ }
+
+ @Override
+ protected String getHoverInfoImpl(IScriptConsoleViewer viewer, IRegion hoverRegion) {
+ try {
+ int cursorPosition = hoverRegion.getOffset() - viewer.getCommandLineOffset();
+
+ String commandLine = viewer.getCommandLine();
+
+ return interpreterShell.getDescription(commandLine, cursorPosition);
+ } catch (IOException e) {
+ // TODO: log exception
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleTracker.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleTracker.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleTracker.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleTracker.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,52 @@
+/*
+ * 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 org.eclipse.jface.text.BadLocationException;
+import org.eclipse.ui.console.IHyperlink;
+import org.eclipse.ui.console.IPatternMatchListenerDelegate;
+import org.eclipse.ui.console.PatternMatchEvent;
+import org.eclipse.ui.console.TextConsole;
+
+public class RutaConsoleTracker implements IPatternMatchListenerDelegate {
+ private TextConsole console;
+
+ public void connect(TextConsole console) {
+ this.console = console;
+ }
+
+ public void disconnect() {
+ console = null;
+ }
+
+ protected TextConsole getConsole() {
+ return console;
+ }
+
+ public void matchFound(PatternMatchEvent event) {
+ try {
+ int offset = event.getOffset();
+ int length = event.getLength();
+ IHyperlink link = new RutaFileHyperlink(console);
+ console.addHyperlink(link, offset + 1, length - 2);
+ } catch (BadLocationException e) {
+ }
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleUtil.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleUtil.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleUtil.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaConsoleUtil.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,49 @@
+/*
+ * 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 org.apache.uima.ruta.ide.RutaIdeUIPlugin;
+import org.apache.uima.ruta.ide.core.RutaNature;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.dltk.console.ScriptConsoleServer;
+import org.eclipse.dltk.core.environment.EnvironmentManager;
+import org.eclipse.dltk.core.environment.IExecutionEnvironment;
+import org.eclipse.dltk.core.environment.IFileHandle;
+import org.eclipse.dltk.launching.ScriptLaunchUtil;
+
+public class RutaConsoleUtil {
+
+ public static void runDefaultRutaInterpreter(RutaInterpreter interpreter) throws CoreException,
+ IOException {
+ ScriptConsoleServer server = ScriptConsoleServer.getInstance();
+
+ String id = server.register(interpreter);
+ String port = Integer.toString(server.getPort());
+
+ String[] args = new String[] { "127.0.0.1", port, id };
+
+ IExecutionEnvironment exeEnv = (IExecutionEnvironment) EnvironmentManager.getLocalEnvironment()
+ .getAdapter(IExecutionEnvironment.class);
+ IFileHandle scriptFile = RutaIdeUIPlugin.getDefault().getConsoleProxy(exeEnv);
+ ScriptLaunchUtil.runScript(RutaNature.NATURE_ID, scriptFile, null, null, args, null);
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/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-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaFileHyperlink.java?rev=1504047&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaFileHyperlink.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/console/RutaFileHyperlink.java Wed Jul 17 08:28:02 2013
@@ -0,0 +1,222 @@
+/*
+ * 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);
+ }
+ }
+
+}