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 * 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/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 * 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> * </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);
}
}
}
/** @Override
* 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
public void clearAll() { public void clearAll() {
if (shell == null) { if (shell == null) {
return; return;
@ -1095,7 +1095,7 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
fileMenuItem.setMenu(fileMenu); fileMenuItem.setMenu(fileMenu);
fileMenu.addListener(SWT.Show, new Listener() { fileMenu.addListener(SWT.Show, new Listener() {
public void handleEvent(Event event) { public void handleEvent(Event event) {
setAltFlagForEditorTafTabComp(); setAltFlagForEditorTafTabComp();
} }
}); });
@ -1206,7 +1206,7 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
optionsMenuItem.setMenu(optionsMenu); optionsMenuItem.setMenu(optionsMenu);
optionsMenu.addListener(SWT.Show, new Listener() { optionsMenu.addListener(SWT.Show, new Listener() {
public void handleEvent(Event event) { public void handleEvent(Event event) {
setAltFlagForEditorTafTabComp(); setAltFlagForEditorTafTabComp();
} }
}); });
@ -1285,7 +1285,7 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
editMenuItem.setMenu(editMenu); editMenuItem.setMenu(editMenu);
editMenu.addListener(SWT.Show, new Listener() { editMenu.addListener(SWT.Show, new Listener() {
public void handleEvent(Event event) { public void handleEvent(Event event) {
setAltFlagForEditorTafTabComp(); setAltFlagForEditorTafTabComp();
} }
}); });
@ -1364,16 +1364,15 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
} }
/** /**
* When respectively using alt+'f', alt+'e', alt+'o' and alt+'h' * When respectively using alt+'f', alt+'e', alt+'o' and alt+'h' to
* to open/display menus 'File', 'Edit', 'Options' and 'Help', * open/display menus 'File', 'Edit', 'Options' and 'Help', the alt flag of
* the alt flag of the editorTafTabComp object is set to true; * the editorTafTabComp object is set to true; it needs to be re-set to
* it needs to be re-set to false * false (DR16980)
* (DR16980)
*/ */
private void setAltFlagForEditorTafTabComp() { private void setAltFlagForEditorTafTabComp() {
if ( editorTafTabComp.getAlt() ) { if (editorTafTabComp.getAlt()) {
editorTafTabComp.setAlt(false); editorTafTabComp.setAlt(false);
} }
} }
/** /**
@ -1394,7 +1393,7 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
helpMenuItem.setMenu(helpMenu); helpMenuItem.setMenu(helpMenu);
helpMenu.addListener(SWT.Show, new Listener() { helpMenu.addListener(SWT.Show, new Listener() {
public void handleEvent(Event event) { public void handleEvent(Event event) {
setAltFlagForEditorTafTabComp(); setAltFlagForEditorTafTabComp();
} }
}); });
@ -2033,10 +2032,10 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
String bbb = editorTafTabComp.getBBB(); String bbb = editorTafTabComp.getBBB();
// DR166478 // DR166478
if ( toolName.equals("UseMetarForPrevailing") ) { if (toolName.equals("UseMetarForPrevailing")) {
if ( checkBasicSyntaxError(true) ) { if (checkBasicSyntaxError(true)) {
return; return;
} }
} }
// Setup for python request // Setup for python request
@ -2110,7 +2109,7 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
*/ */
private boolean checkBasicSyntaxError(boolean doLogMessage) { private boolean checkBasicSyntaxError(boolean doLogMessage) {
String in = editorTafTabComp.getTextEditorControl().getText(); String in = editorTafTabComp.getTextEditorControl().getText();
clearSyntaxErrorLevel(); clearSyntaxErrorLevel();
@ -2151,58 +2150,65 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
int equalSignIndex = in.indexOf("="); int equalSignIndex = in.indexOf("=");
int lastEqualSignIndex = equalSignIndex; int lastEqualSignIndex = equalSignIndex;
if ( tafIndex < 0 && equalSignIndex < 0 ) { // empty TAF if (tafIndex < 0 && equalSignIndex < 0) { // empty TAF
return false; return false;
} }
while (tafIndex > -1 || equalSignIndex > -1) { while (tafIndex > -1 || equalSignIndex > -1) {
if ( tafIndex == -1 || tafIndex > equalSignIndex ) { if (tafIndex == -1 || tafIndex > equalSignIndex) {
int lineIndexOfFirstEqualSign = st.getLineAtOffset(lastEqualSignIndex); int lineIndexOfFirstEqualSign = st
int lineIndexOfSecondEqualSign = st.getLineAtOffset(equalSignIndex); .getLineAtOffset(lastEqualSignIndex);
if ( lineIndexOfFirstEqualSign == lineIndexOfSecondEqualSign ) { int lineIndexOfSecondEqualSign = st
StyleRange sr = new StyleRange(lastEqualSignIndex,1,null,qcColors[3]); .getLineAtOffset(equalSignIndex);
String msg = "Syntax error: there is an extra '=' sign in this line"; if (lineIndexOfFirstEqualSign == lineIndexOfSecondEqualSign) {
syntaxMap.put(sr, msg); StyleRange sr = new StyleRange(lastEqualSignIndex, 1, null,
st.setStyleRange(null); qcColors[3]);
st.setStyleRange(sr); String msg = "Syntax error: there is an extra '=' sign in this line";
syntaxMap.put(sr, msg);
st.setStyleRange(null);
st.setStyleRange(sr);
if (doLogMessage) { if (doLogMessage) {
msgStatComp.setMessageText(msg, qcColors[3].getRGB()); msgStatComp.setMessageText(msg, qcColors[3].getRGB());
} }
return true; return true;
} }
int startIndex = lastEqualSignIndex; int startIndex = lastEqualSignIndex;
while ( !in.substring(startIndex,startIndex+1).matches("[A-Z]") && !in.substring(startIndex,startIndex+1).matches("[0-9]") ) { while (!in.substring(startIndex, startIndex + 1).matches(
startIndex++; "[A-Z]")
} && !in.substring(startIndex, startIndex + 1).matches(
int length = 6; "[0-9]")) {
if ( (equalSignIndex-startIndex) < 6 ) { startIndex++;
length = equalSignIndex-startIndex; }
} int length = 6;
StyleRange sr = new StyleRange(startIndex,length,null,qcColors[3]); if ((equalSignIndex - startIndex) < 6) {
String msg = "Syntax error: There is an extra '=' sign before this point, or 'TAF' is missing at beginning of TAF"; length = equalSignIndex - startIndex;
syntaxMap.put(sr, msg); }
st.setStyleRange(null); StyleRange sr = new StyleRange(startIndex, length, null,
st.setStyleRange(sr); 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) { if (doLogMessage) {
msgStatComp.setMessageText(msg, qcColors[3].getRGB()); msgStatComp.setMessageText(msg, qcColors[3].getRGB());
} }
return true; return true;
} }
tafIndex = in.indexOf("TAF", tafIndex+1); tafIndex = in.indexOf("TAF", tafIndex + 1);
lastEqualSignIndex = equalSignIndex; lastEqualSignIndex = equalSignIndex;
equalSignIndex = in.indexOf("=", equalSignIndex+1); equalSignIndex = in.indexOf("=", equalSignIndex + 1);
} }
return false; return false;
} }
private void syntaxCheck() { private void syntaxCheck() {
// Assume editorTafTabComp is for the active tab. // Assume editorTafTabComp is for the active tab.
st = editorTafTabComp.getTextEditorControl(); st = editorTafTabComp.getTextEditorControl();
st.setText(st.getText().toUpperCase()); st.setText(st.getText().toUpperCase());
@ -3672,6 +3678,11 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
Map<List<String>, Object> results = runPythonQC(tafs, sites, Map<List<String>, Object> results = runPythonQC(tafs, sites,
qcItems, bbb); qcItems, bbb);
if (results == null) {
setMessageStatusError("An Error occured while performing the QC check.");
return;
}
// Display the QC results // Display the QC results
int beginIndex = 0; int beginIndex = 0;
int endIndex = in.indexOf('\n'); 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; Map<List<String>, Object> resultMap = (HashMap<List<String>, Object>) map;
return resultMap; return resultMap;
} catch (JepException e) { } catch (JepException e) {
statusHandler
.handle(Priority.PROBLEM,
"Python error occurred while executing QC - see message details.",
e);
e.printStackTrace(); e.printStackTrace();
return null; return null;
} finally { } finally {

View file

@ -103,6 +103,8 @@
# Title: AvnFPS: TUG code does not handle transition from warm to cold seasons # 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 itertools, logging, math, os, sets, time
import ConfigParser import ConfigParser
import numpy, pupynere import numpy, pupynere
@ -492,7 +494,7 @@ def run(tafs, siteinfo, items, dataDir):
d = {} d = {}
path = os.path.join(ConfigDir, 'gui', 'TafMonitorCfg.xml') path = os.path.join(ConfigDir, 'gui', 'TafMonitorCfg.xml')
if not os.path.isfile(path): 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 return None
tafMonCfg = TafMonitorCfg.unmarshal(path) tafMonCfg = TafMonitorCfg.unmarshal(path)
jMonCfgs = tafMonCfg.getMonitorCfgs() jMonCfgs = tafMonCfg.getMonitorCfgs()