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

@ -26,7 +26,7 @@ package com.raytheon.viz.gfe.dialogs.formatterlauncher;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 18 APR 2008 ### lvenable Initial creation
* 18 APR 2008 ### lvenable Initial creation
*
* </pre>
*

View file

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

View file

@ -26,7 +26,7 @@ package com.raytheon.viz.gfe.dialogs.formatterlauncher;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 18 APR 2008 ### lvenable Initial creation
* 18 APR 2008 ### lvenable Initial creation
*
* </pre>
*

View file

@ -23,19 +23,18 @@ package com.raytheon.viz.gfe.dialogs.formatterlauncher;
* Interface used for sending status of transmitted products.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 22, 2010 #2861 lvenable Initial creation
*
*
* </pre>
*
*
* @author lvenable
* @version 1.0
*/
public interface ITransmissionState
{
public interface ITransmissionState {
void setTransmissionState(ConfigData.productStateEnum state);
}

View file

@ -125,7 +125,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 18 APR 2008 ### lvenable Initial creation
* 19 JAN 2010 4085 ryu Save and load draft
@ -2015,8 +2015,7 @@ public class ProductEditorComp extends Composite implements
if (pds != null) {
String officeTimeZone = dm.getParmManager()
.compositeGridLocation()
.getTimeZone();
.compositeGridLocation().getTimeZone();
int numSegments = pds.getSegmentsArray().size();
SimpleDateFormat fmt = new SimpleDateFormat(longLocalFmtStr);
fmt.setTimeZone(localTimeZone);
@ -2025,8 +2024,7 @@ public class ProductEditorComp extends Composite implements
for (int i = 0; i < numSegments; i++) {
textComp.startUpdate();
HashMap<String, TextIndexPoints> segMap = pds
.getSegmentsArray()
.get(i).getSementMap();
.getSegmentsArray().get(i).getSementMap();
TextIndexPoints tip = segMap.get("purgeT");
if (tip != null) {
@ -2046,10 +2044,10 @@ public class ProductEditorComp extends Composite implements
// vtecs are fixed length and this is variable length,
// which ensures we only need to reParse() once per
// segment
List<String> zones = decodeUGCs(pds.getSegmentsArray().get(i));
List<String> zones = decodeUGCs(pds.getSegmentsArray()
.get(i));
List<String> timeZones = dm.getTextProductMgr()
.getTimeZones(zones,
officeTimeZone);
.getTimeZones(zones, officeTimeZone);
StringBuilder sb = new StringBuilder();
for (String tz : timeZones) {
@ -2254,18 +2252,18 @@ public class ProductEditorComp extends Composite implements
* Save the current text in the product editor to a file.
*/
private void saveFile() {
String fname = null;
if ( productDefinition.get("outputFile") != null ) {
fname = getDefString("outputFile");
if ( fname.equals(EMPTY) ) {
if (productDefinition.get("outputFile") != null) {
fname = getDefString("outputFile");
if (fname.equals(EMPTY)) {
return;
}
} else {
return;
}
fname = fixfname(fname);
FileDialog fd = new FileDialog(parent.getShell(), SWT.SAVE);
fd.setText("Save As");
String filePath = (new File(fname)).getParentFile().getPath();

View file

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

View file

@ -36,7 +36,7 @@ import com.raytheon.viz.gfe.core.DataManager;
* ------------ ---------- ----------- --------------------------
* 18 APR 2008 ### lvenable Initial creation
* 20 AUG 2010 4687 cjeanbap &quot;null&quot; showed up in
* countdown message.
* countdown message.
*
* </pre>
*
@ -45,182 +45,181 @@ import com.raytheon.viz.gfe.core.DataManager;
*
*/
public class StoreTransmitCountdownThread extends Thread {
/**
* Parent display.
*/
private Display display;
/**
* Parent display.
*/
private Display display;
/**
* Progress bar to be updated.
*/
private ProgressBar progressBar;
/**
* Progress bar to be updated.
*/
private ProgressBar progressBar;
/**
* Flag indicating if the thread is done running.
*/
private boolean isDone = false;
/**
* Flag indicating if the thread is done running.
*/
private boolean isDone = false;
/**
* Flag indicating if the thread has been canceled.
*/
private boolean isCancelled = false;
/**
* Flag indicating if the thread has been canceled.
*/
private boolean isCancelled = false;
/**
* Count down label.
*/
private Label countdownLbl;
/**
* Count down label.
*/
private Label countdownLbl;
/**
* Count down string.
*/
private String countdownStr;
/**
* Count down string.
*/
private String countdownStr;
/**
* Counter.
*/
private int counter = 5;
/**
* Counter.
*/
private int counter = 5;
/**
* Store/Transmit callback.
*/
private IStoreTransmitProduct storeCB;
/**
* Store/Transmit callback.
*/
private IStoreTransmitProduct storeCB;
/**
* Count down prefix string.
*/
private String countdownPrefix;
/**
* Count down prefix string.
*/
private String countdownPrefix;
/**
* Constructor.
*
* @param display
* Parent display.
* @param progressBar
* Progress bar.
* @param countdownLbl
* Count down label.
* @param countdownStr
* Count down string.
* @param cb
* Callback interface.
* @param isStore
* True to display store, false to display transmit.
*/
public StoreTransmitCountdownThread(Display display,
ProgressBar progressBar, Label countdownLbl, String countdownStr,
IStoreTransmitProduct cb, boolean isStore) {
this.display = display;
this.progressBar = progressBar;
this.countdownLbl = countdownLbl;
this.countdownStr = countdownStr;
this.storeCB = cb;
countdownPrefix = new String();
CAVEMode opMode = DataManager.getCurrentInstance().getOpMode();
if (!opMode.equals(CAVEMode.OPERATIONAL)) {
countdownPrefix = "Simulated ";
}
if (isStore == true) {
countdownPrefix += "Store in ";
} else {
countdownPrefix += "Transmit in ";
}
}
/**
* Constructor.
*
* @param display
* Parent display.
* @param progressBar
* Progress bar.
* @param countdownLbl
* Count down label.
* @param countdownStr
* Count down string.
* @param cb
* Callback interface.
* @param isStore
* True to display store, false to display transmit.
*/
public StoreTransmitCountdownThread(Display display,
ProgressBar progressBar, Label countdownLbl, String countdownStr,
IStoreTransmitProduct cb, boolean isStore) {
this.display = display;
this.progressBar = progressBar;
this.countdownLbl = countdownLbl;
this.countdownStr = countdownStr;
this.storeCB = cb;
countdownPrefix = new String();
CAVEMode opMode = DataManager.getCurrentInstance().getOpMode();
if (!opMode.equals(CAVEMode.OPERATIONAL)) {
countdownPrefix = "Simulated ";
}
if (isStore == true) {
countdownPrefix += "Store in ";
} else {
countdownPrefix += "Transmit in ";
}
}
/**
* Thread's run method.
*/
@Override
public void run() {
isDone = false;
countdownLabelStart();
/**
* Thread's run method.
*/
@Override
public void run() {
isDone = false;
countdownLabelStart();
for (int i = 0; i < 6; i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
for (int i = 0; i < 6; i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (isCancelled == false) {
display.asyncExec(new Runnable() {
public void run() {
if (progressBar.isDisposed()) {
return;
}
// Increment the progress bar
progressBar
.setSelection(progressBar.getSelection() + 1);
countdownLbl.setText(countdownPrefix + counter
+ " seconds...");
--counter;
}
});
} else {
break;
}
}
if (isCancelled == false) {
display.asyncExec(new Runnable() {
public void run() {
if (progressBar.isDisposed()) {
return;
}
// Increment the progress bar
progressBar.setSelection(progressBar.getSelection() + 1);
countdownLbl.setText(countdownPrefix + counter
+ " seconds...");
--counter;
}
});
} else {
break;
}
}
if (isCancelled == false) {
countdownLabelFinished();
}
if (isCancelled == false) {
countdownLabelFinished();
}
isDone = true;
isDone = true;
storeCB.storeTransmitProduct();
}
storeCB.storeTransmitProduct();
}
/**
* Check if the thread is done running.
*
* @return True if the thread is done running, false if it is still running.
*/
public boolean isDone() {
return isDone;
}
/**
* Check if the thread is done running.
*
* @return True if the thread is done running, false if it is still running.
*/
public boolean isDone() {
return isDone;
}
/**
* Cancel the running thread.
*/
public void cancelThread() {
isCancelled = true;
}
/**
* Cancel the running thread.
*/
public void cancelThread() {
isCancelled = true;
}
/**
* Check if the thread has been canceled.
*
* @return True if the thread was canceled, false otherwise.
*/
public boolean threadCancelled() {
return isCancelled;
}
/**
* Check if the thread has been canceled.
*
* @return True if the thread was canceled, false otherwise.
*/
public boolean threadCancelled() {
return isCancelled;
}
/**
* Set the count down label to have a red background and white text while
* the Store/Transmit is in count down mode.
*/
private void countdownLabelStart() {
display.asyncExec(new Runnable() {
public void run() {
countdownLbl.setBackground(display
.getSystemColor(SWT.COLOR_RED));
countdownLbl.setForeground(display
.getSystemColor(SWT.COLOR_WHITE));
}
});
}
/**
* Set the count down label to have a red background and white text while
* the Store/Transmit is in count down mode.
*/
private void countdownLabelStart() {
display.asyncExec(new Runnable() {
public void run() {
countdownLbl.setBackground(display
.getSystemColor(SWT.COLOR_RED));
countdownLbl.setForeground(display
.getSystemColor(SWT.COLOR_WHITE));
}
});
}
/**
* Set the count down label back to its original state.
*/
private void countdownLabelFinished() {
display.asyncExec(new Runnable() {
public void run() {
countdownLbl.setText(countdownStr);
countdownLbl.setBackground(display
.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
countdownLbl.setForeground(display
.getSystemColor(SWT.COLOR_BLACK));
}
});
}
/**
* Set the count down label back to its original state.
*/
private void countdownLabelFinished() {
display.asyncExec(new Runnable() {
public void run() {
countdownLbl.setText(countdownStr);
countdownLbl.setBackground(display
.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
countdownLbl.setForeground(display
.getSystemColor(SWT.COLOR_BLACK));
}
});
}
}

View file

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