Issue #2925 - Fixed NPE found during testing.

Former-commit-id: a700d23f6d [formerly cc7d240cfd] [formerly c29981fa99] [formerly a700d23f6d [formerly cc7d240cfd] [formerly c29981fa99] [formerly 5b73c516d3 [formerly c29981fa99 [formerly 86306076f94bbfe4e063c4e6d82b7140b5911e61]]]]
Former-commit-id: 5b73c516d3
Former-commit-id: 1fb169f1ce [formerly 05a4c4e31b] [formerly 0052d9d30c35dc39dd69aece42fc59a0f471c58f [formerly f08d4a827f]]
Former-commit-id: 275c2d56eebfcd30f92e3347955172f87a580714 [formerly 2384cc90c0]
Former-commit-id: f160e66a85
This commit is contained in:
Lee Venable 2014-03-21 12:41:13 -05:00
parent 7944e2c35a
commit d08f39f428
2 changed files with 98 additions and 81 deletions

View file

@ -231,6 +231,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* 10/24/2013 16478 zhao add syntax check for extra '=' sign
* 02/12/2014 17076 lvenable Mark guidance tabs as not current so they get refreshed
* 02/19/2014 16980 zhao add code to ensure the Alt flag is false after the Alt kay is released
* 21Mar2014 #2925 lvenable Fixed NPE error found during testing.
*
* </pre>
*
@ -777,19 +778,18 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
}
}
/**
* Mark the tabs as not current so they get refreshed.
*/
private void markTabsAsNotCurrent() {
for (TabItem tbi : guidanceViewerFolder.getItems()) {
if (tbi.getControl() instanceof ViewerTab) {
((ViewerTab) tbi.getControl()).setDisplayCurrent(false);
}
}
}
/**
* Mark the tabs as not current so they get refreshed.
*/
private void markTabsAsNotCurrent() {
for (TabItem tbi : guidanceViewerFolder.getItems()) {
if (tbi.getControl() instanceof ViewerTab) {
((ViewerTab) tbi.getControl()).setDisplayCurrent(false);
}
}
}
@Override
@Override
public void clearAll() {
if (shell == null) {
return;
@ -1095,7 +1095,7 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
fileMenuItem.setMenu(fileMenu);
fileMenu.addListener(SWT.Show, new Listener() {
public void handleEvent(Event event) {
setAltFlagForEditorTafTabComp();
setAltFlagForEditorTafTabComp();
}
});
@ -1206,7 +1206,7 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
optionsMenuItem.setMenu(optionsMenu);
optionsMenu.addListener(SWT.Show, new Listener() {
public void handleEvent(Event event) {
setAltFlagForEditorTafTabComp();
setAltFlagForEditorTafTabComp();
}
});
@ -1285,10 +1285,10 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
editMenuItem.setMenu(editMenu);
editMenu.addListener(SWT.Show, new Listener() {
public void handleEvent(Event event) {
setAltFlagForEditorTafTabComp();
setAltFlagForEditorTafTabComp();
}
});
// -------------------------------------------------
// Create all the items in the Edit dropdown menu
// -------------------------------------------------
@ -1362,19 +1362,18 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
}
});
}
/**
* When respectively using alt+'f', alt+'e', alt+'o' and alt+'h'
* to open/display menus 'File', 'Edit', 'Options' and 'Help',
* the alt flag of the editorTafTabComp object is set to true;
* it needs to be re-set to false
* (DR16980)
* When respectively using alt+'f', alt+'e', alt+'o' and alt+'h' to
* open/display menus 'File', 'Edit', 'Options' and 'Help', the alt flag of
* the editorTafTabComp object is set to true; it needs to be re-set to
* false (DR16980)
*/
private void setAltFlagForEditorTafTabComp() {
if ( editorTafTabComp.getAlt() ) {
editorTafTabComp.setAlt(false);
}
}
private void setAltFlagForEditorTafTabComp() {
if (editorTafTabComp.getAlt()) {
editorTafTabComp.setAlt(false);
}
}
/**
* Create the Help menu.
@ -1394,7 +1393,7 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
helpMenuItem.setMenu(helpMenu);
helpMenu.addListener(SWT.Show, new Listener() {
public void handleEvent(Event event) {
setAltFlagForEditorTafTabComp();
setAltFlagForEditorTafTabComp();
}
});
@ -2018,7 +2017,7 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
configMgr.setDefaultFontAndColors(applyBtn);
applyBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
public void widgetSelected(SelectionEvent event) {
if (editorTafTabComp.getTextEditorControl().getText() != null
&& !editorTafTabComp.getTextEditorControl().getText()
.isEmpty()) {
@ -2031,12 +2030,12 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
String toolName = toolsCbo.getItem(toolsCbo
.getSelectionIndex());
String bbb = editorTafTabComp.getBBB();
// DR166478
if ( toolName.equals("UseMetarForPrevailing") ) {
if ( checkBasicSyntaxError(true) ) {
return;
}
if (toolName.equals("UseMetarForPrevailing")) {
if (checkBasicSyntaxError(true)) {
return;
}
}
// Setup for python request
@ -2106,18 +2105,18 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
/**
*
* @param doLogMessage
* @return true if error found, otherwise false
* @return true if error found, otherwise false
*/
private boolean checkBasicSyntaxError(boolean doLogMessage) {
String in = editorTafTabComp.getTextEditorControl().getText();
String in = editorTafTabComp.getTextEditorControl().getText();
clearSyntaxErrorLevel();
st = editorTafTabComp.getTextEditorControl();
final Map<StyleRange, String> syntaxMap = new HashMap<StyleRange, String>();
st.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseHover(MouseEvent e) {
@ -2147,62 +2146,69 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
}
});
int tafIndex = in.indexOf("TAF");
int tafIndex = in.indexOf("TAF");
int equalSignIndex = in.indexOf("=");
int lastEqualSignIndex = equalSignIndex;
if ( tafIndex < 0 && equalSignIndex < 0 ) { // empty TAF
return false;
if (tafIndex < 0 && equalSignIndex < 0) { // empty TAF
return false;
}
while (tafIndex > -1 || equalSignIndex > -1) {
if ( tafIndex == -1 || tafIndex > equalSignIndex ) {
int lineIndexOfFirstEqualSign = st.getLineAtOffset(lastEqualSignIndex);
int lineIndexOfSecondEqualSign = st.getLineAtOffset(equalSignIndex);
if ( lineIndexOfFirstEqualSign == lineIndexOfSecondEqualSign ) {
StyleRange sr = new StyleRange(lastEqualSignIndex,1,null,qcColors[3]);
String msg = "Syntax error: there is an extra '=' sign in this line";
syntaxMap.put(sr, msg);
st.setStyleRange(null);
st.setStyleRange(sr);
if (tafIndex == -1 || tafIndex > equalSignIndex) {
int lineIndexOfFirstEqualSign = st
.getLineAtOffset(lastEqualSignIndex);
int lineIndexOfSecondEqualSign = st
.getLineAtOffset(equalSignIndex);
if (lineIndexOfFirstEqualSign == lineIndexOfSecondEqualSign) {
StyleRange sr = new StyleRange(lastEqualSignIndex, 1, null,
qcColors[3]);
String msg = "Syntax error: there is an extra '=' sign in this line";
syntaxMap.put(sr, msg);
st.setStyleRange(null);
st.setStyleRange(sr);
if (doLogMessage) {
msgStatComp.setMessageText(msg, qcColors[3].getRGB());
}
return true;
}
int startIndex = lastEqualSignIndex;
while ( !in.substring(startIndex,startIndex+1).matches("[A-Z]") && !in.substring(startIndex,startIndex+1).matches("[0-9]") ) {
startIndex++;
}
int length = 6;
if ( (equalSignIndex-startIndex) < 6 ) {
length = equalSignIndex-startIndex;
}
StyleRange sr = new StyleRange(startIndex,length,null,qcColors[3]);
String msg = "Syntax error: There is an extra '=' sign before this point, or 'TAF' is missing at beginning of TAF";
syntaxMap.put(sr, msg);
st.setStyleRange(null);
st.setStyleRange(sr);
}
int startIndex = lastEqualSignIndex;
while (!in.substring(startIndex, startIndex + 1).matches(
"[A-Z]")
&& !in.substring(startIndex, startIndex + 1).matches(
"[0-9]")) {
startIndex++;
}
int length = 6;
if ((equalSignIndex - startIndex) < 6) {
length = equalSignIndex - startIndex;
}
StyleRange sr = new StyleRange(startIndex, length, null,
qcColors[3]);
String msg = "Syntax error: There is an extra '=' sign before this point, or 'TAF' is missing at beginning of TAF";
syntaxMap.put(sr, msg);
st.setStyleRange(null);
st.setStyleRange(sr);
if (doLogMessage) {
msgStatComp.setMessageText(msg, qcColors[3].getRGB());
}
return true;
}
tafIndex = in.indexOf("TAF", tafIndex+1);
lastEqualSignIndex = equalSignIndex;
equalSignIndex = in.indexOf("=", equalSignIndex+1);
}
return false;
}
private void syntaxCheck() {
return true;
}
tafIndex = in.indexOf("TAF", tafIndex + 1);
lastEqualSignIndex = equalSignIndex;
equalSignIndex = in.indexOf("=", equalSignIndex + 1);
}
return false;
}
private void syntaxCheck() {
// Assume editorTafTabComp is for the active tab.
st = editorTafTabComp.getTextEditorControl();
st.setText(st.getText().toUpperCase());
@ -3672,6 +3678,11 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
Map<List<String>, Object> results = runPythonQC(tafs, sites,
qcItems, bbb);
if (results == null) {
setMessageStatusError("An Error occured while performing the QC check.");
return;
}
// Display the QC results
int beginIndex = 0;
int endIndex = in.indexOf('\n');
@ -3867,6 +3878,10 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
Map<List<String>, Object> resultMap = (HashMap<List<String>, Object>) map;
return resultMap;
} catch (JepException e) {
statusHandler
.handle(Priority.PROBLEM,
"Python error occurred while executing QC - see message details.",
e);
e.printStackTrace();
return null;
} finally {

View file

@ -103,6 +103,8 @@
# Title: AvnFPS: TUG code does not handle transition from warm to cold seasons
#
#
# 21Mar2014 #2925 lvenable Fixed global name not defined error in run() method.
#
import itertools, logging, math, os, sets, time
import ConfigParser
import numpy, pupynere
@ -492,7 +494,7 @@ def run(tafs, siteinfo, items, dataDir):
d = {}
path = os.path.join(ConfigDir, 'gui', 'TafMonitorCfg.xml')
if not os.path.isfile(path):
raise Avn.AvnError('File %s does not exist' % fname)
raise Avn.AvnError('File %s does not exist' % path)
return None
tafMonCfg = TafMonitorCfg.unmarshal(path)
jMonCfgs = tafMonCfg.getMonitorCfgs()