Issue #2176 Implemented emergency warning products.

Cherry picked from 13.6.1 46d5bd4f0a [formerly c62de0d75f] [formerly 7d74ba5ee1] [formerly 67ce90c14a [formerly 7d74ba5ee1 [formerly 36df6339cc00afc5935746a4a47b0e9e8c641f85]]] to 13.5.2

Change-Id: I80623a63abd495baf3e0004625732f26453a30d9

Former-commit-id: cf51ba9e9c [formerly e0bd81c0ae [formerly be486757ed36916c1c3a1e56ddf98754b900b693]]
Former-commit-id: e0bd81c0ae
Former-commit-id: 051cdc28c2
This commit is contained in:
Jonathan Sanchez 2013-07-25 13:47:44 -05:00
parent fadc0d374c
commit 4ff3193e89
10 changed files with 710 additions and 234 deletions

View file

@ -25,7 +25,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.common.dataplugin.radar;bundle-version="1.0.0",
org.apache.commons.logging,
com.raytheon.uf.viz.localization,
com.raytheon.uf.common.auth;bundle-version="1.12.1174"
com.raytheon.uf.common.auth;bundle-version="1.12.1174",
com.raytheon.uf.common.dataplugin.warning;bundle-version="1.12.1174"
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.texteditor,
com.raytheon.viz.texteditor.alarmalert.dialogs,

View file

@ -0,0 +1,196 @@
/**
* 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.
**/
package com.raytheon.viz.texteditor.dialogs;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import com.raytheon.uf.common.activetable.ActiveTableMode;
import com.raytheon.uf.common.activetable.ActiveTableRecord;
import com.raytheon.uf.common.activetable.GetActiveTableRequest;
import com.raytheon.uf.common.activetable.GetActiveTableResponse;
import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction;
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.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.core.mode.CAVEMode;
import com.raytheon.viz.texteditor.util.VtecObject;
import com.raytheon.viz.texteditor.util.VtecUtil;
/**
* Produces the product message and mode message for the warngen confirmation
* dialog for emergency warnings.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 23, 2013 2176 jsanchez Initial creation
*
* </pre>
*
* @author jsanchez
* @version 1.0
*/
public class EmergencyConfirmationMsg implements IWarnGenConfirmationable {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(EmergencyConfirmationMsg.class);
private String productMessage;
private static class EmergencyType {
private static final EmergencyType TORNADO = new EmergencyType(
"TORNADO EMERGENCY", "TO.W");
private static final EmergencyType FLASH_FLOOD = new EmergencyType(
"FLASH FLOOD EMERGENCY", "FF.W");
private final String value;
private final String phensig;
private final static EmergencyType[] values = new EmergencyType[] {
TORNADO, FLASH_FLOOD };
private EmergencyType(String type, String phensig) {
this.value = type;
this.phensig = phensig;
}
public static EmergencyType valueOf(String phensig) {
EmergencyType type = null;
for (EmergencyType t : values) {
if (t.phensig.equals(phensig)) {
type = t;
break;
}
}
return type;
}
};
/**
* Orders the ActiveTableRecord based on the issue time (ascending)
*/
private class ActiveTableRecordComparator implements
Comparator<ActiveTableRecord> {
@Override
public int compare(ActiveTableRecord o1, ActiveTableRecord o2) {
return o1.getIssueTime().compareTo(o2.getIssueTime());
}
}
@Override
public boolean checkWarningInfo(String header, String body, String nnn) {
VtecObject vtec = VtecUtil.parseMessage(body);
EmergencyType type = null;
WarningAction action = null;
if (vtec != null) {
type = EmergencyType.valueOf(vtec.getPhensig());
action = WarningAction.valueOf(vtec.getAction());
if (action == WarningAction.CAN && body.split("\\$\\$").length > 2) {
// It is possible for a warning products to have two segments: a
// CAN and a CON.'$$' denotes the end of one segment. VtecUtil
// only grabs the first VTEC. If there are multiple segments CAN
// should always be the first VTEC
action = WarningAction.CANCON;
}
}
// Check if the warning product is a valid EmergencyType.
if (type != null) {
boolean currentEmergency = body.contains("EMERGENCY");
if (action == WarningAction.NEW && currentEmergency) {
// Only occurs when the warning is first issued and not any
// other action
productMessage = "This is a " + type.value;
} else if (action == WarningAction.CON
|| action == WarningAction.EXT
|| action == WarningAction.CANCON) {
// Check if the warning was an upgrade or downgrade in the
// emergency warning for continuation, extension (FFW), or a
// cancel
// and continuation.
GetActiveTableRequest request = new GetActiveTableRequest();
if (CAVEMode.getMode().equals(CAVEMode.PRACTICE)) {
request.setMode(ActiveTableMode.PRACTICE);
} else {
request.setMode(ActiveTableMode.OPERATIONAL);
}
request.setSiteID(vtec.getOffice());
request.setPhensigList(vtec.getPhensig());
request.setEtn(String.format("%04d", vtec.getSequence()));
try {
GetActiveTableResponse response = (GetActiveTableResponse) ThriftClient
.sendRequest(request);
List<ActiveTableRecord> records = response.getActiveTable();
// There should be existing records since this is for follow
// ups. This is just a precaution
if (records != null && !records.isEmpty()) {
// Get latest active table record
Collections.sort(records,
new ActiveTableRecordComparator());
ActiveTableRecord record = records
.get(records.size() - 1);
boolean wasEmergency = record.getRawmessage().contains(
"EMERGENCY");
if (!wasEmergency && currentEmergency) {
productMessage = "This is an upgrade of a "
+ type.value;
} else if (wasEmergency && !currentEmergency) {
productMessage = "This is a downgrade of a "
+ type.value;
}
}
} catch (VizException e) {
statusHandler.handle(Priority.ERROR,
"Error making request to active table.");
}
}
}
return productMessage == null;
}
@Override
public String getTitle() {
return "Severe Weather Product";
}
@Override
public String getProductMessage() {
return productMessage;
}
@Override
public String getModeMessage() {
return "Should we proceed?\n";
}
}

View file

@ -0,0 +1,67 @@
/**
* 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.
**/
package com.raytheon.viz.texteditor.dialogs;
/**
* Interface to retrieve the WarnGen Confirmation Dialog message values.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 23, 2013 2176 jsanchez Initial creation
*
* </pre>
*
* @author jsanchez
* @version 1.0
*/
public interface IWarnGenConfirmationable {
/**
* Returns true if the WarnGen Confirmation Dialog needs to pop-up.
*
* @param header
* @param body
* @param nnn
* @return
*/
public boolean checkWarningInfo(String header, String body, String nnn);
/**
*
* @return the title for the WarnGen Confirmation Dialog
*/
public String getTitle();
/**
*
* @return the product message in the WarnGen Confirmation Dialog
*/
public String getProductMessage();
/**
*
* @return the mode message in the WarnGen Confirmation Dialog
*/
public String getModeMessage();
}

View file

@ -0,0 +1,66 @@
/**
* 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.
**/
package com.raytheon.viz.texteditor.dialogs;
import com.raytheon.viz.texteditor.qc.QualityControl;
/**
* Produces the product message and mode message for the warngen confirmation
* dialog for warnings failing QC.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 23, 2013 2176 jsanchez Initial creation
*
* </pre>
*
* @author jsanchez
* @version 1.0
*/
public class QCConfirmationMsg implements IWarnGenConfirmationable {
private QualityControl qcCheck = new QualityControl();
@Override
public boolean checkWarningInfo(String header, String body, String nnn) {
return qcCheck.checkWarningInfo(header, body, nnn);
}
@Override
public String getTitle() {
return "Problem Detected by QC";
}
@Override
public String getProductMessage() {
return qcCheck.getErrorMessage();
}
@Override
public String getModeMessage() {
return "Do you really want to Send?\n";
}
}

View file

@ -0,0 +1,102 @@
/**
* 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.
**/
package com.raytheon.viz.texteditor.dialogs;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.raytheon.viz.core.mode.CAVEMode;
import com.raytheon.viz.texteditor.qc.QualityControl;
/**
* Produces the product message and mode message for the warngen confirmation
* dialog for sending a warning.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 23, 2013 2176 jsanchez Initial creation
*
* </pre>
*
* @author jsanchez
* @version 1.0
*/
public class SendConfirmationMsg implements IWarnGenConfirmationable {
private String title;
private boolean resend;
private String afosId;
public SendConfirmationMsg(boolean resend, String afosId, String nnn) {
this.resend = resend;
this.afosId = afosId;
title = QualityControl.getProductWarningType(nnn);
}
@Override
public boolean checkWarningInfo(String header, String body, String nnn) {
return true;
}
@Override
public String getTitle() {
return title;
}
@Override
public String getProductMessage() {
StringBuilder productMessage = new StringBuilder();
if (resend) {
productMessage.append("You are about to RESEND a " + afosId + "\n");
productMessage.append(title).append(".\n");
} else {
productMessage.append("You are about to SEND a " + afosId + "\n");
productMessage.append(title).append(".\n");
}
return productMessage.toString();
}
@Override
public String getModeMessage() {
CAVEMode mode = CAVEMode.getMode();
StringBuilder modeMessage = new StringBuilder();
modeMessage.append("The workstation is in ").append(mode)
.append(" mode.");
if (resend) {
modeMessage.append("\nThere is no QC check for resend product.");
}
Pattern p = Pattern.compile(".\\%[s].");
Matcher m = p.matcher(TextEditorDialog.STORED_SENT_MSG);
boolean result = (CAVEMode.OPERATIONAL.equals(mode) || CAVEMode.TEST
.equals(mode));
modeMessage.append(result ? m.replaceAll(" ") : m.replaceAll(" not "));
return modeMessage.toString();
}
}

View file

@ -85,8 +85,8 @@ import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.FontMetrics;
@ -100,7 +100,6 @@ import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
@ -142,7 +141,6 @@ import com.raytheon.uf.common.time.SimulatedTime;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.services.textdbsrv.IQueryTransport;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
// import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.exception.VizException;
@ -176,7 +174,6 @@ import com.raytheon.viz.texteditor.msgs.ITextEditorCallback;
import com.raytheon.viz.texteditor.msgs.IWmoBrowserCallback;
import com.raytheon.viz.texteditor.notify.NotifyExpiration;
import com.raytheon.viz.texteditor.print.PrintDisplay;
import com.raytheon.viz.texteditor.qc.QualityControl;
import com.raytheon.viz.texteditor.scripting.dialogs.IScriptEditor;
import com.raytheon.viz.texteditor.scripting.dialogs.IScriptEditorObserver;
import com.raytheon.viz.texteditor.scripting.dialogs.ScriptEditorDialog;
@ -191,6 +188,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.dialogs.ICloseCallback;
import com.raytheon.viz.ui.dialogs.SWTMessageBox;
// import com.raytheon.uf.viz.core.RGBColors;
/**
* Main Text Editor dialog.
*
@ -328,6 +327,7 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox;
* *.xml files in localization;
* add selection listener to catch the highlight words and
* set the highlight colors.
* 23Jul2013 2176 jsanchez Added a new confirmation message for emergency warnings.
* 25July2013 15733 GHull Read font and color prefs from TextEditorCfg.
*
* </pre>
@ -789,19 +789,19 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
/**
* Small font menu item.
*/
// private MenuItem smallFontItem;
// private MenuItem smallFontItem;
/**
* Medium font menu item.
*/
// private MenuItem mediumFontItem;
// private MenuItem mediumFontItem;
/**
* Large font menu item.
*/
// private MenuItem largeFontItem;
// private MenuItem largeFontItem;
/**
/**
* Overstrike (overwrite) menu item.
*/
private MenuItem overStrikeItem;
@ -1297,7 +1297,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
* Currently active popupItems.
*/
private static final boolean[] isPopItemDefault = { true, false, true,
false };
false };
/**
* Indictes this instance of dialog if for a warnGen.
@ -1377,12 +1377,14 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
private boolean isPreviousLineWrapped;
private Color textForeground;
private Color textBackground;
private Color highlightForeground;
private Color highlightBackground;
// protected Color color;
// protected Color color;
/**
* Constructor with additional cave style rules
@ -2865,7 +2867,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
private void createAutoWrapSubMenu(Menu autoWrapSubMenu) {
AutoWrapCfg autoWrapcfg = getAutoWrapCfg();
for (WrapButtonCfg buttonCfg : autoWrapcfg.getButtons()) {
MenuItem item = new MenuItem(autoWrapSubMenu, SWT.RADIO);
MenuItem item = new MenuItem(autoWrapSubMenu, SWT.RADIO);
item.setText(buttonCfg.getLabelName());
item.setSelection(buttonCfg.isSelected());
item.setData(buttonCfg);
@ -2954,10 +2956,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
*/
private void createFontSizeSubMenu(Menu fontSizeSubMenu) {
FontSizeCfg fontSizeCfg = TextEditorCfg.getTextEditorCfg().getFontSizeCfg();
SizeButtonCfg seldFontBtn = TextEditorCfg.getTextEditorCfg().getSelectedFontButton();
FontSizeCfg fontSizeCfg = TextEditorCfg.getTextEditorCfg().getFontSizeCfg();
SizeButtonCfg seldFontBtn = TextEditorCfg.getTextEditorCfg().getSelectedFontButton();
for (SizeButtonCfg buttonCfg : fontSizeCfg.getButtons()) {
for (SizeButtonCfg buttonCfg : fontSizeCfg.getButtons()) {
MenuItem item = new MenuItem(fontSizeSubMenu, SWT.RADIO);
item.setText(buttonCfg.getLabelName());
item.setSelection( false );
@ -2965,23 +2967,23 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
// if this button is the initial selection.
if( seldFontBtn.getLabelName().equals( buttonCfg.getLabelName() ) ) {
item.setSelection(true);
item.setSelection(true);
setDefaultFont( seldFontBtn.getFontSize(), seldFontBtn.getFontName() );
}
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
MenuItem item = (MenuItem) event.getSource();
if (item.getSelection()) {
int selectFontSize = ( (SizeButtonCfg) item.getData()).getFontSize();
MenuItem item = (MenuItem) event.getSource();
if (item.getSelection()) {
int selectFontSize = ( (SizeButtonCfg) item.getData()).getFontSize();
String seldFontName = ((SizeButtonCfg) item.getData()).getFontName();
setDefaultFont( selectFontSize, seldFontName );
textEditor.setFont(dftFont);
headerTF.setFont(dftFont);
}
textEditor.setFont(dftFont);
headerTF.setFont(dftFont);
}
}
});
}
@ -3760,19 +3762,20 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
textEditor.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
System.out.println("\ntextEditor default selection event --" + e.toString());
System.out.println("\ntextEditor default selection event --"
+ e.toString());
}
@Override
public void widgetSelected(SelectionEvent e) {
public void widgetSelected(SelectionEvent e) {
StyledText stylText = (StyledText) e.getSource();
StyledText stylText = (StyledText) e.getSource();
// String slctText = stylText.getSelectionText();
// int length = slctText.length();
// String slctText = stylText.getSelectionText();
// int length = slctText.length();
stylText.setSelectionBackground(highlightBackground);
stylText.setSelectionForeground(highlightForeground);
stylText.setSelectionBackground(highlightBackground);
stylText.setSelectionForeground(highlightForeground);
}
});
@ -3841,8 +3844,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
public void verifyKey(VerifyEvent event) {
// Ignore edit keys when not in edit mode.
if (textEditor.getEditable() == false) {
return;
}
return;
}
if (event.keyCode == SWT.DEL || event.keyCode == SWT.BS
|| event.keyCode == SWT.SHIFT) {
// Do nothing...
@ -3942,7 +3945,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
if (e.button == 3) {
processPopup();
processPopup();
}
}
@ -3983,6 +3986,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
// return textColorsCfg;
// }
private void setDefaultTextColor(TextEditorCfg txtClrCfg ) {
textBackground = new Color( shell.getDisplay(), txtClrCfg.getTextBackgroundColor() );
@ -3994,48 +3998,48 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
/**
* Process the user choice from the popup list. DR14842 - re-written
*/
private void processPopup() {
Menu menu = new Menu(shell, SWT.POP_UP);
List<String> items = Arrays.asList(popupItems);
for (String pi : popupItems) {
MenuItem mi = new MenuItem(menu, SWT.PUSH);
mi.setText(pi);
if (isEditMode()) {
mi.setEnabled(true);
} else {
mi.setEnabled(isPopItemDefault[items.indexOf(pi)]);
}
mi.addListener(SWT.Selection, new Listener() {
private void processPopup() {
Menu menu = new Menu(shell, SWT.POP_UP);
List<String> items = Arrays.asList(popupItems);
for (String pi : popupItems) {
MenuItem mi = new MenuItem(menu, SWT.PUSH);
mi.setText(pi);
if (isEditMode()) {
mi.setEnabled(true);
} else {
mi.setEnabled(isPopItemDefault[items.indexOf(pi)]);
}
mi.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
handleSelection(event);
}
});
}
menu.setVisible(true);
}
public void handleEvent(Event event) {
handleSelection(event);
}
});
}
menu.setVisible(true);
}
/**
* Handle the selection from the popup menu
*
* @param event
*/
protected void handleSelection(Event event) {
MenuItem item = (MenuItem) event.widget;
String choice = item.getText();
if (choice != null) {
if (popupItems[0].equals(choice)) {
textEditor.selectAll();
} else if (popupItems[1].equals(choice)) {
cutText();
} else if (popupItems[2].equals(choice)) {
copyText();
} else if (popupItems[3].equals(choice)) {
pasteText();
}
textEditor.update();
}
}
protected void handleSelection(Event event) {
MenuItem item = (MenuItem) event.widget;
String choice = item.getText();
if (choice != null) {
if (popupItems[0].equals(choice)) {
textEditor.selectAll();
} else if (popupItems[1].equals(choice)) {
cutText();
} else if (popupItems[2].equals(choice)) {
copyText();
} else if (popupItems[3].equals(choice)) {
pasteText();
}
textEditor.update();
}
}
/**
* creates the bar containing the script runner controls.
@ -4850,47 +4854,31 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
* true if product is to be resent
*/
synchronized private void sendProduct(final boolean resend) {
final CAVEMode mode = CAVEMode.getMode();
StdTextProduct prod = getStdTextProduct();
String afosId = prod.getCccid() + prod.getNnnid() + prod.getXxxid();
final String title = QualityControl.getProductWarningType(prod
.getNnnid());
final StringBuilder productMessage = new StringBuilder();
final StringBuilder modeMessage = new StringBuilder();
modeMessage.append("The workstation is in ").append(mode)
.append(" mode.");
if (resend) {
productMessage.append("You are about to RESEND a " + afosId + "\n");
productMessage.append(title).append(".\n");
modeMessage.append("\nThere is no QC check for resend product.");
} else if (warnGenFlag) {
productMessage.append("You are about to SEND a " + afosId + "\n");
productMessage.append(title).append(".\n");
QualityControl qcCheck = new QualityControl();
if (qcCheck.checkWarningInfo(headerTF.getText().toUpperCase(),
textEditor.getText().toUpperCase(), prod.getNnnid()) == false) {
if (warnGenFlag) {
QCConfirmationMsg qcMsg = new QCConfirmationMsg();
if (!qcMsg.checkWarningInfo(headerTF.getText().toUpperCase(),
textEditor.getText().toUpperCase(), prod.getNnnid())) {
WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell,
"Problem Detected by QC", qcCheck.getErrorMessage(),
"Do you really want to Send?\n", mode);
qcMsg.getTitle(), qcMsg.getProductMessage(),
qcMsg.getModeMessage());
wgcd.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
if (Boolean.TRUE.equals(returnValue))
finishSendProduct(resend, title, mode,
productMessage, modeMessage);
if (Boolean.TRUE.equals(returnValue)) {
checkEmergencyProduct(resend);
}
}
});
wgcd.open();
return;
} else {
checkEmergencyProduct(resend);
}
} else {
finishSendProduct(resend);
}
finishSendProduct(resend, title, mode, productMessage, modeMessage);
}
/**
@ -4899,21 +4887,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
* the WarnGen being sent.
*
* @param resend
* @param title
* @param mode
* @param productMessage
* @param modeMessage
*/
private void finishSendProduct(final boolean resend, String title,
CAVEMode mode, StringBuilder productMessage,
StringBuilder modeMessage) {
Pattern p = Pattern.compile(".\\%[s].");
Matcher m = p.matcher(STORED_SENT_MSG);
final boolean result = (CAVEMode.OPERATIONAL.equals(mode) || CAVEMode.TEST
.equals(mode));
modeMessage.append(result ? m.replaceAll(" ") : m.replaceAll(" not "));
private void finishSendProduct(final boolean resend) {
if (statusBarLabel.getText().startsWith("Attachment:")) {
StringBuilder sb = new StringBuilder("An Attachment file (");
int startIndex = "Attachment:".length() + 1;
@ -4936,21 +4911,58 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
if (!verifyRequiredFields()) {
return;
}
StdTextProduct prod = getStdTextProduct();
String afosId = prod.getCccid() + prod.getNnnid() + prod.getXxxid();
SendConfirmationMsg sendMsg = new SendConfirmationMsg(resend, afosId,
prod.getNnnid());
WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, title,
productMessage.toString(), modeMessage.toString(), mode);
WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell,
sendMsg.getTitle(), sendMsg.getProductMessage(),
sendMsg.getModeMessage());
wgcd.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
if (Boolean.TRUE.equals(returnValue)) {
warngenCloseCallback(resend, result);
warngenCloseCallback(resend);
}
}
});
wgcd.open();
}
/**
* Checks if the product is a emergency warning product and opens up the
* WarnGen Confirmation Dialog if necessary.
*
* @param resend
* true if product is to be resent
*/
private void checkEmergencyProduct(final boolean resend) {
StdTextProduct prod = getStdTextProduct();
EmergencyConfirmationMsg emergencyMsg = new EmergencyConfirmationMsg();
if (emergencyMsg.checkWarningInfo(headerTF.getText().toUpperCase(),
textEditor.getText().toUpperCase(), prod.getNnnid()) == false) {
WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell,
emergencyMsg.getTitle(), emergencyMsg.getProductMessage(),
emergencyMsg.getModeMessage());
wgcd.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
if (Boolean.TRUE.equals(returnValue)) {
finishSendProduct(resend);
}
}
});
wgcd.open();
} else {
finishSendProduct(resend);
}
}
/**
* This is used by finishedSendProduct as the call back to the warnGen
* confirmaiton Dialog.
@ -4958,10 +4970,13 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
* @param resend
* @param result
*/
private void warngenCloseCallback(boolean resend, boolean isOperational) {
private void warngenCloseCallback(boolean resend) {
// DR14553 (make upper case in product)
String body = textEditor.getText().toUpperCase();
CAVEMode mode = CAVEMode.getMode();
boolean isOperational = (CAVEMode.OPERATIONAL.equals(mode) || CAVEMode.TEST
.equals(mode));
if (isOperational) {
removeOptionalFields();
@ -5614,88 +5629,89 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
textEditor.setText("");
}
} else {
// TODO FIX PARSING
// TODO FIX PARSING
// First, set the current header by assuming that it usually
// consists of the first two lines of text in the text product,
// though there will be exceptions to that "rule" as handled below.
// So, obtain the AFOS NNNxxx. If it's where it is supposed to be
// in the new format, then the existing header is already an AWIPS
// First, set the current header by assuming that it usually
// consists of the first two lines of text in the text product,
// though there will be exceptions to that "rule" as handled below.
// So, obtain the AFOS NNNxxx. If it's where it is supposed to be
// in the new format, then the existing header is already an AWIPS
// text product identifier. Otherwise it is a legacy AFOS
// identifier.
if (TextDisplayModel.getInstance().hasStdTextProduct(token)) {
StdTextProduct textProd = TextDisplayModel.getInstance()
.getStdTextProduct(token);
StdTextProductId prodId = textProd.getProdId();
try {
// start of second line of text
start = textEditor.getOffsetAtLine(thisLine + 1);
if ((textEditor.getText(start, start + afosNnnLimit)
.equals(prodId.getNnnid()))
if (TextDisplayModel.getInstance().hasStdTextProduct(token)) {
StdTextProduct textProd = TextDisplayModel.getInstance()
.getStdTextProduct(token);
StdTextProductId prodId = textProd.getProdId();
try {
// start of second line of text
start = textEditor.getOffsetAtLine(thisLine + 1);
if ((textEditor.getText(start, start + afosNnnLimit)
.equals(prodId.getNnnid()))
&& (textEditor.getText(start + afosNnnLimit + 1,
start + afosXxxLimit).equals(prodId
.getXxxid()))) {
// Text matches the products nnnid and xxxid
numberOfLinesOfHeaderText = 2;
// Text matches the products nnnid and xxxid
numberOfLinesOfHeaderText = 2;
} else if (textEditor.getText(start,
start + afosNnnLimit + 2).equals(
AFOSParser.DRAFT_PIL)
|| textEditor.getText(start,
start + afosNnnLimit + 2).equals("TTAA0")) {
// Text matches temporary WRKWG#
numberOfLinesOfHeaderText = 2;
} else {
// Text matches temporary WRKWG#
numberOfLinesOfHeaderText = 2;
} else {
// Assume this header block is a legacy AFOS identifier.
numberOfLinesOfHeaderText = 1;
}
} catch (IllegalArgumentException e) {
// Assume this header block is a legacy AFOS identifier.
numberOfLinesOfHeaderText = 1;
}
} catch (IllegalArgumentException e) {
// Assume this header block is a legacy AFOS identifier.
numberOfLinesOfHeaderText = 1;
}
}
try {
start = 0;
finish = textEditor.getOffsetAtLine(thisLine
+ numberOfLinesOfHeaderText) - 1;
} catch (IllegalArgumentException e) {
// The text does not span enough lines so use the full extent
// of the product.
finish = textEditor.getCharCount() - 1;
}
try {
start = 0;
finish = textEditor.getOffsetAtLine(thisLine
+ numberOfLinesOfHeaderText) - 1;
} catch (IllegalArgumentException e) {
// The text does not span enough lines so use the full extent
// of the product.
finish = textEditor.getCharCount() - 1;
}
// Set the content of the header block to consist of just the header of
// the text product... it will get reunited with the body when it is
// saved.
if (finish > start) {
headerTF.setText(textEditor.getText(start, finish));
} else {
headerTF.setText("");
}
// Set the content of the header block to consist of just the header
// of
// the text product... it will get reunited with the body when it is
// saved.
if (finish > start) {
headerTF.setText(textEditor.getText(start, finish));
} else {
headerTF.setText("");
}
// Next, set the current body by assuming that it always
// consists of the rest of the text product beyond the line(s)
// of text in the header.
try {
int numberOfBlankLines = -1;
String line = null;
do {
numberOfBlankLines++;
// Next, set the current body by assuming that it always
// consists of the rest of the text product beyond the line(s)
// of text in the header.
try {
int numberOfBlankLines = -1;
String line = null;
do {
numberOfBlankLines++;
line = textEditor.getLine(thisLine
+ numberOfLinesOfHeaderText + numberOfBlankLines);
} while (line.length() == 0 || line.equals(""));
// Note: 'st' is a reference to 'textEditor'...
// delelete the header from the text in 'textEditor'
finish = textEditor.getOffsetAtLine(thisLine
+ numberOfLinesOfHeaderText + numberOfBlankLines);
textEditor.setSelection(start, finish);
textEditor.setEditable(true);
textEditor.invokeAction(SWT.DEL);
textEditor.setEditable(false);
} catch (IllegalArgumentException e) {
// There is no text product body, so set it to the empty string.
textEditor.setText("");
}
} while (line.length() == 0 || line.equals(""));
// Note: 'st' is a reference to 'textEditor'...
// delelete the header from the text in 'textEditor'
finish = textEditor.getOffsetAtLine(thisLine
+ numberOfLinesOfHeaderText + numberOfBlankLines);
textEditor.setSelection(start, finish);
textEditor.setEditable(true);
textEditor.invokeAction(SWT.DEL);
textEditor.setEditable(false);
} catch (IllegalArgumentException e) {
// There is no text product body, so set it to the empty string.
textEditor.setText("");
}
}
// set editor status flags
dirty = false;
@ -5907,9 +5923,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
statusBarLabel.update();
setBusy(true);
if (queryTransport == null) {
queryTransport = TextEditorUtil.getTextDbsrvTransport();
}
if (queryTransport == null) {
queryTransport = TextEditorUtil.getTextDbsrvTransport();
}
productQueryJob.addRequest(command, isObsUpdated);
}
@ -7596,7 +7612,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
headerTF.setFont(shell.getFont());
if (dftFont != null) {
dftFont.dispose();
dftFont.dispose();
}
if (clipboard != null) {
@ -8188,7 +8204,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
private void displayAirportTooltip(Point location) {
String word = parseProduct(textEditor, location.y);
if (word != null) {
String result = AfosBrowserModel.getInstance().getNodeHelp(word);
String result = AfosBrowserModel.getInstance().getNodeHelp(word);
if (result != null) {
// dispaly below and to the right of location.
location.x += 5;
@ -8214,29 +8230,29 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
String result = new String("");
try {
char c = lineText.charAt(0);
if ((c == 'M') || (c == 'S') || (c == 'T')) {
char c = lineText.charAt(0);
if ((c == 'M') || (c == 'S') || (c == 'T')) {
// # Most obs start with METAR, SPECI, TESTM, or TESTS. Skip
// over
// that tag,
// # a space, and the K or P, to get to the 3-char station ID.
if (lineText.length() > 10) {
result = lineText.substring(7, 10);
} else {
result = lineText.substring(lineText.length() - 3);
}
} else if ((c == 'W') || (c == 'Y')) {
// that tag,
// # a space, and the K or P, to get to the 3-char station ID.
if (lineText.length() > 10) {
result = lineText.substring(7, 10);
} else {
result = lineText.substring(lineText.length() - 3);
}
} else if ((c == 'W') || (c == 'Y')) {
// # Canadian SAOs have 3-character IDs, starting with W or Y.
// Grab
// 'em.
result = lineText.substring(0, 3);
} else {
// 'em.
result = lineText.substring(0, 3);
} else {
// # Some military obs don't get tagged. Skip the K or P and get
// 3
// chars.
int wordLineStart = 1;
result = lineText.substring(wordLineStart, wordLineStart + 4);
}
// chars.
int wordLineStart = 1;
result = lineText.substring(wordLineStart, wordLineStart + 4);
}
} catch (StringIndexOutOfBoundsException ex) {
// User has non METAR/SAO products and the parsing failed.
result = null;

View file

@ -71,7 +71,7 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog {
private String IMAGE_PRACTICE = "res/images/twsPractice.gif";
protected WarnGenConfirmationDlg(Shell parentShell, String title,
String productMessage, String modeMessage, CAVEMode mode) {
String productMessage, String modeMessage) {
super(parentShell, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL, CAVE.NONE
| CAVE.DO_NOT_BLOCK);
@ -79,7 +79,7 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog {
this.productMessage = productMessage;
this.modeMessage = modeMessage;
this.mode = mode;
this.mode = CAVEMode.getMode();
setReturnValue(Boolean.FALSE);
}

View file

@ -35,6 +35,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
* ------------ ---------- ----------- --------------------------
* Initial creation
* May 7, 2013 1973 rferrel Changes to properly display Issue Time.
* Jul 22, 2013 2176 jsanchez Added EMER to the display string in the update list.
* Aug 7, 2013 2243 jsanchez Set all the attributes of an AbstractWarningRecord and added an expiration string. Removed calendar object.
* Aug 15,2013 2243 jsanchez Improved the expiration string off by one minute.
* </pre>
@ -94,6 +95,9 @@ public class FollowupData extends WarningRecord {
rval.append(buildExpStr(status, record));
}
if (record.getRawmessage().contains("EMERGENCY")) {
rval.append(" EMER");
}
equvialentString = rval.substring(0,
record.getProductClass().equals("T") ? 20 : 18);

View file

@ -73,6 +73,7 @@ import com.vividsolutions.jts.geom.Geometry;
* May 10, 2013 1951 rjpeter Updated ugcZones references
* May 31, 2013 DR 16264 D. Friedman Fix query in prepare method.
* Jun 05, 2013 DR 16279 D. Friedman Fix updating of issuance time for followups.
* Jul 22, 2013 2176 jsanchez Set the raw message for an EXT.
* Aug 14, 2013 DR 16483 Qinglu Lin Fixed no option issue in WarnGen dropdown menu after
* issuance of an CANCON and restart of CAVE.
* </pre>
@ -314,6 +315,7 @@ public class CurrentWarnings {
if (rval != null) {
rval.setEndTime(warning.getEndTime());
rval.setIssueTime(warning.getIssueTime());
rval.setRawmessage(warning.getRawmessage());
}
}
}

View file

@ -79,6 +79,7 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
* Apr 18, 2013 1877 jsanchez Had the child classes set the comparator. Fixed a null pointer.
* Remove frameAltered condition in matchesFrame. It prevented entries from being displayed.
* Check if geometry is null when inspecting.
* Jul 22, 2013 2176 jsanchez Updated the wire frame and text for EMERGENCY warnings.
* </pre>
*
* @author jsanchez
@ -358,14 +359,23 @@ public abstract class AbstractWWAResource extends
}
if (entry != null && entry.wireframeShape != null) {
LineStyle lineStyle = (record.getProductClass() != null && record
.getProductClass().equals("T")) ? LineStyle.DASHED
: LineStyle.SOLID;
LineStyle lineStyle = LineStyle.SOLID;
if (record.getProductClass() != null
&& record.getProductClass().equals("T")) {
lineStyle = LineStyle.DASHED;
}
int outlineWidth = getCapability(OutlineCapability.class)
.getOutlineWidth();
// Make wire frame outline thicker for EMERGENCY warnings
if (record.getRawmessage().contains("EMERGENCY")) {
outlineWidth *= 2;
}
target.drawWireframeShape(
entry.wireframeShape,
getCapability(ColorableCapability.class).getColor(),
getCapability(OutlineCapability.class)
.getOutlineWidth(), lineStyle);
outlineWidth, lineStyle);
} else if (entry != null && entry.shadedShape != null) {
target.drawShadedShape(entry.shadedShape, 1);
}
@ -409,6 +419,14 @@ public abstract class AbstractWWAResource extends
params.magnification = getCapability(
MagnificationCapability.class).getMagnification();
target.drawStrings(params);
// Draws the string again to have it appear bolder
if (textToPrintReversed[2].endsWith("EMER")) {
params.setText(new String[] { "", "", "EMER", "" },
color);
target.drawStrings(params);
}
}
}
}
@ -581,7 +599,11 @@ public abstract class AbstractWWAResource extends
}
textToPrint[0] += "." + record.getEtn();
textToPrint[1] = record.getPil();
if (record.getRawmessage().contains("EMERGENCY")) {
textToPrint[1] = record.getPil() + " EMER";
} else {
textToPrint[1] = record.getPil();
}
SimpleDateFormat startFormat = DEFAULT_FORMAT;
SimpleDateFormat endFormat = DEFAULT_FORMAT;