ASM #13753 GFE: Incorrect time for products prepared by Product Editor/Make Correction

Change-Id: I4ca0cce5c19ddf6616f1766db4b8e7122374adc9

Former-commit-id: 3350419c4eb30891bb1ca847b99efce69116bc80
This commit is contained in:
Ying-Lian.Shi 2015-08-11 12:40:09 +00:00
parent bbb48e8551
commit 4850fb93a6
2 changed files with 97 additions and 98 deletions

View file

@ -1,19 +1,19 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
@ -122,10 +122,10 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
/**
* Composite containing the product editor controls.
*
*
* <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
@ -146,8 +146,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Changes for non-blocking StoreTransmitDlg.
* Changes for non-blocking WrapLengthDialog.
* 08 Feb 2013 12851 jzeng Add menuToAddTo in create*Menu
* Create createEditorPopupMenu()
* Add mouselistener in createTextControl() for StyledText
* Create createEditorPopupMenu()
* Add mouselistener in createTextControl() for StyledText
* 28 Feb 2013 15889 ryu Removed detachAttributionPhrase and getVTECActionCodes
* 02/12/2013 #1597 randerso Code cleanup. Fixed possible widget disposed errors on shut down.
* 05/08/2013 #1842 dgilling Add alternate setProductText(), fix
@ -167,13 +167,14 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* 02/04/2014 17039 ryu Removed menu item related to the HighlighFramingCodes feature.
* 04/20/2015 4027 randerso Renamed ProductStateEnum with an initial capital
* Expunged Calendar from ActiveTableRecord
* 07/02/2015 13753 lshi Update times for products in Product Editor
* 07/22/2015 13753 lshi Keeps issue time unchanged
* 07/02/2015 13753 lshi Update times for products in Product Editor
* 07/22/2015 13753 lshi Keeps issue time unchanged
* 08/06/2015 13753 lshi removed updateTime flag, undo the change of updateIssueExpireTimes, etc.
* </pre>
*
*
* @author lvenable
* @version 1.0
*
*
*/
public class ProductEditorComp extends Composite implements
INotificationObserver {
@ -185,7 +186,7 @@ public class ProductEditorComp extends Composite implements
/**
* Parent composite.
*/
private Composite parent;
private final Composite parent;
/**
* Toolbar used to mimic a menu bar.
@ -289,7 +290,7 @@ public class ProductEditorComp extends Composite implements
/**
* Date & time formatter.
*/
private SimpleDateFormat expireLabelFmt = new SimpleDateFormat(
private final SimpleDateFormat expireLabelFmt = new SimpleDateFormat(
"HH:mm'Z' dd-MMM-yy");
/**
@ -311,9 +312,9 @@ public class ProductEditorComp extends Composite implements
private ProductDefinition productDefinition;
private String productName;
private final String productName;
private boolean editorCorrectionMode;
private final boolean editorCorrectionMode;
private boolean testVTEC;
@ -355,7 +356,7 @@ public class ProductEditorComp extends Composite implements
* Product transmission callback to report the state of transmitting a
* product.
*/
private ITransmissionState transmissionCB;
private final ITransmissionState transmissionCB;
private final SimpleDateFormat purgeTimeFmt = new SimpleDateFormat("ddHHmm");
@ -374,12 +375,12 @@ public class ProductEditorComp extends Composite implements
*/
private ChangeTimesJob timeUpdater;
private Listener visibilityListener;
private final Listener visibilityListener;
/**
* Enumeration of product types.
*
*
* @author lvenable
*/
public enum productTypeEnum {
@ -423,12 +424,10 @@ public class ProductEditorComp extends Composite implements
private String prodEditorDirectory = null;
private final DataManager dm;
private boolean updateTime = false;
/**
* Constructor.
*
*
* @param parent
* Parent composite.
*/
@ -1080,7 +1079,7 @@ public class ProductEditorComp extends Composite implements
/**
* Store or Transmit text product.
*
*
* @param action
* STORE: show the Store dialog TRANSMITT: shows the Transmit
* dialog. AUTOSTORE: implement autoStore
@ -1191,16 +1190,14 @@ public class ProductEditorComp extends Composite implements
return true;
}
private synchronized boolean changeTimes() {
private boolean changeTimes() {
Calendar GMT = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
GMT.setTime(SimulatedTime.getSystemTime().getTime());
GMT.set(Calendar.SECOND, 0);
Date tt = GMT.getTime();
updateTime = true;
tweakVTEC(tt);
updateIssueExpireTimes(tt);
updateTime = false;
return true;
}
@ -1538,7 +1535,7 @@ public class ProductEditorComp extends Composite implements
/**
* Decodes the start and end times of VTEC, return null if all zeros.
*
*
* @param vt
* The VTEC date string in "yyMMdd'T'HHmm'Z'" format
* @return Date object that corresponds to the specified VTEC time or null
@ -1706,6 +1703,7 @@ public class ProductEditorComp extends Composite implements
textComp.startUpdate();
textComp.patchMND(txt, true);
textComp.updatePType(val);
textComp.endUpdate();
}
@ -1866,7 +1864,7 @@ public class ProductEditorComp extends Composite implements
/**
* Returns a Date from an encoded YYMMDD and hhmm string. Function name is a
* misnomer, but kept from porting AWIPS1 equivalent function.
*
*
* @param day
* The "calendar day" of the time in Java's "yyMMdd" format.
* @param time
@ -1890,7 +1888,7 @@ public class ProductEditorComp extends Composite implements
/**
* Convert time string in DDHHMM format to a Date.
*
*
* @param dtgString
* time string in DDHHMM format
* @return time converted from input string
@ -1965,29 +1963,34 @@ public class ProductEditorComp extends Composite implements
// I know this time string has been replaced. If the lengths of the
// before and after strings are different, a reParse() will be made,
// else it will continue on.
if (textComp != null) {
// Update Issue time -- removed
// Update MND time
// Update Issue time
try {
textComp.startUpdate();
ProductDataStruct pds = textComp.getProductDataStruct();
if (pds != null) {
TextIndexPoints tip = pds.getMndMap().get("nwstime");
if (tip != null) {
SimpleDateFormat fmt = new SimpleDateFormat(
longLocalFmtStr);
fmt.setTimeZone(localTimeZone);
String issueTime = fmt.format(now).toUpperCase();
if (tip != null) {
textComp.replaceText(tip, issueTime);
if (!textComp.isCorMode()) {
if (pds != null) {
TextIndexPoints pit = pds.getPIT();
if (pit != null) {
String time = purgeTimeFmt.format(now);
textComp.replaceText(pit, time);
}
}
}
// Update MND time
TextIndexPoints tip = pds.getMndMap().get("nwstime");
if (tip != null) {
SimpleDateFormat fmt = new SimpleDateFormat(
longLocalFmtStr);
fmt.setTimeZone(localTimeZone);
String issueTime = fmt.format(now).toUpperCase();
if (tip != null) {
textComp.replaceText(tip, issueTime);
}
}
} finally {
textComp.endUpdate();
}
@ -1998,8 +2001,8 @@ public class ProductEditorComp extends Composite implements
// StyledTextComp to re-evaluate whether a reParse() is needed and
// ask it for the segment information each time through the loop (in
// case we're at one of the 4 transition points).
// Update segments' time
// Update segments' time
try {
ProductDataStruct pds = textComp.getProductDataStruct();
@ -2011,7 +2014,7 @@ public class ProductEditorComp extends Composite implements
fmt.setTimeZone(localTimeZone);
String officeIssueTime = fmt.format(now).toUpperCase();
for (int i = 0; i < numSegments; i++) {
textComp.startUpdate();
HashMap<String, TextIndexPoints> segMap = pds
@ -2080,14 +2083,14 @@ public class ProductEditorComp extends Composite implements
* returns the appropriate expiration time. Expiration time is the earliest
* of the specified expiration time, 1 hr if a CAN code is detected, or the
* ending time of ongoing events (CON, EXT, EXB, NEW).
*
*
* @param issTime
* issue time
* @param expTime
* expire time
* @param vtecStr
* vtec string
*
*
* @return expire time
*/
public Date getExpireTime(Date issTime, Date expTime, String vtecStr) {
@ -2170,6 +2173,8 @@ public class ProductEditorComp extends Composite implements
*/
private void loadPrevious() {
String initialValue;
textComp.setCorMode(true);
if (!testVTEC) {
initialValue = "cccnnnxxx";
} else {
@ -2214,9 +2219,10 @@ public class ProductEditorComp extends Composite implements
}
parseIDs();
revive();
// Enter res mode
setPTypeCategory(PTypeCategory.PE);
textComp.setCorMode(true);
}
/**
@ -2353,7 +2359,7 @@ public class ProductEditorComp extends Composite implements
/**
* Get the directory.
*
*
* @return The directory
*/
private String getDir() {
@ -2491,7 +2497,7 @@ public class ProductEditorComp extends Composite implements
/**
* Display the Find or Find & Replace dialog.
*
*
* @param findAndReplace
* If true show the Find & Replace dialog, false shows the Find
* dialog.
@ -2733,7 +2739,7 @@ public class ProductEditorComp extends Composite implements
/*
* (non-Javadoc)
*
*
* @seecom.raytheon.uf.common.jms.notification.INotificationObserver#
* notificationArrived
* (com.raytheon.uf.common.jms.notification.NotificationMessage[])
@ -2915,7 +2921,7 @@ public class ProductEditorComp extends Composite implements
/**
* Word-wrap the text selected by the user.
*
*
*/
private void doWrapSelection() {
StyledText styledText = textComp.getTextEditorST();
@ -2991,7 +2997,7 @@ public class ProductEditorComp extends Composite implements
/*
* (non-Javadoc)
*
*
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.
* IProgressMonitor)
*/
@ -3062,9 +3068,5 @@ public class ProductEditorComp extends Composite implements
callToActionsMI.setMenu(callToActionsSubMenu);
createCallToActionsMenu(callToActionsSubMenu);
}
protected boolean isUpdateTime() {
return updateTime;
}
}

View file

@ -70,7 +70,7 @@ import com.raytheon.viz.gfe.textformatter.TextFmtParserUtil;
/**
* Composite containing the product editor.
*
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
@ -87,16 +87,18 @@ import com.raytheon.viz.gfe.textformatter.TextFmtParserUtil;
* 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.
* 04 FEB 2015 17039 ryu Removed HighlightFramingCodes feature which prevented
* 04 FEB 2015 17039 ryu Removed HighlightFramingCodes feature which prevented
* editing of framing codes.
* 07/02/2015 13753 lshi Update times for products in Product Editor
*
* 08/06/2015 13753 lshi use isSystemTextChange instead of isUpdateTime
*
* </pre>
*
*
* @author lvenable
* @version 1.0
*
*
*/
public class StyledTextComp extends Composite {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(StyledTextComp.class);
@ -130,7 +132,7 @@ public class StyledTextComp extends Composite {
/**
* Parent composite.
*/
private ProductEditorComp parent;
private final ProductEditorComp parent;
/**
* Styled text editor.
@ -178,7 +180,7 @@ public class StyledTextComp extends Composite {
private boolean updatingForCor = false;
private ProductEditorLogger peLog;
private final ProductEditorLogger peLog;
private static final String NORM_SEP = "^\\s*$";
@ -199,7 +201,7 @@ public class StyledTextComp extends Composite {
/**
* Constructor.
*
*
* @param parent
* Parent composite.
* @param wrapMode
@ -303,7 +305,7 @@ public class StyledTextComp extends Composite {
updateTextStyle(event);
checkAutoWrap(event);
if (corMode && !updatingForCor) {
if (corMode && !updatingForCor && !isSystemTextChange()) {
updatingForCor = true;
try {
makeCorrections();
@ -321,7 +323,7 @@ public class StyledTextComp extends Composite {
/**
* Get the StyledText editor.
*
*
* @return The StyledText editor.
*/
public StyledText getTextEditorST() {
@ -330,17 +332,15 @@ public class StyledTextComp extends Composite {
/**
* Set the product text.
*
*
* @param text
* The product text.
*/
public void setProductText(String text) {
newProduct = true;
textEditorST.setText(EMPTY);
textEditorST.setStyleRange(null);
try {
parseProductText(text);
textEditorST.setStyleRange(null);
textEditorST.setText(text);
lockText();
findFramingCodes();
@ -348,6 +348,7 @@ public class StyledTextComp extends Composite {
newProduct = false;
} catch (JepException e) {
statusHandler.error(PRODUCT_PARSE_ERROR, e);
textEditorST.setText(EMPTY);
}
}
@ -501,7 +502,7 @@ public class StyledTextComp extends Composite {
/**
* Parse the product text string.
*
*
* @param productText
* Complete product text.
* @throws JepException
@ -597,7 +598,7 @@ public class StyledTextComp extends Composite {
/**
* Replacement of the text in the given range with new text.
*
*
* @param tip
* the range of text to be replaced
* @param text
@ -626,11 +627,7 @@ public class StyledTextComp extends Composite {
}
private void makeCorrections() {
if (!parent.isUpdateTime()) {
parent.setPTypeCategory(PTypeCategory.COR);
}
if (prodDataStruct == null)
return;
parent.setPTypeCategory(PTypeCategory.COR);
List<SegmentData> segs = prodDataStruct.getSegmentsArray();
for (SegmentData seg : segs) {
if (seg.getSementMap().keySet().contains("vtec")) {
@ -710,7 +707,7 @@ public class StyledTextComp extends Composite {
* 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
* Verify event that was fired.
*/
@ -800,7 +797,7 @@ public class StyledTextComp extends Composite {
/**
* Check if there is selected text and if there is locked text in the
* selected text.
*
*
* @return True if there is selected text that contains locked text.
*/
private boolean selectionHasLockedText() {
@ -814,12 +811,12 @@ public class StyledTextComp extends Composite {
/**
* Check if there is locked text in the specified range of text.
*
*
* @param offset
* The starting point of the locked text search.
* @param length
* The length of the search.
*
*
* @return Whether or not there is text in the range that contains locked
* text.
*/
@ -837,7 +834,7 @@ public class StyledTextComp extends Composite {
/**
* Check if the key being pressed is a "non-edit" key.
*
*
* @param event
* Verify event.
* @return True if the key is an arrow or "non-edit" key.
@ -871,7 +868,7 @@ public class StyledTextComp extends Composite {
/**
* Handle the mouse down event.
*
*
* @param e
* Event fired.
*/
@ -986,7 +983,7 @@ public class StyledTextComp extends Composite {
/**
* Checks if the system is editing, e.g. updating the issue time every
* minute, vs a user typing text in the text area
*
*
* @return
*/
private boolean isSystemTextChange() {
@ -1142,7 +1139,7 @@ public class StyledTextComp extends Composite {
/**
* Getter for the column at which wrap and auto-wrap will wrap the text.
*
*
* @return the column number
*/
public int getWrapColumn() {
@ -1151,7 +1148,7 @@ public class StyledTextComp extends Composite {
/**
* Getter for the column at which wrap and auto-wrap will wrap the text.
*
*
* @param wrapColumn
* the column number
*/
@ -1190,7 +1187,7 @@ public class StyledTextComp extends Composite {
/**
* Query the prefs for setting. If it does not exist, use colorDft as its
* value. Create an SWT Color for display from the value and return it.
*
*
* @param prefs
* A preference store which might have config values.
* @param display
@ -1213,7 +1210,7 @@ public class StyledTextComp extends Composite {
/**
* Send a PROBLEM message if color1 is exactly equal to color2.
*
*
* @param color1
* the first color
* @param color2
@ -1240,7 +1237,7 @@ public class StyledTextComp extends Composite {
* <p>
* The getter name is different to avoid confusion with the getFgColor()
* method of Control.
*
*
* @return the foreground Color
*/
public Color getFgndColor() {
@ -1251,7 +1248,7 @@ public class StyledTextComp extends Composite {
* Get the framed text color of the StyledTextComp. This is the actual
* color, not a copy. It will be disposed when the StyledTextComp is, and
* should not be disposed before then.
*
*
* @return the frameColor
*/
public Color getFrameColor() {
@ -1262,7 +1259,7 @@ public class StyledTextComp extends Composite {
* Get the insert color of the StyledTextComp. This is the actual color, not
* a copy. It will be disposed when the StyledTextComp is, and should not be
* disposed before then.
*
*
* @return the insertColor
*/
public Color getInsertColor() {
@ -1273,7 +1270,7 @@ public class StyledTextComp extends Composite {
* Get the locked text color of the StyledTextComp. This is the actual
* color, not a copy. It will be disposed when the StyledTextComp is, and
* should not be disposed before then.
*
*
* @return the lockColor
*/
public Color getLockColor() {
@ -1283,7 +1280,7 @@ public class StyledTextComp extends Composite {
/**
* Word wrap the text in the block around cursorIndex. Adjust the cursor
* position to account for inserted or deleted whitespace.
*
*
* @param st
* The StyledText in which word wrap is to be performed
* @param cursorIndex