From ba585b94248fe55ddc0877206d66fad4ef09bb76 Mon Sep 17 00:00:00 2001 From: Jonathan Sanchez Date: Tue, 13 Aug 2013 16:30:05 -0500 Subject: [PATCH] Issue #2243 Fixed update list bugs. Change-Id: Ie04d66593c450592c78fccdb8d6b78d889d4b68f Former-commit-id: 8d0ee7f5cad7742ff2f184609aecf5c617fe0625 [formerly d685125b2553bce4899884e723ae307e62df0945] [formerly 8d0ee7f5cad7742ff2f184609aecf5c617fe0625 [formerly d685125b2553bce4899884e723ae307e62df0945] [formerly 49f488a58ff6e1a96d5507d47a5aac62f121c07d [formerly 4dcfd87f1ae127b8050a4c168a5acf0dd6c815ee]]] Former-commit-id: 49f488a58ff6e1a96d5507d47a5aac62f121c07d Former-commit-id: d33332bd58d4b3fd560b669d463e053acd67bc49 [formerly 96c88ad28b3c6104eb6674df36b670b5b949a44b] Former-commit-id: 721b2c7c04c3f9b8a57adfd4b0e9e0f6b88f7ab3 --- .../viz/warngen/gui/FollowupData.java | 15 +++++----- .../viz/warngen/gui/WarngenDialog.java | 28 +++++++++++-------- .../viz/warngen/util/CurrentWarnings.java | 10 +++---- .../viz/warngen/util/FollowUpUtil.java | 15 +++++----- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/FollowupData.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/FollowupData.java index e8b162f040..e83d22f8e9 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/FollowupData.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/FollowupData.java @@ -19,8 +19,6 @@ **/ package com.raytheon.viz.warngen.gui; -import java.util.Calendar; - import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord; import com.raytheon.uf.common.dataplugin.warning.WarningRecord; import com.raytheon.uf.common.time.SimulatedTime; @@ -37,7 +35,7 @@ import com.raytheon.uf.common.time.util.TimeUtil; * ------------ ---------- ----------- -------------------------- * Initial creation * May 7, 2013 1973 rferrel Changes to properly display Issue Time. - * Aug 7, 2013 2243 jsanchez Set all the attributes of an AbstractWarningRecord and added an expiration string. + * Aug 7, 2013 2243 jsanchez Set all the attributes of an AbstractWarningRecord and added an expiration string. Removed calendar object. * * * @@ -121,6 +119,8 @@ public class FollowupData extends WarningRecord { message = "Continuation no longer allowed; within 5 minutes of warning expiration."; } else if (action == WarningAction.EXP) { message = "Expiration no longer allowed; after 10 minutes of warning expiration."; + } else if (action == WarningAction.EXT) { + message = "Extention no longer allowed; within 5 minutes of warning expiration."; } return message; } @@ -137,12 +137,11 @@ public class FollowupData extends WarningRecord { private String buildExpStr(WarningAction status, AbstractWarningRecord record) { StringBuilder rval = new StringBuilder(); - Calendar cal = Calendar.getInstance(); - cal.setTime(SimulatedTime.getSystemTime().getTime()); + long timeInMillis = SimulatedTime.getSystemTime().getMillis(); if (status != WarningAction.COR) { // Positive means not yet expired - long diffMins = (record.getEndTime().getTimeInMillis() - cal - .getTimeInMillis()) / TimeUtil.MILLIS_PER_MINUTE; + long diffMins = (record.getEndTime().getTimeInMillis() - timeInMillis) + / TimeUtil.MILLIS_PER_MINUTE; if (diffMins == 0) { rval.append(" Expired"); } else if (diffMins > 0) { @@ -151,7 +150,7 @@ public class FollowupData extends WarningRecord { rval.append(" Exp ").append(-diffMins).append(" min ago"); } } else { - long diffMins = (cal.getTimeInMillis() - record.getIssueTime() + long diffMins = (timeInMillis - record.getIssueTime() .getTimeInMillis()) / TimeUtil.MILLIS_PER_MINUTE; if (diffMins == 0) { rval.append(" Just Issued"); diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java index a43b94bdf7..131eecb3d4 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java @@ -69,6 +69,8 @@ import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.SimulatedTime; +import com.raytheon.uf.common.time.TimeRange; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.exception.VizException; @@ -391,8 +393,7 @@ public class WarngenDialog extends CaveSWTDialog implements durationList.setLayoutData(gd); durationList.setEnabled(config.isEnableDuration()); - startTime = Calendar.getInstance(); - startTime.setTime(SimulatedTime.getSystemTime().getTime()); + startTime = TimeUtil.newCalendar(); endTime = DurationUtil.calcEndTime(this.startTime, defaultDuration.minutes); @@ -935,17 +936,23 @@ public class WarngenDialog extends CaveSWTDialog implements // Select the previously selected item. invalidFollowUpAction = false; if (currentSelection != null) { - boolean isValid = false; for (int i = 0; i < updateListCbo.getItemCount(); i++) { if (updateListCbo.getItem(i).startsWith( currentSelection.getEquvialentString())) { updateListCbo.select(i); - isValid = true; break; } } - if (!isValid) { + WarningAction action = WarningAction.valueOf(currentSelection + .getAct()); + TimeRange timeRange = FollowUpUtil.getTimeRange(action, + currentSelection); + // Checks if selection is invalid based on the time range. A follow + // up option could be removed due to an action such as a CAN or an + // EXP. If an action removes the follow up, then no warning message + // should be displayed. + if (!timeRange.contains(SimulatedTime.getSystemTime().getTime())) { invalidFollowUpAction = true; preventFollowUpAction(currentSelection); } @@ -1525,6 +1532,8 @@ public class WarngenDialog extends CaveSWTDialog implements } catch (VizException e1) { statusHandler.handle(Priority.PROBLEM, "WarnGen Error", e1); } + // Properly sets the "Create Text" button. + setInstructions(); } protected void recreateDurations(Combo durList) { @@ -1901,14 +1910,12 @@ public class WarngenDialog extends CaveSWTDialog implements .getSelectionIndex())); if (fd == null || (WarningAction.valueOf(fd.getAct()) == WarningAction.NEW)) { - startTime = Calendar.getInstance(); - startTime.setTime(SimulatedTime.getSystemTime().getTime()); + startTime = TimeUtil.newCalendar(); endTime = DurationUtil.calcEndTime(this.startTime, duration); start.setText(df.format(this.startTime.getTime())); end.setText(df.format(this.endTime.getTime())); } else if (WarningAction.valueOf(fd.getAct()) == WarningAction.EXT) { - startTime = Calendar.getInstance(); - startTime.setTime(SimulatedTime.getSystemTime().getTime()); + startTime = TimeUtil.newCalendar(); endTime = DurationUtil.calcEndTime(extEndTime, duration); end.setText(df.format(this.endTime.getTime())); } @@ -2132,8 +2139,7 @@ public class WarngenDialog extends CaveSWTDialog implements .getItem(durationList.getSelectionIndex()))).minutes; warngenLayer.getStormTrackState().duration = duration; - startTime = Calendar.getInstance(); - startTime.setTime(SimulatedTime.getSystemTime().getTime()); + startTime = TimeUtil.newCalendar(); extEndTime = newWarn.getEndTime(); endTime = DurationUtil.calcEndTime(extEndTime, duration); end.setText(df.format(this.endTime.getTime())); diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/CurrentWarnings.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/CurrentWarnings.java index 20fe1926f5..2e474f60f8 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/CurrentWarnings.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/CurrentWarnings.java @@ -46,6 +46,7 @@ import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.SimulatedTime; import com.raytheon.uf.common.time.TimeRange; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.viz.core.RecordFactory; import com.raytheon.uf.viz.core.alerts.AlertMessage; import com.raytheon.uf.viz.core.exception.VizException; @@ -256,9 +257,8 @@ public class CurrentWarnings { public List getCorrectableWarnings( AbstractWarningRecord warnRec) { List rval = new ArrayList(); - Calendar current = Calendar.getInstance(); + Calendar current = TimeUtil.newCalendar(); Calendar end = Calendar.getInstance(); - current.setTime(SimulatedTime.getSystemTime().getTime()); synchronized (officeId) { List records = warningMap.get(toKey( @@ -371,8 +371,7 @@ public class CurrentWarnings { List warnings = warningMap.get(toKey( phensig, etn)); if (warnings != null) { - Calendar c = Calendar.getInstance(); - c.setTime(SimulatedTime.getSystemTime().getTime()); + Calendar c = TimeUtil.newCalendar(); c.add(Calendar.MINUTE, -10); TimeRange t = new TimeRange(c.getTime(), SimulatedTime .getSystemTime().getTime()); @@ -411,8 +410,7 @@ public class CurrentWarnings { AbstractWarningRecord newProd = null; boolean conMatchesCan = false; ArrayList conProds = new ArrayList(); - Calendar c = Calendar.getInstance(); - c.setTime(SimulatedTime.getSystemTime().getTime()); + Calendar c = TimeUtil.newCalendar(); c.add(Calendar.MINUTE, -10); TimeRange t = new TimeRange(c.getTime(), SimulatedTime .getSystemTime().getTime()); diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java index 34ed5ab3ac..57b86a31aa 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java @@ -12,9 +12,10 @@ import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction; import com.raytheon.uf.common.dataplugin.warning.config.WarngenConfiguration; import com.raytheon.uf.common.time.SimulatedTime; import com.raytheon.uf.common.time.TimeRange; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.viz.warngen.gis.AffectedAreas; +import com.raytheon.viz.warngen.gis.Direction; import com.raytheon.viz.warngen.gis.GisUtil; -import com.raytheon.viz.warngen.gis.GisUtil.Direction; import com.raytheon.viz.warngen.text.ICommonPatterns; /** @@ -30,6 +31,7 @@ import com.raytheon.viz.warngen.text.ICommonPatterns; * Oct 18, 2012 15332 jsanchez Fixed refactor bugs. * Mar 13, 2013 DR 15892 D. Friedman Handle SMW format in canceledAreasFromText * Aug 6, 2013 2243 jsanchez Updated the time ranges to be removed from the follow up list correctly. + * Aug 13, 2013 2243 jsanchez Removed calendar object. * * * @@ -56,8 +58,6 @@ public class FollowUpUtil { WarningAction action) { // Current Time - Calendar cal = Calendar.getInstance(); - cal.setTime(SimulatedTime.getSystemTime().getTime()); boolean rval = false; if (record == null) { @@ -74,7 +74,8 @@ public class FollowUpUtil { for (String s : config.getFollowUps()) { WarningAction act = WarningAction.valueOf(s); if (act == action - && getTimeRange(act, record).contains(cal.getTime()) + && getTimeRange(act, record).contains( + SimulatedTime.getSystemTime().getTime()) && act != WarningAction.COR) { rval = true; } @@ -310,10 +311,8 @@ public class FollowUpUtil { AbstractWarningRecord record) { /* Calendars for time calculations */ - Calendar start = Calendar.getInstance(); - Calendar end = Calendar.getInstance(); - start.setTime(SimulatedTime.getSystemTime().getTime()); - end.setTime(SimulatedTime.getSystemTime().getTime()); + Calendar start = TimeUtil.newCalendar(); + Calendar end = TimeUtil.newCalendar(); TimeRange rval = null;