|
From: <caw...@us...> - 2007-09-07 19:46:30
|
Revision: 3113
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3113&view=rev
Author: cawilliams
Date: 2007-09-07 12:46:20 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
add spelling check in ruby comments!
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.properties
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyAnnotation.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyDocumentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyReconciler.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ProblemLocation.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/icons/full/obj16/add_correction.gif
trunk/org.rubypeople.rdt.ui/icons/full/obj16/correction_rename.gif
trunk/org.rubypeople.rdt.ui/icons/full/obj16/never_translate.gif
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingConfigurationBlock.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingPreferenceBlock.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/CompositeReconcilingStrategy.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyCompositeReconcilingStrategy.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/AddWordProposal.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/ChangeCaseProposal.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/CoreSpellingProblem.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/DefaultSpellingEngine.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/RubySpellingEngine.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/RubySpellingProblem.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/RubySpellingReconcileStrategy.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/SpellCheckEngine.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/SpellCheckIterator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/SpellReconcileDictionary.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/SpellingEngine.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/TaskTagDictionary.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/TextSpellingEngine.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/WordCorrectionProposal.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/WordIgnoreProposal.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/WordQuickFixProcessor.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/IPhoneticDistanceAlgorithm.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/IPhoneticHashProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellCheckPreferenceKeys.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellChecker.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellDictionary.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellEvent.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellEventListener.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/RankedWordProposal.java
Added: trunk/org.rubypeople.rdt.ui/icons/full/obj16/add_correction.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/obj16/add_correction.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/obj16/correction_rename.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/obj16/correction_rename.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/obj16/never_translate.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/obj16/never_translate.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.ui/plugin.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.properties 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/plugin.properties 2007-09-07 19:46:20 UTC (rev 3113)
@@ -7,9 +7,12 @@
providerName=RubyPeople, Inc.
hyperlinkProvider=Hyperlink provider
-
callHierarchyViewName=Call Hierarchy
+#--- Spelling
+defaultSpellingEngine.label= Ruby spelling engine
+spellingQuickFixProcessor=Spelling Quick Fix Processor
+
# Browsing
Browsing.perspectiveName= Ruby Browsing
Browsing.viewCategoryName= Ruby Browsing
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-07 19:46:20 UTC (rev 3113)
@@ -1533,5 +1533,24 @@
class="org.rubypeople.rdt.internal.ui.text.correction.QuickFixProcessor"
id="org.rubypeople.rdt.ui.quickFixProcessor"
name="Default Quick Fix Processor"/>
+ <quickFixProcessor
+ name="%spellingQuickFixProcessor"
+ class="org.rubypeople.rdt.internal.ui.text.spelling.WordQuickFixProcessor"
+ id= "org.rubypeople.rdt.ui.text.correction.spelling.QuickFixProcessor">
+ <handledMarkerTypes>
+ <markerType id="org.rubypeople.rdt.internal.spelling"/>
+ </handledMarkerTypes>
+ </quickFixProcessor>
</extension>
+
+ <extension point="org.eclipse.ui.workbench.texteditor.spellingEngine">
+ <engine
+ preferencesClass="org.rubypeople.rdt.internal.ui.preferences.SpellingPreferenceBlock"
+ label="%defaultSpellingEngine.label"
+ class="org.rubypeople.rdt.internal.ui.text.spelling.DefaultSpellingEngine"
+ default="true"
+ id="org.rubypeople.rdt.internal.ui.text.spelling.DefaultSpellingEngine">
+ </engine>
+ </extension>
+
</plugin>
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -90,9 +90,7 @@
private static final String IMG_CTOOLS_RUBY_CONSTANT = NAME_PREFIX + "ruby_constant.gif";
public static final String IMG_OBJS_FIXABLE_PROBLEM= NAME_PREFIX + "quickfix_warning_obj.gif"; //$NON-NLS-1$
- private static final String IMG_OBJS_FIXABLE_ERROR= NAME_PREFIX + "quickfix_error_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_CORRECTION_CHANGE= NAME_PREFIX + "correction_change.gif"; //$NON-NLS-1$
+ private static final String IMG_OBJS_FIXABLE_ERROR= NAME_PREFIX + "quickfix_error_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_NEWJPRJ = createUnManaged(T_WIZBAN, "newrprj_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_NEWCLASS = createUnManaged(T_WIZBAN, "newclass_wiz.gif"); //$NON-NLS-1$
@@ -205,7 +203,16 @@
public static final ImageDescriptor DESC_TOOL_LOADPATH_ORDER= createUnManaged(T_OBJ, "cp_order_obj.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_TOOL_OPENTYPE= createUnManaged(T_ETOOL, "opentype.gif"); //$NON-NLS-1$
+ public static final String IMG_CORRECTION_RENAME= NAME_PREFIX + "correction_rename.gif"; //$NON-NLS-1$
+ public static final String IMG_CORRECTION_ADD= NAME_PREFIX + "add_correction.gif"; //$NON-NLS-1$
+ public static final String IMG_CORRECTION_CHANGE= NAME_PREFIX + "correction_change.gif"; //$NON-NLS-1$
+
+ public static final String IMG_OBJS_NLS_NEVER_TRANSLATE= NAME_PREFIX + "never_translate.gif"; //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OBJS_NLS_NEVER_TRANSLATE= createManagedFromKey(T_OBJ, IMG_OBJS_NLS_NEVER_TRANSLATE);
+
static {
+ createManagedFromKey(T_OBJ, IMG_CORRECTION_RENAME);
+ createManagedFromKey(T_OBJ, IMG_CORRECTION_ADD);
createManagedFromKey(T_OBJ, IMG_CORRECTION_CHANGE);
createManagedFromKey(T_OBJ, IMG_OBJS_FIXABLE_ERROR);
createManagedFromKey(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -94,8 +94,17 @@
public static String OpenTypeHierarchyUtil_error_open_perspective;
public static String OpenTypeHierarchyUtil_error_open_editor;
public static String OpenTypeHierarchyUtil_error_open_view;
-
public static String RubyUI_defaultDialogMessage;
+ public static String Spelling_error_case_label;
+ public static String Spelling_error_label;
+ public static String AbstractSpellingDictionary_encodingError;
+ public static String Spelling_dictionary_file_extension;
+ public static String Spelling_correct_label;
+ public static String Spelling_case_label;
+ public static String Spelling_add_info;
+ public static String Spelling_add_label;
+ public static String Spelling_ignore_info;
+ public static String Spelling_ignore_label;
private RubyUIMessages() {
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-09-07 19:46:20 UTC (rev 3113)
@@ -155,4 +155,19 @@
CoreUtility_buildall_taskname=Build all...
CoreUtility_buildproject_taskname=Build project ''{0}''...
-RubyElementLabels_default_package=(default)
\ No newline at end of file
+RubyElementLabels_default_package=(default)
+
+#########
+# Spelling
+#########
+
+Spelling_dictionary_file_extension=dictionary
+Spelling_error_label=The word ''{0}'' is not correctly spelled
+Spelling_correct_label=Change to ''{0}''
+Spelling_add_info=Adds the word ''{0}'' to the dictionary
+Spelling_add_label=Add ''{0}'' to dictionary
+Spelling_ignore_info=Always ignores ''{0}'' during the current session
+Spelling_ignore_label=Always ignore ''{0}''
+Spelling_case_label=Change to upper case
+Spelling_error_case_label= The word ''{0}'' should have an initial upper case letter
+AbstractSpellingDictionary_encodingError= Could not read: ''{0}'', where the bad characters are replaced by ''{1}''. Check the encoding of the spelling dictionary ({2}).
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -192,6 +192,28 @@
public static String KeywordInputDialog_error_entryExists;
public static String KeywordInputDialog_error_noSpace;
public static String RubyEditorPreferencePage_enableHovers;
+ public static String SpellingPreferencePage_dictionary_error;
+ public static String SpellingPreferencePage_locale_error;
+ public static String SpellingPreferencePage_empty_threshold;
+ public static String SpellingPreferencePage_invalid_threshold;
+ public static String SpellingPreferencePage_preferences_user;
+ public static String SpellingPreferencePage_ignore_digits_label;
+ public static String SpellingPreferencePage_ignore_mixed_label;
+ public static String SpellingPreferencePage_ignore_sentence_label;
+ public static String SpellingPreferencePage_ignore_upper_label;
+ public static String SpellingPreferencePage_ignore_url_label;
+ public static String SpellingPreferencePage_preferences_engine;
+ public static String SpellingPreferencePage_dictionary_label;
+ public static String SpellingPreferencePage_workspace_dictionary_label;
+ public static String SpellingPreferencePage_browse_label;
+ public static String SpellingPreferencePage_preferences_advanced;
+ public static String SpellingPreferencePage_proposals_threshold;
+ public static String SpellingPreferencePage_enable_contentassist_label;
+ public static String SpellingPreferencePage_filedialog_title;
+ public static String SpellingPreferencePage_filter_dictionary_extension;
+ public static String SpellingPreferencePage_filter_all_extension;
+ public static String SpellingPreferencePage_filter_dictionary_label;
+ public static String SpellingPreferencePage_filter_all_label;
static {
NLS.initializeMessages(BUNDLE_NAME, PreferencesMessages.class);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-09-07 19:46:20 UTC (rev 3113)
@@ -220,4 +220,27 @@
BuildPathsPropertyPage_unsavedchanges_button_discard=Discard
BuildPathsPropertyPage_unsavedchanges_button_ignore=Apply Later
-RubyBuildConfigurationBlock_invalid_input={0} is not a valid number of problems.
\ No newline at end of file
+RubyBuildConfigurationBlock_invalid_input={0} is not a valid number of problems.
+
+SpellingPreferencePage_empty_threshold= A maximum number of correction proposals must be specified.
+SpellingPreferencePage_invalid_threshold=''{0}'' is not a valid maximum number of correction proposals.
+SpellingPreferencePage_ignore_digits_label=Ignore &words with digits
+SpellingPreferencePage_ignore_mixed_label=Ignore &mixed case words
+SpellingPreferencePage_ignore_sentence_label=Ignore &sentence capitalization
+SpellingPreferencePage_ignore_upper_label=Ignore u&pper case words
+SpellingPreferencePage_ignore_url_label=Ignore &internet addresses
+SpellingPreferencePage_proposals_threshold= Maximum &number of correction proposals:
+SpellingPreferencePage_dictionary_label=Plat&form dictionary:
+SpellingPreferencePage_workspace_dictionary_label=&User defined dictionary:
+SpellingPreferencePage_browse_label=&Browse...
+SpellingPreferencePage_dictionary_error=The dictionary file must be read/write accessible.
+SpellingPreferencePage_locale_error=There is no dictionary available for this language.
+SpellingPreferencePage_filedialog_title=Select dictionary
+SpellingPreferencePage_filter_dictionary_extension=*.dictionary
+SpellingPreferencePage_filter_all_extension=*.*
+SpellingPreferencePage_filter_dictionary_label=Dictionary Files
+SpellingPreferencePage_filter_all_label=All Files
+SpellingPreferencePage_enable_contentassist_label=Ma&ke dictionary available to content assist
+SpellingPreferencePage_preferences_user=&Options
+SpellingPreferencePage_preferences_engine=&Language
+SpellingPreferencePage_preferences_advanced=Ad&vanced
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingConfigurationBlock.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingConfigurationBlock.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingConfigurationBlock.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -0,0 +1,446 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.ui.preferences;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+import org.rubypeople.rdt.internal.corext.util.Messages;
+import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo;
+import org.rubypeople.rdt.internal.ui.dialogs.StatusUtil;
+import org.rubypeople.rdt.internal.ui.text.spelling.SpellCheckEngine;
+import org.rubypeople.rdt.internal.ui.util.PixelConverter;
+import org.rubypeople.rdt.internal.ui.util.SWTUtil;
+import org.rubypeople.rdt.internal.ui.wizards.IStatusChangeListener;
+import org.rubypeople.rdt.ui.PreferenceConstants;
+
+/**
+ * Options configuration block for spell-check related settings.
+ *
+ * @since 3.0
+ */
+public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
+
+ /** Preference keys for the preferences in this block */
+ private static final Key PREF_SPELLING_IGNORE_DIGITS= getRDTUIKey(PreferenceConstants.SPELLING_IGNORE_DIGITS);
+ private static final Key PREF_SPELLING_IGNORE_MIXED= getRDTUIKey(PreferenceConstants.SPELLING_IGNORE_MIXED);
+ private static final Key PREF_SPELLING_IGNORE_SENTENCE= getRDTUIKey(PreferenceConstants.SPELLING_IGNORE_SENTENCE);
+ private static final Key PREF_SPELLING_IGNORE_UPPER= getRDTUIKey(PreferenceConstants.SPELLING_IGNORE_UPPER);
+ private static final Key PREF_SPELLING_IGNORE_URLS= getRDTUIKey(PreferenceConstants.SPELLING_IGNORE_URLS);
+ private static final Key PREF_SPELLING_LOCALE= getRDTUIKey(PreferenceConstants.SPELLING_LOCALE);
+ private static final Key PREF_SPELLING_PROPOSAL_THRESHOLD= getRDTUIKey(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD);
+ private static final Key PREF_SPELLING_USER_DICTIONARY= getRDTUIKey(PreferenceConstants.SPELLING_USER_DICTIONARY);
+ private static final Key PREF_SPELLING_ENABLE_CONTENTASSIST= getRDTUIKey(PreferenceConstants.SPELLING_ENABLE_CONTENTASSIST);
+
+ /**
+ * Creates a selection dependency between a master and a slave control.
+ *
+ * @param master
+ * The master button that controls the state of the slave
+ * @param slave
+ * The slave control that is enabled only if the master is
+ * selected
+ */
+ protected static void createSelectionDependency(final Button master, final Control slave) {
+
+ master.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ // Do nothing
+ }
+
+ public void widgetSelected(SelectionEvent event) {
+ slave.setEnabled(master.getSelection());
+ }
+ });
+ slave.setEnabled(master.getSelection());
+ }
+
+ /**
+ * Returns the locale codes for the locale list.
+ *
+ * @param locales
+ * The list of locales
+ * @return Array of locale codes for the list
+ */
+ protected static String[] getDictionaryCodes(final Set locales) {
+
+ int index= 0;
+ Locale locale= null;
+
+ final String[] codes= new String[locales.size()];
+ for (final Iterator iterator= locales.iterator(); iterator.hasNext();) {
+
+ locale= (Locale)iterator.next();
+ codes[index++]= locale.toString();
+ }
+ return codes;
+ }
+
+ /**
+ * Returns the display labels for the locale list.
+ *
+ * @param locales
+ * The list of locales
+ * @return Array of display labels for the list
+ */
+ protected static String[] getDictionaryLabels(final Set locales) {
+
+ int index= 0;
+ Locale locale= null;
+
+ final String[] labels= new String[locales.size()];
+ for (final Iterator iterator= locales.iterator(); iterator.hasNext();) {
+
+ locale= (Locale)iterator.next();
+ labels[index++]= locale.getDisplayName();
+ }
+ return labels;
+ }
+
+ /**
+ * Validates that the file with the specified absolute path exists and can
+ * be opened.
+ *
+ * @param path
+ * The path of the file to validate
+ * @return <code>true</code> iff the file exists and can be opened,
+ * <code>false</code> otherwise
+ */
+ protected static IStatus validateAbsoluteFilePath(final String path) {
+
+ final StatusInfo status= new StatusInfo();
+ if (path.length() > 0) {
+
+ final File file= new File(path);
+ if (!file.isFile() || !file.isAbsolute() || !file.exists() || !file.canRead() || !file.canWrite())
+ status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error);
+
+ }
+ return status;
+ }
+
+ /**
+ * Validates that the specified locale is available.
+ *
+ * @param locale
+ * The locale to validate
+ * @return The status of the validation
+ */
+ protected static IStatus validateLocale(final String locale) {
+
+ final StatusInfo status= new StatusInfo(IStatus.ERROR, PreferencesMessages.SpellingPreferencePage_locale_error);
+ final Set locales= SpellCheckEngine.getAvailableLocales();
+
+ Locale current= null;
+ for (final Iterator iterator= locales.iterator(); iterator.hasNext();) {
+
+ current= (Locale)iterator.next();
+ if (current.toString().equals(locale))
+ return new StatusInfo();
+ }
+ return status;
+ }
+
+ /**
+ * Validates that the specified number is positive.
+ *
+ * @param number
+ * The number to validate
+ * @return The status of the validation
+ */
+ protected static IStatus validatePositiveNumber(final String number) {
+
+ final StatusInfo status= new StatusInfo();
+ if (number.length() == 0) {
+ status.setError(PreferencesMessages.SpellingPreferencePage_empty_threshold);
+ } else {
+ try {
+ final int value= Integer.parseInt(number);
+ if (value < 0) {
+ status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
+ }
+ } catch (NumberFormatException exception) {
+ status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
+ }
+ }
+ return status;
+ }
+
+ /** The dictionary path field */
+ private Text fDictionaryPath= null;
+
+ /** The status for the workspace dictionary file */
+ private IStatus fFileStatus= new StatusInfo();
+
+ /** The status for the proposal threshold */
+ private IStatus fThresholdStatus= new StatusInfo();
+
+ /**
+ * All controls
+ * @since 3.1
+ */
+ private Control[] fAllControls;
+
+ /**
+ * All previously enabled controls
+ * @since 3.1
+ */
+ private Control[] fEnabledControls;
+
+ /**
+ * Creates a new spelling configuration block.
+ *
+ * @param context
+ * The status change listener
+ * @param project
+ * The Java project
+ */
+ public SpellingConfigurationBlock(final IStatusChangeListener context, final IProject project, IWorkbenchPreferenceContainer container) {
+ super(context, project, getAllKeys(), container);
+
+ IStatus status= validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY));
+ if (status.getSeverity() != IStatus.OK)
+ setValue(PREF_SPELLING_USER_DICTIONARY, ""); //$NON-NLS-1$
+
+ status= validateLocale(getValue(PREF_SPELLING_LOCALE));
+ if (status.getSeverity() != IStatus.OK)
+ setValue(PREF_SPELLING_LOCALE, SpellCheckEngine.getDefaultLocale().toString());
+ }
+
+ protected Combo addComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) {
+ ControlData data= new ControlData(key, values);
+
+ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent= indent;
+
+ Label labelControl= new Label(parent, SWT.LEFT | SWT.WRAP);
+ labelControl.setText(label);
+ labelControl.setLayoutData(gd);
+
+ Combo comboBox= new Combo(parent, SWT.READ_ONLY);
+ comboBox.setItems(valueLabels);
+ comboBox.setData(data);
+ gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan= 2;
+ comboBox.setLayoutData(gd);
+ comboBox.addSelectionListener(getSelectionListener());
+
+ fLabels.put(comboBox, labelControl);
+
+ String currValue= getValue(key);
+ comboBox.select(data.getSelection(currValue));
+
+ fComboBoxes.add(comboBox);
+ return comboBox;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createContents(final Composite parent) {
+
+ Composite composite= new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+
+ List allControls= new ArrayList();
+ final PixelConverter converter= new PixelConverter(parent);
+
+ final String[] trueFalse= new String[] { IPreferenceStore.TRUE, IPreferenceStore.FALSE };
+
+ Group user= new Group(composite, SWT.NONE);
+ user.setText(PreferencesMessages.SpellingPreferencePage_preferences_user);
+ user.setLayout(new GridLayout());
+ user.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ allControls.add(user);
+
+ String label= PreferencesMessages.SpellingPreferencePage_ignore_digits_label;
+ Control slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_DIGITS, trueFalse, 0);
+ allControls.add(slave);
+
+ label= PreferencesMessages.SpellingPreferencePage_ignore_mixed_label;
+ slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_MIXED, trueFalse, 0);
+ allControls.add(slave);
+
+ label= PreferencesMessages.SpellingPreferencePage_ignore_sentence_label;
+ slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_SENTENCE, trueFalse, 0);
+ allControls.add(slave);
+
+ label= PreferencesMessages.SpellingPreferencePage_ignore_upper_label;
+ slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_UPPER, trueFalse, 0);
+ allControls.add(slave);
+
+ label= PreferencesMessages.SpellingPreferencePage_ignore_url_label;
+ slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_URLS, trueFalse, 0);
+ allControls.add(slave);
+
+ final Group engine= new Group(composite, SWT.NONE);
+ engine.setText(PreferencesMessages.SpellingPreferencePage_preferences_engine);
+ engine.setLayout(new GridLayout(4, false));
+ engine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ allControls.add(engine);
+
+ label= PreferencesMessages.SpellingPreferencePage_dictionary_label;
+ final Set locales= SpellCheckEngine.getAvailableLocales();
+
+ Combo combo= addComboBox(engine, label, PREF_SPELLING_LOCALE, getDictionaryCodes(locales), getDictionaryLabels(locales), 0);
+ combo.setEnabled(locales.size() > 1);
+ allControls.add(combo);
+ allControls.add(fLabels.get(combo));
+
+ new Label(engine, SWT.NONE); // placeholder
+
+ label= PreferencesMessages.SpellingPreferencePage_workspace_dictionary_label;
+ fDictionaryPath= addTextField(engine, label, PREF_SPELLING_USER_DICTIONARY, 0, 0);
+ GridData gd= (GridData) fDictionaryPath.getLayoutData();
+ gd.grabExcessHorizontalSpace= true;
+ gd.widthHint= converter.convertWidthInCharsToPixels(40);
+ allControls.add(fDictionaryPath);
+ allControls.add(fLabels.get(fDictionaryPath));
+
+
+ Button button= new Button(engine, SWT.PUSH);
+ button.setText(PreferencesMessages.SpellingPreferencePage_browse_label);
+ button.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(final SelectionEvent event) {
+ handleBrowseButtonSelected();
+ }
+ });
+ button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
+ SWTUtil.setButtonDimensionHint(button);
+ allControls.add(button);
+
+ Group advanced= new Group(composite, SWT.NONE);
+ advanced.setText(PreferencesMessages.SpellingPreferencePage_preferences_advanced);
+ advanced.setLayout(new GridLayout(3, false));
+ advanced.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ allControls.add(advanced);
+
+ label= PreferencesMessages.SpellingPreferencePage_proposals_threshold;
+ Text text= addTextField(advanced, label, PREF_SPELLING_PROPOSAL_THRESHOLD, 0, 0);
+ text.setTextLimit(3);
+ gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.widthHint= converter.convertWidthInCharsToPixels(4);
+ text.setLayoutData(gd);
+ allControls.add(text);
+ allControls.add(fLabels.get(text));
+
+ label= PreferencesMessages.SpellingPreferencePage_enable_contentassist_label;
+ button= addCheckBox(advanced, label, PREF_SPELLING_ENABLE_CONTENTASSIST, trueFalse, 0);
+ allControls.add(button);
+
+ fAllControls= (Control[]) allControls.toArray(new Control[allControls.size()]);
+
+// PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
+ return composite;
+ }
+
+ private static Key[] getAllKeys() {
+ return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_ENABLE_CONTENTASSIST };
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean)
+ */
+ protected final String[] getFullBuildDialogStrings(final boolean workspace) {
+ return null;
+ }
+
+ /**
+ * Handles selections of the browse button.
+ */
+ protected void handleBrowseButtonSelected() {
+
+ final FileDialog dialog= new FileDialog(fDictionaryPath.getShell(), SWT.OPEN);
+ dialog.setText(PreferencesMessages.SpellingPreferencePage_filedialog_title);
+ dialog.setFilterExtensions(new String[] { PreferencesMessages.SpellingPreferencePage_filter_dictionary_extension, PreferencesMessages.SpellingPreferencePage_filter_all_extension });
+ dialog.setFilterNames(new String[] { PreferencesMessages.SpellingPreferencePage_filter_dictionary_label, PreferencesMessages.SpellingPreferencePage_filter_all_label });
+
+ final String path= dialog.open();
+ if (path != null)
+ fDictionaryPath.setText(path);
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(java.lang.String,java.lang.String)
+ */
+ protected void validateSettings(final Key key, final String oldValue, final String newValue) {
+
+ if (key == null || PREF_SPELLING_PROPOSAL_THRESHOLD.equals(key))
+ fThresholdStatus= validatePositiveNumber(getValue(PREF_SPELLING_PROPOSAL_THRESHOLD));
+
+ if (key == null || PREF_SPELLING_USER_DICTIONARY.equals(key))
+ fFileStatus= validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY));
+
+ fContext.statusChanged(StatusUtil.getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus }));
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#updateCheckBox(org.eclipse.swt.widgets.Button)
+ * @since 3.1
+ */
+ protected void updateCheckBox(Button curr) {
+ super.updateCheckBox(curr);
+ Event event= new Event();
+ event.type= SWT.Selection;
+ event.display= curr.getDisplay();
+ event.widget= curr;
+ curr.notifyListeners(SWT.Selection, event);
+ }
+
+ /**
+ * @since 3.1
+ */
+ protected void setEnabled(boolean enabled) {
+ if (enabled && fEnabledControls != null) {
+ for (int i= fEnabledControls.length - 1; i >= 0; i--)
+ fEnabledControls[i].setEnabled(true);
+ fEnabledControls= null;
+ }
+ if (!enabled && fEnabledControls == null) {
+ List enabledControls= new ArrayList();
+ for (int i= fAllControls.length - 1; i >= 0; i--) {
+ Control control= fAllControls[i];
+ if (control.isEnabled()) {
+ enabledControls.add(control);
+ control.setEnabled(false);
+ }
+ }
+ fEnabledControls= (Control[]) enabledControls.toArray(new Control[enabledControls.size()]);
+ }
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingConfigurationBlock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingPreferenceBlock.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingPreferenceBlock.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingPreferenceBlock.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.texteditor.spelling.IPreferenceStatusMonitor;
+import org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock;
+import org.rubypeople.rdt.internal.ui.wizards.IStatusChangeListener;
+
+/**
+ * Spelling preference block
+ *
+ * @since 3.1
+ */
+public class SpellingPreferenceBlock implements ISpellingPreferenceBlock {
+
+ private class NullStatusChangeListener implements IStatusChangeListener {
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
+ */
+ public void statusChanged(IStatus status) {
+ }
+ }
+
+ private class StatusChangeListenerAdapter implements IStatusChangeListener {
+
+ private IPreferenceStatusMonitor fMonitor;
+
+ private IStatus fStatus;
+
+ public StatusChangeListenerAdapter(IPreferenceStatusMonitor monitor) {
+ super();
+ fMonitor= monitor;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
+ */
+ public void statusChanged(IStatus status) {
+ fStatus= status;
+ fMonitor.statusChanged(status);
+ }
+
+ public IStatus getStatus() {
+ return fStatus;
+ }
+ }
+
+ private SpellingConfigurationBlock fBlock= new SpellingConfigurationBlock(new NullStatusChangeListener(), null, null);
+
+ private SpellingPreferenceBlock.StatusChangeListenerAdapter fStatusMonitor;
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public Control createControl(Composite parent) {
+ return fBlock.createContents(parent);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#initialize(org.eclipse.ui.texteditor.spelling.IPreferenceStatusMonitor)
+ */
+ public void initialize(IPreferenceStatusMonitor statusMonitor) {
+ fStatusMonitor= new StatusChangeListenerAdapter(statusMonitor);
+ fBlock.fContext= fStatusMonitor;
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#canPerformOk()
+ */
+ public boolean canPerformOk() {
+ return fStatusMonitor == null || fStatusMonitor.getStatus() == null || !fStatusMonitor.getStatus().matches(IStatus.ERROR);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performOk()
+ */
+ public void performOk() {
+ fBlock.performOk();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performDefaults()
+ */
+ public void performDefaults() {
+ fBlock.performDefaults();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performRevert()
+ */
+ public void performRevert() {
+ fBlock.performRevert();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#dispose()
+ */
+ public void dispose() {
+ fBlock.dispose();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#setEnabled(boolean)
+ */
+ public void setEnabled(boolean enabled) {
+ fBlock.setEnabled(enabled);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingPreferenceBlock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyAnnotation.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyAnnotation.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyAnnotation.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -112,5 +112,13 @@
* <code>null<code> if no marker type can be evaluated.
*/
String getMarkerType();
+
+ /**
+ * Returns the problem arguments or <code>null</code> if no problem arguments can be evaluated.
+ *
+ * @return returns the problem arguments or <code>null</code> if no problem
+ * arguments can be evaluated.
+ */
+ String[] getArguments();
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyDocumentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyDocumentProvider.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyDocumentProvider.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -582,6 +582,13 @@
public String getText() {
return fProblem.getMessage();
}
+
+ /*
+ * @see IRubyAnnotation#getArguments()
+ */
+ public String[] getArguments() {
+ return isProblem() ? fProblem.getArguments() : null;
+ }
/*
* @see IRubyAnnotation#isProblem()
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/CompositeReconcilingStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/CompositeReconcilingStrategy.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/CompositeReconcilingStrategy.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.text;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.reconciler.DirtyRegion;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
+
+/**
+ * A reconciling strategy consisting of a sequence of internal reconciling strategies.
+ * By default, all requests are passed on to the contained strategies.
+ *
+ * @since 3.0
+ */
+public class CompositeReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
+
+ /** The list of internal reconciling strategies. */
+ private IReconcilingStrategy[] fStrategies;
+
+ /**
+ * Creates a new, empty composite reconciling strategy.
+ */
+ public CompositeReconcilingStrategy() {
+ }
+
+ /**
+ * Sets the reconciling strategies for this composite strategy.
+ *
+ * @param strategies the strategies to be set or <code>null</code>
+ */
+ public void setReconcilingStrategies(IReconcilingStrategy[] strategies) {
+ fStrategies= strategies;
+ }
+
+ /**
+ * Returns the previously set stratgies or <code>null</code>.
+ *
+ * @return the contained strategies or <code>null</code>
+ */
+ public IReconcilingStrategy[] getReconcilingStrategies() {
+ return fStrategies;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
+ */
+ public void setDocument(IDocument document) {
+ if (fStrategies == null)
+ return;
+
+ for (int i= 0; i < fStrategies.length; i++)
+ fStrategies[i].setDocument(document);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
+ */
+ public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
+ if (fStrategies == null)
+ return;
+
+ for (int i= 0; i < fStrategies.length; i++)
+ fStrategies[i].reconcile(dirtyRegion, subRegion);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
+ */
+ public void reconcile(IRegion partition) {
+ if (fStrategies == null)
+ return;
+
+ for (int i= 0; i < fStrategies.length; i++)
+ fStrategies[i].reconcile(partition);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void setProgressMonitor(IProgressMonitor monitor) {
+ if (fStrategies == null)
+ return;
+
+ for (int i=0; i < fStrategies.length; i++) {
+ if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
+ IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
+ extension.setProgressMonitor(monitor);
+ }
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
+ */
+ public void initialReconcile() {
+ if (fStrategies == null)
+ return;
+
+ for (int i=0; i < fStrategies.length; i++) {
+ if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
+ IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
+ extension.initialReconcile();
+ }
+ }
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/CompositeReconcilingStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyCompositeReconcilingStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyCompositeReconcilingStrategy.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyCompositeReconcilingStrategy.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.text;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.reconciler.DirtyRegion;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.text.ruby.IProblemRequestorExtension;
+import org.rubypeople.rdt.internal.ui.text.ruby.RubyReconcilingStrategy;
+import org.rubypeople.rdt.internal.ui.text.spelling.RubySpellingReconcileStrategy;
+
+/**
+ * Reconciling strategy for Ruby code. This is a composite strategy containing the
+ * regular java model reconciler and the comment spelling strategy.
+ *
+ * @since 3.0
+ */
+public class RubyCompositeReconcilingStrategy extends CompositeReconcilingStrategy {
+
+ private ITextEditor fEditor;
+ private RubyReconcilingStrategy fRubyStrategy;
+
+ /**
+ * Creates a new Ruby reconciling strategy.
+ *
+ * @param editor the editor of the strategy's reconciler
+ * @param documentPartitioning the document partitioning this strategy uses for configuration
+ */
+ public RubyCompositeReconcilingStrategy(ITextEditor editor, String documentPartitioning) {
+ fEditor= editor;
+ fRubyStrategy= new RubyReconcilingStrategy(editor);
+ setReconcilingStrategies(new IReconcilingStrategy[] {
+ fRubyStrategy,
+ new RubySpellingReconcileStrategy(editor)
+ });
+ }
+
+ /**
+ * Returns the problem requestor for the editor's input element.
+ *
+ * @return the problem requestor for the editor's input element
+ */
+ private IProblemRequestorExtension getProblemRequestorExtension() {
+ IDocumentProvider p= fEditor.getDocumentProvider();
+ if (p == null) {
+ // work around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=51522
+ p= RubyPlugin.getDefault().getRubyDocumentProvider();
+ }
+ IAnnotationModel m= p.getAnnotationModel(fEditor.getEditorInput());
+ if (m instanceof IProblemRequestorExtension)
+ return (IProblemRequestorExtension) m;
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
+ */
+ public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
+ IProblemRequestorExtension e= getProblemRequestorExtension();
+ if (e != null) {
+ try {
+ e.beginReportingSequence();
+ super.reconcile(dirtyRegion, subRegion);
+ } finally {
+ e.endReportingSequence();
+ }
+ } else {
+ super.reconcile(dirtyRegion, subRegion);
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
+ */
+ public void reconcile(IRegion partition) {
+ IProblemRequestorExtension e= getProblemRequestorExtension();
+ if (e != null) {
+ try {
+ e.beginReportingSequence();
+ super.reconcile(partition);
+ } finally {
+ e.endReportingSequence();
+ }
+ } else {
+ super.reconcile(partition);
+ }
+ }
+
+ /**
+ * Tells this strategy whether to inform its listeners.
+ *
+ * @param notify <code>true</code> if listeners should be notified
+ */
+ public void notifyListeners(boolean notify) {
+ fRubyStrategy.notifyListeners(notify);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#initialReconcile()
+ */
+ public void initialReconcile() {
+ IProblemRequestorExtension e= getProblemRequestorExtension();
+ if (e != null) {
+ try {
+ e.beginReportingSequence();
+ super.initialReconcile();
+ } finally {
+ e.endReportingSequence();
+ }
+ } else {
+ super.initialReconcile();
+ }
+ }
+
+ /**
+ * Called before reconciling is started.
+ *
+ * @since 3.0
+ */
+ public void aboutToBeReconciled() {
+ fRubyStrategy.aboutToBeReconciled();
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyCompositeReconcilingStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyReconciler.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyReconciler.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyReconciler.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -10,9 +10,9 @@
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.reconciler.DirtyRegion;
-import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.texteditor.ITextEditor;
@@ -73,7 +73,7 @@
* @param strategy
* @param isIncremental
*/
- public RubyReconciler(ITextEditor editor, IReconcilingStrategy strategy, boolean isIncremental) {
+ public RubyReconciler(ITextEditor editor, RubyCompositeReconcilingStrategy strategy, boolean isIncremental) {
super(strategy, isIncremental);
this.fTextEditor = editor;
@@ -114,6 +114,8 @@
if (!fIninitalProcessDone) return;
super.forceReconciling();
+ RubyCompositeReconcilingStrategy strategy= (RubyCompositeReconcilingStrategy) getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
+ strategy.notifyListeners(false);
}
/*
@@ -127,5 +129,18 @@
}
fIninitalProcessDone = true;
}
+
+ @Override
+ protected void reconcilerReset() {
+ super.reconcilerReset();
+ RubyCompositeReconcilingStrategy strategy= (RubyCompositeReconcilingStrategy) getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
+ strategy.notifyListeners(true);
+ }
+
+ @Override
+ protected void aboutToBeReconciled() {
+ RubyCompositeReconcilingStrategy strategy= (RubyCompositeReconcilingStrategy) getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
+ strategy.aboutToBeReconciled();
+ }
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ProblemLocation.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ProblemLocation.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ProblemLocation.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -26,7 +26,7 @@
public class ProblemLocation implements IProblemLocation {
private final int fId;
-// private final String[] fArguments;
+ private final String[] fArguments;
private final int fOffset;
private final int fLength;
private final boolean fIsError;
@@ -34,7 +34,7 @@
public ProblemLocation(int offset, int length, IRubyAnnotation annotation) {
fId= annotation.getId();
-// fArguments= annotation.getArguments();
+ fArguments= annotation.getArguments();
fOffset= offset;
fLength= length;
fIsError= RubyMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotation.getType());
@@ -45,7 +45,7 @@
public ProblemLocation(int offset, int length, int id, String[] arguments, boolean isError, String markerType) {
fId= id;
-// fArguments= arguments;
+ fArguments= arguments;
fOffset= offset;
fLength= length;
fIsError= isError;
@@ -54,7 +54,7 @@
public ProblemLocation(IProblem problem) {
fId= problem.getID();
-// fArguments= problem.getArguments();
+ fArguments= problem.getArguments();
fOffset= problem.getSourceStart();
fLength= problem.getSourceEnd() - fOffset + 1;
fIsError= problem.isError();
@@ -73,8 +73,7 @@
* @see org.eclipse.jdt.internal.ui.text.correction.IProblemLocation#getProblemArguments()
*/
public String[] getProblemArguments() {
-// return fArguments;
- return new String[0];
+ return fArguments;
}
/* (non-Javadoc)
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/AddWordProposal.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/AddWordProposal.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/AddWordProposal.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.ui.text.spelling;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.rubypeople.rdt.internal.corext.util.Messages;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+import org.rubypeople.rdt.internal.ui.RubyUIMessages;
+import org.rubypeople.rdt.internal.ui.text.spelling.engine.ISpellCheckEngine;
+import org.rubypeople.rdt.internal.ui.text.spelling.engine.ISpellChecker;
+import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.ui.text.ruby.IInvocationContext;
+import org.rubypeople.rdt.ui.text.ruby.IRubyCompletionProposal;
+
+/**
+ * Proposal to add the unknown word to the dictionaries.
+ *
+ * @since 3.0
+ */
+public class AddWordProposal implements IRubyCompletionProposal {
+
+ /** The invocation context */
+ private final IInvocationContext fContext;
+
+ /** The word to add */
+ private final String fWord;
+
+ /**
+ * Creates a new add word proposal
+ *
+ * @param word
+ * The word to add
+ * @param context
+ * The invocation context
+ */
+ public AddWordProposal(final String word, final IInvocationContext context) {
+ fContext= context;
+ fWord= word;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
+ */
+ public final void apply(final IDocument document) {
+
+ final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
+ final ISpellChecker checker= engine.createSpellChecker(engine.getLocale(), PreferenceConstants.getPreferenceStore());
+
+ if (checker != null) {
+ checker.addWord(fWord);
+ RubySpellingProblem.removeAllInActiveEditor(fWord);
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
+ */
+ public String getAdditionalProposalInfo() {
+ return Messages.format(RubyUIMessages.Spelling_add_info, new String[] { WordCorrectionProposal.getHtmlRepresentation(fWord)});
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
+ */
+ public final IContextInformation getContextInformation() {
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+ */
+ public String getDisplayString() {
+ return Messages.format(RubyUIMessages.Spelling_add_label, new String[] { fWord });
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
+ */
+ public Image getImage() {
+ return RubyPluginImages.get(RubyPluginImages.IMG_CORRECTION_ADD);
+ }
+
+ /*
+ * @see org.eclipse.jdt.ui.text.java.IRubyCompletionProposal#getRelevance()
+ */
+ public int getRelevance() {
+ return Integer.MIN_VALUE;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
+ */
+ public final Point getSelection(final IDocument document) {
+ return new Point(fContext.getSelectionOffset(), fContext.getSelectionLength());
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/AddWordProposal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/ChangeCaseProposal.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/...
[truncated message content] |