Issue #436 Made hazardDict an OrderedDict so order of entries is preserved.
Modifed include path so procedures/smartTools are found before utilities of the same name so existing site MakeHazardConfig.py files in procedures will be found before the base file in utilities. Added code to default new localEffects dicts to empty so existing MakeHazardConfig.py files can be used. Change-Id: I4a59d930f8b93bf76c28f3dec3881fbccc077eff Former-commit-id:16231374f8
[formerlyd7a818fd1d
] [formerly16231374f8
[formerlyd7a818fd1d
] [formerly7662d249ab
[formerly 18f0efe7a8d9f2c31786fc449403f720b554b95d]]] Former-commit-id:7662d249ab
Former-commit-id:6e3674f9fc
[formerlyd3693827a1
] Former-commit-id:1b655b0826
This commit is contained in:
parent
b78c280ac8
commit
f69d7b9c64
6 changed files with 86 additions and 108 deletions
|
@ -29,10 +29,6 @@ import numpy
|
|||
import LogStream
|
||||
import JUtil
|
||||
|
||||
if sys.modules.has_key("MakeHazardConfig"):
|
||||
sys.modules.__delitem__("MakeHazardConfig")
|
||||
import MakeHazardConfig
|
||||
|
||||
class Procedure (SmartScript.SmartScript):
|
||||
def __init__(self, dbss):
|
||||
SmartScript.SmartScript.__init__(self, dbss)
|
||||
|
@ -45,6 +41,9 @@ class Procedure (SmartScript.SmartScript):
|
|||
|
||||
|
||||
def setUpUI(self):
|
||||
if sys.modules.has_key("MakeHazardConfig"):
|
||||
sys.modules.__delitem__("MakeHazardConfig")
|
||||
import MakeHazardConfig
|
||||
|
||||
args = {}
|
||||
args['dataManager'] = self._dataManager
|
||||
|
@ -59,8 +58,18 @@ class Procedure (SmartScript.SmartScript):
|
|||
args['tcmList'] = MakeHazardConfig.tcmList
|
||||
args['tropicalHaz'] = self._tropicalHaz
|
||||
args['natlBaseETN'] = self._natlBaseETN
|
||||
args['localEffectAreas'] = MakeHazardConfig.localEffectAreas
|
||||
args['localAreaData'] = MakeHazardConfig.localAreaData
|
||||
|
||||
if not hasattr(MakeHazardConfig, 'localEffectAreas') or \
|
||||
MakeHazardConfig.localEffectAreas is None:
|
||||
args['localEffectAreas'] = {}
|
||||
else:
|
||||
args['localEffectAreas'] = MakeHazardConfig.localEffectAreas
|
||||
|
||||
if not hasattr(MakeHazardConfig, 'localAreaData') or \
|
||||
MakeHazardConfig.localAreaData is None:
|
||||
args['localAreaData'] = {}
|
||||
else:
|
||||
args['localAreaData'] = MakeHazardConfig.localAreaData
|
||||
|
||||
# create the Java/SWT dialog and open it
|
||||
from com.raytheon.viz.gfe.makehazard import MakeHazardDialog
|
||||
|
|
|
@ -39,49 +39,54 @@ def sortHazardList(dict):
|
|||
# change the order so that the most common values your site uses are
|
||||
# near the front of each list. The key is the menu entry on the
|
||||
# Make Hazard dialog, the values are the key values for Hazards.
|
||||
hazardDict = {
|
||||
'Winter Weather' : ["BZ.W", "BZ.A", "ZR.Y",
|
||||
|
||||
# Using OrderedDict allows you to control the order in which the
|
||||
# Hazard Types are displayed in the dialog
|
||||
#
|
||||
from collections import OrderedDict
|
||||
hazardDict = OrderedDict([
|
||||
('Winter Weather', ["BZ.W", "BZ.A", "ZR.Y",
|
||||
"IS.W", "LE.Y", "LE.W", "LE.A",
|
||||
"WC.Y", "WC.W", "WC.A", "WS.W", "WS.A", "WW.Y"],
|
||||
'Hydrology' : ["FF.A", "FA.A"],
|
||||
'Fire Weather' : ["FW.A", "FW.W"],
|
||||
'Convective Watches' : ["SV.A", "TO.A"],
|
||||
'Coastal Flood' : ["CF.S", "LS.S", "CF.Y", "CF.W", "CF.A",
|
||||
"SU.Y", "SU.W", "LS.Y", "LS.W", "LS.A", "RP.S"],
|
||||
'Non-Precipitation' : ["AF.W", "AF.Y", "AQ.Y", "AS.O", "AS.Y", "DU.Y",
|
||||
"WC.Y", "WC.W", "WC.A", "WS.W", "WS.A", "WW.Y"]),
|
||||
('Hydrology', ["FF.A", "FA.A"]),
|
||||
('Fire Weather', ["FW.A", "FW.W"]),
|
||||
('Convective Watches', ["SV.A", "TO.A"]),
|
||||
('Coastal Flood', ["CF.S", "LS.S", "CF.Y", "CF.W", "CF.A",
|
||||
"SU.Y", "SU.W", "LS.Y", "LS.W", "LS.A", "RP.S"]),
|
||||
('Non-Precipitation', ["AF.W", "AF.Y", "AQ.Y", "AS.O", "AS.Y", "DU.Y",
|
||||
"DS.W", "EH.W", "EH.A", "EC.W", "EC.A", "FG.Y", "FZ.W", "FZ.A",
|
||||
"HZ.W", "HZ.A", "ZF.Y", "FR.Y", "HT.Y", "HW.W", "HW.A",
|
||||
"LW.Y", "SM.Y", "WI.Y"],
|
||||
'Marine' : ["MA.S", "MH.W", "MH.Y", "BW.Y", "UP.Y", "MF.Y",
|
||||
"LW.Y", "SM.Y", "WI.Y"]),
|
||||
('Marine', ["MA.S", "MH.W", "MH.Y", "BW.Y", "UP.Y", "MF.Y",
|
||||
"GL.A", "GL.W", "SE.A", "SE.W", "UP.A", "UP.W", "HF.A", "HF.W", "LO.Y", "SC.Y", "SW.Y",
|
||||
"RB.Y", "SI.Y", "MS.Y", "SR.A", "SR.W"],
|
||||
'Tropical Cyclone' : ["HU.W", "HU.A", "HU.S", "TR.W", "TR.A"],
|
||||
'Tsunami' : ["TS.A", "TS.W"],
|
||||
"RB.Y", "SI.Y", "MS.Y", "SR.A", "SR.W"]),
|
||||
('Tropical Cyclone', ["HU.W", "HU.A", "HU.S", "TR.W", "TR.A"]),
|
||||
('Tsunami', ["TS.A", "TS.W"]),
|
||||
|
||||
#'Local' : ["TEST"], #example of adding local hazards
|
||||
# ('Local', ["TEST"]), #example of adding local hazards
|
||||
# you can define your own groups of hazards by adding new categories
|
||||
}
|
||||
])
|
||||
|
||||
# for GUM use comment out the above definition and uncomment the one below
|
||||
|
||||
#hazardDict = {
|
||||
# 'Hydrology' : ["FF.A", "FA.A"],
|
||||
# 'Fire Weather' : ["FW.A", "FW.W"],
|
||||
# 'Coastal Flood' : ["CF.S", "LS.S", "CF.Y", "CF.W", "CF.A",
|
||||
# "SU.Y", "SU.W", "LS.Y", "LS.W", "LS.A", "RP.S"],
|
||||
# 'Non-Precipitation' : ["AF.W", "AF.Y", "AQ.Y", "AS.O", "AS.Y", "DU.Y",
|
||||
#hazardDict = OrderedDict([
|
||||
# ('Hydrology', ["FF.A", "FA.A"]),
|
||||
# ('Fire Weather', ["FW.A", "FW.W"]),
|
||||
# ('Coastal Flood', ["CF.S", "LS.S", "CF.Y", "CF.W", "CF.A",
|
||||
# "SU.Y", "SU.W", "LS.Y", "LS.W", "LS.A", "RP.S"]),
|
||||
# ('Non-Precipitation', ["AF.W", "AF.Y", "AQ.Y", "AS.O", "AS.Y", "DU.Y",
|
||||
# "DS.W", "EH.W", "EH.A", "EC.W", "EC.A", "FG.Y", "FZ.W", "FZ.A",
|
||||
# "HZ.W", "HZ.A", "ZF.Y", "FR.Y", "HT.Y", "HW.W", "HW.A",
|
||||
# "LW.Y", "SM.Y", "WI.Y"],
|
||||
# 'Marine' : ["MA.S", "MH.W", "MH.Y", "BW.Y", "UP.Y", "MF.Y",
|
||||
# "LW.Y", "SM.Y", "WI.Y"]),
|
||||
# ('Marine', ["MA.S", "MH.W", "MH.Y", "BW.Y", "UP.Y", "MF.Y",
|
||||
# "GL.A", "GL.W", "SE.A", "SE.W", "UP.A", "UP.W", "HF.A", "HF.W", "LO.Y", "SC.Y", "SW.Y",
|
||||
# "RB.Y", "SI.Y", "MS.Y", "SR.A", "SR.W"],
|
||||
# 'Typhoon' : ["TY.A", "TY.W", "TR.A", "TR.W", "HU.S"],
|
||||
# 'Tsunami' : ["TS.A", "TS.W"],
|
||||
# "RB.Y", "SI.Y", "MS.Y", "SR.A", "SR.W"]),
|
||||
# ('Typhoon', ["TY.A", "TY.W", "TR.A", "TR.W", "HU.S"]),
|
||||
# ('Tsunami', ["TS.A", "TS.W"]),
|
||||
#
|
||||
# #'Local' : ["TEST"], #example of adding local hazards
|
||||
# # ('Local', ["TEST"]), #example of adding local hazards
|
||||
# # you can define your own groups of hazards by adding new categories
|
||||
# }
|
||||
# ])
|
||||
|
||||
|
||||
# This function sorts the hazards in the hazardDict by description.
|
||||
|
@ -140,7 +145,9 @@ tcmList = [] # Comment out for HLS sites
|
|||
#tcmList = ["TCMCP1", "TCMCP2", "TCMCP3", "TCMCP4", "TCMCP5"]
|
||||
|
||||
# Dictionary mapping Hazard Types to applicable local effect areas
|
||||
# that can be intersected with the zone edit areas
|
||||
# that can be intersected with the zone edit areas.
|
||||
# You should not define localEffectAreas entries for Tropical Cyclone
|
||||
# or Convective Watches.
|
||||
localEffectAreas = {}
|
||||
|
||||
#localEffectAreas = {
|
||||
|
|
|
@ -25,14 +25,12 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
@ -1000,50 +998,33 @@ public class MakeHazardDialog extends CaveSWTDialog implements
|
|||
|
||||
List<String> groups = new ArrayList<String>(getHazardsDictionary()
|
||||
.keySet());
|
||||
Collections.sort(groups);
|
||||
this.currentHazardType = "";
|
||||
|
||||
SelectionAdapter selAdapt = new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
// org.eclipse.swt.widgets.List list =
|
||||
// (org.eclipse.swt.widgets.List) e
|
||||
// .getSource();
|
||||
// String[] sel = list.getSelection();
|
||||
// if (sel.length > 0) {
|
||||
// setHazardType(sel[0]);
|
||||
// }
|
||||
|
||||
Button b = (Button) e.getSource();
|
||||
if (b.getSelection()) {
|
||||
String key = b.getText();
|
||||
setHazardType(key);
|
||||
org.eclipse.swt.widgets.List list = (org.eclipse.swt.widgets.List) e
|
||||
.getSource();
|
||||
String[] sel = list.getSelection();
|
||||
if (sel.length > 0) {
|
||||
setHazardType(sel[0]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// org.eclipse.swt.widgets.List hazardGroupList = new
|
||||
// org.eclipse.swt.widgets.List(
|
||||
// hazardTypeGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL
|
||||
// | SWT.SINGLE);
|
||||
// gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
// gd.heightHint = hazardGroupList.getItemHeight() * 12
|
||||
// + hazardGroupList.getBorderWidth();
|
||||
// hazardGroupList.setLayoutData(gd);
|
||||
// hazardGroupList.addSelectionListener(selAdapt);
|
||||
// for (String k : groups) {
|
||||
// hazardGroupList.add(k);
|
||||
// if (k.equals(this.defaultHazardType)) {
|
||||
// hazardGroupList.select(hazardGroupList.getItemCount() - 1);
|
||||
// }
|
||||
// }
|
||||
|
||||
org.eclipse.swt.widgets.List hazardGroupList = new org.eclipse.swt.widgets.List(
|
||||
hazardTypeGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL
|
||||
| SWT.SINGLE);
|
||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
gd.heightHint = hazardGroupList.getItemHeight() * 12
|
||||
+ hazardGroupList.getBorderWidth();
|
||||
hazardGroupList.setLayoutData(gd);
|
||||
hazardGroupList.addSelectionListener(selAdapt);
|
||||
for (String k : groups) {
|
||||
// add a radio button control to the radioComposite
|
||||
Button radioButton = new Button(hazardTypeGroup, SWT.RADIO);
|
||||
radioButton.setText(k);
|
||||
radioButton.addSelectionListener(selAdapt);
|
||||
radioButton.setSelection(k.equals(this.defaultHazardType));
|
||||
hazardGroupList.add(k);
|
||||
if (k.equals(this.defaultHazardType)) {
|
||||
hazardGroupList.select(hazardGroupList.getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
etnSegNumberField = new Text(etnSegNumGroup, SWT.BORDER);
|
||||
|
@ -1237,33 +1218,6 @@ public class MakeHazardDialog extends CaveSWTDialog implements
|
|||
}
|
||||
|
||||
private Map<String, List<String>> getHazardsDictionary() {
|
||||
if (hazardDict == null) {
|
||||
hazardDict = new TreeMap<String, List<String>>();
|
||||
hazardDict.put("Winter Weather", Arrays.asList("BZ.W", "BZ.A",
|
||||
"BS.Y", "ZR.Y", "HS.W", "IS.W", "LE.Y", "LE.W", "LE.A",
|
||||
"LB.Y", "IP.Y", "IP.W", "SN.Y", "SB.Y", "WC.Y", "WC.W",
|
||||
"WC.A", "WS.W", "WS.A", "WW.Y"));
|
||||
hazardDict.put("Hydrology", Arrays.asList("FF.A", "FA.A"));
|
||||
hazardDict.put("Fire Weather", Arrays.asList("FW.A", "FW.W"));
|
||||
hazardDict.put("Convective Watches", Arrays.asList("SV.A", "TO.A"));
|
||||
hazardDict.put("Coastal Flood", Arrays.asList("CF.S", "LS.S",
|
||||
"CF.Y", "CF.W", "CF.A", "SU.Y", "SU.W", "RP.S", "LS.Y",
|
||||
"LS.W", "LS.A"));
|
||||
hazardDict.put("Non-Precipitation", Arrays.asList("AF.W", "AF.Y",
|
||||
"AS.Y", "DU.Y", "DS.W", "EH.W", "EH.A", "EC.W", "EC.A",
|
||||
"FG.Y", "FZ.W", "FZ.A", "HZ.W", "HZ.A", "ZF.Y", "FR.Y",
|
||||
"HT.Y", "HW.W", "HW.A", "LW.Y", "SM.Y", "WI.Y"));
|
||||
hazardDict.put("Common Marine/NPW",
|
||||
Arrays.asList("AF.W", "AF.Y", "FG.Y", "SM.Y"));
|
||||
hazardDict.put("Marine", Arrays.asList("MA.S", "MH.W", "MH.Y",
|
||||
"BW.Y", "UP.Y", "FG.Y", "GL.A", "GL.W", "SE.A", "SE.W",
|
||||
"UP.A", "UP.W", "HF.A", "HF.W", "LO.Y", "SC.Y", "SW.Y",
|
||||
"RB.Y", "SI.Y", "SM.Y", "SR.A", "SR.W"));
|
||||
hazardDict.put("Tropical Cyclone",
|
||||
Arrays.asList("HU.W", "HU.A", "HU.S", "TR.W", "TR.A"));
|
||||
hazardDict.put("Tsunami", Arrays.asList("TS.A", "TS.W"));
|
||||
}
|
||||
|
||||
return hazardDict;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ public class ProcedureFactory {
|
|||
GfePyIncludeUtil.getCommonPythonIncludePath(),
|
||||
GfePyIncludeUtil.getVtecIncludePath(),
|
||||
GfePyIncludeUtil.getCommonGfeIncludePath(),
|
||||
GfePyIncludeUtil.getUtilitiesIncludePath(),
|
||||
GfePyIncludeUtil.getProceduresIncludePath());
|
||||
GfePyIncludeUtil.getProceduresIncludePath(),
|
||||
GfePyIncludeUtil.getUtilitiesIncludePath());
|
||||
|
||||
ProcedureController procCont = null;
|
||||
if (ui) {
|
||||
|
|
|
@ -63,8 +63,8 @@ public class SmartToolFactory {
|
|||
GfePyIncludeUtil.getCommonPythonIncludePath(),
|
||||
GfePyIncludeUtil.getVtecIncludePath(),
|
||||
GfePyIncludeUtil.getCommonGfeIncludePath(),
|
||||
GfePyIncludeUtil.getUtilitiesIncludePath(),
|
||||
GfePyIncludeUtil.getSmartToolsIncludePath());
|
||||
GfePyIncludeUtil.getSmartToolsIncludePath(),
|
||||
GfePyIncludeUtil.getUtilitiesIncludePath());
|
||||
|
||||
SmartToolController smartCont = null;
|
||||
if (ui) {
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
|
||||
|
||||
from java.lang import Integer, Float, Long, Boolean, String
|
||||
from java.util import HashMap, ArrayList
|
||||
from java.util import HashMap, LinkedHashMap, ArrayList
|
||||
from java.util import Collections
|
||||
from collections import OrderedDict
|
||||
|
||||
#
|
||||
# Provides convenience methods for Java-Python bridging
|
||||
|
@ -72,15 +73,22 @@ def javaStringMapToPyDict(javaMap):
|
|||
def javaMapToPyDict(javaMap, customConverter=None):
|
||||
keys = javaMap.keySet()
|
||||
itr = keys.iterator()
|
||||
pyDict = {}
|
||||
if javaMap.jclassname == "java.util.LinkedHashMap":
|
||||
pyDict = OrderedDict()
|
||||
else:
|
||||
pyDict = {}
|
||||
while itr.hasNext():
|
||||
key = itr.next()
|
||||
obj = javaMap.get(key)
|
||||
pyDict[javaObjToPyVal(key)] = javaObjToPyVal(obj, customConverter)
|
||||
return pyDict
|
||||
|
||||
def pyDictToJavaMap(pyDict):
|
||||
jmap = HashMap()
|
||||
def pyDictToJavaMap(pyDict):
|
||||
if isinstance(pyDict, OrderedDict):
|
||||
jmap = LinkedHashMap()
|
||||
else:
|
||||
jmap = HashMap()
|
||||
|
||||
for key in pyDict:
|
||||
jmap.put(pyValToJavaObj(key), pyValToJavaObj(pyDict[key]))
|
||||
return jmap
|
||||
|
@ -105,7 +113,7 @@ def pyValToJavaObj(val):
|
|||
for i in val:
|
||||
tempList.add(pyValToJavaObj(i))
|
||||
retObj = Collections.unmodifiableList(tempList)
|
||||
elif valtype is dict:
|
||||
elif issubclass(valtype, dict):
|
||||
retObj = pyDictToJavaMap(val)
|
||||
elif issubclass(valtype, JavaWrapperClass):
|
||||
retObj = val.toJavaObj()
|
||||
|
|
Loading…
Add table
Reference in a new issue