Merge branch 'master_14.2.2' into asm_14.2.2

Remove unintentional changes from cd136c3.
Fix problem in warning-request.xml from 3c9c34c.

Conflicts:
	cave/build/static/linux/cave/cave.sh
	cave/build/static/linux/cave/caveUtil.sh
	cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/editor/TafViewerEditorDlg.java
	cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java
	cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/PolygonUtil.java
	cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java
	edexOsgi/com.raytheon.edex.plugin.warning/res/spring/warning-request.xml
	edexOsgi/com.raytheon.uf.common.ohd/utility/common_static/base/hydro/Apps_defaults
	edexOsgi/com.raytheon.uf.edex.plugin.manualIngest/res/spring/manualIngest-spring.xml

Change-Id: I814b0ae3c464bbb21b609870b3dca7d575ed948d

Former-commit-id: f146c7bcd0 [formerly cf35c1870fc4b6b3c2ceaf038274c4701f8046b1]
Former-commit-id: fd900e38c2
This commit is contained in:
David Friedman 2014-03-27 19:17:03 +00:00
commit 32a7adbe4b
1270 changed files with 88329 additions and 65918 deletions

View file

@ -268,7 +268,7 @@
<sequential>
<property name="___memorySettingsVersion___"
value="3.0"/>
value="4.0"/>
<if>
<not>
<equals
@ -392,6 +392,37 @@
append="true" />
</actions>
</call>
<!-- site type specific overrides (wfo, ncep, etc) -->
<call path="//${cave.arch}/site-type-override">
<param name="site-type"
path="site-type/text()" />
<param name="max-memory"
path="ini-substitutions/max-memory/value/text()" />
<param name="max-perm"
path="ini-substitutions/max-perm/value/text()" />
<actions>
<!-- Create a site-type-specific ini file -->
<copy verbose="true"
file="/tmp/cave/cave.ini"
tofile="/tmp/cave/@{site-type}.ini"
overwrite="true" />
<!-- Update the ini file -->
<update.ini
ini.file="@{site-type}.ini"
jvm.arg="${cave-memory-settings.default-memory-setting.default-max-memory.jvm-arg}"
current.value="${cave-memory-settings.default-memory-setting.default-max-memory.value}"
new.value="@{max-memory}" />
<update.ini
ini.file="@{site-type}.ini"
jvm.arg="${cave-memory-settings.default-memory-setting.default-max-perm.jvm-arg}"
current.value="${cave-memory-settings.default-memory-setting.default-max-perm.value}"
new.value="@{max-perm}" />
</actions>
</call>
</xmltask>
<!-- Finish the iniLookup.sh script -->

View file

@ -2,7 +2,7 @@
<cave-memory-settings>
<!-- The version should be incremented whenever
the file layout changes. -->
<file-version>3.0</file-version>
<file-version>4.0</file-version>
<!-- Example Entry ... See Below. -->
<!--
@ -107,6 +107,41 @@
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>servicebackup</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>128m</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-perspective</first-arg>
<second-arg>NCP</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>1536M</value>
</max-memory>
<max-perm>
<value>DEFAULT</value>
</max-perm>
</ini-substitutions>
</memory-setting>
</arch.x86>
<arch.x86_64>
@ -140,11 +175,11 @@
<ini-substitutions>
<max-memory>
<value>512M</value>
<value>256M</value>
</max-memory>
<max-perm>
<value>128m</value>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
@ -161,7 +196,7 @@
</max-memory>
<max-perm>
<value>128m</value>
<value>128M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
@ -182,6 +217,231 @@
</max-perm>
</ini-substitutions>
</memory-setting>
</arch.x86_64>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>servicebackup</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-perspective</first-arg>
<second-arg>NCP</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>2048M</value>
</max-memory>
<max-perm>
<value>DEFAULT</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>activatesite</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>avnsetup</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>metar</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>windrose</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>cigvisdist</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>cigvistrend</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>hydroTimeSeries</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>autodqc</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<!-- memory default overrides for a particular site type (wfo, ncep, etc) -->
<!-- site-type names need to be all lower case -->
<site-type-override>
<site-type>wfo</site-type>
<ini-substitutions>
<max-memory>
<value>3072M</value>
</max-memory>
<max-perm>
<value>DEFAULT</value>
</max-perm>
</ini-substitutions>
</site-type-override>
<site-type-override>
<site-type>rfc</site-type>
<ini-substitutions>
<max-memory>
<value>2048M</value>
</max-memory>
<max-perm>
<value>DEFAULT</value>
</max-perm>
</ini-substitutions>
</site-type-override>
<site-type-override>
<site-type>ncep</site-type>
<ini-substitutions>
<max-memory>
<value>2048M</value>
</max-memory>
<max-perm>
<value>DEFAULT</value>
</max-perm>
</ini-substitutions>
</site-type-override>
<site-type-override>
<site-type>cwsu</site-type>
<ini-substitutions>
<max-memory>
<value>3072M</value>
</max-memory>
<max-perm>
<value>DEFAULT</value>
</max-perm>
</ini-substitutions>
</site-type-override>
</arch.x86_64>
</cave-memory-settings>

View file

@ -1,5 +0,0 @@
s2s
default : SKY_COVER_00
1 : SKY_COVER_00
4 : SKY_COVER_08
7 : SKY_COVER_06

View file

@ -1,13 +0,0 @@
s2s
0 : SKY_COVER_00
1 : SKY_COVER_02
2 : SKY_COVER_03
4 : SKY_COVER_08
5 : SKY_COVER_00
6 : SKY_COVER_05
8 : SKY_COVER_09
9 : SKY_COVER_03
11 : SKY_COVER_03
12 : SKY_COVER_02
13 : SKY_COVER_02
14 : SKY_COVER_00

View file

@ -1,11 +0,0 @@
s2s
SEV : ICING_08
MODSEV : ICING_06
MOD : ICING_05
LGTMOD : ICING_04
LGT : ICING_03
TRACELGT: ICING_02
TRACE : ICING_01
NEG : ICING_00

View file

@ -1,10 +0,0 @@
s2s
0 : PRESSURE_TENDENCY_00
1 : PRESSURE_TENDENCY_01
2 : PRESSURE_TENDENCY_02
3 : PRESSURE_TENDENCY_03
4 : PRESSURE_TENDENCY_04
5 : PRESSURE_TENDENCY_05
6 : PRESSURE_TENDENCY_06
7 : PRESSURE_TENDENCY_07
8 : PRESSURE_TENDENCY_08

View file

@ -1,11 +0,0 @@
s2s
default : SKY_COVER_10
BLNK : SKY_COVER_10
SKC : SKY_COVER_00
CLR : SKY_COVER_00
FEW : SKY_COVER_02
SCT : SKY_COVER_03
BKN : SKY_COVER_06
OVC : SKY_COVER_08
OBS : SKY_COVER_09
VV : SKY_COVER_09

View file

@ -1,10 +0,0 @@
s2s
default : SKY_COVER_10
1 : SKY_COVER_10
2 : SKY_COVER_00
3 : SKY_COVER_00
4 : SKY_COVER_03
5 : SKY_COVER_02
6 : SKY_COVER_06
7 : SKY_COVER_08
8 : SKY_COVER_09

View file

@ -1,9 +0,0 @@
s2s
EXTRM :TURBULENCE_7
SEV :TURBULENCE_6
MODSEV:TURBULENCE_5
MOD :TURBULENCE_4
LGTMOD:TURBULENCE_3
LGT :TURBULENCE_2
NEGLGT:TURBULENCE_1
NEG :TURBULENCE_0

View file

@ -1,71 +0,0 @@
s2s
-SHRA : PRESENT_WX_080
+SHRA : PRESENT_WX_082
SHRA : PRESENT_WX_081
-SHSN : PRESENT_WX_085
+SHSN : PRESENT_WX_086
SHSN : PRESENT_WX_086
-TSRA : PRESENT_WX_095
+TSRA : PRESENT_WX_097
TSRA : PRESENT_WX_095
-TSSN : PRESENT_WX_095
+TSSN : PRESENT_WX_097
TSSN : PRESENT_WX_095
FZRASN : PRESENT_WX_066
BCBR : PRESENT_WX_010
MIBR : PRESENT_WX_010
BR : PRESENT_WX_010
FZFG : PRESENT_WX_048
BCFG : PRESENT_WX_041
MIFG : PRESENT_WX_044
FG : PRESENT_WX_045
TS : PRESENT_WX_095
+TS : PRESENT_WX_097
FC : PRESENT_WX_019
+FC : PRESENT_WX_019
PO : PRESENT_WX_008
DRSN : PRESENT_WX_036
+DRSN : PRESENT_WX_037
BLSN : PRESENT_WX_038
+BLSN : PRESENT_WX_039
FU : PRESENT_WX_004
HZ : PRESENT_WX_005
-SH : PRESENT_WX_080
SH : PRESENT_WX_081
DU : PRESENT_WX_006
SA : PRESENT_WX_007
SS : PRESENT_WX_009
DS : PRESENT_WX_009
+SS : PRESENT_WX_009
+DS : PRESENT_WX_009
-FZRA : PRESENT_WX_066
-FZDZ : PRESENT_WX_056
FZRA : PRESENT_WX_067
FZDZ : PRESENT_WX_057
GR : PRESENT_WX_088
IC : PRESENT_WX_078
PE : PRESENT_WX_079
PL : PRESENT_WX_079
GS : PRESENT_WX_087
DZRA : PRESENT_WX_058
RADZ : PRESENT_WX_058
RASN : PRESENT_WX_069
SNRA : PRESENT_WX_069
-RA : PRESENT_WX_061
+RA : PRESENT_WX_065
RA : PRESENT_WX_063
-DZ : PRESENT_WX_051
+DZ : PRESENT_WX_055
DZ : PRESENT_WX_053
-SN : PRESENT_WX_071
+SN : PRESENT_WX_075
SN : PRESENT_WX_073
-UP : PRESENT_WX_203
+UP : PRESENT_WX_203
UP : PRESENT_WX_203
IP : PRESENT_WX_079
SG : PRESENT_WX_077
VA : PRESENT_WX_201
PRFG : PRESENT_WX_044
SQ : PRESENT_WX_018
BLDU : PRESENT_WX_007

View file

@ -85,8 +85,10 @@ if [ -f /awips2/java/jre/lib/amd64/server/libjvm.so ]; then
fi
#run a loop for alertviz
while [ $exitVal -ne 0 ]
count=0
while [ $exitVal -ne 0 -a $count -lt 10 ]
do
count=`expr $count + 1`
curTime=`date +%Y%m%d_%H%M%S`
LOGFILE=${LOGDIR}/alertviz_${curTime}_console.log
export LOGFILE_ALERTVIZ=${LOGDIR}/alertviz_${curTime}_admin.log

View file

@ -28,6 +28,8 @@
# cave sessions.
# Dec 05, 2013 #2590 dgilling Modified so gfeclient.sh can be wrapped
# around this script.
# Jan 24, 2014 #2739 bsteffen Log exit status
# Jan 30, 2014 #2593 bclement warns based on memory usage, fixed for INI files with spaces
#
#
@ -45,6 +47,8 @@ JAVA_INSTALL="/awips2/java"
PYTHON_INSTALL="/awips2/python"
export AWIPS_INSTALL_DIR="${CAVE_INSTALL}"
MAX_MEM_PROPORTION="0.9"
source ${CAVE_INSTALL}/caveUtil.sh
RC=$?
if [ ${RC} -ne 0 ]; then
@ -61,6 +65,9 @@ copyVizShutdownUtilIfNecessary
# delete any old disk caches in the background
deleteOldCaveDiskCaches &
# Enable core dumps
ulimit -c unlimited
export LD_LIBRARY_PATH=${JAVA_INSTALL}/lib:${PYTHON_INSTALL}/lib:$LD_LIBRARY_PATH
export LD_PRELOAD=libpython.so
if [[ -z "$CALLED_EXTEND_LIB_PATH" ]]; then
@ -109,20 +116,39 @@ export TEXTWS=`hostname | sed -e 's/lx/xt/g'`
hostName=`hostname -s`
if [[ $hostName =~ xt.* ]]; then
export IGNORE_NUM_CAVES=1
fi
# check number of running caves
if [[ -z $IGNORE_NUM_CAVES ]]; then
# free usually reports below on G threshold (11 instead of 12G), giving the 3 cave recommended in field
mem=( `free -g | grep "Mem:"` )
# get total memory on system in bytes
mem=( `free -b | grep "Mem:"` )
mem=${mem[1]}
let _maxCaves=mem/3
getPidsOfMyRunningCaves
if [[ "$_numPids" -ge "$_maxCaves" ]]; then
zenity --question --title "Max CAVE sessions already running" --text "$_numPids CAVE sessions already running. Starting more may impact system performance and stability.\n\nProceed?"
# get max amount of system memory used before we warn
memThreshold=$(echo "$mem * $MAX_MEM_PROPORTION" | bc)
# remove decimal
printf -v memThreshold "%.0f" "$memThreshold"
# get launcher.ini argument determined by user arguments
lookupINI "$@"
launcherRegex='--launcher.ini\s(.+\.ini)'
# default to cave.ini
targetIni="/awips2/cave/cave.ini"
if [[ $CAVE_INI_ARG =~ $launcherRegex ]]
then
targetIni="${BASH_REMATCH[1]}"
fi
# read max memory that could be used by this instance
memOfLaunchingCave=$(readMemFromIni "$targetIni")
# read total max memory of caves already running
getTotalMemOfRunningCaves
# add them together
_totalAfterStart=$(($memOfLaunchingCave + $_totalRunningMem))
if [[ "$_totalAfterStart" -ge "$memThreshold" ]]; then
# convert to megs for display
memOfLaunchingCave=$(($memOfLaunchingCave / $BYTES_IN_MB))
_totalRunningMem=$(($_totalRunningMem / $BYTES_IN_MB))
getPidsOfMyRunningCaves
memMsg="$_numPids CAVE applications already running with a combined max memory of ${_totalRunningMem}MB. "
memMsg+="The requested application has a max memory requirement of ${memOfLaunchingCave}MB. "
memMsg+="Starting may impact system performance and stability.\n\nProceed?"
zenity --question --title "Low Available Memory for Application" --text "$memMsg"
cancel="$?"
if [[ "$cancel" == "1" ]]; then
@ -165,7 +191,6 @@ then
PROGRAM_NAME="cave"
fi
hostName=`hostname -s`
BASE_LOGDIR=$HOME/caveData/logs/consoleLogs
LOGDIR=$BASE_LOGDIR/$hostName/
@ -177,49 +202,59 @@ fi
# delete any old disk caches in the background
deleteOldCaveLogs &
export pid=$$
curTime=`date +%Y%m%d_%H%M%S`
LOGFILE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_console.log"
export LOGFILE_CAVE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_alertviz.log"
export LOGFILE_PERFORMANCE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_perf.log"
# can we write to log directory
if [ -w ${LOGDIR} ]; then
touch ${LOGFILE}
fi
# At this point fork so that log files can be set up with the process pid and
# this process can log the exit status of cave.
(
export pid=`/bin/bash -c 'echo $PPID'`
# remove "-noredirect" flag from command-line if set so it doesn't confuse any
# commands we call later.
redirect="true"
USER_ARGS=()
while [[ $1 ]]
do
LOGFILE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_console.log"
export LOGFILE_CAVE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_alertviz.log"
export LOGFILE_PERFORMANCE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_perf.log"
# can we write to log directory
if [ -w ${LOGDIR} ]; then
touch ${LOGFILE}
fi
# remove "-noredirect" flag from command-line if set so it doesn't confuse any
# commands we call later.
redirect="true"
USER_ARGS=()
while [[ $1 ]]
do
if [[ "$1" == "-noredirect" ]]
then
redirect="false"
redirect="false"
else
USER_ARGS+=("$1")
USER_ARGS+=("$1")
fi
shift
done
done
# Special instructions for the 64-bit jvm.
ARCH_ARGS=""
if [ -f /awips2/java/jre/lib/amd64/server/libjvm.so ]; then
ARCH_ARGS="-vm /awips2/java/jre/lib/amd64/server/libjvm.so"
fi
# Special instructions for the 64-bit jvm.
ARCH_ARGS=""
if [ -f /awips2/java/jre/lib/amd64/server/libjvm.so ]; then
ARCH_ARGS="-vm /awips2/java/jre/lib/amd64/server/libjvm.so"
fi
lookupINI "${USER_ARGS[@]}"
lookupINI "${USER_ARGS[@]}"
if [[ "${runMonitorThreads}" == "true" ]] ; then
# nohup to allow tar process to continue after user has logged out
nohup ${CAVE_INSTALL}/monitorThreads.sh $pid >> /dev/null 2>&1 &
fi
if [[ "${runMonitorThreads}" == "true" ]] ; then
# nohup to allow tar process to continue after user has logged out
nohup ${CAVE_INSTALL}/monitorThreads.sh $pid >> /dev/null 2>&1 &
fi
if [[ "${redirect}" == "true" ]] ; then
exec ${CAVE_INSTALL}/cave ${ARCH_ARGS} ${SWITCHES} "${CAVE_INI_ARG}" "${USER_ARGS[@]}" > ${LOGFILE} 2>&1
else
exec ${CAVE_INSTALL}/cave ${ARCH_ARGS} ${SWITCHES} "${CAVE_INI_ARG}" "${USER_ARGS[@]}" 2>&1 | tee ${LOGFILE}
fi
) &
pid=$!
LOGFILE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_console.log"
logExitStatus $pid $LOGFILE
if [[ "${redirect}" == "true" ]] ; then
exec ${CAVE_INSTALL}/cave ${ARCH_ARGS} ${SWITCHES} ${CAVE_INI_ARG} "${USER_ARGS[@]}" > ${LOGFILE} 2>&1
else
exec ${CAVE_INSTALL}/cave ${ARCH_ARGS} ${SWITCHES} ${CAVE_INI_ARG} "${USER_ARGS[@]}" 2>&1 | tee ${LOGFILE}
fi

View file

@ -25,8 +25,13 @@
# Dec 05, 2013 #2593 rjpeter Fix getPidsOfMyRunningCaves
# Dec 05, 2013 #2590 dgilling Modified extendLibraryPath() to export a
# var if it's already been run.
# Jan 24, 2014 #2739 bsteffen Add method to log exit status of process.
# Jan 30, 2014 #2593 bclement extracted generic part of getPidsOfMyRunningCaves into forEachRunningCave
# added methods for reading max memory from .ini files
# fixes for INI files with spaces
# Feb 20, 2014 #2780 bclement added site type ini file check
#
#
# Mar 13 2014 #15348 kjohnson added function to remove logs
source /awips2/cave/iniLookup.sh
@ -39,6 +44,10 @@ fi
# This script will be sourced by cave.sh.
export CAVE_INI_ARG=
BYTES_IN_KB=1024
BYTES_IN_MB=1048576
BYTES_IN_GB=1073741824
function lookupINI()
{
# Arguments:
@ -55,12 +64,18 @@ function lookupINI()
position=$(( $position + 1 ))
nextArg=${!position}
retrieveAssociatedINI ${arg} ${nextArg}
retrieveAssociatedINI ${arg} "${nextArg}"
RC=$?
if [ ${RC} -eq 0 ]; then
export CAVE_INI_ARG="--launcher.ini /awips2/cave/${ASSOCIATED_INI}"
else
export CAVE_INI_ARG="--launcher.ini /awips2/cave/cave.ini"
siteTypeIni="/awips2/cave/${SITE_TYPE}.ini"
if [[ -e ${siteTypeIni} ]]
then
export CAVE_INI_ARG="--launcher.ini ${siteTypeIni}"
else
export CAVE_INI_ARG="--launcher.ini /awips2/cave/cave.ini"
fi
fi
return 0
fi
@ -116,8 +131,8 @@ function copyVizShutdownUtilIfNecessary()
chmod a+x ${HOME}/.kde/shutdown/${VIZ_UTILITY_SCRIPT}
}
# returns _numPids and array _pids containing the pids of the currently running cave sessions.
function getPidsOfMyRunningCaves()
# takes a function as an argument and calls the function passing in the ps string of the process
function forEachRunningCave()
{
local user=`whoami`
local caveProcs=`ps -ef | grep -E "(/awips2/cave|/usr/local/viz)/cave " | grep -v "grep" | grep $user`
@ -125,17 +140,89 @@ function getPidsOfMyRunningCaves()
# preserve IFS and set it to line feed only
local PREV_IFS=$IFS
IFS=$'\n'
_numPids=0
# grab the pids for future use
for caveProc in $caveProcs
do
_pids[$_numPids]=`echo $caveProc | awk '{print $2}'`
let "_numPids+=1"
"$@" $caveProc
done
IFS=$PREV_IFS
}
# takes in ps string of cave process, stores pid in _pids and increments _numPids
function processPidOfCave()
{
_pids[$_numPids]=`echo $1 | awk '{print $2}'`
let "_numPids+=1"
}
# returns _numPids and array _pids containing the pids of the currently running cave sessions.
function getPidsOfMyRunningCaves()
{
_numPids=0
forEachRunningCave processPidOfCave
}
# takes a name of an ini file as an argument, echos the memory (in bytes) from file (or default)
function readMemFromIni()
{
local inifile="$1"
local mem
local unit
local regex='^[^#]*-Xmx([0-9]+)([bBkKmMgG])?'
# read ini file line by line looking for Xmx arg
while read -r line
do
if [[ $line =~ $regex ]]
then
mem=${BASH_REMATCH[1]}
unit=${BASH_REMATCH[2]}
break
fi
done < "$inifile"
# convert to bytes
case "$unit" in
[kK])
mem=$(($mem * $BYTES_IN_KB))
;;
[mM])
mem=$(($mem * $BYTES_IN_MB))
;;
[gG])
mem=$(($mem * $BYTES_IN_GB))
;;
esac
regex='^[0-9]+$'
if [[ ! $mem =~ $regex ]]
then
# we couldn't find a valid Xmx value
# java default is usually 1G
mem=1073741824
fi
echo $mem
}
# takes in ps string of cave process, reads Xmx from ini and adds bytes to _totalRunninMem
function addMemOfCave()
{
local inifile
# get ini file from process string
local regex='--launcher.ini\s(.+\.ini)'
if [[ $1 =~ $regex ]]
then
inifile="${BASH_REMATCH[1]}"
else
inifile="/awips2/cave/cave.ini"
fi
let "_totalRunningMem+=$(readMemFromIni "$inifile")"
}
# finds total max memory of running caves in bytes and places it in _totalRunningMem
function getTotalMemOfRunningCaves()
{
_totalRunningMem=0
forEachRunningCave addMemOfCave
}
function deleteOldCaveDiskCaches()
{
local curDir=`pwd`
@ -194,9 +281,35 @@ function deleteOldCaveDiskCaches()
cd $curDir
}
# log the exit status and time to a log file, requires 2 args pid and log file
function logExitStatus()
{
pid=$1
logFile=$2
trap 'kill $pid' SIGHUP SIGINT SIGQUIT SIGTERM
wait $pid
exitCode=$?
curTime=`date --rfc-3339=seconds`
echo Exited at $curTime with an exit status of $exitCode >> $logFile
# If a core file was generated attempt to save it to a better place
coreFile=core.$pid
if [ -f "$coreFile" ]; then
basePath="/data/fxa/cave"
hostName=`hostname -s`
hostPath="$basePath/$hostName/"
mkdir -p $hostPath
if [ -d "$hostPath" ]; then
mv $coreFile $hostPath
fi
fi
}
#Delete old CAVE logs DR 15348
function deleteOldCaveLogs()
{
local curDir=$(pwd)
local mybox=$(hostname)
@ -204,8 +317,9 @@ function deleteOldCaveLogs()
echo -e "find $BASE_LOGDIR -type f -name "*.log" -mtime +7 -exec rm {} \;"
find "$BASE_LOGDIR" -type f -name "*.log" -mtime +7 -exec rm {} \;
find "$BASE_LOGDIR" -type f -name "*.log" -mtime +7 -exec rm {} \;
exit 0
}

View file

@ -0,0 +1,69 @@
@echo OFF
REM Determine if we are running on a 32-bit or 64-bit OS.
IF NOT EXIST C:\Windows\SysWOW64\reg.exe (
SET REG_EXE=C:\Windows\System32\reg.exe
) ELSE (
SET REG_EXE=C:\Windows\SysWOW64\reg.exe
)
REM Determine where we are located.
SET CONTAINING_DIRECTORY=%~dp0
REM Prepare the environment.
REM Registry Query Variables.
SET A2_JAVA_REG="HKLM\Software\Raytheon\Runtime Environment\AWIPS II Java"
SET A2_PYTHON_REG="HKLM\Software\Raytheon\Runtime Environment\AWIPS II Python"
REM Determine where AWIPS II Java (the jre) is located.
%REG_EXE% QUERY %A2_JAVA_REG% /v JavaJreDirectory > NUL 2>&1
IF ERRORLEVEL 1 (echo ENVIRONMENT ERROR - Unable to find AWIPS II Java. && PAUSE && EXIT)
FOR /F "tokens=2* delims= " %%A IN (
'%REG_EXE% QUERY %A2_JAVA_REG% /v JavaJreDirectory') DO (
SET JavaJreDirectory=%%B)
REM Determine where AWIPS II Python is located.
%REG_EXE% QUERY %A2_PYTHON_REG% /v PythonInstallDirectory > NUL 2>&1
IF ERRORLEVEL 1 (echo ENVIRONMENT ERROR - Unable to find AWIPS II Python. && PAUSE && EXIT)
FOR /F "tokens=2* delims= " %%A IN (
'%REG_EXE% QUERY %A2_PYTHON_REG% /v PythonInstallDirectory') DO (
SET PythonInstallDirectory=%%B)
REM Add Java and Python to the path.
SET Path=%PythonInstallDirectory%;%PythonInstallDirectory%\DLLs;%Path%
SET Path=%JavaJreDirectory%\bin;%Path%
REM Define 'PythonPath'.
SET PythonPath=%PythonInstallDirectory%\Lib\lib-tk;%PythonPath%
SET PythonPath=%PythonInstallDirectory%\DLLs;%PythonPath%
SET PythonPath=%PythonInstallDirectory%\Lib;%PythonPath%
SET PythonPath=%PythonInstallDirectory%;%PythonPath%
REM Eliminate variables that will no longer be used.
SET PythonInstallDirectory=
SET JavaJreDirectory=
SET REG_EXE=
SET A2_JAVA_REG=
SET A2_PYTHON_REG=
REM Determine where we will be logging to.
SET HOME_DIRECTORY=%HOMEDRIVE%%HOMEPATH%
SET CAVEDATA_LOG_DIRECTORY=%HOMEDRIVE%%HOMEPATH%\caveData\logs
SET CONSOLE_LOG_DIRECTORY=%CAVEDATA_LOG_DIRECTORY%\consoleLogs\%COMPUTERNAME%
IF NOT EXIST "%CONSOLE_LOG_DIRECTORY%" (MKDIR "%CONSOLE_LOG_DIRECTORY%")
echo Starting ALERTVIZ; leave this CMD window open to enable AlertViz 'restart'.
REM Start AlertViz (and implement the alertviz restart capability).
:AlertVizLoopStart
SET RND=%random%
SET RND_DATETIME_FILE=%TMP%\awips2dt_%RND%.tmp
REM Python is used to retrieve the current date and time because the order
REM of the Windows date/time fields is not necessarily guaranteed and the
REM Windows date/time fields can only be extracted using substring operations
REM instead of -formatter- strings like Linux allows.
python -c "from datetime import datetime; print datetime.now().strftime('%%Y%%m%%d_%%H%%M%%S');" > %RND_DATETIME_FILE%
SET /p LOG_DATETIME= < %RND_DATETIME_FILE%
DEL %RND_DATETIME_FILE%
"%CONTAINING_DIRECTORY%alertviz.exe" %* > "%CONSOLE_LOG_DIRECTORY%\alertviz_%LOG_DATETIME%.log" 2>&1
IF %ERRORLEVEL% == 0 (EXIT)
echo Restarting AlertViz.
GOTO AlertVizLoopStart

View file

@ -0,0 +1,72 @@
@echo OFF
REM Determine if we are running on a 32-bit or 64-bit OS.
IF NOT EXIST C:\Windows\SysWOW64\reg.exe (
SET REG_EXE=C:\Windows\System32\reg.exe
) ELSE (
SET REG_EXE=C:\Windows\SysWOW64\reg.exe
)
REM Determine where we are located.
SET CONTAINING_DIRECTORY=%~dp0
REM Prepare the environment.
REM Registry Query Variables.
SET A2_JAVA_REG="HKLM\Software\Raytheon\Runtime Environment\AWIPS II Java"
SET A2_PYTHON_REG="HKLM\Software\Raytheon\Runtime Environment\AWIPS II Python"
REM Determine where AWIPS II Java (the jre) is located.
%REG_EXE% QUERY %A2_JAVA_REG% /v JavaJreDirectory > NUL 2>&1
IF ERRORLEVEL 1 (echo ENVIRONMENT ERROR - Unable to find AWIPS II Java. && PAUSE && EXIT)
FOR /F "tokens=2* delims= " %%A IN (
'%REG_EXE% QUERY %A2_JAVA_REG% /v JavaJreDirectory') DO (
SET JavaJreDirectory=%%B)
REM Determine where AWIPS II Python is located.
%REG_EXE% QUERY %A2_PYTHON_REG% /v PythonInstallDirectory > NUL 2>&1
IF ERRORLEVEL 1 (echo ENVIRONMENT ERROR - Unable to find AWIPS II Python. && PAUSE && EXIT)
FOR /F "tokens=2* delims= " %%A IN (
'%REG_EXE% QUERY %A2_PYTHON_REG% /v PythonInstallDirectory') DO (
SET PythonInstallDirectory=%%B)
REM Add Java and Python to the path.
SET Path=%PythonInstallDirectory%;%PythonInstallDirectory%\DLLs;%Path%
SET Path=%JavaJreDirectory%\bin;%Path%
REM Add the CAVE lib directory to the path.
SET Path=%CONTAINING_DIRECTORY%lib;%Path%
REM Define 'PythonPath'.
SET PythonPath=%CONTAINING_DIRECTORY%lib;%PythonPath%
SET PythonPath=%PythonInstallDirectory%\Lib\lib-tk;%PythonPath%
SET PythonPath=%PythonInstallDirectory%\DLLs;%PythonPath%
SET PythonPath=%PythonInstallDirectory%\Lib;%PythonPath%
SET PythonPath=%PythonInstallDirectory%;%PythonPath%
REM Eliminate variables that will no longer be used.
SET PythonInstallDirectory=
SET JavaJreDirectory=
SET REG_EXE=
SET A2_JAVA_REG=
SET A2_PYTHON_REG=
REM Determine where we will be logging to.
SET HOME_DIRECTORY=%HOMEDRIVE%%HOMEPATH%
SET CAVEDATA_LOG_DIRECTORY=%HOMEDRIVE%%HOMEPATH%\caveData\logs
SET CONSOLE_LOG_DIRECTORY=%CAVEDATA_LOG_DIRECTORY%\consoleLogs\%COMPUTERNAME%
IF NOT EXIST "%CONSOLE_LOG_DIRECTORY%" (MKDIR "%CONSOLE_LOG_DIRECTORY%")
SET RND=%random%
SET RND_DATETIME_FILE=%TMP%\awips2dt_%RND%.tmp
REM Python is used to retrieve the current date and time because the order
REM of the Windows date/time fields is not necessarily guaranteed and the
REM Windows date/time fields can only be extracted using substring operations
REM instead of -formatter- strings like Linux allows.
python -c "from datetime import datetime; print datetime.now().strftime('%%Y%%m%%d_%%H%%M%%S');" > %RND_DATETIME_FILE%
SET /p LOG_DATETIME= < %RND_DATETIME_FILE%
DEL %RND_DATETIME_FILE%
echo THIS CMD WINDOW CAN BE CLOSED AT ANY TIME!
cd %HOMEPATH%
REM Start CAVE.
"%CONTAINING_DIRECTORY%cave.exe" %* > "%CONSOLE_LOG_DIRECTORY%\cave_%LOG_DATETIME%.log" 2>&1
IF ERRORLEVEL 1 (echo CAVE ERROR - check the logs for additional information. && PAUSE)
EXIT

View file

@ -19,6 +19,10 @@
package com.raytheon.uf.viz.application;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
@ -39,6 +43,7 @@ import com.raytheon.uf.viz.application.component.IStandaloneComponent;
* Apr 18, 2007 chammack Initial Creation.
* Dec 03, 2007 461 bphillip Added persistence of workstation time to localization
* Oct 07, 2008 1433 chammack Added alertviz startup
* Jan 23, 2014 njensen Added shutdown hook and printout
*
* </pre>
*
@ -54,6 +59,7 @@ public class VizApplication implements IApplication {
* @seeorg.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.
* IApplicationContext)
*/
@Override
public Object start(IApplicationContext context) throws Exception {
String appToRun = ProgramArguments.getInstance()
@ -78,6 +84,8 @@ public class VizApplication implements IApplication {
return IApplication.EXIT_OK;
}
addShutdownHook();
return component.startComponent(appToRun);
}
@ -86,6 +94,7 @@ public class VizApplication implements IApplication {
*
* @see org.eclipse.equinox.app.IApplication#stop()
*/
@Override
public void stop() {
}
@ -123,4 +132,29 @@ public class VizApplication implements IApplication {
return standalone;
}
protected void addShutdownHook() {
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
/*
* This may seem pointless but is actually quite helpful to
* confirm how the process exited. If the process is killed by a
* kill command on a terminal, the console output will have this
* message but not the normal safe shutdown output (see
* com.raytheon.uf.viz.core.Activator's stop() and
* VizWorkbenchAdvisor's preShutdown()). In contrast, a
* spontaneous death of the process or force kill will not have
* this printout.
*/
SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
System.out.println(sdf.format(new Date())
+ " VizApplication's runtime shutdown hook triggered");
}
}) {
});
}
}

View file

@ -81,6 +81,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* archive and category directory and
* implementation of compression.
* Oct 08, 2013 2442 rferrel Remove category directory.
* Feb 04, 2013 2270 rferrel Move HDF files to parent's directory.
*
* </pre>
*
@ -89,6 +90,10 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
*/
public class GenerateCaseDlg extends CaveSWTDialog {
/** Extension for HDF files. */
private static final String hdfExt = ".h5";
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(GenerateCaseDlg.class);
@ -539,6 +544,11 @@ public class GenerateCaseDlg extends CaveSWTDialog {
new File(destination, file));
}
} else {
// DR 2270 bump HDF files up a directory.
if (destination.getName().endsWith(hdfExt)) {
destination = new File(destination.getParentFile()
.getParentFile(), destination.getName());
}
FileUtil.copyFile(source, destination);
destination.setLastModified(source.lastModified());
}
@ -652,6 +662,13 @@ public class GenerateCaseDlg extends CaveSWTDialog {
addTarFiles(file.listFiles());
}
} else {
// DR 2270 bump HDF files up a directory.
if (name.endsWith(hdfExt)) {
File destination = new File(file.getParentFile()
.getParentFile(), file.getName());
name = destination.getAbsolutePath().substring(
startRelativePath);
}
TarArchiveEntry entry = new TarArchiveEntry(file, name);
entry.setSize(file.length());
FileInputStream fileStream = null;

View file

@ -106,5 +106,8 @@
<graphicsExtension
class="com.raytheon.uf.viz.core.drawables.ext.GeneralCanvasRenderingExtension">
</graphicsExtension>
<graphicsExtension
class="com.raytheon.uf.viz.core.drawables.ext.colormap.GeneralColormapShadedShapeExtension">
</graphicsExtension>
</extension>
</plugin>

View file

@ -21,10 +21,6 @@
package com.raytheon.uf.viz.core;
import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
@ -52,6 +48,7 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
* Jan 14, 2013 1469 bkowal Removed the hdf5 data directory.
* Aug 27, 2013 2295 bkowal Removed the jms server property; added
* jms connection string
* Feb 17, 2014 2812 njensen getHostName() now uses getWsId()'s hostname
*
* </pre>
*
@ -255,45 +252,20 @@ public final class VizApp {
private static String host = null;
/**
* Gets the ip address of the host machine calling the function
* Gets the host name from the WsId of the host machine calling the function
*
* @return
*/
public static synchronized String getHostName() {
if (host == null) {
InetAddress addrToUse = null;
boolean found = false;
try {
Enumeration<NetworkInterface> nis = NetworkInterface
.getNetworkInterfaces();
while (nis.hasMoreElements() && !found) {
NetworkInterface ni = nis.nextElement();
ni.isVirtual();
ni.isUp();
Enumeration<InetAddress> addrs = ni.getInetAddresses();
while (addrs.hasMoreElements() && !found) {
InetAddress addr = addrs.nextElement();
if (addr.isLinkLocalAddress() == false
&& addr.isSiteLocalAddress() == false
&& addr.isLoopbackAddress() == false) {
addrToUse = addr;
found = true;
}
}
}
} catch (SocketException e) {
e.printStackTrace();
}
if (addrToUse == null) {
host = getWsId().getHostName();
if (host == null) {
String hostname = System.getenv("HOSTNAME");
if (hostname != null && hostname.trim().length() == 0) {
if (hostname != null && hostname.trim().length() > 0) {
host = hostname;
} else {
host = "localhost";
}
} else {
host = addrToUse.getHostName();
}
}
return host;

View file

@ -19,6 +19,10 @@
**/
package com.raytheon.uf.viz.core.comm;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.comm.IHttpsCredentialsHandler;
import com.raytheon.uf.viz.core.auth.UserController;
@ -34,6 +38,7 @@ import com.raytheon.uf.viz.core.auth.UserController;
* ------------ ---------- ----------- --------------------------
* Mar 04, 2013 1786 mpduff Initial creation.
* Jun 07, 2013 1981 mpduff Save user's username in UserController.
* Feb 10, 2014 2704 njensen Added credentialsFailed()
*
* </pre>
*
@ -59,4 +64,11 @@ public class CaveHttpsCredentialsHandler implements IHttpsCredentialsHandler {
UserController.updateUserData(credentials[0]);
return credentials;
}
@Override
public void credentialsFailed() {
MessageDialog.openError(new Shell(Display.getDefault()),
"Login failed",
"Invalid username and/or password. Please try again.");
}
}

View file

@ -53,6 +53,8 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
* Mar 22, 2013 1786 mpduff Changed to use HttpClient for
* connectivity.
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
* Jan 15, 2014 njensen Added printConnectivityProblems()
* Feb 04, 2014 2704 njensen Check JMS capability, return exceptions with results
*
* </pre>
*
@ -74,9 +76,16 @@ public class ConnectivityManager {
public String server;
public Exception exception;
public ConnectivityResult(boolean hc, String server) {
this(hc, server, null);
}
public ConnectivityResult(boolean hc, String server, Exception e) {
this.hasConnectivity = hc;
this.server = server;
this.exception = e;
}
}
@ -88,8 +97,10 @@ public class ConnectivityManager {
* @return whether quit was selected. TODO: need to return two booleans, one
* for quit and one for connectivity
*/
public static void checkHttpServer(String server, IConnectivityCallback callback) {
public static void checkHttpServer(String server,
IConnectivityCallback callback) {
boolean good = false;
Exception exc = null;
try {
HttpClient client = HttpClient.getInstance();
HttpGet request = new HttpGet();
@ -97,9 +108,9 @@ public class ConnectivityManager {
client.executeRequest(request);
good = true;
} catch (Exception e) {
// ignore
exc = e;
}
callback.connectionChecked(new ConnectivityResult(good, server));
callback.connectionChecked(new ConnectivityResult(good, server, exc));
}
/**
@ -108,14 +119,16 @@ public class ConnectivityManager {
* @param server
* server to check
*/
public static void checkLocalizationServer(String server, IConnectivityCallback callback) {
public static void checkLocalizationServer(String server,
IConnectivityCallback callback) {
boolean good = false;
Exception exc = null;
try {
good = checkLocalizationServer(server, true) != null;
} catch (Exception e) {
// ignore
exc = e;
}
callback.connectionChecked(new ConnectivityResult(good, server));
callback.connectionChecked(new ConnectivityResult(good, server, exc));
}
/**
@ -124,8 +137,8 @@ public class ConnectivityManager {
* result is returned, otherwise the localization server is contacted to get
* the response.
*/
public static GetServersResponse checkLocalizationServer(String server, boolean force)
throws VizException {
public static GetServersResponse checkLocalizationServer(String server,
boolean force) throws VizException {
if (!force) {
GetServersResponse resp = getServersResponseCache.get(server);
if (resp != null) {
@ -133,29 +146,53 @@ public class ConnectivityManager {
}
}
GetServersRequest req = new GetServersRequest();
GetServersResponse resp = (GetServersResponse) ThriftClient.sendRequest(req, server);
GetServersResponse resp = (GetServersResponse) ThriftClient
.sendRequest(req, server);
getServersResponseCache.put(server, resp);
return resp;
}
/**
* Checks the connectivity of the given server
* Checks the connectivity of the given alert service
*
* @param server
* server to check
* @return whether quit was selected. TODO: need to return two booleans, one
* for quit and one for connectivity
*/
public static void checkJmsServer(String server,
public static void checkAlertService(String server,
IConnectivityCallback callback) {
boolean good = true;
Exception exc = null;
try {
ActiveMQConnectionFactory f = new ActiveMQConnectionFactory(server);
f.createConnection().close();
} catch (JMSException e) {
exc = e;
good = false;
}
callback.connectionChecked(new ConnectivityResult(good, server));
callback.connectionChecked(new ConnectivityResult(good, server, exc));
}
/**
* Checks the connectivity of the given JMS server
*
* @param connectionString
* @param callback
*/
public static void checkJmsServer(String connectionString,
IConnectivityCallback callback) {
boolean good = true;
Exception exc = null;
try {
JMSConnection jms = new JMSConnection(connectionString);
jms.getFactory().createConnection().close();
} catch (JMSException e) {
exc = e;
good = false;
}
callback.connectionChecked(new ConnectivityResult(good,
connectionString, exc));
}
}

View file

@ -42,7 +42,8 @@ import org.eclipse.ui.PlatformUI;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 6, 2013 1786 mpduff Initial creation
* Mar 06, 2013 1786 mpduff Initial creation
* Feb 10, 2014 2704 njensen Allow message to expand size of dialog
*
* </pre>
*
@ -50,6 +51,7 @@ import org.eclipse.ui.PlatformUI;
* @version 1.0
*/
public class HttpsLoginDlg extends Dialog {
private static final long serialVersionUID = 1L;
private Shell shell;
@ -76,7 +78,7 @@ public class HttpsLoginDlg extends Dialog {
*/
public HttpsLoginDlg(String message) {
super(new Shell(Display.getDefault(), SWT.TITLE));
this.message = message;
this.message = message.replace("\"", "");
}
/**
@ -112,7 +114,9 @@ public class HttpsLoginDlg extends Dialog {
comp.setLayout(new GridLayout(2, false));
GridData gd = new GridData(SWT.RIGHT, SWT.None, true, true);
gd.widthHint = 500;
if (message == null || message.length() < 50) {
gd.widthHint = 500;
}
gd.horizontalSpan = 2;
Label authMessage = new Label(comp, SWT.CENTER);

View file

@ -0,0 +1,267 @@
/**
* 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.uf.viz.core.drawables.ext.colormap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.swt.graphics.RGB;
import org.geotools.coverage.grid.GeneralGridGeometry;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.Polygon;
/**
* For targets which cannot optimize support of {@link IColormapShadedShape}
* this will provide an inefficient default that simply generates a shaded shape
* whenever draw is called with new colors.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jan 23, 2014 2363 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GeneralColormapShadedShapeExtension extends
GraphicsExtension<IGraphicsTarget> implements
IColormapShadedShapeExtension {
@Override
public GeneralColormapShadedShape createColormapShadedShape(
GeneralGridGeometry targetGeometry, boolean tesselate) {
return new GeneralColormapShadedShape(targetGeometry, tesselate);
}
@Override
public IShadedShape createShadedShape(IColormapShadedShape baseShape,
Map<Object, RGB> colors) {
GeneralColormapShadedShape generalShape = (GeneralColormapShadedShape) baseShape;
return generalShape.generateShape(target, colors);
}
@Override
public void drawColormapShadedShape(IColormapShadedShape shape,
Map<Object, RGB> colors, float alpha, float brightness)
throws VizException {
if (shape.isDrawable()) {
GeneralColormapShadedShape generalShape = (GeneralColormapShadedShape) shape;
IShadedShape shadedShape = generalShape.getShape(target,
colors);
target.drawShadedShape(shadedShape, alpha, brightness);
}
}
@Override
public int getCompatibilityValue(IGraphicsTarget target) {
return Compatibilty.GENERIC;
}
/**
* Contains all the interesting logic for this extension. Basic
* functionality is to save off the LineStrings for each add operation so
* that a real {@link IShadedShape} can be generated when the colors are
* provided. Also keeps around a shape after rendering for potential reuse
* if the colors don't change.
*/
private static class GeneralColormapShadedShape implements
IColormapShadedShape {
private final GeneralGridGeometry targetGeometry;
private final boolean tesselate;
private List<AddPair> addPairs = new ArrayList<AddPair>();
private Map<Object, RGB> lastColors;
private IShadedShape lastShape;
private GeneralColormapShadedShape(GeneralGridGeometry targetGeometry,
boolean tesselate) {
this.targetGeometry = targetGeometry;
this.tesselate = tesselate;
}
/**
* Get a shaded shape that can be used to render this. This method also
* implements the caching if colors doesn't change.
*
* @param target
* the target be rendered onto.
* @param colors
* the colors to use for the shape
* @return the shape to render.
*/
public IShadedShape getShape(IGraphicsTarget target,
Map<Object, RGB> colors) {
if (!colors.equals(lastColors)) {
if (lastShape != null) {
lastShape.dispose();
}
lastShape = generateShape(target, colors);
lastColors = new HashMap<Object, RGB>(colors);
}
return lastShape;
}
/**
* Generate a new {@link IShadedShape} that renders identically to this.
*
* @param target
* the target be rendered onto.
* @param colors
* the colors to use for the shape
* @return a new shape that will render the same as this shape with
* colors applied.
*/
public IShadedShape generateShape(IGraphicsTarget target,
Map<Object, RGB> colors) {
IShadedShape shape = target.createShadedShape(true, targetGeometry,
tesselate);
for (AddPair pair : addPairs) {
if (pair.pixelSpace) {
shape.addPolygonPixelSpace(pair.lineString,
colors.get(pair.colorKey));
} else {
shape.addPolygon(pair.lineString, colors.get(pair.colorKey));
}
}
return shape;
}
@Override
public void compile() {
if (lastShape != null) {
lastShape.compile();
}
}
@Override
public boolean isMutable() {
if (lastShape != null) {
return lastShape.isMutable();
}
return true;
}
@Override
public boolean isDrawable() {
return !addPairs.isEmpty();
}
@Override
public void dispose() {
if (lastShape != null) {
lastShape.dispose();
lastShape = null;
}
addPairs = new ArrayList<AddPair>();
}
@Override
public void reset() {
lastShape.reset();
lastColors.clear();
addPairs = new ArrayList<AddPair>();
}
@Override
public Collection<Object> getColorKeys() {
Set<Object> keys = new HashSet<Object>(addPairs.size(), 1.0f);
return keys;
}
@Override
public void addPolygon(LineString[] lineString, Object colorKey) {
addPairs.add(new AddPair(lineString, colorKey, false));
if (lastShape != null && lastColors != null) {
lastShape.addPolygon(lineString, lastColors.get(colorKey));
}
}
@Override
public void addPolygonPixelSpace(LineString[] contours, Object colorKey) {
addPairs.add(new AddPair(contours, colorKey, true));
if (lastShape != null && lastColors != null) {
lastShape.addPolygonPixelSpace(contours,
lastColors.get(colorKey));
}
}
@Override
public void addGeometry(Geometry geometry, Object colorKey) {
if (geometry instanceof GeometryCollection) {
GeometryCollection geomCollection = (GeometryCollection) geometry;
for (int i = 0; i < geomCollection.getNumGeometries(); i++) {
addGeometry(geomCollection.getGeometryN(i), colorKey);
}
} else if (geometry instanceof LineString) {
LineString[] lineStrings = { (LineString) geometry };
addPolygon(lineStrings, colorKey);
} else if (geometry instanceof Polygon) {
LineString[] lineStrings = { ((Polygon) geometry)
.getExteriorRing() };
addPolygon(lineStrings, colorKey);
}
}
}
/**
* Simple Object for storing the parameters to any of the add methods on
* {@link IColormapShadedShape}.
*/
private static class AddPair {
public final LineString[] lineString;
public final Object colorKey;
public final boolean pixelSpace;
public AddPair(LineString[] lineString, Object colorKey,
boolean pixelSpace) {
this.lineString = lineString;
this.colorKey = colorKey;
this.pixelSpace = pixelSpace;
}
}
}

View file

@ -19,11 +19,17 @@
**/
package com.raytheon.uf.viz.core.localization;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.net.UnknownHostException;
import java.util.regex.Pattern;
import org.apache.http.conn.HttpHostConnectException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.VerifyEvent;
@ -41,6 +47,8 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.comm.HttpServerException;
import com.raytheon.uf.common.comm.InvalidURIException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -58,6 +66,9 @@ import com.raytheon.uf.viz.core.comm.IConnectivityCallback;
* ------------ ---------- ----------- --------------------------
* Aug 05, 2009 mschenke Initial creation
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
* Feb 04, 2014 2704 njensen Shifted some private fields/methods to protected,
* Added status and details, better site validation
* Feb 17, 2014 2704 njensen Changed some alertviz fields to protected
*
* </pre>
*
@ -66,16 +77,23 @@ import com.raytheon.uf.viz.core.comm.IConnectivityCallback;
*/
public class ConnectivityPreferenceDialog extends Dialog {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ConnectivityPreferenceDialog.class, "CAVE");
protected static final Pattern VALID_SITENAME = Pattern
.compile("^[A-Za-z0-9._-]+$");
private class LocalizationCallback implements IConnectivityCallback {
@Override
public void connectionChecked(ConnectivityResult results) {
localizationGood = results.hasConnectivity;
appendDetails(buildDetails(results));
if (!results.hasConnectivity && status == null) {
status = buildErrorMessage(results);
}
}
}
private class AlertVizCallback implements IConnectivityCallback {
@ -83,31 +101,32 @@ public class ConnectivityPreferenceDialog extends Dialog {
@Override
public void connectionChecked(ConnectivityResult results) {
alertVizGood = results.hasConnectivity;
appendDetails(buildDetails(results));
if (!results.hasConnectivity && status == null) {
status = buildErrorMessage(results);
}
}
}
/**
* Set time dialog shell
*/
private Shell shell;
/**
* Display component
*/
private Display display;
protected Display display;
private Label localizationLabel;
private Text localizationText;
protected Text localizationText;
private String localization = "";
private boolean localizationGood = false;
private Text alertVizText;
protected Text alertVizText;
private String alertVizServer = null;
protected String alertVizServer = null;
private boolean alertVizGood = true;
@ -115,10 +134,16 @@ public class ConnectivityPreferenceDialog extends Dialog {
private String site = "";
private Text siteText;
protected Text siteText;
private Label statusLabel;
private boolean canceled = false;
private Composite detailsComp;
private StyledText detailsText;
private IConnectivityCallback localizationCallback = new LocalizationCallback();
private IConnectivityCallback alertCallback = new AlertVizCallback();
@ -126,14 +151,20 @@ public class ConnectivityPreferenceDialog extends Dialog {
/**
* Title of the dialog.
*/
private static final String dialogTitle = "Connectivity Preferences";
private String title;
public ConnectivityPreferenceDialog(boolean checkAlertViz) {
this(new Shell(Display.getDefault()), checkAlertViz);
protected String status;
protected String details;
public ConnectivityPreferenceDialog(boolean checkAlertViz, String title) {
this(new Shell(Display.getDefault()), checkAlertViz, title);
}
public ConnectivityPreferenceDialog(Shell parentShell, boolean checkAlertViz) {
public ConnectivityPreferenceDialog(Shell parentShell,
boolean checkAlertViz, String title) {
super(parentShell);
this.title = title;
localization = LocalizationManager.getInstance()
.getLocalizationServer();
site = LocalizationManager.getInstance().getSite();
@ -155,8 +186,8 @@ public class ConnectivityPreferenceDialog extends Dialog {
if (!validate()) {
Shell parent = getParent();
display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM);
shell.setText(dialogTitle);
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE);
shell.setText(title);
// Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, true);
@ -165,6 +196,9 @@ public class ConnectivityPreferenceDialog extends Dialog {
initializeComponents();
shell.pack();
shell.setMinimumSize(shell.getBounds().width,
shell.getBounds().height);
updateStatus(false, status, details);
shell.open();
while (!shell.isDisposed()) {
@ -177,16 +211,69 @@ public class ConnectivityPreferenceDialog extends Dialog {
}
private void initializeComponents() {
createErrorText();
Composite textBoxComp = new Composite(shell, SWT.NONE);
textBoxComp.setLayout(new GridLayout(2, false));
createTextBoxes(textBoxComp);
createStatusText();
createBottomButtons();
}
private void createErrorText() {
Label label = new Label(shell, SWT.CENTER);
label.setText("Error: Unable to connect to localization server");
/**
* Creates the status label, text, and details button
*/
protected void createStatusText() {
Composite comp = new Composite(shell, SWT.NONE);
comp.setLayout(new GridLayout(3, false));
comp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
Label lbl = new Label(comp, SWT.NONE);
lbl.setText("Status:");
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
statusLabel = new Label(comp, SWT.BORDER);
statusLabel.setLayoutData(gd);
statusLabel.setText("");
final Button detailsButton = new Button(comp, SWT.TOGGLE);
detailsButton.setText("Details");
detailsButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (detailsComp.isVisible()) {
((GridData) detailsComp.getLayoutData()).exclude = true;
detailsComp.setVisible(false);
shell.pack();
} else {
((GridData) detailsComp.getLayoutData()).exclude = false;
((GridData) detailsComp.getLayoutData()).widthHint = detailsComp
.getBounds().width;
detailsComp.setVisible(true);
shell.pack();
}
}
});
createDetailsText();
}
/**
* Creates the expanding details text
*/
protected void createDetailsText() {
detailsComp = new Composite(shell, SWT.NONE);
detailsComp.setLayout(new GridLayout(1, false));
detailsComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 150;
detailsText = new StyledText(detailsComp, SWT.BORDER | SWT.MULTI
| SWT.H_SCROLL | SWT.V_SCROLL);
detailsText.setText("");
detailsText.setLayoutData(gd);
/*
* Hide the composite
*/
((GridData) detailsComp.getLayoutData()).exclude = true;
detailsComp.setVisible(false);
}
protected void createTextBoxes(Composite textBoxComp) {
@ -194,12 +281,12 @@ public class ConnectivityPreferenceDialog extends Dialog {
localizationLabel = new Label(textBoxComp, SWT.RIGHT);
localizationLabel.setText("Localization Server:");
GridData gd = new GridData(SWT.RIGHT, SWT.None, true, true);
GridData gd = new GridData(SWT.RIGHT, SWT.CENTER, true, true);
gd.widthHint = 150;
localizationLabel.setLayoutData(gd);
localizationText = new Text(textBoxComp, SWT.NONE);
gd = new GridData(SWT.RIGHT, SWT.None, true, true);
localizationText = new Text(textBoxComp, SWT.BORDER);
gd = new GridData(SWT.LEFT, SWT.None, true, true);
gd.widthHint = 300;
localizationText.setLayoutData(gd);
localizationText.setText(localization == null ? "" : localization);
@ -207,17 +294,18 @@ public class ConnectivityPreferenceDialog extends Dialog {
Label label = new Label(textBoxComp, SWT.RIGHT);
label.setText("Site:");
gd = new GridData(SWT.RIGHT, SWT.None, true, true);
gd = new GridData(SWT.RIGHT, SWT.CENTER, true, true);
gd.widthHint = 150;
label.setLayoutData(gd);
siteText = new Text(textBoxComp, SWT.NONE);
siteText = new Text(textBoxComp, SWT.BORDER);
siteText.addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent e) {
e.text = e.text.toUpperCase();
}
});
gd = new GridData(SWT.RIGHT, SWT.None, true, true);
gd = new GridData(SWT.LEFT, SWT.None, true, true);
gd.widthHint = 300;
siteText.setLayoutData(gd);
siteText.setText(site == null ? "" : site);
@ -299,7 +387,7 @@ public class ConnectivityPreferenceDialog extends Dialog {
shell.setVisible(false);
MessageDialog
.openError(
null,
shell,
"Connectivity Error",
"Unable to validate localization preferences, please enter valid options or quit the application");
shell.setVisible(true);
@ -327,6 +415,8 @@ public class ConnectivityPreferenceDialog extends Dialog {
}
public boolean validate() {
status = null;
details = null;
if (localizationText != null && !localizationText.isDisposed()
&& localizationText.isEnabled()) {
String localization = localizationText.getText().trim();
@ -360,20 +450,28 @@ public class ConnectivityPreferenceDialog extends Dialog {
} else {
validateSite();
}
return siteGood && localizationGood && alertVizGood;
boolean everythingGood = siteGood && localizationGood && alertVizGood;
updateStatus(everythingGood, status, details);
return everythingGood;
}
private void validateLocalization() {
ConnectivityManager.checkLocalizationServer(localization, localizationCallback);
ConnectivityManager.checkLocalizationServer(localization,
localizationCallback);
}
private void validateAlertviz() {
ConnectivityManager.checkJmsServer(alertVizServer, alertCallback);
protected void validateAlertviz() {
ConnectivityManager.checkAlertService(alertVizServer, alertCallback);
}
private void validateSite() {
if (site == null || site.trim().equals("")) {
protected void validateSite() {
if (site == null || site.trim().length() == 0
|| !VALID_SITENAME.matcher(site).find()) {
siteGood = false;
if (status == null) {
status = "Invalid Site ID";
}
} else {
siteGood = true;
}
@ -387,6 +485,20 @@ public class ConnectivityPreferenceDialog extends Dialog {
}
}
/**
* Gets the color for the status label
*
* @param isGood
* @return
*/
protected Color getForegroundColor(boolean isGood) {
if (isGood) {
return display.getSystemColor(SWT.COLOR_DARK_GREEN);
} else {
return display.getSystemColor(SWT.COLOR_DARK_RED);
}
}
public String getLocalization() {
return localization;
}
@ -438,4 +550,118 @@ public class ConnectivityPreferenceDialog extends Dialog {
localizationText.setEnabled(enabled);
}
}
/**
* Builds a details string based on a stacktrace of connectivity results. If
* there is no exception with the results, this returns the empty string.
*
* @param results
* @return
*/
protected String buildDetails(ConnectivityResult results) {
StringBuilder sb = new StringBuilder();
if (results.exception != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
results.exception.printStackTrace(ps);
String stack = baos.toString();
ps.close();
sb.append(stack);
}
return sb.toString();
}
/**
* Adds new details to the details field without overwriting it
*
* @param newDetails
*/
protected void appendDetails(String newDetails) {
if (details == null) {
details = "";
}
if (details.length() > 0) {
details += "\n\n\n";
}
details += newDetails;
}
/**
* Creates an error message for the status label by attempting to find the
* most relevant error message from the exception's stacktrace.
*
* @param result
* @return
*/
protected String buildErrorMessage(ConnectivityResult result) {
StringBuilder sb = new StringBuilder();
Exception prettyErrExc = result.exception;
/*
* Loop through the Caused Bys and try to find one that is the most
* useful for the label. This is totally arbitrary and corresponds to
* what njensen predicted would be most useful.
*/
while (prettyErrExc != null) {
if (prettyErrExc instanceof HttpHostConnectException
|| prettyErrExc instanceof InvalidURIException) {
sb.append(prettyErrExc.getMessage());
break;
}
if (prettyErrExc instanceof UnknownHostException) {
sb.append("Unknown host: " + prettyErrExc.getMessage());
break;
} else if (prettyErrExc instanceof HttpServerException) {
sb.append("Server returned Error ");
String emsg = prettyErrExc.getMessage();
int titleIndex = emsg.indexOf("<title>");
if (titleIndex > -1) {
String httpMsg = emsg.substring(titleIndex + 7,
emsg.indexOf("</title>"));
sb.append(httpMsg);
} else {
int statusCode = ((HttpServerException) prettyErrExc)
.getStatusCode();
sb.append(statusCode);
break;
}
}
prettyErrExc = (Exception) prettyErrExc.getCause();
}
if (sb.length() == 0) {
if (result.exception != null
&& result.exception.getMessage() != null) {
sb.append(result.exception.getMessage());
} else {
sb.append("Connectivity Error");
}
}
return sb.toString();
}
/**
* Updates the status label and details of the connectivity dialog
*
* @param good
* @param status
* @param details
*/
protected void updateStatus(boolean good, String status, String details) {
if (statusLabel != null && !statusLabel.isDisposed()
&& detailsText != null && !detailsText.isDisposed()) {
statusLabel.setForeground(getForegroundColor(good));
detailsText.setText(details != null ? details : "");
if (good) {
statusLabel.setText("Successful connection");
} else {
if (status != null) {
statusLabel.setText(status);
} else {
// shoudln't be able to reach this but just in case
statusLabel.setText("Connection error");
}
}
}
}
}

View file

@ -52,6 +52,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
* Aug 27, 2013 2295 bkowal The entire jms connection string is now
* provided by EDEX.
* Feb 04, 2014 2704 njensen Pass connectivity dialog title
*
* </pre>
*
@ -108,7 +109,7 @@ public class LocalizationInitializer {
protected void setupServers() throws VizException {
if (promptUI) {
ConnectivityPreferenceDialog dlg = new ConnectivityPreferenceDialog(
checkAlertviz);
checkAlertviz, "Connectivity Preferences");
if (dlg.open() == true) {
System.exit(0);
}

View file

@ -95,6 +95,7 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
* Aug 27, 2013 2295 bkowal The entire jms connection string is now
* provided by EDEX.
* Feb 04, 2014 2704 njensen Allow setting server without saving
*
* </pre>
*
@ -210,19 +211,39 @@ public class LocalizationManager implements IPropertyChangeListener {
}
}
/**
* Sets the localization server and saves the setting
*
* @param currentServer
* the localization URI
*/
public void setCurrentServer(String currentServer) {
setCurrentServer(currentServer, true);
}
/**
* Sets the localization server
*
* @param currentServer
* the localization URI
* @param save
* whether or not to save the setting
*/
public void setCurrentServer(String currentServer, boolean save) {
if (!this.currentServer.equals(currentServer)) {
this.currentServer = currentServer;
if (!overrideServer) {
localizationStore.putValue(
LocalizationConstants.P_LOCALIZATION_HTTP_SERVER,
this.currentServer);
applyChanges();
if (save) {
applyChanges();
}
}
try {
GetServersResponse resp = ConnectivityManager.checkLocalizationServer(
currentServer, false);
GetServersResponse resp = ConnectivityManager
.checkLocalizationServer(currentServer, false);
VizApp.setHttpServer(resp.getHttpServer());
VizApp.setJmsConnectionString(resp.getJmsConnectionString());
VizApp.setPypiesServer(resp.getPypiesServer());

View file

@ -236,7 +236,7 @@ public class LocalizationPreferences extends FieldEditorPreferencePage
if (alertEditor != null) {
text = alertEditor.getTextControl(getFieldEditorParent());
ConnectivityManager.checkJmsServer(text.getText().trim(),
ConnectivityManager.checkAlertService(text.getText().trim(),
new IConnectivityCallback() {
@Override
public void connectionChecked(ConnectivityResult results) {
@ -260,6 +260,7 @@ public class LocalizationPreferences extends FieldEditorPreferencePage
* @see
* org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
@Override
public void init(IWorkbench workbench) {
}

View file

@ -86,7 +86,7 @@ public class LocalizationServerEditor extends StringFieldEditor implements
ConnectivityManager.checkHttpServer(this.getTextControl().getText(),
this);
} else {
ConnectivityManager.checkJmsServer(this.getTextControl().getText(),
ConnectivityManager.checkAlertService(this.getTextControl().getText(),
this);
}
if (!good) {

View file

@ -20,6 +20,7 @@
package com.raytheon.uf.viz.core.reflect;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@ -45,6 +46,7 @@ import org.reflections.util.ConfigurationBuilder;
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Oct 21, 2013 2491 bsteffen Initial creation
* Jan 22, 2014 2062 bsteffen Handle bundles with no wiring.
*
* </pre>
*
@ -54,19 +56,28 @@ import org.reflections.util.ConfigurationBuilder;
public class BundleReflections {
private Reflections reflections;
private final Reflections reflections;
public BundleReflections(Bundle bundle, Scanner scanner) throws IOException {
ConfigurationBuilder cb = new ConfigurationBuilder();
BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
cb.addClassLoader(bundleWiring.getClassLoader());
cb.addUrls(FileLocator.getBundleFile(bundle).toURI().toURL());
cb.setScanners(scanner);
reflections = cb.build();
if (bundleWiring != null) {
cb.addClassLoader(bundleWiring.getClassLoader());
cb.addUrls(FileLocator.getBundleFile(bundle).toURI().toURL());
cb.setScanners(scanner);
reflections = cb.build();
} else {
reflections = null;
}
}
public <T> Set<Class<? extends T>> getSubTypesOf(final Class<T> type) {
return reflections.getSubTypesOf(type);
if (reflections == null) {
return Collections.emptySet();
} else {
return reflections.getSubTypesOf(type);
}
}
public Set<Class<?>> getSubTypesOf(Class<?>... types) {

View file

@ -20,19 +20,18 @@
package com.raytheon.uf.viz.core.reflect;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.osgi.framework.namespace.BundleNamespace;
import org.osgi.framework.namespace.PackageNamespace;
import org.osgi.framework.wiring.BundleWire;
import org.osgi.framework.wiring.BundleWiring;
import org.reflections.scanners.SubTypesScanner;
@ -56,6 +55,7 @@ import com.raytheon.uf.viz.core.Activator;
* Oct 18, 2013 2491 bsteffen Initial creation
* Dec 10, 2013 2602 bsteffen Add null checks to detect unloaded
* bundles.
* Feb 03, 2013 2764 bsteffen Use OSGi API to get dependencies.
*
* </pre>
*
@ -68,15 +68,11 @@ public class SubClassLocator implements ISubClassLocator {
private static final String CACHE_FILENAME = "subclassCache.txt";
private static final Pattern COMMA_SPLIT = Pattern.compile("[,]");
private static final Pattern SEMICOLON_SPLIT = Pattern.compile("[;]");
private final Map<String, BundleReflections> reflectionLookup = new HashMap<String, BundleReflections>();
private final Map<String, Bundle> bundleLookup = new HashMap<String, Bundle>();
private final Map<String, List<Bundle>> requiredBundles = new HashMap<String, List<Bundle>>();
private final Map<String, Collection<Bundle>> requiredBundles = new HashMap<String, Collection<Bundle>>();
private final BundleClassCache cache;
@ -146,6 +142,14 @@ public class SubClassLocator implements ISubClassLocator {
return Collections.emptySet();
}
if (bundle.getState() == Bundle.UNINSTALLED) {
/*
* We won't be able to get a class loader for uninstalled bundles so
* don't process them.
*/
return Collections.emptySet();
}
if (includeRequiredSubclasses) {
/* Short circut if we already did this. */
Set<Class<?>> result = recursiveClasses.get(bundleName);
@ -159,7 +163,8 @@ public class SubClassLocator implements ISubClassLocator {
Set<Class<?>> dependencies = getRequiredSubclasses(base, bundle,
recursiveClasses);
/* Must pass dependencies in so type heirarchy is complete. */
Set<Class<?>> owned = loadSubClassesReflectively(bundle, dependencies);
Set<Class<?>> owned = loadSubClassesReflectively(bundle,
dependencies);
/* populate the cache */
ownedNames = new String[owned.size()];
int index = 0;
@ -180,8 +185,7 @@ public class SubClassLocator implements ISubClassLocator {
Arrays.asList(ownedNames));
if (includeRequiredSubclasses) {
Set<Class<?>> dependencies = getRequiredSubclasses(base,
bundle,
recursiveClasses);
bundle, recursiveClasses);
Set<Class<?>> all = new HashSet<Class<?>>(dependencies);
all.addAll(owned);
recursiveClasses.put(bundleName, all);
@ -279,31 +283,32 @@ public class SubClassLocator implements ISubClassLocator {
}
/**
* Parse bundle header to get all required bundles
* Get back all the bundles this bundle depends on.
*
* @param bundle
* the bundle
* @return bundles required by bundle.
*/
private List<Bundle> getRequiredBundles(Bundle bundle) {
private Collection<Bundle> getRequiredBundles(Bundle bundle) {
String bundleName = bundle.getSymbolicName();
List<Bundle> required = requiredBundles.get(bundle);
Collection<Bundle> required = requiredBundles.get(bundleName);
if (required == null) {
required = new ArrayList<Bundle>();
String requiredBundlesHeader = bundle.getHeaders().get(
Constants.REQUIRE_BUNDLE);
if (requiredBundlesHeader != null) {
String[] requiredBundles = COMMA_SPLIT
.split(requiredBundlesHeader);
for (String requiredBundleName : requiredBundles) {
String[] nameParts = SEMICOLON_SPLIT
.split(requiredBundleName);
Bundle reqBundle = bundleLookup.get(nameParts[0]);
if (reqBundle != null) {
required.add(reqBundle);
}
required = new HashSet<Bundle>();
BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
if (bundleWiring != null) {
/* Get Required bundles */
for (BundleWire bw : bundleWiring
.getRequiredWires(BundleNamespace.BUNDLE_NAMESPACE)) {
required.add(bw.getProviderWiring().getBundle());
}
/* Get Bundles through import package */
for (BundleWire bw : bundleWiring
.getRequiredWires(PackageNamespace.PACKAGE_NAMESPACE)) {
required.add(bw.getProviderWiring().getBundle());
}
}
/* Avoid recursion */
required.remove(bundle);
requiredBundles.put(bundleName, required);
}

View file

@ -36,6 +36,7 @@ import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
import com.raytheon.uf.common.geospatial.CRSCache;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
@ -63,14 +64,17 @@ import com.vividsolutions.jts.geom.Coordinate;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 8, 2012 mschenke Initial creation
* May 28, 2013 2037 njensen Made imageMap concurrent to fix leak
* Jun 20, 2013 2122 mschenke Fixed null pointer in interrogate and made
* canceling jobs safer
* Oct 16, 2013 2333 mschenke Added auto NaN checking for interrogation
* Nov 14, 2013 2492 mschenke Added more interrogate methods that take units
* Date Ticket# Engineer Description
* ------------- -------- ----------- -----------------------------------------
* Aug 08, 2012 mschenke Initial creation
* May 28, 2013 2037 njensen Made imageMap concurrent to fix leak
* Jun 20, 2013 2122 mschenke Fixed null pointer in interrogate and
* made canceling jobs safer
* Oct 16, 2013 2333 mschenke Added auto NaN checking for interrogation
* Nov 14, 2013 2492 mschenke Added more interrogate methods that take
* units
* Feb 07, 2014 2211 bsteffen Fix sampling units when data mapping is
* enabled.
*
* </pre>
*
@ -539,55 +543,65 @@ public class TileSetRenderable implements IRenderable {
public double interrogate(Coordinate coordinate, Unit<?> resultUnit,
double nanValue) throws VizException {
double dataValue = Double.NaN;
TileLevel level = tileSet.getTileLevel(lastPaintedLevel);
double[] grid = null;
try {
double[] local = new double[2];
llToLocalProj
.transform(new double[] { coordinate.x, coordinate.y }, 0,
local, 0, 1);
double localX = local[0];
double localY = local[1];
TileLevel level = tileSet.getTileLevel(lastPaintedLevel);
double[] grid = level.crsToGrid(localX, localY);
Tile tile = level.getTile(grid[0], grid[1]);
if (tile != null) {
DrawableImage di = imageMap.get(tile);
if (di != null) {
IImage image = di.getImage();
if (image instanceof IColormappedImage) {
IColormappedImage cmapImage = (IColormappedImage) image;
dataValue = cmapImage.getValue(
(int) grid[0] % tileSize, (int) grid[1]
% tileSize);
if (dataValue == nanValue) {
dataValue = Double.NaN;
} else {
Unit<?> dataUnit = cmapImage.getDataUnit();
if (resultUnit != null && dataUnit != null
&& dataUnit.equals(resultUnit) == false) {
if (resultUnit.isCompatible(dataUnit)) {
dataValue = dataUnit.getConverterTo(
resultUnit).convert(dataValue);
} else {
throw new IllegalArgumentException(
"Unable to interrogate tile set. "
+ String.format(
"Desired unit (%s) is not compatible with data unit (%s).",
UnitFormat
.getUCUMInstance()
.format(resultUnit),
UnitFormat
.getUCUMInstance()
.format(dataUnit)));
}
}
}
}
}
}
grid = level.crsToGrid(local[0], local[1]);
} catch (TransformException e) {
throw new VizException("Error interrogating ", e);
}
IColormappedImage cmapImage = null;
Tile tile = level.getTile(grid[0], grid[1]);
if (tile != null) {
DrawableImage di = imageMap.get(tile);
if (di != null) {
IImage image = di.getImage();
if (image instanceof IColormappedImage) {
cmapImage = (IColormappedImage) image;
}
}
}
if (cmapImage != null) {
dataValue = cmapImage.getValue((int) grid[0] % tileSize,
(int) grid[1] % tileSize);
if (dataValue == nanValue) {
dataValue = Double.NaN;
} else {
ColorMapParameters parameters = cmapImage
.getColorMapParameters();
Unit<?> dataUnit = cmapImage.getDataUnit();
if (parameters.getDataMapping() != null) {
/*
* Ignore dataUnit, use colorMapUnit which is derived from
* the data mapping
*/
dataUnit = parameters.getColorMapUnit();
}
if (resultUnit != null && dataUnit != null
&& dataUnit.equals(resultUnit) == false) {
if (resultUnit.isCompatible(dataUnit)) {
dataValue = dataUnit.getConverterTo(resultUnit)
.convert(dataValue);
} else {
UnitFormat uf = UnitFormat.getUCUMInstance();
String message = String
.format("Unable to interrogate tile set. Desired unit (%s) is not compatible with data unit (%s).",
uf.format(resultUnit),
uf.format(dataUnit));
throw new IllegalArgumentException(message);
}
}
}
}
return dataValue;
}
}

View file

@ -10,7 +10,7 @@
</crossSectionAdapter>
<crossSectionAdapter
adapter="com.raytheon.uf.viz.d2d.xy.adapters.crosssection.PointCSAdapter"
class="com.raytheon.edex.plugin.modelsounding.common.SoundingSite"
class="com.raytheon.uf.common.dataplugin.modelsounding.SoundingSite"
name="Model Sounding Cross Section Adapter">
</crossSectionAdapter>
<crossSectionAdapter
@ -119,7 +119,7 @@
</timeSeriesAdapter>
<timeSeriesAdapter
adapter="com.raytheon.uf.viz.d2d.xy.adapters.timeseries.PointDataTimeSeriesAdapter"
class="com.raytheon.edex.plugin.modelsounding.common.SoundingSite"
class="com.raytheon.uf.common.dataplugin.modelsounding.SoundingSite"
name="Model Sounding Time Series Adapter">
</timeSeriesAdapter>
</extension>
@ -175,7 +175,7 @@
</varHeightAdapter>
<varHeightAdapter
adapter="com.raytheon.uf.viz.d2d.xy.adapters.varheight.PointDataVarHeightAdapter"
class="com.raytheon.edex.plugin.modelsounding.common.SoundingSite"
class="com.raytheon.uf.common.dataplugin.modelsounding.SoundingSite"
name="Model Sounding Var Height Adapter">
</varHeightAdapter>
</extension>

View file

@ -18,6 +18,12 @@
<property name="registryHandler" ref="registryHandler" />
</bean>
</constructor-arg>
<constructor-arg>
<bean
class="com.raytheon.uf.common.datadelivery.registry.handlers.AdhocSubscriptionHandler">
<property name="registryHandler" ref="registryHandler" />
</bean>
</constructor-arg>
</bean>
<bean name="PendingSubscriptionHandler"

View file

@ -33,7 +33,6 @@ import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionType;
import com.raytheon.uf.common.datadelivery.registry.Utils.SubscriptionStatus;
import com.raytheon.uf.common.datadelivery.registry.handlers.IAdhocSubscriptionHandler;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
@ -44,11 +43,11 @@ 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.BinOffset;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
import com.raytheon.uf.viz.core.rsc.DisplayType;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.ResourceType;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
import com.raytheon.uf.viz.productbrowser.AbstractRequestableProductBrowserDataDefinition;
import com.raytheon.uf.viz.productbrowser.ProductBrowserLabel;
import com.raytheon.uf.viz.productbrowser.ProductBrowserPreference;
@ -74,6 +73,8 @@ import com.raytheon.viz.pointdata.util.PointDataInventory;
* Oct 13, 2013 2460 dhladky Added display of Adhoc subscriptions
* Nov 19, 2013 2458 mpduff Only pull subscriptions for the local site
* Nov 21, 2013 2554 dhladky Restored ADHOC's to working.
* Jan 14, 2014 2459 mpduff Change Subscription status code
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
*
* </pre>
*
@ -403,7 +404,7 @@ public class DataDeliveryProductBrowserDataDefinition
List<Subscription> subList = getSubscriptions();
for (Subscription s : subList) {
if (SubscriptionStatus.ACTIVE.toString().equals(s.getStatus())
if (s.isActive()
|| s.getSubscriptionType().equals(SubscriptionType.QUERY)) {
if (s.getDataSetType() == dataType) {
activeSubList.add(s);
@ -439,8 +440,8 @@ public class DataDeliveryProductBrowserDataDefinition
final ISubscriptionHandler handler = RegistryObjectHandlers
.get(ISubscriptionHandler.class);
try {
subList = handler.getByFilters(null, LocalizationManager
.getInstance().getCurrentSite());
subList = handler.getByFilters(null,
DataDeliveryUtils.getDataDeliveryId());
} catch (RegistryHandlerException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}

View file

@ -26,7 +26,6 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthUtilizationDlg;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.GraphDataUtil;
/**
* Action handler for the bandwidth scheduling graph.
@ -40,6 +39,7 @@ import com.raytheon.uf.viz.datadelivery.bandwidth.ui.GraphDataUtil;
* Nov 25, 2012 1269 mpduff Initial creation.
* Dec 13, 2012 1269 lvenable Updated to use a graph utility for the graph data.
* Oct 28, 2013 2430 mpduff Removed redraw if already open.
* Jan 29, 2014 2722 mpduff Don't get graph data up front.
*
* </pre>
*
@ -58,11 +58,9 @@ public class BandwidthScheduleGraphAction extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
if (dlg == null || dlg.isDisposed()) {
GraphDataUtil gdu = new GraphDataUtil(null);
gdu.retrieveData();
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
dlg = new BandwidthUtilizationDlg(shell, gdu);
dlg = new BandwidthUtilizationDlg(shell);
dlg.open();
} else {
dlg.open();

View file

@ -31,11 +31,11 @@ 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.auth.UserController;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionManagerFilter;
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionManagerDlg;
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionManagerFilters;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
/**
* Subscription Manager Dialog Action class.
@ -49,8 +49,9 @@ import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionManagerFilters;
* Jan 10, 2012 mpduff Initial creation
* Oct 03, 2012 1241 djohnson Use {@link DataDeliveryPermission}.
* May 28, 2013 1650 djohnson Allow using filters for the Subscription Manager Dialog.
* Jul 26, 2031 2232 mpduff Refactored Data Delivery permissions.
* Jul 26, 2031 2232 mpduff Refactored Data Delivery permissions.
* Sep 04, 2013 2330 bgonzale execute now filters subscriptions by current site id.
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
*
*
* </pre>
@ -81,7 +82,7 @@ public class SubscriptionManagerAction extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) {
return loadSubscriptionManager(SubscriptionManagerFilters
.getBySiteId(LocalizationManager.getInstance().getCurrentSite()));
.getBySiteId(DataDeliveryUtils.getDataDeliveryId()));
}
/**

View file

@ -102,7 +102,9 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
* Oct 28, 2013 2430 mpduff Add % of bandwidth utilized graph.
* Nov 19, 2013 1531 mpduff Made graph resizable.
* Nov 25, 2013 2545 mpduff Default to Opsnet if Network not available yet.
* Dec 17, 2013 2633 mpduff Fix redraw problems.
* Dec 17, 2013 2633 mpduff Fix redraw problems..
* Jan 09, 2014 2633 mpduff On resize keep graph at bottom so data are always visible.
* Jan 29, 2014 2722 mpduff Changed how graph data are requested.
* </pre>
*
* @author lvenable
@ -249,13 +251,13 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
* @param graphDataUtil
* Bandwidth graph data object
*/
public BandwidthCanvasComp(Composite parentComp, GraphDataUtil graphDataUtil) {
public BandwidthCanvasComp(Composite parentComp) {
super(parentComp, SWT.BORDER);
this.parentComp = parentComp;
this.display = this.parentComp.getDisplay();
this.graphDataUtil = graphDataUtil;
this.bgd = this.graphDataUtil.getGraphData(false);
this.graphDataUtil = new GraphDataUtil(this);
this.bgd = this.graphDataUtil.getGraphData();
init();
}
@ -264,7 +266,6 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
* Initialize method.
*/
private void init() {
this.graphDataUtil.setDataUpdateCallback(this);
NotificationManagerJob.addObserver("notify.msg", this);
this.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
@ -1408,7 +1409,7 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
* @param graphData
* Bandwidth graph data.
*/
public void setGraphData(BandwidthGraphData graphData) {
private void setGraphData(BandwidthGraphData graphData) {
this.bgd = graphData;
generateCanvasSettings();
@ -1479,6 +1480,9 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
cornerPointOffset.y = 0;
}
cornerPointOffset.y = (graphCanvasSettings.getImageHeight() - graphCanvasSettings
.getCanvasHeight()) * -1;
verticalSlider.setSelection(cornerPointOffset.y * -1);
horizontalSlider.setSelection(cornerPointOffset.x * -1);
@ -1523,14 +1527,15 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
// Do a full update every 10 minutes
if (fullUpdateMinuteCount > 10) {
graphDataUtil.requestGraphDataUsingThread();
fullUpdateMinuteCount = 0;
}
}
}
}
/**
* This method will update the subscription table with any updates,
* deletions, or new subscriptions.
* This method will update the graph with any updates, deletions, or new
* subscriptions.
*/
@Override
public void notificationArrived(NotificationMessage[] messages) {
@ -1555,7 +1560,7 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
VizApp.runAsync(new Runnable() {
@Override
public void run() {
setGraphData(graphDataUtil.getGraphData(true));
setGraphData(graphDataUtil.getGraphData());
updateCanvasSettings();
updateCanvases();
layout();

View file

@ -53,6 +53,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Dec 13, 2012 1269 lvenable Fixes and updates.
* Oct 28, 2013 2430 mpduff Add % of bandwidth utilized graph.
* Nov 19, 2013 1531 mpduff Made resizable.
* Jan 29, 2014 2722 mpduff GraphDataUtil not in this class.
*
* </pre>
*
@ -77,9 +78,6 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog {
/** Graph composite */
private BandwidthCanvasComp canvasComp;
/** Graph data utility class */
private final GraphDataUtil graphDataUtil;
private MenuItem displayOpsNetMI;
private MenuItem displaySbnMI;
@ -92,12 +90,10 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog {
* @param graphDataUtil
* Graph data utility object
*/
public BandwidthUtilizationDlg(Shell parent, GraphDataUtil graphDataUtil) {
public BandwidthUtilizationDlg(Shell parent) {
super(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.RESIZE, CAVE.DO_NOT_BLOCK
| CAVE.INDEPENDENT_SHELL);
setText("Bandwidth Utilization");
this.graphDataUtil = graphDataUtil;
}
/**
@ -133,7 +129,7 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog {
mainComp.setLayout(gl);
mainComp.setLayoutData(gd);
canvasComp = new BandwidthCanvasComp(mainComp, graphDataUtil);
canvasComp = new BandwidthCanvasComp(mainComp);
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gl = new GridLayout(1, false);

View file

@ -46,6 +46,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* Dec 12, 2012 1269 lvenable Initial creation
* Feb 14, 2013 1596 djohnson Remove sysouts, correct statusHandler class, handle null response.
* Mar 26, 2013 1827 djohnson Graph data should be requested from data delivery.
* Jan 29, 2014 2722 mpduff Callback is now passed in.
*
* </pre>
*
@ -67,7 +68,7 @@ public class GraphDataUtil implements Runnable {
private BandwidthGraphData graphData;
/** Callback called when the data has been updated */
private IDataUpdated dataUpdatedCB;
private final IDataUpdated dataUpdatedCB;
/** Executor service used for the threaded data retrieval */
private final ExecutorService service = Executors.newSingleThreadExecutor();
@ -83,21 +84,10 @@ public class GraphDataUtil implements Runnable {
this.dataUpdatedCB = dataUpdatedCB;
}
/**
* Set the updated data callback.
*
* @param dataUpdatedCB
* Call back called when the data has been updated via separate
* thread.
*/
public void setDataUpdateCallback(IDataUpdated dataUpdatedCB) {
this.dataUpdatedCB = dataUpdatedCB;
}
/**
* Perform a data retrieval on the UI thread.
*/
public void retrieveData() {
private void retrieveData() {
response = sendRequest(request);
if (response != null) {
@ -115,10 +105,11 @@ public class GraphDataUtil implements Runnable {
* returning the data.
* @return Bandwidth graph data.
*/
public BandwidthGraphData getGraphData(boolean newData) {
if (newData || graphData == null) {
public BandwidthGraphData getGraphData() {
if (graphData == null) {
retrieveData();
}
return graphData;
}

View file

@ -48,7 +48,6 @@ 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.util.FileUtil;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.core.notification.NotificationMessage;
import com.raytheon.uf.viz.datadelivery.common.ui.IDialogClosed;
import com.raytheon.uf.viz.datadelivery.common.ui.SortImages.SortDirection;
@ -57,6 +56,7 @@ import com.raytheon.uf.viz.datadelivery.common.ui.TableComp;
import com.raytheon.uf.viz.datadelivery.common.ui.TableCompConfig;
import com.raytheon.uf.viz.datadelivery.common.ui.TableDataManager;
import com.raytheon.uf.viz.datadelivery.common.ui.ViewDetailsDlg;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.BrowserColumnNames;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
@ -85,6 +85,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
* Feb 15, 2013 1638 mschenke Moved Util.EOL into FileUtil
* Apr 10, 2013 1891 djohnson Declare variable as List.
* Sep 11, 2013 2352 mpduff Add siteId to getSubscribedToDataSetNames method.
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
*
* </pre>
*
@ -627,7 +628,7 @@ public class BrowserTableComp extends TableComp implements IDialogClosed {
try {
datasetNames = DataDeliveryHandlers.getSubscriptionHandler()
.getSubscribedToDataSetNames(
LocalizationManager.getInstance().getCurrentSite());
DataDeliveryUtils.getDataDeliveryId());
} catch (RegistryHandlerException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to retrieve subscription dataset names!", e);

View file

@ -93,6 +93,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* Jul 12, 2013 2141 mpduff Valid envelope test happens as needed instead of when changes are made.
* Oct 10, 2013 2104 mschenke Switched to use MapScalesManager
* Oct 11, 2013 2386 mpduff Refactor DD Front end.
* Jan 10, 2014 2452 mpduff Add label stating all lat/lons will be converted to easting.
* Jan 25, 2014 2452 mpduff Changed label based on feedback.
*
* </pre>
*
@ -396,11 +398,17 @@ public class AreaComp extends Composite implements ISubset {
});
gd = new GridData();
gd.horizontalSpan = 3;
gd.horizontalSpan = 2;
manualLbl = new Label(regionComp, SWT.LEFT);
manualLbl.setText("Manual Lat/Lon Edit");
manualLbl.setLayoutData(gd);
gd = new GridData();
gd.horizontalSpan = 1;
Label l = new Label(regionComp, SWT.LEFT);
l.setText("Lat/Lon values will be in the format of the data set.");
l.setLayoutData(gd);
/*
* Predefined controls.
*/

View file

@ -19,6 +19,10 @@
**/
package com.raytheon.uf.viz.datadelivery.common.ui;
import java.util.List;
import com.raytheon.uf.viz.datadelivery.notification.NotificationRowData;
/**
* Table find interface.
*
@ -30,6 +34,7 @@ package com.raytheon.uf.viz.datadelivery.common.ui;
* ------------ ---------- ----------- --------------------------
* May 7, 2012 jpiatt Initial creation.
* Sep 26, 2013 2417 mpduff Add clearSelection method.
* Feb 07, 2014 2453 mpduff Added getCurrentSelectionIndex method.
* </pre>
*
* @author jpiatt
@ -38,26 +43,34 @@ package com.raytheon.uf.viz.datadelivery.common.ui;
public interface ITableFind {
/**
* handleFind call
* handle page selection
*/
void handlePageSelection();
/**
* handleFind call
* select a row
*
* @param index
*/
void selectIndex(int index);
void selectRow(NotificationRowData row);
/**
* handleFind call
* handle multiple rows
*
* @param indices
*/
void selectIndices(int[] indices);
void selectRows(List<NotificationRowData> rows);
/**
* Clear any table selections.
*/
void clearSelections();
/**
* Get the currently selected index within the data array, not the visible
* table.
*
* @return
*/
int getCurrentSelectionIndex();
}

View file

@ -29,7 +29,8 @@ package com.raytheon.uf.viz.datadelivery.common.ui;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 06, 2012 lvenable Initial creation
* Apr 10, 2013 1891 djohnson Declare variable as List.
* Apr 10, 2013 1891 djohnson Declare variable as List.
* Feb 07, 2014 2453 mpduff Added getSize().
*
* </pre>
*
@ -132,8 +133,7 @@ public class TableDataManager<T extends ITableData<T>> implements ISortTable {
public T getDataRow(int index) {
if (index >= 0 && index < tableData.size()) {
return tableData.get(index);
}
else {
} else {
return tableData.get(0);
}
}
@ -187,4 +187,13 @@ public class TableDataManager<T extends ITableData<T>> implements ISortTable {
public SortDirection getSortDirection() {
return currentSortDirection;
}
/**
* Get the size of the data array.
*
* @return The size
*/
public int getSize() {
return this.tableData.size();
}
}

View file

@ -97,6 +97,7 @@ import com.raytheon.viz.ui.widgets.duallist.IUpdate;
* May 28, 2013 1650 djohnson More information when failing to schedule subscriptions.
* Jun 13, 2013 2108 mpduff Refactored DataSizeUtils.
* Oct 28, 2013 2292 mpduff Change overlap services.
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
* </pre>
*
* @author jpiatt
@ -410,8 +411,7 @@ public class UserSelectComp extends Composite implements IUpdate, IDisplay,
subscription.setCoverage(cov);
}
subscription.addOfficeID(LocalizationManager.getInstance()
.getCurrentSite());
subscription.addOfficeID(DataDeliveryUtils.getDataDeliveryId());
if (sizeUtils != null) {
subscription.setDataSetSize(sizeUtils
.getDataSetSizeInKb(subscription));

View file

@ -21,7 +21,11 @@ package com.raytheon.uf.viz.datadelivery.handlers;
import java.util.List;
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
import com.raytheon.uf.common.datadelivery.registry.SharedSubscription;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionDeleteRequest;
import com.raytheon.uf.common.datadelivery.registry.handlers.IAdhocSubscriptionHandler;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISharedSubscriptionHandler;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISiteSubscriptionHandler;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
@ -46,6 +50,7 @@ import com.raytheon.uf.common.serialization.comm.RequestRouter;
* Mar 29, 2013 1841 djohnson Composes a userSubscriptionsHandler.
* Apr 05, 2013 1841 djohnson Add shared subscription support.
* May 21, 2013 2020 mpduff Rename UserSubscription to SiteSubscription.
* Jan 20, 2014 2538 mpduff Added the doesNameExist method.
*
* </pre>
*
@ -62,8 +67,10 @@ public class VizSubscriptionHandler extends SubscriptionHandler {
*/
public VizSubscriptionHandler(
ISiteSubscriptionHandler siteSubscriptionHandler,
ISharedSubscriptionHandler sharedSubscriptionHandler) {
super(siteSubscriptionHandler, sharedSubscriptionHandler);
ISharedSubscriptionHandler sharedSubscriptionHandler,
IAdhocSubscriptionHandler adhocSubscriptionHandler) {
super(siteSubscriptionHandler, sharedSubscriptionHandler,
adhocSubscriptionHandler);
}
/**
@ -72,7 +79,7 @@ public class VizSubscriptionHandler extends SubscriptionHandler {
@Override
public void deleteByIds(String username, List<String> ids)
throws RegistryHandlerException {
SubscriptionDeleteRequest request = new SubscriptionDeleteRequest(ids,
ISubscriptionHandler.class, username);
@ -85,4 +92,40 @@ public class VizSubscriptionHandler extends SubscriptionHandler {
}
}
/**
* Does the name exist for the provided type of subscription?
*
* @param name
* The subscription name to check
* @param clazzes
* List of subscription types
* @return true if the name exists for any of the provided types
* @throws RegistryHandlerException
*/
public boolean doesNameExist(String name, Class... clazzes)
throws RegistryHandlerException {
boolean found = false;
for (Class<?> clazz : clazzes) {
if (found) {
return true;
}
if (clazz == SiteSubscription.class) {
found = getSiteSubscriptionHandler().getByName(name) != null;
continue;
}
if (!found && clazz == SharedSubscription.class) {
found = getSharedSubscriptionHandler().getByName(name) != null;
continue;
}
if (!found && clazz == AdhocSubscription.class) {
found = getAdhocSubscriptionHandler().getByName(name) != null;
continue;
}
}
return found;
}
}

View file

@ -20,21 +20,18 @@
package com.raytheon.uf.viz.datadelivery.notification;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
@ -59,6 +56,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Dec 12. 2012 1418 mpduff Change label.
* Aug 30, 2013 2314 mpduff Fixed find, filter, and various other bugs.
* Sep 26, 2013 2417 mpduff Reset the highlight all indices on close.
* Feb 07, 2014 2453 mpduff Refactored dialog.
*
* </pre>
*
@ -95,41 +93,20 @@ public class FindDlg extends CaveSWTDialog {
/** ITableFind callback */
private final ITableFind callback;
/** Table row Index */
int tableIndex = -1;
/** Table row start Index */
int startIndex = 0;
/** Table row end Index */
int endIndex = 0;
/** Table row selected Index */
int selectedIndex = 0;
private int selectedIndex = 0;
/** Message Checkbox flag */
boolean msgFlag = false;
private boolean msgFlag = false;
/** Category Checkbox flag */
boolean categoryFlag = false;
private boolean categoryFlag = false;
/** Case Sensitive flag */
boolean caseFlag = false;
/** Yes continue search flag */
boolean yesFlag = false;
/** Found Item flag */
boolean exists = false;
private boolean caseFlag = false;
/** Exclude search flag */
boolean excludeFlag = false;
/** Message string */
String msg = null;
/** Subscription string */
String sub = null;
private boolean excludeFlag = false;
/**
* Constructor.
@ -150,13 +127,11 @@ public class FindDlg extends CaveSWTDialog {
*/
public FindDlg(Shell parent,
TableDataManager<NotificationRowData> filteredTableList,
int sIndex, int eIndex, int selected, ITableFind callback) {
int selected, ITableFind callback) {
super(parent, SWT.DIALOG_TRIM, CAVE.NONE | CAVE.DO_NOT_BLOCK);
this.setText("Find");
this.filteredTableList = filteredTableList;
sIndex = startIndex;
eIndex = endIndex;
selectedIndex = selected;
this.callback = callback;
}
@ -185,12 +160,6 @@ public class FindDlg extends CaveSWTDialog {
*/
@Override
protected void initializeComponents(Shell shell) {
shell.addListener(SWT.Close, new Listener() {
@Override
public void handleEvent(Event event) {
callback.selectIndices(null);
}
});
createFindLayout();
createBottomButtons();
}
@ -219,12 +188,6 @@ public class FindDlg extends CaveSWTDialog {
findTxt.setLayoutData(gd);
findTxt.selectAll();
findTxt.setLayoutData(gd);
findTxt.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
findText();
}
});
gl = new GridLayout(2, false);
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
@ -314,89 +277,16 @@ public class FindDlg extends CaveSWTDialog {
closeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
callback.selectIndices(null);
close();
}
});
}
/**
* Find text on key release. Check all pages of filtered list. Stop when
* match is found and don't move to the next.
*/
private void findText() {
// Text in the find text box
String text = findTxt.getText();
// Get button selections
msgFlag = msgBtn.getSelection();
categoryFlag = categoryBtn.getSelection();
caseFlag = caseBtn.getSelection();
excludeFlag = exclusionBtn.getSelection();
int itemCount = filteredTableList.getDataArray().size();
tableIndex = 0;
if (filteredTableList != null) {
// Check rows in the entire filtered list - all pages
for (NotificationRowData row : filteredTableList.getDataArray()) {
// Column data
msg = row.getMessage();
sub = row.getCategory();
if (tableIndex <= itemCount) {
tableIndex++;
if (caseFlag) {
if (excludeFlag) {
// Select index if does not match message or
// subscription
if ((!msg.contains(text) && msgFlag)
|| (!sub.contains(text) && categoryFlag)) {
exists = true;
callback.selectIndex(tableIndex);
break;
}
// Select index if matches message or subscription
} else if ((msg.contains(text) && msgFlag)
|| (sub.contains(text) && categoryFlag)) {
exists = true;
callback.selectIndex(tableIndex);
break;
}
} else {
if (excludeFlag) {
// Select index if matches non case sensitive
// message or subscription
if ((!msg.toUpperCase()
.contains(text.toUpperCase()) && msgFlag)
|| (!sub.toLowerCase().contains(
text.toLowerCase()) && categoryFlag)) {
exists = true;
callback.selectIndex(tableIndex);
break;
}
} else if ((msg.toUpperCase().contains(
text.toUpperCase()) && msgFlag)
|| (sub.toLowerCase().contains(
text.toLowerCase()) && categoryFlag)) {
exists = true;
callback.selectIndex(tableIndex);
break;
}
}
}
}
}
}
/**
* Find Button action handler. Find the next matching row upon button click.
*/
private void handleFindBtn() {
int prevSelectedIndex = selectedIndex;
// Text in the find text box
String text = findTxt.getText();
@ -420,56 +310,20 @@ public class FindDlg extends CaveSWTDialog {
boolean continueSearch = true;
boolean exists = false;
boolean hitEnd = false;
selectedIndex = selectedIndex + 1;
selectedIndex = callback.getCurrentSelectionIndex() + 1;
while (continueSearch) {
if (tableIndex < itemCount) {
// Get the row data starting at the currently highlighted row
if (selectedIndex < itemCount) {
NotificationRowData row = filteredTableList.getDataArray().get(
tableIndex);
selectedIndex);
// Column data
msg = row.getMessage();
sub = row.getCategory();
tableIndex++;
if (caseFlag) {
if (excludeFlag) {
// Select index if does not match message or
// subscription
if ((!msg.contains(text) && msgFlag)
|| (!sub.contains(text) && categoryFlag)) {
continueSearch = false;
callback.selectIndex(tableIndex);
}
} else if ((msg.contains(text) && msgFlag)
|| (sub.contains(text) && categoryFlag)) {
// Select index if matches message or subscription
continueSearch = false;
callback.selectIndex(tableIndex);
}
} else {
if (excludeFlag) {
// Select index if matches non case sensitive message or
// subscription
if ((!msg.toUpperCase().contains(text.toUpperCase()) && msgFlag)
|| (!sub.toLowerCase().contains(
text.toLowerCase()) && categoryFlag)) {
continueSearch = false;
callback.selectIndex(tableIndex);
}
} else if ((msg.toUpperCase().contains(text.toUpperCase()) && msgFlag)
|| (sub.toLowerCase().contains(text.toLowerCase()) && categoryFlag)) {
continueSearch = false;
callback.selectIndex(tableIndex);
}
}
// If the item was found set exists to true
if (!continueSearch) {
boolean matchFound = checkForMatch(text, row);
if (matchFound) {
continueSearch = false;
exists = true;
callback.selectRow(row);
}
selectedIndex++;
} else {
if (!hitEnd) {
int answer = DataDeliveryUtils
@ -480,10 +334,11 @@ public class FindDlg extends CaveSWTDialog {
"The end of the table has been reached. Would you like to search from the beginning of the table?");
if (answer == SWT.NO) {
exists = true;
selectedIndex = prevSelectedIndex;
break;
// Start search over at beginning of table
} else if (answer == SWT.YES) {
tableIndex = 0;
// Start search over at beginning of table
selectedIndex = 0;
continueSearch = true;
}
hitEnd = true;
@ -499,7 +354,7 @@ public class FindDlg extends CaveSWTDialog {
mb.setText("Find Warning");
mb.setMessage("No item matching your search was found.");
mb.open();
tableIndex = 0;
selectedIndex = prevSelectedIndex;
callback.clearSelections();
}
}
@ -509,7 +364,6 @@ public class FindDlg extends CaveSWTDialog {
* text.
*/
private void handleHighlightBtn() {
// Text in the find text box
String text = findTxt.getText();
@ -519,61 +373,54 @@ public class FindDlg extends CaveSWTDialog {
caseFlag = caseBtn.getSelection();
excludeFlag = exclusionBtn.getSelection();
ArrayList<Integer> items = new ArrayList<Integer>();
int[] indices = new int[0];
// Start search at beginning of table
tableIndex = 0;
List<NotificationRowData> items = new ArrayList<NotificationRowData>();
if (filteredTableList != null) {
for (int i = 0; i < filteredTableList.getDataArray().size(); i++) {
for (int i = 0; i < filteredTableList.getSize(); i++) {
NotificationRowData row = filteredTableList.getDataArray().get(
i);
// Message Column
msg = row.getMessage();
// Subscription Name column
sub = row.getCategory();
if (caseFlag) {
if (excludeFlag) {
// Select index if does not match message or
// subscription
if ((!msg.contains(text) && msgFlag)
|| (!sub.contains(text) && categoryFlag)) {
items.add(i);
}
} else if ((msg.contains(text) && msgFlag)
|| (sub.contains(text) && categoryFlag)) {
// Select index if matches message or subscription
items.add(i);
}
} else {
if (excludeFlag) {
// Select index if matches non case sensitive message or
// subscription
if ((!msg.toUpperCase().contains(text.toUpperCase()) && msgFlag)
|| (!sub.toLowerCase().contains(
text.toLowerCase()) && categoryFlag)) {
items.add(i);
}
} else if ((msg.toUpperCase().contains(text.toUpperCase()) && msgFlag)
|| (sub.toLowerCase().contains(text.toLowerCase()) && categoryFlag)) {
items.add(i);
}
boolean matchFound = checkForMatch(text, row);
if (matchFound) {
items.add(row);
}
tableIndex++;
}
indices = new int[items.size()];
// Create an int array of the rows to highlight
for (int i = 0; i < items.size(); i++) {
indices[i] = items.get(i);
}
callback.selectIndices(indices);
callback.selectRows(items);
}
}
}
/**
* Check if the matchText matches the row.
*
* @param matchText
* The text to match
* @param row
* The row to check
* @return true if matches
*/
private boolean checkForMatch(String matchText, NotificationRowData row) {
boolean matchFound = false;
String msg = row.getMessage();
String sub = row.getCategory();
if (!caseFlag) {
msg = msg.toUpperCase();
sub = sub.toUpperCase();
matchText = matchText.toUpperCase();
}
if (excludeFlag) {
if ((!msg.contains(matchText) && msgFlag)
|| (!sub.contains(matchText) && categoryFlag)) {
matchFound = true;
}
} else {
if ((msg.contains(matchText) && msgFlag)
|| (sub.contains(matchText) && categoryFlag)) {
matchFound = true;
}
}
return matchFound;
}
}

View file

@ -104,6 +104,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Aug 30, 2013 2314 mpduff Change the reading of the xml. Make load config dlg non-blocking.
* Sep 25, 2013 2408 mpduff Added a restore hidden notifications menu.
* Sep 25, 2013 2410 mpduff Check type of localization file.
* Feb 07, 2013 2453 mpduff Support find dialog refactor..
*
* </pre>
*
@ -394,7 +395,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange,
hideOlderMI.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
tableComp.handleDeleteOlderThan();
tableComp.handleHideOlderThan();
}
});
@ -405,7 +406,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange,
hideMI.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
tableComp.handleDeleteNotification();
tableComp.handleHideNotification();
}
});
@ -493,7 +494,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange,
mi.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
tableComp.handleDeleteByPriority((Integer) ((MenuItem) e
tableComp.handleHideByPriority((Integer) ((MenuItem) e
.getSource()).getData());
}
});
@ -540,6 +541,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange,
id = Activator.imageDescriptorFromPlugin(
"com.raytheon.uf.viz.datadelivery", "icons/dd_new.png");
trayImg2 = id.createImage();
tray = display.getSystemTray();
createTray();
@ -572,8 +574,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange,
private void handleFind() {
if (fnd == null || fnd.isDisposed()) {
fnd = new FindDlg(shell, tableComp.getFilteredTableList(),
tableComp.getStartIndex(), tableComp.getEndIndex(),
tableComp.getSelectedIndex(), tableComp);
tableComp.getTable().getSelectionIndex(), tableComp);
fnd.open();
} else {
fnd.bringToTop();
@ -839,7 +840,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange,
if (isDisposed() == false && tableComp.passesFilter(records)) {
tableComp.populateTableDataRows(records);
tableComp.populateTable();
tableComp.handlePageSelection();
// update title display......
if (tableComp.isLocked()) {
setText(TITLE_TEXT + tableComp.getPauseCountLabel());

View file

@ -40,6 +40,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
* Jun 07, 2012 687 lvenable Table data refactor.
* Aug 30, 2013 2314 mpduff Fix formatting.
* Sep 16, 2013 2375 mpduff Change date sort order.
* Feb 07, 2014 2453 mpduff Added toString()
*
* </pre>
*
@ -299,4 +300,8 @@ public class NotificationRowData implements ITableData<NotificationRowData> {
}
}
@Override
public String toString() {
return this.date.toString() + " - " + this.message;
}
}

View file

@ -23,7 +23,6 @@ import java.util.ArrayList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.widgets.Shell;
@ -58,6 +57,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Oct 10, 2013 2428 skorolev Fixed memory leak for Regions
* Oct 24, 2013 2486 skorolev Fixed an error of editing subset box.
* Nov 06, 2013 2486 skorolev Corrected the regions and zoom handling defects.
* Jan 08, 2014 2643 mpduff Changed the way mouse interactions are handled.
*
* </pre>
*
@ -124,9 +124,6 @@ public class DrawBoxResource extends
/** The x value of the 360 degree longitude line */
private double x360;
/** Map pixel rectangle */
private Rectangle mapRctgl;
/**
* @param resourceData
* @param loadProperties
@ -165,7 +162,7 @@ public class DrawBoxResource extends
double[] lr = descriptor.worldToPixel(new double[] { c2.x, c2.y });
PixelExtent pe = new PixelExtent(ul[0], lr[0], ul[1], lr[1]);
target.drawRect(pe, boxColor, 3, 1);
getMapRectangle();
setCorners();
}
}
@ -190,8 +187,7 @@ public class DrawBoxResource extends
double[] point360 = getResourceContainer().translateInverseClick(c);
this.x360 = Math.round(point360[0]);
getMapRectangle();
setCorners();
}
/*
@ -225,18 +221,17 @@ public class DrawBoxResource extends
@Override
public boolean handleMouseDown(int x, int y, int mouseButton) {
if (mouseButton == 1) {
// handle mouse only in the map space
if (mapRctgl.contains(x, y)) {
// translateClick returns null if point is not in the map space
Coordinate coord = getResourceContainer().translateClick(x, y);
if (coord != null) {
if (!resizingBox) {
x1 = x;
y1 = y;
c1 = getResourceContainer().translateClick(x, y);
if (c1 != null) {
c1.x = spatialUtils.convertToEasting(c1.x);
if (spatialUtils.getLongitudinalShift() > 0
&& x >= x360) {
c1.x += 360;
}
c1 = (Coordinate) coord.clone();
c1.x = spatialUtils.convertToEasting(c1.x);
if (spatialUtils.getLongitudinalShift() > 0
&& x >= x360) {
c1.x += 360;
}
}
}
@ -256,34 +251,31 @@ public class DrawBoxResource extends
public boolean handleMouseDownMove(int x, int y, int mouseButton) {
if (mouseButton == 1) {
drawingBox = true;
// handle mouse only in the map space
if (mapRctgl.contains(x, y)) {
// translateClick returns null if point is not in the map space
Coordinate c = getResourceContainer().translateClick(x, y);
if (c != null) {
if (resizingBox) {
Coordinate c = getResourceContainer().translateClick(x,
y);
if (c != null) {
if (boxSide == 0) {
c1.y = c.y;
y1 = y;
} else if (boxSide == 1) {
c1.x = c.x;
x1 = x;
c1.x = spatialUtils.convertToEasting(c1.x);
if (spatialUtils.getLongitudinalShift() > 0
&& x >= x360) {
c1.x += 360;
}
} else if (boxSide == 2) {
c2.y = c.y;
y2 = y;
} else if (boxSide == 3) {
c2.x = c.x;
x2 = x;
c2.x = spatialUtils.convertToEasting(c2.x);
if (spatialUtils.getLongitudinalShift() > 0
&& x >= x360) {
c2.x += 360;
}
if (boxSide == 0) {
c1.y = c.y;
y1 = y;
} else if (boxSide == 1) {
c1.x = c.x;
x1 = x;
c1.x = spatialUtils.convertToEasting(c1.x);
if (spatialUtils.getLongitudinalShift() > 0
&& x >= x360) {
c1.x += 360;
}
} else if (boxSide == 2) {
c2.y = c.y;
y2 = y;
} else if (boxSide == 3) {
c2.x = c.x;
x2 = x;
c2.x = spatialUtils.convertToEasting(c2.x);
if (spatialUtils.getLongitudinalShift() > 0
&& x >= x360) {
c2.x += 360;
}
}
} else {
@ -298,7 +290,6 @@ public class DrawBoxResource extends
x2 = x;
y2 = y;
}
fireBoxChangedEvent();
target.setNeedsRefresh(true);
}
@ -347,37 +338,34 @@ public class DrawBoxResource extends
@Override
public boolean handleMouseUp(int x, int y, int mouseButton) {
if (mouseButton == 1) {
// handle mouse only in the map space
if (mapRctgl.contains(x, y)) {
// translateClick returns null if point is not in the map space
Coordinate c = getResourceContainer().translateClick(x, y);
if (c != null) {
if (resizingBox) {
Coordinate c = getResourceContainer().translateClick(x,
y);
if (c != null) {
c.x = spatialUtils.convertToEasting(c.x);
if (spatialUtils.getLongitudinalShift() > 0
&& x >= x360) {
c.x += 360;
}
if (boxSide == 0) {
c1.y = c.y;
y1 = y;
} else if (boxSide == 1) {
c1.x = c.x;
x1 = x;
} else if (boxSide == 2) {
c2.y = c.y;
y2 = y;
} else if (boxSide == 3) {
c2.x = c.x;
x2 = x;
}
c.x = spatialUtils.convertToEasting(c.x);
if (spatialUtils.getLongitudinalShift() > 0
&& x >= x360) {
c.x += 360;
}
if (boxSide == 0) {
c1.y = c.y;
y1 = y;
} else if (boxSide == 1) {
c1.x = c.x;
x1 = x;
} else if (boxSide == 2) {
c2.y = c.y;
y2 = y;
} else if (boxSide == 3) {
c2.x = c.x;
x2 = x;
}
} else {
if (drawingBox) {
x2 = x;
y2 = y;
c2 = getResourceContainer().translateClick(x, y);
if (c2 != null) {
c2 = getResourceContainer().translateClick(x, y);
if (c2 != null) {
if (drawingBox) {
x2 = x;
y2 = y;
c2.x = spatialUtils.convertToEasting(c2.x);
if (spatialUtils.getLongitudinalShift() > 0
&& x >= x360) {
@ -388,14 +376,14 @@ public class DrawBoxResource extends
c1 = getResourceContainer().translateClick(x, y);
}
}
createRegions();
target.setNeedsRefresh(true);
fireBoxChangedEvent();
}
createRegions();
target.setNeedsRefresh(true);
fireBoxChangedEvent();
drawingBox = false;
} else if (mouseButton == 2) {
super.handleMouseUp(x, y, 1);
getMapRectangle();
setCorners();
}
return true;
}
@ -554,23 +542,7 @@ public class DrawBoxResource extends
/**
* Get map's rectangle in pixels after changing.
*/
private void getMapRectangle() {
Coordinate top = new Coordinate();
top.x = spatialUtils.getUpperLeft().x;
top.y = spatialUtils.getUpperLeft().y;
double[] pointTop = getResourceContainer().translateInverseClick(top);
int xTop = (int) Math.round(pointTop[0]);
int yTop = (int) Math.round(pointTop[1]);
Coordinate bot = new Coordinate();
bot.x = spatialUtils.getLowerRight().x;
bot.y = spatialUtils.getLowerRight().y;
double[] pointBot = getResourceContainer().translateInverseClick(bot);
int xBottom = (int) Math.round(pointBot[0]);
int yBottom = (int) Math.round(pointBot[1]);
mapRctgl = new Rectangle(xTop, yTop, (xBottom - xTop), (yBottom - yTop));
private void setCorners() {
// Re-calculate regions
if ((c1 != null) && (c2 != null)) {
double[] luBox = getResourceContainer().translateInverseClick(c1);

View file

@ -39,6 +39,8 @@ import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IForceA
* ------------ ---------- ----------- --------------------------
* Dec 4, 2012 1286 djohnson Initial creation
* May 28, 2013 1650 djohnson More information when failing to schedule subscriptions.
* Jan 17, 2014 2459 mpduff Change gui usage of unscheduled to deactivated.
* Jan 26, 2014 2459 mpduff Change unscheduled label to deactivated.
*
* </pre>
*
@ -88,10 +90,10 @@ public class CancelForceApplyAndIncreaseLatencyDisplayText implements
if (singleSubscription
&& wouldBeUnscheduledSubscriptions.contains(name)) {
return titleCaseActionText + " " + name
+ " and leave in an unscheduled status";
+ " and leave in a Deactivated status";
}
return titleCaseActionText + " " + name
+ " and unschedule the others";
+ " and deactivate the others";
case EDIT_SUBSCRIPTIONS:
return "Edit the "
+ ((singleSubscription) ? "subscription" : "subscriptions");

View file

@ -72,7 +72,6 @@ import com.raytheon.uf.common.datadelivery.registry.SharedSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.registry.Utils.SubscriptionStatus;
import com.raytheon.uf.common.datadelivery.registry.ebxml.DataSetQuery;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.registry.handlers.IPendingSubscriptionHandler;
@ -144,6 +143,8 @@ import com.raytheon.viz.ui.presenter.components.ComboBoxConf;
* Oct 21, 2013 2292 mpduff Close dialog on OK.
* Nov 07, 2013 2291 skorolev Used showText() method for "Unable to Create Subscription" message.
* Nov 08, 2013 2506 bgonzale Removed send notification when a subscription is updated and created.
* Jan 14, 2014 2459 mpduff Change Subscription status code
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
*
* </pre>
*
@ -471,8 +472,7 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
btn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String currentSite = LocalizationManager.getInstance()
.getCurrentSite();
String currentSite = DataDeliveryUtils.getDataDeliveryId();
SiteSelectionDlg dlg = new SiteSelectionDlg(shell, currentSite,
sharedSites);
dlg.setCloseCallback(new ICloseCallback() {
@ -1030,7 +1030,7 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
subscription = sharedSub;
} else {
Set<String> officeList = Sets.newHashSet();
officeList.add(LocalizationManager.getInstance().getCurrentSite());
officeList.add(DataDeliveryUtils.getDataDeliveryId());
subscription.setOfficeIDs(officeList);
}
@ -1088,14 +1088,11 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
.parse(endText);
subscription.setActivePeriodEnd(endPeriodDate);
}
subscription.setActive(true);
} catch (ParseException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
} else {
subscription.setActive(true);
subscription.setActivePeriodStart(null);
subscription.setActivePeriodEnd(null);
}
@ -1543,8 +1540,7 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
*/
private void setSubscriptionId(Subscription sub) {
if (sub.getOriginatingSite() == null) {
LocalizationManager lm = LocalizationManager.getInstance();
sub.setOriginatingSite(lm.getCurrentSite());
sub.setOriginatingSite(DataDeliveryUtils.getDataDeliveryId());
}
String id = RegistryUtil.getRegistryObjectKey(sub);
sub.setId(id);
@ -1635,8 +1631,7 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
// If currently in the window, assume starting from last year for
// the start date
if (subscription.getStatus().equals(
SubscriptionStatus.ACTIVE.toString())) {
if (subscription.isActive()) {
calendarYearToUse--;
}

View file

@ -41,10 +41,10 @@ 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.auth.UserController;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.datadelivery.common.ui.GroupSelectComp;
import com.raytheon.uf.viz.datadelivery.common.ui.IGroupAction;
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.presenter.components.ComboBoxConf;
import com.raytheon.viz.ui.presenter.components.WidgetConf;
@ -67,7 +67,8 @@ import com.raytheon.viz.ui.presenter.components.WidgetConf;
* Apr 08, 2013 1826 djohnson Remove delivery options.
* May 14, 2013 1040 mpduff Changed to add office Id rather than setting it.
* May 21, 2013 2020 mpduff Rename UserSubscription to SiteSubscription.
* Nov 08, 2013 2506 bgonzale Removed send notification when a subscription is created.
* Nov 08, 2013 2506 bgonzale Removed send notification when a subscription is created.
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
*
* </pre>
*
@ -263,8 +264,7 @@ public class GroupAddDlg extends CaveSWTDialog {
System.out.println("Fix Me: Need to calculate data set size");
subscription.setDataSetSize(999);
subscription.addOfficeID(LocalizationManager.getInstance()
.getCurrentSite());
subscription.addOfficeID(DataDeliveryUtils.getDataDeliveryId());
// TODO: How to do this better? Will shared subscriptions participate in
// groups?

View file

@ -52,6 +52,7 @@ import com.raytheon.viz.ui.widgets.duallist.DualListConfig;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 29, 2013 1040 mpduff Initial creation
* Feb 11, 2014 2771 bgonzale Show all SiteDataTypes in site list.
*
* </pre>
*
@ -153,9 +154,7 @@ public class SiteSelectionDlg extends CaveSWTDialog {
for (Entry<String, SiteData> entry : siteDataMap.entrySet()) {
SiteDataType type = entry.getValue().getType();
if (type == SiteDataType.WFO || type == SiteDataType.RFC) {
siteList.add(entry.getKey());
}
siteList.add(entry.getKey());
}
// Remove the current site

View file

@ -26,6 +26,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.xml.bind.JAXBException;
@ -54,6 +57,7 @@ import org.eclipse.swt.widgets.TableColumn;
import com.raytheon.uf.common.auth.AuthException;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.datadelivery.registry.SharedSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
@ -71,6 +75,8 @@ import com.raytheon.uf.common.site.SiteMap;
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.util.TimeUtil;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.datadelivery.actions.DataBrowserAction;
@ -144,6 +150,12 @@ import com.raytheon.viz.ui.presenter.IDisplay;
* Nov 06, 2013 2358 mpduff Resurrected file management code.
* Nov 08, 2013 2506 bgonzale Removed send notification when a subscription is deleted.
* Dec 05, 2013 2570 skorolev Show All subscriptions.
* Jan 08, 2014 2642 mpduff Update dialog for permissions, adding site to shared
* Jan 14, 2014 2459 mpduff Change Subscription status code
* Feb 04, 2014 2722 mpduff Add auto-refresh task.
* Feb 14, 2014 2806 mpduff Disable activate/deactivate buttons when viewing other site's subscriptions
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
*
* </pre>
*
* @author mpduff
@ -180,8 +192,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
}
/** Current site */
private final String CURRENT_SITE = LocalizationManager.getInstance()
.getCurrentSite();
private final String CURRENT_SITE = DataDeliveryUtils.getDataDeliveryId();
/** The activate button */
private Button activateBtn;
@ -253,6 +264,29 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
/** Option to select all groups of subscriptions */
private final String ALL_SUBSCRIPTIONS = "All Subscriptions";
/** Edit menu */
private MenuItem editMI;
/** Copy menu */
private MenuItem copyMI;
/** Delete menu */
private MenuItem deleteMI;
/** Edit group menu */
private MenuItem editGroupMI;
/** Delete group menu */
private MenuItem deleteGroupMI;
/** Group menu */
private MenuItem groupMI;
/** New menu */
private MenuItem newMI;
private final ScheduledExecutorService scheduler;
/**
* Constructor
*
@ -263,9 +297,13 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
public SubscriptionManagerDlg(Shell parent,
ISubscriptionManagerFilter filter) {
super(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.RESIZE,
CAVE.INDEPENDENT_SHELL | CAVE.PERSPECTIVE_INDEPENDENT);
CAVE.INDEPENDENT_SHELL | CAVE.PERSPECTIVE_INDEPENDENT
| CAVE.DO_NOT_BLOCK);
this.filter = filter;
scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleAtFixedRate(new RefreshTask(), 15, 15,
TimeUnit.MINUTES);
setText("Data Delivery Subscription Manager");
}
@ -320,6 +358,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
createBottomButtons();
enableControls(true);
}
/*
@ -337,6 +376,17 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
return mainLayout;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
protected void disposed() {
super.disposed();
scheduler.shutdownNow();
}
/**
* Create subscription menu.
*/
@ -351,7 +401,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
Menu fileMenu = new Menu(menuBar);
fileMenuItem.setMenu(fileMenu);
MenuItem newMI = new MenuItem(fileMenu, SWT.NONE);
newMI = new MenuItem(fileMenu, SWT.NONE);
newMI.setText("New Subscription...");
newMI.addSelectionListener(new SelectionAdapter() {
@Override
@ -360,7 +410,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
}
});
MenuItem groupMI = new MenuItem(fileMenu, SWT.NONE);
groupMI = new MenuItem(fileMenu, SWT.NONE);
groupMI.setText("New Group...");
groupMI.addSelectionListener(new SelectionAdapter() {
@Override
@ -510,7 +560,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
Menu editMenu = new Menu(menuBar);
editMenuItem.setMenu(editMenu);
MenuItem editMI = new MenuItem(editMenu, SWT.NONE);
editMI = new MenuItem(editMenu, SWT.NONE);
editMI.setText("Edit Subscription...");
editMI.addSelectionListener(new SelectionAdapter() {
@Override
@ -519,7 +569,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
}
});
MenuItem copyMI = new MenuItem(editMenu, SWT.NONE);
copyMI = new MenuItem(editMenu, SWT.NONE);
copyMI.setText("Copy Subscription...");
copyMI.addSelectionListener(new SelectionAdapter() {
@Override
@ -528,8 +578,8 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
}
});
MenuItem deleteMI = new MenuItem(editMenu, SWT.NONE);
deleteMI.setText("Delete Subscription");
deleteMI = new MenuItem(editMenu, SWT.NONE);
deleteMI.setText("Delete/Remove from Subscription");
deleteMI.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
@ -537,7 +587,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
}
});
MenuItem editGroupMI = new MenuItem(editMenu, SWT.NONE);
editGroupMI = new MenuItem(editMenu, SWT.NONE);
editGroupMI.setText("Edit Group...");
editGroupMI.addSelectionListener(new SelectionAdapter() {
@Override
@ -546,7 +596,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
}
});
MenuItem deleteGroupMI = new MenuItem(editMenu, SWT.NONE);
deleteGroupMI = new MenuItem(editMenu, SWT.NONE);
deleteGroupMI.setText("Delete Group...");
deleteGroupMI.addSelectionListener(new SelectionAdapter() {
@Override
@ -607,6 +657,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
@Override
public void widgetSelected(SelectionEvent event) {
handleFilterSelection();
enableControls(officeCbo.getText().equals(CURRENT_SITE));
}
});
@ -631,8 +682,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
*/
@Override
public void handleRefresh() {
tableComp.populateData();
tableComp.populateTable();
tableComp.handleRefresh();
}
private void createBottomButtons() {
@ -702,7 +752,6 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
* true for create dialog and false for edit
*/
private void handleGroupCreate(boolean create) {
final String permission = DataDeliveryPermission.SUBSCRIPTION_CREATE
.toString();
IUser user = UserController.getUserObject();
@ -940,52 +989,78 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
try {
if (DataDeliveryServices.getPermissionsService()
.checkPermission(user, msg, permission).isAuthorized()) {
String message = null;
ArrayList<SubscriptionManagerRowData> deleteList = new ArrayList<SubscriptionManagerRowData>();
final List<Subscription> subsToDelete = new ArrayList<Subscription>();
final List<Subscription> subsToUpdate = new ArrayList<Subscription>();
if (selectionCount > 1) {
message = "Are you sure you want to delete these subscriptions?";
} else {
message = "Are you sure you want to delete this subscription?";
for (int idx : tableComp.getTable().getSelectionIndices()) {
SubscriptionManagerRowData removedItem = tableComp
.getSubscriptionData().getDataRow(idx);
Subscription sub = removedItem.getSubscription();
if (sub instanceof SharedSubscription) {
sub.getOfficeIDs().remove(CURRENT_SITE);
if (sub.getOfficeIDs().size() > 0) {
subsToUpdate.add(sub);
} else {
subsToDelete.add(sub);
}
} else {
subsToDelete.add(removedItem.getSubscription());
}
deleteList.add(removedItem);
}
String message = getMessage(subsToDelete, subsToUpdate);
int choice = DataDeliveryUtils.showMessage(shell, SWT.YES
| SWT.NO, "Delete Confirmation", message);
if (choice == SWT.YES) {
ArrayList<SubscriptionManagerRowData> deleteList = new ArrayList<SubscriptionManagerRowData>();
final List<Subscription> subsToDelete = new ArrayList<Subscription>();
for (int idx : tableComp.getTable().getSelectionIndices()) {
SubscriptionManagerRowData removedItem = tableComp
.getSubscriptionData().getDataRow(idx);
subsToDelete.add(removedItem.getSubscription());
deleteList.add(removedItem);
}
// remove the rows from the table
tableComp.getSubscriptionData().removeAll(deleteList);
// Should we be using this or the LocalizationManager, or
// UserController.getUserObject().getUniqueID()
final String username = System.getenv().get("LOGNAME");
final String username = LocalizationManager.getInstance()
.getCurrentUser();
Job job = new Job("Deleting Subscriptions...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
DataDeliveryGUIUtils.markBusyInUIThread(shell);
List<RegistryHandlerException> exceptions = deleteSubscriptions(
username, subsToDelete);
List<RegistryHandlerException> exceptions = new ArrayList<RegistryHandlerException>(
0);
if (!subsToDelete.isEmpty()) {
exceptions = deleteSubscriptions(username,
subsToDelete);
}
if (!subsToUpdate.isEmpty()) {
exceptions.addAll(updateSubscriptions(username,
subsToUpdate));
}
for (RegistryHandlerException t : exceptions) {
statusHandler.handle(Priority.ERROR,
"Failed to delete some subscriptions: "
+ t.getLocalizedMessage(), t);
}
return Status.OK_STATUS;
}
};
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
handleRefresh();
}
});
DataDeliveryGUIUtils.markNotBusyInUIThread(shell);
}
});
job.schedule();
} else {
// Refresh the table to reset any objects edited
handleRefresh();
}
}
} catch (AuthException e) {
@ -993,6 +1068,35 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
}
}
/**
* Get the delete confirmation message.
*
* @param subsToDelete
* subscription list to delete
* @param subsToUpdate
* subscription list to update
* @return The confirmation message
*/
private String getMessage(List<Subscription> subsToDelete,
List<Subscription> subsToUpdate) {
StringBuilder sb = new StringBuilder();
if (!subsToDelete.isEmpty()) {
sb.append("The following subscriptions will be deleted:\n");
for (Subscription sub : subsToDelete) {
sb.append(sub.getName()).append("\n");
}
}
if (!subsToUpdate.isEmpty()) {
sb.append("\nThe following subscriptions will be removed:\n");
for (Subscription sub : subsToUpdate) {
sb.append(sub.getName()).append("\n");
}
}
return sb.toString();
}
/**
* Handle filtering the subscription table using combo box selections.
*/
@ -1080,7 +1184,11 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
.getSubscriptionData().getDataRow(idx);
Subscription sub = rowData.getSubscription();
sub.setActive(activate);
if (activate) {
sub.activate();
} else {
sub.deactivate();
}
try {
SubscriptionServiceResult response = subscriptionService
@ -1199,16 +1307,12 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
Set<String> sites = siteData.keySet();
officeNames = sites.toArray(new String[sites.size()]);
String[] officeAll = new String[officeNames.length + 1];
officeAll[0] = ALL;
System.arraycopy(officeNames, 0, officeAll, 1, officeNames.length);
officeCbo.setItems(officeAll);
officeCbo.setItems(officeNames);
String site = CURRENT_SITE;
if (this.selectedOffice != null) {
for (String item : officeAll) {
for (String item : officeNames) {
if (item.equals(selectedOffice)) {
site = item;
break;
@ -1319,7 +1423,6 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
*/
private List<RegistryHandlerException> deleteSubscriptions(String username,
List<Subscription> subscriptions) {
List<RegistryHandlerException> exceptions = new ArrayList<RegistryHandlerException>();
ISubscriptionHandler handler = RegistryObjectHandlers
@ -1333,6 +1436,32 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
return exceptions;
}
/**
* Update subscriptions.
*
* @param username
* User updating the subscriptions
* @param subscriptions
* Subscriptions to update
* @return List of errors that occurred
*/
private List<RegistryHandlerException> updateSubscriptions(String username,
List<Subscription> subscriptions) {
List<RegistryHandlerException> exceptions = new ArrayList<RegistryHandlerException>();
ISubscriptionHandler handler = RegistryObjectHandlers
.get(ISubscriptionHandler.class);
for (Subscription sub : subscriptions) {
try {
handler.update(sub);
} catch (RegistryHandlerException e) {
exceptions.add(e);
}
}
return exceptions;
}
/**
* {@inheritDoc}
*/
@ -1389,4 +1518,41 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
loadGroupNames();
loadOfficeNames();
}
/**
* Enable/Disable controls.
*
* @param enable
* true to enable, false to disable
*/
private void enableControls(boolean enable) {
copyMI.setEnabled(enable);
deleteGroupMI.setEnabled(enable);
editMI.setEnabled(enable);
copyMI.setEnabled(enable);
deleteMI.setEnabled(enable);
editGroupMI.setEnabled(enable);
groupMI.setEnabled(enable);
newMI.setEnabled(enable);
tableComp.enableMenus(enable);
activateBtn.setEnabled(enable);
deactivateBtn.setEnabled(enable);
}
/**
* Private inner work thread used to auto refresh dialog.
*/
private class RefreshTask implements Runnable {
@Override
public void run() {
if (TimeUtil.currentTimeMillis() - tableComp.getLastUpdateTime() >= TimeUtil.MILLIS_PER_MINUTE * 5) {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
handleRefresh();
}
});
}
}
}
}

View file

@ -50,6 +50,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
* Jan 25, 2012 1528 djohnson Priorities no longer need incrementing for display.
* Apr 08, 2013 1826 djohnson Remove delivery options.
* May 15, 2013 1040 mpduff Change Office IDs to set.
* Jan 14, 2014 2459 mpduff Change Subscription status code
* </pre>
*
* @author mpduff
@ -472,8 +473,7 @@ public class SubscriptionManagerRowData implements
this.setPriority(subscription.getPriority().getPriorityValue());
this.setSubscriptionStart(subscription.getSubscriptionStart());
this.setSubscriptionEnd(subscription.getSubscriptionEnd());
this.setActive(subscription.isActive());
this.setStatus(subscription.getStatus());
this.setStatus(subscription.getStatus().toString());
}
/**

View file

@ -45,7 +45,9 @@ import com.raytheon.uf.common.datadelivery.registry.GriddedTime;
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
import com.raytheon.uf.common.datadelivery.registry.PendingSubscription;
import com.raytheon.uf.common.datadelivery.registry.PointTime;
import com.raytheon.uf.common.datadelivery.registry.RecurringSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionState;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.registry.handlers.IPendingSubscriptionHandler;
@ -94,6 +96,8 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
* Oct 12, 2013 2460 dhladky restored adhoc subscriptions to registry storage.
* Oct 22, 2013 2292 mpduff Removed subscriptionOverlapService.
* Nov 07, 2013 2291 skorolev Used showText() method for "Shared Subscription" message.
* Jan 26, 2014 2259 mpduff Turn off subs to be deactivated.
* Feb 04, 2014 2677 mpduff Don't do overlap checks when deactivating subs.
*
* </pre>
*
@ -539,28 +543,42 @@ public class SubscriptionService implements ISubscriptionService {
final IForceApplyPromptDisplayText displayTextStrategy)
throws RegistryHandlerException {
SubscriptionOverlapRequest request = new SubscriptionOverlapRequest(
subscriptions);
if (subscriptions == null || subscriptions.isEmpty()) {
return new SubscriptionServiceResult(false,
"No subscriptions submitted.");
}
SubscriptionOverlapResponse response = null;
try {
response = (SubscriptionOverlapResponse) RequestRouter.route(
request, DataDeliveryConstants.DATA_DELIVERY_SERVER);
if (response.isDuplicate()) {
return new SubscriptionServiceResult(true,
StringUtil.createMessage(DUPLICATE_SUBSCRIPTIONS,
response.getSubscriptionNameList()));
}
/*
* If activating the subscriptions check for overlaps.
*
* Only need to check one because all are being updated the same way.
*/
if (subscriptions.get(0).getSubscriptionState() == SubscriptionState.ON) {
SubscriptionOverlapRequest request = new SubscriptionOverlapRequest(
subscriptions);
if (response.isOverlap()) {
List<String> subNames = response.getSubscriptionNameList();
Collections.sort(subNames);
forceApplyPrompt.displayMessage(displayTextStrategy, StringUtil
.createMessage(OVERLAPPING_SUBSCRIPTIONS, subNames));
SubscriptionOverlapResponse response = null;
try {
response = (SubscriptionOverlapResponse) RequestRouter.route(
request, DataDeliveryConstants.DATA_DELIVERY_SERVER);
if (response.isDuplicate()) {
return new SubscriptionServiceResult(true,
StringUtil.createMessage(DUPLICATE_SUBSCRIPTIONS,
response.getSubscriptionNameList()));
}
if (response.isOverlap()) {
List<String> subNames = response.getSubscriptionNameList();
Collections.sort(subNames);
forceApplyPrompt.displayMessage(displayTextStrategy,
StringUtil.createMessage(OVERLAPPING_SUBSCRIPTIONS,
subNames));
}
} catch (Exception e) {
statusHandler.error("Error checking subscription overlapping",
e);
return new SubscriptionServiceResult(false);
}
} catch (Exception e) {
statusHandler.error("Error checking subscription overlapping", e);
return new SubscriptionServiceResult(false);
}
try {
@ -768,6 +786,10 @@ public class SubscriptionService implements ISubscriptionService {
continue;
}
unscheduledSub.setUnscheduled(true);
if (unscheduledSub instanceof RecurringSubscription) {
((RecurringSubscription) unscheduledSub)
.setSubscriptionState(SubscriptionState.OFF);
}
subscriptionHandler.update(unscheduledSub);
}
}

View file

@ -46,7 +46,9 @@ import org.eclipse.swt.widgets.TableItem;
import com.raytheon.uf.common.auth.AuthException;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.datadelivery.registry.PendingSubscription;
import com.raytheon.uf.common.datadelivery.registry.SharedSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
import com.raytheon.uf.common.datadelivery.service.BaseSubscriptionNotificationResponse;
@ -55,6 +57,7 @@ import com.raytheon.uf.common.registry.handler.RegistryObjectHandlers;
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.util.TimeUtil;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.notification.NotificationMessage;
@ -106,6 +109,9 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
* Jul 29, 2013 2232 mpduff IndexOutOfBoundsException check.
* Jul 26, 2031 2232 mpduff Refactored Data Delivery permissions.
* Oct 11, 2013 2386 mpduff Refactor DD Front end.
* Jan 08, 2014 2642 mpduff Enable/disable menus based on site, allow user to add their site to a shared sub.
* Feb 04, 2014 2722 mpduff Add last update time.
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
* @version 1.0
*/
@ -115,6 +121,9 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(SubscriptionTableComp.class);
/** Current site constant */
private final String CURRENT_SITE = DataDeliveryUtils.getDataDeliveryId();
/** Pop up menu object. */
private Menu popupMenu;
@ -152,6 +161,12 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
/** The subscription type. */
private SubscriptionType subType = SubscriptionType.VIEWER;
/** Currently selected site */
private boolean currentSiteSelected;
/** Last table update time */
protected long lastUpdateTime = TimeUtil.currentTimeMillis();
/**
* Constructor.
*
@ -668,7 +683,7 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
if (subType == SubscriptionType.MANAGER) {
MenuItem editItem = new MenuItem(popupMenu, SWT.PUSH);
editItem.setText("Edit...");
editItem.setEnabled(menuItemsEnabled);
editItem.setEnabled(menuItemsEnabled && this.currentSiteSelected);
editItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@ -679,13 +694,32 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
// Add the selected row to a subscription group
MenuItem groupItem = new MenuItem(popupMenu, SWT.PUSH);
groupItem.setText("Add to Group...");
groupItem.setEnabled(menuItemsEnabled);
groupItem.setEnabled(menuItemsEnabled && this.currentSiteSelected);
groupItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleGroupAdd();
}
});
/*
* If a single shared sub is selected and another site's subs are
* loaded then allow the user to add their site to the shared sub.
*/
if (table.getSelectionCount() == 1) {
final Subscription sub = getSelectedSubscription();
if (sub instanceof SharedSubscription) {
MenuItem addToShared = new MenuItem(popupMenu, SWT.PUSH);
addToShared.setText("Add site to shared");// subscription");
addToShared.setEnabled(true);
addToShared.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleAddSiteToShared(sub);
}
});
}
}
}
table.setMenu(popupMenu);
@ -730,6 +764,7 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
lastUpdateTime = TimeUtil.currentTimeMillis();
if (!isDisposed()) {
handleRefresh();
}
@ -753,9 +788,11 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
*/
@Override
public void handleRefresh() {
populateData();
populateTable();
if (!isDisposed()) {
populateData();
populateTable();
this.lastUpdateTime = TimeUtil.currentTimeMillis();
}
}
@Override
@ -786,4 +823,83 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
ISubscriptionManagerFilter subscriptionFilter) {
this.subscriptionFilter = subscriptionFilter;
}
}
/**
* Enable based on the current site selected in the SubscriptionManagerDlg.
*
* @param enable
* true to enable the menu
*/
protected void enableMenus(boolean enable) {
this.currentSiteSelected = enable;
}
/**
* Add the current site ID to the shared subscription.
*
* @param sub
* The subscription to add the current site
*/
private void handleAddSiteToShared(final Subscription sub) {
final Shell shell = table.getShell();
Job job = new Job("Updating Subscription...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
DataDeliveryGUIUtils.markBusyInUIThread(shell);
final String permission = DataDeliveryPermission.SUBSCRIPTION_EDIT
.toString();
IUser user = UserController.getUserObject();
String msg = user.uniqueId()
+ " is not authorized to add site to existing shared subscriptions.\nPermission: "
+ permission;
try {
if (DataDeliveryServices.getPermissionsService()
.checkPermissions(user, msg, permission)
.isAuthorized()) {
sub.getOfficeIDs().add(CURRENT_SITE);
DataDeliveryHandlers.getSubscriptionHandler()
.update(sub);
}
} catch (AuthException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred in authorization request", e);
} catch (RegistryHandlerException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
return Status.OK_STATUS;
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Unexpected Exception", e);
return Status.CANCEL_STATUS;
}
}
};
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
try {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
populateTable();
}
});
} finally {
DataDeliveryGUIUtils.markNotBusyInUIThread(shell);
}
}
});
job.schedule();
}
/**
* @return the lastUpdateTime
*/
public long getLastUpdateTime() {
return lastUpdateTime;
}
}

View file

@ -51,6 +51,7 @@ import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSet;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.PointDataSet;
import com.raytheon.uf.common.datadelivery.registry.SharedSubscription;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionType;
@ -68,6 +69,7 @@ import com.raytheon.uf.viz.core.VizAppTaskExecutor;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.datadelivery.common.xml.AreaXML;
import com.raytheon.uf.viz.datadelivery.filter.MetaDataManager;
import com.raytheon.uf.viz.datadelivery.handlers.VizSubscriptionHandler;
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.subscription.CreateSubscriptionDlg;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService;
@ -138,6 +140,12 @@ import com.raytheon.viz.ui.presenter.IDisplay;
* Oct 25, 2013 2292 mpduff Move overlap processing to edex.
* Nov 14, 2013 2538 mpduff Added check for duplicate subscription.
* Nov 14, 2013 2548 mpduff Set the subscription type (QUERY OR RECURRING)
* Jan 14, 2014 2459 mpduff Change Subscription status code
* Jan 20, 2014 2538 mpduff Call doesNameExist method to check for dupes
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
* Feb 26, 2014 #2833 lvenable Added code to prevent the Subset (this) dialog from
* disappearing when the Subscription button is double clicked.
* Added dispose check for subscription button.
* </pre>
*
* @author mpduff
@ -412,7 +420,7 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
int buttonWidth = 87;
GridData btnData = new GridData(buttonWidth, SWT.DEFAULT);
Button subscribeBtn = new Button(bottomComp, SWT.PUSH);
final Button subscribeBtn = new Button(bottomComp, SWT.PUSH);
if (!create) {
subscribeBtn.setText("Continue...");
subscribeBtn.setToolTipText("Click to continue editing");
@ -425,6 +433,14 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
subscribeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
/*
* Need to disable the Subscription button as it takes time to
* do all of the validation. Once the subscription dialog
* returns the button will enable.
*/
subscribeBtn.setEnabled(false);
if (subscription == null) {
launchCreateSubscriptionGui(createSubscription(
new SiteSubscription(), Network.OPSNET));
@ -433,6 +449,11 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
subscription.getRoute());
launchCreateSubscriptionGui(subscription);
}
// Enable the subscription button if it is not disposed.
if (subscribeBtn.isDisposed() == false) {
subscribeBtn.setEnabled(true);
}
}
});
@ -504,10 +525,13 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
if (valid) {
// Check for existing subscription
ISubscriptionHandler handler = RegistryObjectHandlers
VizSubscriptionHandler handler = (VizSubscriptionHandler) RegistryObjectHandlers
.get(ISubscriptionHandler.class);
String name = nameText.getText();
try {
if (handler.getByName(nameText.getText()) != null) {
if (handler.doesNameExist(name, SiteSubscription.class,
SharedSubscription.class, AdhocSubscription.class)) {
String message = "A query with this name already exists.\n\nPlease enter a different query name.";
DataDeliveryUtils.showMessage(getShell(), SWT.ERROR,
"Duplicate Query Name", message);
@ -563,8 +587,7 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
sub.setOwner((create) ? LocalizationManager.getInstance()
.getCurrentUser() : this.subscription.getOwner());
sub.setOriginatingSite(LocalizationManager.getInstance()
.getCurrentSite());
sub.setOriginatingSite(DataDeliveryUtils.getDataDeliveryId());
sub.setSubscriptionType(SubscriptionType.RECURRING);
return setupCommonSubscriptionAttributes(sub, defaultRoute);
@ -592,7 +615,7 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
sub.setRoute(defaultRoute);
sub.setName(nameText.getText());
if (subscription == null || subscription.getOfficeIDs() == null) {
sub.addOfficeID(LocalizationManager.getInstance().getCurrentSite());
sub.addOfficeID(DataDeliveryUtils.getDataDeliveryId());
} else {
sub.setOfficeIDs(subscription.getOfficeIDs());
}
@ -603,7 +626,6 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
sub.setSubscriptionStart(this.subscription.getSubscriptionStart());
sub.setActivePeriodEnd(this.subscription.getActivePeriodEnd());
sub.setActivePeriodStart(this.subscription.getActivePeriodStart());
sub.setActive(this.subscription.isActive());
sub.setPriority(this.subscription.getPriority());
}

View file

@ -34,6 +34,9 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.auth.resp.SuccessfulExecution;
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest;
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest.RequestType;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.DataLevelType;
import com.raytheon.uf.common.datadelivery.registry.DataType;
@ -43,6 +46,8 @@ import com.raytheon.uf.common.datadelivery.registry.Parameter;
import com.raytheon.uf.common.datadelivery.registry.PointTime;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
import com.raytheon.uf.common.serialization.comm.RequestRouter;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.util.CollectionUtil;
import com.raytheon.uf.common.util.SizeUtil;
@ -82,8 +87,9 @@ import com.vividsolutions.jts.geom.Coordinate;
* Jul 26, 2031 2232 mpduff Removed sendAuthorizationRequest method.
* Aug 30, 2013 2288 bgonzale Added latency to details display.
* Sep 30, 2013 1797 dhladky Time GriddedTime separation
* Oct 11, 2013 2386 mpduff Refactor DD Front end.
* Nov 07, 2013 2291 skorolev Added showText() method for messages with many lines.
* Oct 11, 2013 2386 mpduff Refactor DD Front end.
* Nov 07, 2013 2291 skorolev Added showText() method for messages with many lines.
* Feb 11, 2014 2771 bgonzale Added Data Delivery ID, getter, and retrieval method.
* </pre>
*
* @author mpduff
@ -121,6 +127,8 @@ public class DataDeliveryUtils {
public static final String UNABLE_TO_RETRIEVE_PENDING_SUBSCRIPTIONS = "Unable to retrieve pending subscriptions!";
private static final String dataDeliveryId = retrieveDataDeliveryId();
/**
* TABLE_TYPE enumeration.
*/
@ -832,4 +840,21 @@ public class DataDeliveryUtils {
public static int getMaxLatency(GriddedDataSet dataSet) {
return getMaxLatency(new ArrayList<Integer>(dataSet.getCycles()));
}
public static String getDataDeliveryId() {
return dataDeliveryId;
}
private static String retrieveDataDeliveryId() {
IBandwidthRequest request = new IBandwidthRequest();
request.setRequestType(RequestType.GET_DATADELIVERY_ID);
try {
SuccessfulExecution response = (SuccessfulExecution) RequestRouter
.route(request, DataDeliveryConstants.DATA_DELIVERY_SERVER);
return (String) response.getResponse();
} catch (Exception e) {
throw new RuntimeException(
"Unable to retrieve Data Delivery ID from EDEX.", e);
}
}
}

View file

@ -31,6 +31,7 @@ import com.raytheon.uf.viz.datadelivery.notification.xml.MessageLoadXML;
* Mar 12, 2012 jsanchez Initial creation
* Jan 22, 2013 1501 djohnson Route requests to datadelivery.
* Sep 05, 2013 2314 mpduff support the load all messages option.
* Feb 07, 2014 2453 mpduff Remove username query param.
*
* </pre>
*
@ -84,10 +85,9 @@ public class NotificationHandler implements INotificationObserver {
public List<NotificationRecord> intialLoad(MessageLoadXML messageLoad,
ArrayList<String> users) {
int loadAmount;
String username = null;
Integer hours = null;
Integer maxResults = null;
Boolean loadAll = false;
boolean loadAll = false;
// Retrieve the message load configuration
if (messageLoad != null) {
loadAll = messageLoad.isLoadAllMessages();
@ -100,22 +100,11 @@ public class NotificationHandler implements INotificationObserver {
}
}
// Set usernames from filter
if (users != null && users.isEmpty() == false) {
StringBuffer sb = new StringBuffer();
for (String user : users) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(user);
}
username = sb.toString();
}
// Request data from the notification table.
// Note: Removing username query parameter for front end label
// consistency
try {
GetNotificationRequest request = new GetNotificationRequest();
request.setUsername(username);
request.setHours(hours);
request.setMaxResults(maxResults);
request.setLoadAll(loadAll);

View file

@ -21,7 +21,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 7, 2013 skorolev Initial creation
* Nov 7, 2013 skorolev Initial creation
* Jan 20, 2013 #2291 lvenable Fixed resizing of components.
*
* </pre>
*
@ -41,23 +42,26 @@ public class TextMessageDlg extends CaveSWTDialog {
@Override
protected void initializeComponents(Shell shell) {
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, false, false);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
GridLayout gl = new GridLayout(1, false);
Composite mainComp = new Composite(shell, SWT.NONE);
mainComp.setLayout(gl);
mainComp.setLayoutData(gd);
gd = new GridData();
gd.widthHint = 350;
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 400;
gd.heightHint = 350;
StyledText text = new StyledText(mainComp, SWT.MULTI | SWT.WRAP
| SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
text.setLayoutData(gd);
text.setText(messageText);
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.widthHint = 60;
Button okBtn = new Button(mainComp, SWT.PUSH);
okBtn.setText("OK");
okBtn.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, true));
okBtn.setLayoutData(gd);
okBtn.setLayoutData(gd);
okBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@ -65,5 +69,4 @@ public class TextMessageDlg extends CaveSWTDialog {
}
});
}
}

View file

@ -57,6 +57,7 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
* Jul 16, 2013 2158 bsteffen Allow VizGlobalsManager to work without
* accessing UI thread.
* Oct 15, 2013 2361 njensen Added startupTimer
* Jan 27, 2014 2744 njensen Add Local History pref back in
*
* </pre>
*
@ -192,8 +193,17 @@ public class VizWorkbenchAdvisor extends WorkbenchAdvisor {
for (IPreferenceNode root : topNodes) {
String rootId = root.getId();
if (rootId.equals("org.eclipse.ui.preferencePages.Workbench")) {
IPreferenceNode node = root
.findSubNode("org.eclipse.ui.preferencePages.Workspace");
if (node != null) {
node.remove("org.eclipse.ui.preferencePages.LinkedResources");
node.remove("org.eclipse.ui.preferencePages.BuildOrder");
IPreferenceNode localHistoryNode = node
.findSubNode("org.eclipse.ui.preferencePages.FileStates");
root.add(localHistoryNode);
root.remove("org.eclipse.ui.preferencePages.Workspace");
}
root.remove("org.eclipse.search.preferences.SearchPreferencePage");
root.remove("org.eclipse.ui.preferencePages.Workspace");
} else if (rootId.equals("org.python.pydev.prefs")) {
root.remove("org.python.pydev.ui.pythonpathconf.interpreterPreferencesPageJython");
root.remove("org.python.pydev.ui.pythonpathconf.interpreterPreferencesPageIronpython");
@ -325,7 +335,7 @@ public class VizWorkbenchAdvisor extends WorkbenchAdvisor {
startupTimer.stop();
System.out.println("Workbench startup time: "
+ startupTimer.getElapsedTime() + " ms");
}
}
}

View file

@ -123,8 +123,10 @@ public class AlertVizApplication implements IStandaloneComponent {
AlertvizJob as = new AlertvizJob(port);
if (as.isAlreadyStarted()) {
Container.logInternal(Priority.ERROR,
"Alertviz already started on port: " + port + ", exiting");
String exitMsg = "Alertviz already started on port: " + port
+ ", exiting";
System.out.println(exitMsg);
Container.logInternal(Priority.ERROR, exitMsg);
return IApplication.EXIT_OK;
}

View file

@ -23,11 +23,11 @@
</requires>
<plugin
id="com.raytheon.edex.plugin.modelsounding"
id="com.raytheon.uf.common.dataplugin.modelsounding"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
unpack="true"/>
<plugin
id="com.raytheon.uf.common.sounding"

View file

@ -13,7 +13,8 @@ Require-Bundle: com.raytheon.uf.viz.core,
com.raytheon.viz.core;bundle-version="1.12.1174",
com.raytheon.viz.ui;bundle-version="1.12.1174",
com.raytheon.viz.alerts;bundle-version="1.12.1174",
com.raytheon.uf.viz.thinclient;bundle-version="1.0.0"
com.raytheon.uf.viz.thinclient;bundle-version="1.0.0",
com.raytheon.viz.grid;bundle-version="1.12.1174"
Import-Package: com.raytheon.uf.common.comm,
com.raytheon.uf.common.datastorage,
com.raytheon.uf.viz.core.maps.rsc,

View file

@ -36,6 +36,7 @@ import com.raytheon.uf.viz.core.comm.ConnectivityManager;
import com.raytheon.uf.viz.core.comm.ConnectivityManager.ConnectivityResult;
import com.raytheon.uf.viz.core.comm.IConnectivityCallback;
import com.raytheon.uf.viz.thinclient.Activator;
import com.raytheon.uf.viz.thinclient.ThinClientUriUtil;
import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
/**
@ -51,6 +52,7 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
* Jan 14, 2013 1469 bkowal The hdf5 data directory is no longer a
* preference.
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
* Feb 04, 2014 2704 njensen Only one field for proxy server
*
* </pre>
*
@ -61,9 +63,7 @@ public class ThinClientServerPreferences extends FieldEditorPreferencePage {
private BooleanFieldEditor useProxies;
private StringFieldEditor pypiesServer;
private StringFieldEditor servicesServer;
private StringFieldEditor proxyServer;
private Button connectivityButton;
@ -92,18 +92,11 @@ public class ThinClientServerPreferences extends FieldEditorPreferencePage {
"&Use Proxy Servers", getFieldEditorParent());
addField(useProxies);
servicesServer = new StringFieldEditor(
ThinClientPreferenceConstants.P_SERVICES_PROXY,
"&Services Address: ", getFieldEditorParent());
servicesServer.setErrorMessage("Cannot connect to Services server");
addField(servicesServer);
pypiesServer = new StringFieldEditor(
ThinClientPreferenceConstants.P_PYPIES_PROXY,
"&Pypies Address: ", getFieldEditorParent());
pypiesServer.setErrorMessage("Cannot connect to Pypies server");
addField(pypiesServer);
proxyServer = new StringFieldEditor(
ThinClientPreferenceConstants.P_PROXY_ADDRESS,
"&Proxy Address: ", getFieldEditorParent());
proxyServer.setErrorMessage("Cannot connect to Proxy server");
addField(proxyServer);
addConnectivityButton();
}
@ -131,43 +124,40 @@ public class ThinClientServerPreferences extends FieldEditorPreferencePage {
* Check the connectivity of the server field editors
*/
private void checkConnectivity() {
final ConnectivityResult result = new ConnectivityResult(false, "");
final ConnectivityResult servicesResult = new ConnectivityResult(false,
"");
final ConnectivityResult pypiesResult = new ConnectivityResult(false,
"");
String errorMessage = "Cannot connect to proxy server: ";
boolean serverError = false;
// check HTTP Server
Text text = servicesServer.getTextControl(getFieldEditorParent());
ConnectivityManager.checkLocalizationServer(text.getText().trim(),
Text text = proxyServer.getTextControl(getFieldEditorParent());
String proxyAddr = text.getText().trim();
ConnectivityManager.checkLocalizationServer(
ThinClientUriUtil.getServicesAddress(proxyAddr),
new IConnectivityCallback() {
@Override
public void connectionChecked(ConnectivityResult results) {
result.hasConnectivity = results.hasConnectivity;
servicesResult.hasConnectivity = results.hasConnectivity;
}
});
if (result.hasConnectivity) {
text.setBackground(Display.getDefault().getSystemColor(
SWT.COLOR_WHITE));
} else {
text.setBackground(Display.getDefault().getSystemColor(
SWT.COLOR_RED));
serverError = true;
}
// check Pypies Server
Text textPypies = pypiesServer.getTextControl(getFieldEditorParent());
ConnectivityManager.checkHttpServer(textPypies.getText().trim(),
ConnectivityManager.checkHttpServer(
ThinClientUriUtil.getPypiesAddress(proxyAddr),
new IConnectivityCallback() {
@Override
public void connectionChecked(ConnectivityResult results) {
result.hasConnectivity = results.hasConnectivity;
pypiesResult.hasConnectivity = results.hasConnectivity;
}
});
if (result.hasConnectivity) {
textPypies.setBackground(Display.getDefault().getSystemColor(
if (servicesResult.hasConnectivity && pypiesResult.hasConnectivity) {
text.setBackground(Display.getDefault().getSystemColor(
SWT.COLOR_WHITE));
} else {
textPypies.setBackground(Display.getDefault().getSystemColor(
text.setBackground(Display.getDefault().getSystemColor(
SWT.COLOR_RED));
serverError = true;
}
@ -191,8 +181,7 @@ public class ThinClientServerPreferences extends FieldEditorPreferencePage {
private void updateEnabledFields() {
boolean useProxies = this.useProxies.getBooleanValue();
servicesServer.setEnabled(useProxies, connectivityButton.getParent());
pypiesServer.setEnabled(useProxies, connectivityButton.getParent());
proxyServer.setEnabled(useProxies, connectivityButton.getParent());
connectivityButton.setEnabled(useProxies);
}

View file

@ -19,12 +19,17 @@
**/
package com.raytheon.uf.viz.thinclient.cave.refresh;
import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.jface.preference.IPreferenceStore;
import com.raytheon.uf.viz.core.alerts.AlertMessage;
import com.raytheon.uf.viz.thinclient.Activator;
import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
import com.raytheon.uf.viz.thinclient.refresh.TimedRefresher.RefreshTimerTask;
import com.raytheon.viz.alerts.jobs.AutoUpdater;
import com.raytheon.viz.alerts.observers.ProductAlertObserver;
/**
* Timer task responsible for refreshing IEditorParts that implement
@ -38,6 +43,7 @@ import com.raytheon.viz.alerts.jobs.AutoUpdater;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 10, 2011 mschenke Initial creation
* Feb 21, 2014 DR 16744 D. Friedman Update all alert observers
*
* </pre>
*
@ -56,8 +62,17 @@ public class DataRefreshTask implements RefreshTimerTask {
public void run() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
if (store.getBoolean(ThinClientPreferenceConstants.P_DISABLE_JMS)) {
new AutoUpdater().alertArrived(ThinClientDataUpdateTree
.getInstance().updateAllData());
Collection<AlertMessage> alerts = ThinClientDataUpdateTree
.getInstance().updateAllData();
// Make sure it gets to GridUpdater
ArrayList<String> s = new ArrayList<String>(alerts.size());
for (AlertMessage am : alerts) {
s.add(am.dataURI);
}
ProductAlertObserver.processDataURIAlerts(s);
new AutoUpdater().alertArrived(alerts);
}
}

View file

@ -29,8 +29,10 @@ import java.util.Set;
import java.util.TimeZone;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -44,6 +46,8 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
import com.raytheon.uf.viz.core.rsc.updater.DataUpdateTree;
import com.raytheon.viz.grid.inv.RadarUpdater;
import com.raytheon.viz.grid.util.RadarAdapter;
/**
* TODO Add Description
@ -55,6 +59,7 @@ import com.raytheon.uf.viz.core.rsc.updater.DataUpdateTree;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 13, 2011 bsteffen Initial creation
* Feb 21, 2014 DR 16744 D. Friedman Add radar/grid updates
*
* </pre>
*
@ -63,7 +68,7 @@ import com.raytheon.uf.viz.core.rsc.updater.DataUpdateTree;
*/
public class ThinClientDataUpdateTree extends DataUpdateTree {
private IUFStatusHandler statusHandler = UFStatus
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(ThinClientDataUpdateTree.class);
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
@ -95,8 +100,9 @@ public class ThinClientDataUpdateTree extends DataUpdateTree {
for (DataPair pair : getDataPairs()) {
AbstractResourceData resourceData = pair.data.getResourceData();
if (!(resourceData instanceof AbstractRequestableResourceData)
|| resourceData.isFrozen())
|| resourceData.isFrozen()) {
continue;
}
Map<String, RequestConstraint> metadata = pair.metadata;
metadata = new HashMap<String, RequestConstraint>(metadata);
metadata.put("insertTime", new RequestConstraint(time,
@ -115,9 +121,70 @@ public class ThinClientDataUpdateTree extends DataUpdateTree {
e);
}
}
getRadarUpdates(time, messages);
getGridUpdates(time, messages);
return messages;
}
/**
* Get radar update messages. This is needed to update the
* radar-as-gridded-data inventory.
*/
private void getRadarUpdates(String time, Set<AlertMessage> messages) {
Set<AlertMessage> radarMessages = new HashSet<AlertMessage>();
Map<String, RequestConstraint> metadata = RadarAdapter.getInstance()
.getUpdateConstraints();
metadata = new HashMap<String, RequestConstraint>(metadata);
metadata.put("insertTime", new RequestConstraint(time,
ConstraintType.GREATER_THAN));
try {
PluginDataObject[] pdos = DataCubeContainer.getData(metadata);
for (PluginDataObject pdo : pdos) {
AlertMessage am = new AlertMessage();
am.dataURI = pdo.getDataURI();
am.decodedAlert = RecordFactory.getInstance().loadMapFromUri(
am.dataURI);
radarMessages.add(am);
}
messages.addAll(radarMessages);
for (String dataURI : RadarUpdater.getInstance()
.convertRadarAlertsToGridDatauris(radarMessages)) {
AlertMessage am = new AlertMessage();
am.dataURI = dataURI;
am.decodedAlert = RecordFactory.getInstance().loadMapFromUri(
am.dataURI);
messages.add(am);
}
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
/** Get gridded data update messages. */
private void getGridUpdates(String time, Set<AlertMessage> messages) {
Map<String, RequestConstraint> newQuery = new HashMap<String, RequestConstraint>();
DbQueryRequest dbRequest = new DbQueryRequest();
newQuery.put("pluginName", new RequestConstraint("grid"));
newQuery.put("insertTime", new RequestConstraint(time,
ConstraintType.GREATER_THAN));
dbRequest.setConstraints(newQuery);
dbRequest.addRequestField("dataURI");
DbQueryResponse response = null;
try {
response = (DbQueryResponse) ThriftClient.sendRequest(dbRequest);
for (String dataURI : response.getFieldObjects("dataURI",
String.class)) {
AlertMessage am = new AlertMessage();
am.dataURI = dataURI;
am.decodedAlert = RecordFactory.getInstance().loadMapFromUri(
am.dataURI);
messages.add(am);
}
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
/**
* Get the estimated difference between the clock on the server and the
* local clock. The offset returned from this method will always be slightly

View file

@ -0,0 +1,91 @@
/**
* 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.uf.viz.thinclient;
/**
* Utilities for manipulating thin client URIs
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 3, 2014 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
public class ThinClientUriUtil {
private static String services = "services";
private static String pypies = "pypies";
static {
services = System.getProperty("thinclient.proxy.services", services);
pypies = System.getProperty("thinclient.proxy.pypies", pypies);
}
private ThinClientUriUtil() {
}
/**
* Returns the address to connect to EDEX services when going through the
* thin client proxy
*
* @param proxyAddress
* the address of the proxy server
* @return
*/
public static String getServicesAddress(String proxyAddress) {
return appendTrailingSlash(proxyAddress) + services;
}
/**
* Returns the address to connect to PyPIES when going through the thin
* client proxy
*
* @param proxyAddress
* the address of the proxy server
* @return
*/
public static String getPypiesAddress(String proxyAddress) {
return appendTrailingSlash(proxyAddress) + pypies;
}
/**
* Appends a trailing slash to an address if the address does not have one
*
* @param proxyAddress
* @return
*/
private static String appendTrailingSlash(String proxyAddress) {
if (!proxyAddress.endsWith("/")) {
proxyAddress += "/";
}
return proxyAddress;
}
}

View file

@ -25,15 +25,15 @@ import org.apache.commons.collections.map.DefaultedMap;
import org.eclipse.jface.preference.IPreferenceStore;
import com.raytheon.uf.common.comm.HttpClient;
import com.raytheon.uf.common.localization.msgs.GetServersRequest;
import com.raytheon.uf.common.localization.msgs.GetServersResponse;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.VizServers;
import com.raytheon.uf.viz.core.comm.ConnectivityManager;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.localization.LocalizationInitializer;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.uf.viz.thinclient.Activator;
import com.raytheon.uf.viz.thinclient.ThinClientUriUtil;
import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
import com.raytheon.uf.viz.thinclient.ui.ThinClientConnectivityDialog;
@ -51,8 +51,9 @@ import com.raytheon.uf.viz.thinclient.ui.ThinClientConnectivityDialog;
* Dec 06, 2012 1396 njensen Added setting VizServers
* Jan 14, 2013 1469 bkowal Removed setting the hdf5 data directory
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
* Aug 27, 2013 2295 bkowal The entire jms connection string is
* Aug 27, 2013 2295 bkowal The entire jms connection string is
* now provided by EDEX.
* Feb 04, 2014 2704 njensen Single proxy address/preference
*
* </pre>
*
@ -87,20 +88,25 @@ public class ThinClientLocalizationInitializer extends LocalizationInitializer {
.getBoolean(ThinClientPreferenceConstants.P_DISABLE_JMS);
if (store.getBoolean(ThinClientPreferenceConstants.P_USE_PROXIES)) {
String servicesProxy = store
.getString(ThinClientPreferenceConstants.P_SERVICES_PROXY);
LocalizationManager.getInstance().setCurrentServer(servicesProxy);
String proxyAddr = store
.getString(ThinClientPreferenceConstants.P_PROXY_ADDRESS);
String servicesProxy = ThinClientUriUtil
.getServicesAddress(proxyAddr);
LocalizationManager.getInstance().setCurrentServer(servicesProxy,
false);
VizApp.setHttpServer(servicesProxy);
if (!disableJMS) {
GetServersRequest req = new GetServersRequest();
GetServersResponse resp = (GetServersResponse) ThriftClient
.sendLocalizationRequest(req);
GetServersResponse resp = ConnectivityManager
.checkLocalizationServer(servicesProxy, false);
if (!disableJMS) {
VizApp.setJmsConnectionString(resp.getJmsConnectionString());
}
}
VizApp.setHttpServer(servicesProxy);
VizApp.setPypiesServer(store
.getString(ThinClientPreferenceConstants.P_PYPIES_PROXY));
String pypiesProxy = ThinClientUriUtil
.getPypiesAddress(proxyAddr);
VizApp.setPypiesServer(pypiesProxy);
boolean compressRequests = store
.getBoolean(ThinClientPreferenceConstants.P_ENABLE_REQUEST_COMPRESSION);
HttpClient.getInstance().setCompressRequests(compressRequests);

View file

@ -30,6 +30,7 @@ package com.raytheon.uf.viz.thinclient.preferences;
* ------------ ---------- ----------- --------------------------
* Oct 20, 2011 mschenke Initial creation
* Jan 14, 2013 1469 bkowal The hdf5 data directory is no longer a preference constant.
* Feb 04, 2014 2704 njensen Single proxy preference constant
*
* </pre>
*
@ -47,10 +48,6 @@ public class ThinClientPreferenceConstants {
public static String P_USE_PROXIES = "useHttpProxy";
public static String P_SERVICES_PROXY = "servicesProxyAddress";
public static String P_PYPIES_PROXY = "pypiesProxyAddress";
public static String P_MENU_TIME_UPDATE_INTERVALS = "menuTimeUpdateInterval";
public static String P_DATA_UPDATE_INTERVALS = "dataUpdateInterval";
@ -70,4 +67,6 @@ public class ThinClientPreferenceConstants {
public static String P_ENABLE_REQUEST_COMPRESSION = "enableRequestCompression";
public static String P_PREFERENCE_PLACEHOLDER = "placeholderPreference";
public static String P_PROXY_ADDRESS = "proxyAddress";
}

View file

@ -27,25 +27,30 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.localization.msgs.GetServersResponse;
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.comm.ConnectivityManager;
import com.raytheon.uf.viz.core.comm.ConnectivityManager.ConnectivityResult;
import com.raytheon.uf.viz.core.comm.IConnectivityCallback;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.localization.ConnectivityPreferenceDialog;
import com.raytheon.uf.viz.core.localization.LocalizationConstants;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.thinclient.Activator;
import com.raytheon.uf.viz.thinclient.ThinClientUriUtil;
import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
/**
* TODO Add Description
* Connectivity dialog for launching thinclient or thinalertviz. Contains extra
* options not available when connecting with a normal CAVE.
*
* <pre>
*
@ -55,6 +60,11 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
* ------------ ---------- ----------- --------------------------
* Nov 23, 2011 bsteffen Initial creation
* Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking.
* Feb 04, 2014 2704 njensen Refactored
* Feb 17, 2014 2704 njensen Added checks for alertviz connectivity
* Feb 20, 2014 2704 njensen Fix issues where settings are valid
* but dialog doesn't realize it
*
*
* </pre>
*
@ -71,8 +81,11 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
@Override
public void connectionChecked(ConnectivityResult results) {
servicesGood = results.hasConnectivity;
appendDetails(buildDetails(results));
if (!results.hasConnectivity && status == null) {
status = buildErrorMessage(results);
}
}
}
private class PypiesCallback implements IConnectivityCallback {
@ -80,26 +93,30 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
@Override
public void connectionChecked(ConnectivityResult results) {
pypiesGood = results.hasConnectivity;
appendDetails(buildDetails(results));
if (!results.hasConnectivity && status == null) {
status = buildErrorMessage(results);
}
}
}
private class JmsCallback implements IConnectivityCallback {
@Override
public void connectionChecked(ConnectivityResult results) {
jmsGood = results.hasConnectivity;
appendDetails(buildDetails(results));
if (!results.hasConnectivity && status == null) {
status = buildErrorMessage(results);
}
}
}
private Label servicesLabel;
private Text servicesText;
private String services = "";
private boolean servicesGood = false;
private IConnectivityCallback servicesCallback = new ServicesCallback();
private Label pypiesLabel;
private Text pypiesText;
private String pypies = "";
private boolean pypiesGood = false;
private IConnectivityCallback pypiesCallback = new PypiesCallback();
@ -108,15 +125,29 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
private boolean useProxy = false;
private Button disableJmsCheck;
private boolean disableJms = false;
private boolean jmsGood = false;
private Label jmsErrorLabel;
private IConnectivityCallback jmsCallback = new JmsCallback();
private Text proxyText;
private String proxyAddress;
public ThinClientConnectivityDialog(boolean checkAlertViz) {
super(checkAlertViz);
super(checkAlertViz, "Thin Client Connectivity Preferences");
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
useProxy = store
.getBoolean(ThinClientPreferenceConstants.P_USE_PROXIES);
services = store
.getString(ThinClientPreferenceConstants.P_SERVICES_PROXY);
pypies = store.getString(ThinClientPreferenceConstants.P_PYPIES_PROXY);
disableJms = store
.getBoolean(ThinClientPreferenceConstants.P_DISABLE_JMS);
proxyAddress = store
.getString(ThinClientPreferenceConstants.P_PROXY_ADDRESS);
}
@Override
@ -124,66 +155,75 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
super.createTextBoxes(textBoxComp);
Label label = new Label(textBoxComp, SWT.RIGHT);
label.setText("Use Proxy Servers:");
GridData gd = new GridData(SWT.RIGHT, SWT.None, true, true);
label.setText("Disable JMS:");
GridData gd = new GridData(SWT.RIGHT, SWT.CENTER, true, true);
gd.widthHint = 150;
label.setLayoutData(gd);
useProxyCheck = new Button(textBoxComp, SWT.CHECK | SWT.LEFT);
Composite jmsComp = new Composite(textBoxComp, SWT.NONE);
GridLayout gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
jmsComp.setLayout(gl);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
jmsComp.setLayoutData(gd);
disableJmsCheck = new Button(jmsComp, SWT.CHECK | SWT.LEFT);
disableJmsCheck.setSelection(disableJms);
disableJmsCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
disableJms = disableJmsCheck.getSelection();
validate();
}
});
jmsErrorLabel = new Label(jmsComp, SWT.LEFT);
jmsErrorLabel.setText("Error connecting to JMS");
jmsErrorLabel.setForeground(display.getSystemColor(SWT.COLOR_RED));
jmsErrorLabel.setVisible(false);
label = new Label(textBoxComp, SWT.RIGHT);
label.setText("Use Proxy Server:");
gd = new GridData(SWT.RIGHT, SWT.CENTER, true, true);
gd.widthHint = 150;
label.setLayoutData(gd);
Composite proxyComp = new Composite(textBoxComp, SWT.NONE);
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
proxyComp.setLayout(gl);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
proxyComp.setLayoutData(gd);
useProxyCheck = new Button(proxyComp, SWT.CHECK | SWT.LEFT);
useProxyCheck.setSelection(useProxy);
useProxyCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateProxyEnabled();
}
});
servicesLabel = new Label(textBoxComp, SWT.RIGHT);
servicesLabel.setText("Services Proxy Address:");
gd = new GridData(SWT.RIGHT, SWT.None, true, true);
gd.widthHint = 150;
servicesLabel.setLayoutData(gd);
proxyText = new Text(proxyComp, SWT.NONE | SWT.BORDER);
gd = new GridData(SWT.FILL, SWT.None, true, true);
proxyText.setLayoutData(gd);
proxyText.setText(proxyAddress == null ? "" : proxyAddress);
proxyText.setBackground(getTextColor(servicesGood && pypiesGood));
servicesText = new Text(textBoxComp, SWT.NONE);
gd = new GridData(SWT.RIGHT, SWT.None, true, true);
gd.widthHint = 300;
servicesText.setLayoutData(gd);
servicesText.setText(services);
if (!servicesGood) {
servicesText.setBackground(textBoxComp.getDisplay().getSystemColor(
SWT.COLOR_RED));
}
pypiesLabel = new Label(textBoxComp, SWT.RIGHT);
pypiesLabel.setText("Pypies Proxy Address:");
gd = new GridData(SWT.RIGHT, SWT.None, true, true);
gd.widthHint = 150;
pypiesLabel.setLayoutData(gd);
pypiesText = new Text(textBoxComp, SWT.NONE);
gd = new GridData(SWT.RIGHT, SWT.None, true, true);
gd.widthHint = 300;
pypiesText.setLayoutData(gd);
pypiesText.setText(pypies);
if (!pypiesGood) {
pypiesText.setBackground(textBoxComp.getDisplay().getSystemColor(
SWT.COLOR_RED));
}
updateProxyEnabled();
}
@Override
protected void applySettings() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
store.setValue(ThinClientPreferenceConstants.P_USE_PROXIES, useProxy);
store.setValue(ThinClientPreferenceConstants.P_DISABLE_JMS, disableJms);
if (useProxy) {
store.setValue(ThinClientPreferenceConstants.P_SERVICES_PROXY,
services);
store.setValue(ThinClientPreferenceConstants.P_PYPIES_PROXY, pypies);
// Set the site and alertViz server for super.
LocalizationManager.getInstance().setCurrentSite(getSite());
store.setValue(ThinClientPreferenceConstants.P_USE_PROXIES,
useProxy);
store.setValue(ThinClientPreferenceConstants.P_PROXY_ADDRESS,
proxyAddress);
if (getAlertVizServer() != null) {
LocalizationManager
.getInstance()
@ -191,11 +231,11 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
.setValue(LocalizationConstants.P_ALERT_SERVER,
getAlertVizServer());
}
// setting the site will save the preference store
LocalizationManager.getInstance().setCurrentSite(getSite());
try {
((IPersistentPreferenceStore) store).save();
((IPersistentPreferenceStore) LocalizationManager.getInstance()
.getLocalizationStore()).save();
} catch (IOException e) {
statusHandler.handle(Priority.SIGNIFICANT,
"Unable to persist localization preference store", e);
@ -208,51 +248,125 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
@Override
public boolean validate() {
boolean superValid = super.validate();
if (!useProxy) {
return superValid;
boolean superResult = super.validate();
validateJms(superResult);
return superResult && jmsGood;
}
if (servicesText != null && !servicesText.isDisposed()
&& servicesText.isEnabled()) {
String services = servicesText.getText().trim();
if (!servicesGood || !this.services.equals(services)) {
this.services = services;
validateServices();
servicesText.setBackground(getTextColor(servicesGood));
}
} else {
status = null;
details = null;
// validate proxy
if (proxyText != null && !proxyText.isDisposed()
&& proxyText.isEnabled()) {
proxyAddress = proxyText.getText();
}
if (proxyAddress != null && proxyAddress.length() > 0) {
validateServices();
}
if (pypiesText != null && !pypiesText.isDisposed()
&& pypiesText.isEnabled()) {
String pypies = pypiesText.getText().trim();
if (!pypiesGood || !this.pypies.equals(pypies)) {
this.pypies = pypies;
validatePypies();
pypiesText.setBackground(getTextColor(pypiesGood));
}
} else {
validatePypies();
} else {
status = "Please enter a thin client proxy server address";
}
return servicesGood && pypiesGood && isSiteGood() && isAlertVizGood();
if (proxyText != null && !proxyText.isDisposed()) {
proxyText.setBackground(getTextColor(servicesGood && pypiesGood));
}
validateJms(servicesGood);
// validate site
if (siteText != null && !siteText.isDisposed()) {
super.setSite(siteText.getText());
}
super.validateSite();
if (siteText != null && !siteText.isDisposed()) {
siteText.setBackground(getTextColor(isSiteGood()));
}
// validate alertviz
// apparently alertvizserver == null means it's alertviz itself
if (alertVizServer != null) {
if (alertVizText != null && !alertVizText.isDisposed()) {
setAlertVizServer(alertVizText.getText());
}
super.validateAlertviz();
if (alertVizText != null && !alertVizText.isDisposed()) {
alertVizText.setBackground(getTextColor(isAlertVizGood()));
}
}
boolean everythingGood = servicesGood && pypiesGood && isSiteGood()
&& isAlertVizGood() && jmsGood;
updateStatus(everythingGood, status, details);
return everythingGood;
}
private void validateServices() {
ConnectivityManager.checkLocalizationServer(services, servicesCallback);
ConnectivityManager.checkLocalizationServer(
ThinClientUriUtil.getServicesAddress(proxyAddress),
servicesCallback);
}
private void validatePypies() {
ConnectivityManager.checkHttpServer(pypies, pypiesCallback);
ConnectivityManager.checkHttpServer(
ThinClientUriUtil.getPypiesAddress(proxyAddress),
pypiesCallback);
}
private void updateProxyEnabled() {
useProxy = useProxyCheck.getSelection();
servicesLabel.setEnabled(useProxy);
servicesText.setEnabled(useProxy);
pypiesLabel.setEnabled(useProxy);
pypiesText.setEnabled(useProxy);
setLocalizationEnabled(!useProxy);
proxyText.setEnabled(useProxy);
super.setLocalizationEnabled(!useProxy);
if (useProxy) {
if (localizationText != null && !localizationText.isDisposed()) {
localizationText.setBackground(getTextColor(true));
}
} else {
if (proxyText != null && !proxyText.isDisposed()) {
proxyText.setBackground(getTextColor(true));
}
}
validate();
}
/**
* Validates that a connection to JMS works.
*
* @param hasEdexConnection
* if we've successfully connected to edex
*/
private void validateJms(boolean hasEdexConnection) {
// only check Jms if it's enabled and we can connect to the services
if (!disableJms) {
if (hasEdexConnection) {
try {
String server = useProxy ? ThinClientUriUtil
.getServicesAddress(proxyAddress)
: getLocalization();
GetServersResponse response = ConnectivityManager
.checkLocalizationServer(server, false);
ConnectivityManager.checkJmsServer(
response.getJmsConnectionString(), jmsCallback);
} catch (VizException e) {
if (status == null) {
status = "Error connecting to JMS";
}
appendDetails(buildDetails(new ConnectivityResult(false,
null, e)));
jmsGood = false;
}
} else {
// JMS can't be good if we're not connected to edex cause
// then we don't even know where to connect to
jmsGood = false;
}
}
jmsGood = (jmsGood || disableJms);
if (jmsErrorLabel != null && !jmsErrorLabel.isDisposed()) {
jmsErrorLabel.setVisible(!jmsGood);
}
}
}

View file

@ -6,8 +6,13 @@ const int RED_BAND = 0;
const int GREEN_BAND = 1;
const int BLUE_BAND = 2;
uniform DataTexture rawData;
uniform DataMapping dataMapping;
uniform sampler2D rawDataTex;
uniform DataTextureInfo rawData;
uniform sampler1D dataMappingDataValues;
uniform sampler1D dataMappingColorValues;
uniform int dataMappingValues;
uniform ColorMapping colorMapping;
uniform sampler2D trueColorTexture;
@ -49,7 +54,7 @@ vec4 applyColorBand(int colorband) {
vec2((xy.x / width), (xy.y / height)));
// Lookup raw data value
float dataValue = textureToDataValue(rawData, gl_TexCoord[0].st);
float dataValue = textureToDataValue(rawDataTex, rawData, gl_TexCoord[0].st);
float r = curVal.r;
float g = curVal.g;
@ -58,7 +63,7 @@ vec4 applyColorBand(int colorband) {
if (dataValue != rawData.noDataValue && dataValue == dataValue) {
// Convert dataValue to cmapValue
float cmapValue = dataToColorMapValue(dataValue, dataMapping);
float cmapValue = dataToColorMapValue(dataValue, dataMappingDataValues, dataMappingColorValues, dataMappingValues);
float index = getColorMappingIndex(cmapValue, colorMapping);
int currentMask = toBitMask(a);
@ -86,4 +91,4 @@ void main(void) {
} else {
gl_FragColor = applyColorBand(band);
}
}
}

View file

@ -73,7 +73,8 @@ import com.raytheon.viz.aviation.resource.ResourceConfigMgr.ResourceTag;
* text height and width.
* 12/9/2010 7380 rferrel Adjust text size to be more like AWIPS I.
* 1/17/2011 7782 rferrel Added qcSkipCheck to mimic A1.
* 3/18/2011 7888 rferrel Added getLargeTF method.
* 3/18/2011 7888 rferrel Added getLargeTF method.
* 02/19/2014 16980 zhao added getter and setter for the Alt flag
*
* </pre>
*
@ -1368,4 +1369,12 @@ public class EditorTafTabComp extends Composite {
rtdRdo.setEnabled(editable);
corRdo.setEnabled(editable);
}
public boolean getAlt() {
return alt;
}
public void setAlt(boolean b) {
alt = b;
}
}

View file

@ -80,8 +80,10 @@ import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.MessageBox;
@ -229,6 +231,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* 10/24/2013 16478 zhao add syntax check for extra '=' sign
* 01/13/2014 16153 zhao Modified qcCheck().
* 01/15/2014 16458 zhao Check for extra '=' sign before 'regular syntax check'
* 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
*
* </pre>
*
@ -676,6 +680,10 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
populateTafViewer();
// Update the metar and mos guidance in the viewer tab.
updateViewerTab(stationName);
// Mark the tabs as not current so they get updated.
markTabsAsNotCurrent();
break;
case OPEN_RTN:
@ -771,7 +779,19 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
}
}
@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() {
if (shell == null) {
return;
@ -1075,6 +1095,11 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
// Create the File menu item with a File "dropdown" menu
Menu fileMenu = new Menu(menuBar);
fileMenuItem.setMenu(fileMenu);
fileMenu.addListener(SWT.Show, new Listener() {
public void handleEvent(Event event) {
setAltFlagForEditorTafTabComp();
}
});
// -------------------------------------------------
// Create all the items in the File dropdown menu
@ -1181,6 +1206,11 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
// Create the Options menu item with a Options "dropdown" menu
Menu optionsMenu = new Menu(menuBar);
optionsMenuItem.setMenu(optionsMenu);
optionsMenu.addListener(SWT.Show, new Listener() {
public void handleEvent(Event event) {
setAltFlagForEditorTafTabComp();
}
});
// ----------------------------------------------------
// Create all the items in the Options dropdown menu
@ -1255,7 +1285,12 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
// Create the File menu item with a File "dropdown" menu
Menu editMenu = new Menu(menuBar);
editMenuItem.setMenu(editMenu);
editMenu.addListener(SWT.Show, new Listener() {
public void handleEvent(Event event) {
setAltFlagForEditorTafTabComp();
}
});
// -------------------------------------------------
// Create all the items in the Edit dropdown menu
// -------------------------------------------------
@ -1329,6 +1364,19 @@ 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)
*/
private void setAltFlagForEditorTafTabComp() {
if ( editorTafTabComp.getAlt() ) {
editorTafTabComp.setAlt(false);
}
}
/**
* Create the Help menu.
@ -1346,6 +1394,11 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
// Create the File menu item with a File "dropdown" menu
Menu helpMenu = new Menu(menuBar);
helpMenuItem.setMenu(helpMenu);
helpMenu.addListener(SWT.Show, new Listener() {
public void handleEvent(Event event) {
setAltFlagForEditorTafTabComp();
}
});
// -------------------------------------------------
// Create all the items in the Help dropdown menu

View file

@ -45,12 +45,14 @@ import com.raytheon.uf.viz.core.exception.VizException;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 4, 2009 njensen Initial creation
* Jul 6, 2010 5792 rferrel getLatestTafs now returns tafs
* sorted by issue date newest at
* the start of the array.
* 08AUG2012 15613 zhao Modified safeFormatTaf()
* Sep 4, 2009 njensen Initial creation
* Jul 6, 2010 5792 rferrel getLatestTafs now returns tafs
* sorted by issue date newest at
* the start of the array.
* 08AUG2012 15613 zhao Modified safeFormatTaf()
* Sep 11, 2013 2277 mschenke Got rid of ScriptCreator references
* Feb 24, 2014 2830 njensen Sort dataTimes in getLatestTafs()
* so it works correctly
*
* </pre>
*
@ -97,6 +99,11 @@ public class TafUtil {
TafRecord.PLUGIN_NAME));
map.put("stationId", new RequestConstraint(siteID));
/*
* even if only requesting one, cannot pass in true because that
* will return a DataTime with only refTime set and tafs need to
* have fcstTime, validPeriod, etc set
*/
DataTime[] dt = DataCubeContainer.performTimeQuery(map, false);
if (dt.length == 0) {
return null;
@ -105,6 +112,7 @@ public class TafUtil {
if (size > dt.length) {
size = dt.length;
}
Arrays.sort(dt);
DataTime[] requestedTimes = new DataTime[size];
int k = 0;
for (int i = dt.length - 1; i > -1; i--) {

View file

@ -45,7 +45,6 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 28, 2007 Eric Babin Initial Creation
* 2013-12-20 ss#114 D. Friedman Change 2 of 3
*
* </pre>
*

View file

@ -52,7 +52,6 @@ import com.raytheon.viz.ui.VizWorkbenchManager;
* operate independently of each other;
* the dialogs will have unique titles.
* 15Mar2013 15693 mgamazaychikov Added magnification capability.
* 2013-12-20 ss#114 D. Friedman Change 3 of 3
*
* </pre>
*

View file

@ -278,7 +278,7 @@ public class VectorGraphicsRenderable {
lineShape.addLineSegment(new double[][] { { ix2, jy2 },
{ ix3, jy3 } });
if (config.isBarbFillFiftyTriangle()) {
double[] triangleRaw = { ix1, jy1, ix2, jy2, ix3, jy3 };
double[] triangleRaw = { ix1, jy1, ix2, jy2, ix3, jy3, ix1, jy1 };
CoordinateSequence triangleSeq = new PackedCoordinateSequence.Double(
triangleRaw, 2);
LineString triangleLS = new GeometryFactory()

View file

@ -3,7 +3,10 @@
#include <mapping>
#include <coloring>
uniform sampler1D colorMappingColorMap;
uniform sampler1D colorMappingAlphaMask;
uniform ColorMapping colorMapping;
uniform ColorModifiers modifiers;
uniform float bkgrndRed;
@ -11,22 +14,20 @@ uniform float bkgrndGreen;
uniform float bkgrndBlue;
void main(void){
sampler1D colorMap = colorMapping.colorMap;
float logFactor = colorMapping.logFactor;
int applyMask = colorMapping.applyMask;
sampler1D alphaMask = colorMapping.alphaMask;
// Lookup color in colorMap for index
float index = gl_TexCoord[0].s;
if ( logFactor > 0.0 ) {
index = getLogFactorIndex(index, logFactor);
}
vec4 color = texture1D(colorMap, index).rgba;
vec4 color = texture1D(colorMappingColorMap, index).rgba;
// Apply alpha mask if set
float alpha = color.a;
if ( applyMask == 1 ) {
if ( texture1D(alphaMask , index ).r != 0.0 ) {
if ( texture1D(colorMappingAlphaMask , index ).r != 0.0 ) {
color = vec4(bkgrndRed, bkgrndGreen, bkgrndBlue, alpha);
}
}

View file

@ -1,13 +1,21 @@
#include <mapping>
#include <coloring>
uniform DataTexture rawData;
uniform DataMapping dataMapping;
uniform sampler2D rawDataTex;
uniform DataTextureInfo rawData;
uniform sampler1D dataMappingDataValues;
uniform sampler1D dataMappingColorValues;
uniform int dataMappingValues;
uniform sampler1D colorMappingColorMap;
uniform sampler1D colorMappingAlphaMask;
uniform ColorMapping colorMapping;
uniform ColorModifiers modifiers;
void main(void) {
float dataValue = textureToDataValue(rawData, gl_TexCoord[0].st);
float dataValue = textureToDataValue(rawDataTex, rawData, gl_TexCoord[0].st);
// No data check/special NaN check
if (dataValue == rawData.noDataValue || dataValue != dataValue) {
@ -16,9 +24,9 @@ void main(void) {
}
// Convert dataValue to cmapValue
float cmapValue = dataToColorMapValue(dataValue, dataMapping);
float cmapValue = dataToColorMapValue(dataValue, dataMappingDataValues, dataMappingColorValues, dataMappingValues);
// Get color for colormapping, given value
vec4 textureColor = getColorByValue(cmapValue, colorMapping);
vec4 textureColor = getColorByValue(cmapValue, colorMapping, colorMappingColorMap, colorMappingAlphaMask);
// Apply the color modifiers into gl_FragColor
gl_FragColor = applyColorModifiers(textureColor, modifiers);
}

View file

@ -8,8 +8,7 @@
* implied data will range 0-1 and need scaling to get raw value
* where scaleMin maps to 0 and scaleMax maps to 1.
*/
struct DataTexture {
sampler2D rawTex;
struct DataTextureInfo {
float noDataValue;
int isScaled;
float scaleMin;
@ -18,23 +17,9 @@ struct DataTexture {
float height;
};
/**
* Fields used for converting from image data values to
* colormapping data values. Done to avoid conversions in
* application code. dmv[i] -> cmv[i]. Linear interpolation
* is done where non-exact matches are found. Mappings should
* be uploaded as floats so no scaling is needed
*/
struct DataMapping {
sampler1D dataMappingValues;
sampler1D colorMappingValues;
int numMappingValues;
};
struct ColorMapping {
/** Fields for color map and size. colorMap contains colors to
* use for mapping. cmapMin/Max is range colormap is applied over */
sampler1D colorMap;
float cmapMin;
float cmapMax;
@ -42,7 +27,6 @@ struct ColorMapping {
* same size as colorMap and contains 0s and 1s, 1 indicating alpha
* should be set to completely transparent */
int applyMask;
sampler1D alphaMask;
/** Fields for logarithmic and mirrored indexing into the colorMap */
int isMirrored;
@ -51,28 +35,28 @@ struct ColorMapping {
};
/**
* Returns the data value for the DataTexture at location.
* Returns the data value for the DataTextureInfo at location.
*/
float textureToDataValue(DataTexture texture, vec2 location) {
vec4 textureValue = texture2D(texture.rawTex, location);
float textureToDataValue(sampler2D texture, DataTextureInfo info, vec2 location) {
vec4 textureValue = texture2D(texture, location);
float dataValue = textureValue.r;
if (texture.isScaled == 1) {
if (info.isScaled == 1) {
// Convert to non-scaled value
dataValue = ((dataValue * (texture.scaleMax - texture.scaleMin))
+ texture.scaleMin);
dataValue = ((dataValue * (info.scaleMax - info.scaleMin))
+ info.scaleMin);
}
return dataValue;
}
/**
* Returns the data value for the DataTexture at location.
* Returns the data value for the DataTextureInfo at location.
*/
float dataToTextureValue(DataTexture texture, float dataValue) {
float dataToTextureValue(DataTextureInfo info, float dataValue) {
float textureValue = dataValue;
if (texture.isScaled == 1) {
textureValue = (dataValue - texture.scaleMin)
/ (texture.scaleMax - texture.scaleMin);
if (info.isScaled == 1) {
textureValue = (dataValue - info.scaleMin)
/ (info.scaleMax - info.scaleMin);
}
return textureValue;
}
@ -86,10 +70,9 @@ float lookupMappingValue(sampler1D mappingTex, int index,
}
/**
* Converts a data value into a colorMap value given the DataMapping
* Converts a data value into a colorMap value given the data mapping info
*/
float dataToColorMapValue(float dataValue, DataMapping mapping) {
int numMappingValues = mapping.numMappingValues;
float dataToColorMapValue(float dataValue, sampler1D dataMappingDataValues, sampler1D dataMappingColorValues, int numMappingValues) {
if (numMappingValues == 0) {
// Short circuit if no mapping is needed
return dataValue;
@ -99,9 +82,9 @@ float dataToColorMapValue(float dataValue, DataMapping mapping) {
int lowIndex = 0;
int highIndex = numMappingValues - 1;
float lowValue = lookupMappingValue(mapping.dataMappingValues, lowIndex,
float lowValue = lookupMappingValue(dataMappingDataValues, lowIndex,
numMappingValues);
float highValue = lookupMappingValue(mapping.dataMappingValues, highIndex,
float highValue = lookupMappingValue(dataMappingDataValues, highIndex,
numMappingValues);
int reversed = 0;
if (lowValue > highValue) {
@ -117,7 +100,7 @@ float dataToColorMapValue(float dataValue, DataMapping mapping) {
int nextIndex = lowIndex + ((highIndex - lowIndex) / 2);
if (nextIndex > lowIndex && nextIndex < highIndex) {
// Look up next value and determine if it is a high or low
float nextValue = lookupMappingValue(mapping.dataMappingValues,
float nextValue = lookupMappingValue(dataMappingDataValues,
nextIndex, numMappingValues);
if (nextValue < dataValue) {
if (reversed == 0) {
@ -146,9 +129,9 @@ float dataToColorMapValue(float dataValue, DataMapping mapping) {
factor = 1.0 - factor;
}
float lowCmapValue = lookupMappingValue(mapping.colorMappingValues,
float lowCmapValue = lookupMappingValue(dataMappingColorValues,
lowIndex, numMappingValues);
float highCmapValue = lookupMappingValue(mapping.colorMappingValues,
float highCmapValue = lookupMappingValue(dataMappingColorValues,
highIndex, numMappingValues);
return lowCmapValue + (highCmapValue - lowCmapValue) * factor;
@ -180,16 +163,16 @@ float getLinearIndex(float cmapValue, float cmapMin, float cmapMax) {
*/
float valueToLogIndex(float value, float rangeMin, float rangeMax) {
// Account for 0 min index
if (rangeMin == 0) {
if (rangeMin == 0.0) {
rangeMin = 0.0000001;
if (rangeMax < 0) {
if (rangeMax < 0.0) {
rangeMin = -rangeMin;
}
}
int reverse = 0;
if ((value < rangeMin && rangeMin > 0)
|| (value > rangeMin && rangeMin < 0)) {
if ((value < rangeMin && rangeMin > 0.0)
|| (value > rangeMin && rangeMin < 0.0)) {
reverse = 1;
}
@ -200,10 +183,10 @@ float valueToLogIndex(float value, float rangeMin, float rangeMax) {
// Check uncomputable index value, everything between this range is 0,
// rangeMin->rangeMax 0 -> 1, -rangeMin->-rangeMax 0 -> -1
if (value <= rangeMin && value >= -rangeMin) {
return 0;
return 0.0;
}
double index = (log(value) - log(rangeMin))
float index = (log(value) - log(rangeMin))
/ (log(rangeMax) - log(rangeMin));
if (reverse != 0) {
index = -index;
@ -232,12 +215,12 @@ float getLogIndex(float cmapValue, float cmapMin, float cmapMax, int mirror) {
float index = 0.0;
// Flag if min/max values are on opposite sides of zero
int minMaxOpposite = 0;
if ((cmapMin < 0 && cmapMax > 0) || (cmapMin > 0 && cmapMax < 0)) {
if ((cmapMin < 0.0 && cmapMax > 0.0) || (cmapMin > 0.0 && cmapMax < 0.0)) {
minMaxOpposite = 1;
}
if (mirror != 0 || minMaxOpposite != 0) {
if (cmapMax < 0) {
if (cmapMax < 0.0) {
// Invert colormapping if negative range was given
cmapValue = -cmapValue;
}
@ -261,9 +244,9 @@ float getLogIndex(float cmapValue, float cmapMin, float cmapMax, int mirror) {
float logPosCmapMax = absLogZeroVal + log(posCmapMax);
// Calculate index which zeroVal is at based on neg max and pos max
float zeroValIndex = logNegCmapMax / (logNegCmapMax + logPosCmapMax);
if (cmapValue > 0) {
if (cmapValue > 0.0) {
index = valueToLogIndex(rangeValue, zeroVal, posCmapMax);
index = zeroValIndex + (1 - zeroValIndex) * index;
index = zeroValIndex + (1.0 - zeroValIndex) * index;
} else {
index = valueToLogIndex(rangeValue, zeroVal, negCmapMax);
index = zeroValIndex - zeroValIndex * index;
@ -277,8 +260,8 @@ float getLogIndex(float cmapValue, float cmapMin, float cmapMax, int mirror) {
if (inverted == 1) {
index = 1.0 - index;
}
if (cmapMin > 0 && cmapValue < rangeMin
|| (cmapMin < 0 && cmapValue > -rangeMin)) {
if (cmapMin > 0.0 && cmapValue < rangeMin
|| (cmapMin < 0.0 && cmapValue > -rangeMin)) {
index = -index;
}
}
@ -333,13 +316,13 @@ float getColorMappingIndex(float cmapValue, ColorMapping colorMapping) {
/**
* Returns a color for the index based on the ColorMapping
*/
vec4 getColorByIndex(float index, ColorMapping colorMapping) {
vec4 getColorByIndex(float index, sampler1D colorMap, sampler1D alphaMask, int applyMask) {
// Lookup color in colorMap for index
vec4 textureColor = texture1D(colorMapping.colorMap, index).rgba;
vec4 textureColor = texture1D(colorMap, index).rgba;
// Apply alpha mask
if (colorMapping.applyMask == 1) {
if (texture1D(colorMapping.alphaMask, index).r != 0.0) {
if (applyMask == 1) {
if (texture1D(alphaMask, index).r != 0.0) {
textureColor = vec4(textureColor.rgb, 0.0);
}
}
@ -349,7 +332,7 @@ vec4 getColorByIndex(float index, ColorMapping colorMapping) {
/**
* Returns a color for the cmapValue based on the ColorMapping
*/
vec4 getColorByValue(float cmapValue, ColorMapping colorMapping) {
return getColorByIndex(getColorMappingIndex(cmapValue, colorMapping),
colorMapping);
vec4 getColorByValue(float cmapValue, ColorMapping colorMapping, sampler1D colorMap, sampler1D alphaMask) {
float index = getColorMappingIndex(cmapValue, colorMapping);
return getColorByIndex(index, colorMap, alphaMask, colorMapping.applyMask);
}

View file

@ -3,21 +3,27 @@
#include <mapping>
uniform DataTexture imageData;
uniform DataMapping imageToMosaic;
uniform DataTexture mosaicData;
uniform sampler2D imageDataTex;
uniform DataTextureInfo imageData;
uniform sampler1D imageToMosaicDataValues;
uniform sampler1D imageToMosaicColorValues;
uniform int imageToMosaicValues;
uniform sampler2D mosaicDataTex;
uniform DataTextureInfo mosaicData;
void main(void) {
float imageValue = textureToDataValue(imageData, gl_TexCoord[0].st);
float imageValue = textureToDataValue(imageDataTex, imageData, gl_TexCoord[0].st);
vec2 frag_xy = gl_FragCoord.xy;
float mosaicValue = textureToDataValue(mosaicData,
float mosaicValue = textureToDataValue(mosaicDataTex, mosaicData,
vec2(frag_xy.x / mosaicData.width, frag_xy.y / mosaicData.height));
float newValue = mosaicValue;
// No data check/special NaN check
if (imageValue != imageData.noDataValue && imageValue == imageValue) {
// Convert image value to mosaic value
imageValue = dataToColorMapValue(imageValue, imageToMosaic);
imageValue = dataToColorMapValue(imageValue, imageToMosaicDataValues, imageToMosaicColorValues, imageToMosaicValues);
if (imageValue > mosaicValue) {
newValue = imageValue;
}

View file

@ -3,14 +3,20 @@
#include <mapping>
uniform DataTexture imageData;
uniform DataMapping imageToMosaic;
uniform DataTexture mosaicData;
uniform sampler2D imageDataTex;
uniform DataTextureInfo imageData;
uniform sampler1D imageToMosaicDataValues;
uniform sampler1D imageToMosaicColorValues;
uniform int imageToMosaicValues;
uniform sampler2D mosaicDataTex;
uniform DataTextureInfo mosaicData;
void main(void) {
float imageValue = textureToDataValue(imageData, gl_TexCoord[0].st);
float imageValue = textureToDataValue(imageDataTex, imageData, gl_TexCoord[0].st);
vec2 frag_xy = gl_FragCoord.xy;
float mosaicValue = textureToDataValue(mosaicData,
float mosaicValue = textureToDataValue(mosaicDataTex, mosaicData,
vec2(frag_xy.x / mosaicData.width, frag_xy.y / mosaicData.height));
float newValue;
@ -19,7 +25,7 @@ void main(void) {
// Use existing value
newValue = mosaicValue;
} else {
newValue = dataToColorMapValue(imageValue, imageToMosaic);
newValue = dataToColorMapValue(imageValue, imageToMosaicDataValues, imageToMosaicColorValues, imageToMosaicValues);
}
gl_FragColor = vec4(dataToTextureValue(mosaicData, newValue), 0.0, 0.0,
1.0);

View file

@ -110,8 +110,7 @@ public class GLStats {
lowMem |= getSystemStats(output);
lowMem |= getImageCacheStats(output);
lowMem |= getNvidiaStats(gl, output);
// The ATI version is untested, only enable if it has been tested.
// lowMem |= getAtiStats(gl, output);
lowMem |= getAtiStats(gl, output);
if (lowMem) {
lastPrintTime = curTime;

View file

@ -19,9 +19,6 @@
**/
package com.raytheon.viz.core.gl.ext.imaging;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.HashSet;
import java.util.Set;
@ -41,6 +38,9 @@ import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.gl.AbstractGLMesh;
import com.raytheon.viz.core.gl.GLCapabilities;
import com.raytheon.viz.core.gl.GLGeometryObject2D;
import com.raytheon.viz.core.gl.GLGeometryObject2D.GLGeometryObjectData;
import com.raytheon.viz.core.gl.GLGeometryPainter;
import com.raytheon.viz.core.gl.IGLTarget;
import com.raytheon.viz.core.gl.glsl.GLSLFactory;
import com.raytheon.viz.core.gl.glsl.GLShaderProgram;
@ -57,7 +57,10 @@ import com.vividsolutions.jts.geom.Coordinate;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 15, 2011 mschenke Initial creation
* Dec 15, 2011 mschenke Initial creation
* Jan 9, 2014 2680 mschenke Switched simple PixelCoverage mesh
* rendering to use VBOs instead of
* deprecated immediate mode rendering
*
* </pre>
*
@ -206,6 +209,11 @@ public abstract class AbstractGLImagingExtension extends
continue;
}
}
// Needed to fix ATI driver bug, after each image render, flush the
// GL pipeline to avoid random images being drawn improperly. May be
// fixed with driver update or cleaning up how image coverages are
// rendered (getting rid of glEnableClientState as it is deprecated)
gl.glFlush();
}
if (lastTextureType != -1) {
@ -258,46 +266,36 @@ public abstract class AbstractGLImagingExtension extends
return ((AbstractGLMesh) mesh).paint(target, paintProps);
}
} else if (coords != null) {
FloatBuffer fb = ByteBuffer.allocateDirect(4 * 5 * 4)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
Coordinate ul = pc.getUl();
Coordinate ur = pc.getUr();
Coordinate lr = pc.getLr();
Coordinate ll = pc.getLl();
fb.put(new float[] { coords.left() + corrFactor,
coords.bottom() + corrFactor });
fb.put(new float[] { (float) ll.x, (float) ll.y, (float) ll.z });
int geometryType = GL.GL_TRIANGLE_STRIP;
GLGeometryObject2D vertexData = new GLGeometryObject2D(
new GLGeometryObjectData(geometryType, GL.GL_VERTEX_ARRAY));
vertexData.allocate(4);
vertexData.addSegment(new double[][] { { ll.x, ll.y },
{ lr.x, lr.y }, { ul.x, ul.y }, { ur.x, ur.y } });
vertexData.compile(gl);
fb.put(new float[] { coords.right() - corrFactor,
coords.bottom() + corrFactor });
fb.put(new float[] { (float) lr.x, (float) lr.y, (float) lr.z });
GLGeometryObject2D textureData = new GLGeometryObject2D(
new GLGeometryObjectData(geometryType,
GL.GL_TEXTURE_COORD_ARRAY));
textureData.allocate(4);
textureData.addSegment(new double[][] {
{ coords.left(), coords.bottom() },
{ coords.right(), coords.bottom() },
{ coords.left(), coords.top() },
{ coords.right(), coords.top() } });
textureData.compile(gl);
fb.put(new float[] { coords.left() + corrFactor,
coords.top() - corrFactor });
fb.put(new float[] { (float) ul.x, (float) ul.y, (float) ul.z });
GLGeometryPainter.paintGeometries(gl, vertexData, textureData);
fb.put(new float[] { coords.right() - corrFactor,
coords.top() - corrFactor });
fb.put(new float[] { (float) ur.x, (float) ur.y, (float) ur.z });
vertexData.dispose();
textureData.dispose();
// Clear error bit
gl.glGetError();
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
gl.glInterleavedArrays(GL.GL_T2F_V3F, 0, fb.rewind());
int error = gl.glGetError();
if (error == GL.GL_NO_ERROR) {
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
} else {
target.handleError(error);
}
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
return PaintStatus.PAINTED;
}
return PaintStatus.ERROR;

View file

@ -56,7 +56,9 @@ public class GLSLStructFactory {
int texBinding, AbstractGLColormappedImage image) {
ColorMapParameters parameters = image.getColorMapParameters();
AbstractGLColorMapDataFormat dataFormat = image.getDataFormat();
setFieldUniform(program, name, "rawTex", texBinding);
// Set the texture outside the struct
setFieldUniform(program, name + "Tex", texBinding);
// Set struct fields
setFieldUniform(program, name, "noDataValue",
parameters.getNoDataValue());
setFieldUniform(program, name, "isScaled", dataFormat.isScaled());
@ -82,11 +84,9 @@ public class GLSLStructFactory {
public static void createDataMapping(GLShaderProgram program, String name,
int dataMappingTexBinding, int colorMappingTexBinding,
int numMappingValues) {
setFieldUniform(program, name, "dataMappingValues",
dataMappingTexBinding);
setFieldUniform(program, name, "colorMappingValues",
colorMappingTexBinding);
setFieldUniform(program, name, "numMappingValues", numMappingValues);
setFieldUniform(program, name + "DataValues", dataMappingTexBinding);
setFieldUniform(program, name + "ColorValues", colorMappingTexBinding);
setFieldUniform(program, name + "Values", numMappingValues);
}
/**
@ -101,12 +101,12 @@ public class GLSLStructFactory {
public static void createColorMapping(GLShaderProgram program, String name,
int colorMapTexBinding, int alphaMaskTexBinding,
ColorMapParameters parameters) {
setFieldUniform(program, name, "colorMap", colorMapTexBinding);
setFieldUniform(program, name + "ColorMap", colorMapTexBinding);
setFieldUniform(program, name, "cmapMin", parameters.getColorMapMin());
setFieldUniform(program, name, "cmapMax", parameters.getColorMapMax());
setFieldUniform(program, name, "applyMask", parameters.isUseMask());
setFieldUniform(program, name, "alphaMask", alphaMaskTexBinding);
setFieldUniform(program, name + "AlphaMask", alphaMaskTexBinding);
setFieldUniform(program, name, "isMirrored", parameters.isMirror());
setFieldUniform(program, name, "isLogarithmic",
@ -132,6 +132,13 @@ public class GLSLStructFactory {
private static void setFieldUniform(GLShaderProgram program,
String structName, String fieldName, Object fieldValue) {
program.setUniform(structName + FIELD_SEPERATOR + fieldName, fieldValue);
setFieldUniform(program, structName + FIELD_SEPERATOR + fieldName,
fieldValue);
}
private static void setFieldUniform(GLShaderProgram program,
String fieldName, Object fieldValue) {
program.setUniform(fieldName, fieldValue);
}
}

View file

@ -280,7 +280,7 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
gl = GLU.getCurrentGL();
theWidth = width;
theHeight = width;
theHeight = height;
float magnificationVal = Activator.getDefault().getPreferenceStore()
.getFloat(PreferenceConstants.P_FONT_MAGNIFICATION);
@ -324,7 +324,7 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
gl = GLU.getCurrentGL();
theWidth = width;
theHeight = width;
theHeight = height;
float magnificationVal = Activator.getDefault().getPreferenceStore()
.getFloat(PreferenceConstants.P_FONT_MAGNIFICATION);
@ -1706,8 +1706,9 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
endAzm += 360.0;
}
double totalAzimuth = (endAzm - startAzm);
boolean includeSides = circle.includeSides && !fill
&& ((endAzm - startAzm) < 360.0);
&& (totalAzimuth < 360.0);
if (fill) {
gl.glBegin(GL.GL_TRIANGLE_FAN);
@ -1720,8 +1721,16 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
}
}
double step = (endAzm - startAzm) / (circle.numberOfPoints);
for (double azm = startAzm; azm <= endAzm; azm += step) {
// Get the number of unique points in the circle
int points = circle.numberOfPoints;
if (totalAzimuth >= 360) {
// If angle is meant to be complete circle, add extra point
// to ensure circle is touching
points += 1;
}
double step = totalAzimuth / (points - 1);
for (int i = 0; i < points; ++i) {
double azm = startAzm + (i * step);
double[] pointOnCircle = getPointOnCircle(x, y, z, radius,
azm);
gl.glVertex3d(pointOnCircle[0], pointOnCircle[1],
@ -1784,8 +1793,12 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
message = "GL table too large?";
break;
}
case GL.GL_INVALID_FRAMEBUFFER_OPERATION_EXT: {
message = "Invalid FrameBuffer operation";
break;
}
default: {
message = "GL Error" + errorid;
message = "GL Error: " + errorid;
}
}

View file

@ -35,6 +35,9 @@ import com.raytheon.viz.core.gl.GLDisposalManager.GLDisposer;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 13, 2007 chammack Initial Creation.
* Jan 9, 2013 2680 mschenke Changed size calculation to longs to
* avoid int overflow when using cache
* size > 1GB
*
* </pre>
*
@ -90,14 +93,15 @@ public class ImageCache extends LRUCache<Object, IImageCacheable> implements
public static ImageCache getInstance(CacheType type) {
if (type == CacheType.MEMORY) {
if (memoryCache == null) {
memoryCache = new ImageCache(1024 * 1024 * MEMORY_CACHE_SIZE);
memoryCache = new ImageCache(1024L * 1024L * MEMORY_CACHE_SIZE);
}
return memoryCache;
}
if (type == CacheType.TEXTURE) {
if (textureCache == null) {
textureCache = new ImageCache(1024 * 1024 * TEXTURE_CACHE_SIZE);
textureCache = new ImageCache(
1024L * 1024L * TEXTURE_CACHE_SIZE);
}
return textureCache;
}

View file

@ -32,7 +32,8 @@ import javax.media.opengl.GL;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 17, 2012 bsteffen Initial creation
* Feb 17, 2012 bsteffen Initial creation
* Jan 9, 2014 2680 mschenke Added default error message handling
*
* </pre>
*
@ -113,8 +114,11 @@ public class GLFrameBufferObject extends GLIdWrapper {
errorMessage = "Error: Framebuffer not supported by hardware/drivers";
break;
}
default: {
errorMessage = "Framebuffer is not complete, unknown reason";
break;
}
}
return errorMessage;
}
}

View file

@ -36,6 +36,8 @@ import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
import com.raytheon.uf.common.colormap.prefs.ColorMapParameters.PersistedParameters;
import com.raytheon.uf.common.datastorage.DataStoreFactory;
import com.raytheon.uf.common.datastorage.IDataStore;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.style.LabelingPreferences;
import com.raytheon.uf.common.style.ParamLevelMatchCriteria;
@ -91,6 +93,8 @@ public class TopoResource extends
protected TileSetRenderable topoTileSet;
private double noDataValue;
protected TopoResource(TopoResourceData topoData,
LoadProperties loadProperties, File dataFile) throws VizException {
super(topoData, loadProperties);
@ -189,12 +193,13 @@ public class TopoResource extends
}
SamplePreferences samplePrefs = prefs.getSamplePrefs();
if (samplePrefs != null && samplePrefs.getFormatString() != null) {
if ((samplePrefs != null)
&& (samplePrefs.getFormatString() != null)) {
params.setFormatString(samplePrefs.getFormatString());
}
LabelingPreferences labelPrefs = prefs.getColorbarLabeling();
if (labelPrefs != null && labelPrefs.getValues() != null) {
if ((labelPrefs != null) && (labelPrefs.getValues() != null)) {
params.setColorBarIntervals(labelPrefs.getValues());
}
}
@ -213,6 +218,16 @@ public class TopoResource extends
getCapability(ColorMapCapability.class).setColorMapParameters(params);
IDataStore dataStore = DataStoreFactory.getDataStore(this.dataFile);
try {
IDataRecord rec = dataStore.retrieve("/", "full",
Request.buildPointRequest(new java.awt.Point(0, 0)));
noDataValue = rec.getFillValue().doubleValue();
} catch (Exception e) {
statusHandler.error(e.getLocalizedMessage(), e);
noDataValue = Double.NaN;
}
topoTileSet = new TileSetRenderable(
getCapability(ImagingCapability.class), getTopoGeometry(),
getTopoTileImageCreator(), getNumberOfTopoLevels(), 512);
@ -284,7 +299,7 @@ public class TopoResource extends
double height;
try {
// height = TopoQuery.getInstance().getHeight(coord.asLatLon());
height = topoTileSet.interrogate(coord.asLatLon());
height = topoTileSet.interrogate(coord.asLatLon(), noDataValue);
} catch (Exception e) {
throw new VizException("Error transforming", e);
}

View file

@ -1,5 +1,4 @@
#!/bin/bash
# CAVE startup script
# Note: CAVE will not run as 'root'
@ -25,8 +24,6 @@
# SOFTWARE HISTORY
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# Dec 04, 2013 #2589 dgilling Create command-line arg that controls
# xvfb initialization.
# Dec 05, 2013 #2593 rjpeter set IGNORE_NUM_CAVES
# Dec 05, 2013 #2590 dgilling Remove duplicated code and call to
# cave.sh.
@ -50,28 +47,12 @@ fi
PROGRAM_NAME="gfeclient"
# remove "-enablegl" flag from command-line if set so it doesn't confuse any
# commands we call later.
USER_ARGS=()
while [[ $1 ]]
do
if [ "$1" == "-enablegl" ]
then
ENABLEGL="true"
else
USER_ARGS+=("$1")
fi
shift
done
if [ -n "$ENABLEGL" ]
# if display not set
if [ -n "$DISPLAY" ]
then
# if display not set
if [ -n "$DISPLAY" ]
then
echo "Using Display set to $DISPLAY"
extendLibraryPath
else
else
echo "Display not set, creating offscreen x on port $$"
extendLibraryPath "-noX"
Xvfb :$$ -screen 0 1280x1024x24 &
@ -79,13 +60,12 @@ then
export DISPLAY="localhost:$$.0"
#don't use shader when no display set
SWITCHES="${SWITCHES} -no_shader"
fi
fi
export IGNORE_NUM_CAVES=1
source /awips2/cave/cave.sh -nosplash -noredirect -component gfeclient "${USER_ARGS[@]}" &
wait
source /awips2/cave/cave.sh -nosplash -noredirect -component gfeclient "$@" &
wait $!
if [ -n "$xvfb" ]
then

View file

@ -22,8 +22,7 @@
# SOFTWARE HISTORY
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# Dec 04, 2013 #2589 dgilling Create command-line arg that controls
# xvfb initialization.
# Feb 07, 2014 #2509 dgilling Fix baseline merge issue.
#
#
@ -37,8 +36,7 @@ CAVE_DIR=/awips2/cave
# execute the runProcedure module
_GFECLI="${RUN_FROM_DIR}/gfeclient.sh"
_GFECLI_ARGS="-enablegl"
_MODULE="${CAVE_DIR}/etc/gfe/utility/PngWriter.py"
_MODULE="${RUN_FROM_DIR}/src/ifpimage/PngWriter.py"
# quoting of '$@' is used to prevent command line interpretation
if [ ! -f $_GFECLI ] || [ ! -d $CAVE_DIR ]
@ -46,6 +44,6 @@ then
echo "CAVE and/or gfeclient not installed on this workstation ..exiting"
exit 1
else
$_GFECLI $_GFECLI_ARGS $_MODULE "$@"
$_GFECLI $_MODULE "$@"
fi

View file

@ -11,6 +11,7 @@
# Apr 03,2012 436 randerso Converted to Python procedure to allow some
# level of site customization
# Apr 09,2012 436 randerso Merged RNK's MakeHazards_Elevation procedure
# Feb 12,2014 17058 ryu Extend converter for Collections$EmptyList objects.
#
# Author: randerso
# ----------------------------------------------------------------------------
@ -307,6 +308,8 @@ def converter(obj):
objtype = obj.jclassname
if objtype == "java.util.Date":
retVal = AbsTime.AbsTime(obj)
elif objtype == "java.util.Collections$EmptyList":
retVal = []
elif objtype == "com.raytheon.uf.common.time.TimeRange":
retVal = TimeRange.TimeRange(obj)
return retVal

View file

@ -1,61 +1,70 @@
##
# 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
# 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
#
# 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.
##
# ----------------------------------------------------------------------------
# This software is in the public domain, furnished "as is", without technical
# support, and with no warranty, express or implied, as to its usefulness for
# any purpose.
#
# MergeHazards
#
# Author: lefebvre
#
# This procedure reads all of the temporary hazard grids and selectively
# loads them in the the "Hazards" grid.
# ----------------------------------------------------------------------------
# The MenuItems list defines the GFE menu item(s) under which the
# Procedure is to appear.
# Possible items are: Populate, Edit, Consistency, Verify, Hazards
MenuItems = ["Hazards"]
#import Tkinter
import SmartScript
import string
import HazardUtils
import VTECTable
import LogStream
import numpy
from HazardUtils import MODEL
from HazardUtils import ELEMENT
from HazardUtils import LEVEL
######################### CONFIGURATION SECTION ######################
#
# This dictionary defines which hazards cannot be combined with other
# Hazards. The structure lists each hazard in the VTECTable followed
# by a list of VTEC codes that may not be combined with it at the same
# grid point. For example "DS.W" : ["DU.Y"] means that DS.W may not
# be combined with a DU.Y hazard at the same grid point.
# ----------------------------------------------------------------------------
# This software is in the public domain, furnished "as is", without technical
# support, and with no warranty, express or implied, as to its usefulness for
# any purpose.
#
# MergeHazards
#
# Author: lefebvre
#
# This procedure reads all of the temporary hazard grids and selectively
# loads them in the the "Hazards" grid.
# ----------------------------------------------------------------------------
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# Dec 23, 2013 16893 ryu Check in njensen's change to removeTempHazards()
# to call SmartScript.unloadWEs().
#
########################################################################
# The MenuItems list defines the GFE menu item(s) under which the
# Procedure is to appear.
# Possible items are: Populate, Edit, Consistency, Verify, Hazards
MenuItems = ["Hazards"]
#import Tkinter
import SmartScript
import string
import HazardUtils
import VTECTable
import LogStream
import numpy
from HazardUtils import MODEL
from HazardUtils import ELEMENT
from HazardUtils import LEVEL
######################### CONFIGURATION SECTION ######################
#
# This dictionary defines which hazards cannot be combined with other
# Hazards. The structure lists each hazard in the VTECTable followed
# by a list of VTEC codes that may not be combined with it at the same
# grid point. For example "DS.W" : ["DU.Y"] means that DS.W may not
# be combined with a DU.Y hazard at the same grid point.
HazardsConflictDict = {
"AF.W" : ["AF.Y"],
"AF.Y" : ["AF.W"],
@ -187,302 +196,304 @@ HazardsConflictDict = {
"ZR.Y" : ["BZ.A", "LE.A", "WS.A", "BZ.W", "IS.W", "WS.W", "LE.W",
"WW.Y", "LE.Y"],
}
########################## END OF CONFIGURATION SECTION ########################
class Procedure(SmartScript.SmartScript):
def __init__(self, dbss):
SmartScript.SmartScript.__init__(self, dbss)
self._dbss = dbss
##
# Get the list of loaded temporary hazard parms
# @return: Temporary hazard parm names, i.e., ["hazAFY"]
# @rtype: List of Strings
def getHazardParmNames(self):
parms = self.loadedParms()
hazParms = []
for weName, level, dbID in parms:
if string.find(weName, "haz") == 0:
# TODO: Why is this back/forth xform needed?
key = self._hazUtils._tempWENameToKey(weName)
index = string.find(key, ":")
if index != -1:
mkey = key[0:index]
segNum = key[index+1:]
else:
mkey = key
segNum = ""
# append the hazard and a description
parmName = "haz" + key
parmName = string.replace(parmName, ".", "")
parmName = string.replace(parmName, ":", "")
hazParms.append(parmName)
return hazParms
##
# Unload (delete) all the temporary hazards
def removeTempHazards(self):
parms = self.loadedParms()
for weName, level, dbID in parms:
if string.find(weName, "haz") == 0:
self.unloadWE(MODEL, weName, level)
return
##
# The action performed when the user opts to cancel a merge.
# This was a callback under Tcl/tk; now displayDialog invokes
# it directly.
def cancelCommand(self):
LogStream.logEvent("MergeHazards: cancel")
return
##
# The action performed when the user opts to continue a merge.
# This was a callback under Tcl/tk; now displayDialog invokes
# it directly.
def continueCommand(self):
LogStream.logEvent("MergeHazards: continue")
parm = self.getParm(MODEL, ELEMENT, LEVEL)
parm.setMutable(True)
self.mergeHazardGrids()
return
##
# Displays a dialog box and queries the user to continue to merge or
# abort the merge
########################## END OF CONFIGURATION SECTION ########################
class Procedure(SmartScript.SmartScript):
def __init__(self, dbss):
SmartScript.SmartScript.__init__(self, dbss)
self._dbss = dbss
##
# Get the list of loaded temporary hazard parms
# @return: Temporary hazard parm names, i.e., ["hazAFY"]
# @rtype: List of Strings
def getHazardParmNames(self):
parms = self.loadedParms()
hazParms = []
for weName, level, dbID in parms:
if string.find(weName, "haz") == 0:
# TODO: Why is this back/forth xform needed?
key = self._hazUtils._tempWENameToKey(weName)
index = string.find(key, ":")
if index != -1:
mkey = key[0:index]
segNum = key[index+1:]
else:
mkey = key
segNum = ""
# append the hazard and a description
parmName = "haz" + key
parmName = string.replace(parmName, ".", "")
parmName = string.replace(parmName, ":", "")
hazParms.append(parmName)
return hazParms
##
# Unload (delete) all the temporary hazards
def removeTempHazards(self):
parms = self.loadedParms()
toRemovePairs = []
for weName, level, dbID in parms:
if string.find(weName, "haz") == 0:
toRemovePairs.append((weName, level))
self.unloadWEs(MODEL, toRemovePairs)
return
##
# The action performed when the user opts to cancel a merge.
# This was a callback under Tcl/tk; now displayDialog invokes
# it directly.
def cancelCommand(self):
LogStream.logEvent("MergeHazards: cancel")
return
##
# The action performed when the user opts to continue a merge.
# This was a callback under Tcl/tk; now displayDialog invokes
# it directly.
def continueCommand(self):
LogStream.logEvent("MergeHazards: continue")
parm = self.getParm(MODEL, ELEMENT, LEVEL)
parm.setMutable(True)
self.mergeHazardGrids()
return
##
# Displays a dialog box and queries the user to continue to merge or
# abort the merge
def displayDialog(self, message):
from MessageBox import MessageBox
messageBox = MessageBox(style=MessageBox.ICON_WARNING)
messageBox.setText("MakeHazard")
messageBox.setMessage(message)
messageBox.setButtonLabels(["Continue Merge", "Cancel Merge"])
messageBox.setDefaultIndex(1)
if (messageBox.open() == 0):
self.continueCommand()
else:
self.cancelCommand()
return
##
# Returns the set of hazParms grids that overlap with the specified
# timeRange.
# @param hazParms: Hazard parm names to check
# @type hazParms: Sequence of string
# @param timeRange: The time range to check for overlap with
# @type timeRange: Python TimeRange
# @return: Byte grids and keys of the overlapping parms
# @rtype: 2-tuple: list of byte arrays, list of list of strings
def getOverlappingHazGrids(self, hazParms, timeRange):
byteGridList = []
keyList = []
for hazParm in hazParms:
trList = self._hazUtils._getWEInventory(hazParm)
for tr in trList:
if tr.overlaps(timeRange):
byteGrid, hazKey = self.getGrids(MODEL, hazParm, LEVEL,
tr, mode="First")
if isinstance(hazKey, str):
hazKey = eval(hazKey)
byteGridList.append(byteGrid)
keyList.append(hazKey)
return byteGridList, keyList
##
# Returns the first non-None key it finds in the keyList
# @param keyList: Keys to search
# @type keyList: Sequence of string
# @return: First key that is not "<None>"
# @rtype: string
def getHazardKey(self, keyList):
for k in keyList:
if k != "<None>":
return k
##
# Checks the specified hazard grids to see if they are conflicting
# Each grid is a tuple (byteGrid, key). Uses the configurable
# HazardConflictDict to determine whether two hazards can be combined
# at the same grid point. Returns an empty list if no conflict or
# the list of hazards if they do.
#
# This method should really only be used internally; it assumes that
# there is at most one key other than "<None>", and that it contains
# a single subkey.
#
# @param hazGrid1: The first hazard grid
# @type hazGrid1: 2-tuple: numpy array of int8, list of String
# @param hazGrid2: The second hazard grid
# @type hazGrid2: 2-tuple: numpy array of int8, list of String
# @return: conflicting hazard names or empty list
# @rtype: list
def conflictingHazards(self, hazGrid1, hazGrid2):
byteGrid1, hazKey1 = hazGrid1
byteGrid2, hazKey2 = hazGrid2
key1 = self.getHazardKey(hazKey1)
key2 = self.getHazardKey(hazKey2)
phenSig1 = key1[0:4] # remove the etn
phenSig2 = key2[0:4]
keyConflict = False
if phenSig1 == phenSig2 and key1 != key2:
keyConflict = True
elif HazardsConflictDict.has_key(phenSig1):
if phenSig2 in HazardsConflictDict[phenSig1]:
keyConflict = True
if keyConflict:
# calculate the overlap, adding the grids together will tell us if
# there is any overlap. Any grid points > 1 are overlapped
totalGrid = byteGrid1 + byteGrid2
overlapMask = numpy.greater(totalGrid, 1)
if numpy.any(overlapMask):
return [key1, key2]
return []
##
# See if there are any temporary hazards for the same position and time
# that conflict with one another.
#
# @param hazParms: Temporary hazard parm names to check.
# @type hazParms: sequence of string
# @return: The first conflict, or None if there are no conflicts
# @rtype: 2-tuple(TimeRange, list of string) or NoneType
def checkForHazardConflicts(self, hazParms):
timeList = []
for hazParm in hazParms:
trList = self._hazUtils._getWEInventory(hazParm)
for tr in trList:
if tr.startTime().unixTime() not in timeList:
timeList.append(tr.startTime().unixTime())
if tr.endTime().unixTime() not in timeList:
timeList.append(tr.endTime().unixTime())
timeList.sort() # sort the list
for t in xrange(len(timeList) - 1):
start = timeList[t]
end = timeList[t+1]
timeRange = self._hazUtils._makeTimeRange(start, end)
byteGridList = []
keyList = []
byteGridList, keyList = self.getOverlappingHazGrids(hazParms, timeRange)
# compare each grid to all other grids at this timeRange
for firstIndex in xrange(len(byteGridList) - 1):
for secondIndex in xrange(firstIndex + 1, len(byteGridList)):
grid1 = (byteGridList[firstIndex], keyList[firstIndex])
grid2 = (byteGridList[secondIndex], keyList[secondIndex])
conflictList = self.conflictingHazards(grid1, grid2)
if conflictList != []:
return (timeRange, conflictList)
# if we made it to here, all is well
return None
##
# Perform checks to see if it's OK to merge hazards. If there are no conflicting
# locks or incompatible hazards, do the merge. If there are conflicting locks,
# generate a status bar message and quit. If there incompatible
# hazards, show a warning and let the user decide whether to continue.
def checkForMerge(self):
# get the hazards selected by the forecaster
hazParms = self.getHazardParmNames()
# check for empty list of hazards
if hazParms == []:
self.statusBarMsg("No temporary grids to merge.", "S")
return
# FIXME: Lock race condition
# check for conflicting locks
if self._hazUtils._conflictingLocks(hazParms):
self.statusBarMsg("There are conflicting locks. " +
"Please resolve these before merging any hazards", "S")
return
conflicts = self.checkForHazardConflicts(hazParms)
if conflicts is None:
# if no conflicts, merge the grids
# We made the hazards parm immutable when we separated hazard grids.
# It has to be made mutable to do the merge.
parm = self.getParm(MODEL, ELEMENT, LEVEL)
parm.setMutable(True)
self.mergeHazardGrids()
else:
haz1 = string.replace(conflicts[1][0], ".", "")
haz2 = string.replace(conflicts[1][1], ".", "")
timeRange = str(conflicts[0])
msg = "Hazard conflict detected!\n\n"
msg += "Time: " + timeRange + " \n\n"
msg += "with Hazard grids haz" + haz1 + " and haz" + haz2 + ".\n"
LogStream.logEvent("Merge conflict: "+ msg)
self.displayDialog(msg)
return
##
# Performs the actual merge of the temp hazards grids into the "Hazards" grid.
def mergeHazardGrids(self):
# get the hazards selected by the forecaster
hazParms = self.getHazardParmNames()
self._hazUtils._removeAllHazardsGrids()
for hazParm in hazParms:
trList = self._hazUtils._getWEInventory(hazParm)
for tr in trList:
byteGrid, hazKey = self.getGrids(MODEL, hazParm, LEVEL, tr,
mode="First")
if isinstance(hazKey, str):
hazKey = eval(hazKey)
uniqueKeys = self._hazUtils._getUniqueKeys(byteGrid, hazKey)
for uKey in uniqueKeys:
if uKey == "<None>":
continue
subKeys = self._hazUtils._getSubKeys(uKey)
for subKey in subKeys:
# make the mask - find all areas that contain the subKey
mask = numpy.zeros(byteGrid.shape)
for haz in hazKey:
if string.find(haz, subKey) >= 0:
hazIndex = self.getIndex(haz, hazKey)
mask = numpy.logical_or(numpy.equal(byteGrid, hazIndex), mask)
# make the grid
self._hazUtils._addHazard(ELEMENT, tr, subKey, mask)
LogStream.logEvent("merge: " + \
str(self._hazUtils._printTime(tr.startTime().unixTime())) + " " + \
str(self._hazUtils._printTime(tr.endTime().unixTime())) + " " + \
subKey + "\n")
self.removeTempHazards()
return
##
# The main entry point of the procedure.
def execute(self):
self.setToolType("numeric")
self._hazUtils = HazardUtils.HazardUtils(self._dbss, None)
# see if the Hazards WE is loaded in the GFE, if not abort the tool
if not self._hazUtils._hazardsLoaded():
self.statusBarMsg("Hazards Weather Element must be loaded in " +\
"the GFE before running MergeHazards", "S")
self.cancel()
self.checkForMerge()
return
from MessageBox import MessageBox
messageBox = MessageBox(style=MessageBox.ICON_WARNING)
messageBox.setText("MakeHazard")
messageBox.setMessage(message)
messageBox.setButtonLabels(["Continue Merge", "Cancel Merge"])
messageBox.setDefaultIndex(1)
if (messageBox.open() == 0):
self.continueCommand()
else:
self.cancelCommand()
return
##
# Returns the set of hazParms grids that overlap with the specified
# timeRange.
# @param hazParms: Hazard parm names to check
# @type hazParms: Sequence of string
# @param timeRange: The time range to check for overlap with
# @type timeRange: Python TimeRange
# @return: Byte grids and keys of the overlapping parms
# @rtype: 2-tuple: list of byte arrays, list of list of strings
def getOverlappingHazGrids(self, hazParms, timeRange):
byteGridList = []
keyList = []
for hazParm in hazParms:
trList = self._hazUtils._getWEInventory(hazParm)
for tr in trList:
if tr.overlaps(timeRange):
byteGrid, hazKey = self.getGrids(MODEL, hazParm, LEVEL,
tr, mode="First")
if isinstance(hazKey, str):
hazKey = eval(hazKey)
byteGridList.append(byteGrid)
keyList.append(hazKey)
return byteGridList, keyList
##
# Returns the first non-None key it finds in the keyList
# @param keyList: Keys to search
# @type keyList: Sequence of string
# @return: First key that is not "<None>"
# @rtype: string
def getHazardKey(self, keyList):
for k in keyList:
if k != "<None>":
return k
##
# Checks the specified hazard grids to see if they are conflicting
# Each grid is a tuple (byteGrid, key). Uses the configurable
# HazardConflictDict to determine whether two hazards can be combined
# at the same grid point. Returns an empty list if no conflict or
# the list of hazards if they do.
#
# This method should really only be used internally; it assumes that
# there is at most one key other than "<None>", and that it contains
# a single subkey.
#
# @param hazGrid1: The first hazard grid
# @type hazGrid1: 2-tuple: numpy array of int8, list of String
# @param hazGrid2: The second hazard grid
# @type hazGrid2: 2-tuple: numpy array of int8, list of String
# @return: conflicting hazard names or empty list
# @rtype: list
def conflictingHazards(self, hazGrid1, hazGrid2):
byteGrid1, hazKey1 = hazGrid1
byteGrid2, hazKey2 = hazGrid2
key1 = self.getHazardKey(hazKey1)
key2 = self.getHazardKey(hazKey2)
phenSig1 = key1[0:4] # remove the etn
phenSig2 = key2[0:4]
keyConflict = False
if phenSig1 == phenSig2 and key1 != key2:
keyConflict = True
elif HazardsConflictDict.has_key(phenSig1):
if phenSig2 in HazardsConflictDict[phenSig1]:
keyConflict = True
if keyConflict:
# calculate the overlap, adding the grids together will tell us if
# there is any overlap. Any grid points > 1 are overlapped
totalGrid = byteGrid1 + byteGrid2
overlapMask = numpy.greater(totalGrid, 1)
if numpy.any(overlapMask):
return [key1, key2]
return []
##
# See if there are any temporary hazards for the same position and time
# that conflict with one another.
#
# @param hazParms: Temporary hazard parm names to check.
# @type hazParms: sequence of string
# @return: The first conflict, or None if there are no conflicts
# @rtype: 2-tuple(TimeRange, list of string) or NoneType
def checkForHazardConflicts(self, hazParms):
timeList = []
for hazParm in hazParms:
trList = self._hazUtils._getWEInventory(hazParm)
for tr in trList:
if tr.startTime().unixTime() not in timeList:
timeList.append(tr.startTime().unixTime())
if tr.endTime().unixTime() not in timeList:
timeList.append(tr.endTime().unixTime())
timeList.sort() # sort the list
for t in xrange(len(timeList) - 1):
start = timeList[t]
end = timeList[t+1]
timeRange = self._hazUtils._makeTimeRange(start, end)
byteGridList = []
keyList = []
byteGridList, keyList = self.getOverlappingHazGrids(hazParms, timeRange)
# compare each grid to all other grids at this timeRange
for firstIndex in xrange(len(byteGridList) - 1):
for secondIndex in xrange(firstIndex + 1, len(byteGridList)):
grid1 = (byteGridList[firstIndex], keyList[firstIndex])
grid2 = (byteGridList[secondIndex], keyList[secondIndex])
conflictList = self.conflictingHazards(grid1, grid2)
if conflictList != []:
return (timeRange, conflictList)
# if we made it to here, all is well
return None
##
# Perform checks to see if it's OK to merge hazards. If there are no conflicting
# locks or incompatible hazards, do the merge. If there are conflicting locks,
# generate a status bar message and quit. If there incompatible
# hazards, show a warning and let the user decide whether to continue.
def checkForMerge(self):
# get the hazards selected by the forecaster
hazParms = self.getHazardParmNames()
# check for empty list of hazards
if hazParms == []:
self.statusBarMsg("No temporary grids to merge.", "S")
return
# FIXME: Lock race condition
# check for conflicting locks
if self._hazUtils._conflictingLocks(hazParms):
self.statusBarMsg("There are conflicting locks. " +
"Please resolve these before merging any hazards", "S")
return
conflicts = self.checkForHazardConflicts(hazParms)
if conflicts is None:
# if no conflicts, merge the grids
# We made the hazards parm immutable when we separated hazard grids.
# It has to be made mutable to do the merge.
parm = self.getParm(MODEL, ELEMENT, LEVEL)
parm.setMutable(True)
self.mergeHazardGrids()
else:
haz1 = string.replace(conflicts[1][0], ".", "")
haz2 = string.replace(conflicts[1][1], ".", "")
timeRange = str(conflicts[0])
msg = "Hazard conflict detected!\n\n"
msg += "Time: " + timeRange + " \n\n"
msg += "with Hazard grids haz" + haz1 + " and haz" + haz2 + ".\n"
LogStream.logEvent("Merge conflict: "+ msg)
self.displayDialog(msg)
return
##
# Performs the actual merge of the temp hazards grids into the "Hazards" grid.
def mergeHazardGrids(self):
# get the hazards selected by the forecaster
hazParms = self.getHazardParmNames()
self._hazUtils._removeAllHazardsGrids()
for hazParm in hazParms:
trList = self._hazUtils._getWEInventory(hazParm)
for tr in trList:
byteGrid, hazKey = self.getGrids(MODEL, hazParm, LEVEL, tr,
mode="First")
if isinstance(hazKey, str):
hazKey = eval(hazKey)
uniqueKeys = self._hazUtils._getUniqueKeys(byteGrid, hazKey)
for uKey in uniqueKeys:
if uKey == "<None>":
continue
subKeys = self._hazUtils._getSubKeys(uKey)
for subKey in subKeys:
# make the mask - find all areas that contain the subKey
mask = numpy.zeros(byteGrid.shape)
for haz in hazKey:
if string.find(haz, subKey) >= 0:
hazIndex = self.getIndex(haz, hazKey)
mask = numpy.logical_or(numpy.equal(byteGrid, hazIndex), mask)
# make the grid
self._hazUtils._addHazard(ELEMENT, tr, subKey, mask)
LogStream.logEvent("merge: " + \
str(self._hazUtils._printTime(tr.startTime().unixTime())) + " " + \
str(self._hazUtils._printTime(tr.endTime().unixTime())) + " " + \
subKey + "\n")
self.removeTempHazards()
return
##
# The main entry point of the procedure.
def execute(self):
self.setToolType("numeric")
self._hazUtils = HazardUtils.HazardUtils(self._dbss, None)
# see if the Hazards WE is loaded in the GFE, if not abort the tool
if not self._hazUtils._hazardsLoaded():
self.statusBarMsg("Hazards Weather Element must be loaded in " +\
"the GFE before running MergeHazards", "S")
self.cancel()
self.checkForMerge()
return

View file

@ -1,19 +1,19 @@
##
# 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
# 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
#
#
# 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.
##
@ -27,16 +27,25 @@
#
# Author: hansen
# ----------------------------------------------------------------------------
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 02/12/2014 #2591 randerso Added retry when loading combinations fails
import string, getopt, sys, time, os, types, math
import ModuleAccessor
import Utility, logging, traceback
import AbsTime
from java.lang import ThreadDeath
from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceID, ReferenceData
GridLoc = None
LatLonIds = []
MAX_TRIES = 2
# If someone imports TextFormatter and needs this instance
# they should either be fixed to use the IFPImporter module
# or turn this line on (which is a kludge but should make
@ -44,19 +53,19 @@ LatLonIds = []
#IFPImporter = IFPImporter.IFPImporter
class TextFormatter:
def __init__(self, dataManager):
def __init__(self, dataManager):
# Variable for unique combinations
self.__comboNumber = -1
self.dataMgr = dataManager
self.log = logging.getLogger("FormatterRunner.TextFormatter.TextFormatter")
pass
# def __del__(self):
# for i in LatLonIds:
# self.dataMgr.getRefManager().deleteRefSet(i, False)
def getForecast(self, fcstName, argDict):
" Create the forecast "
" Create the forecast "
ForecastNarrative = argDict["ForecastNarrative"]
ForecastTable = argDict["ForecastTable"]
@ -71,7 +80,7 @@ class TextFormatter:
argDict["getForecast"] = self.getForecast
argDict["getFcstDef"] = self.getFcstDef
argDict["dataMgr"] = self.dataMgr
self.__ut = argDict["utility"]
self.__ut = argDict["utility"]
# Get the Forecast Definition and type from the server
#print "finding", fcstName
@ -79,11 +88,11 @@ class TextFormatter:
#print "found ", found
if found == 0:
text = "Text Product Definition Not Found: " + fcstName + " " + \
traceback.format_exc()
traceback.format_exc()
self.log.error("Text Product Definition Not Found: Caught Exception: " + fcstName, exc_info=True)
raise Exception, text
forecastDef = argDict["forecastDef"]
fcstType = self.__ut.set(forecastDef,"type",None)
fcstType = self.__ut.set(forecastDef, "type", None)
argDict["fcstType"] = fcstType
if fcstType is None:
text = "Text Product Type Not Found: " + fcstName + " " + \
@ -101,16 +110,16 @@ class TextFormatter:
# Must have at least one edit area and time range specified
if fcstType != "smart" and fcstType != "component":
if argDict["editAreas"] == []:
text= "No Edit Areas Specified over which to generate product."
text=text+'\nTry setting "defaultEditAreas" in the product Definition'
text=text+'\nOr, if running from the command line, add a -r flag.'
text = "No Edit Areas Specified over which to generate product."
text = text + '\nTry setting "defaultEditAreas" in the product Definition'
text = text + '\nOr, if running from the command line, add a -r flag.'
text = text + '\n' + string.join(traceback.format_exc())
self.log.error("Caught Exception: " + text)
raise Exception, text
if argDict["rawRanges"] == []:
text= "No Time Ranges Specified over which to generate product."
text=text+'\nTry setting "defaultRanges" in the product Definition'
text=text+'\nOr, if running from the command line, add a -w flag.'
text = "No Time Ranges Specified over which to generate product."
text = text + '\nTry setting "defaultRanges" in the product Definition'
text = text + '\nOr, if running from the command line, add a -w flag.'
text = text + '\n' + string.join(traceback.format_exc())
self.log.error("Caught Exception: " + text)
raise Exception, text
@ -153,7 +162,7 @@ class TextFormatter:
argDict["module"] = module
product.setUp("T", argDict)
product._argDict = argDict
try:
text = product.generateForecast(argDict)
except RuntimeError, e:
@ -166,11 +175,11 @@ class TextFormatter:
# requirement for TEST phrasing for TEST products
if argDict.get('testMode', 0):
testMsg = "\nTHIS IS A TEST MESSAGE. DO NOT TAKE ACTION" +\
testMsg = "\nTHIS IS A TEST MESSAGE. DO NOT TAKE ACTION" + \
" BASED ON THIS TEST\nMESSAGE.\n"
#split by "$$"
segs = text.split('\n$$')
for i in xrange(len(segs)-1): #never the last one
for i in xrange(len(segs) - 1): #never the last one
if text.find(testMsg) == -1: #not found, add it in
segs[i] = segs[i] + testMsg
text = '\n$$'.join(segs) #put text back together again
@ -185,7 +194,7 @@ class TextFormatter:
if not forecastDef.get('lowerCase', 0):
text = text.upper()
else:
text="Text Product Type Invalid "+\
text = "Text Product Type Invalid " + \
"(must be 'table', 'component' or 'narrative'): ", fcstName, type
text = text + '\n' + string.join(traceback.format_exc())
self.log.error("Caught Exception: " + text)
@ -196,18 +205,18 @@ class TextFormatter:
def __createNarrativeDef(self, fcstName, timeRange):
return {
"methodList": [self.assembleChildWords],
"narrativeDef": [(fcstName, timeRange.duration()/3600)],
"narrativeDef": [(fcstName, timeRange.duration() / 3600)],
}
def __loop(self, argDict, forecast, forecastDef):
# Loop through product by edit areas and time ranges
begText = self.__ut.set(forecastDef,"beginningText","")
endText = self.__ut.set(forecastDef,"endingText","")
editAreaLoopBegText = self.__ut.set(forecastDef,"editAreaLoopBegText","")
timeRangeLoopBegText = self.__ut.set(forecastDef,"timeRangeLoopBegText","")
editAreaLoopEndText = self.__ut.set(forecastDef,"editAreaLoopEndText","")
timeRangeLoopEndText = self.__ut.set(forecastDef,"timeRangeLoopEndText","")
begText = self.__ut.set(forecastDef, "beginningText", "")
endText = self.__ut.set(forecastDef, "endingText", "")
editAreaLoopBegText = self.__ut.set(forecastDef, "editAreaLoopBegText", "")
timeRangeLoopBegText = self.__ut.set(forecastDef, "timeRangeLoopBegText", "")
editAreaLoopEndText = self.__ut.set(forecastDef, "editAreaLoopEndText", "")
timeRangeLoopEndText = self.__ut.set(forecastDef, "timeRangeLoopEndText", "")
outerLoop = self.__ut.set(forecastDef, "outerLoop", "EditArea")
editAreas = argDict["editAreas"]
@ -274,10 +283,10 @@ class TextFormatter:
#print "varDict", varDict
for item, default in [
("language","english"),
("appendFile",None),
("lineLength",69), # no command line option
("timePeriod",3),
("language", "english"),
("appendFile", None),
("lineLength", 69), # no command line option
("timePeriod", 3),
]:
try: # Try the varDict
#print "trying varDict", item
@ -362,19 +371,28 @@ class TextFormatter:
# (["Zones37","Zones38"], "/37/38"),"/37/38"),
# (["Zones57","Zones58","Zones59"],"57/58/59")
# ]
# RWA-05/19/11: added this check here to force Combinations files
# to be reloaded since we removed a similar check from ModuleAccessor
# to preserve the magicCodeChanges. Perhaps we should be doing something
# similar to magicCodeChanges for Combinations files as well.
if sys.modules.has_key(dfEditAreas):
del sys.modules[dfEditAreas]
accessor = ModuleAccessor.ModuleAccessor()
dfEditAreas = accessor.variable(dfEditAreas, "Combinations")
if dfEditAreas is None:
return "COMBINATION FILE NOT FOUND: " + \
self.__ut.set(forecastDef, "defaultEditAreas", [])
comboName = dfEditAreas
for retryCount in xrange(MAX_TRIES):
accessor = ModuleAccessor.ModuleAccessor()
dfEditAreas = accessor.variable(comboName, "Combinations")
if dfEditAreas is None:
if sys.modules.has_key(comboName):
comboMod = sys.modules[comboName]
if comboMod.__file__.endswith(".pyo"):
os.remove(comboMod.__file__)
comboMod = None
del sys.modules[comboName]
# if not last try, log and try again
if retryCount < MAX_TRIES - 1:
# log but don't pop up
self.log.error("Error loading combinations file: %s, retrying", comboName)
else:
return "COMBINATION FILE NOT FOUND: " + \
self.__ut.set(forecastDef, "defaultEditAreas", [])
else:
break
elif len(dfEditAreas) > 0:
refDataList = []
@ -411,7 +429,7 @@ class TextFormatter:
filterMethod = product.filterMethod
except:
allowedHazards = None
if allowedHazards is not None and allowedHazards != []:
# Set up editAreas as a list of combinations
# Cases:
@ -440,7 +458,7 @@ class TextFormatter:
"AreaDictionary")
editAreas = self._separateByTimeZone(editAreas,
areaDictName, argDict['creationTime'],
effectiveTZ = separateByTZ)
effectiveTZ=separateByTZ)
accurateCities = product.Definition.get('accurateCities', 0)
cityRefData = []
@ -464,7 +482,7 @@ class TextFormatter:
"contain entry for edit area: "
self.log.error(msg + `ean`)
continue
for city, llrec in citydict[ean].iteritems():
# Create a referenceData given lat, lon, dim
area = (llrec[0], llrec[1], 0)
@ -490,8 +508,8 @@ class TextFormatter:
filterMethod, argDict["databaseID"], stationID4,
argDict["vtecActiveTable"], argDict["vtecMode"],
sampleThreshold, creationTime=argDict["creationTime"], dataMgr=self.dataMgr,
accurateCities=accurateCities,
cityEditAreas=cityRefData)
accurateCities=accurateCities,
cityEditAreas=cityRefData)
# Store hazards object for later use
argDict["hazards"] = hazards
@ -540,7 +558,7 @@ class TextFormatter:
except:
trName = ""
if tr is not None:
rawRanges.append((tr,trName))
rawRanges.append((tr, trName))
elif len(dfRanges) == 0:
pass
else:
@ -548,13 +566,13 @@ class TextFormatter:
forecast = TimeRangeUtils.TimeRangeUtils()
for rangeName in dfRanges:
rawRange = forecast.getTimeRange(rangeName, argDict)
rawRanges.append((rawRange,rangeName))
rawRanges.append((rawRange, rangeName))
argDict["rawRanges"] = rawRanges
#print "rawRanges", rawRanges
# Row Label
areaType = self.__ut.set(forecastDef,"areaType","")
rowVariable = self.__ut.set(forecastDef,"rowVariable","EditArea")
areaType = self.__ut.set(forecastDef, "areaType", "")
rowVariable = self.__ut.set(forecastDef, "rowVariable", "EditArea")
if rowVariable == "EditArea":
rowLabel = areaType
elif rowVariable == "WeatherElement":
@ -566,7 +584,7 @@ class TextFormatter:
def __pairAreaWithLabel(self, chosenAreas, defaultEditAreas):
# Pair the chosen edit areas with associated labels from
# default list and return new list
dfEditAreas= []
dfEditAreas = []
for area in chosenAreas:
for name, label in defaultEditAreas:
if area == name:
@ -620,8 +638,8 @@ class TextFormatter:
def __getLatLonAreaName(self, latLonTuple):
lat, lon, dim = latLonTuple
name = "Ref" + '%s%s%s' % (lat, lon, dim)
name = name.replace(".","")
name = name.replace("-","")
name = name.replace(".", "")
name = name.replace("-", "")
return name
def getCombinations(self, combinations, argDict):
@ -635,7 +653,7 @@ class TextFormatter:
newArea = self.getEditArea(editArea, argDict)
if comboList.index(editArea) == 0:
comboNumber = self.getComboNumber()
label = "Combo"+`comboNumber`
label = "Combo" + `comboNumber`
refId = ReferenceID(label)
#global GridLoc
#GridLoc = newArea.getGloc()
@ -680,7 +698,7 @@ class TextFormatter:
try:
product = argDict["self"]
exec "fcstDef = product."+fcstName+"()"
exec "fcstDef = product." + fcstName + "()"
module = argDict["module"]
except:
# See if fcstName is variable in imported modules e.g. MyTable = {}
@ -699,7 +717,7 @@ class TextFormatter:
try:
# Look for fcstName = {}
# This can be removed eventually
exec "fcstDef = module."+fcstName
exec "fcstDef = module." + fcstName
except:
try:
# Try to instantiate smart text product class
@ -750,7 +768,7 @@ class TextFormatter:
def getEditArea(self, editAreaName, argDict):
# Returns an AFPS.ReferenceData object given an edit area name
# as defined in the GFE
# as defined in the GFE
# Apply suffix if appropriate
refID = ReferenceID(editAreaName)
#print "Getting edit area"
@ -779,7 +797,7 @@ class TextFormatter:
return tmp
def _separateByTimeZone(self, editAreaGroups, areaDictName, creationTime,
effectiveTZ = "effectiveTZ"):
effectiveTZ="effectiveTZ"):
#takes the list of areas, and based on the time zones breaks
#them up to ensure that each grouping using the same time zone.
#areaDictName is name of the area dictionary. creationTime is the
@ -817,7 +835,7 @@ class TextFormatter:
zoneTZ = localTZ
tzid = localTZid
#print "falling back to WFOtz: ", zoneTZ
self.log.warning("WARNING: Entry " + area +
self.log.warning("WARNING: Entry " + area +
" missing from AreaDictionary. Using default time zone.")
zones = tzDir.get(zoneTZ, [])
@ -835,7 +853,7 @@ class TextFormatter:
elif effectiveTZ == "actualTZ":
dict = tzDir
else:
self.log.error("Invalid effectiveTZ for separateByTZ() " +
self.log.error("Invalid effectiveTZ for separateByTZ() " +
effectiveTZ)
return editAreaGroups
keys = dict.keys()
@ -850,39 +868,39 @@ class TextFormatter:
#################################################################
def makeSquare(lat, lon, km):
" Make a list of square of given km around lat,lon"
latinc = km/222.0
loninc = math.cos(lat/57.17) * km / 222.0
latinc = km / 222.0
loninc = math.cos(lat / 57.17) * km / 222.0
latTop = lat + latinc
latBottom =lat - latinc
latBottom = lat - latinc
lonLeft = lon - loninc
lonRight = lon + loninc
points = []
points.append(`latTop`+","+ `lonRight`)
points.append(`latTop`+","+ `lonLeft`)
points.append(`latBottom`+","+ `lonLeft`)
points.append(`latBottom`+","+`lonRight`)
points.append(`latTop` + "," + `lonRight`)
points.append(`latTop` + "," + `lonLeft`)
points.append(`latBottom` + "," + `lonLeft`)
points.append(`latBottom` + "," + `lonRight`)
return points
def makePoint(point):
" Make a CartCoord2D from the point in format: x,y"
from com.vividsolutions.jts.geom import Coordinate
ind = string.find(point,",")
latStr = point[0:ind-1]
lonStr = point[ind+1:len(point)]
ind = string.find(point, ",")
latStr = point[0:ind - 1]
lonStr = point[ind + 1:len(point)]
lat = float(latStr)
lon = float(lonStr)
return Coordinate(lon,lat)
lon = float(lonStr)
return Coordinate(lon, lat)
def makeArea(gridLoc, pointList, refname=None):
" Make a Reference Area with a unique ReferenceID"
from com.vividsolutions.jts.geom import GeometryFactory, LinearRing, Coordinate, Polygon
from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceData_CoordinateType as CoordinateType
from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceData_CoordinateType as CoordinateType
geomFactory = GeometryFactory()
import jep
size = len(pointList)
if pointList[0] != pointList[size-1]: # closing the loop
if pointList[0] != pointList[size - 1]: # closing the loop
pointList.append(pointList[0])
pointArray = jep.jarray(len(pointList), Coordinate)
for i in range(len(pointList)):
@ -893,7 +911,7 @@ def makeArea(gridLoc, pointList, refname=None):
polyArray[0] = poly
region = geomFactory.createMultiPolygon(polyArray)
if refname is None:
refname = "Ref" + getTime()
refname = "Ref" + getTime()
refId = ReferenceID(refname)
refData = ReferenceData(gridLoc, refId, region, CoordinateType.LATLON)
# randerso: I don't think this is necessary
@ -913,8 +931,8 @@ def storeReferenceData(refSetMgr, refData, temp=True):
def getTime():
"Return an ascii string for the current time without spaces or :'s"
timeStr = `time.time()`
timeStr = string.replace(timeStr,".","_")
timeStr = `time.time()`
timeStr = string.replace(timeStr, ".", "_")
return timeStr
def getAbsTime(timeStr):
@ -926,7 +944,7 @@ def getAbsTime(timeStr):
hour = string.atoi(timeStr[9:11])
minute = string.atoi(timeStr[11:13])
return AFPSSup.AbsTimeYMD(year,month,day,hour,minute)
return AbsTime.absTimeYMD(year, month, day, hour, minute)
def usage():
print """

View file

@ -505,16 +505,16 @@ class VectorRelatedPhrases(PhraseBuilder.PhraseBuilder):
def windSpdProb_thresholds(self, tree, node):
return [
((50.0, 80.0), (40.0, 60.0)), # Per 1
(45.0, 32.5), # Per 2
(40.0, 25.0), # Per 3
(35.0, 20.0), # Per 4
(30.0, 15.0), # Per 5
(25.0, 12.5), # Per 6
(22.5, 10.0), # Per 7
(20.0, 8.0), # Per 8
(17.5, 6.0), # Per 9
(15.0, 5.0), # Per 10
((45.0, 80.0), (25.0, 60.0)), # Per 1
(35.0, 20.0), # Per 2
(30.0, 15.0), # Per 3
(25.0, 12.5), # Per 4
(22.5, 10.0), # Per 5
(20.0, 8.0), # Per 6
(17.5, 7.0), # Per 7
(15.0, 6.0), # Per 8
(12.5, 5.0), # Per 9
(10.0, 4.0), # Per 10
]
def firstComponentPeriod(self, tree, node):
@ -1130,7 +1130,7 @@ class VectorRelatedPhrases(PhraseBuilder.PhraseBuilder):
desc = "posHR"
elif maxMag >= 34.0:
desc = "posTS"
elif pws64 >= thresh64low or pws64 +2.0 >= thresh64low:
elif pws64 >= thresh64low or pws64 +5.0 >= thresh64low:
desc = "posHR"
elif pws34 >= thresh34low or pws34+10.0 >= thresh34low:
desc = "posTS"
@ -1203,7 +1203,7 @@ class VectorRelatedPhrases(PhraseBuilder.PhraseBuilder):
desc = "posHR"
elif maxMag >= 34.0:
desc = "posTS"
elif pws64 >= thresh64 or pws64 +2.0 >= thresh64:
elif pws64 >= thresh64 or pws64 +5.0 >= thresh64:
desc = "posHR"
elif pws34 >= thresh34 or pws34+10.0 >= thresh34:
desc = "posTS"
@ -1299,7 +1299,7 @@ class VectorRelatedPhrases(PhraseBuilder.PhraseBuilder):
else:
self.debug_print("HERE I AM")
if pws64 >= thresh64 or pws64+1.0 >= thresh64:
if pws64 >= thresh64 or pws64+2.5 >= thresh64:
desc = "posHR"
elif maxMag >= 64.0:
desc = "posHR"
@ -1399,7 +1399,7 @@ class VectorRelatedPhrases(PhraseBuilder.PhraseBuilder):
else:
self.debug_print("HERE I AM")
if pws64 >= thresh64 or pws64+1 >= thresh64:
if pws64 >= thresh64 or pws64+2.5 >= thresh64:
desc = "posHR"
elif maxMag >= 64.0:
desc = "posHR"
@ -1435,14 +1435,18 @@ class VectorRelatedPhrases(PhraseBuilder.PhraseBuilder):
self.debug_print("(34 kt threshold, 64 kt threshold) = (%.2f, %.2f)" %
(thresh34, thresh64), 1)
if (pws64 >= thresh64 or (pws64 + 1.0) >= thresh64) and maxMag >= 20.0:
if (pws64 >= thresh64 or (pws64 + 1.0) >= thresh64):
desc = "posHR"
elif maxMag >= 64.0:
desc = "posHR"
elif (pws34 >= thresh34 or (pws34 + 2.5) >= thresh34) and maxMag >= 20.0:
elif (self._Hurricane_A or self._Hurricane_W) and maxMag >= 50:
desc = "posHR"
elif (pws34 >= thresh34 or (pws34 + 2.5) >= thresh34):
desc = "posTS"
elif maxMag >= 34.0:
desc = "posTS"
elif (self._Hurricane_A or self._Hurricane_W or self._TropStorm_A or self._TropStorm_W) and maxMag >= 25:
desc = "posTS"
else:
desc = ""
@ -1470,14 +1474,18 @@ class VectorRelatedPhrases(PhraseBuilder.PhraseBuilder):
self.debug_print("(34 kt threshold, 64 kt threshold) = (%.2f, %.2f)" %
(thresh34, thresh64), 1)
if (pws64 >= thresh64 or (pws64 + 1.0) >= thresh64) and maxMag >= 20.0:
if (pws64 >= thresh64 or (pws64 + 1.0) >= thresh64):
desc = "posHR"
elif maxMag >= 64.0:
desc = "posHR"
elif (pws34 >= thresh34 or (pws34 + 2.5) >= thresh34) and maxMag >= 20.0:
elif (self._Hurricane_A or self._Hurricane_W) and maxMag >= 50:
desc = "posHR"
elif (pws34 >= thresh34 or (pws34 + 2.5) >= thresh34):
desc = "posTS"
elif maxMag >= 34.0:
desc = "posTS"
elif (self._Hurricane_A or self._Hurricane_W or self._TropStorm_A or self._TropStorm_W) and maxMag >= 25:
desc = "posTS"
else:
desc = ""

Some files were not shown because too many files have changed in this diff Show more