Omaha #4018 Added logging of changes in GFE product editor. Additional code clean up.
Change-Id: Ifa188f6e465062b1cf16042c87bf1074814909a2 Former-commit-id:bdc365d9c9
[formerly 9d2f64b08acbec0567c7f29871480827ff0f6de7] Former-commit-id:346ea417ea
This commit is contained in:
parent
a00e04a8d7
commit
48c2f0e843
4 changed files with 118 additions and 97 deletions
|
@ -33,7 +33,7 @@
|
||||||
# Jul 10, 2014 #3363 bclement logs command used to launch application to console logs
|
# Jul 10, 2014 #3363 bclement logs command used to launch application to console logs
|
||||||
# Oct 10, 2014 #3675 njensen Logback now does console logging to ensure correct pid
|
# Oct 10, 2014 #3675 njensen Logback now does console logging to ensure correct pid
|
||||||
# Oct 13, 2014 #3675 bclement startup shutdown log includes both launching pid and placeholder
|
# Oct 13, 2014 #3675 bclement startup shutdown log includes both launching pid and placeholder
|
||||||
#
|
# Jan 28, 2015 #4018 randerso Added a productEditor log file to changes in the GFE product editor
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,6 +218,7 @@ curTime=`date +%Y%m%d_%H%M%S`
|
||||||
export LOGFILE_CAVE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_logs.log"
|
export LOGFILE_CAVE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_logs.log"
|
||||||
export LOGFILE_CONSOLE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_console.log"
|
export LOGFILE_CONSOLE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_console.log"
|
||||||
export LOGFILE_PERFORMANCE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_perf.log"
|
export LOGFILE_PERFORMANCE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_perf.log"
|
||||||
|
export LOGFILE_PRODUCT_EDITOR="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_productEditor.log"
|
||||||
|
|
||||||
# can we write to log directory
|
# can we write to log directory
|
||||||
if [ -w ${LOGDIR} ]; then
|
if [ -w ${LOGDIR} ]; then
|
||||||
|
|
|
@ -22,6 +22,7 @@ package com.raytheon.viz.gfe.dialogs.formatterlauncher;
|
||||||
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.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
|
@ -35,6 +36,7 @@ import org.eclipse.swt.graphics.Point;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 05 Jan 2008 1784 lvenable Initial creation
|
* 05 Jan 2008 1784 lvenable Initial creation
|
||||||
|
* 28 Jan 2015 4018 randerso Code cleanup
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -51,12 +53,12 @@ public class ProductDataStruct {
|
||||||
/**
|
/**
|
||||||
* HashMap of ci text index points.
|
* HashMap of ci text index points.
|
||||||
*/
|
*/
|
||||||
private HashMap<String, TextIndexPoints> ci;
|
private Map<String, TextIndexPoints> ci;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HashMap of mnd text index points.
|
* HashMap of mnd text index points.
|
||||||
*/
|
*/
|
||||||
private HashMap<String, TextIndexPoints> mnd;
|
private Map<String, TextIndexPoints> mnd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of segment data.
|
* Array of segment data.
|
||||||
|
@ -66,7 +68,7 @@ public class ProductDataStruct {
|
||||||
/**
|
/**
|
||||||
* Parsed map containing the parsed product text.
|
* Parsed map containing the parsed product text.
|
||||||
*/
|
*/
|
||||||
private HashMap<String, Object> parsedMap;
|
private Map<String, Object> parsedMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A String array containing the product text. Each element in the array is
|
* A String array containing the product text. Each element in the array is
|
||||||
|
@ -89,8 +91,7 @@ public class ProductDataStruct {
|
||||||
* @param productText
|
* @param productText
|
||||||
* Product text.
|
* Product text.
|
||||||
*/
|
*/
|
||||||
public ProductDataStruct(HashMap<String, Object> parsedMap,
|
public ProductDataStruct(Map<String, Object> parsedMap, String productText) {
|
||||||
String productText) {
|
|
||||||
this.parsedMap = parsedMap;
|
this.parsedMap = parsedMap;
|
||||||
|
|
||||||
this.productText = productText;
|
this.productText = productText;
|
||||||
|
@ -121,21 +122,20 @@ public class ProductDataStruct {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsedMap.get("frames") instanceof List == false) {
|
if ((parsedMap.get("frames") instanceof List) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
frames = new ArrayList<TextIndexPoints>();
|
frames = new ArrayList<TextIndexPoints>();
|
||||||
|
|
||||||
List<?> parseFrames = (List<?>) parsedMap.get("frames");
|
List<Map<String, List<List<Integer>>>> parseFrames = (List<Map<String, List<List<Integer>>>>) parsedMap
|
||||||
|
.get("frames");
|
||||||
for (Object object : parseFrames) {
|
|
||||||
HashMap frameMap = (HashMap) object;
|
|
||||||
|
|
||||||
|
for (Map<String, List<List<Integer>>> frameMap : parseFrames) {
|
||||||
Set<String> keys = frameMap.keySet();
|
Set<String> keys = frameMap.keySet();
|
||||||
|
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
List<?> frameIndexes = (List<?>) frameMap.get(key);
|
List<List<Integer>> frameIndexes = frameMap.get(key);
|
||||||
|
|
||||||
TextIndexPoints tip = createTextIndexPoints(frameIndexes);
|
TextIndexPoints tip = createTextIndexPoints(frameIndexes);
|
||||||
|
|
||||||
|
@ -156,15 +156,16 @@ public class ProductDataStruct {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<?> tmpArray;
|
List<List<Integer>> tmpArray;
|
||||||
TextIndexPoints tip;
|
TextIndexPoints tip;
|
||||||
|
|
||||||
HashMap parsedCi = (HashMap) parsedMap.get("ci");
|
Map<String, List<List<Integer>>> parsedCi = (Map<String, List<List<Integer>>>) parsedMap
|
||||||
|
.get("ci");
|
||||||
|
|
||||||
Set<String> keys = parsedCi.keySet();
|
Set<String> keys = parsedCi.keySet();
|
||||||
|
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
tmpArray = (List<?>) parsedCi.get(key);
|
tmpArray = parsedCi.get(key);
|
||||||
tip = createTextIndexPoints(tmpArray);
|
tip = createTextIndexPoints(tmpArray);
|
||||||
ci.put(key, tip);
|
ci.put(key, tip);
|
||||||
}
|
}
|
||||||
|
@ -181,19 +182,18 @@ public class ProductDataStruct {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<?> tmpArray;
|
List<List<Integer>> tmpArray;
|
||||||
TextIndexPoints tip;
|
TextIndexPoints tip;
|
||||||
|
|
||||||
HashMap parsedMnd = (HashMap) parsedMap.get("mnd");
|
Map<String, List<List<Integer>>> parsedMnd = (Map<String, List<List<Integer>>>) parsedMap
|
||||||
|
.get("mnd");
|
||||||
|
|
||||||
Set<String> keys = parsedMnd.keySet();
|
Set<String> keys = parsedMnd.keySet();
|
||||||
|
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
tmpArray = (List<?>) parsedMnd.get(key);
|
tmpArray = parsedMnd.get(key);
|
||||||
tip = createTextIndexPoints(tmpArray);
|
tip = createTextIndexPoints(tmpArray);
|
||||||
|
|
||||||
// TODO : remove
|
|
||||||
// System.out.println("mnd key = " + key + "\t\t" + tip.getText());
|
|
||||||
mnd.put(key, tip);
|
mnd.put(key, tip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,36 +210,36 @@ public class ProductDataStruct {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextIndexPoints tip;
|
TextIndexPoints tip;
|
||||||
List<?> tmpArray;
|
List<List<Integer>> tmpArray;
|
||||||
|
|
||||||
// Get the Array of segments from the parsed map.
|
// Get the Array of segments from the parsed map.
|
||||||
List<?> parsedSegs = (List<?>) parsedMap.get("segs");
|
List<Map<String, Object>> parsedSegs = (List<Map<String, Object>>) parsedMap
|
||||||
|
.get("segs");
|
||||||
|
|
||||||
// Loop through each segment.
|
// Loop through each segment.
|
||||||
for (Object seg : parsedSegs) {
|
for (Map<String, Object> curSegMap : parsedSegs) {
|
||||||
|
|
||||||
HashMap curSegMap = (HashMap) seg;
|
|
||||||
|
|
||||||
Set<String> keys = curSegMap.keySet();
|
Set<String> keys = curSegMap.keySet();
|
||||||
|
|
||||||
SegmentData segData = new SegmentData();
|
SegmentData segData = new SegmentData();
|
||||||
|
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
if (key.compareTo("headInfo") == 0) {
|
if (key.equals("headInfo")) {
|
||||||
List<?> headInfoArray = (List<?>) curSegMap.get(key);
|
List<Map<String, List<List<Integer>>>> headInfoArray = (List<Map<String, List<List<Integer>>>>) curSegMap
|
||||||
|
.get(key);
|
||||||
|
|
||||||
for (Object hiObj : headInfoArray) {
|
for (Object hiObj : headInfoArray) {
|
||||||
HashMap headInfoMap = (HashMap) hiObj;
|
Map<String, List<List<Integer>>> headInfoMap = (Map<String, List<List<Integer>>>) hiObj;
|
||||||
|
|
||||||
Set<String> headInfoKeys = headInfoMap.keySet();
|
Set<String> headInfoKeys = headInfoMap.keySet();
|
||||||
for (String hiKey : headInfoKeys) {
|
for (String hiKey : headInfoKeys) {
|
||||||
tmpArray = (List<?>) headInfoMap.get(hiKey);
|
tmpArray = headInfoMap.get(hiKey);
|
||||||
tip = createTextIndexPoints(tmpArray);
|
tip = createTextIndexPoints(tmpArray);
|
||||||
segData.addToHeadInfoMap(hiKey, tip);
|
segData.addToHeadInfoMap(hiKey, tip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tmpArray = (List<?>) curSegMap.get(key);
|
tmpArray = (List<List<Integer>>) curSegMap.get(key);
|
||||||
tip = createTextIndexPoints(tmpArray);
|
tip = createTextIndexPoints(tmpArray);
|
||||||
segData.addToSegmentMap(key, tip);
|
segData.addToSegmentMap(key, tip);
|
||||||
}
|
}
|
||||||
|
@ -256,19 +256,18 @@ public class ProductDataStruct {
|
||||||
* Array of indexes.
|
* Array of indexes.
|
||||||
* @return TextIndexPoint data.
|
* @return TextIndexPoint data.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
private TextIndexPoints createTextIndexPoints(List<List<Integer>> tmpArray) {
|
||||||
private TextIndexPoints createTextIndexPoints(List tmpArray) {
|
|
||||||
TextIndexPoints tip = new TextIndexPoints();
|
TextIndexPoints tip = new TextIndexPoints();
|
||||||
|
|
||||||
// Get the starting index
|
// Get the starting index
|
||||||
List<?> startPoints = (List<?>) tmpArray.get(0);
|
List<Integer> startPoints = tmpArray.get(0);
|
||||||
int startLine = ((Integer) startPoints.get(0)) - 1;
|
int startLine = (startPoints.get(0)) - 1;
|
||||||
int startCol = (Integer) startPoints.get(1);
|
int startCol = startPoints.get(1);
|
||||||
|
|
||||||
// Get the ending index
|
// Get the ending index
|
||||||
List<?> endPoints = (List<?>) tmpArray.get(1);
|
List<Integer> endPoints = tmpArray.get(1);
|
||||||
int endLine = ((Integer) endPoints.get(0)) - 1;
|
int endLine = (endPoints.get(0)) - 1;
|
||||||
int endCol = ((Integer) endPoints.get(1));
|
int endCol = (endPoints.get(1));
|
||||||
|
|
||||||
String text = getIndexString(startLine, startCol, endLine, endCol);
|
String text = getIndexString(startLine, startCol, endLine, endCol);
|
||||||
|
|
||||||
|
@ -320,7 +319,7 @@ public class ProductDataStruct {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
int endColOffset = 0;
|
int endColOffset = 0;
|
||||||
if (endCol - 1 == productTextArray[i].length()) {
|
if ((endCol - 1) == productTextArray[i].length()) {
|
||||||
endColOffset = -1;
|
endColOffset = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +362,7 @@ public class ProductDataStruct {
|
||||||
*
|
*
|
||||||
* @return The CI map.
|
* @return The CI map.
|
||||||
*/
|
*/
|
||||||
public HashMap<String, TextIndexPoints> getCiMap() {
|
public Map<String, TextIndexPoints> getCiMap() {
|
||||||
return ci;
|
return ci;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +371,7 @@ public class ProductDataStruct {
|
||||||
*
|
*
|
||||||
* @return The MND map.
|
* @return The MND map.
|
||||||
*/
|
*/
|
||||||
public HashMap<String, TextIndexPoints> getMndMap() {
|
public Map<String, TextIndexPoints> getMndMap() {
|
||||||
return mnd;
|
return mnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,72 +411,70 @@ public class ProductDataStruct {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void printData() {
|
public void printData() {
|
||||||
// System.out.println("**** PRINT START ********************************");
|
System.out.println("**** PRINT START ********************************");
|
||||||
// System.out.println("****");
|
System.out.println("****");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print the Frames information.
|
* Print the Frames information.
|
||||||
*/
|
*/
|
||||||
// System.out.println("");
|
System.out.println("");
|
||||||
// System.out.println("--- frames");
|
System.out.println("--- frames");
|
||||||
for (TextIndexPoints frameData : frames) {
|
for (TextIndexPoints frameData : frames) {
|
||||||
// System.out.println("frame text = " + frameData.getText());
|
System.out.println("frame text = " + frameData.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print the CI information.
|
* Print the CI information.
|
||||||
*/
|
*/
|
||||||
// System.out.println("");
|
System.out.println("");
|
||||||
// System.out.println("--- ci");
|
System.out.println("--- ci");
|
||||||
Set<String> ciKeys = ci.keySet();
|
Set<String> ciKeys = ci.keySet();
|
||||||
|
|
||||||
for (String key : ciKeys) {
|
for (String key : ciKeys) {
|
||||||
// System.out.println("key = " + key);
|
System.out.println("key = " + key);
|
||||||
// System.out.println("text = " + ci.get(key).getText());
|
System.out.println("text = " + ci.get(key).getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print the MND information.
|
* Print the MND information.
|
||||||
*/
|
*/
|
||||||
// System.out.println("");
|
System.out.println("");
|
||||||
// System.out.println("--- mnd");
|
System.out.println("--- mnd");
|
||||||
Set<String> mndKeys = mnd.keySet();
|
Set<String> mndKeys = mnd.keySet();
|
||||||
|
|
||||||
for (String key : mndKeys) {
|
for (String key : mndKeys) {
|
||||||
// System.out.println("key = " + key);
|
System.out.println("key = " + key);
|
||||||
// System.out.println("text = " + mnd.get(key).getText());
|
System.out.println("text = " + mnd.get(key).getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print the Segments information.
|
* Print the Segments information.
|
||||||
*/
|
*/
|
||||||
// System.out.println("");
|
System.out.println("");
|
||||||
// System.out.println("--- segments");
|
System.out.println("--- segments");
|
||||||
for (SegmentData segData : segments) {
|
for (SegmentData segData : segments) {
|
||||||
// System.out.println("++++++ segment map");
|
System.out.println("++++++ segment map");
|
||||||
HashMap<String, TextIndexPoints> segMap = segData.getSementMap();
|
Map<String, TextIndexPoints> segMap = segData.getSementMap();
|
||||||
|
|
||||||
Set<String> segMapKeys = segMap.keySet();
|
Set<String> segMapKeys = segMap.keySet();
|
||||||
for (String segMapKey : segMapKeys) {
|
for (String segMapKey : segMapKeys) {
|
||||||
// TextIndexPoints tip = segMap.get(segMapKey);
|
TextIndexPoints tip = segMap.get(segMapKey);
|
||||||
// System.out.println("SegMapKey = " + segMapKey);
|
System.out.println("SegMapKey = " + segMapKey);
|
||||||
// System.out.println("Text = " +
|
System.out.println("Text = " + segMap.get(segMapKey).getText());
|
||||||
// segMap.get(segMapKey).getText());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// System.out.println("++++++ headinfo map");
|
System.out.println("++++++ headinfo map");
|
||||||
HashMap<String, TextIndexPoints> headInfoMap = segData
|
Map<String, TextIndexPoints> headInfoMap = segData.getHeadInfoMap();
|
||||||
.getHeadInfoMap();
|
|
||||||
|
|
||||||
Set<String> headInfoKeys = headInfoMap.keySet();
|
Set<String> headInfoKeys = headInfoMap.keySet();
|
||||||
for (String headInfoKey : headInfoKeys) {
|
for (String headInfoKey : headInfoKeys) {
|
||||||
// System.out.println("headInfoKey = " + headInfoKey);
|
System.out.println("headInfoKey = " + headInfoKey);
|
||||||
// System.out.println("Text = "
|
System.out.println("Text = "
|
||||||
// + headInfoMap.get(headInfoKey).getText());
|
+ headInfoMap.get(headInfoKey).getText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// System.out.println("**** PRINT END **********************************");
|
System.out.println("**** PRINT END **********************************");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWmoId() {
|
public String getWmoId() {
|
||||||
|
@ -505,7 +502,7 @@ public class ProductDataStruct {
|
||||||
return mnd.get("pline");
|
return mnd.get("pline");
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextIndexPoints getFunnyFiled() {
|
public TextIndexPoints getFunnyField() {
|
||||||
return ci.get("funnyfield");
|
return ci.get("funnyfield");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,8 +532,9 @@ public class ProductDataStruct {
|
||||||
int column = 0;
|
int column = 0;
|
||||||
for (line = 0; line < productTextArray.length; line++) {
|
for (line = 0; line < productTextArray.length; line++) {
|
||||||
int llen = productTextArray[line].length() + 1;
|
int llen = productTextArray[line].length() + 1;
|
||||||
if (offset < llen)
|
if (offset < llen) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
offset -= llen;
|
offset -= llen;
|
||||||
}
|
}
|
||||||
column = offset;
|
column = offset;
|
||||||
|
|
|
@ -163,7 +163,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
* 12/01/2014 #624 zhao Modified saveFile()
|
* 12/01/2014 #624 zhao Modified saveFile()
|
||||||
* 12/16/2014 #14946 ryu Modified updateIssueExpireTimes() so issuance time is displayed
|
* 12/16/2014 #14946 ryu Modified updateIssueExpireTimes() so issuance time is displayed
|
||||||
* for the local time zones for each segment.
|
* for the local time zones for each segment.
|
||||||
*
|
* 01/28/2015 #4018 randerso Code cleanup.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author lvenable
|
* @author lvenable
|
||||||
|
@ -957,10 +957,7 @@ public class ProductEditorComp extends Composite implements
|
||||||
*/
|
*/
|
||||||
private void createTextControl() {
|
private void createTextControl() {
|
||||||
|
|
||||||
textComp = new StyledTextComp(this);
|
textComp = new StyledTextComp(this, wrapColumn, wrapMode);
|
||||||
textComp.setWrapColumn(wrapColumn);
|
|
||||||
|
|
||||||
textComp.setAutoWrapMode(wrapMode);
|
|
||||||
|
|
||||||
createEditorPopupMenu();
|
createEditorPopupMenu();
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ import org.eclipse.swt.widgets.Listener;
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
|
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
|
||||||
import com.raytheon.uf.common.python.PythonScript;
|
import com.raytheon.uf.common.python.PythonScript;
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
|
import com.raytheon.uf.common.status.ProductEditorLogger;
|
||||||
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.viz.core.RGBColors;
|
import com.raytheon.uf.viz.core.RGBColors;
|
||||||
|
@ -84,6 +85,9 @@ import com.raytheon.viz.gfe.textformatter.TextFmtParserUtil;
|
||||||
* 29 AUG 2013 #2250 dgilling Better error handling for parseProductText().
|
* 29 AUG 2013 #2250 dgilling Better error handling for parseProductText().
|
||||||
* 04 SEP 2013 16534 ryu Fixed word wrap to not insert duplicate text; refactor.
|
* 04 SEP 2013 16534 ryu Fixed word wrap to not insert duplicate text; refactor.
|
||||||
* 20 DEC 2013 16854 ryu Force re-parsing of text on type change.
|
* 20 DEC 2013 16854 ryu Force re-parsing of text on type change.
|
||||||
|
* 28 JAN 2015 4018 randerso Code cleanup. Fixed reparsing when framing codes are cut
|
||||||
|
* or pasted instead of just typed over.
|
||||||
|
* Added logging of text changes to help diagnose future issues.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -124,7 +128,7 @@ public class StyledTextComp extends Composite {
|
||||||
/**
|
/**
|
||||||
* Parent composite.
|
* Parent composite.
|
||||||
*/
|
*/
|
||||||
private Composite parent;
|
private ProductEditorComp parent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Styled text editor.
|
* Styled text editor.
|
||||||
|
@ -157,7 +161,7 @@ public class StyledTextComp extends Composite {
|
||||||
|
|
||||||
private boolean autoWrapMode;
|
private boolean autoWrapMode;
|
||||||
|
|
||||||
private int wrapColumn = 80; // TODO: get from external
|
private int wrapColumn;
|
||||||
|
|
||||||
private boolean dirty = false;
|
private boolean dirty = false;
|
||||||
|
|
||||||
|
@ -175,6 +179,8 @@ public class StyledTextComp extends Composite {
|
||||||
|
|
||||||
private boolean updatingForCor = false;
|
private boolean updatingForCor = false;
|
||||||
|
|
||||||
|
private ProductEditorLogger peLog;
|
||||||
|
|
||||||
private static final String NORM_SEP = "^\\s*$";
|
private static final String NORM_SEP = "^\\s*$";
|
||||||
|
|
||||||
private static final String FUNNY_SEP = "^(\\s*)\\*(\\s*)";
|
private static final String FUNNY_SEP = "^(\\s*)\\*(\\s*)";
|
||||||
|
@ -197,11 +203,18 @@ public class StyledTextComp extends Composite {
|
||||||
*
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
* Parent composite.
|
* Parent composite.
|
||||||
|
* @param wrapMode
|
||||||
|
* @param wrapColumn
|
||||||
*/
|
*/
|
||||||
public StyledTextComp(Composite parent) {
|
public StyledTextComp(ProductEditorComp parent, int wrapColumn,
|
||||||
|
boolean wrapMode) {
|
||||||
super(parent, SWT.BORDER);
|
super(parent, SWT.BORDER);
|
||||||
|
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
this.wrapColumn = wrapColumn;
|
||||||
|
this.autoWrapMode = wrapMode;
|
||||||
|
|
||||||
|
this.peLog = new ProductEditorLogger(parent.getProductName());
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -294,6 +307,7 @@ public class StyledTextComp extends Composite {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyText(ExtendedModifyEvent event) {
|
public void modifyText(ExtendedModifyEvent event) {
|
||||||
|
logTextChange(event);
|
||||||
updateTextStyle(event);
|
updateTextStyle(event);
|
||||||
checkAutoWrap(event);
|
checkAutoWrap(event);
|
||||||
|
|
||||||
|
@ -362,7 +376,7 @@ public class StyledTextComp extends Composite {
|
||||||
/*
|
/*
|
||||||
* Lock the ci block text.
|
* Lock the ci block text.
|
||||||
*/
|
*/
|
||||||
HashMap<String, TextIndexPoints> ciMap = prodDataStruct.getCiMap();
|
Map<String, TextIndexPoints> ciMap = prodDataStruct.getCiMap();
|
||||||
TextIndexPoints ciBlockTip = ciMap.get("ciblock");
|
TextIndexPoints ciBlockTip = ciMap.get("ciblock");
|
||||||
|
|
||||||
if (ciBlockTip != null) {
|
if (ciBlockTip != null) {
|
||||||
|
@ -374,7 +388,7 @@ public class StyledTextComp extends Composite {
|
||||||
/*
|
/*
|
||||||
* Lock the mnd text.
|
* Lock the mnd text.
|
||||||
*/
|
*/
|
||||||
HashMap<String, TextIndexPoints> mndMap = prodDataStruct.getMndMap();
|
Map<String, TextIndexPoints> mndMap = prodDataStruct.getMndMap();
|
||||||
TextIndexPoints mndTip = mndMap.get("mnd");
|
TextIndexPoints mndTip = mndMap.get("mnd");
|
||||||
|
|
||||||
if (mndTip != null) {
|
if (mndTip != null) {
|
||||||
|
@ -502,11 +516,11 @@ public class StyledTextComp extends Composite {
|
||||||
* If python throws an Error trying to parse the product.
|
* If python throws an Error trying to parse the product.
|
||||||
*/
|
*/
|
||||||
private void parseProductText(String productText) throws JepException {
|
private void parseProductText(String productText) throws JepException {
|
||||||
HashMap<String, Object> fmtResult = TextFmtParserUtil
|
Map<String, Object> fmtResult = TextFmtParserUtil
|
||||||
.parseText(productText);
|
.parseText(productText);
|
||||||
prodDataStruct = new ProductDataStruct(fmtResult, productText);
|
prodDataStruct = new ProductDataStruct(fmtResult, productText);
|
||||||
|
|
||||||
prodDataStruct.printData();
|
// prodDataStruct.printData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void patchMND(String tag) {
|
public void patchMND(String tag) {
|
||||||
|
@ -565,7 +579,7 @@ public class StyledTextComp extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the code and the pit
|
// Find the code and the pit
|
||||||
TextIndexPoints ff = prodDataStruct.getFunnyFiled();
|
TextIndexPoints ff = prodDataStruct.getFunnyField();
|
||||||
TextIndexPoints pit = prodDataStruct.getPIT();
|
TextIndexPoints pit = prodDataStruct.getPIT();
|
||||||
|
|
||||||
if (ff == null) {
|
if (ff == null) {
|
||||||
|
@ -620,7 +634,7 @@ public class StyledTextComp extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeCorrections() {
|
private void makeCorrections() {
|
||||||
((ProductEditorComp) parent).setPTypeCategory(PTypeCategory.COR);
|
parent.setPTypeCategory(PTypeCategory.COR);
|
||||||
List<SegmentData> segs = prodDataStruct.getSegmentsArray();
|
List<SegmentData> segs = prodDataStruct.getSegmentsArray();
|
||||||
for (SegmentData seg : segs) {
|
for (SegmentData seg : segs) {
|
||||||
if (seg.getSementMap().keySet().contains("vtec")) {
|
if (seg.getSementMap().keySet().contains("vtec")) {
|
||||||
|
@ -642,8 +656,7 @@ public class StyledTextComp extends Composite {
|
||||||
int offset = textEditorST.getCaretOffset();
|
int offset = textEditorST.getCaretOffset();
|
||||||
Pattern codePattern = Pattern.compile("\\.([A-Z]{3})\\.");
|
Pattern codePattern = Pattern.compile("\\.([A-Z]{3})\\.");
|
||||||
for (SegmentData segData : segs) {
|
for (SegmentData segData : segs) {
|
||||||
HashMap<String, TextIndexPoints> segMap = segData
|
Map<String, TextIndexPoints> segMap = segData.getSementMap();
|
||||||
.getSementMap();
|
|
||||||
TextIndexPoints tipUgc = segMap.get("ugc");
|
TextIndexPoints tipUgc = segMap.get("ugc");
|
||||||
int start = prodDataStruct.positionToOffset(tipUgc
|
int start = prodDataStruct.positionToOffset(tipUgc
|
||||||
.getStartIndex());
|
.getStartIndex());
|
||||||
|
@ -697,8 +710,10 @@ public class StyledTextComp extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the verify key event. This event fires after a change has been
|
* Handle the verify key event. Sent when the text is about to be modified.
|
||||||
* made to the control (after the text has been updated, for example)
|
* A verify event occurs after the user has done something to modify the
|
||||||
|
* text (typically typed a key), but before the text is modified. The doit
|
||||||
|
* field in the verify event indicates whether or not to modify the text.
|
||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
* Verify event that was fired.
|
* Verify event that was fired.
|
||||||
|
@ -754,10 +769,6 @@ public class StyledTextComp extends Composite {
|
||||||
+ event.length + 1);
|
+ event.length + 1);
|
||||||
StyleRange startRange = textEditorST.getStyleRangeAtOffset(start);
|
StyleRange startRange = textEditorST.getStyleRangeAtOffset(start);
|
||||||
StyleRange endRange = textEditorST.getStyleRangeAtOffset(end);
|
StyleRange endRange = textEditorST.getStyleRangeAtOffset(end);
|
||||||
// StyleRange startRange = textEditorST
|
|
||||||
// .getStyleRangeAtOffset(event.start - 1);
|
|
||||||
// StyleRange endRange = textEditorST
|
|
||||||
// .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)
|
||||||
|
@ -773,13 +784,14 @@ public class StyledTextComp extends Composite {
|
||||||
|
|
||||||
// framing code was deleted, need to turn it black
|
// framing code was deleted, need to turn it black
|
||||||
boolean framingCodeChange = false;
|
boolean framingCodeChange = false;
|
||||||
if (("*").equals(event.replacedText)
|
if (event.replacedText.contains("*")
|
||||||
|| ("|").equals(event.replacedText)) {
|
|| event.replacedText.contains("|")) {
|
||||||
framingCodeChange = true;
|
framingCodeChange = true;
|
||||||
}
|
}
|
||||||
// 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);
|
String newText = textEditorST.getText().substring(event.start,
|
||||||
if ((newText == '*') || (newText == '|')) {
|
event.start + event.length);
|
||||||
|
if (newText.contains("*") || newText.contains("|")) {
|
||||||
framingCodeChange = true;
|
framingCodeChange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1530,4 +1542,17 @@ public class StyledTextComp extends Composite {
|
||||||
return new int[] { startIndex, endIndex, text.length() };
|
return new int[] { startIndex, endIndex, text.length() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void logTextChange(ExtendedModifyEvent event) {
|
||||||
|
StyledText st = ((StyledText) event.widget);
|
||||||
|
String oldText = event.replacedText;
|
||||||
|
String newText = "";
|
||||||
|
if (event.length > 0) {
|
||||||
|
newText = st.getText(event.start, (event.start + event.length) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!newText.equals(oldText)) {
|
||||||
|
peLog.logEdit(event.start, oldText, newText);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue