Merge "Omaha #3453 Added the spell check dictionary to site level localization." into omaha_14.4.1
Former-commit-id:2710aed225
[formerly 2bac6ff5e600218f61343a7dc0f540c27f291924] Former-commit-id:8536f6681a
This commit is contained in:
commit
3ddebb2170
3 changed files with 63 additions and 9 deletions
|
@ -11,7 +11,8 @@ Require-Bundle: org.eclipse.ui,
|
||||||
com.google.guava;bundle-version="11.0.2"
|
com.google.guava;bundle-version="11.0.2"
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Import-Package: org.eclipse.jdt.ui,
|
Import-Package: org.eclipse.jdt.internal.ui.text.spelling,
|
||||||
|
org.eclipse.jdt.ui,
|
||||||
org.eclipse.jface.text,
|
org.eclipse.jface.text,
|
||||||
org.eclipse.jface.text.contentassist,
|
org.eclipse.jface.text.contentassist,
|
||||||
org.eclipse.jface.text.source,
|
org.eclipse.jface.text.source,
|
||||||
|
|
|
@ -25,10 +25,10 @@ import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.content.IContentTypeManager;
|
import org.eclipse.core.runtime.content.IContentTypeManager;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
import org.eclipse.jdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.editors.text.EditorsUI;
|
|
||||||
import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector;
|
import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector;
|
||||||
import org.eclipse.ui.texteditor.spelling.SpellingContext;
|
import org.eclipse.ui.texteditor.spelling.SpellingContext;
|
||||||
import org.eclipse.ui.texteditor.spelling.SpellingService;
|
import org.eclipse.ui.texteditor.spelling.SpellingService;
|
||||||
|
@ -44,6 +44,8 @@ import org.eclipse.ui.texteditor.spelling.SpellingService;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jun 17, 2014 3453 rblum Initial creation
|
* Jun 17, 2014 3453 rblum Initial creation
|
||||||
|
* Aug 18, 2014 3453 rblum Added the spell check dictionary
|
||||||
|
* to site level localization.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -54,7 +56,7 @@ import org.eclipse.ui.texteditor.spelling.SpellingService;
|
||||||
public class EnhancedSpellCheckJob extends Job {
|
public class EnhancedSpellCheckJob extends Job {
|
||||||
|
|
||||||
private IDocument document;
|
private IDocument document;
|
||||||
|
|
||||||
private IRegion[] region = new IRegion[1];
|
private IRegion[] region = new IRegion[1];
|
||||||
|
|
||||||
private ISpellingProblemCollector collector;
|
private ISpellingProblemCollector collector;
|
||||||
|
@ -69,7 +71,7 @@ public class EnhancedSpellCheckJob extends Job {
|
||||||
public void setDocument(IDocument document) {
|
public void setDocument(IDocument document) {
|
||||||
this.document = document;
|
this.document = document;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRegion(IRegion region) {
|
public void setRegion(IRegion region) {
|
||||||
this.region[0] = region;
|
this.region[0] = region;
|
||||||
}
|
}
|
||||||
|
@ -83,9 +85,11 @@ public class EnhancedSpellCheckJob extends Job {
|
||||||
SpellingService service = (SpellingService) PlatformUI.getWorkbench()
|
SpellingService service = (SpellingService) PlatformUI.getWorkbench()
|
||||||
.getService(SpellingService.class);
|
.getService(SpellingService.class);
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
EditorsUI.getPreferenceStore().setValue(SpellingService.PREFERENCE_SPELLING_ENGINE,
|
PreferenceConstants.getPreferenceStore().setValue(
|
||||||
|
SpellingService.PREFERENCE_SPELLING_ENGINE,
|
||||||
"spellingEngine");
|
"spellingEngine");
|
||||||
service = new SpellingService(EditorsUI.getPreferenceStore());
|
service = new SpellingService(
|
||||||
|
PreferenceConstants.getPreferenceStore());
|
||||||
}
|
}
|
||||||
|
|
||||||
SpellingContext context = new SpellingContext();
|
SpellingContext context = new SpellingContext();
|
||||||
|
|
|
@ -19,11 +19,15 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.viz.spellchecker.text;
|
package com.raytheon.uf.viz.spellchecker.text;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.internal.ui.text.spelling.AddWordProposal;
|
||||||
|
import org.eclipse.jdt.internal.ui.text.spelling.DisableSpellCheckingProposal;
|
||||||
|
import org.eclipse.jdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.text.Document;
|
import org.eclipse.jface.text.Document;
|
||||||
import org.eclipse.jface.text.ITextListener;
|
import org.eclipse.jface.text.ITextListener;
|
||||||
|
@ -47,7 +51,6 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Menu;
|
import org.eclipse.swt.widgets.Menu;
|
||||||
import org.eclipse.swt.widgets.MenuItem;
|
import org.eclipse.swt.widgets.MenuItem;
|
||||||
import org.eclipse.ui.editors.text.EditorsUI;
|
|
||||||
import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector;
|
import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector;
|
||||||
import org.eclipse.ui.texteditor.spelling.SpellingProblem;
|
import org.eclipse.ui.texteditor.spelling.SpellingProblem;
|
||||||
import org.eclipse.ui.texteditor.spelling.SpellingService;
|
import org.eclipse.ui.texteditor.spelling.SpellingService;
|
||||||
|
@ -55,6 +58,14 @@ import org.eclipse.ui.texteditor.spelling.SpellingService;
|
||||||
import com.google.common.collect.BoundType;
|
import com.google.common.collect.BoundType;
|
||||||
import com.google.common.collect.Range;
|
import com.google.common.collect.Range;
|
||||||
import com.google.common.collect.Ranges;
|
import com.google.common.collect.Ranges;
|
||||||
|
import com.raytheon.uf.common.localization.IPathManager;
|
||||||
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||||
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||||
|
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||||
|
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||||
|
import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException;
|
||||||
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.viz.core.VizApp;
|
import com.raytheon.uf.viz.core.VizApp;
|
||||||
import com.raytheon.uf.viz.spellchecker.jobs.EnhancedSpellCheckJob;
|
import com.raytheon.uf.viz.spellchecker.jobs.EnhancedSpellCheckJob;
|
||||||
|
|
||||||
|
@ -70,6 +81,8 @@ import com.raytheon.uf.viz.spellchecker.jobs.EnhancedSpellCheckJob;
|
||||||
* Jun 18, 2014 3453 rblum Initial creation
|
* Jun 18, 2014 3453 rblum Initial creation
|
||||||
* Aug 06, 2014 3453 rblum Refreshing all viewers on enable/
|
* Aug 06, 2014 3453 rblum Refreshing all viewers on enable/
|
||||||
* disable of spell checking.
|
* disable of spell checking.
|
||||||
|
* Aug 18, 2014 3453 rblum Added the spell check dictionary
|
||||||
|
* to site level localization.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -77,9 +90,13 @@ import com.raytheon.uf.viz.spellchecker.jobs.EnhancedSpellCheckJob;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@SuppressWarnings("restriction")
|
||||||
public class SpellCheckTextViewer extends TextViewer implements
|
public class SpellCheckTextViewer extends TextViewer implements
|
||||||
ISpellingProblemCollector {
|
ISpellingProblemCollector {
|
||||||
|
|
||||||
|
private static final IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(SpellCheckTextViewer.class);
|
||||||
|
|
||||||
private List<SpellingProblem> problems;
|
private List<SpellingProblem> problems;
|
||||||
|
|
||||||
private IPreferenceStore store;
|
private IPreferenceStore store;
|
||||||
|
@ -90,6 +107,10 @@ public class SpellCheckTextViewer extends TextViewer implements
|
||||||
|
|
||||||
private Map<Range<Integer>, SpellingProblem> ranges;
|
private Map<Range<Integer>, SpellingProblem> ranges;
|
||||||
|
|
||||||
|
private final String siteDictionary = "spellcheck/dictionary.txt";
|
||||||
|
|
||||||
|
private LocalizationFile lf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param styles
|
* @param styles
|
||||||
|
@ -98,7 +119,18 @@ public class SpellCheckTextViewer extends TextViewer implements
|
||||||
super(parent, styles);
|
super(parent, styles);
|
||||||
problems = new ArrayList<SpellingProblem>();
|
problems = new ArrayList<SpellingProblem>();
|
||||||
ranges = new HashMap<Range<Integer>, SpellingProblem>();
|
ranges = new HashMap<Range<Integer>, SpellingProblem>();
|
||||||
store = EditorsUI.getPreferenceStore();
|
store = PreferenceConstants.getPreferenceStore();
|
||||||
|
|
||||||
|
IPathManager mgr = PathManagerFactory.getPathManager();
|
||||||
|
lf = mgr.getLocalizationFile(mgr.getContext(
|
||||||
|
LocalizationType.CAVE_STATIC, LocalizationLevel.SITE),
|
||||||
|
siteDictionary);
|
||||||
|
|
||||||
|
// Get the localized dictionary and store it in the Preference store
|
||||||
|
File dictionary = lf.getFile();
|
||||||
|
String filePath = dictionary.getPath();
|
||||||
|
store.setValue(PreferenceConstants.SPELLING_USER_DICTIONARY, filePath);
|
||||||
|
|
||||||
setDocument(new Document());
|
setDocument(new Document());
|
||||||
textViewers.add(this);
|
textViewers.add(this);
|
||||||
ITextListener listener = new ITextListener() {
|
ITextListener listener = new ITextListener() {
|
||||||
|
@ -244,7 +276,24 @@ public class SpellCheckTextViewer extends TextViewer implements
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
ICompletionProposal prop = (ICompletionProposal) item.getData();
|
ICompletionProposal prop = (ICompletionProposal) item.getData();
|
||||||
prop.apply(getDocument());
|
if (prop instanceof DisableSpellCheckingProposal) {
|
||||||
|
store.setValue(SpellingService.PREFERENCE_SPELLING_ENABLED,
|
||||||
|
false);
|
||||||
|
} else {
|
||||||
|
prop.apply(getDocument());
|
||||||
|
|
||||||
|
if (prop instanceof AddWordProposal) {
|
||||||
|
try {
|
||||||
|
if (lf != null) {
|
||||||
|
lf.save();
|
||||||
|
}
|
||||||
|
} catch (LocalizationOpFailedException exception) {
|
||||||
|
statusHandler
|
||||||
|
.error("Unable to save dictionary into localization",
|
||||||
|
exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
scheduleSpellJob(true);
|
scheduleSpellJob(true);
|
||||||
refreshAllTextViewers(false);
|
refreshAllTextViewers(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue