Omaha #3685 Fix spell checker to use mixed case.

Fix bug in importShapefile

Change-Id: I818bef97b2306cb47e07d4885e77906d1fd5c793

Former-commit-id: 5c1570eafd [formerly 25ded2580ec97f4a966297f0af6dbb5d0e66956a]
Former-commit-id: 6ab8c36e83
This commit is contained in:
Ron Anderson 2014-10-23 09:02:16 -05:00
parent 64162dd9c0
commit ea43af0c3a
2 changed files with 19 additions and 11 deletions

View file

@ -66,7 +66,6 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.FileUtil; import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.viz.spellchecker.Activator;
import com.raytheon.uf.viz.spellchecker.jobs.SpellCheckJob; import com.raytheon.uf.viz.spellchecker.jobs.SpellCheckJob;
/** /**
@ -79,6 +78,7 @@ import com.raytheon.uf.viz.spellchecker.jobs.SpellCheckJob;
* 18 APR 2008 ### lvenable Initial creation * 18 APR 2008 ### lvenable Initial creation
* 01Mar2010 4765 MW Fegan Moved from GFE plug-in. * 01Mar2010 4765 MW Fegan Moved from GFE plug-in.
* 09/24/2014 #16693 lshi filter out swear words in spelling check * 09/24/2014 #16693 lshi filter out swear words in spelling check
* 10/23/2014 #3685 randerso Changes to support mixed case
* *
* </pre> * </pre>
* *
@ -87,9 +87,10 @@ import com.raytheon.uf.viz.spellchecker.jobs.SpellCheckJob;
* *
*/ */
public class SpellCheckDlg extends Dialog implements ISpellingProblemCollector { public class SpellCheckDlg extends Dialog implements ISpellingProblemCollector {
private static java.util.List<String> swearWords = Arrays.asList("ASSHOLE"); private static java.util.List<String> swearWords = Arrays.asList("ASSHOLE");
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(SpellCheckDlg.class); private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(SpellCheckDlg.class);
private static final Pattern DIGITS = Pattern.compile("\\d"); private static final Pattern DIGITS = Pattern.compile("\\d");
@ -331,6 +332,7 @@ public class SpellCheckDlg extends Dialog implements ISpellingProblemCollector {
* org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector#accept(org * org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector#accept(org
* .eclipse.ui.texteditor.spelling.SpellingProblem) * .eclipse.ui.texteditor.spelling.SpellingProblem)
*/ */
@Override
public void accept(SpellingProblem problem) { public void accept(SpellingProblem problem) {
if (shell.isDisposed()) { if (shell.isDisposed()) {
return; return;
@ -345,15 +347,16 @@ public class SpellCheckDlg extends Dialog implements ISpellingProblemCollector {
misspelledLbl.setText(badWord); misspelledLbl.setText(badWord);
ICompletionProposal[] proposals = problem.getProposals(); ICompletionProposal[] proposals = problem.getProposals();
if (proposals != null && proposals.length > 0) { if ((proposals != null) && (proposals.length > 0)) {
for (ICompletionProposal proposal : proposals) { for (ICompletionProposal proposal : proposals) {
String pdString = proposal.getDisplayString(); String pdString = proposal.getDisplayString();
Matcher pdMatch = CHANGE_TO.matcher(pdString); Matcher pdMatch = CHANGE_TO.matcher(pdString);
if (pdMatch.matches()) { if (pdMatch.matches()) {
String replString = pdMatch.group(1).toUpperCase(); String replString = pdMatch.group(1);
// proposals may include case changes, which get lost // proposals may include case changes, which get lost
//if (replString != badWord) { // if (replString != badWord) {
if (!swearWords.contains(replString) && !replString.equals(badWord)) { if (!swearWords.contains(replString)
&& !replString.equals(badWord)) {
suggestionList.add(replString); suggestionList.add(replString);
} }
} }
@ -370,7 +373,7 @@ public class SpellCheckDlg extends Dialog implements ISpellingProblemCollector {
StyleRange styleRange = styledText.getStyleRangeAtOffset(problem StyleRange styleRange = styledText.getStyleRangeAtOffset(problem
.getOffset()); .getOffset());
if (styleRange == null || styleRange.isUnstyled() if ((styleRange == null) || styleRange.isUnstyled()
|| styleRange.similarTo(REDSTYLE)) { || styleRange.similarTo(REDSTYLE)) {
if (ignoreAll.contains(badWord)) { if (ignoreAll.contains(badWord)) {
scanForErrors(); scanForErrors();
@ -407,6 +410,7 @@ public class SpellCheckDlg extends Dialog implements ISpellingProblemCollector {
* org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector#beginCollecting * org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector#beginCollecting
* () * ()
*/ */
@Override
public void beginCollecting() { public void beginCollecting() {
// nothing at present // nothing at present
} }
@ -531,7 +535,7 @@ public class SpellCheckDlg extends Dialog implements ISpellingProblemCollector {
probStart = matcher.start(2); probStart = matcher.start(2);
// Only replace unstyled (unlocked) instances // Only replace unstyled (unlocked) instances
styleRange = styledText.getStyleRangeAtOffset(probStart); styleRange = styledText.getStyleRangeAtOffset(probStart);
if (styleRange == null || styleRange.isUnstyled()) { if ((styleRange == null) || styleRange.isUnstyled()) {
repList.addFirst(Integer.valueOf(probStart)); repList.addFirst(Integer.valueOf(probStart));
} }
found = matcher.find(); found = matcher.find();
@ -582,7 +586,8 @@ public class SpellCheckDlg extends Dialog implements ISpellingProblemCollector {
try { try {
userDLFile.save(); userDLFile.save();
} catch (Exception e) { } catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, "Error saving user dictionary", e); statusHandler.handle(Priority.PROBLEM,
"Error saving user dictionary", e);
} }
// The spell check job might have a backlog of errors // The spell check job might have a backlog of errors
// for this word, which no longer apply. // for this word, which no longer apply.
@ -658,6 +663,7 @@ public class SpellCheckDlg extends Dialog implements ISpellingProblemCollector {
* org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector#endCollecting * org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector#endCollecting
* () * ()
*/ */
@Override
public void endCollecting() { public void endCollecting() {
MessageDialog.openInformation(shell, "", "Done checking document"); MessageDialog.openInformation(shell, "", "Done checking document");
styledText.setSelectionRange(0, 0); styledText.setSelectionRange(0, 0);

View file

@ -23,6 +23,8 @@
# Date Ticket# Engineer Description # Date Ticket# Engineer Description
# ------------ ---------- ----------- -------------------------- # ------------ ---------- ----------- --------------------------
# 03/25/2014 #2664 randerso Added support for importing non-WGS84 shape files # 03/25/2014 #2664 randerso Added support for importing non-WGS84 shape files
# 10/23/2014 #3685 randerso Fixed bug where .prj was not recognized when shape file
# was in the current directory (no directory specified)
# #
## ##
@ -46,7 +48,7 @@ if [ $# -lt 3 ] ; then
exit -1 exit -1
fi fi
SHP_PATH=${1} SHP_PATH=`readlink -f ${1}`
SHP_DIR="${SHP_PATH%/*}" # shape file dir SHP_DIR="${SHP_PATH%/*}" # shape file dir
SHP_NAME="${SHP_PATH##*/}" # shape file name with extension SHP_NAME="${SHP_PATH##*/}" # shape file name with extension
SHP_BASE="${SHP_NAME%.*}" # shape file name without extension SHP_BASE="${SHP_NAME%.*}" # shape file name without extension