Omaha #4018 Formatted all formatter launcher code to make later code reviews easier

Change-Id: Iaf415b8bdd3e8fdc46b8ea66e066b9c2ce3b6f7a

Former-commit-id: ef1afbaa0c [formerly a7ab638203] [formerly 5c08543da0] [formerly 8a86832fb2 [formerly 5c08543da0 [formerly 99ae51d268e784461c0686a9d86d512049a501ac]]]
Former-commit-id: 8a86832fb2
Former-commit-id: ff05c9f6924076e0f72cb56db3be2828275d381d [formerly a00e04a8d7]
Former-commit-id: a4c15c7bea
This commit is contained in:
Ron Anderson 2015-01-27 13:40:56 -06:00
parent 0e805888ee
commit 6e7d00e190
8 changed files with 243 additions and 231 deletions

View file

@ -548,7 +548,7 @@ public class FindReplaceDlg extends CaveSWTDialog {
this.searchOptions.remove(FindReplaceOptions.SEARCH_POS_END); this.searchOptions.remove(FindReplaceOptions.SEARCH_POS_END);
int[] matchRange = findString(searchString); int[] matchRange = findString(searchString);
while (!(matchRange[0] == 0 && matchRange[1] == 0)) { while (!((matchRange[0] == 0) && (matchRange[1] == 0))) {
int newOffset = matchRange[1]; int newOffset = matchRange[1];
editorST.replaceTextRange(matchRange[0], searchString.length(), editorST.replaceTextRange(matchRange[0], searchString.length(),
@ -607,7 +607,7 @@ public class FindReplaceDlg extends CaveSWTDialog {
int[] replaceMatch = findString(replaceString, int[] replaceMatch = findString(replaceString,
selectionToBeReplaced.x); selectionToBeReplaced.x);
if (!(replaceMatch[0] == 0 && replaceMatch[1] == 0)) { if (!((replaceMatch[0] == 0) && (replaceMatch[1] == 0))) {
editorComp.reParse(); editorComp.reParse();
editorST.setCaretOffset(replaceMatch[1]); editorST.setCaretOffset(replaceMatch[1]);
} }
@ -630,8 +630,9 @@ public class FindReplaceDlg extends CaveSWTDialog {
* *
*/ */
private void handleClickFind(SelectionEvent event) { private void handleClickFind(SelectionEvent event) {
if (findTF.getText().equals("")) if (findTF.getText().equals("")) {
return; return;
}
cursorOffset = editorST.getCaretOffset(); cursorOffset = editorST.getCaretOffset();
@ -639,8 +640,8 @@ public class FindReplaceDlg extends CaveSWTDialog {
// For BACKWARD_SEARCH option: // For BACKWARD_SEARCH option:
// Need skip the previously found string // Need skip the previously found string
if (searchOptions.contains(FindReplaceOptions.BACKWARD_SEARCH)) { if (searchOptions.contains(FindReplaceOptions.BACKWARD_SEARCH)) {
if (editorST.getSelectionRange() != null if ((editorST.getSelectionRange() != null)
&& editorST.getSelectionRange().y > 0) { && (editorST.getSelectionRange().y > 0)) {
cursorOffset -= editorST.getSelectionRange().y; cursorOffset -= editorST.getSelectionRange().y;
if (cursorOffset < 0) { if (cursorOffset < 0) {
cursorOffset = 0; cursorOffset = 0;
@ -671,7 +672,7 @@ public class FindReplaceDlg extends CaveSWTDialog {
private boolean findAndSelectString(String searchString) { private boolean findAndSelectString(String searchString) {
int[] matchRange = findString(searchString); int[] matchRange = findString(searchString);
if (!(matchRange[0] == 0 && matchRange[1] == 0)) { if (!((matchRange[0] == 0) && (matchRange[1] == 0))) {
editorST.setSelection(matchRange[0], matchRange[1]); editorST.setSelection(matchRange[0], matchRange[1]);
editorST.showSelection(); editorST.showSelection();
cursorOffset = editorST.getCaretOffset(); cursorOffset = editorST.getCaretOffset();
@ -744,8 +745,9 @@ public class FindReplaceDlg extends CaveSWTDialog {
// if (searchOptions.contains(FindReplaceOptions.EXACT_MATCH) // if (searchOptions.contains(FindReplaceOptions.EXACT_MATCH)
// && !searchOptions.contains(FindReplaceOptions.REGEX_SEARCH)) // && !searchOptions.contains(FindReplaceOptions.REGEX_SEARCH))
// searchRegex = "\\b" + searchRegex + "\\b"; // searchRegex = "\\b" + searchRegex + "\\b";
if (searchOptions.contains(FindReplaceOptions.IGNORE_CASE)) if (searchOptions.contains(FindReplaceOptions.IGNORE_CASE)) {
regexFlags |= Pattern.CASE_INSENSITIVE; regexFlags |= Pattern.CASE_INSENSITIVE;
}
// Need handle the PatternSyntaxException when user searches meta // Need handle the PatternSyntaxException when user searches meta
// character(s) but forgot to toggle on the regex option. // character(s) but forgot to toggle on the regex option.
@ -761,10 +763,11 @@ public class FindReplaceDlg extends CaveSWTDialog {
match[0] = matcher.start(); match[0] = matcher.start();
match[1] = matcher.end(); match[1] = matcher.end();
if (searchOptions if (searchOptions
.contains(FindReplaceOptions.FORWARD_SEARCH)) .contains(FindReplaceOptions.FORWARD_SEARCH)) {
break; break;
} }
} }
}
} catch (PatternSyntaxException e) { } catch (PatternSyntaxException e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"Unable to parse the search string", e); "Unable to parse the search string", e);
@ -829,7 +832,7 @@ public class FindReplaceDlg extends CaveSWTDialog {
int searchEndIndex; int searchEndIndex;
int[] match = { 0, 0 }; int[] match = { 0, 0 };
if (searchString == null || searchString.equals("")) { if ((searchString == null) || searchString.equals("")) {
return match; return match;
} }

View file

@ -35,7 +35,6 @@ package com.raytheon.viz.gfe.dialogs.formatterlauncher;
* @author lvenable * @author lvenable
* @version 1.0 * @version 1.0
*/ */
public interface ITransmissionState public interface ITransmissionState {
{
void setTransmissionState(ConfigData.productStateEnum state); void setTransmissionState(ConfigData.productStateEnum state);
} }

View file

@ -2015,8 +2015,7 @@ public class ProductEditorComp extends Composite implements
if (pds != null) { if (pds != null) {
String officeTimeZone = dm.getParmManager() String officeTimeZone = dm.getParmManager()
.compositeGridLocation() .compositeGridLocation().getTimeZone();
.getTimeZone();
int numSegments = pds.getSegmentsArray().size(); int numSegments = pds.getSegmentsArray().size();
SimpleDateFormat fmt = new SimpleDateFormat(longLocalFmtStr); SimpleDateFormat fmt = new SimpleDateFormat(longLocalFmtStr);
fmt.setTimeZone(localTimeZone); fmt.setTimeZone(localTimeZone);
@ -2025,8 +2024,7 @@ public class ProductEditorComp extends Composite implements
for (int i = 0; i < numSegments; i++) { for (int i = 0; i < numSegments; i++) {
textComp.startUpdate(); textComp.startUpdate();
HashMap<String, TextIndexPoints> segMap = pds HashMap<String, TextIndexPoints> segMap = pds
.getSegmentsArray() .getSegmentsArray().get(i).getSementMap();
.get(i).getSementMap();
TextIndexPoints tip = segMap.get("purgeT"); TextIndexPoints tip = segMap.get("purgeT");
if (tip != null) { if (tip != null) {
@ -2046,10 +2044,10 @@ public class ProductEditorComp extends Composite implements
// vtecs are fixed length and this is variable length, // vtecs are fixed length and this is variable length,
// which ensures we only need to reParse() once per // which ensures we only need to reParse() once per
// segment // segment
List<String> zones = decodeUGCs(pds.getSegmentsArray().get(i)); List<String> zones = decodeUGCs(pds.getSegmentsArray()
.get(i));
List<String> timeZones = dm.getTextProductMgr() List<String> timeZones = dm.getTextProductMgr()
.getTimeZones(zones, .getTimeZones(zones, officeTimeZone);
officeTimeZone);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String tz : timeZones) { for (String tz : timeZones) {

View file

@ -58,8 +58,11 @@ public class SegmentData {
/** /**
* Add entry into the segment map. * Add entry into the segment map.
* @param key Map key. *
* @param tip Text index point data. * @param key
* Map key.
* @param tip
* Text index point data.
*/ */
public void addToSegmentMap(String key, TextIndexPoints tip) { public void addToSegmentMap(String key, TextIndexPoints tip) {
segMap.put(key, tip); segMap.put(key, tip);
@ -67,8 +70,11 @@ public class SegmentData {
/** /**
* Add entry into the head info map. * Add entry into the head info map.
* @param key Map key. *
* @param tip Text index point data. * @param key
* Map key.
* @param tip
* Text index point data.
*/ */
public void addToHeadInfoMap(String key, TextIndexPoints tip) { public void addToHeadInfoMap(String key, TextIndexPoints tip) {
headInfoMap.put(key, tip); headInfoMap.put(key, tip);
@ -76,7 +82,9 @@ public class SegmentData {
/** /**
* Get a text index point data from the segment map. * Get a text index point data from the segment map.
* @param key Map key. *
* @param key
* Map key.
* @return Segment text index point data. * @return Segment text index point data.
*/ */
public TextIndexPoints getSegmentDataIndexPoints(String key) { public TextIndexPoints getSegmentDataIndexPoints(String key) {
@ -85,7 +93,9 @@ public class SegmentData {
/** /**
* Get a text index point data from the head info map. * Get a text index point data from the head info map.
* @param key Map key. *
* @param key
* Map key.
* @return Segment text index point data. * @return Segment text index point data.
*/ */
public TextIndexPoints getHeadInfoDataIndexPoints(String key) { public TextIndexPoints getHeadInfoDataIndexPoints(String key) {
@ -94,6 +104,7 @@ public class SegmentData {
/** /**
* Get the segment map. * Get the segment map.
*
* @return The segment map. * @return The segment map.
*/ */
public HashMap<String, TextIndexPoints> getSementMap() { public HashMap<String, TextIndexPoints> getSementMap() {
@ -102,6 +113,7 @@ public class SegmentData {
/** /**
* Get the head info map. * Get the head info map.
*
* @return The head info map. * @return The head info map.
*/ */
public HashMap<String, TextIndexPoints> getHeadInfoMap() { public HashMap<String, TextIndexPoints> getHeadInfoMap() {

View file

@ -148,8 +148,7 @@ public class StoreTransmitCountdownThread extends Thread {
return; return;
} }
// Increment the progress bar // Increment the progress bar
progressBar progressBar.setSelection(progressBar.getSelection() + 1);
.setSelection(progressBar.getSelection() + 1);
countdownLbl.setText(countdownPrefix + counter countdownLbl.setText(countdownPrefix + counter
+ " seconds..."); + " seconds...");
--counter; --counter;

View file

@ -410,7 +410,8 @@ public class StyledTextComp extends Composite {
// should be unlocked. Cities list is unlocked for editing // should be unlocked. Cities list is unlocked for editing
// when framing codes are present. // when framing codes are present.
if (newProduct) { if (newProduct) {
if (cityTip != null && cityTip.getText().indexOf("|*") > 0) { if ((cityTip != null)
&& (cityTip.getText().indexOf("|*") > 0)) {
unlockCitySegs.add(ugc); unlockCitySegs.add(ugc);
} }
} }
@ -448,7 +449,7 @@ public class StyledTextComp extends Composite {
* correct the end value. * correct the end value.
*/ */
int endLineOffset = 0; int endLineOffset = 0;
if (endLine == productTextArray.length - 1) { if (endLine == (productTextArray.length - 1)) {
++endLineOffset; ++endLineOffset;
} }
@ -568,7 +569,7 @@ public class StyledTextComp extends Composite {
TextIndexPoints pit = prodDataStruct.getPIT(); TextIndexPoints pit = prodDataStruct.getPIT();
if (ff == null) { if (ff == null) {
if (pit == null || newfield.length() == 0) { if ((pit == null) || (newfield.length() == 0)) {
return; // No typecode or ci block found return; // No typecode or ci block found
} else { } else {
ff = new TextIndexPoints(); ff = new TextIndexPoints();
@ -608,8 +609,7 @@ public class StyledTextComp extends Composite {
// only reparse if we replaced with different length text or forced // only reparse if we replaced with different length text or forced
// else, replace StyleRanges since the operation is safe // else, replace StyleRanges since the operation is safe
if ((tip.getText().length() != text.length()) if ((tip.getText().length() != text.length()) || forceReparse) {
|| forceReparse) {
dirty = true; dirty = true;
} else { } else {
for (StyleRange range : ranges) { for (StyleRange range : ranges) {
@ -635,7 +635,7 @@ public class StyledTextComp extends Composite {
try { try {
startUpdate(); startUpdate();
List<SegmentData> segs = prodDataStruct.getSegmentsArray(); List<SegmentData> segs = prodDataStruct.getSegmentsArray();
if (segs == null || segs.size() == 0) { if ((segs == null) || (segs.size() == 0)) {
return; return;
} }
@ -648,7 +648,7 @@ public class StyledTextComp extends Composite {
int start = prodDataStruct.positionToOffset(tipUgc int start = prodDataStruct.positionToOffset(tipUgc
.getStartIndex()); .getStartIndex());
int end = prodDataStruct.positionToOffset(tipUgc.getEndIndex()); int end = prodDataStruct.positionToOffset(tipUgc.getEndIndex());
if (offset <= start || offset >= end) { if ((offset <= start) || (offset >= end)) {
continue; continue;
} }
TextIndexPoints tipVtec = segMap.get("vtec"); TextIndexPoints tipVtec = segMap.get("vtec");
@ -735,8 +735,8 @@ public class StyledTextComp extends Composite {
// this is specifically to handle the case of deleting line breaks // this is specifically to handle the case of deleting line breaks
// between two separate locked sections so a locked section cannot be // between two separate locked sections so a locked section cannot be
// moved onto the end of an unlocked line // moved onto the end of an unlocked line
if (length == 1 && event.text.length() == 0) { if ((length == 1) && (event.text.length() == 0)) {
if (offset + 2 < textEditorST.getCharCount() if (((offset + 2) < textEditorST.getCharCount())
&& rangeHasLockedText(offset, 2)) { && rangeHasLockedText(offset, 2)) {
event.doit = false; event.doit = false;
return; return;
@ -748,7 +748,7 @@ public class StyledTextComp extends Composite {
} }
private void updateTextStyle(ExtendedModifyEvent event) { private void updateTextStyle(ExtendedModifyEvent event) {
if (event.start + event.length + 1 < textEditorST.getCharCount()) { if ((event.start + event.length + 1) < textEditorST.getCharCount()) {
int start = Math.max(0, event.start - 1); int start = Math.max(0, event.start - 1);
int end = Math.min(textEditorST.getCharCount() - 1, event.start int end = Math.min(textEditorST.getCharCount() - 1, event.start
+ event.length + 1); + event.length + 1);
@ -760,9 +760,9 @@ public class StyledTextComp extends Composite {
// .getStyleRangeAtOffset(event.start + event.length + 1); // .getStyleRangeAtOffset(event.start + event.length + 1);
// if it's in a framing code, turn it red // if it's in a framing code, turn it red
if (startRange != null && endRange != null if ((startRange != null) && (endRange != null)
&& event.start > startRange.start && (event.start > startRange.start)
&& event.start + event.length < endRange.start && ((event.start + event.length) < endRange.start)
&& startRange.similarTo(endRange) && startRange.similarTo(endRange)
&& startRange.foreground.equals(frameColor)) { && startRange.foreground.equals(frameColor)) {
StyleRange style = (StyleRange) startRange.clone(); StyleRange style = (StyleRange) startRange.clone();
@ -779,7 +779,7 @@ public class StyledTextComp extends Composite {
} }
// framing code was added, need to turn it red // framing code was added, need to turn it red
char newText = textEditorST.getText().charAt(event.start); char newText = textEditorST.getText().charAt(event.start);
if (newText == '*' || newText == '|') { if ((newText == '*') || (newText == '|')) {
framingCodeChange = true; framingCodeChange = true;
} }
@ -801,8 +801,8 @@ public class StyledTextComp extends Composite {
StyleRange[] srArray = textEditorST.getStyleRanges(true); StyleRange[] srArray = textEditorST.getStyleRanges(true);
for (int i = 0; i < srArray.length; i++) { for (int i = 0; i < srArray.length; i++) {
if (srArray[i].start <= offset if ((srArray[i].start <= offset)
&& offset <= srArray[i].start + srArray[i].length) { && (offset <= (srArray[i].start + srArray[i].length))) {
if (srArray[i].foreground == frameColor) { if (srArray[i].foreground == frameColor) {
inFramingCode(srArray[i]); inFramingCode(srArray[i]);
} }
@ -868,10 +868,11 @@ public class StyledTextComp extends Composite {
* @return True if the key is an arrow or "non-edit" key. * @return True if the key is an arrow or "non-edit" key.
*/ */
private boolean isNonEditKey(KeyEvent event) { private boolean isNonEditKey(KeyEvent event) {
if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN if ((event.keyCode == SWT.ARROW_UP)
|| event.keyCode == SWT.ARROW_LEFT || (event.keyCode == SWT.ARROW_DOWN)
|| event.keyCode == SWT.ARROW_RIGHT || (event.keyCode == SWT.ARROW_LEFT)
|| event.keyCode == SWT.SHIFT) { || (event.keyCode == SWT.ARROW_RIGHT)
|| (event.keyCode == SWT.SHIFT)) {
return true; return true;
} }
@ -943,8 +944,8 @@ public class StyledTextComp extends Composite {
StyleRange[] sr = textEditorST.getStyleRanges(true); StyleRange[] sr = textEditorST.getStyleRanges(true);
for (int i = 0; i < sr.length; i++) { for (int i = 0; i < sr.length; i++) {
if (sr[i].start <= offset if ((sr[i].start <= offset)
&& offset <= sr[i].start + sr[i].length) { && (offset <= (sr[i].start + sr[i].length))) {
if (sr[i].foreground == frameColor) { if (sr[i].foreground == frameColor) {
inFramingCode(sr[i]); inFramingCode(sr[i]);
} }
@ -1110,15 +1111,15 @@ public class StyledTextComp extends Composite {
int lineNum = textEditorST.getLineAtOffset(event.start); int lineNum = textEditorST.getLineAtOffset(event.start);
int lineLength = textEditorST.getLine(lineNum).length(); int lineLength = textEditorST.getLine(lineNum).length();
if (lineLength < wrapColumn if ((lineLength < wrapColumn)
&& event.length >= event.replacedText.length()) { && (event.length >= event.replacedText.length())) {
return; return;
} }
String NL = textEditorST.getLineDelimiter(); String NL = textEditorST.getLineDelimiter();
String line = textEditorST.getLine(lineNum) String line = textEditorST.getLine(lineNum)
+ ((lineNum + 1 < totalLines) ? NL : EMPTY); + (((lineNum + 1) < totalLines) ? NL : EMPTY);
lineLength = line.length(); lineLength = line.length();
if (NL.equals(line) || EMPTY.equals(line)) { if (NL.equals(line) || EMPTY.equals(line)) {
return; return;
@ -1148,14 +1149,14 @@ public class StyledTextComp extends Composite {
// check for locked text // check for locked text
StyleRange styleRange = textEditorST.getStyleRangeAtOffset(lineOff StyleRange styleRange = textEditorST.getStyleRangeAtOffset(lineOff
+ index); + index);
if (styleRange != null && styleRange.foreground == lockColor) { if ((styleRange != null) && (styleRange.foreground == lockColor)) {
return; return;
} }
// deal with programmatic changes distant from the cursor // deal with programmatic changes distant from the cursor
int eventCursor = cursorOffset; int eventCursor = cursorOffset;
if (eventCursor < event.start if ((eventCursor < event.start)
|| eventCursor > event.start + event.length) { || (eventCursor > (event.start + event.length))) {
eventCursor = event.start + event.length; eventCursor = event.start + event.length;
} }
@ -1233,7 +1234,7 @@ public class StyledTextComp extends Composite {
insertColor, lockColor }; insertColor, lockColor };
String[] labels = new String[] { "Background", "Foreground", "Frame", String[] labels = new String[] { "Background", "Foreground", "Frame",
"Insert", "Locked" }; "Insert", "Locked" };
for (int i = 0; i < colors.length - 1; i++) { for (int i = 0; i < (colors.length - 1); i++) {
for (int j = i + 1; j < colors.length; j++) { for (int j = i + 1; j < colors.length; j++) {
warnIfEqual(colors[i], colors[j], labels[i], labels[j]); warnIfEqual(colors[i], colors[j], labels[i], labels[j]);
} }
@ -1417,7 +1418,7 @@ public class StyledTextComp extends Composite {
lineCursorPos = 0; lineCursorPos = 0;
// remember last good endIndex // remember last good endIndex
endIndex = lineStartOffset + line.length() - 1; endIndex = (lineStartOffset + line.length()) - 1;
} }
if (endIndex < 0) { if (endIndex < 0) {
@ -1446,7 +1447,7 @@ public class StyledTextComp extends Composite {
// get the text from the caret to the end of the block // get the text from the caret to the end of the block
String post = ""; String post = "";
if (endIndex >= cursorIndex && cursorIndex < st.getCharCount()) { if ((endIndex >= cursorIndex) && (cursorIndex < st.getCharCount())) {
post = st.getText(cursorIndex, endIndex); post = st.getText(cursorIndex, endIndex);
} }
@ -1455,7 +1456,7 @@ public class StyledTextComp extends Composite {
if (cursorIndex > 0) { if (cursorIndex > 0) {
lchar = st.getTextRange(cursorIndex - 1, 1); lchar = st.getTextRange(cursorIndex - 1, 1);
char lchar0 = lchar.charAt(0); char lchar0 = lchar.charAt(0);
if (Character.isSpaceChar(lchar0) && lchar0 != NL.charAt(0)) { if (Character.isSpaceChar(lchar0) && (lchar0 != NL.charAt(0))) {
lchar = " "; lchar = " ";
} else { } else {
lchar = ""; lchar = "";
@ -1465,7 +1466,7 @@ public class StyledTextComp extends Composite {
String rchar = ""; String rchar = "";
if (post.length() > 0) { if (post.length() > 0) {
char post0 = post.charAt(0); char post0 = post.charAt(0);
if (Character.isSpaceChar(post0) && post0 != NL.charAt(0)) { if (Character.isSpaceChar(post0) && (post0 != NL.charAt(0))) {
rchar = " "; rchar = " ";
} }
} }
@ -1522,7 +1523,7 @@ public class StyledTextComp extends Composite {
post = post.replaceAll("^\\s*", ""); post = post.replaceAll("^\\s*", "");
String text = pre + rchar + post; String text = pre + rchar + post;
st.replaceTextRange(startIndex, 1 + endIndex - startIndex, text); st.replaceTextRange(startIndex, (1 + endIndex) - startIndex, text);
int newCaretOffset = startIndex + pre.length(); int newCaretOffset = startIndex + pre.length();
st.setCaretOffset(newCaretOffset); st.setCaretOffset(newCaretOffset);