Omaha #3453 Inline Spellcheck - Fixed issues found while in Testing.

Former-commit-id: a1d23e4198 [formerly 9d9065714e1fffa3b65e0f2ccb724dc1dd7a4e7b]
Former-commit-id: d5994a8a6b
This commit is contained in:
Robert Blum 2014-10-01 10:22:25 -05:00
parent 0d677d1aca
commit 6c1676e743
2 changed files with 33 additions and 3 deletions

View file

@ -8,7 +8,8 @@ Bundle-Vendor: RAYTHEON
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.raytheon.viz.core;bundle-version="1.11.26",
com.google.guava;bundle-version="11.0.2"
com.google.guava;bundle-version="11.0.2",
org.eclipse.jdt.ui
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.jdt.internal.ui.text.spelling,

View file

@ -25,6 +25,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
import org.eclipse.jdt.internal.ui.text.spelling.AddWordProposal;
import org.eclipse.jdt.internal.ui.text.spelling.DisableSpellCheckingProposal;
import org.eclipse.jdt.ui.PreferenceConstants;
@ -83,6 +85,8 @@ import com.raytheon.uf.viz.spellchecker.jobs.EnhancedSpellCheckJob;
* disable of spell checking.
* Aug 18, 2014 3453 rblum Added the spell check dictionary
* to site level localization.
* Oct 01, 2014 3453 rblum Allow MB3 click anywhere in the textbox
* to enable/disable spellcheck.
*
* </pre>
*
@ -97,6 +101,8 @@ public class SpellCheckTextViewer extends TextViewer implements
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(SpellCheckTextViewer.class);
private final String enableSpellCheckText = "Enable spell checking";
private List<SpellingProblem> problems;
private IPreferenceStore store;
@ -151,14 +157,18 @@ public class SpellCheckTextViewer extends TextViewer implements
offset = getTextWidget().getOffsetAtLocation(
new Point(e.x, e.y));
} catch (Exception exception) {
return;
/*
* Do Nothing - Did not click on text.
*/
}
SpellingProblem problem = getProblemInRange(offset);
final Menu menu = new Menu(getTextWidget());
if (store
.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED) == false) {
MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText("Enable spell checking");
item.setText(enableSpellCheckText);
item.setImage(JavaPluginImages
.get(JavaPluginImages.IMG_CORRECTION_ADD));
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@ -177,7 +187,26 @@ public class SpellCheckTextViewer extends TextViewer implements
addSelectionAction(item);
}
} else {
/*
* Spell check is enabled but did not click on
* mis-spelled word - Allow disabling
*/
MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText(JavaUIMessages.Spelling_disable_label);
item.setImage(JavaPluginImages
.get(JavaPluginImages.IMG_OBJS_NLS_NEVER_TRANSLATE));
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
store.setValue(
SpellingService.PREFERENCE_SPELLING_ENABLED,
false);
refreshAllTextViewers(false);
}
});
}
menu.addMenuListener(new MenuAdapter() {
@Override
public void menuHidden(MenuEvent e) {