diff --git a/RadarServer/com.raytheon.rcm.lib/src/com/raytheon/rcm/request/RpsListFormatter.java b/RadarServer/com.raytheon.rcm.lib/src/com/raytheon/rcm/request/RpsListFormatter.java index 2f7a7338c3..0640c69652 100644 --- a/RadarServer/com.raytheon.rcm.lib/src/com/raytheon/rcm/request/RpsListFormatter.java +++ b/RadarServer/com.raytheon.rcm.lib/src/com/raytheon/rcm/request/RpsListFormatter.java @@ -28,93 +28,106 @@ import com.raytheon.rcm.products.ProductInfo.Selector; import com.raytheon.rcm.products.RadarProduct; import com.raytheon.rcm.products.RadarProduct.Param; - +/** + * Used to format a {@link RpsList} before it is written. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * ?            ?          ?           Initial creation.
+ * Jan 20, 2016 5271       bkowal      Include time span / end hour for products
+ *                                     that use minutes for the time span.
+ * 
+ * + */ public class RpsListFormatter { - /* See AWIPS-1 ProductRequestList::writeList() - * - */ - public static void formatAwips1RpsList(RpsList list, String fileName, PrintWriter s) { - RadarType radarType = list.getVcp() == 80 || list.getVcp() == 90 ? - RadarType.TDWR : RadarType.WSR; - Calendar cal = Calendar.getInstance(); - s.format("RPS List %s %s... %d products\n", - fileName != null ? fileName : "", - String.format("%1$tY:%1$tm:%1$td:%1$tH:%1$tM:%1$tS", cal), - list.getRequests().length); - s.print(" An RPS list contains the fields: Prod-Name, Mnemonic, Prod-Code\n" + - " Number of Data Levels, Resolution, Layer Code, Elevation, Contour Interval,\n" + - " Priority, Req Interval, Map, Lower Layer, Upper Layer, multCut, endHour, timeSpan\n" + - " The record format is: '%-39s %-3s%4d%4d%6d %c%6d%7d%2d%2d%c%3d%3d %c%7d%7d'\n"); + /* + * See AWIPS-1 ProductRequestList::writeList() + */ + public static void formatAwips1RpsList(RpsList list, String fileName, + PrintWriter s) { + RadarType radarType = list.getVcp() == 80 || list.getVcp() == 90 ? RadarType.TDWR + : RadarType.WSR; + Calendar cal = Calendar.getInstance(); + s.format("RPS List %s %s... %d products\n", fileName != null ? fileName + : "", + String.format("%1$tY:%1$tm:%1$td:%1$tH:%1$tM:%1$tS", cal), list + .getRequests().length); + s.print(" An RPS list contains the fields: Prod-Name, Mnemonic, Prod-Code\n" + + " Number of Data Levels, Resolution, Layer Code, Elevation, Contour Interval,\n" + + " Priority, Req Interval, Map, Lower Layer, Upper Layer, multCut, endHour, timeSpan\n" + + " The record format is: '%-39s %-3s%4d%4d%6d %c%6d%7d%2d%2d%c%3d%3d %c%7d%7d'\n"); - for (Request r : list.getRequests()) { - s.println(formatAwips1Request(r, radarType)); - } - } - - private static final char[] layerCodes = {'L', 'M', 'H'}; - - public static String formatAwips1Request(Request r, RadarType radarType) { - RadarProduct rp = ProductInfo.getInstance().selectOne( - new Selector(radarType, null, (int) r.productCode, null)); - - /* Could probably guess how to format the important parts, but this - * is what AWIPS-1 does anyway... - */ - if (rp == null) - throw new IllegalArgumentException("Cannot format unknown product type " + - r.productCode + "."); - - /* Note there is no check for rp.contains(ELEVATION) This - * is fine for the current set of products that are available in - * the RPS list editor... - */ - /* // Mimic: - if (_multCuts == 'Y' && _elev > 16384) - { - _elev -= 16384; + for (Request r : list.getRequests()) { + s.println(formatAwips1Request(r, radarType)); } - */ - boolean multiCuts = false; - int elev = r.pdw22; - if (r.getElevationSelection() == Request.ALL_ELEVATIONS && - r.getElevationAngle() != 0) { - elev = r.getElevationAngle(); - multiCuts = true; - } - - char layerCode = '-'; - if (rp.layer != null) { - try { - layerCode = layerCodes[rp.layer - 1]; - } catch (ArrayIndexOutOfBoundsException e) { - // nothing - } - } - int lowerLayer = -1; - int upperLayer = -1; - if (rp.params.contains(Param.LAYER)) { - lowerLayer = r.getBottomAltitude(); - upperLayer = r.getTopAltitude(); - } else if (rp.params.contains(Param.MINI_VOLUME)) { - lowerLayer = r.getMiniVolume(); - } - int endHour = -1; - int timeSpan = -1; - if (rp.params.contains(Param.TIME_SPAN)) { - endHour = r.getEndHour(); - timeSpan = r.getTimeSpan(); - } - - return String.format("%-39.39s %-3.3s%4d%4d%6d %c%6d%7d%2d%2d%c%3d%3d %c%7d%7d", - rp.name, rp.mnemonic, - r.productCode, - rp.levels != null ? rp.levels : 0, - rp.resolution != null ? (int)(rp.resolution * 100) : 0, - layerCode, elev, -1 /*contour interval*/, - r.highPriority ? 1 : 0, r.interval, - r.mapRequested ? 'Y' : 'N', - lowerLayer, upperLayer, - multiCuts ? 'Y' : 'N', - endHour, timeSpan); - } + } + + private static final char[] layerCodes = { 'L', 'M', 'H' }; + + public static String formatAwips1Request(Request r, RadarType radarType) { + RadarProduct rp = ProductInfo.getInstance().selectOne( + new Selector(radarType, null, (int) r.productCode, null)); + + /* + * Could probably guess how to format the important parts, but this is + * what AWIPS-1 does anyway... + */ + if (rp == null) { + throw new IllegalArgumentException( + "Cannot format unknown product type " + r.productCode + "."); + } + + /* + * Note there is no check for rp.contains(ELEVATION) This is fine for + * the current set of products that are available in the RPS list + * editor... + */ + /* + * // Mimic: if (_multCuts == 'Y' && _elev > 16384) { _elev -= 16384; } + */ + boolean multiCuts = false; + int elev = r.pdw22; + if (r.getElevationSelection() == Request.ALL_ELEVATIONS + && r.getElevationAngle() != 0) { + elev = r.getElevationAngle(); + multiCuts = true; + } + + char layerCode = '-'; + if (rp.layer != null) { + try { + layerCode = layerCodes[rp.layer - 1]; + } catch (ArrayIndexOutOfBoundsException e) { + // nothing + } + } + int lowerLayer = -1; + int upperLayer = -1; + if (rp.params.contains(Param.LAYER)) { + lowerLayer = r.getBottomAltitude(); + upperLayer = r.getTopAltitude(); + } else if (rp.params.contains(Param.MINI_VOLUME)) { + lowerLayer = r.getMiniVolume(); + } + int endHour = -1; + int timeSpan = -1; + if (rp.params.contains(Param.TIME_SPAN) + || rp.params.contains(Param.TIME_SPAN_MINUTES)) { + endHour = r.getEndHour(); + timeSpan = r.getTimeSpan(); + } + + return String.format( + "%-39.39s %-3.3s%4d%4d%6d %c%6d%7d%2d%2d%c%3d%3d %c%7d%7d", + rp.name, rp.mnemonic, r.productCode, + rp.levels != null ? rp.levels : 0, + rp.resolution != null ? (int) (rp.resolution * 100) : 0, + layerCode, elev, -1 /* contour interval */, r.highPriority ? 1 + : 0, r.interval, r.mapRequested ? 'Y' : 'N', + lowerLayer, upperLayer, multiCuts ? 'Y' : 'N', endHour, + timeSpan); + } } diff --git a/RadarServer/com.raytheon.rcm.server/src/com/raytheon/rcm/rpsmgr/RPSListManager.java b/RadarServer/com.raytheon.rcm.server/src/com/raytheon/rcm/rpsmgr/RPSListManager.java index aa453a4fb7..817e5461c2 100755 --- a/RadarServer/com.raytheon.rcm.server/src/com/raytheon/rcm/rpsmgr/RPSListManager.java +++ b/RadarServer/com.raytheon.rcm.server/src/com/raytheon/rcm/rpsmgr/RPSListManager.java @@ -61,9 +61,9 @@ import com.raytheon.rcm.server.StatusManager.RadarStatus; /** * Manages current RPS lists and requests for changes to RPS lists. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
@@ -73,8 +73,9 @@ import com.raytheon.rcm.server.StatusManager.RadarStatus;
  * 2014-02-03   DR 14762   D. Friedman Handle updated national RPS lists.
  * 2015-06-10   4498       nabowle     Rename Util->RcmUtil
  * 2015-09-08   DR 17944   D. Friedman Handle elevation list file updates.
+ * 2016-01-20   5271       bkowal      Fix resource leak.
  * 
- * + * */ public class RPSListManager extends RadarEventAdapter { @@ -181,11 +182,13 @@ public class RPSListManager extends RadarEventAdapter { return "Error getting radar status"; } - int[] cuts = ElevationInfo.getInstance().getScanElevations(radarID, currentVCP); + int[] cuts = ElevationInfo.getInstance().getScanElevations(radarID, + currentVCP); if (cuts == null && RcmUtil.getRadarType(rc) == RadarType.WSR) cuts = gsmCuts; - if (list.getVcp() != RpsList.UNSPECIFIED_VCP && list.getVcp() != currentVCP) { + if (list.getVcp() != RpsList.UNSPECIFIED_VCP + && list.getVcp() != currentVCP) { if (store) return null; // TODO: Should warn instead. else @@ -240,13 +243,13 @@ public class RPSListManager extends RadarEventAdapter { rpsList = null; if (rpsList == null) { - int[] cuts = ElevationInfo.getInstance(). - getScanElevations(rc.getRadarID(), gsm.vcp); + int[] cuts = ElevationInfo.getInstance().getScanElevations( + rc.getRadarID(), gsm.vcp); if (cuts == null && RcmUtil.getRadarType(rc) == RadarType.WSR) cuts = gsm.cuts; - rpsList = getMergedRpsListForRadar(rc, gsm.opMode, gsm.vcp, - cuts, null); + rpsList = getMergedRpsListForRadar(rc, gsm.opMode, gsm.vcp, cuts, + null); // TODO: Should persist this (wouldn't need clone code) if (rpsList != null) @@ -259,7 +262,7 @@ public class RPSListManager extends RadarEventAdapter { /** * From AWIPS 1 ProductRequestList::addMiniVolumeProduct() (DCS 3411) - * + * * For TDWR VCP80, 2 products might be generated in one volume (2 mini * volumes) for some products. Parameter lowerLayer is used to specify these * 2 products: 1 - generated at mid volume; 2 - generated at end volume @@ -267,7 +270,7 @@ public class RPSListManager extends RadarEventAdapter { * implementation --------------------------------------------------------- * Searches list for mini volume products, add a new entry with lowerLayer 1 * CZ(35-38),ET(41),VIL(57),STI(58),HI(59),TVS(61),MD(141),DMD(149) - * + * */ /* * This must be kept in sync with @@ -279,8 +282,8 @@ public class RPSListManager extends RadarEventAdapter { return; /* - * We want to put these products at the end of the list so that they - * do not have priority over existing products. + * We want to put these products at the end of the list so that they do + * not have priority over existing products. */ Selector sel = new Selector(); sel.radarType = RadarType.TDWR; @@ -290,8 +293,8 @@ public class RPSListManager extends RadarEventAdapter { Request r = reqs.get(i); sel.code = (int) r.productCode; RadarProduct prod = ProductInfo.getInstance().selectOne(sel); - if (prod != null && prod.params.contains(Param.MINI_VOLUME) && - r.getMiniVolume() != 1) { + if (prod != null && prod.params.contains(Param.MINI_VOLUME) + && r.getMiniVolume() != 1) { Request r2 = r.clone(); r2.setMiniVolume(1); reqs.add(r2); @@ -321,14 +324,14 @@ public class RPSListManager extends RadarEventAdapter { Log.warnf("Cannot determine maximum RPS list size for %s", rc.getRadarID()); if (requestCount < 0) - Log.warnf("Cannot number of requests in RPS list for %s", rc - .getRadarID()); + Log.warnf("Cannot number of requests in RPS list for %s", + rc.getRadarID()); if (maxSize >= 0 && requestCount >= 0 && requestCount > maxSize) { int truncCount = 0; int i; for (i = reqs.length - 1; i >= 0; --i) { - truncCount += RpsList.getRequestCount(reqs[i], rc.getRadarID(), rpsList.getVcp(), - RcmUtil.getRadarType(rc)); + truncCount += RpsList.getRequestCount(reqs[i], rc.getRadarID(), + rpsList.getVcp(), RcmUtil.getRadarType(rc)); if (requestCount - truncCount <= maxSize) break; } @@ -337,8 +340,10 @@ public class RPSListManager extends RadarEventAdapter { int originalCount = requestCount; requestCount = requestCount - truncCount; - Log.warnf("Truncated list for %s from %d entries (%d requests) to %d entries (%d requests)", - rc.getRadarID(), reqs.length, originalCount, i, requestCount); + Log.warnf( + "Truncated list for %s from %d entries (%d requests) to %d entries (%d requests)", + rc.getRadarID(), reqs.length, originalCount, i, + requestCount); // TODO: Also need to send a message to Guardian reqs = Arrays.copyOf(reqs, i); rpsList = new RpsList(rpsList.getOpMode(), rpsList.getVcp(), reqs); @@ -346,8 +351,8 @@ public class RPSListManager extends RadarEventAdapter { Log.warnf("Sending empty RPS list to %s", rc.getRadarID()); } - Log.eventf("%s: Sending RPS list with %d entries (%d requests)", rc.getRadarID(), - rpsList.getRequests().length, requestCount); + Log.eventf("%s: Sending RPS list with %d entries (%d requests)", + rc.getRadarID(), rpsList.getRequests().length, requestCount); byte[] msg = ProductRequest.encode(rpsList.getRequests()); radarServer.getConnectionManager().sendMessageToRadar(rc.getRadarID(), msg); @@ -396,8 +401,7 @@ public class RPSListManager extends RadarEventAdapter { path = new File(dir, rc.getRadarID().toUpperCase() + ".currentVCP"); fo = new FileOutputStream(path); - try { - PrintWriter p = new PrintWriter(fo); + try (PrintWriter p = new PrintWriter(fo)) { p.printf("VCP%d\n", rpsList.getVcp()); p.flush(); } finally { @@ -431,7 +435,7 @@ public class RPSListManager extends RadarEventAdapter { /** * Constructs a an RPS list for the given parameters, merging national and * local lists as appropriate. - * + * * @param rc * @param opMode * @param vcp @@ -487,14 +491,12 @@ public class RPSListManager extends RadarEventAdapter { maybeAddSPGMiniVolumeProducts(rc, reqs, vcp); /* - * AWIPS 1 disabled duplicate merging for TDWRs because some requests - * in the national RPS list would disappear. This was due to incorrect - * handling of multi-elevation requests. AWIPS 2 handles - * multi-elevation request correctly. (See DCS 3472, DRs 19386, 20239, - * and 20244.) - * - * if (vcp == 80 || vcp == 90) - * elevList = null; + * AWIPS 1 disabled duplicate merging for TDWRs because some requests in + * the national RPS list would disappear. This was due to incorrect + * handling of multi-elevation requests. AWIPS 2 handles multi-elevation + * request correctly. (See DCS 3472, DRs 19386, 20239, and 20244.) + * + * if (vcp == 80 || vcp == 90) elevList = null; */ RadarType radarType = RcmUtil.getRadarType(rc); @@ -518,7 +520,7 @@ public class RPSListManager extends RadarEventAdapter { * later multi-elevation request that subsumes it to be * lost when the list is truncated to fix the maximum * number of products. - * + * * On the other hand, this could cause products listed * before index j to be lost because the RPG counts each * elevation in a multi-elevation request as a separate @@ -599,8 +601,8 @@ public class RPSListManager extends RadarEventAdapter { private void resetRpsListForRadar(RadarConfig rc) { String radarID = rc.getRadarID(); - RadarStatus status = radarServer.getStatusManager() - .getRadarStatus(radarID); + RadarStatus status = radarServer.getStatusManager().getRadarStatus( + radarID); byte[] gsmData = null; if (status != null) gsmData = status.getCurrentGSM(); @@ -609,10 +611,8 @@ public class RPSListManager extends RadarEventAdapter { if (gsmData != null) { handleGSM(rc, gsmData); } else { - Log.debugf( - "RPS-relevant configuration changed for %s, but " - + "it is not connected. Cannot send a list now.", - radarID); + Log.debugf("RPS-relevant configuration changed for %s, but " + + "it is not connected. Cannot send a list now.", radarID); } } } diff --git a/build/deploy.edex.awips2/esb/conf/spring/edex-db.xml b/build/deploy.edex.awips2/esb/conf/spring/edex-db.xml index 33b93f5c92..880c824e96 100644 --- a/build/deploy.edex.awips2/esb/conf/spring/edex-db.xml +++ b/build/deploy.edex.awips2/esb/conf/spring/edex-db.xml @@ -1,63 +1,64 @@ - - - - + + + + - - - - - com.raytheon.uf.common.dataplugin.text - com.raytheon.uf.common.dataplugin.shef - com.raytheon.edex.plugin.shef - com.raytheon.uf.common.bmh - - - - - - file:///${edex.home}/conf/db/hibernateConfig/metadata/hibernate.cfg.xml - - - - - + + + + + com.raytheon.uf.common.dataplugin.text + com.raytheon.uf.common.dataplugin.text.subscription + com.raytheon.uf.common.dataplugin.shef + com.raytheon.edex.plugin.shef + com.raytheon.uf.common.bmh + + + + + + file:///${edex.home}/conf/db/hibernateConfig/metadata/hibernate.cfg.xml + + + + + - - - - - - - + + + - - - - file:///${edex.home}/conf/db/hibernateConfig/maps/hibernate.cfg.xml - - - + + + - - - + + + + file:///${edex.home}/conf/db/hibernateConfig/maps/hibernate.cfg.xml + + + + + + + \ No newline at end of file diff --git a/build/deploy.edex.awips2/esb/etc/registry.sh b/build/deploy.edex.awips2/esb/etc/registry.sh index 387afed6e3..dc533f725a 100644 --- a/build/deploy.edex.awips2/esb/etc/registry.sh +++ b/build/deploy.edex.awips2/esb/etc/registry.sh @@ -30,6 +30,7 @@ export EDEX_DEBUG_PORT=5012 export EDEX_JMX_PORT=1620 export LOG_CONF=logback-registry.xml export MGMT_PORT=9605 +export HTTP_PORT=9588 export METADATA_POOL_MAX=20 export METADATA_POOL_TIMEOUT=60 diff --git a/build/deploy.edex.awips2/esb/etc/request.sh b/build/deploy.edex.awips2/esb/etc/request.sh index adab74fc07..670a13ac07 100644 --- a/build/deploy.edex.awips2/esb/etc/request.sh +++ b/build/deploy.edex.awips2/esb/etc/request.sh @@ -33,3 +33,4 @@ export EDEX_DEBUG_PORT=5005 export EDEX_JMX_PORT=1616 export LOG_CONF=logback-request.xml export MGMT_PORT=9601 +export HTTP_PORT=9581 diff --git a/build/deploy.edex.awips2/esb/etc/ebxmlRegistry.sh b/build/deploy.edex.awips2/esb/etc/sbnSimulator.sh similarity index 83% rename from build/deploy.edex.awips2/esb/etc/ebxmlRegistry.sh rename to build/deploy.edex.awips2/esb/etc/sbnSimulator.sh index 2467b3a59f..eada11f76a 100644 --- a/build/deploy.edex.awips2/esb/etc/ebxmlRegistry.sh +++ b/build/deploy.edex.awips2/esb/etc/sbnSimulator.sh @@ -22,16 +22,15 @@ export MAX_MEM=1536 # in Meg if [ $HIGH_MEM == "on" ]; then - export MAX_MEM=2048 + export MAX_MEM=2560 fi export MAX_PERM_SIZE=192m -export EDEX_DEBUG_PORT=5012 -export EDEX_JMX_PORT=1620 -export LOG_CONF=logback-ebxmlRegistry.xml -export MGMT_PORT=9605 +export EDEX_DEBUG_PORT=5013 +export LOG_CONF=logback-registry.xml +export MGMT_PORT=9606 export METADATA_POOL_MAX=20 export METADATA_POOL_TIMEOUT=60 -export SOFT_REF_LRU_POLICY_MS_PER_MB=50 +export SOFT_REF_LRU_POLICY_MS_PER_MB=50 \ No newline at end of file diff --git a/build/deploy.edex/DeployESB.groovy b/build/deploy.edex/DeployESB.groovy index a227414174..a186d3b206 100644 --- a/build/deploy.edex/DeployESB.groovy +++ b/build/deploy.edex/DeployESB.groovy @@ -30,6 +30,7 @@ import groovy.util.logging.* * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 4, 2014 3836 bkowal Initial Commit + * Dec 9, 2015 4216 dhladky Fix multi WA deploys * * * @@ -85,22 +86,7 @@ class DeployESB architecture = (System.getProperty("os.arch") == "amd64") ? "x86_64" : "x86" } - String esbLibIllusionPath = esbDirectory + File.separator + "lib" + File.separator + - "lib_illusion" + File.separator + architecture - if (new File(esbLibIllusionPath).exists() == false) - { - log.log(java.util.logging.Level.SEVERE, - "Unable to find the illusion lib associated with architecture - " + architecture) - System.exit(-1) - } - - String libIllusionDestination = edexRootDirectory + File.separator + - "lib" + File.separator + "lib_illusion" - new File(libIllusionDestination).mkdirs() - ant.copy( todir : libIllusionDestination, overwrite : true ) - { - fileset( dir : esbLibIllusionPath ) - } + } public static void deployEdexConfiguration(String edexRootDirectory, String esbDirectory) diff --git a/build/deploy.edex/RunDeployInstall.groovy b/build/deploy.edex/RunDeployInstall.groovy index 9919ce49ec..fbbdf9c871 100644 --- a/build/deploy.edex/RunDeployInstall.groovy +++ b/build/deploy.edex/RunDeployInstall.groovy @@ -44,6 +44,7 @@ import IPluginCustomDeployer * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 4, 2014 3836 bkowal Initial Commit + * Dec 9, 2015 4216 dhladky Fix multi WA deploy * * * @@ -124,7 +125,7 @@ class DeployInstall // complete the esb deployment // we need to determine the location of the build.edex project - ProjectInformation projectInformation = this.projectInformationMap["build.edex"] + ProjectInformation projectInformation = this.projectInformationMap["deploy.edex.awips2"] if (projectInformation == null) { log.log(java.util.logging.Level.SEVERE, diff --git a/cave/build/p2-build.xml b/cave/build/p2-build.xml index 1481823ac0..c11dc8e287 100644 --- a/cave/build/p2-build.xml +++ b/cave/build/p2-build.xml @@ -5,7 +5,7 @@ - + diff --git a/cave/build/tools/capture.bat b/cave/build/tools/capture.bat new file mode 100644 index 0000000000..8a9df8421f --- /dev/null +++ b/cave/build/tools/capture.bat @@ -0,0 +1,129 @@ +@echo OFF + +REM This is a MSFT Windows version of the CAVE capture script. +REM This script will identify any running CAVE processes (cave.exe) +REM and use Java to generate jstacks and (optionally) heap dumps +REM for the process(es). All of the files generated by this capture +REM script and any associated CAVE logs will be placed in a directory +REM in the user's 'My Documents' directory. +REM Usage: capture.bat [-d][-h] + +REM Verify that the location of the Java JDK is known. +IF "%JAVA_JDK%" == "" ( + echo ERROR: Unable to determine the location of the Java JDK. Use the JAVA_JDK Env Variable to set the location. + GOTO EOF +) + +SET heap_dump=0 + +REM Process and validate any command line parameters, displaying usage +REM information if necessary. +IF "%1" == "" GOTO run +REM Verify that there is only one argument. +IF NOT "%2" == "" GOTO usage +REM Check for the -d argument. +IF "%1" == "-d" ( + SET heap_dump=1 + GOTO run +) +REM Either an invalid argument or the -h argument. +GOTO usage + +:usage +echo Usage: %0 [-d][-h] +echo -d: Enables the heap dump capture +echo -h: Displays the usage message +GOTO EOF + +:run +SET jstack_iterations=15 +SET PROCESS=cave.exe + +REM Prepare Environment +SET Path=%JAVA_JDK%\bin;%Path% + +REM Build a date/time string to use in the name for the capture 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 CAPTURE_DATETIME= < %RND_DATETIME_FILE% +DEL %RND_DATETIME_FILE% + +SET CAPTURE_DIRECTORY=%userprofile%\capture_%CAPTURE_DATETIME% +SET CAVEDATA_LOGS_DIRECTORY=%userprofile%\%logdir% +SET CAPTURE_LOG=%CAPTURE_DIRECTORY%\capture_info.log + +REM Get the PID of any currently running CAVE process. +for /f "tokens=2 delims=," %%F in ('tasklist /nh /fi "imagename eq %PROCESS%" /fo csv') do call :process_pid %%~F +GOTO prepare_exit + +:process_pid +IF NOT EXIST "%CAPTURE_DIRECTORY%" (MKDIR "%CAPTURE_DIRECTORY%") + +SET process_pid=%1 +SET jstack_counter=0 +echo Found %PROCESS% with pid %process_pid% ... +echo Found %PROCESS% with pid %process_pid% ... >> %CAPTURE_LOG% +:while_jstack +if %jstack_counter% lss %jstack_iterations% ( + set /a jstack_counter+=1 + echo Completing jstack iteration %jstack_counter% ... + echo Completing jstack iteration %jstack_counter% ... >> %CAPTURE_LOG% + + SET jstack_log=%CAPTURE_DIRECTORY%\pid_%process_pid%_jstack_%jstack_counter%.log + jstack -l %process_pid% >> "%jstack_log%" + echo Running command: jstack -l %process_pid% >> %CAPTURE_LOG% + IF ERRORLEVEL 1 ( + echo jstack for pid %process_pid% failed to connect, rerunning with -F >> %CAPTURE_LOG% + echo jstack for pid %process_pid% failed to connect, rerunning with -F + echo Running command: jstack -l -F %process_pid% >> %CAPTURE_LOG% + jstack -l -F %process_pid% >> "%jstack_log%" + ) + + goto :while_jstack +) + +REM Copy the CAVE logs for the pid to the capture directory. +echo Running command: xcopy "%CAVEDATA_LOGS_DIRECTORY%\*pid_%process_pid%*.log" "%CAPTURE_DIRECTORY%" >> %CAPTURE_LOG% +xcopy "%CAVEDATA_LOGS_DIRECTORY%\*pid_%process_pid%*.log" "%CAPTURE_DIRECTORY%" >> %CAPTURE_LOG% +IF ERRORLEVEL 0 GOTO check_heap +echo Failed to copy the CAVE logs files. +echo Failed to copy the CAVE logs files. >> %CAPTURE_LOG% + +:check_heap +REM Create a heap dump if the option has been enabled. +IF %heap_dump% NEQ 1 ( + echo Heap dumps have been disabled. >> %CAPTURE_LOG% + exit /b +) + +SET heap_path=%CAPTURE_DIRECTORY%\pid_%process_pid%_heap.hprof +SET dump_path=%CAPTURE_DIRECTORY%\pid_%process_pid%_dump.txt +echo Running command: jmap -heap %process_pid% >> %CAPTURE_LOG% +jmap -heap %process_pid% > %heap_path% + +echo Running command: jmap -dump:live,format=b,file=%dump_path% %process_pid% >> %CAPTURE_LOG% +jmap -dump:live,format=b,file=%dump_path% %process_pid% +IF ERRORLEVEL 1 ( + echo jmap for pid %process_pid% failed to connect, rerunning with -F >> %CAPTURE_LOG% + echo jmap for pid %process_pid% failed to connect, rerunning with -F + echo Running command: jmap -dump:live,format=b,file=%dump_path% -F %process_pid% >> %CAPTURE_LOG% + jmap -dump:live,format=b,file=%dump_path% -F %process_pid% +) + +REM end of process_pid sub-routine +exit /b + +:prepare_exit + +IF NOT EXIST %CAPTURE_DIRECTORY% (GOTO EOF) +echo Capture data is available in %CAPTURE_DIRECTORY% ... + +start "" "%CAPTURE_DIRECTORY%" +PAUSE + +:EOF diff --git a/cave/com.raytheon.uf.viz.acarssounding/src/com/raytheon/uf/viz/acarssounding/AcarsSndNSharpResourceData.java b/cave/com.raytheon.uf.viz.acarssounding/src/com/raytheon/uf/viz/acarssounding/AcarsSndNSharpResourceData.java index 30c297da4b..7de7914170 100644 --- a/cave/com.raytheon.uf.viz.acarssounding/src/com/raytheon/uf/viz/acarssounding/AcarsSndNSharpResourceData.java +++ b/cave/com.raytheon.uf.viz.acarssounding/src/com/raytheon/uf/viz/acarssounding/AcarsSndNSharpResourceData.java @@ -63,6 +63,7 @@ import com.raytheon.uf.viz.d2d.nsharp.rsc.D2DNSharpResourceData; * ------------ ---------- ----------- -------------------------- * Aug 15, 2013 bsteffen Initial creation * Jul 23, 2014 3410 bclement preparePointInfo() calls unpackResultLocation() + * Dec 17, 2015 5215 dgilling Set point name to stationId. * * * @@ -78,21 +79,27 @@ public class AcarsSndNSharpResourceData extends D2DNSharpResourceData { private static final String LATITUDE = "location.latitude"; + private static final String STATION_ID = "location.stationId"; + public AcarsSndNSharpResourceData() { super("MDCRS"); } @Override protected void preparePointInfo() throws VizException { - if (coordinate == null) { + if ((coordinate == null) || (pointName == null)) { DbQueryRequest request = new DbQueryRequest(); request.setConstraints(getMetadataMap()); - request.addFields(new String[] { LONGITUDE, LATITUDE }); + request.addFields(new String[] { STATION_ID, LONGITUDE, LATITUDE }); request.setDistinct(true); DbQueryResponse response = (DbQueryResponse) ThriftClient .sendRequest(request); for (Map result : response.getResults()) { + if (pointName == null) { + pointName = (String) result.get(STATION_ID); + } + if (coordinate == null) { coordinate = unpackResultLocation(result, LONGITUDE, LATITUDE); @@ -111,7 +118,8 @@ public class AcarsSndNSharpResourceData extends D2DNSharpResourceData { request.addConstraint("dataTime", new RequestConstraint(new DataTime( stnInfo.getReftime()).toString())); try { - DbQueryResponse response = (DbQueryResponse) ThriftClient.sendRequest(request); + DbQueryResponse response = (DbQueryResponse) ThriftClient + .sendRequest(request); ACARSSoundingRecord[] records = response .getEntityObjects(ACARSSoundingRecord.class); if (records.length > 0) { @@ -127,7 +135,8 @@ public class AcarsSndNSharpResourceData extends D2DNSharpResourceData { builder.addTemperature(layer.getTemp(), SI.KELVIN); } if (layer.getWindDirection() != null) { - builder.addWindDirection(layer.getWindDirection(), NonSI.DEGREE_ANGLE); + builder.addWindDirection(layer.getWindDirection(), + NonSI.DEGREE_ANGLE); } if (layer.getWindSpeed() != null) { builder.addWindSpeed(layer.getWindSpeed(), @@ -153,7 +162,7 @@ public class AcarsSndNSharpResourceData extends D2DNSharpResourceData { } catch (VizException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); } - + return null; } } diff --git a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertMessageDlg.java b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertMessageDlg.java index 8c2e07a68e..fac331bfbe 100644 --- a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertMessageDlg.java +++ b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertMessageDlg.java @@ -42,7 +42,6 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -101,6 +100,10 @@ import com.raytheon.uf.viz.alertviz.ui.audio.IAudioAction; * 31 May 2011 8058 cjeanbap Kill sound based on TextMsgBox id. * 26 Aug 2013 #2293 lvenable Fixed color memory leaks. * 02 Jun 2015 4473 mschenke Remember dialog position + * 28 Oct 2015 5054 randerso Fix lots of multimonitor display issues. + * 14 Jan 2016 5054 randerso Fix the Tips window to display on the correct monitor + * Removed duplicate parent shell + * 25 Jan 2016 5054 randerso Converted to stand alone window * * * @@ -119,11 +122,6 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, private static final ScopedPreferenceStore dialogPrefs = new ScopedPreferenceStore( InstanceScope.INSTANCE, Activator.PLUGIN_ID); - /** - * Parent shell. - */ - private final Shell parentShell; - /** * Local shell. */ @@ -150,9 +148,9 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, private Label resizeLabel; /** - * Location of the dialog on the screen. + * Mouse down location */ - private Point origin; + private Point mouseDownPt; /** * Show dialog flag. @@ -169,26 +167,11 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, */ private boolean resizeDialog = false; - /** - * Dialog location. - */ - private Point dialogLoc; - /** * ArrayList of TextMsgControlComp objects. */ private ArrayList txtMsgCompArray; - /** - * Starting X position. - */ - private int startXpos = -1; - - /** - * Screen width. - */ - private int screenWidth = 0; - /** * Text composite. */ @@ -247,20 +230,21 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, /** * Constructor. * - * @param parentShell - * Parent shell. + * @param display + * Parent display. * @param audioCB * Audio callback. * @param showDialog * Show dialog flag. * @param configData * Configuration data. + * @param alertAudioMgr */ - public AlertMessageDlg(Shell parentShell, IAudioAction audioCB, + public AlertMessageDlg(Display display, IAudioAction audioCB, boolean showDialog, Configuration configData, AlertAudioMgr alertAudioMgr) { + this.display = display; this.showDialog = showDialog; - this.parentShell = parentShell; this.alertAudioMgr = alertAudioMgr; this.audioCB = audioCB; @@ -273,17 +257,21 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, } } + /** + * @return the shell + */ + public Shell getShell() { + return shell; + } + /** * Open method used to display the dialog. * * @return True/False. */ public Object open() { - display = parentShell.getDisplay(); - - Shell shell1 = new Shell(parentShell, SWT.NO_TRIM); - shell = new Shell(shell1, SWT.ON_TOP); - shell.setLocation(getDialogPosition()); + shell = new Shell(display, SWT.ON_TOP | SWT.NO_TRIM); + shell.setBounds(restoreDialogPosition()); shell.addDisposeListener(new DisposeListener() { @Override @@ -306,6 +294,7 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, shell.pack(); shell.open(); + // force bar location to be within the display. Point shellLoc = shell.getLocation(); Point shellSize = shell.getSize(); Display d = shell.getDisplay(); @@ -333,11 +322,18 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, return returnValue; } + /** + * @return true if dialog is disposed + */ + public boolean isDisposed() { + return (shell == null) || shell.isDisposed(); + } + /** * Dispose of all the message timers. */ public void dispose() { - setDialogPosition(dialogLoc); + saveDialogPosition(shell.getBounds()); // Stop all of the message timers. for (int i = 0; i < txtMsgCompArray.size(); i++) { @@ -356,6 +352,10 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, monitor.dispose(); } + if (shell != null) { + shell.dispose(); + } + ConfigurationManager.getInstance().getCustomLocalization() .removeFileUpdatedObserver(this); @@ -374,8 +374,6 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, * Initialize the components on the display. */ private void initializeComponents() { - screenWidth = display.getPrimaryMonitor().getBounds().width; - TrayConfiguration.TrayMode tm = configData.getGlobalConfiguration() .getMode(); boolean monitorOnly = (TrayConfiguration.TrayMode.MO.equals(tm) ? true @@ -402,9 +400,6 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, mainComp.setLayout(gl); mainComp.setLayoutData(gd); - dialogLoc = shell.getLocation(); - origin = dialogLoc; - moveLabel = new Label(mainComp, SWT.NONE); moveLabel.setImage(new Image(display, loadHandleImage())); moveLabel.setToolTipText("Move"); @@ -531,8 +526,8 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, } public void setMaxLogSize(final int maxLogSize) { - if (txtMsgCompArray != null && txtMsgCompArray.size() > 0 - && maxLogSize != txtMsgCompArray.get(0).getMaxLogSize()) { + if ((txtMsgCompArray != null) && (txtMsgCompArray.size() > 0) + && (maxLogSize != txtMsgCompArray.get(0).getMaxLogSize())) { for (TextMsgControlComp comp : txtMsgCompArray) { comp.setMaxLogSize(maxLogSize); } @@ -547,31 +542,24 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, */ @Override public void mouseMove(MouseEvent e) { - if ((Label) e.getSource() == moveLabel) { - if (origin != null && moveDialog == true) { - dialogLoc = display.map(shell, null, e.x, e.y); - shell.setLocation(dialogLoc.x - origin.x, dialogLoc.y - - origin.y); - } - } else if ((Label) e.getSource() == resizeLabel) { - if (resizeDialog == true) { - int newWidth = e.x - startXpos + shell.getSize().x; - - if (newWidth < 300) { - return; + if (mouseDownPt != null) { + if ((Label) e.getSource() == moveLabel) { + if (moveDialog == true) { + Point dialogLoc = shell.getLocation(); + dialogLoc.x = dialogLoc.x + (e.x - mouseDownPt.x); + dialogLoc.y = dialogLoc.y + (e.y - mouseDownPt.y); + shell.setLocation(dialogLoc); } + } else if ((Label) e.getSource() == resizeLabel) { + if (resizeDialog == true) { + int newWidth = shell.getSize().x + (e.x - mouseDownPt.x); - int shellLocationXCoord = shell.getLocation().x; + if (newWidth < 300) { + return; + } - if (shellLocationXCoord > screenWidth) { - shellLocationXCoord = shellLocationXCoord - screenWidth; + shell.setSize(newWidth, shell.getSize().y); } - - if (newWidth >= (screenWidth - shellLocationXCoord)) { - return; - } - - shell.setSize(newWidth, shell.getSize().y); } } } @@ -585,13 +573,12 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, @Override public void mouseDown(MouseEvent e) { if (e.button != SWT.BUTTON3) { - origin = new Point(e.x, e.y); + mouseDownPt = new Point(e.x, e.y); if ((Label) e.getSource() == moveLabel) { moveDialog = true; } else if ((Label) e.getSource() == resizeLabel) { resizeDialog = true; - startXpos = e.x; } } } @@ -605,14 +592,12 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, @Override public void mouseUp(MouseEvent e) { if (e.button != SWT.BUTTON3) { + mouseDownPt = null; if ((Label) e.getSource() == moveLabel) { moveDialog = false; - configData.getGlobalConfiguration().setPosition( - shell.getBounds()); } else if ((Label) e.getSource() == resizeLabel) { resizeDialog = false; - startXpos = -1; } } } @@ -637,10 +622,6 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, public void showDialog(boolean showDialogFlag) { showDialog = showDialogFlag; - // if (showDialog == true) { - // shell.setLocation(dialogLoc.x - origin.x, dialogLoc.y - origin.y); - // } - shell.setVisible(showDialog); } @@ -661,7 +642,7 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, } public void resetTabControl() { - boolean isOpen = tabControlDlg != null && !tabControlDlg.isDisposed() + boolean isOpen = (tabControlDlg != null) && !tabControlDlg.isDisposed() && tabControlDlg.isOpened(); reLayout(); // TODO: Need to determine which tabs to open and populate them. @@ -689,7 +670,7 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, RGB[] prevForeground = new RGB[size]; dispose(); for (int i = 0; i < txtMsgCompArray.size(); i++) { - if (txtMsgCompArray.get(i) != null + if ((txtMsgCompArray.get(i) != null) && !txtMsgCompArray.get(i).isDisposed()) { prevMessageText[i] = txtMsgCompArray.get(i) .getMessageText(); @@ -707,15 +688,16 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, open(); result = true; for (int i = 0; i < txtMsgCompArray.size(); i++) { - if (i < prevMessageText.length && prevMessageText[i] != null) { + if ((i < prevMessageText.length) + && (prevMessageText[i] != null)) { txtMsgCompArray.get(i).setMessageText(prevMessageText[i]); - if (prevBackground[i] != null && prevForeground[i] != null) { + if ((prevBackground[i] != null) + && (prevForeground[i] != null)) { txtMsgCompArray.get(i).setMessageTextBackAndForeground( prevBackground[i], prevForeground[i]); } } } - setDialogLocation(); shell.update(); alertAudioMgr = null; alertAudioMgr = new AlertAudioMgr(display, @@ -982,13 +964,6 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, this.configData = configData; } - /** - * Save the dialog location information. - */ - public void saveDialogBounds() { - configData.getGlobalConfiguration().setPosition(shell.getBounds()); - } - /** * Is the message dlg enabled * @@ -1012,24 +987,23 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, return; } - Shell shell = new Shell(); - shell.addDisposeListener(new DisposeListener() { + infoTextShell = new Shell(this.shell.getDisplay()); + infoTextShell.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { infoTextShell = null; } }); - infoTextShell = shell; - - shell.setLayout(new FillLayout()); - shell.setSize(800, 900); - - shell.setText(" AlertViz Tips! "); + infoTextShell.setMinimumSize(300, 200); + infoTextShell.setLayout(new GridLayout()); + infoTextShell.setText(" AlertViz Tips! "); // create the styled text widget - StyledText widget = new StyledText(shell, SWT.MULTI | SWT.WRAP + StyledText widget = new StyledText(infoTextShell, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + widget.setLayoutData(layoutData); widget.setText("----------------------------------------------\n" + " Here are some basic tips on how to use the AlertViz Main GUI: \n\n" @@ -1069,7 +1043,26 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, + "5 - Perhaps not even important enough for a notice of any kind. Informational. \n\n" + "------------------------------------------------------------\n\n"); - shell.open(); + infoTextShell.layout(); + infoTextShell.pack(); + + Rectangle b = this.shell.getBounds(); + Monitor m = this.shell.getMonitor(); + + // attempt to position tips window above or below alertviz bar + + // if tips window would be partially off screen it will be forced on + // screen by eclipse/window manager + if (b.y < (m.getBounds().height - (b.y + b.height))) { + // space below alertviz bar > than space above so position below + infoTextShell.setLocation(b.x, b.y + b.height); + } else { + // space above alertviz bar > than space below so position above + infoTextShell.setLocation(b.x, b.y + - infoTextShell.getBounds().height); + } + + infoTextShell.open(); } /** @@ -1114,13 +1107,13 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, errorBtnBgColor = new Color(display, 237, 233, 227); errorBtn.setBackground(errorBtnBgColor); - if (tabControlDlg == null || tabControlDlg.isDisposed()) { + if ((tabControlDlg == null) || tabControlDlg.isDisposed()) { tabControlDlg = TabControlDlg.getInstance(shell); } if (textMsgLog == null) { String[] categories = new String[] { "Causes", "Catch", "Error", "Exception" }; - textMsgLog = new TextMsgLog(parentShell, categories, 0, messageVec); + textMsgLog = new TextMsgLog(shell, categories, 0, messageVec); textMsgLog.setIndex(0); } if (opened) { @@ -1146,7 +1139,7 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, if (textMsgLog == null) { String[] categories = new String[] { "Causes", "Catch", "Error", "Exception" }; - textMsgLog = new TextMsgLog(parentShell, categories, 0, messageVec); + textMsgLog = new TextMsgLog(shell, categories, 0, messageVec); textMsgLog.setIndex(0); } textMsgLog.addMessage(statMsg); @@ -1173,14 +1166,14 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, for (Source source : sourceMap.values()) { String name = source.getName(); - if (source.isMonitor() && name != null) { + if (source.isMonitor() && (name != null)) { String imageFile = source.getConfigurationMonitor() .getMonitorMetadata().getImageFile(); boolean omitMonitor = source.getConfigurationMonitor() .getMonitorMetadata().getOmit(); AlertMonitor monitor = alertMonitors.get(name); - if (imageFile != null + if ((imageFile != null) && (!imageFile.equals("null") && !imageFile.equals(""))) { if (monitor != null) { monitor.setImageName(imageFile); @@ -1227,42 +1220,23 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener, return map; } - public Rectangle getCurrentLocation() { - Rectangle position = new Rectangle(dialogLoc.x, dialogLoc.y, - parentShell.getBounds().width, parentShell.getBounds().height); - return position; - } - - private void setDialogLocation() { - // get any monitors height; should be in an utility class also used in - // TabControlDlg. - Monitor any = (display.getMonitors())[0]; - Rectangle monSize = any.getBounds(); - int monY = monSize.height; - - Rectangle rect = shell.getBounds(); - - if (shell.getBounds().y < 0) { - shell.setLocation(rect.x, rect.y + 100); - } - - if (shell.getBounds().y > (monY - 100)) { - shell.setLocation(rect.x, rect.y - 100); - } - } - public AlertAudioMgr getAlertAudioManager() { return alertAudioMgr; } - public static Point getDialogPosition() { - return new Point(dialogPrefs.getInt(P_ALERT_MSG_DLG_POSITION + ".x"), - dialogPrefs.getInt(P_ALERT_MSG_DLG_POSITION + ".y")); + public static Rectangle restoreDialogPosition() { + return new Rectangle( + dialogPrefs.getInt(P_ALERT_MSG_DLG_POSITION + ".x"), + dialogPrefs.getInt(P_ALERT_MSG_DLG_POSITION + ".y"), + dialogPrefs.getInt(P_ALERT_MSG_DLG_POSITION + ".width"), + dialogPrefs.getInt(P_ALERT_MSG_DLG_POSITION + ".height")); } - public static void setDialogPosition(Point p) { - dialogPrefs.setValue(P_ALERT_MSG_DLG_POSITION + ".x", p.x); - dialogPrefs.setValue(P_ALERT_MSG_DLG_POSITION + ".y", p.y); + public static void saveDialogPosition(Rectangle r) { + dialogPrefs.setValue(P_ALERT_MSG_DLG_POSITION + ".x", r.x); + dialogPrefs.setValue(P_ALERT_MSG_DLG_POSITION + ".y", r.y); + dialogPrefs.setValue(P_ALERT_MSG_DLG_POSITION + ".width", r.width); + dialogPrefs.setValue(P_ALERT_MSG_DLG_POSITION + ".height", r.height); try { dialogPrefs.save(); } catch (IOException e) { diff --git a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertPopupMessageDlg.java b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertPopupMessageDlg.java index edab9ff9b6..d3b93c1c2f 100644 --- a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertPopupMessageDlg.java +++ b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertPopupMessageDlg.java @@ -42,7 +42,6 @@ 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.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.List; @@ -71,6 +70,8 @@ import com.raytheon.uf.viz.alertviz.config.AlertMetadata; * acknowledgeLastMessage(). * 20 Apr 2015 4311 lvenable Fixed text field to accept really long text strings. * 29 Jun 2015 4311 randerso Reworking AlertViz dialogs to be resizable. + * 25 Jan 2016 5054 randerso Converted to stand alone window + * 08 Feb 2016 5312 randerso Deleted isDisposed() added isOpen() * * * @@ -78,8 +79,8 @@ import com.raytheon.uf.viz.alertviz.config.AlertMetadata; * @version 1.0 * */ -public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener, - MouseListener, DisposeListener { +public class AlertPopupMessageDlg implements MouseMoveListener, MouseListener, + DisposeListener { private static final int MAX_INITIAL_LINES = 5; private static final int WIDTH_IN_CHARS = 135; @@ -282,8 +283,7 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener, /** * Constructor. * - * @param parent - * Parent shell. + * @param display * @param statMsg * Status message. * @param expanded @@ -293,9 +293,9 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener, * @param startUpRGB * Color to be displayed at startup. */ - public AlertPopupMessageDlg(Shell parent, StatusMessage statMsg, + public AlertPopupMessageDlg(Display display, StatusMessage statMsg, boolean expanded, Listener listener, RGB startUpRGB) { - super(parent, 0); + this.display = display; eventListener = listener; statMsgArray.add(statMsg); this.expanded = expanded; @@ -308,10 +308,7 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener, * Initialize the shell */ private void initShell(RGB startUp) { - Shell parent = getParent(); - display = parent.getDisplay(); - - shell = new Shell(parent, SWT.ON_TOP | SWT.RESIZE); + shell = new Shell(display, SWT.ON_TOP | SWT.RESIZE); shell.setText("Alert Visualization Popup Message Dialog"); shell.addDisposeListener(this); @@ -1066,12 +1063,12 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener, } /** - * Returns if dialog is disposed. + * Returns true if dialog is open * - * @return True if disposed, false if not. + * @return True if open, false if not. */ - public boolean isDisposed() { - return shell.isDisposed(); + public boolean isOpen() { + return (shell != null) && !shell.isDisposed() && shell.isVisible(); } } diff --git a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertVisConfigDlg.java b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertVisConfigDlg.java index e08bee1378..343f44d840 100644 --- a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertVisConfigDlg.java +++ b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertVisConfigDlg.java @@ -38,7 +38,6 @@ 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.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Group; @@ -100,6 +99,8 @@ import com.raytheon.uf.viz.alertviz.ui.dialogs.ConfigurationFileDlg.Function; * 07 Feb 2013 15490 Xiaochuan Past this object to LayoutControlsComp. * 26 Aug 2013 #2293 lvenable Fixed color memory leak and cleaned up some code. * 23 Oct 2013 2303 bgonzale Old patch to fix tool tip layout. + * 28 Oct 2005 5054 randerso Removed bar position as it was written but never read + * 25 Jan 2016 5054 randerso Converted to stand alone window * * * @@ -107,8 +108,8 @@ import com.raytheon.uf.viz.alertviz.ui.dialogs.ConfigurationFileDlg.Function; * @version 1.0 * */ -public class AlertVisConfigDlg extends Dialog implements - IConfigurationChangedListener, INeedsSaveListener { +public class AlertVisConfigDlg implements IConfigurationChangedListener, + INeedsSaveListener { private final String CONFIG_LABEL = "Current Config: "; @@ -264,16 +265,16 @@ public class AlertVisConfigDlg extends Dialog implements /** * Constructor. * - * @param parent - * Parent shell. + * @param display * @param configData * Configuration data. */ - public AlertVisConfigDlg(Shell parent, final AlertMessageDlg alertMsgDlg, - Configuration configData, ConfigContext configContext, + public AlertVisConfigDlg(Display display, + final AlertMessageDlg alertMsgDlg, Configuration configData, + ConfigContext configContext, IConfigurationChangedListener configurationChangeListener, IRestartListener restartListener) { - super(parent, 0); + this.display = display; this.configData = configData; this.configContext = configContext; sourceMap = configData.getSources(); @@ -306,8 +307,6 @@ public class AlertVisConfigDlg extends Dialog implements * @return True/False. */ public Object open() { - Shell parent = getParent(); - display = parent.getDisplay(); shell = new Shell(display, SWT.DIALOG_TRIM | SWT.MIN | SWT.RESIZE | SWT.MAX); shell.setText("Alert Visualization Configuration"); @@ -396,6 +395,7 @@ public class AlertVisConfigDlg extends Dialog implements layoutControls = new LayoutControlsComp(layoutGroup, configData, this, this); layoutGroup.addMouseTrackListener(new MouseTrackAdapter() { + @Override public void mouseHover(MouseEvent e) { mttLayout.open(); } @@ -418,6 +418,7 @@ public class AlertVisConfigDlg extends Dialog implements mttCommonSetting = new MonitorToolTip(commonSettingsGroup, true); commonSettingsGroup.addMouseTrackListener(new MouseTrackAdapter() { + @Override public void mouseHover(MouseEvent e) { mttCommonSetting.open(); } @@ -632,6 +633,7 @@ public class AlertVisConfigDlg extends Dialog implements mttSource = new MonitorToolTip(sourcesLbl, false); sourcesLbl.addMouseTrackListener(new MouseTrackAdapter() { + @Override public void mouseHover(MouseEvent e) { mttSource.open(); } @@ -686,6 +688,7 @@ public class AlertVisConfigDlg extends Dialog implements sourcesList.setMenu(popupMenuSourceList); popupMenuSourceList.addListener(SWT.Show, new Listener() { + @Override public void handleEvent(Event event) { MenuItem[] menuItems = popupMenuSourceList.getItems(); @@ -864,6 +867,7 @@ public class AlertVisConfigDlg extends Dialog implements mttPriorities = new MonitorToolTip(priorityLbl, false); priorityLbl.addMouseTrackListener(new MouseTrackAdapter() { + @Override public void mouseHover(MouseEvent e) { mttPriorities.open(); } @@ -1134,7 +1138,7 @@ public class AlertVisConfigDlg extends Dialog implements sourceMap.keySet()); Boolean saveInfo = (Boolean) newSrcCatDlg.open(); - if (saveInfo != null && saveInfo == true) { + if ((saveInfo != null) && (saveInfo == true)) { String name = newSrcCatDlg.getTextKey(); String desc = newSrcCatDlg.getDescription(); @@ -1251,17 +1255,15 @@ public class AlertVisConfigDlg extends Dialog implements gConfig.setMode(layoutControls.getSelectedLayoutTrayMode()); // Mandatory // to be // HERE! - if (alertMsgDlg != null) { - gConfig.setPosition(alertMsgDlg.getCurrentLocation()); - } } /** * Populate the priority controls. */ private void populatePriorityControls() { - if (priorityControls == null) + if (priorityControls == null) { return; + } int index = sourcesList.getSelectionIndex(); diff --git a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertVisualization.java b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertVisualization.java index fe644671d8..0ff2c8bf47 100644 --- a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertVisualization.java +++ b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertVisualization.java @@ -22,12 +22,15 @@ package com.raytheon.uf.viz.alertviz.ui.dialogs; import java.io.File; import org.eclipse.equinox.app.IApplication; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MenuDetectEvent; import org.eclipse.swt.events.MenuDetectListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Display; @@ -35,7 +38,6 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.ToolTip; import org.eclipse.swt.widgets.Tray; @@ -96,6 +98,10 @@ import com.raytheon.uf.viz.core.VizApp; * 18 Mar 2015 4234 njensen Remove reference to non-working python * 03 Jun 2015 4473 njensen Updated for new AlertvizJob API * 29 Jun 2015 4311 randerso Reworking AlertViz dialogs to be resizable. + * 28 Oct 2015 5054 randerso Call AlertVisualization.dispose() on restart so all the + * other dispose methods are called. + * 25 Jan 2016 5054 randerso Removed dummy parent shell + * 08 Feb 2016 5312 randerso Changed to build tray menu on demand * * * @@ -106,11 +112,6 @@ import com.raytheon.uf.viz.core.VizApp; public class AlertVisualization implements ITimerAction, IAudioAction, IAlertArrivedCallback, Listener, IConfigurationChangedListener, IRestartListener { - /** - * Dialog shell. - */ - protected Shell shell; - /** * The display control. */ @@ -136,35 +137,10 @@ public class AlertVisualization implements ITimerAction, IAudioAction, */ private TrayItem trayItem; - /** - * A pop-up menu for the tray item. - */ - protected Menu trayItemMenu; - - /** - * Show alert visualization menu item. - */ - private MenuItem showAlertDialogMI; - - /** - * Do not disturb menu item. - */ - private MenuItem doNotDisturbMI; - - /** - * Show alert dialog popup menu item - */ - private MenuItem showPopup; - - /** - * Acknowledge all alerts menu item - */ - private MenuItem ackAll; - /** * Alert message dialog. */ - private AlertMessageDlg alertMessageDlg; + protected AlertMessageDlg alertMessageDlg; /** * Text blink count variable. @@ -211,6 +187,10 @@ public class AlertVisualization implements ITimerAction, IAudioAction, */ private boolean showAlertDlg = true; + private boolean ackAll = false; + + private boolean showPopup = false; + /** * Tool tip. */ @@ -221,8 +201,6 @@ public class AlertVisualization implements ITimerAction, IAudioAction, */ protected final boolean runningStandalone; - private Rectangle prevLocation = null; - private ConfigContext configContext; private Configuration prevConfigFile; @@ -245,15 +223,6 @@ public class AlertVisualization implements ITimerAction, IAudioAction, showAlertDlg = Boolean.getBoolean("ShowAlertVizBar"); doNotDisturb = true; } - initShell(); - } - - /** - * Initialize a main shell. - */ - private void initShell() { - shell = new Shell(display); - initializeComponents(); AlertvizJob.getInstance().addAlertArrivedCallback(this); @@ -295,10 +264,6 @@ public class AlertVisualization implements ITimerAction, IAudioAction, alertMessageDlg.dispose(); } - if (shell != null) { - shell.dispose(); - } - if (display != null) { display.dispose(); } @@ -322,9 +287,9 @@ public class AlertVisualization implements ITimerAction, IAudioAction, * Initialize the alert message dialog. */ private void initAlertMessageDialog() { - alertMessageDlg = new AlertMessageDlg(shell, this, showAlertDlg, + alertMessageDlg = new AlertMessageDlg(display, this, showAlertDlg, configData, audioMgr); - display.asyncExec(new Runnable() { + display.syncExec(new Runnable() { @Override public void run() { alertMessageDlg.open(); @@ -361,14 +326,13 @@ public class AlertVisualization implements ITimerAction, IAudioAction, trayItem = new TrayItem(tray, SWT.NONE); updateToolTip(); - trayItemMenu = new Menu(shell, SWT.POP_UP); - - createTrayMenuItems(); - // Right click action trayItem.addMenuDetectListener(new MenuDetectListener() { @Override public void menuDetected(MenuDetectEvent de) { + Menu trayItemMenu = new Menu(alertMessageDlg.getShell(), + SWT.POP_UP); + createTrayMenuItems(trayItemMenu); trayItemMenu.setVisible(true); } }); @@ -389,10 +353,12 @@ public class AlertVisualization implements ITimerAction, IAudioAction, /** * Create the tray menu items. + * + * @param menu */ - protected void createTrayMenuItems() { + protected void createTrayMenuItems(Menu menu) { - showAlertDialogMI = new MenuItem(trayItemMenu, SWT.CHECK); + MenuItem showAlertDialogMI = new MenuItem(menu, SWT.CHECK); showAlertDialogMI.setText("Show Alert Dialog"); showAlertDialogMI.setSelection(showAlertDlg); showAlertDialogMI.addSelectionListener(new SelectionAdapter() { @@ -411,20 +377,21 @@ public class AlertVisualization implements ITimerAction, IAudioAction, }); if (Boolean.getBoolean("SystemTray")) { - doNotDisturbMI = new MenuItem(trayItemMenu, SWT.CHECK); + MenuItem doNotDisturbMI = new MenuItem(menu, SWT.CHECK); doNotDisturbMI.setText("Do Not Disturb"); doNotDisturbMI.setSelection(doNotDisturb); doNotDisturbMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - doNotDisturb = doNotDisturbMI.getSelection(); + MenuItem item = (MenuItem) event.widget; + doNotDisturb = item.getSelection(); } }); } - new MenuItem(trayItemMenu, SWT.SEPARATOR); + new MenuItem(menu, SWT.SEPARATOR); - MenuItem configTrayMI = new MenuItem(trayItemMenu, SWT.NONE); + MenuItem configTrayMI = new MenuItem(menu, SWT.NONE); configTrayMI.setText("Configuration..."); configTrayMI.addSelectionListener(new SelectionAdapter() { @Override @@ -433,7 +400,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction, } }); - MenuItem viewLogMI = new MenuItem(trayItemMenu, SWT.NONE); + MenuItem viewLogMI = new MenuItem(menu, SWT.NONE); viewLogMI.setText("System Log..."); viewLogMI.addSelectionListener(new SelectionAdapter() { SimpleLogViewer slv = null; @@ -441,7 +408,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction, @Override public void widgetSelected(SelectionEvent event) { if ((slv == null) || slv.isDisposed()) { - slv = new SimpleLogViewer(shell); + slv = new SimpleLogViewer(display); slv.open(); } else { slv.bringToTop(); @@ -449,22 +416,23 @@ public class AlertVisualization implements ITimerAction, IAudioAction, } }); - new MenuItem(trayItemMenu, SWT.SEPARATOR); + new MenuItem(menu, SWT.SEPARATOR); - showPopup = new MenuItem(trayItemMenu, SWT.NONE); - showPopup.setText("Show Alert Popup Dialog..."); - showPopup.setEnabled(false); - showPopup.addSelectionListener(new SelectionAdapter() { + MenuItem showPopupMI = new MenuItem(menu, SWT.NONE); + showPopupMI.setText("Show Alert Popup Dialog..."); + showPopupMI.setEnabled(showPopup && (alertPopupDlg != null) + && !alertPopupDlg.isOpen()); + showPopupMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { openAlertPopupDialog(); } }); - ackAll = new MenuItem(trayItemMenu, SWT.NONE); - ackAll.setText("Acknowledge All Messages"); - ackAll.setEnabled(false); - ackAll.addSelectionListener(new SelectionAdapter() { + MenuItem ackAllMI = new MenuItem(menu, SWT.NONE); + ackAllMI.setText("Acknowledge All Messages"); + ackAllMI.setEnabled(ackAll); + ackAllMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { if (alertPopupDlg != null) { @@ -479,16 +447,31 @@ public class AlertVisualization implements ITimerAction, IAudioAction, }); if (this.runningStandalone) { - new MenuItem(trayItemMenu, SWT.SEPARATOR); - MenuItem restartMI = new MenuItem(trayItemMenu, SWT.NONE); + new MenuItem(menu, SWT.SEPARATOR); + MenuItem restartMI = new MenuItem(menu, SWT.NONE); restartMI.setText("Restart"); restartMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION - | SWT.YES | SWT.NO); - mb.setMessage("Any unsaved changes will be lost. Restart anyway?"); - if (mb.open() == SWT.YES) { + MessageDialog dialog = new MessageDialog( + alertMessageDlg.getShell(), + "Confirm Restart!", + null, + "Any unsaved changes will be lost. Restart anyway?", + MessageDialog.QUESTION, new String[] { + IDialogConstants.YES_LABEL, + IDialogConstants.NO_LABEL }, 0); + + dialog.create(); + + // center dialog on display + Shell shell = dialog.getShell(); + Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); + Rectangle bounds = alertMessageDlg.getShell().getMonitor() + .getBounds(); + shell.setLocation(bounds.x + ((bounds.width - size.x) / 2), + bounds.y + ((bounds.height - size.y) / 2)); + if (dialog.open() == 0) { restart(); } } @@ -586,7 +569,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction, if ((configDlg != null) && !configDlg.isDisposed()) { configDlg.close(); } - configDlg = new AlertVisConfigDlg(shell, alertMessageDlg, configData, + configDlg = new AlertVisConfigDlg(display, alertMessageDlg, configData, configContext, this, this); configDlg.open(); } @@ -608,7 +591,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction, final AlertMetadata amd, final Category cat, final TrayConfiguration gConfig) { - if (shell.isDisposed()) { + if ((alertMessageDlg == null) || alertMessageDlg.isDisposed()) { Container.logInternal(Priority.ERROR, statMsg.getMessage() + "\n" + statMsg.getDetails()); return; @@ -690,10 +673,10 @@ public class AlertVisualization implements ITimerAction, IAudioAction, // Pop-up message if (amd.isPopup() == true) { if (alertPopupDlg == null) { - alertPopupDlg = new AlertPopupMessageDlg(shell, statMsg, + alertPopupDlg = new AlertPopupMessageDlg(display, statMsg, gConfig.isExpandedPopup(), this, amd.getBackground()); - showPopup.setEnabled(true); - ackAll.setEnabled(true); + showPopup = true; + ackAll = true; startBlinkTrayTimer(); } else { alertPopupDlg.addNewMessage(statMsg, amd); @@ -761,7 +744,8 @@ public class AlertVisualization implements ITimerAction, IAudioAction, toolTip.dispose(); } - toolTip = new ToolTip(shell, SWT.BALLOON | SWT.ICON_WARNING); + toolTip = new ToolTip(alertMessageDlg.getShell(), SWT.BALLOON + | SWT.ICON_WARNING); toolTip.setText(cat.getCategoryName()); toolTip.setMessage(statMsg.getMessage()); @@ -797,6 +781,9 @@ public class AlertVisualization implements ITimerAction, IAudioAction, } } + /** + * @return the exit status + */ public Integer getExitStatus() { return exitStatus; } @@ -809,8 +796,8 @@ public class AlertVisualization implements ITimerAction, IAudioAction, public void handleEvent(Event event) { switch (event.type) { case SWT.Hide: - ackAll.setEnabled(true); - showPopup.setEnabled(true); + ackAll = true; + showPopup = true; startBlinkTrayTimer(); updateToolTip(); break; @@ -819,8 +806,9 @@ public class AlertVisualization implements ITimerAction, IAudioAction, alertPopupDlg = null; cancelTimer(); updateToolTip(); - ackAll.setEnabled(false); - showPopup.setEnabled(false); + + ackAll = false; + showPopup = false; break; default: Container.logInternal(Priority.WARN, "Unexpected event type: " @@ -838,7 +826,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction, // such as Integer(1) the executable attempts to bring // up an error screen before exiting with the error code. exitStatus = IApplication.EXIT_RELAUNCH; - display.dispose(); + this.dispose(); } } @@ -848,19 +836,16 @@ public class AlertVisualization implements ITimerAction, IAudioAction, configData = ConfigurationManager.getInstance() .getCurrentConfiguration(); configContext = ConfigurationManager.getInstance().getCurrentContext(); - if ((alertMessageDlg != null) && (showAlertDialogMI != null)) { + if (alertMessageDlg != null) { alertMessageDlg.setConfigData(configData); if (configData.isMonitorLayoutChanged(prevConfigFile)) { if (alertMessageDlg.reLayout()) { - showAlertDialogMI.setEnabled(true); + showAlertDlg = true; } prevConfigFile = configData.clone(); } audioMgr = alertMessageDlg.getAlertAudioManager(); } - // if (configDlg != null && !configDlg.isDisposed()) { - // configDlg.restart(requestRestart); - // } } /** diff --git a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/FileSelectDlg.java b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/FileSelectDlg.java index d6ca0ce033..73de31a51b 100644 --- a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/FileSelectDlg.java +++ b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/FileSelectDlg.java @@ -34,7 +34,6 @@ import java.util.Vector; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -55,7 +54,6 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -73,6 +71,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * 07 Dec 2010 6531 cjeanbap Refactored class to be an Abstract class. * 02 Mar 2011 5632 cjeanbap Update Listbox title text * 06 May 2011 9101 cjeanbap Changed Constructor method signature. + * 12 Nov 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * * * * @author lvenable @@ -268,7 +268,7 @@ public class FileSelectDlg extends Dialog { fileList.add(locFile.getFile(false).getName()); } fileList.select(getIndex()); - fileList.addSelectionListener(new SelectionListener() { + fileList.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { selectedIndex = fileList.getSelectionIndex(); @@ -287,10 +287,6 @@ public class FileSelectDlg extends Dialog { associatedTextBox.setText(name); } } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } }); } @@ -313,6 +309,7 @@ public class FileSelectDlg extends Dialog { okBtn.setText("OK"); okBtn.setLayoutData(gd); okBtn.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { returnObj = true; shell.dispose(); @@ -324,6 +321,7 @@ public class FileSelectDlg extends Dialog { cancelBtn.setText("Cancel"); cancelBtn.setLayoutData(gd); cancelBtn.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { if (isSelected()) { returnObj = false; @@ -339,6 +337,7 @@ public class FileSelectDlg extends Dialog { importNewBtn1.setText("Import"); importNewBtn1.setLayoutData(gd); importNewBtn1.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { FileDialog newFileDlg = new FileDialog(shell, SWT.OPEN | SWT.SINGLE); @@ -368,10 +367,7 @@ public class FileSelectDlg extends Dialog { } setSelectedFile(newFile.getName()); } - } catch (LocalizationOpFailedException e) { - statusHandler.handle(Priority.PROBLEM, - e.getLocalizedMessage(), e); - } catch (IOException e) { + } catch (LocalizationException | IOException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); } @@ -382,7 +378,7 @@ public class FileSelectDlg extends Dialog { } private boolean saveToLocalizationFile(File file, LocalizationFile locFile) - throws IOException, LocalizationOpFailedException { + throws IOException, LocalizationException { File newFile = locFile.getFile(); InputStream in = new FileInputStream(file); OutputStream out = new FileOutputStream(newFile); diff --git a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/SimpleLogViewer.java b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/SimpleLogViewer.java index e050c65880..27eebc25e8 100644 --- a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/SimpleLogViewer.java +++ b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/SimpleLogViewer.java @@ -20,9 +20,14 @@ package com.raytheon.uf.viz.alertviz.ui.dialogs; import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Collection; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.swt.SWT; @@ -36,7 +41,6 @@ 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.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.FileDialog; @@ -71,6 +75,8 @@ import com.raytheon.uf.viz.alertviz.config.TrayConfiguration; * Jun 02, 2015 4473 njensen Cleaned up warnings * Jul 01, 2015 4473 njensen Fix update of table on alert arrival * Jun 29, 2015 4311 randerso Reworking AlertViz dialogs to be resizable. + * Jan 25, 2016 5054 randerso Converted to stand alone window + * Feb 11, 2016 5314 dgilling Fix System Log functionality. * * * @@ -78,7 +84,7 @@ import com.raytheon.uf.viz.alertviz.config.TrayConfiguration; * @version 1.0 */ -public class SimpleLogViewer extends Dialog implements IAlertArrivedCallback { +public class SimpleLogViewer implements IAlertArrivedCallback { private Display display; @@ -88,8 +94,6 @@ public class SimpleLogViewer extends Dialog implements IAlertArrivedCallback { private Button showLog; - int[] range; - private Table table; private Color yellow; @@ -104,13 +108,12 @@ public class SimpleLogViewer extends Dialog implements IAlertArrivedCallback { /** * - * @param parent + * @param display */ - public SimpleLogViewer(Shell parent) { - super(parent, SWT.NONE); + public SimpleLogViewer(Display display) { first = true; - display = parent.getDisplay(); + this.display = display; // Create a new shell object and set the text for the dialog. shell = new Shell(display, SWT.DIALOG_TRIM | SWT.MIN | SWT.TITLE @@ -171,15 +174,10 @@ public class SimpleLogViewer extends Dialog implements IAlertArrivedCallback { columns[3].setWidth(100); columns[4].setText("Message"); columns[4].setWidth(100); + int sz = 0; try { - range = SystemStatusHandler.getCurrentRange(); - if ((range[0] == 0) && (range[1] == 0)) { - // database is empty - sz = 0; - } else { - sz = (range[1] - range[0]) + 1; - } + sz = SystemStatusHandler.getMessageCount(); } catch (AlertvizException e2) { Container .logInternal( @@ -199,17 +197,27 @@ public class SimpleLogViewer extends Dialog implements IAlertArrivedCallback { table.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { + Integer pk = (Integer) e.item.getData(); int idx = table.getSelectionIndex(); + StatusMessage sm = null; try { - - sm = SystemStatusHandler.retrieveByPk(idx + range[0]); + /* + * This event is triggered during initialization before the + * first TableItem has been assigned a PK in its data field. + * So we fall back to item selection index just in case. + */ + if (pk != null) { + sm = SystemStatusHandler.retrieveByPk(pk.intValue()); + } else { + sm = SystemStatusHandler.retrieveByRowOffset(idx); + } } catch (Exception e1) { Container .logInternal( Priority.ERROR, "SimpleLogViewer: exception retrieving StatusMessage by key from SystemStatusHandler: " - + (idx + range[0]), e1); + + (idx + 1), e1); } detailsComp.displayDetails(sm); } @@ -227,12 +235,13 @@ public class SimpleLogViewer extends Dialog implements IAlertArrivedCallback { int index = table.indexOf(item); try { StatusMessage sm = SystemStatusHandler - .retrieveByPk(range[0] + index); + .retrieveByRowOffset(index); item.setText(0, "" + sm.getEventTime().toString()); item.setText(1, "" + sm.getPriority().ordinal()); item.setText(2, sm.getSourceKey()); item.setText(3, sm.getCategory()); item.setText(4, sm.getMessage()); + item.setData(Integer.valueOf(sm.getPk())); if (sm.getPriority() == Priority.CRITICAL) { item.setForeground(red); @@ -247,14 +256,15 @@ public class SimpleLogViewer extends Dialog implements IAlertArrivedCallback { } } catch (AlertvizException e1) { - Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID, - "Error fetching the data", e1); - ErrorDialog.openError( - Display.getCurrent().getActiveShell(), - "Error fetching data", - "Error fetching the log data", s); + Container + .logInternal( + Priority.ERROR, + "SimpleLogViewer: exception retrieving StatusMessage by row offset from SystemStatusHandler: " + + index, e1); + errorDialogWithStackTrace(Display.getCurrent() + .getActiveShell(), "Error fetching data", + "Error fetching the log data", e1); } - } }); @@ -281,10 +291,12 @@ public class SimpleLogViewer extends Dialog implements IAlertArrivedCallback { LogUtil.saveLogToFile(new File(fileName), new Timestamp(0), Order.AFTER); } catch (AlertvizException e1) { - final Status s = new Status(IStatus.ERROR, - Activator.PLUGIN_ID, "Error saving log", e1); - ErrorDialog.openError(shell, "Error saving log", - "Error saving log", s); + Container.logInternal(Priority.ERROR, + "SimpleLogViewer: exception saving log file: " + + fileName, e1); + errorDialogWithStackTrace(Display.getCurrent() + .getActiveShell(), "Error saving log", + "Error saving log", e1); } } } @@ -356,8 +368,11 @@ public class SimpleLogViewer extends Dialog implements IAlertArrivedCallback { AlertvizJob.getInstance().addAlertArrivedCallback(this); shell.open(); - table.showItem(table.getItem(table.getItemCount() - 1)); - table.select(table.getItemCount() - 1); + + if (table.getItemCount() > 0) { + table.showItem(table.getItem(table.getItemCount() - 1)); + table.select(table.getItemCount() - 1); + } // Wait until the shell is disposed. Display display = shell.getDisplay(); @@ -404,4 +419,26 @@ public class SimpleLogViewer extends Dialog implements IAlertArrivedCallback { size.y += delta; shell.setSize(size); } + + private static void errorDialogWithStackTrace(Shell parentShell, + String dialogTitle, String msg, Throwable t) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + t.printStackTrace(pw); + String trace = sw.toString(); + + Collection childStatuses = new ArrayList<>(); + + String lineSep = System.getProperty("line.separator"); + for (String line : trace.split(lineSep)) { + childStatuses.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, + line)); + } + + MultiStatus ms = new MultiStatus(Activator.PLUGIN_ID, IStatus.ERROR, + childStatuses.toArray(new Status[0]), t.getLocalizedMessage(), + t); + + ErrorDialog.openError(parentShell, dialogTitle, msg, ms); + } } diff --git a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/TmpFileSelectDlg.java b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/TmpFileSelectDlg.java deleted file mode 100644 index 59cad56ce5..0000000000 --- a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/TmpFileSelectDlg.java +++ /dev/null @@ -1,248 +0,0 @@ -package com.raytheon.uf.viz.alertviz.ui.dialogs; - -import java.io.File; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Font; -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.Dialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Shell; - -import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.localization.PathManagerFactory; - -public abstract class TmpFileSelectDlg extends Dialog { - - /** - * Dialog shell. - */ - private Shell shell; - - /** - * The display control. - */ - private Display display; - - /** - * Control font. - */ - private Font controlFont; - - /** - * Sound file list control. - */ - private List soundFileList; - - /** - * Return object when the shell is disposed. - */ - private Boolean returnObj = null; - - /** - * Array of localization files. - */ - private LocalizationFile[] locFiles; - - /** - * Current sound file. - */ - public File currentFile; - - /** - * New sound file. - */ - private File newFile; - - private String path; - - private String fileExtension; - - public TmpFileSelectDlg(Shell parent, int style) { - super(parent, style); - } - - /** - * Open method used to display the dialog. - * - * @param audioFile - * The name of the audio file, if null default to index 0. - * @return True/False. - */ - public Object open(String title, String actionFile) { - Shell parent = getParent(); - display = parent.getDisplay(); - shell = new Shell(parent, SWT.TITLE); - //shell.setText("Action File Selection"); - - // Create the main layout for the shell. - GridLayout mainLayout = new GridLayout(1, false); - mainLayout.marginHeight = 2; - mainLayout.marginWidth = 2; - mainLayout.verticalSpacing = 2; - shell.setLayout(mainLayout); - - // Initialize all of the controls and layouts - initializeComponents(); - - if (actionFile != null) { - setSelectedAudioFile(actionFile); - } - - shell.pack(); - shell.open(); - - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } - } - - controlFont.dispose(); - - return returnObj; - } - - /** - * Initialize the controls on the display. - */ - private void initializeComponents() { - controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); - - createListControl(); - // Create the buttons at the bottom of the display. - createBottomButtons(); - - getAvailableFiles(); - } - - /** - * Set the selected index of file list object based upon the - * audio file. - * - * @param audioFile The name of the audio file. - */ - private void setSelectedAudioFile(String audioFile) { - String[] audioFiles = soundFileList.getItems(); - int index = 0; - for (int i = 0; i < audioFiles.length; i++) { - if (audioFile.endsWith(audioFiles[i])) { - index = i; - break; - } - } - soundFileList.select(index); - } - - /** - * Create the list control. - */ - private void createListControl() { - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - Composite listComp = new Composite(shell, SWT.NONE); - listComp.setLayout(new GridLayout(1, false)); - listComp.setLayoutData(gd); - - Label listLbl = new Label(listComp, SWT.NONE); - listLbl.setText("Available Sound Files:"); - - gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.widthHint = 400; - gd.heightHint = 400; - gd.horizontalSpan = 2; - soundFileList = new List(listComp, SWT.BORDER | SWT.SINGLE - | SWT.V_SCROLL | SWT.H_SCROLL); - soundFileList.setLayoutData(gd); - soundFileList.setFont(controlFont); - } - - /** - * Create the buttons at the bottom of the dialog. - */ - private void createBottomButtons() { - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - Composite mainButtonComp = new Composite(shell, SWT.NONE); - mainButtonComp.setLayout(new GridLayout(1, false)); - mainButtonComp.setLayoutData(gd); - - gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false); - Composite buttonComp = new Composite(shell, SWT.NONE); - buttonComp.setLayout(new GridLayout(2, false)); - buttonComp.setLayoutData(gd); - - gd = new GridData(100, SWT.DEFAULT); - Button okBtn = new Button(buttonComp, SWT.PUSH); - okBtn.setText("OK"); - okBtn.setLayoutData(gd); - okBtn.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - if (soundFileList.getSelectionIndex() != 0) { - newFile = locFiles[soundFileList.getSelectionIndex()].getFile(); - } else { - newFile = locFiles[0].getFile(); - } - returnObj = true; - shell.dispose(); - } - }); - - gd = new GridData(100, SWT.DEFAULT); - Button cancelBtn = new Button(buttonComp, SWT.PUSH); - cancelBtn.setText("Cancel"); - cancelBtn.setLayoutData(gd); - cancelBtn.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - returnObj = false; - shell.dispose(); - } - }); - } - - /** - * Get the list of available sound files. - */ - private void getAvailableFiles() { - String[] extensions = new String[] { fileExtension }; - locFiles = PathManagerFactory.getPathManager().listStaticFiles( - path, extensions, true, true); - - for (int i = 0; i < locFiles.length; i++) { - soundFileList.add(locFiles[i].getName()); - } - - if (currentFile != null) { - soundFileList.select(soundFileList.indexOf(currentFile - .getName())); - } - } - - /** - * Get the selected sound file. - * - * @return The sound file. - */ - public File getSelectedFile() { - return newFile; - } - - public void setFileExtension(String fileExtension) { - this.fileExtension = fileExtension; - } - - public void setFile(String file) { - if (file != null) { - this.currentFile = new File(file); - } - } - - public void setFilesLocationPath(String path) { - this.path = path; - } -} \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/ConfigurationManager.java b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/ConfigurationManager.java index c342b796a5..d8bae169e6 100644 --- a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/ConfigurationManager.java +++ b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/ConfigurationManager.java @@ -19,11 +19,8 @@ **/ package com.raytheon.uf.viz.alertviz; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; import java.io.IOException; +import java.io.InputStream; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -34,13 +31,15 @@ import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; +import com.raytheon.uf.common.localization.SaveableOutputStream; +import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; @@ -58,14 +57,18 @@ import com.raytheon.uf.viz.alertviz.config.Source; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Apr 7, 2010 mschenke Initial creation + * Apr 07, 2010 mschenke Initial creation * Mar 16, 2011 6531 rferrel Start up loads host dependent * configuration file. - * Aug 28 2012 13528 Xiaochuan Using setNewConfiguration() to + * Aug 28, 2012 13528 Xiaochuan Using setNewConfiguration() to * re-set configuration data and * run notifyListeners(). - * Apr 07 2015 4346 rferrel Created {@link #retrieveBaseConfiguration()}. + * Apr 07, 2015 4346 rferrel Created {@link #retrieveBaseConfiguration}. * May 20, 2015 4346 rjpeter Updated to also load from common_static. + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated ILocalizationFile methods + * Feb 12, 2016 4834 bsteffen Fix multiple saves of the customConfiguration. + * * * * @author mschenke @@ -166,7 +169,7 @@ public class ConfigurationManager { ConfigContext workstationContext = DEFAULT_WORKSTATION_CONFIG; try { - LocalizationFile file = getLocalizationFile(workstationContext); + ILocalizationFile file = getLocalizationFile(workstationContext); if (file == null || !file.exists()) { ConfigContext sourceContext = DEFAULT_SITE_CONFIG; @@ -262,7 +265,7 @@ public class ConfigurationManager { /** * Delete the configuration passed in * - * @param name + * @param context */ public void deleteConfiguration(ConfigContext context) { if (context.isBaseOrConfiguredLevel() || isDefaultConfig(context)) { @@ -272,7 +275,7 @@ public class ConfigurationManager { if (current.equals(context)) { loadAsCurrent(DEFAULT_WORKSTATION_CONFIG); } - LocalizationFile file = getLocalizationFile(context); + ILocalizationFile file = getLocalizationFile(context); try { file.delete(); } catch (Exception e) { @@ -317,10 +320,10 @@ public class ConfigurationManager { private void loadFromLocalizationType(LocalizationType type) { IPathManager pm = PathManagerFactory.getPathManager(); LocalizationContext[] contexts = pm.getLocalSearchHierarchy(type); - LocalizationFile[] files = pm.listFiles(contexts, CONFIG_DIR, + ILocalizationFile[] files = pm.listFiles(contexts, CONFIG_DIR, EXTENSIONS, true, true); // Win32 - for (LocalizationFile file : files) { + for (ILocalizationFile file : files) { LocalizationContext fileContext = file.getContext(); /* @@ -329,8 +332,8 @@ public class ConfigurationManager { */ if ((fileContext.getLocalizationLevel() != LocalizationLevel.BASE) || ((fileContext.getLocalizationLevel() == LocalizationLevel.BASE) && DEFAULT_BASE_CONFIG - .getLocalizationFileName().equals(file.getName()))) { - String fileName = file.getName(); + .getLocalizationFileName().equals(file.getPath()))) { + String fileName = file.getPath(); LocalizationContext locContext = file.getContext(); String name = fileName.substring( fileName.lastIndexOf(IPathManager.SEPARATOR) + 1, // win32 @@ -362,7 +365,7 @@ public class ConfigurationManager { } public Configuration retrieveConfiguration(ConfigContext configContext) { - LocalizationFile file = getLocalizationFile(configContext); + ILocalizationFile file = getLocalizationFile(configContext); if (DEFAULT_BASE_CONFIG.equals(configContext)) { if (baseConfiguration == null) { baseConfiguration = retrieveBaseConfiguration(); @@ -379,7 +382,7 @@ public class ConfigurationManager { * @return configuration */ private Configuration retrieveBaseConfiguration() { - LocalizationFile file = getLocalizationFile(DEFAULT_BASE_CONFIG); + ILocalizationFile file = getLocalizationFile(DEFAULT_BASE_CONFIG); Configuration configuration = retrieveConfiguration(file); configuration = mergeBaseConfigurations(LocalizationType.CAVE_STATIC, configuration); @@ -393,12 +396,12 @@ public class ConfigurationManager { IPathManager pm = PathManagerFactory.getPathManager(); LocalizationContext context = pm.getContext(type, LocalizationLevel.BASE); - LocalizationFile[] files = pm.listFiles(context, CONFIG_DIR, + ILocalizationFile[] files = pm.listFiles(context, CONFIG_DIR, EXTENSIONS, false, true); - for (LocalizationFile f : files) { + for (ILocalizationFile f : files) { // Merge other base files with the default. if (!DEFAULT_BASE_CONFIG.getLocalizationFileName().equals( - f.getName())) { + f.getPath())) { Configuration fileConfig = retrieveConfiguration(f); Configuration mergeConfig = configuration.mergeUnder( fileConfig, true); @@ -409,14 +412,11 @@ public class ConfigurationManager { return configuration; } - public Configuration retrieveConfiguration(LocalizationFile file) { + public Configuration retrieveConfiguration(ILocalizationFile file) { Configuration config = null; - if (file != null) { + if (file != null && file.exists()) { try { - File actualFile = file.getFile(); - if (actualFile != null && actualFile.exists()) { - config = (Configuration) deserializeFromFile(actualFile); - } + config = (Configuration) deserializeFromFile(file); } catch (SerializationException e) { statusHandler.handle(Priority.CRITICAL, "Error deserializing configuration xml", e); @@ -427,18 +427,12 @@ public class ConfigurationManager { private boolean saveToFile(ConfigContext cContext, Configuration config) { boolean success = true; - LocalizationFile file = getLocalizationFile(cContext); + ILocalizationFile file = getLocalizationFile(cContext); try { // do not attempt to save to base if (file != null && file.getContext().getLocalizationLevel() != LocalizationLevel.BASE) { - serializeToFile(config, file.getFile()); - if (!file.save()) { - // failed to save delete the local copy and switch to the - // default config. - file.delete(); - success = false; - } + serializeToFile(config, file); } } catch (SerializationException e) { statusHandler.handle(Priority.CRITICAL, @@ -468,62 +462,27 @@ public class ConfigurationManager { } } - private void serializeToFile(Object obj, File file) + private void serializeToFile(Object obj, ILocalizationFile file) throws SerializationException { - FileWriter writer = null; - Marshaller msh = marshaller; - try { - File dir = file.getParentFile(); - if (dir.isDirectory() == false) { - dir.delete(); - dir.mkdirs(); - } - msh.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, new Boolean(true)); - writer = new FileWriter(file); - msh.marshal(obj, writer); + try (SaveableOutputStream os = file.openOutputStream()) { + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, + new Boolean(true)); + marshaller.marshal(obj, os); + os.save(); } catch (Exception e) { throw new SerializationException(e); - } finally { - if (writer != null) { - try { - writer.close(); - } catch (IOException e) { - // Log to internal Log4j log - Container - .logInternal( - Priority.ERROR, - "ConfigurationManager: exception closing file writer.", - e); - } - } } } - private Object deserializeFromFile(File file) throws SerializationException { - FileReader reader = null; - Unmarshaller msh = unmarshaller; - try { - reader = new FileReader(file); - Object obj = msh.unmarshal(reader); - return obj; - } catch (FileNotFoundException e) { + private Object deserializeFromFile(ILocalizationFile file) + throws SerializationException { + try (InputStream is = file.openInputStream()) { + return unmarshaller.unmarshal(is); + } catch (LocalizationException | IOException | JAXBException e) { Container.logInternal(Priority.ERROR, - "AlertViz ConfigurationManager unable to find file: " - + file.getAbsolutePath(), e); + "ConfigurationManager: Exception unmarshalling from file: " + + file.getPath(), e); throw new SerializationException(e); - } catch (JAXBException e) { - Container.logInternal(Priority.ERROR, - "ConfigurationManager: JAXB exception unmarshalling from file: " - + file.getAbsolutePath(), e); - throw new SerializationException(e); - } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException e) { - // ignore - } - } } } @@ -531,15 +490,12 @@ public class ConfigurationManager { IPathManager pm = PathManagerFactory.getPathManager(); LocalizationContext ctx = pm.getContext(LocalizationType.CAVE_STATIC, LocalizationLevel.SITE); - LocalizationFile file = pm.getLocalizationFile(ctx, + ILocalizationFile file = pm.getLocalizationFile(ctx, ConfigContext.ALERTVIZ_DIR + IPathManager.SEPARATOR + "AlertVizForced.xml"); - File actualFile = file.getFile(); - // Win32: JHB put in check for length - if (actualFile != null && actualFile.exists() - && actualFile.length() > 0) { - try { - return (ForcedConfiguration) unmarshaller.unmarshal(actualFile); + if (file != null && file.exists()) { + try (InputStream is = file.openInputStream()) { + return (ForcedConfiguration) unmarshaller.unmarshal(is); } catch (Exception e) { statusHandler.handle(Priority.SIGNIFICANT, "Error deserializing forced configuration", e); @@ -569,10 +525,9 @@ public class ConfigurationManager { } private void updateCustom(boolean isRemove, Object obj) { - LocalizationFile locFile = getCustomLocalization(); - File customFile = locFile.getFile(); + ILocalizationFile locFile = getCustomLocalization(); try { - customConfiguration = (Configuration) deserializeFromFile(customFile); + customConfiguration = (Configuration) deserializeFromFile(locFile); if (obj instanceof Category) { Map categories = customConfiguration .getCategories(); @@ -594,12 +549,11 @@ public class ConfigurationManager { } customConfiguration.setSources(sources); } - serializeToFile(customConfiguration, customFile); - locFile.save(); + serializeToFile(customConfiguration, locFile); + /* Must reload fresh copy next time it is used. */ + customLocalization = null; } catch (SerializationException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); - } catch (LocalizationOpFailedException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); } } diff --git a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/Container.java b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/Container.java index 1055429a89..8e39311a64 100755 --- a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/Container.java +++ b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/Container.java @@ -28,7 +28,6 @@ import org.apache.log4j.Logger; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.message.StatusMessage; @@ -58,6 +57,7 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager; * Jun 03, 2013 2026 randerso Fixed typo * Jul 27, 2015 4654 skorolev Added a localization level filtration * Sep 21, 2015 4654 njensen Made filter logic strict instead of eager + * Jan 14, 2016 5054 randerso Remove dummy shell * * * @@ -315,7 +315,7 @@ public class Container implements IConfigurationChangedListener { } // Status status = null; - ErrorDialog.openError(new Shell(), + ErrorDialog.openError(null, "Error saving to internal database", "Serious internal error occurred", new Status( IStatus.ERROR, Activator.PLUGIN_ID, diff --git a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/SystemStatusHandler.java b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/SystemStatusHandler.java index 3dc084ca28..e6855f447e 100644 --- a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/SystemStatusHandler.java +++ b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/SystemStatusHandler.java @@ -43,6 +43,7 @@ import com.raytheon.uf.viz.alertviz.internal.LogMessageDAO; * Aug 26, 2013 2142 njensen Changed to use SLF4J * Jul 02, 2014 3337 njensen Disabled logback packaging data * May 22, 2015 4473 njensen Refactored + * Feb 11, 2016 5314 dgilling Add retrieveByRowOffset. * * * @author chammack @@ -122,16 +123,30 @@ public class SystemStatusHandler extends AbstractStatusHandler { } /** - * Get the current range of persisted StatusMessages + * Retrieve a status message by row offset * + * @param index + * The row offset, 0-based index. + * @return the status message + * @throws AlertvizException + * If an error occurred querying the database for the status + * message + */ + public static StatusMessage retrieveByRowOffset(int index) + throws AlertvizException { + return LogMessageDAO.getInstance().loadByRowOffset(index); + } + + /** + * Get the current number of persisted StatusMessages. + *

* NOTE: This only works when called from inside the alertviz container * - * - * @return the range [min, max] of values + * @return * @throws AlertvizException */ - public static int[] getCurrentRange() throws AlertvizException { - return LogMessageDAO.getInstance().getLogRange(); + public static int getMessageCount() throws AlertvizException { + return LogMessageDAO.getInstance().getMessageCount(); } /** @@ -148,5 +163,4 @@ public class SystemStatusHandler extends AbstractStatusHandler { int count) throws AlertvizException { return LogMessageDAO.getInstance().load(count, category); } - } diff --git a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/config/Configuration.java b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/config/Configuration.java index 731121cff1..16eeadc243 100644 --- a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/config/Configuration.java +++ b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/config/Configuration.java @@ -31,7 +31,6 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.viz.alertviz.config.TrayConfiguration.TrayMode; /** @@ -49,6 +48,7 @@ import com.raytheon.uf.viz.alertviz.config.TrayConfiguration.TrayMode; * May 3, 2011 9067 cjeanbap Add isMonitorLayoutChanged() method. * Apr 27 2012 13744 Xiaochuan Update isMonitorLayoutChanged() to compare * source size in Previous and current. + * Oct 28, 2005 5054 randerso removed bar position as it was written but never read * * * @@ -57,7 +57,7 @@ import com.raytheon.uf.viz.alertviz.config.TrayConfiguration.TrayMode; */ @XmlAccessorType(XmlAccessType.NONE) @XmlRootElement(name = "alertConfiguration") -public class Configuration implements ISerializableObject { +public class Configuration { @XmlAttribute private String name; @@ -127,7 +127,7 @@ public class Configuration implements ISerializableObject { * Look up a source * * @param componentName - * @return + * @return the source */ public Source lookupSource(String componentName) { return this.sourceMap.get(componentName); @@ -137,7 +137,7 @@ public class Configuration implements ISerializableObject { * Look up a category * * @param componentName - * @return + * @return the category */ public Category lookupCategory(String componentName) { return this.categoryMap.get(componentName); @@ -148,7 +148,7 @@ public class Configuration implements ISerializableObject { * * This is usually used by serialization, not end users. * - * @param collection + * @param sources */ @XmlElement(name = "source") public void setSourceCollection(Source[] sources) { @@ -163,7 +163,7 @@ public class Configuration implements ISerializableObject { * * This is usually used by serialization, not end users. * - * @return + * @return the source collection */ public Source[] getSourceCollection() { return sourceMap.values().toArray(new Source[sourceMap.size()]); @@ -174,7 +174,7 @@ public class Configuration implements ISerializableObject { * * This is usually used by serialization, not end users. * - * @param collection + * @param categories */ @XmlElement(name = "category") public void setCategoryCollection(Category[] categories) { @@ -189,20 +189,27 @@ public class Configuration implements ISerializableObject { * * This is usually used by serialization, not end users. * - * @return + * @return the category collection */ public Category[] getCategoryCollection() { return categoryMap.values().toArray(new Category[categoryMap.size()]); } + /** + * @return the name + */ public String getName() { return name; } + /** + * @param name + */ public void setName(String name) { this.name = name; } + @Override public Configuration clone() { Configuration newConfig = new Configuration(); newConfig.name = name; @@ -225,6 +232,7 @@ public class Configuration implements ISerializableObject { return newConfig; } + @Override public String toString() { String rval = getName() + ":\n"; rval += "\tTrayConfig:\n"; @@ -232,8 +240,7 @@ public class Configuration implements ISerializableObject { + globalConfiguration.getAudioDuration() + " blinkDuration=" + globalConfiguration.getBlinkDuration() + " logLength=" + globalConfiguration.getLogLength() + "\n"; - rval += "\t\t" + "mode=" + globalConfiguration.getMode() + " position=" - + globalConfiguration.getPosition() + "\n"; + rval += "\t\t" + "mode=" + globalConfiguration.getMode() + "\n"; rval += "\t\t" + "categoryShown=" + globalConfiguration.isCategoryShown() + " expandedPopup=" + globalConfiguration.isExpandedPopup() + " priorityShown=" @@ -404,78 +411,80 @@ public class Configuration implements ISerializableObject { } return result; } - + /** - * Determine if a Monitor was added/omitted (enable/disabled) and/or if the Layout of the - * Alert Message Dialog was changed. + * Determine if a Monitor was added/omitted (enable/disabled) and/or if the + * Layout of the Alert Message Dialog was changed. * - * @param configData the current save Configuration Data. - * @return boolean, true if either Monitor and/or Layout was changed otherwise false. + * @param configData + * the current save Configuration Data. + * @return boolean, true if either Monitor and/or Layout was changed + * otherwise false. */ - public boolean isMonitorLayoutChanged(Configuration configData) { - boolean modified = false; + public boolean isMonitorLayoutChanged(Configuration configData) { + boolean modified = false; - TrayMode prevLayoutMode = configData.getGlobalConfiguration().getMode(); - if (!prevLayoutMode.equals(this.getGlobalConfiguration().getMode())) { - modified = true; - } + TrayMode prevLayoutMode = configData.getGlobalConfiguration().getMode(); + if (!prevLayoutMode.equals(this.getGlobalConfiguration().getMode())) { + modified = true; + } - Map prevCategoryMap = configData.getCategories(); - for (Iterator categories = this.getCategories().keySet() - .iterator(); categories.hasNext() && !modified;) { - String categoryName = categories.next(); - Category prevCategory = prevCategoryMap.get(categoryName); - Category newCategory = this.getCategories().get(categoryName); - if (prevCategory != null && newCategory == null) { - modified = true; - } else if (prevCategory == null && newCategory != null) { - modified = true; - } else if (prevCategory != null && newCategory != null) { - if (prevCategory.getTextBox() != newCategory.getTextBox()) { - modified = true; - } - } - } + Map prevCategoryMap = configData.getCategories(); + for (Iterator categories = this.getCategories().keySet() + .iterator(); categories.hasNext() && !modified;) { + String categoryName = categories.next(); + Category prevCategory = prevCategoryMap.get(categoryName); + Category newCategory = this.getCategories().get(categoryName); + if (prevCategory != null && newCategory == null) { + modified = true; + } else if (prevCategory == null && newCategory != null) { + modified = true; + } else if (prevCategory != null && newCategory != null) { + if (prevCategory.getTextBox() != newCategory.getTextBox()) { + modified = true; + } + } + } - Map prevSources = configData.getSources(); + Map prevSources = configData.getSources(); - if (prevSources.size() != this.getSources().size()) { - modified = true; - } else { - for (Iterator sources = this.getSources().keySet() - .iterator(); sources.hasNext() && !modified;) { - String sourceName = sources.next(); - Source prevSource = prevSources.get(sourceName); - Source newSource = this.getSources().get(sourceName); - if (prevSource == null) { - modified = true; - } else if (prevSource != null && newSource != null) { - MonitorMetadata newMonitorMetadata = newSource - .getConfigurationMonitor().getMonitorMetadata(); - MonitorMetadata prevMonitorMetadata = prevSource - .getConfigurationMonitor().getMonitorMetadata(); + if (prevSources.size() != this.getSources().size()) { + modified = true; + } else { + for (Iterator sources = this.getSources().keySet() + .iterator(); sources.hasNext() && !modified;) { + String sourceName = sources.next(); + Source prevSource = prevSources.get(sourceName); + Source newSource = this.getSources().get(sourceName); + if (prevSource == null) { + modified = true; + } else if (prevSource != null && newSource != null) { + MonitorMetadata newMonitorMetadata = newSource + .getConfigurationMonitor().getMonitorMetadata(); + MonitorMetadata prevMonitorMetadata = prevSource + .getConfigurationMonitor().getMonitorMetadata(); - if (newMonitorMetadata != null - && prevMonitorMetadata == null) { - modified = true; - } else if ((newMonitorMetadata.getOmit()) - && (prevMonitorMetadata.getOmit() == false)) { - modified = true; - } - if ((newMonitorMetadata.getOmit() == false) - && (prevMonitorMetadata.getOmit() == true)) { - modified = true; - } else if (newMonitorMetadata.getImageFile() != null - && prevMonitorMetadata.getImageFile() == null) { - modified = true; - } else if (newMonitorMetadata.getImageFile() == null - && prevMonitorMetadata.getImageFile() != null) { - modified = true; - } - } - } - } + if (newMonitorMetadata != null + && prevMonitorMetadata == null) { + modified = true; + } else if ((newMonitorMetadata.getOmit()) + && (prevMonitorMetadata.getOmit() == false)) { + modified = true; + } + if ((newMonitorMetadata.getOmit() == false) + && (prevMonitorMetadata.getOmit() == true)) { + modified = true; + } else if (newMonitorMetadata.getImageFile() != null + && prevMonitorMetadata.getImageFile() == null) { + modified = true; + } else if (newMonitorMetadata.getImageFile() == null + && prevMonitorMetadata.getImageFile() != null) { + modified = true; + } + } + } + } - return modified; - } + return modified; + } } diff --git a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/config/TrayConfiguration.java b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/config/TrayConfiguration.java index e5a2ecc622..4244fc7dc1 100644 --- a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/config/TrayConfiguration.java +++ b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/config/TrayConfiguration.java @@ -23,10 +23,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; -import org.eclipse.swt.graphics.Rectangle; - -import com.raytheon.uf.common.serialization.ISerializableObject; - /** * Global configuration items for alertviz * @@ -35,13 +31,14 @@ import com.raytheon.uf.common.serialization.ISerializableObject; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Sep 18, 2008 1433 chammack Initial creation + * Oct 28, 2005 5054 randerso removed bar position as it was written but never read * * * @author chammack * @version 1.0 */ @XmlAccessorType(XmlAccessType.NONE) -public class TrayConfiguration implements ISerializableObject { +public class TrayConfiguration { /** * The mode of the display: @@ -109,21 +106,6 @@ public class TrayConfiguration implements ISerializableObject { @XmlAttribute private int logLength; - /** - * The position of the bar - */ - @XmlAttribute - private int xPosition; - - @XmlAttribute - private int yPosition; - - @XmlAttribute - private int width; - - @XmlAttribute - private int height; - /** * @return the mode */ @@ -154,28 +136,6 @@ public class TrayConfiguration implements ISerializableObject { this.priorityShown = priorityShown; } - /** - * @return the position - */ - public Rectangle getPosition() { - Rectangle position = null; - if (xPosition >= 0 && yPosition >= 0 && width >= 1 && height >= 1) { - position = new Rectangle(xPosition, yPosition, width, height); - } - return position; - } - - /** - * @param position - * the position to set - */ - public void setPosition(Rectangle position) { - this.xPosition = position.x; - this.yPosition = position.y; - this.width = position.width; - this.height = position.height; - } - /** * @return the sourceKeyShown */ @@ -259,59 +219,24 @@ public class TrayConfiguration implements ISerializableObject { } /** - * @param messageLogLength + * @param logLength * the messageLogLength to set */ public void setLogLength(int logLength) { this.logLength = logLength; } - public int getXPosition() { - return xPosition; - } - - public void setXPosition(int position) { - xPosition = position; - } - - public int getYPosition() { - return yPosition; - } - - public void setYPosition(int position) { - yPosition = position; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height = height; - } - + @Override public TrayConfiguration clone() { TrayConfiguration newConfig = new TrayConfiguration(); newConfig.audioDuration = audioDuration; newConfig.blinkDuration = blinkDuration; newConfig.categoryShown = categoryShown; newConfig.expandedPopup = expandedPopup; - newConfig.height = height; newConfig.logLength = logLength; newConfig.mode = mode; newConfig.priorityShown = priorityShown; newConfig.sourceKeyShown = sourceKeyShown; - newConfig.width = width; - newConfig.xPosition = xPosition; - newConfig.yPosition = yPosition; return newConfig; } diff --git a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/internal/LogMessageDAO.java b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/internal/LogMessageDAO.java index e6edd3f40e..d6e08aa5fb 100644 --- a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/internal/LogMessageDAO.java +++ b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/internal/LogMessageDAO.java @@ -50,6 +50,7 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Sep 11, 2008 1433 chammack Initial creation + * Feb 11, 2016 5314 dgilling Add loadByRowOffset. * * * @author chammack @@ -64,11 +65,13 @@ public class LogMessageDAO { private static final String SELECT_ALL_QUERY_BY_PK = "SELECT event_time, category, priority, message, details, source, pk, acknowledgedBy, acknowledgedAt FROM log WHERE pk = ?"; + private static final String SELECT_ALL_QUERY_BY_ROW_OFFSET = "SELECT event_time, category, priority, message, details, source, pk, acknowledgedBy, acknowledgedAt FROM log ORDER BY pk OFFSET ? ROWS FETCH NEXT ROW ONLY"; + private static final String PURGE_TIME_QUERY = "SELECT purge_time FROM dbMetadata"; private static final String PURGE_TIME_UPDATE = "UPDATE dbMetadata SET purge_time = ?"; - private static final String DATA_RANGE_QUERY = "SELECT MIN(pk), MAX(pk) FROM log"; + private static final String MESSAGE_COUNT_QUERY = "SELECT COUNT(pk) FROM log"; private static final String SELECT_ALL_BY_DATE_AND_SOURCE_AFTER = "SELECT event_time, category, priority, message, details, source, pk, acknowledgedBy, acknowledgedAt FROM log WHERE event_time > ?"; @@ -353,6 +356,45 @@ public class LogMessageDAO { } } + /** + * Retrieves the specified status message from the message store using the + * specified index as a row offset. + * + * @param index + * The index of the message to retrieve + * @return The status message + * @throws AlertvizException + * If an error occurred retrieving the message from the message + * store. + */ + public StatusMessage loadByRowOffset(int index) throws AlertvizException { + ResultSet rs = null; + PreparedStatement statement = null; + boolean errorOccurred = false; + try { + Connection conn = getConnection(); + statement = conn.prepareStatement(SELECT_ALL_QUERY_BY_ROW_OFFSET); + statement.setInt(1, index); + + rs = statement.executeQuery(); + + conn.commit(); + return reconstituteResults(rs)[0]; + } catch (SQLException e) { + errorOccurred = true; + throw new AlertvizException("Error loading " + index, e); + } catch (RuntimeException e) { + errorOccurred = true; + throw new AlertvizException("Error loading " + index, e); + } finally { + closeResultSet(rs); + closeStatement(statement); + if (errorOccurred) { + closeConnection(); + } + } + } + public StatusMessage[] load(int count) throws AlertvizException { ResultSet rs = null; Statement statement = null; @@ -383,15 +425,16 @@ public class LogMessageDAO { boolean errorOccurred = false; try { Connection conn = getConnection(); - if (order == Order.BEFORE) + if (order == Order.BEFORE) { statement = conn .prepareStatement(SELECT_ALL_BY_DATE_AND_SOURCE_BEFORE); - else if (order == Order.AFTER) + } else if (order == Order.AFTER) { statement = conn .prepareStatement(SELECT_ALL_BY_DATE_AND_SOURCE_AFTER); - else + } else { throw new IllegalArgumentException("Unsupported order : " + order); + } statement.setMaxFieldSize(count); statement.setTimestamp(1, filter); @@ -477,7 +520,12 @@ public class LogMessageDAO { } } - public int[] getLogRange() throws AlertvizException { + /** + * Retrieves the number of status messages in the message store. + * + * @return Total number of messages. + */ + public int getMessageCount() throws AlertvizException { ResultSet rs = null; Statement statement = null; boolean errorOccurred = false; @@ -485,15 +533,12 @@ public class LogMessageDAO { Connection conn = getConnection(); statement = conn.createStatement(); statement.setMaxFieldSize(1); - rs = statement.executeQuery(DATA_RANGE_QUERY); + rs = statement.executeQuery(MESSAGE_COUNT_QUERY); if (rs.next()) { - int min = rs.getInt(1); - int max = rs.getInt(2); - - return new int[] { min, max }; + int count = rs.getInt(1); + return count; } conn.commit(); - return null; } catch (SQLException e) { errorOccurred = true; throw new AlertvizException("Error getting time range ", e); @@ -504,6 +549,8 @@ public class LogMessageDAO { closeConnection(); } } + + return 0; } public Timestamp getLastPurgeTime() throws AlertvizException { @@ -547,8 +594,9 @@ public class LogMessageDAO { sm.setAcknowledgedBy(rs.getString(8)); Timestamp ts = rs.getTimestamp(9); - if (ts != null) + if (ts != null) { sm.setAcknowledgedAt(new Date(ts.getTime())); + } retVal.add(sm); } diff --git a/cave/com.raytheon.uf.viz.archive.feature/feature.xml b/cave/com.raytheon.uf.viz.archive.feature/feature.xml index 19dc9c07a9..0632b8c694 100644 --- a/cave/com.raytheon.uf.viz.archive.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.archive.feature/feature.xml @@ -40,6 +40,6 @@ id="org.apache.commons.compress" download-size="0" install-size="0" - version="1.5.0"/> + version="1.10.0"/> diff --git a/cave/com.raytheon.uf.viz.archive/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.archive/META-INF/MANIFEST.MF index be6e378e31..b97e565602 100644 --- a/cave/com.raytheon.uf.viz.archive/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.archive/META-INF/MANIFEST.MF @@ -2,11 +2,11 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Archive Bundle-SymbolicName: com.raytheon.uf.viz.archive;singleton:=true -Bundle-Version: 1.14.0.qualifier +Bundle-Version: 1.15.0.qualifier Bundle-Vendor: RAYTHEON Require-Bundle: org.eclipse.ui;bundle-version="3.8.2", org.eclipse.core.runtime, - org.apache.commons.lang;bundle-version="2.3.0", + org.apache.commons.lang3;bundle-version="3.4.0", org.apache.commons.io;bundle-version="2.4.0", com.raytheon.viz.ui;bundle-version="1.12.1174", com.raytheon.uf.common.serialization;bundle-version="1.12.1174", diff --git a/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/AbstractArchiveDlg.java b/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/AbstractArchiveDlg.java index 1b2c576996..a763217581 100644 --- a/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/AbstractArchiveDlg.java +++ b/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/AbstractArchiveDlg.java @@ -49,7 +49,7 @@ import com.raytheon.uf.common.archive.config.ArchiveConfigManager; import com.raytheon.uf.common.archive.config.ArchiveConstants; import com.raytheon.uf.common.archive.config.CategoryConfig; import com.raytheon.uf.common.archive.config.DisplayData; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; +import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.util.SizeUtil; import com.raytheon.uf.viz.archive.data.ArchiveInfo; import com.raytheon.uf.viz.archive.data.CategoryInfo; @@ -83,6 +83,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Apr 10, 2014 3023 rferrel Added setTotalSelectedSize method. * Apr 23, 2014 3045 rferrel Changes to prevent race condition while getting labels. * Aug 26, 2014 3553 rferrel Force redisplay of table after getting all display labels. + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException * * * @@ -473,7 +474,7 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements String fileName = ArchiveConstants.selectFileName(type, selectName); try { manager.deleteSelection(fileName); - } catch (LocalizationOpFailedException e) { + } catch (LocalizationException e) { MessageDialog.openError(shell, "Case Error", "Unable to delete file: " + fileName); } @@ -819,6 +820,7 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements * * @param startTimeOffset */ + @Override public void setRetentionTimes(long startTimeOffset) { // do nothing override by sub-classes } @@ -858,6 +860,7 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements /** * Perform updates once all the display data is loaded. */ + @Override public void loadedAllDisplayData() { VizApp.runAsync(new Runnable() { diff --git a/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/ArchiveTableComp.java b/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/ArchiveTableComp.java index 921cbcccd8..d67f4884a1 100644 --- a/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/ArchiveTableComp.java +++ b/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/ArchiveTableComp.java @@ -24,7 +24,7 @@ import java.util.Arrays; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang3.ArrayUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; diff --git a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/rsc/AdvisoryResource.java b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/rsc/AdvisoryResource.java index f80012899a..09d298e52f 100644 --- a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/rsc/AdvisoryResource.java +++ b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/rsc/AdvisoryResource.java @@ -80,6 +80,7 @@ import com.vividsolutions.jts.geom.Polygon; * Aug 14, 2014 3523 mapeters Updated deprecated {@link DrawableString#textStyle} * assignments. * Jul 7, 2015 10352 byin Added SymbolLoader to plot symbols + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling * * * @author bsteffen @@ -194,7 +195,7 @@ public class AdvisoryResource extends if (font != null) { font.dispose(); } - this.font = target.initializeFont("Monospace", 10, new Style[] {}); + this.font = target.initializeFont("Monospace", 8, new Style[] {}); this.symbolLoader = new SymbolLoader(); } diff --git a/cave/com.raytheon.uf.viz.bufrsigwx/src/com/raytheon/uf/viz/bufrsigwx/rsc/SigWxResource.java b/cave/com.raytheon.uf.viz.bufrsigwx/src/com/raytheon/uf/viz/bufrsigwx/rsc/SigWxResource.java index 489cfbe8e9..ffe3aac79f 100644 --- a/cave/com.raytheon.uf.viz.bufrsigwx/src/com/raytheon/uf/viz/bufrsigwx/rsc/SigWxResource.java +++ b/cave/com.raytheon.uf.viz.bufrsigwx/src/com/raytheon/uf/viz/bufrsigwx/rsc/SigWxResource.java @@ -29,8 +29,6 @@ import org.eclipse.swt.graphics.Rectangle; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.bufrsigwx.SigWxData; -import com.raytheon.uf.common.dataquery.requests.RequestConstraint; -import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.common.geospatial.ReferencedCoordinate; import com.raytheon.uf.common.pointdata.PointDataContainer; import com.raytheon.uf.common.pointdata.PointDataView; @@ -56,6 +54,8 @@ import com.raytheon.viz.pointdata.PointDataRequest; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Sep 28, 2009 3099 bsteffen Initial creation + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling + * Feb 04, 2015 5309 tgurney Remove dependency on dataURI * * * @@ -155,7 +155,7 @@ public abstract class SigWxResource extends if (font != null) { font.dispose(); } - this.font = target.initializeFont("Monospace", 10, + this.font = target.initializeFont("Monospace", 8, new Style[] { Style.BOLD }); } @@ -167,21 +167,11 @@ public abstract class SigWxResource extends * @throws VizException */ protected void updateRecords(DataTime dataTime) throws VizException { - - RequestConstraint constraint = new RequestConstraint(); - - constraint.setConstraintType(ConstraintType.IN); - - for (SigWxData record : recordsToParse.get(dataTime)) { - constraint.addToConstraintValueList(record.getDataURI()); - } - Map constraints = new HashMap(); - constraints.put("dataURI", constraint); // Request the point data PointDataContainer pdc = PointDataRequest.requestPointDataAllLevels( dataTime, resourceData.getMetadataMap().get("pluginName") .getConstraintValue(), getParameters(), null, - constraints); + resourceData.getMetadataMap()); if (recordsToDisplay.containsKey(dataTime)) { recordsToDisplay.get(dataTime).combine(pdc); } else { diff --git a/cave/com.raytheon.uf.viz.common.core.feature/feature.xml b/cave/com.raytheon.uf.viz.common.core.feature/feature.xml index 820badf50c..45ca8825bd 100644 --- a/cave/com.raytheon.uf.viz.common.core.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.common.core.feature/feature.xml @@ -100,6 +100,13 @@ version="0.0.0" unpack="false"/> + + + + + + + + diff --git a/cave/com.raytheon.uf.viz.cwa/src/com/raytheon/uf/viz/cwa/rsc/CWAResource.java b/cave/com.raytheon.uf.viz.cwa/src/com/raytheon/uf/viz/cwa/rsc/CWAResource.java index 5060b0b48a..a805bc9889 100644 --- a/cave/com.raytheon.uf.viz.cwa/src/com/raytheon/uf/viz/cwa/rsc/CWAResource.java +++ b/cave/com.raytheon.uf.viz.cwa/src/com/raytheon/uf/viz/cwa/rsc/CWAResource.java @@ -70,9 +70,9 @@ import com.vividsolutions.jts.geom.Polygon; /** * Resource for Center Weather Advisory - * + * *

- *
+ * 
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
@@ -81,8 +81,10 @@ import com.vividsolutions.jts.geom.Polygon;
  *                                      compabilities.
  * May 11, 2015 4379       nabowle      Display all current CWAs for each frame.
  * Jun 15, 2015 4379       nabowle      Make last frame a live frame.
+ * Nov 05, 2015 5070       randerso     Adjust font sizes for dpi scaling
+ * 
  * 
- * + * * @author jsanchez * @version 1.0 */ @@ -186,11 +188,11 @@ public class CWAResource extends constraints.put(END, constraint); // Request the point data - this.pdc = PointDataRequest - .requestPointDataAllLevels((DataTime) null, + this.pdc = PointDataRequest.requestPointDataAllLevels( + (DataTime) null, resourceData.getMetadataMap().get("pluginName") - .getConstraintValue(), - getParameters(), null, constraints); + .getConstraintValue(), getParameters(), null, + constraints); if (wfs != null) { wfs.dispose(); @@ -249,7 +251,7 @@ public class CWAResource extends /** * Get the list of PointDataViews. PointDataViews that share an event id * will be deduplicated to the most recent record for that event id. - * + * * @return The list of PointDataViews. * @throws VizException */ @@ -332,7 +334,7 @@ public class CWAResource extends /** * Cancel the heart beat timer task - * + * * @param resource */ protected static void cancelRefreshTask(CWAResource resource) { @@ -373,7 +375,7 @@ public class CWAResource extends * Get the current/simulated time to the minute. Seconds and Milliseconds * will be zero so a consistent time can be used each minute when retrieving * from the frame map. - * + * * @return */ public static DataTime now() { @@ -424,7 +426,7 @@ public class CWAResource extends @Override protected void initInternal(IGraphicsTarget target) throws VizException { - this.font = target.initializeFont("Monospace", 11, + this.font = target.initializeFont("Monospace", 9, new Style[] { Style.ITALIC }); updateLiveFrame(now()); scheduleRefreshTask(this); @@ -516,7 +518,7 @@ public class CWAResource extends /** * Adds a new record to this resource - * + * * @param obj */ protected void addRecord(CWARecord obj) { diff --git a/cave/com.raytheon.uf.viz.cwat/src/com/raytheon/uf/viz/cwat/CWATResource.java b/cave/com.raytheon.uf.viz.cwat/src/com/raytheon/uf/viz/cwat/CWATResource.java index b0ed95e937..1b3ddb1d03 100644 --- a/cave/com.raytheon.uf.viz.cwat/src/com/raytheon/uf/viz/cwat/CWATResource.java +++ b/cave/com.raytheon.uf.viz.cwat/src/com/raytheon/uf/viz/cwat/CWATResource.java @@ -66,13 +66,13 @@ import com.vividsolutions.jts.geom.Coordinate; * *
  * 
- *    SOFTWARE HISTORY
- *   
- *    Date         Ticket#     Engineer    Description
- *    ------------ ----------  ----------- --------------------------
- *    16JUN2009    2037        dhladky    Initial Creation.
- *    Apr 17, 2013   1916      njensen    Overrode getDataTimes()
+ * SOFTWARE HISTORY
  * 
+ * Date         Ticket#     Engineer    Description
+ * ------------ ----------  ----------- --------------------------
+ * 16JUN2009    2037        dhladky     Initial Creation.
+ * Apr 17, 2013 1916        njensen     Overrode getDataTimes()
+ * Nov 05, 2015 5070       randerso     Adjust font sizes for dpi scaling
  * 
  * 
* @@ -180,7 +180,7 @@ public class CWATResource extends @Override protected void initInternal(IGraphicsTarget target) throws VizException { if (this.font == null) { - this.font = target.initializeFont("Dialog", 11, null); + this.font = target.initializeFont("Dialog", 9, null); } init = true; } diff --git a/cave/com.raytheon.uf.viz.d2d.core/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.d2d.core/META-INF/MANIFEST.MF index 536cda76d0..afd31b02b9 100644 --- a/cave/com.raytheon.uf.viz.d2d.core/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.d2d.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Core Plug-in Bundle-SymbolicName: com.raytheon.uf.viz.d2d.core;singleton:=true -Bundle-Version: 1.14.0.qualifier +Bundle-Version: 1.15.0.qualifier Bundle-Vendor: RAYTHEON Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui, @@ -14,7 +14,7 @@ Require-Bundle: org.eclipse.core.runtime, com.raytheon.uf.viz.core.rsc;bundle-version="1.0.0", com.raytheon.uf.viz.core.maps;bundle-version="1.12.1174", com.raytheon.viz.ui;bundle-version="1.12.1174", - org.apache.commons.lang;bundle-version="2.3.0" + org.apache.commons.lang3;bundle-version="3.4.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.uf.viz.d2d.core, diff --git a/cave/com.raytheon.uf.viz.d2d.core/plugin.xml b/cave/com.raytheon.uf.viz.d2d.core/plugin.xml index 9c1065bf9f..f33f3af832 100644 --- a/cave/com.raytheon.uf.viz.d2d.core/plugin.xml +++ b/cave/com.raytheon.uf.viz.d2d.core/plugin.xml @@ -35,13 +35,13 @@ categoryId="com.raytheon.uf.viz.core.theme.d2d" id="com.raytheon.uf.viz.d2d.core.map.D2DColorBarResourceFont" label="D2D Colorbar Font" - value="Monospace-regular-11"> + value="Monospace-regular-9"> Colorbar font for D2D @@ -53,7 +53,7 @@ categoryId="com.raytheon.uf.viz.core.theme.d2d" id="com.raytheon.uf.viz.d2d.core.legend.D2DLegendResource" label="D2D Legend Font" - value="Monospace-bold-14"> + value="Monospace-bold-12"> Legend font for D2D @@ -62,7 +62,7 @@ categoryId="com.raytheon.uf.viz.core.theme.d2d" id="com.raytheon.uf.viz.d2d.core.sampling.D2DSamplingResource" label="Sampling Font" - value="Monospaced-bold-12"> + value="Monospace-bold-10"> The sampling font for D2D diff --git a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/legend/D2DLegendResource.java b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/legend/D2DLegendResource.java index 8420ef138b..7a8d9bd814 100644 --- a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/legend/D2DLegendResource.java +++ b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/legend/D2DLegendResource.java @@ -74,6 +74,7 @@ import com.raytheon.viz.ui.actions.DummyAction; * Aug 2, 2013 DR 16427 Qinglu Lin (David's approach) Changing InputPriority.SYSTEM_RESOURCE to * InputPriority.SYSTEM_RESOURCE_LOW in initInternal(). * Jun 30, 2015 RM14663 kshresth Font size increased for Contour labels. + * Nov 05, 2015 5070 randerso Removed incorrect magnification limits * * * @@ -508,7 +509,8 @@ public class D2DLegendResource extends * by being added later, runs before the changeModelHandler. See * InputManager.handeMouseXxx. */ - rc.registerMouseHandler(changeModeHandler, InputPriority.SYSTEM_RESOURCE_LOW); + rc.registerMouseHandler(changeModeHandler, + InputPriority.SYSTEM_RESOURCE_LOW); rc.registerMouseHandler(legendHandler, InputPriority.SYSTEM_RESOURCE_LOW); } @@ -572,8 +574,8 @@ public class D2DLegendResource extends private float getScaledMagnification() { float magnification = getCapability(MagnificationCapability.class) .getMagnification().floatValue(); - if (magnification < 0.9f) { - magnification = 1.0f; + if (magnification < 0.6f) { + magnification = 0.6f; } else if (magnification > 1.0f) { magnification = 1 + (magnification / 4.0f); } diff --git a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/map/D2DMapRenderableDisplay.java b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/map/D2DMapRenderableDisplay.java index 2c3ac0f916..bc1e507301 100644 --- a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/map/D2DMapRenderableDisplay.java +++ b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/map/D2DMapRenderableDisplay.java @@ -28,7 +28,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.AbstractTimeMatcher; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.VizConstants; @@ -41,13 +40,10 @@ import com.raytheon.uf.viz.core.globals.VizGlobalsManager; import com.raytheon.uf.viz.core.map.IMapDescriptor; import com.raytheon.uf.viz.core.map.MapDescriptor; import com.raytheon.uf.viz.core.maps.scales.MapScaleRenderableDisplay; -import com.raytheon.uf.viz.core.maps.scales.MapScalesManager; -import com.raytheon.uf.viz.core.maps.scales.MapScalesManager.ManagedMapScale; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.IResourceGroup; import com.raytheon.uf.viz.core.rsc.ResourceList; import com.raytheon.uf.viz.core.rsc.ResourceList.AddListener; -import com.raytheon.uf.viz.core.rsc.ResourceProperties; import com.raytheon.uf.viz.core.rsc.capabilities.DensityCapability; import com.raytheon.uf.viz.core.rsc.capabilities.MagnificationCapability; import com.raytheon.uf.viz.d2d.core.D2DProperties; @@ -61,18 +57,21 @@ import com.raytheon.viz.core.imagery.ImageCombiner; *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Feb 09, 2009            njensen     Initial creation
- * Mar 21, 2013       1638 mschenke    Made map scales not tied to d2d
- * Mar 22, 2013       1638 mschenke    Moved map scale code to MapScaleRenderableDisplay
- * Apr 06, 2015 ASM #17215 D. Friedman Implement clear to avoid removing time match basis
- * Sep 03, 2015       4779 njensen     Removed DataScale references
+ * 
+ * Date          Ticket#  Engineer   Description
+ * ------------- -------- ---------- -------------------------------------------
+ * Feb 09, 2009  1960     njensen    Initial creation
+ * Mar 21, 2013  1638     mschenke   Made map scales not tied to d2d
+ * Mar 22, 2013  1638     mschenke   Moved map scale code to
+ *                                   MapScaleRenderableDisplay
+ * Apr 06, 2015  17215    dfriedman  Implement clear to avoid removing time
+ *                                   match basis
+ * Sep 03, 2015  4779     njensen    Removed DataScale references
+ * Dec 03, 2015  5147     bsteffen   Reset TimeMatcher on clear
  * 
  * 
* * @author njensen - * @version 1.0 */ @XmlAccessorType(XmlAccessType.NONE) @XmlRootElement @@ -313,65 +312,21 @@ public class D2DMapRenderableDisplay extends MapScaleRenderableDisplay } /** - * Like MapScaleRenderableDisplayer.clear, but avoids removing the time - * match basis until other resources are removed. This reduces time matching - * churn and reduces the chances of lockups. - * - * @see com.raytheon.uf.viz.core.maps.scales.MapScaleRenderableDisplay#clear() + * Replace the time matcher with a copy before clearing. The existing time + * matcher is carefully tracking information for the resources(especially + * the time match basis), replacing the timeMatcher saves time updating or + * removing the saved information since the resources will all be removed + * anyway. */ @Override public void clear() { - AbstractVizResource timeMatchBasis = null; AbstractTimeMatcher timeMatcher = descriptor.getTimeMatcher(); if (timeMatcher instanceof D2DTimeMatcher) { - timeMatchBasis = ((D2DTimeMatcher) timeMatcher).getTimeMatchBasis(); - } - ManagedMapScale scale = MapScalesManager.getInstance().getScaleByName( - getScaleName()); - if (scale != null) { - ResourceList list = descriptor.getResourceList(); - for (ResourcePair rp : list) { - if (rp.getProperties().isSystemResource() == false) { - // Keep system resources - if (rp.getResource() != timeMatchBasis) { - list.remove(rp); - } - } - } - if (timeMatchBasis != null) { - list.removeRsc(timeMatchBasis); - } - loadScale(scale); - } else { - // Map scale could not be found, default to remove all - // non-map/system layers and reset display - ResourceList list = descriptor.getResourceList(); - for (ResourcePair rp : list) { - ResourceProperties props = rp.getProperties(); - if (props.isMapLayer() == false - && props.isSystemResource() == false) { - if (rp.getResource() != timeMatchBasis) { - list.remove(rp); - } - } else { - try { - props.setVisible(true); - rp.getResource().recycle(); - } catch (Throwable e) { - props.setVisible(false); - statusHandler.handle(Priority.PROBLEM, "Clear error: " - + e.getMessage() + ":: The resource [" - + rp.getResource().getSafeName() - + "] has been disabled.", e); - } - } - } - if (timeMatchBasis != null) { - list.removeRsc(timeMatchBasis); - } - - scaleToClientArea(getBounds()); + D2DTimeMatcher newTimeMatcher = new D2DTimeMatcher(); + timeMatcher.copyFrom(newTimeMatcher); + descriptor.setTimeMatcher(newTimeMatcher); } + super.clear(); } } diff --git a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/map/D2DSelectedPaneResource.java b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/map/D2DSelectedPaneResource.java index a78021336d..e3c331c7d5 100644 --- a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/map/D2DSelectedPaneResource.java +++ b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/map/D2DSelectedPaneResource.java @@ -52,6 +52,7 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor; * ------------ ---------- ----------- -------------------------- * Dec 20, 2010 mschenke Initial creation * Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls. + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling * * * @@ -131,12 +132,10 @@ public class D2DSelectedPaneResource extends / paintProps.getCanvasBounds().height; stringL.basics.x = stringI.basics.x = plus.basics.x = paintProps - .getView() - .getExtent().getMinX() + .getView().getExtent().getMinX() + (LEFT_OFFSET * ratioX); stringL.basics.y = stringI.basics.y = plus.basics.y = paintProps - .getView() - .getExtent().getMaxY() + .getView().getExtent().getMaxY() - (BOTTOM_OFFSET * ratioY); if (editor.getNumberofPanes() > 1 @@ -178,7 +177,7 @@ public class D2DSelectedPaneResource extends */ @Override protected void initInternal(IGraphicsTarget target) throws VizException { - font = target.initializeFont(Font.MONOSPACED, 24, + font = target.initializeFont(Font.MONOSPACED, 20, new Style[] { Style.BOLD }); stringL = new DrawableString("L", L_COLOR); diff --git a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/time/D2DTimeMatcher.java b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/time/D2DTimeMatcher.java index 3964711678..90fbdae60c 100644 --- a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/time/D2DTimeMatcher.java +++ b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/time/D2DTimeMatcher.java @@ -28,12 +28,15 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.concurrent.atomic.AtomicReference; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; -import org.apache.commons.lang.Validate; +import org.apache.commons.lang3.Validate; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.status.IUFStatusHandler; @@ -47,7 +50,6 @@ import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.uf.viz.core.VizConstants; import com.raytheon.uf.viz.core.comm.PerspectiveSpecificLoadProperties; -import com.raytheon.uf.viz.core.drawables.AbstractDescriptor; import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay; import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo; @@ -71,28 +73,29 @@ import com.raytheon.uf.viz.d2d.core.D2DLoadProperties; *
  * 
  * SOFTWARE HISTORY
- * Date          Ticket#  Engineer    Description
- * ------------- -------- ----------- --------------------------
- * Feb 10, 2009           chammack    Initial creation
- * Jul 03, 2013  2159     bsteffen    Synchronize TimeCache access.
- * Aug  9, 2013  16448    D. Friedman Validate time match basis in
- *                                    redoTimeMatching
- * May  5, 2014  17201    D. Friedman Make same-radar time matching work more
- *                                    like A1.
- * May  5, 2014  3265     bsteffen    Better handling of resources returning
- *                                    null dataTimes.
- * May 13, 2015  4461     bsteffen    Move the logic to change frames into the
- *                                    FrameCoordinator.
- * Jul 14, 2015  DR 13900 D. Friedman Validate descriptor of time match basis
- *                                    before time matching it.
- * Jul 30, 2015  17761    D. Friedman Allow resources to return data times based
- *                                    on base frame times.
- * Sep 10, 2015  4856     njensen     Removed unnecessary code
+ * 
+ * Date          Ticket#  Engineer   Description
+ * ------------- -------- ---------- -------------------------------------------
+ * Feb 10, 2009  1959     chammack   Initial creation
+ * Jul 03, 2013  2159     bsteffen   Synchronize TimeCache access.
+ * Aug 09, 2013  16448    dfriedman  Validate time match basis in
+ *                                   redoTimeMatching
+ * May 05, 2014  17201    dfriedman  Make same-radar time matching work more
+ *                                   like A1.
+ * May 05, 2014  3265     bsteffen   Better handling of resources returning null
+ *                                   dataTimes.
+ * May 13, 2015  4461     bsteffen   Move the logic to change frames into the
+ *                                   FrameCoordinator.
+ * Jul 14, 2015  13900    dfriedman  Validate descriptor of time match basis
+ *                                   before time matching it.
+ * Jul 30, 2015  17761    dfriedman  Allow resources to return data times based
+ *                                   on base frame times.
+ * Sep 10, 2015  4856     njensen    Removed unnecessary code
+ * Dec 03, 2015  5147     bsteffen   Make timeMatchBasis atomic.
  * 
  * 
* * @author chammack - * @version 1.0 */ @XmlAccessorType(XmlAccessType.NONE) public class D2DTimeMatcher extends AbstractTimeMatcher { @@ -108,7 +111,8 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { /** * The last set of times that the resource with these properties was * matched against. As long as we are matching against these same times - * then lastFrameTimes is valid. + * then lastFrameTimes is valid. This will be null for the + * TimeMatchBasis. */ private DataTime[] lastBaseTimes; @@ -144,21 +148,21 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { } /** - * the rsc that determines the frame times to be displayed, i.e. other + * The resource that determines the frame times to be displayed, i.e. other * resources on the same descriptor will time match against the - * timeMatchBasis + * timeMatchBasis. This is an atomic reference to allow safe concurrent + * modification. It is never safe to assume that 2 calls to get will return + * the same value so complex operations(such as redoTimeMatching) will need + * to get a reference to the basis once at the beginning of the operation + * and use that reference throughout the operation. */ - protected transient AbstractVizResource timeMatchBasis; + protected final AtomicReference> timeMatchBasisRef = new AtomicReference<>(); private final IDisposeListener timeMatchBasisDisposeListener = new IDisposeListener() { @Override public void disposed(AbstractVizResource resource) { - if ((resource == timeMatchBasis)) { - synchronized (D2DTimeMatcher.this) { - timeMatchBasis = null; - } - } + timeMatchBasisRef.compareAndSet(resource, null); } }; @@ -187,9 +191,6 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { private final Map, TimeCache> timeCacheMap = new IdentityHashMap, D2DTimeMatcher.TimeCache>(); - /** - * Default Constructor. - */ public D2DTimeMatcher() { super(); try { @@ -218,9 +219,6 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { * Checks if a resource is contained in the {@link IResourceGroup} * recursively checking for {@link IResourceGroup}s in the group's list * - * @param group - * @param resource - * @return */ private boolean contained(IResourceGroup group, AbstractVizResource resource) { @@ -241,52 +239,40 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { } @Override - public void redoTimeMatching(IDescriptor descriptor) throws VizException { + public void redoTimeMatching(IDescriptor descriptor) { synchronized (this) { - if ((timeMatchBasis != null) - && (timeMatchBasis.getDescriptor() == descriptor) - && !validateTimeMatchBasis(descriptor)) { - changeTimeMatchBasis(null); - } - if (timeMatchBasis != null) { - IDescriptor tmDescriptor = timeMatchBasis.getDescriptor(); - if (tmDescriptor != null) { - if (tmDescriptor != descriptor - && tmDescriptor.getTimeMatcher() == this - && hasContainer(descriptor)) { - if (validateDescriptor(tmDescriptor)) { - redoTimeMatching(tmDescriptor); - } else { - changeTimeMatchBasis(null); - } - } else if (contained(tmDescriptor, timeMatchBasis) == false) { - // Checks to ensure the timeMatchBasis is not "orphaned" - timeMatchBasis = null; - } - } - } - // Find the times for the time match basis. - DataTime[] timeSteps = findBasisTimes(descriptor.getResourceList(), - descriptor.getNumberOfFrames()); - if (timeSteps == null) { + /* Find the times for the time match basis. */ + Pair, DataTime[]> basisInfo = findBasisTimes(descriptor); + if (basisInfo == null) { descriptor.setFramesInfo(new FramesInfo(null, -1)); return; } + AbstractVizResource timeMatchBasis = basisInfo.getLeft(); + DataTime[] timeSteps = basisInfo.getRight(); Map, DataTime[]> resourceTimeMap = new HashMap, DataTime[]>(); resourceTimeMap.put(timeMatchBasis, timeSteps); - // Find times for every other resource + /* Find the times for the time match basis. */ Iterator pairIterator = descriptor.getResourceList() .listIterator(); while (pairIterator.hasNext()) { AbstractVizResource rsc = pairIterator.next() .getResource(); - recursiveOverlay(descriptor, new FramesInfo(timeSteps, -1, - resourceTimeMap), rsc, resourceTimeMap); + recursiveOverlay(descriptor, timeMatchBasis, new FramesInfo( + timeSteps, -1, resourceTimeMap), rsc, resourceTimeMap); } - // Update the descriptor to the new times. + if (descriptor.getTimeMatcher() != this) { + /* + * The descriptor has switched to a new time matcher so the + * results of this operation are no longer relevant and are + * discarded. This can happen when the display is cleared. + */ + return; + } + + /* Update the descriptor to the new times. */ if ((timeMatchBasis.getDescriptor() != null) && (timeMatchBasis.getDescriptor() != descriptor)) { int idx = timeMatchBasis.getDescriptor().getFramesInfo() @@ -303,7 +289,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { resourceTimeMap)); } - // Add Remove data for all the resources. + /* Add Remove data for all the resources. */ for (Entry, DataTime[]> entry : resourceTimeMap .entrySet()) { if (entry.getKey().getDescriptor() == descriptor) { @@ -319,17 +305,22 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { * * @param descriptor * the descriptor that is being updated + * @param timeMatchBasis + * the current timeMatchBasis, used to ensure that it is not time + * matched again, even if it is located in a IResourceGroup + * @param framesInfo + * the matched times for the rsc passed in will be added to the + * map of this FramesInfo * @param rsc * the resource being updated. * @param frameTimesSoure * map of all previously time matched resources that may be used * to determine the frame times - * @throws VizException */ private void recursiveOverlay(IDescriptor descriptor, - FramesInfo framesInfo, AbstractVizResource rsc, - Map, DataTime[]> frameTimesSoure) - throws VizException { + AbstractVizResource timeMatchBasis, FramesInfo framesInfo, + AbstractVizResource rsc, + Map, DataTime[]> frameTimesSoure) { if (rsc == null) { return; } @@ -338,7 +329,8 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { frameTimesSoure); for (ResourcePair rp : ((IResourceGroup) rsc).getResourceList()) { AbstractVizResource rsc1 = rp.getResource(); - recursiveOverlay(descriptor, framesInfo, rsc1, completed); + recursiveOverlay(descriptor, timeMatchBasis, framesInfo, rsc1, + completed); } } @@ -347,8 +339,8 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { .getLoadProperties()); TimeCache timeCache = getTimeCache(rsc); synchronized (timeCache) { - DataTime[] timeSteps = getFrameTimes(descriptor, framesInfo, - frameTimesSoure); + DataTime[] timeSteps = getFrameTimes(descriptor, + timeMatchBasis, framesInfo, frameTimesSoure); if (Arrays.equals(timeSteps, timeCache.getLastBaseTimes())) { framesInfo.getTimeMap().put(rsc, timeCache.getLastFrameTimes()); @@ -378,15 +370,10 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { /** * Determine the times to match this resource against, for single panel this - * is the timeMatchBasisTimes, for four panel it is a bit more complex. - * - * @param descriptor - * @param frameInfo - * @param frameTimesSoure - * @return + * is the timeMatchBasis times, for four panel it is a bit more complex. */ private DataTime[] getFrameTimes(IDescriptor descriptor, - FramesInfo frameInfo, + AbstractVizResource timeMatchBasis, FramesInfo frameInfo, Map, DataTime[]> frameTimesSource) { DataTime[] descTimes = frameInfo.getFrameTimes(); if ((timeMatchBasis != null) @@ -394,17 +381,19 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { return descTimes; } - // If the time match basis is not in this descriptor we should instead - // fall back on the first resource in this descriptor which has times - // for this frame. This concept was adopted from Frame::dataTime() in - // the A1 source. + /* + * If the time match basis is not in this descriptor we should instead + * fall back on the first resource in this descriptor which has times + * for this frame. This concept was adopted from Frame::dataTime() in + * the A1 source. + */ DataTime[] times = new DataTime[frameInfo.getFrameCount()]; for (ResourcePair rp : descriptor.getResourceList()) { DataTime[] rscTimes = frameTimesSource.get(rp.getResource()); if ((rscTimes == null) || (rscTimes.length != times.length)) { if (rp.getResource() instanceof IResourceGroup) { - // Descend into resource groups. + /* Descend into resource groups. */ for (ResourcePair rp1 : ((IResourceGroup) rp.getResource()) .getResourceList()) { rscTimes = frameTimesSource.get(rp1.getResource()); @@ -437,32 +426,85 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { /** * Attempts to find the frame times for a time match basis, if time match * basis is not defined attempts to find a new time match basis. Returns - * null if no Time Match basis can be found. - * - * @param descriptor - * @param resourceList - * @return - * @throws VizException + * null if no Time Match basis can be found. This method will update the + * {@link #timeMatchBasisRef} if needed. */ - private DataTime[] findBasisTimes(ResourceList resourceList, - int numberOfFrames) throws VizException { - if (timeMatchBasis != null) { - TimeCache timeCache = getTimeCache(timeMatchBasis); - DataTime[] times = null; - synchronized (timeCache) { - times = timeCache.getLastFrameTimes(); - if ((times == null) || (timeCache.getLastBaseTimes() != null) - || (timeCache.getLastFrameCount() != numberOfFrames)) { - times = makeEmptyLoadList(numberOfFrames, timeMatchBasis); - timeCache.setTimes(null, times, numberOfFrames); + private Pair, DataTime[]> findBasisTimes( + IDescriptor descriptor) { + int numberOfFrames = descriptor.getNumberOfFrames(); + AbstractVizResource timeMatchBasis = timeMatchBasisRef.get(); + if (timeMatchBasis == null) { + Pair, DataTime[]> pair = findNewBasis( + descriptor.getResourceList(), numberOfFrames); + if (pair != null) { + AbstractVizResource rsc = pair.getLeft(); + configureBasis(rsc); + if (!timeMatchBasisRef.compareAndSet(null, rsc)) { + unconfigureBasis(rsc); } } - if (times != null) { - return times; - } else { - timeMatchBasis = null; + return pair; + } + + IDescriptor tmDescriptor = timeMatchBasis.getDescriptor(); + if ((tmDescriptor == descriptor) + && !validateTimeMatchBasis(descriptor, timeMatchBasis)) { + changeTimeMatchBasis(null); + return findBasisTimes(descriptor); + } + if (tmDescriptor != null) { + if (tmDescriptor != descriptor + && tmDescriptor.getTimeMatcher() == this + && hasContainer(descriptor)) { + if (validateDescriptor(tmDescriptor)) { + redoTimeMatching(tmDescriptor); + } else { + changeTimeMatchBasis(null); + return findBasisTimes(descriptor); + } + } else if (contained(tmDescriptor, timeMatchBasis) == false) { + /* Checks to ensure the timeMatchBasis is not "orphaned" */ + timeMatchBasisRef.compareAndSet(timeMatchBasis, null); + return findBasisTimes(descriptor); } } + TimeCache timeCache = getTimeCache(timeMatchBasis); + DataTime[] times = null; + synchronized (timeCache) { + times = timeCache.getLastFrameTimes(); + if ((times == null) || (timeCache.getLastBaseTimes() != null) + || (timeCache.getLastFrameCount() != numberOfFrames)) { + times = makeEmptyLoadList(numberOfFrames, timeMatchBasis); + timeCache.setTimes(null, times, numberOfFrames); + } + } + if (times != null) { + return new ImmutablePair, DataTime[]>( + timeMatchBasis, times); + } else { + /* + * This might fail if another thread has assigned a basis while this + * method was looking for one. In this case the current operation + * will proceed with the wrong basis. Proceed anyway since the basis + * that was chosen would have been the correct basis when this + * method began. Whatever operation set the basis should have + * initiated redoTimeMatching which will run after this and assign + * times with the new basis. + */ + timeMatchBasisRef.compareAndSet(timeMatchBasis, null); + return findBasisTimes(descriptor); + } + } + + /** + * Recursive operation to search for a resource that is able to be the time + * match basis. Returns the resource and the matched times for that + * resource. If no resources is able to be the timeMatchBasis then null is + * returned. This method does not actually change {@link #timeMatchBasisRef} + * . + */ + public Pair, DataTime[]> findNewBasis( + ResourceList resourceList, int numberOfFrames) { Iterator pairIterator = resourceList.iterator(); while (pairIterator.hasNext()) { ResourcePair pair = pairIterator.next(); @@ -476,13 +518,12 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { } if (rsc.getResourceData() instanceof IResourceGroup) { - DataTime[] times = findBasisTimes( - ((IResourceGroup) rsc.getResourceData()) - .getResourceList(), - numberOfFrames); + IResourceGroup group = (IResourceGroup) rsc.getResourceData(); + Pair, DataTime[]> resultPair = findNewBasis( + group.getResourceList(), numberOfFrames); - if (times != null) { - return times; + if (resultPair != null) { + return resultPair; } } else { DataTime[] times = makeEmptyLoadList(numberOfFrames, rsc); @@ -491,7 +532,8 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { synchronized (cache) { cache.setTimes(null, times, numberOfFrames); } - return times; + return new ImmutablePair, DataTime[]>( + rsc, times); } } } @@ -499,21 +541,11 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { } /** - * Make an empty load list for a resource, if this is successful the - * resource will be defined as the time match basis - * - * @param descriptor - * @param rsc - * @return - * @throws VizException + * Make an empty load list for a resource. Only a time match basis should + * use this method for getting matched times. */ private DataTime[] makeEmptyLoadList(int numberOfFrames, - AbstractVizResource rsc) throws VizException { - if ((timeMatchBasis != null) && (rsc != timeMatchBasis)) { - throw new IllegalArgumentException( - "Cannot make Empty Load List for a resource which is not the Time Match Basis."); - } - + AbstractVizResource rsc) { TimeMatchingConfiguration config = getConfiguration( rsc.getLoadProperties()).clone(); if ((config.getDataTimes() == null) @@ -531,19 +563,14 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { if ((timeSteps == null) || (timeSteps.length == 0)) { return null; } - changeTimeMatchBasis(rsc); return timeSteps; } /** * Remove unused times from a resource and add in any new times. - * - * @param rsc - * @param timeSteps - * @throws VizException */ private void timeMatchUpdate(AbstractVizResource rsc, - DataTime[] timeSteps) throws VizException { + DataTime[] timeSteps) { if (rsc.getResourceData() instanceof IResourceGroup) { for (ResourcePair tmp : ((IResourceGroup) rsc.getResourceData()) @@ -562,9 +589,6 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { /** * Find the Time Matching Configuration for this resource. If one can't be * found, return an empty configuration. - * - * @param properties - * @return */ private TimeMatchingConfiguration getConfiguration(LoadProperties properties) { if (properties == null) { @@ -582,6 +606,11 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { return new TimeMatchingConfiguration(); } + /** + * Thread safe access to {@link #timeCacheMap}. If the map has no entry for + * this resource then a new {@link TimeCache} is created, added to the map, + * and returned. + */ private TimeCache getTimeCache(AbstractVizResource resource) { synchronized (timeCacheMap) { TimeCache cache = timeCacheMap.get(resource); @@ -596,8 +625,6 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { /** * Populates all unset fields of the configuration with defaults except * dataTimes, dataTimes should be set before calling this function. - * - * @param config */ private void populateConfiguration(TimeMatchingConfiguration config) { Arrays.sort(config.getDataTimes()); @@ -626,29 +653,33 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { } /** - * Retrieves the latest times from a time sequence resource + * Retrieves the latest times from a resource * - * If the resource is also requestable, we check the catalog for the latest - * product times. + * If the resource data is an {@link AbstractRequestableResourceData} then + * this will query for the available times. * - * @param rsc - * @param timeSteps - * @return - * @throws VizException */ protected DataTime[] getLatestTimes(AbstractVizResource rsc, - DataTime[] timeSteps) throws VizException { + DataTime[] timeSteps) { DataTime[] availableTimes = null; - // If resource is handling requests itself, just return the datatimes - // listed in the resource + /* + * If resource is handling requests itself, just return the datatimes + * listed in the resource + */ AbstractResourceData resourceData = rsc.getResourceData(); if (resourceData instanceof AbstractRequestableResourceData) { AbstractRequestableResourceData req = (AbstractRequestableResourceData) resourceData; if (req.isRequeryNecessaryOnTimeMatch() || (rsc.getDataTimes() == null) || (rsc.getDataTimes().length == 0)) { - availableTimes = req.getAvailableTimes(); + try { + availableTimes = req.getAvailableTimes(); + } catch (VizException e) { + statusHandler + .error("Unable to query times for " + + rsc.getSafeName(), e); + } } } @@ -662,7 +693,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { /** * Prunes data that is no longer used by calling - * AbstractVizResource.remove(DataTime). + * {@link AbstractVizResource#remove(DataTime)} * * @param rsc * the resource to prune @@ -715,10 +746,9 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { * available dataTimes * @param resource * the resource to update - * @throws VizException */ private void updateResourceWithLatest(DataTime[] dataTimes, - AbstractVizResource resource) throws VizException { + AbstractVizResource resource) { Validate.notNull(resource, "Resource must not be null"); if (resource.getResourceData() == null) { return; @@ -735,10 +765,16 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { * place to break things. */ Arrays.sort(dt, new DataTimeComparator()); - PluginDataObject[] pdo = arrd.getLatestPluginDataObjects(dataTimes, - dt); - if (pdo.length > 0) { - resource.getResourceData().update(pdo); + try { + PluginDataObject[] pdo = arrd.getLatestPluginDataObjects( + dataTimes, dt); + if (pdo.length > 0) { + resource.getResourceData().update(pdo); + } + } catch (VizException e) { + statusHandler.error( + "Unable to update data for " + resource.getSafeName(), + e); } } @@ -747,40 +783,40 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { @Override public void handleRemove(AbstractVizResource resource, IDescriptor descriptor) { - if ((resource == timeMatchBasis) - && (descriptor instanceof AbstractDescriptor)) { - synchronized (this) { - timeMatchBasis = null; - } - } + timeMatchBasisRef.compareAndSet(resource, null); synchronized (timeCacheMap) { timeCacheMap.remove(resource); } } - /** - * @return the loadMode - */ public LoadMode getLoadMode() { return loadMode; } - /** - * @param loadMode - * the loadMode to set - */ public void setLoadMode(LoadMode loadMode) { this.loadMode = loadMode; } + /** + * Attempt to match the provided availableTimes against the current state of + * the time matcher. This can be used while loading a resource to determine + * if any matching times are possible and for preloading any data for those + * times. + * + * This method is also responsible for using the + * AbstractTimeMatchingConfigurationFactory for this matcher to configure + * the time match settings. The final times the resource displays may change + * if other resources are being loaded concurrently. When a resource is done + * loading {@link #redoTimeMatching(IDescriptor)} must be used to properly + * add the resource to the {@link FramesInfo} of the {@link IDescriptor}. + */ @Override public DataTime[] initialLoad(LoadProperties loadProps, DataTime[] availableTimes, IDescriptor descriptor) throws VizException { - DataTime[] dataTimesToLoad = null; - TimeMatchingConfiguration config = null; + AbstractVizResource timeMatchBasis = timeMatchBasisRef.get(); if (timeMatchBasis == null) { config = configFactory.getConfiguration(loadProps, this, availableTimes, descriptor); @@ -810,8 +846,8 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { } populateConfiguration(config); DataTime[] existingDataTimes = getFrameTimes(descriptor, - descriptor.getFramesInfo(), descriptor.getFramesInfo() - .getTimeMap()); + timeMatchBasis, descriptor.getFramesInfo(), descriptor + .getFramesInfo().getTimeMap()); TimeMatcher tm = new TimeMatcher(); dataTimesToLoad = tm.makeOverlayList(config.getDataTimes(), @@ -821,7 +857,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { if ((timeMatchBasis.getDescriptor() != null) && (timeMatchBasis.getDescriptor() != descriptor)) { - // Still use my times, but the index from the time match basis + /* Still use my times, but the index from the time match basis */ FramesInfo myFi = descriptor.getFramesInfo(); FramesInfo tmFi = timeMatchBasis.getDescriptor() .getFramesInfo(); @@ -836,90 +872,77 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { /** * Changes the time match basis for the time matcher to be the specified * resource - * - * @param resource */ public void changeTimeMatchBasis(AbstractVizResource resource) { - if (timeMatchBasis != resource) { - if (timeMatchBasis != null) { - TimeMatchingConfiguration config = getConfiguration(timeMatchBasis - .getLoadProperties()); - config.setTimeMatchBasis(false); - TimeCache timeCache = getTimeCache(timeMatchBasis); - synchronized (timeCache) { - timeCache.setTimes(null, null); - } - timeMatchBasis - .unregisterListener(timeMatchBasisDisposeListener); - } - - timeMatchBasis = resource; - - if (timeMatchBasis != null) { - TimeMatchingConfiguration config = getConfiguration(timeMatchBasis - .getLoadProperties()); - config.setTimeMatchBasis(true); - TimeCache timeCache = getTimeCache(timeMatchBasis); - synchronized (timeCache) { - timeCache.setTimes(null, null); - } - timeMatchBasis.registerListener(timeMatchBasisDisposeListener); - } + if (resource != null) { + configureBasis(resource); + } + AbstractVizResource prev = timeMatchBasisRef.getAndSet(resource); + if (prev != null) { + unconfigureBasis(prev); } } /** - * Returns the time match basis for the D2DTimeMatcher - * - * @return + * Used to setup the {@link TimeMatchingConfiguration} and + * {@link #timeMatchBasisDisposeListener} for a new timeMatchBasis. This + * should be used before modifying the {@link TimeMatchBasisRef}. */ - public AbstractVizResource getTimeMatchBasis() { - return timeMatchBasis; - } - - public boolean hasTimeMatchBasis() { - return (timeMatchBasis != null); + private void configureBasis(AbstractVizResource newBasis) { + TimeMatchingConfiguration config = getConfiguration(newBasis + .getLoadProperties()); + config.setTimeMatchBasis(true); + TimeCache timeCache = getTimeCache(newBasis); + synchronized (timeCache) { + timeCache.setTimes(null, null); + } + newBasis.registerListener(timeMatchBasisDisposeListener); } /** - * @return the clockFilter + * Used to revert the {@link TimeMatchingConfiguration} and + * {@link #timeMatchBasisDisposeListener} when a timeMatchBasis is removed. + * This should be used after modifying the {@link TimeMatchBasisRef}. */ + private void unconfigureBasis(AbstractVizResource oldBasis) { + TimeMatchingConfiguration config = getConfiguration(oldBasis + .getLoadProperties()); + config.setTimeMatchBasis(false); + TimeCache timeCache = getTimeCache(oldBasis); + synchronized (timeCache) { + timeCache.setTimes(null, null); + } + oldBasis.unregisterListener(timeMatchBasisDisposeListener); + } + + public AbstractVizResource getTimeMatchBasis() { + return timeMatchBasisRef.get(); + } + + public boolean hasTimeMatchBasis() { + return (timeMatchBasisRef.get() != null); + } + public Date getClockFilter() { return clockFilter; } - /** - * @return the forecastFilter - */ public long getForecastFilter() { return forecastFilter; } - /** - * @return the deltaFilter - */ public long getDeltaFilter() { return deltaFilter; } - /** - * @return the isTimeOptionsSelected - */ public boolean isTimeOptionsSelected() { return isTimeOptionsSelected; } - /** - * @param isTimeOptionsSelected - * the isTimeOptionsSelected to set - */ public void setTimeOptionsSelected(boolean isTimeOptionsSelected) { this.isTimeOptionsSelected = isTimeOptionsSelected; } - /** - * @return the dataTimeDialogManager - */ public AbstractTimeMatchingConfigurationFactory getTimeMatchingConfigurationFactory() { return configFactory; } @@ -927,7 +950,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { @Override public List getDisplayLoadOrder( List displays) { - // if any of the displays have a set time match basis then load it first + /* if any of the displays have a set time match basis then load it first */ AbstractRenderableDisplay basisDisplay = null; for (AbstractRenderableDisplay display : displays) { if (getBasisResourcePair(display.getDescriptor().getResourceList()) != null) { @@ -947,8 +970,10 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { @Override public List getResourceLoadOrder(List resources) { - // if any of the resources are set as the time match basis then load it - // first + /* + * if any of the resources are set as the time match basis then load it + * first + */ ResourcePair basisPair = getBasisResourcePair(resources); if (basisPair != null) { List results = new ArrayList(resources); @@ -979,7 +1004,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { public void copyFrom(AbstractTimeMatcher timeMatcher) { if (timeMatcher instanceof D2DTimeMatcher) { D2DTimeMatcher d2d = (D2DTimeMatcher) timeMatcher; - if (timeMatchBasis == null) { + if (timeMatchBasisRef.get() == null) { this.clockFilter = d2d.clockFilter; this.forecastFilter = d2d.forecastFilter; this.deltaFilter = d2d.deltaFilter; @@ -994,7 +1019,8 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { configFactory.resetMultiload(); } - private boolean validateTimeMatchBasis(IDescriptor descriptor) { + private static boolean validateTimeMatchBasis(IDescriptor descriptor, + AbstractVizResource timeMatchBasis) { /* * If a resource is shared by multiple panels (this can be the case with * tools, at least), then it is necessary to search all of them as @@ -1010,18 +1036,21 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { IDescriptor paneDescriptor = paneDisplay != null ? paneDisplay .getDescriptor() : null; if ((paneDescriptor != null) - && validateTimeMatchBasis(paneDescriptor - .getResourceList())) { + && validateTimeMatchBasis( + paneDescriptor.getResourceList(), + timeMatchBasis)) { return true; } } } else { - return validateTimeMatchBasis(descriptor.getResourceList()); + return validateTimeMatchBasis(descriptor.getResourceList(), + timeMatchBasis); } return false; } - private boolean validateTimeMatchBasis(ResourceList list) { + private static boolean validateTimeMatchBasis(ResourceList list, + AbstractVizResource timeMatchBasis) { for (ResourcePair rp : list) { AbstractVizResource rsc = rp.getResource(); if (rsc == timeMatchBasis) { @@ -1031,8 +1060,9 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { continue; } else if ((rsc != null) && (rsc.getResourceData() instanceof IResourceGroup)) { - if (validateTimeMatchBasis(((IResourceGroup) rsc - .getResourceData()).getResourceList())) { + IResourceGroup group = (IResourceGroup) rsc.getResourceData(); + if (validateTimeMatchBasis(group.getResourceList(), + timeMatchBasis)) { return true; } } @@ -1045,7 +1075,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { return display.getContainer() != null; } - private boolean validateDescriptor(IDescriptor descriptor) { + private static boolean validateDescriptor(IDescriptor descriptor) { IRenderableDisplay display = descriptor.getRenderableDisplay(); IDisplayPaneContainer container = display != null ? display .getContainer() : null; @@ -1054,8 +1084,9 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { IRenderableDisplay paneDisplay = pane.getRenderableDisplay(); IDescriptor paneDescriptor = paneDisplay != null ? paneDisplay .getDescriptor() : null; - if (paneDescriptor == descriptor) + if (paneDescriptor == descriptor) { return true; + } } } return false; diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseAlaska.xml b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseAlaska.xml index 019d9de459..07b5cabc6e 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseAlaska.xml +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseAlaska.xml @@ -31,7 +31,7 @@ @@ -86,7 +86,7 @@ diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseAtlantic.xml b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseAtlantic.xml index 92d6c70827..d948049008 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseAtlantic.xml +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseAtlantic.xml @@ -77,13 +77,13 @@ @@ -108,12 +108,12 @@ diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseAustralia.xml b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseAustralia.xml index 410b2f3aee..df94e87ab6 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseAustralia.xml +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseAustralia.xml @@ -20,7 +20,7 @@ --> @@ -155,7 +155,7 @@ diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseCanadaEastern.xml b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseCanadaEastern.xml index 47048c0dec..4b8432767b 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseCanadaEastern.xml +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseCanadaEastern.xml @@ -70,7 +70,7 @@ @@ -95,7 +95,7 @@ diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseJapan.xml b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseJapan.xml index 160001720f..e74356312f 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseJapan.xml +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseJapan.xml @@ -158,7 +158,7 @@ @@ -168,7 +168,7 @@ diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseMexico.xml b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseMexico.xml index 01b6a6b107..7f17296169 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseMexico.xml +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseMexico.xml @@ -30,12 +30,12 @@ @@ -45,7 +45,7 @@ @@ -70,12 +70,12 @@ diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/basePacificEast.xml b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/basePacificEast.xml index 929c254b29..c171550d6f 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/basePacificEast.xml +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/basePacificEast.xml @@ -81,7 +81,7 @@ diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/basePacificWest.xml b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/basePacificWest.xml index 6e030771ab..84b79c272f 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/basePacificWest.xml +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/basePacificWest.xml @@ -25,7 +25,7 @@ @@ -72,12 +72,12 @@ @@ -122,7 +122,7 @@ diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseRussia.xml b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseRussia.xml index 8b73228ba9..19a3506607 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseRussia.xml +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseRussia.xml @@ -20,7 +20,7 @@ --> @@ -135,12 +135,12 @@ diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseUSCentral.xml b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseUSCentral.xml index f54605d3b6..bd7806397a 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseUSCentral.xml +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseUSCentral.xml @@ -65,7 +65,7 @@ @@ -100,7 +100,7 @@ @@ -115,7 +115,7 @@ diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseUSEastern.xml b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseUSEastern.xml index c86d43ca8b..fcdb113247 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseUSEastern.xml +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseUSEastern.xml @@ -165,7 +165,7 @@ diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseUSWestern.xml b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseUSWestern.xml index 6c2a17173d..48deeec1fd 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseUSWestern.xml +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/localization/menus/upperair/baseUSWestern.xml @@ -35,12 +35,12 @@ @@ -65,7 +65,7 @@ @@ -130,7 +130,7 @@ diff --git a/cave/com.raytheon.uf.viz.d2d.ui.ncephydro/localization/bundles/ncepHydro/SvrWxPlot.xml b/cave/com.raytheon.uf.viz.d2d.ui.ncephydro/localization/bundles/ncepHydro/SvrWxPlot.xml index 75e85c838a..8dbd836c72 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui.ncephydro/localization/bundles/ncepHydro/SvrWxPlot.xml +++ b/cave/com.raytheon.uf.viz.d2d.ui.ncephydro/localization/bundles/ncepHydro/SvrWxPlot.xml @@ -45,6 +45,11 @@ + + + + + @@ -69,6 +74,11 @@ + + + + + @@ -93,6 +103,11 @@ + + + + + diff --git a/cave/com.raytheon.uf.viz.d2d.ui.ncephydro/localization/menus/ncepHydro/tpc/hurricane.xml b/cave/com.raytheon.uf.viz.d2d.ui.ncephydro/localization/menus/ncepHydro/tpc/hurricane.xml index a1ffaef8e0..a5dfb1bbb6 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui.ncephydro/localization/menus/ncepHydro/tpc/hurricane.xml +++ b/cave/com.raytheon.uf.viz.d2d.ui.ncephydro/localization/menus/ncepHydro/tpc/hurricane.xml @@ -28,12 +28,12 @@ - + - + diff --git a/cave/com.raytheon.uf.viz.d2d.ui.upperair/localization/menus/upperair/baseAddedFeatures.xml b/cave/com.raytheon.uf.viz.d2d.ui.upperair/localization/menus/upperair/baseAddedFeatures.xml index 1070174a41..4d41a96981 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui.upperair/localization/menus/upperair/baseAddedFeatures.xml +++ b/cave/com.raytheon.uf.viz.d2d.ui.upperair/localization/menus/upperair/baseAddedFeatures.xml @@ -19,12 +19,4 @@ further_licensing_information. --> - - - - - - - - \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.d2d.ui.upperair/localization/menus/upperair/baseNPNPlot.xml b/cave/com.raytheon.uf.viz.d2d.ui.upperair/localization/menus/upperair/baseNPNPlot.xml index 6d0ea12fb6..beb3f22bfa 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui.upperair/localization/menus/upperair/baseNPNPlot.xml +++ b/cave/com.raytheon.uf.viz.d2d.ui.upperair/localization/menus/upperair/baseNPNPlot.xml @@ -98,7 +98,6 @@ - + \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.d2d.ui.upperair/localization/menus/upperair/baseRadar.xml b/cave/com.raytheon.uf.viz.d2d.ui.upperair/localization/menus/upperair/baseRadar.xml index 6d94615b29..a911376543 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui.upperair/localization/menus/upperair/baseRadar.xml +++ b/cave/com.raytheon.uf.viz.d2d.ui.upperair/localization/menus/upperair/baseRadar.xml @@ -168,6 +168,5 @@ - \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml b/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml index 91b3c6cb3d..cfa8627d00 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml +++ b/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml @@ -268,14 +268,42 @@ definitionId="com.raytheon.uf.viz.d2d.ui.inD2DActionSet"> - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Sep 13, 2007 chammack Initial Creation. - * Jul 8, 2008 #1183 chammack Migrate to new localization - * Oct 16, 2012 #1229 rferrel Changes for non-blocking VizLocalizationFileListDlg. - * Jun 02, 2015 #4401 bkowal Updated to use {@link VizLocalizationFileListDlg}. - * Jun 30, 2015 #4401 bkowal Specify the localization type when constructing a - * {@link VizLocalizationFileListDlg}. + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Sep 13, 2007 chammack Initial Creation. + * Jul 8, 2008 #1183 chammack Migrate to new localization + * Oct 16, 2012 #1229 rferrel Changes for non-blocking VizLocalizationFileListDlg. + * Jun 02, 2015 #4401 bkowal Updated to use {@link VizLocalizationFileListDlg}. + * Jun 30, 2015 #4401 bkowal Specify the localization type when constructing a + * {@link VizLocalizationFileListDlg}. + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods * * * @@ -64,13 +64,6 @@ public class DeleteAWIPSProcedure extends AbstractHandler { private VizLocalizationFileListDlg listDlg; - /* - * (non-Javadoc) - * - * @see - * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands - * .ExecutionEvent) - */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { if (listDlg == null || listDlg.getShell() == null @@ -83,15 +76,15 @@ public class DeleteAWIPSProcedure extends AbstractHandler { @Override public void dialogClosed(Object returnValue) { - if (returnValue instanceof LocalizationFile) { - LocalizationFile selectedFile = (LocalizationFile) returnValue; + if (returnValue instanceof ILocalizationFile) { + ILocalizationFile selectedFile = (ILocalizationFile) returnValue; try { selectedFile.delete(); - } catch (LocalizationOpFailedException e) { + } catch (LocalizationException e) { statusHandler.handle( Priority.PROBLEM, "Error deleting procedure: " - + selectedFile.getName()); + + selectedFile.getPath()); } } } diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/MagButtonHandler.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/MagButtonHandler.java index 7a14fa1fb2..59d492e024 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/MagButtonHandler.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/MagButtonHandler.java @@ -39,7 +39,9 @@ import com.raytheon.viz.ui.actions.AbstractGlobalsButtonHandler; * Jul 23, 2007 randerso Initial Creation. * Sep 4, 2012 15335 kshresth Will now display lightning/wind * fields when magnification set to 0 - * @author randerso + * Nov 05, 2015 5070 randerso Removed override of 0.0 magnification + * + * @author randerso * */ public class MagButtonHandler extends AbstractGlobalsButtonHandler implements @@ -53,7 +55,6 @@ public class MagButtonHandler extends AbstractGlobalsButtonHandler implements protected void updateGlobalValue(IWorkbenchWindow changedWindow, UIElement element, Object value) { Double mag = (Double) value; - if (mag <= 0.1) mag=0.0; element.setText("Mag: " + mag); } } diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/MagHandler.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/MagHandler.java index 59e5f06137..2f91addcb0 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/MagHandler.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/MagHandler.java @@ -49,6 +49,7 @@ import com.raytheon.viz.ui.EditorUtil; * Jul 19, 2007 randerso Initial Creation. * Sep 4, 2012 15335 kshresth Will now display lightning/wind * fields when magnification set to 0 + * Nov 05, 2015 5070 randerso Removed override of 0.0 magnification * * * @@ -73,8 +74,6 @@ public class MagHandler extends AbstractHandler implements IElementUpdater { double magnification = Double.parseDouble((arg0 .getParameter("magnification"))); if (editor != null) { - if (magnification == 0.0f) - magnification = 0.1; IDisplayPane[] panes = editor.getDisplayPanes(); for (IDisplayPane pane : panes) { IRenderableDisplay disp = pane.getRenderableDisplay(); diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/OpenAWIPSProcedure.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/OpenAWIPSProcedure.java index 01a6fbf939..2389878b0f 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/OpenAWIPSProcedure.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/OpenAWIPSProcedure.java @@ -36,7 +36,6 @@ import com.raytheon.uf.viz.d2d.ui.dialogs.procedures.ProcedureDlg; import com.raytheon.viz.ui.VizWorkbenchManager; import com.raytheon.viz.ui.actions.LoadPerspectiveHandler; import com.raytheon.viz.ui.dialogs.ICloseCallback; -import com.raytheon.viz.ui.dialogs.localization.VizLocalizationFileListDlg; import com.raytheon.viz.ui.dialogs.localization.VizOpenLocalizationFileListDlg; /** @@ -56,6 +55,7 @@ import com.raytheon.viz.ui.dialogs.localization.VizOpenLocalizationFileListDlg; * Jun 02, 2015 #4401 bkowal Updated to use {@link VizOpenLocalizationFileListDlg}. * Jun 30, 2015 #4401 bkowal Specify the localization type when constructing a * {@link VizOpenLocalizationFileListDlg}. + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods * * * @author chammack @@ -68,13 +68,6 @@ public class OpenAWIPSProcedure extends AbstractHandler { private static final IUFStatusHandler log = UFStatus .getHandler(OpenAWIPSProcedure.class); - /* - * (non-Javadoc) - * - * @see - * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands - * .ExecutionEvent) - */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { if (dialog == null || dialog.getShell() == null || dialog.isDisposed()) { @@ -95,7 +88,7 @@ public class OpenAWIPSProcedure extends AbstractHandler { log.info("Loading display file: " + f.getAbsolutePath()); ProcedureDlg.displayDialog(LocalizationUtil - .extractName(selectedFile.getName()), p, + .extractName(selectedFile.getPath()), p, VizWorkbenchManager.getInstance() .getCurrentWindow().getShell()); } diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/ImageBlinkDialog.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/ImageBlinkDialog.java index e0444aebf4..0c94a5eb91 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/ImageBlinkDialog.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/ImageBlinkDialog.java @@ -34,9 +34,9 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; @@ -59,9 +59,10 @@ import com.raytheon.viz.ui.dialogs.colordialog.IColorBarAction; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 13, 2010 mschenke Initial creation + * Sep 13, 2010 mschenke Initial creation * Oct 16, 2012 1229 rferrel Updated to use bringToTop to * activate existing dialog. + * Jan 15, 2015 5054 randerso Remove unnecessary new Shell * * * @@ -110,8 +111,10 @@ public class ImageBlinkDialog extends CaveSWTDialog implements D2DMapRenderableDisplay[] displays) { ImageBlinkDialog dlg = dialogMap.get(resource); if (dlg == null || dlg.getShell() == null || dlg.isDisposed()) { - dlg = new ImageBlinkDialog(new Shell(Display.getCurrent()), rates, - currRate, resource, rscProps, displays); + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(); + dlg = new ImageBlinkDialog(shell, rates, currRate, resource, + rscProps, displays); dialogMap.put(resource, dlg); dlg.open(); } else { diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/PrintDialog.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/PrintDialog.java index 872e98d3d0..0886a23742 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/PrintDialog.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/PrintDialog.java @@ -27,8 +27,7 @@ import java.awt.image.ComponentColorModel; import java.awt.image.IndexColorModel; import java.awt.image.WritableRaster; import java.io.File; -import java.io.IOException; -import java.io.OutputStream; +import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -63,12 +62,13 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Spinner; import org.eclipse.swt.widgets.Text; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; -import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.localization.SaveableOutputStream; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.core.IDisplayPane; @@ -85,7 +85,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.editor.AbstractEditor; /** - * TODO Add Description + * Class representing a print dialog with various print settings. * *
  * 
@@ -94,12 +94,12 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Feb 15, 2011            bkowal     Initial creation
- * ======================================
- * AWIPS2 DR Work
  * 08/15/2012         1053 jkorman     Added capability to save/restore user
  * print settings.
  * 10/12/2012         1229 rferrel    Made dialog non-blocking.
  * 12/09/2014   ASM #11982 D. Friedman Fix print-to-file
+ * 01/11/2016         5242 kbisanz     Replaced calls to deprecated LocalizationFile methods
+ * 
  * 
  * 
* @@ -651,8 +651,8 @@ public class PrintDialog extends CaveSWTDialog { } else if (this.fileRadioButton.getSelection()) { printerSettings.selectedPrinter = this.printToFileData; printerSettings.selectedPrinter.printToFile = true; - printerSettings.selectedPrinter.fileName = - this.destinationFileText.getText(); + printerSettings.selectedPrinter.fileName = this.destinationFileText + .getText(); } printerSettings.selectedPrinter.copyCount = this.copiesSpinner .getSelection(); @@ -910,25 +910,15 @@ public class PrintDialog extends CaveSWTDialog { LocalizationContext ctx = initUserLocalization(); // Get a list of localization files! - LocalizationFile f = PathManagerFactory.getPathManager() + ILocalizationFile f = PathManagerFactory.getPathManager() .getLocalizationFile(ctx, SETTINGS_FILENAME); - OutputStream strm = null; - try { - strm = f.openOutputStream(); + + try (SaveableOutputStream strm = f.openOutputStream()) { JAXB.marshal(settings, strm); // Ensure that the file is saved on the server! - f.save(); + strm.save(); } catch (Exception e) { statusHandler.error("Could not save user print settings", e); - } finally { - if (f != null) { - try { - strm.close(); - } catch (IOException ioe) { - statusHandler.error("Could not close user print settings", - ioe); - } - } } } @@ -940,15 +930,15 @@ public class PrintDialog extends CaveSWTDialog { LocalizationContext ctx = initUserLocalization(); // Get a list of localization files! - LocalizationFile f = PathManagerFactory.getPathManager() + ILocalizationFile f = PathManagerFactory.getPathManager() .getLocalizationFile(ctx, SETTINGS_FILENAME); // If its not there, no previous settings have been saved. Just exit. if (f.exists()) { UserPrintSettings settings = null; - try { + try (InputStream strm = f.openInputStream()) { - settings = (UserPrintSettings) JAXB.unmarshal( - f.openInputStream(), UserPrintSettings.class); + settings = (UserPrintSettings) JAXB.unmarshal(strm, + UserPrintSettings.class); } catch (Exception e) { statusHandler.error( @@ -1041,4 +1031,4 @@ public class PrintDialog extends CaveSWTDialog { return localization; } -} \ No newline at end of file +} diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java index 517f4da18c..cdd7c4aba4 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java @@ -20,7 +20,6 @@ package com.raytheon.uf.viz.d2d.ui.dialogs.procedures; -import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -56,17 +55,17 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.PlatformUI; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; -import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.localization.SaveableOutputStream; 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.DataTime; -import com.raytheon.uf.common.util.FileUtil; import com.raytheon.uf.viz.core.DescriptorMap; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.drawables.AbstractDescriptor; @@ -118,6 +117,7 @@ import com.raytheon.viz.ui.views.PartAdapter2; * Mar 12, 2015 4204 njensen Ensure renamed bundle goes into tab name on next load * Apr 08, 2015 4185 mapeters Disable Copy In when not applicable for active editor * Jun 02, 2015 4401 bkowal Updated to use {@link VizLocalizationFileListDlg}. + * Feb 12, 2016 5242 dgilling Remove calls to deprecated Localization APIs. * * * @@ -358,14 +358,6 @@ public class ProcedureDlg extends CaveSWTDialog { ProcedureComm.getInstance().addCopyOutStateListener(changeListener); final ProcedureComm.ICopyOutListener copyOutListener = new ProcedureComm.ICopyOutListener() { - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ui.dialogs.procedure.ProcedureComm.ICopyOutListener - * #copyOut(com.raytheon.viz.ui.dialogs.procedure.ProcedureComm. - * BundlePair, java.lang.Object) - */ @Override public void copyOut(BundlePair b, Object src) { if (src != thisDlg) { @@ -438,14 +430,6 @@ public class ProcedureDlg extends CaveSWTDialog { private void saveProcedure(boolean closeAfterSave) { try { - IPathManager pm = PathManagerFactory.getPathManager(); - - LocalizationContext context = pm.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.USER); - - LocalizationFile localizationFile = pm.getLocalizationFile(context, - PROCEDURES_DIR + File.separator + fileName); - Procedure procedure = new Procedure(); BundlePair[] bp = bundles.toArray(new BundlePair[bundles.size()]); Bundle[] bundlesToSave = new Bundle[bp.length]; @@ -472,17 +456,26 @@ public class ProcedureDlg extends CaveSWTDialog { } procedure.setBundles(bundlesToSave); + IPathManager pm = PathManagerFactory.getPathManager(); + LocalizationContext context = pm.getContext( + LocalizationType.CAVE_STATIC, LocalizationLevel.USER); + ILocalizationFile localizationFile = pm + .getLocalizationFile(context, PROCEDURES_DIR + + IPathManager.SEPARATOR + fileName); String procedureXML = procedure.toXML(); - FileUtil.bytes2File(procedureXML.getBytes(), - localizationFile.getFile()); - localizationFile.save(); + try (SaveableOutputStream outStream = localizationFile + .openOutputStream()) { + outStream.write(procedureXML.getBytes()); + outStream.save(); + } shell.setText("Procedure - " + fileName); saved = true; saveBtn.setEnabled(false); - if (closeAfterSave) + if (closeAfterSave) { close(); + } } catch (Exception e) { final String errMsg = "Error occurred during procedure save."; statusHandler.handle(Priority.PROBLEM, errMsg, e); diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/SideView.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/SideView.java index 6e43a2510a..2afaf3d633 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/SideView.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/SideView.java @@ -72,30 +72,31 @@ import com.raytheon.viz.ui.panes.PaneManager; import com.vividsolutions.jts.geom.Coordinate; /** - * The side view for "docking" maps + * The side view for "docking" displays. * *
  * 
- *      SOFTWARE HISTORY
+ * SOFTWARE HISTORY
  *     
- *      Date       	    Ticket#		Engineer	Description
- *      ------------	----------	-----------	--------------------------
- *      7/1/06                      chammack    Initial Creation.
- *      Dec 19, 2007                njensen     Support for different tab types.
- *      Jul  8, 2009    #830        bgonzale    use pane manager instead of managing own panes.
- *      Oct  22, 2009   #3348       bsteffen    limit number of frames in sidepane rather than reseting
- *      Jul 1, 2010     #6146       bkowal      Updates the legend mode so that smaller panes will 
- *                                              now include a legend
- *      Nov 20, 2012   DR 15524    M.Porricelli Changed so interactive screens still editable when
- *                                              swapped to side panel
- *      Mar 21, 2013       1638     mschenke    Changed map scales not tied to d2d
- *      Aug  9, 2013   DR 16427     D. Friedman Swap additional input handlers.
- *      Oct 10, 2013    #2104       mschenke    Switched to use MapScalesManager
- *      Jul 15, 2014     2954       njensen     Updated init() for MapScalesManager change
- *      Aug 25, 2014     3467       mapeters    Removed changing of editability from swapPanes().
- *      Mar 02, 2015     4204       njensen     Support for swapping part names
- *      Apr 02, 2015     4204       njensen     Fix 4-panel swap of renamed parts
- *      Sep 18, 2015   DR 17996     D. Friedman Clear editor pane's IRenderableDisplay before swap
+ * Date         Ticket#     Engineer    Description
+ * ------------ ----------  ----------- --------------------------
+ * Jul 01, 2006             chammack    Initial Creation.
+ * Dec 19, 2007             njensen     Support for different tab types.
+ * Jul 08, 2009    830      bgonzale    use pane manager instead of managing own panes.
+ * Oct 22, 2009    334      bsteffen    limit number of frames in sidepane rather than reseting
+ * Jul 01, 2010    6146     bkowal      Updates the legend mode so that smaller panes will 
+ *                                       now include a legend
+ * Nov 20, 2012 DR 15524    M.Porricelli Changed so interactive screens still editable when
+ *                                        swapped to side panel
+ * Mar 21, 2013    1638     mschenke    Changed map scales not tied to d2d
+ * Aug 09, 2013 DR 16427    D. Friedman Swap additional input handlers.
+ * Oct 10, 2013    2104     mschenke    Switched to use MapScalesManager
+ * Jul 15, 2014    2954     njensen     Updated init() for MapScalesManager change
+ * Aug 25, 2014    3467     mapeters    Removed changing of editability from swapPanes().
+ * Mar 02, 2015    4204     njensen     Support for swapping part names
+ * Apr 02, 2015    4204     njensen     Fix 4-panel swap of renamed parts
+ * Sep 18, 2015 DR 17996    D. Friedman Clear editor pane's IRenderableDisplay before swap
+ * Oct 21, 2015    5023     njensen     Removed unnecessary setPartName()
  * 
  * 
* @@ -151,13 +152,6 @@ public class SideView extends ViewPart implements IMultiPaneEditor, } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets - * .Composite) - */ @Override public void createPartControl(Composite parent) { try { @@ -202,24 +196,12 @@ public class SideView extends ViewPart implements IMultiPaneEditor, int buttonDown = 0; - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDown(int, - * int, int) - */ @Override public boolean handleMouseDown(int x, int y, int mouseButton) { buttonDown = mouseButton; return false; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseUp(int, int, - * int) - */ @Override public boolean handleMouseUp(int x, int y, int mouseButton) { if (buttonDown == 3 && buttonDown == mouseButton) { // right click @@ -231,11 +213,6 @@ public class SideView extends ViewPart implements IMultiPaneEditor, } }; - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.IDisplayPaneContainer#getDisplayPanes() - */ @Override public IDisplayPane[] getDisplayPanes() { if (this.paneManager == null) { @@ -245,43 +222,21 @@ public class SideView extends ViewPart implements IMultiPaneEditor, } } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.IDisplayPaneContainer#getLoopProperties() - */ @Override public LoopProperties getLoopProperties() { return this.loopProperties; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ui.IDisplayPaneContainer#setLoopProperties(com.raytheon - * .viz.core.datastructure.LoopProperties) - */ @Override public void setLoopProperties(LoopProperties loopProperties) { this.loopProperties = loopProperties; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.core.IDisplayPaneContainer#getActiveDisplayPane() - */ @Override public IDisplayPane getActiveDisplayPane() { return paneManager.getActiveDisplayPane(); } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.core.IDisplayPaneContainer#refresh() - */ @Override public void refresh() { paneManager.refresh(); @@ -425,7 +380,10 @@ public class SideView extends ViewPart implements IMultiPaneEditor, IRenderableDisplay display = editorPanes[i] .getRenderableDisplay(); boolean hide = editorHiddenDisplays.contains(display); - // TODO: See note above for the isCompatibleEditor condition. + /* + * TODO: See note above for the isCompatibleEditor + * condition. + */ if (isCompatibleEditor) { editorPanes[i].setRenderableDisplay(null); } @@ -492,11 +450,6 @@ public class SideView extends ViewPart implements IMultiPaneEditor, } } } - /* - * have to set part name again here cause addPane() or - * removePane() may mess it up - */ - theEditor.setPartName(viewName); } else { int min = Math.min(viewPaneCount, editorPaneCount); for (int i = 0; i < min; ++i) { @@ -626,24 +579,11 @@ public class SideView extends ViewPart implements IMultiPaneEditor, } } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.core.IDisplayPaneContainer#translateClick(double, - * double) - */ @Override public Coordinate translateClick(double x, double y) { return paneManager.translateClick(x, y); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.core.IDisplayPaneContainer#translateInverseClick( - * com.vividsolutions.jts.geom.Coordinate) - */ @Override public double[] translateInverseClick(Coordinate c) { return paneManager.translateInverseClick(c); @@ -703,68 +643,34 @@ public class SideView extends ViewPart implements IMultiPaneEditor, paneManager.showPane(pane); } - /* - * (non-Javadoc) - * - * @seecom.raytheon.uf.viz.core.IDisplayPaneContainer# - * addRenderableDisplayChangedListener - * (com.raytheon.uf.viz.core.IRenderableDisplayChangedListener) - */ @Override public void addRenderableDisplayChangedListener( IRenderableDisplayChangedListener displayChangedListener) { - + // no op } - /* - * (non-Javadoc) - * - * @seecom.raytheon.uf.viz.core.IDisplayPaneContainer# - * notifyRenderableDisplayChangedListeners - * (com.raytheon.uf.viz.core.IDisplayPane, - * com.raytheon.uf.viz.core.drawables.IRenderableDisplay) - */ @Override public void notifyRenderableDisplayChangedListeners(IDisplayPane pane, IRenderableDisplay display, DisplayChangeType type) { - + // no op } - /* - * (non-Javadoc) - * - * @seecom.raytheon.uf.viz.core.IDisplayPaneContainer# - * removeRenderableDisplayChangedListener - * (com.raytheon.uf.viz.core.IRenderableDisplayChangedListener) - */ @Override public void removeRenderableDisplayChangedListener( IRenderableDisplayChangedListener displayChangedListener) { - + // no op } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ui.editor.IMultiPaneEditor#addSelectedPaneChangedListener - * (com.raytheon.viz.ui.editor.ISelectedPaneChangedListener) - */ @Override public void addSelectedPaneChangedListener( ISelectedPanesChangedListener listener) { + // no op } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ui.editor.IMultiPaneEditor#removeSelectedPaneChangedListener - * (com.raytheon.viz.ui.editor.ISelectedPaneChangedListener) - */ @Override public void removeSelectedPaneChangedListener( ISelectedPanesChangedListener listener) { + // no op } @Override @@ -783,26 +689,11 @@ public class SideView extends ViewPart implements IMultiPaneEditor, paneManager.unregisterMouseHandler(handler); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ui.editor.IMultiPaneEditor#getSelectedPanes(java.lang - * .String) - */ @Override public IDisplayPane[] getSelectedPanes(String action) { return paneManager.getSelectedPanes(action); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ui.color.IBackgroundColorChangedListener#setColor(com - * .raytheon.viz.ui.color.IBackgroundColorChangedListener.BGColorMode, - * org.eclipse.swt.graphics.RGB) - */ @Override public void setColor(BGColorMode mode, RGB newColor) { for (IDisplayPane pane : getDisplayPanes()) { diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/actions/FourPanelLayoutMenuAction.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/actions/FourPanelLayoutMenuAction.java index d2a198b918..06dbb8dd5d 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/actions/FourPanelLayoutMenuAction.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/actions/FourPanelLayoutMenuAction.java @@ -21,14 +21,11 @@ package com.raytheon.uf.viz.d2d.ui.map.actions; import java.util.List; -import org.eclipse.ui.part.EditorPart; - import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.drawables.IRenderableDisplay; import com.raytheon.uf.viz.d2d.core.ID2DRenderableDisplay; import com.raytheon.uf.viz.d2d.core.legend.D2DLegendResource; import com.raytheon.uf.viz.d2d.core.legend.D2DLegendResource.LegendMode; -import com.raytheon.viz.ui.IRenameablePart; import com.raytheon.viz.ui.cmenu.AbstractRightClickAction; import com.raytheon.viz.ui.editor.IMultiPaneEditor; @@ -43,12 +40,13 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor; * *
  * 
- *    SOFTWARE HISTORY
+ * SOFTWARE HISTORY
  *   
- *    Date         Ticket#     Engineer    Description
- *    ------------ ----------  ----------- --------------------------
- *    Aug 19, 2009             bgonzale    Initial Creation.
- *    Apr 07, 2015  4204       njensen     Keep part name if renamed
+ * Date         Ticket#     Engineer    Description
+ * ------------ ----------  ----------- --------------------------
+ * Aug 19, 2009             bgonzale    Initial Creation.
+ * Apr 07, 2015  4204       njensen     Keep part name if renamed
+ * Oct 21, 2015  5023       njensen     Removed unnecessary part name code (undid previous change)
  * 
  * 
* @@ -64,11 +62,6 @@ public class FourPanelLayoutMenuAction extends AbstractRightClickAction { super("Four Panel Layout"); } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.action.Action#run() - */ @Override public void run() { if (getContainer() instanceof IMultiPaneEditor == false @@ -79,14 +72,6 @@ public class FourPanelLayoutMenuAction extends AbstractRightClickAction { IRenderableDisplay definiteDisplay = getContainer().getDisplayPanes()[0] .getRenderableDisplay(); - String partName = null; - if (editor instanceof EditorPart) { - EditorPart part = (EditorPart) editor; - if (!part.getPartName().equals(part.getEditorInput().getName())) { - partName = part.getPartName(); - } - } - if (editor.getNumberofPanes() > 1) { for (IDisplayPane pane : getContainer().getDisplayPanes()) { editor.showPane(pane); @@ -97,11 +82,6 @@ public class FourPanelLayoutMenuAction extends AbstractRightClickAction { } } - // keep the part name if it was customized - if (partName != null && editor instanceof IRenameablePart) { - ((IRenameablePart) editor).setPartName(partName); - } - for (IDisplayPane pane : editor.getDisplayPanes()) { List rscs = pane.getDescriptor() .getResourceList() diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrquikscat/utility/edex_static/base/plugin-filters/quikscat_filters.xml b/cave/com.raytheon.uf.viz.damagepath/localization/menus/tools/damagepath-index.xml similarity index 61% rename from edexOsgi/com.raytheon.uf.edex.plugin.bufrquikscat/utility/edex_static/base/plugin-filters/quikscat_filters.xml rename to cave/com.raytheon.uf.viz.damagepath/localization/menus/tools/damagepath-index.xml index a770b7ddbf..2cd7df9958 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.bufrquikscat/utility/edex_static/base/plugin-filters/quikscat_filters.xml +++ b/cave/com.raytheon.uf.viz.damagepath/localization/menus/tools/damagepath-index.xml @@ -18,15 +18,8 @@ See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for further_licensing_information. --> - - - - Exclude SouthernHemisphere - EXCLUDE - -0.1 - -180.0 - -90.0 - 180.0 - - Point.QuikScat - + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrquikscat/res/pointdata/bufrquikscat.xml b/cave/com.raytheon.uf.viz.damagepath/localization/menus/tools/damagepath-menu.xml similarity index 54% rename from edexOsgi/com.raytheon.uf.edex.plugin.bufrquikscat/res/pointdata/bufrquikscat.xml rename to cave/com.raytheon.uf.viz.damagepath/localization/menus/tools/damagepath-menu.xml index c5a142160d..630e3a250d 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.bufrquikscat/res/pointdata/bufrquikscat.xml +++ b/cave/com.raytheon.uf.viz.damagepath/localization/menus/tools/damagepath-menu.xml @@ -1,4 +1,4 @@ - + - - - - - - - - - - - - + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.damagepath/src/com/raytheon/uf/viz/damagepath/DamagePathLayer.java b/cave/com.raytheon.uf.viz.damagepath/src/com/raytheon/uf/viz/damagepath/DamagePathLayer.java index be0a393730..0c3a28ae45 100644 --- a/cave/com.raytheon.uf.viz.damagepath/src/com/raytheon/uf/viz/damagepath/DamagePathLayer.java +++ b/cave/com.raytheon.uf.viz.damagepath/src/com/raytheon/uf/viz/damagepath/DamagePathLayer.java @@ -43,6 +43,7 @@ import com.raytheon.uf.common.json.geo.GeoJsonMapUtil; import com.raytheon.uf.common.json.geo.IGeoJsonService; import com.raytheon.uf.common.json.geo.SimpleGeoJsonService; import com.raytheon.uf.common.localization.FileUpdatedMessage; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.ILocalizationFileObserver; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; @@ -88,7 +89,8 @@ import com.vividsolutions.jts.geom.Polygon; * INFO level, fix geotools CRS warning. * Aug 05, 2015 4635 dgilling Default save location for damage path * is now at SITE level. - * Aug 18, 2015 3806 njensen Use SaveableOutputStream to save + * Aug 18, 2015 3806 njensen Use SaveableOutputStream to save + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods * * * @@ -133,7 +135,7 @@ public class DamagePathLayer extends private final Job loadJob = new Job("Loading Damage Path") { @Override protected IStatus run(IProgressMonitor monitor) { - LocalizationFile prevFile = getValidDamagePathFile(); + ILocalizationFile prevFile = getValidDamagePathFile(); if (prevFile != null) { loadDamagePath(prevFile); @@ -154,7 +156,7 @@ public class DamagePathLayer extends private final Job saveJob = new Job("Saving Damage Path") { @Override protected IStatus run(IProgressMonitor monitor) { - LocalizationFile file = getDamagePathFile(); + ILocalizationFile file = getDamagePathFile(); saveDamagePath(file); return Status.OK_STATUS; } @@ -231,11 +233,11 @@ public class DamagePathLayer extends * future release, remove this function and replace uses with * getDamagePathFile. */ - private LocalizationFile getValidDamagePathFile() { + private ILocalizationFile getValidDamagePathFile() { LocalizationContext ctx = getContext(); - LocalizationFile file = PathManagerFactory.getPathManager() + ILocalizationFile file = PathManagerFactory.getPathManager() .getLocalizationFile(ctx, PATH); - LocalizationFile oldFile = PathManagerFactory.getPathManager() + ILocalizationFile oldFile = PathManagerFactory.getPathManager() .getLocalizationFile(ctx, OLD_PATH); if (file.exists()) { return file; @@ -249,14 +251,14 @@ public class DamagePathLayer extends @Override public void fileUpdated(FileUpdatedMessage message) { if (message.getFileName().equals(PATH)) { - LocalizationFile file = getDamagePathFile(); + ILocalizationFile file = getDamagePathFile(); if (file.exists()) { loadDamagePath(file); } } } - protected void loadDamagePath(LocalizationFile file) { + protected void loadDamagePath(ILocalizationFile file) { try { DamagePathLoader loader = new DamagePathLoader(file); Collection>> newData = loader @@ -279,11 +281,11 @@ public class DamagePathLayer extends } } catch (Exception e) { statusHandler.error( - "Error loading damage path file " + file.getName(), e); + "Error loading damage path file " + file.getPath(), e); } } - protected void saveDamagePath(LocalizationFile file) { + protected void saveDamagePath(ILocalizationFile file) { try (SaveableOutputStream sos = file.openOutputStream()) { IGeoJsonService json = new SimpleGeoJsonService(); SimpleFeatureCollection featureCollection = buildFeatureCollection(); @@ -291,7 +293,7 @@ public class DamagePathLayer extends sos.save(); } catch (Throwable t) { statusHandler.error( - "Error saving damage path file " + file.getName(), t); + "Error saving damage path file " + file.getPath(), t); } } diff --git a/cave/com.raytheon.uf.viz.damagepath/src/com/raytheon/uf/viz/damagepath/DamagePathLoader.java b/cave/com.raytheon.uf.viz.damagepath/src/com/raytheon/uf/viz/damagepath/DamagePathLoader.java index 54409d5f96..2b6de83ed1 100644 --- a/cave/com.raytheon.uf.viz.damagepath/src/com/raytheon/uf/viz/damagepath/DamagePathLoader.java +++ b/cave/com.raytheon.uf.viz.damagepath/src/com/raytheon/uf/viz/damagepath/DamagePathLoader.java @@ -40,7 +40,7 @@ import com.raytheon.uf.common.json.JsonException; import com.raytheon.uf.common.json.geo.GeoJsonMapUtil; import com.raytheon.uf.common.json.geo.IGeoJsonService; import com.raytheon.uf.common.json.geo.SimpleGeoJsonService; -import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.util.Pair; import com.vividsolutions.jts.geom.Geometry; @@ -63,6 +63,7 @@ import com.vividsolutions.jts.geom.Polygon; * 15.1 version of damage path tool. * Jul 01, 2015 #4375 dgilling Remove isValid check to imported * polygons. + * Jan 11, 2016 #5242 kbisanz Replaced calls to deprecated LocalizationFile methods * * * @@ -76,7 +77,7 @@ public final class DamagePathLoader { private final Collection>> damagePathData; - public DamagePathLoader(LocalizationFile locFile) + public DamagePathLoader(ILocalizationFile locFile) throws LocalizationException, IOException, JsonException { this(locFile, null); } @@ -86,8 +87,9 @@ public final class DamagePathLoader { this(null, Paths.get(filePath)); } - private DamagePathLoader(LocalizationFile locFileSource, Path realFileSource) - throws LocalizationException, IOException, JsonException { + private DamagePathLoader(ILocalizationFile locFileSource, + Path realFileSource) throws LocalizationException, IOException, + JsonException { this.damagePathData = new ArrayList<>(); if (locFileSource != null) { @@ -101,7 +103,7 @@ public final class DamagePathLoader { return damagePathData; } - private void loadFromLocalizationFile(final LocalizationFile locFile) + private void loadFromLocalizationFile(final ILocalizationFile locFile) throws LocalizationException, IOException, JsonException { try (InputStream is = locFile.openInputStream()) { loadFromInputStream(is); diff --git a/cave/com.raytheon.uf.viz.dataplugins.feature/feature.xml b/cave/com.raytheon.uf.viz.dataplugins.feature/feature.xml index 6c0a799102..1c4a327831 100644 --- a/cave/com.raytheon.uf.viz.dataplugins.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.dataplugins.feature/feature.xml @@ -63,13 +63,6 @@ version="0.0.0" unpack="false"/> - - * @@ -74,23 +73,6 @@ public class DerivedParamWizard extends CaveSWTWizard { addPage(newFunctionPage); } - /* - * Max, I took this out but itwill go away with the SWT Wizard stuff. - */ - - // @Override - // public void createPageControls(Composite pageContainer) { - // pageContainer.setLayout(new GridLayout(1, false)); - // pageContainer.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, - // false)); - // super.createPageControls(pageContainer); - // } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.Wizard#performFinish() - */ @Override public boolean performFinish() { IPathManager pm = PathManagerFactory.getPathManager(); @@ -102,15 +84,11 @@ public class DerivedParamWizard extends CaveSWTWizard { String fileName = newFunctionPage.getFunctionName() + "." + newFunctionPage.getSelectedFunctionType().getExtension(); String path = DerivedParameterGenerator.FUNCTIONS_DIR - + File.separator + fileName; + + IPathManager.SEPARATOR + fileName; LocalizationFile file = pm.getLocalizationFile(userCtx, path); - File f = file.getFile(); - if (f.exists()) { - f.delete(); - } - try { - FileUtil.bytes2File(functionContents.getBytes(), f); - file.save(); + try (SaveableOutputStream outStream = file.openOutputStream()) { + outStream.write(functionContents.getBytes()); + outStream.save(); functionFile = file; } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), @@ -123,13 +101,9 @@ public class DerivedParamWizard extends CaveSWTWizard { String path = DerivedParameterGenerator.XML_DIR + IPathManager.SEPARATOR + fileName; LocalizationFile file = pm.getLocalizationFile(userCtx, path); - File f = file.getFile(); - if (f.exists()) { - f.delete(); - } - try { - FileUtil.bytes2File(definitionContents.getBytes(), f); - file.save(); + try (SaveableOutputStream outStream = file.openOutputStream()) { + outStream.write(functionContents.getBytes()); + outStream.save(); definitionFile = file; } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), diff --git a/cave/com.raytheon.uf.viz.feature.alertviz/feature.xml b/cave/com.raytheon.uf.viz.feature.alertviz/feature.xml index a6ea404280..49432d2d26 100644 --- a/cave/com.raytheon.uf.viz.feature.alertviz/feature.xml +++ b/cave/com.raytheon.uf.viz.feature.alertviz/feature.xml @@ -413,6 +413,13 @@ install-size="0" version="0.0.0" unpack="false"/> + + * @@ -427,7 +428,8 @@ public class DataStoreResource extends DrawableString ds = new DrawableString(label, null); - ds.font = req.getResource().font; + ds.font = req.getResource().getFont( + req.getTarget()); Rectangle2D rect = req.getTarget() .getStringsBounds(ds); @@ -1113,8 +1115,9 @@ public class DataStoreResource extends } @Override - protected void paintInternal(IGraphicsTarget aTarget, + protected void paintInternal(IGraphicsTarget target, PaintProperties paintProps) throws VizException { + PixelExtent screenExtent = (PixelExtent) paintProps.getView() .getExtent(); @@ -1148,12 +1151,6 @@ public class DataStoreResource extends double labelMagnification = getCapability(MagnificationCapability.class) .getMagnification(); - if (font == null) { - font = aTarget.initializeFont(aTarget.getDefaultFont() - .getFontName(), (float) (10 * labelMagnification), null); - font.setSmoothing(false); - } - String shadingField = getCapability(ShadeableCapability.class) .getShadingField(); boolean isShaded = isPolygonal() && (shadingField != null); @@ -1189,7 +1186,7 @@ public class DataStoreResource extends boolean highlightsOnly = updateHighlights && !updateLabels && !updateShading && !updateExtent; - queryJob.queueRequest(new Request(aTarget, this, boundingGeom, + queryJob.queueRequest(new Request(target, this, boundingGeom, geomField, labelField, shadingField, colorMap, isProduct, highlightsOnly)); lastExtent = expandedExtent; @@ -1210,12 +1207,12 @@ public class DataStoreResource extends && shadedShape.isDrawable()) { float opacity = getCapability(ShadeableCapability.class) .getOpacity(); - aTarget.drawShadedShape(shadedShape, alpha * opacity); + target.drawShadedShape(shadedShape, alpha * opacity); } if ((outlineShape != null) && outlineShape.isDrawable() && getCapability(OutlineCapability.class).isOutlineOn()) { - aTarget.drawWireframeShape(outlineShape, + target.drawWireframeShape(outlineShape, getCapability(ColorableCapability.class).getColor(), getCapability(OutlineCapability.class).getOutlineWidth(), getCapability(OutlineCapability.class).getLineStyle(), @@ -1227,18 +1224,18 @@ public class DataStoreResource extends if ((highlightShape != null) && highlightShape.isDrawable() && getCapability(OutlineCapability.class).isOutlineOn()) { - aTarget.drawWireframeShape(highlightShape, highlightColor, + target.drawWireframeShape(highlightShape, highlightColor, highlightWidth, highlightStyle); } if ((labels != null) && isLabeled && (labelMagnification != 0)) { - drawLabels(aTarget, paintProps, worldToScreenRatio); + drawLabels(target, paintProps, worldToScreenRatio); } if (rubberBandExtent != null) { - aTarget.drawShadedRect(rubberBandExtent, RUBBER_BAND_COLOR, 0.5, + target.drawShadedRect(rubberBandExtent, RUBBER_BAND_COLOR, 0.5, null); - aTarget.drawRect(rubberBandExtent, RUBBER_BAND_COLOR, 2, 1.0); + target.drawRect(rubberBandExtent, RUBBER_BAND_COLOR, 2, 1.0); } if (dragPromptCoord != null) { @@ -1249,7 +1246,7 @@ public class DataStoreResource extends ds.addTextStyle(TextStyle.BOXED, new RGB(255, 255, 255)); ds.horizontalAlignment = HorizontalAlignment.LEFT; ds.verticallAlignment = VerticalAlignment.BOTTOM; - aTarget.drawStrings(ds); + target.drawStrings(ds); } } @@ -1279,9 +1276,8 @@ public class DataStoreResource extends highlightShape = result.highlightShape; } - private void drawLabels(IGraphicsTarget aTarget, - PaintProperties paintProps, double worldToScreenRatio) - throws VizException { + private void drawLabels(IGraphicsTarget target, PaintProperties paintProps, + double worldToScreenRatio) throws VizException { double offsetX = getCapability(LabelableCapability.class).getxOffset() * worldToScreenRatio; double offsetY = getCapability(LabelableCapability.class).getyOffset() @@ -1315,7 +1311,7 @@ public class DataStoreResource extends DrawableString string = new DrawableString(node.label, color); string.setCoordinates(node.location[0] + offsetX, node.location[1] - offsetY); - string.font = font; + string.font = getFont(target); string.horizontalAlignment = HorizontalAlignment.CENTER; string.verticallAlignment = VerticalAlignment.MIDDLE; boolean add = true; @@ -1347,7 +1343,7 @@ public class DataStoreResource extends } } - aTarget.drawStrings(strings); + target.drawStrings(strings); } /** @@ -1969,17 +1965,13 @@ public class DataStoreResource extends @Override public void resourceChanged(ChangeType type, Object object) { + super.resourceChanged(type, object); if (type.equals(ChangeType.CAPABILITY)) { if (object instanceof ColorableCapability) { if (this.timeRange != null) { // force rebuild of shaded shape to pick up color change lastExtent = null; } - } else if (object instanceof MagnificationCapability) { - if (font != null) { - font.dispose(); - font = null; - } } } issueRefresh(); diff --git a/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/rsc/HpeLabelResource.java b/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/rsc/HpeLabelResource.java index 501e7eed14..ce6812c6f6 100644 --- a/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/rsc/HpeLabelResource.java +++ b/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/rsc/HpeLabelResource.java @@ -71,6 +71,7 @@ import com.raytheon.viz.grid.rsc.general.D2DGridResource; * May 5, 2014 3026 mpduff Initial creation * Dec 16, 2014 3026 mpduff Change location of text * Feb 13, 2015 4121 mpduff Change label caching. + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling * * * @@ -164,7 +165,7 @@ public class HpeLabelResource extends @Override protected void initInternal(IGraphicsTarget target) throws VizException { if (font == null) { - font = target.initializeFont("Dialog", 11, null); + font = target.initializeFont("Dialog", 9, null); } font.setMagnification(getCapability(MagnificationCapability.class) .getMagnification().floatValue()); diff --git a/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/KmlExportDialog.java b/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/KmlExportDialog.java index 96d1ecc296..59b5973803 100644 --- a/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/KmlExportDialog.java +++ b/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/KmlExportDialog.java @@ -180,7 +180,7 @@ public class KmlExportDialog extends CaveSWTDialog { protected void initializeFramesGroup(Group group) { group.setLayout(new GridLayout(5, false)); - group.setText("Export Location"); + group.setText("Export Frames"); allFramesButton = new Button(group, SWT.RADIO); allFramesButton.setText("All Frames"); diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/editor/LocalizationEditorInput.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/editor/LocalizationEditorInput.java index 41f2e2bd1a..699ca7848d 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/editor/LocalizationEditorInput.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/editor/LocalizationEditorInput.java @@ -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 * 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. **/ @@ -31,9 +31,11 @@ import org.eclipse.ui.IMemento; import org.eclipse.ui.IPathEditorInput; import org.eclipse.ui.IPersistableElement; +import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.LocalizationUtil; +import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -49,7 +51,9 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * ------------ ---------- ----------- -------------------------- * Nov 3, 2010 mschenke Initial creation * Nov 27, 2013 mschenke Moved into localization.perspective project - * Feb 11, 2015 4108 randerso Implmented hashCode() and equals() + * Feb 11, 2015 4108 randerso Implmented hashCode() and equals() + * Jan 06, 2016 4834 nabowle add refreshLocalizationFile(). + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods * * * @@ -85,10 +89,21 @@ public class LocalizationEditorInput implements IFileEditorInput, public void setLocalizationFile(LocalizationFile localizationFile) { this.localizationFile = localizationFile; - name = LocalizationUtil.extractName(localizationFile.getName()); + name = LocalizationUtil.extractName(localizationFile.getPath()); file = null; } + /** + * Refreshes the localizationFile reference. + */ + public void refreshLocalizationFile() { + IPathManager pathManager = PathManagerFactory.getPathManager(); + LocalizationFile latestFile = pathManager.getLocalizationFile( + this.localizationFile.getContext(), + this.localizationFile.getPath()); + this.localizationFile = latestFile; + } + /** * @return the localizationFile */ @@ -96,55 +111,30 @@ public class LocalizationEditorInput implements IFileEditorInput, return localizationFile; } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IEditorInput#exists() - */ @Override public boolean exists() { return localizationFile.exists(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IEditorInput#getImageDescriptor() - */ @Override public ImageDescriptor getImageDescriptor() { return null; } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IEditorInput#getName() - */ @Override public String getName() { return name + " - " + localizationFile.getContext().getLocalizationLevel(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IEditorInput#getPersistable() - */ @Override public IPersistableElement getPersistable() { return this; } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IEditorInput#getToolTipText() - */ @Override public String getToolTipText() { - String tip = localizationFile.getName(); + String tip = localizationFile.getPath(); if (localizationFile.isProtected()) { tip += " (Protected @ " + localizationFile.getProtectedLevel() + ")"; @@ -152,32 +142,17 @@ public class LocalizationEditorInput implements IFileEditorInput, return tip; } - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ @SuppressWarnings("rawtypes") @Override public Object getAdapter(Class adapter) { return Platform.getAdapterManager().getAdapter(this, adapter); } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IStorageEditorInput#getStorage() - */ @Override public IStorage getStorage() throws CoreException { return getFile(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IFileEditorInput#getFile() - */ @Override public IFile getFile() { if (file.exists() == false) { @@ -192,25 +167,15 @@ public class LocalizationEditorInput implements IFileEditorInput, return file; } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPathEditorInput#getPath() - */ @Override public IPath getPath() { return getFile().getRawLocation(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento) - */ @Override public void saveState(IMemento memento) { LocalizationContext ctx = localizationFile.getContext(); - memento.putString(FILE_NAME_ID, localizationFile.getName()); + memento.putString(FILE_NAME_ID, localizationFile.getPath()); memento.putString(CONTEXT_NAME_ID, ctx.getContextName()); memento.putString(CONTEXT_TYPE_ID, ctx.getLocalizationType().name()); memento.putString(CONTEXT_LEVEL_ID, ctx.getLocalizationLevel().name()); @@ -218,21 +183,11 @@ public class LocalizationEditorInput implements IFileEditorInput, .toPortableString()); } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPersistableElement#getFactoryId() - */ @Override public String getFactoryId() { return FACTORY_ID; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ @Override public int hashCode() { final int prime = 31; @@ -242,11 +197,6 @@ public class LocalizationEditorInput implements IFileEditorInput, return result; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ @Override public boolean equals(Object obj) { if (this == obj) { diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/editor/LocalizationEditorUtils.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/editor/LocalizationEditorUtils.java index 8c4cb0911d..7feeb3f7f4 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/editor/LocalizationEditorUtils.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/editor/LocalizationEditorUtils.java @@ -30,7 +30,7 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; -import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -46,6 +46,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Nov 27, 2013 mschenke Methods extracted from LocalizationPerspectiveUtils + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods * * * @@ -72,7 +73,7 @@ public class LocalizationEditorUtils { if (reg == null) { return new IEditorDescriptor[0]; } - return reg.getEditors(input.getLocalizationFile().getName()); + return reg.getEditors(input.getLocalizationFile().getPath()); } /** @@ -87,7 +88,7 @@ public class LocalizationEditorUtils { if (reg == null) { return null; } - return reg.getDefaultEditor(input.getLocalizationFile().getName()); + return reg.getDefaultEditor(input.getLocalizationFile().getPath()); } /** @@ -118,7 +119,7 @@ public class LocalizationEditorUtils { IEditorRegistry reg = getEditorRegistry(); if (reg != null) { IEditorDescriptor desc = reg.getDefaultEditor(input - .getLocalizationFile().getName()); + .getLocalizationFile().getPath()); String id = DEFAULT_TEXT_EDITOR; if (desc != null) { id = desc.getId(); @@ -177,16 +178,16 @@ public class LocalizationEditorUtils { * @return the open editor part or null if not being edited */ public static IEditorPart getEditorForFile(IWorkbenchPage page, - LocalizationFile file) { + ILocalizationFile file) { for (IEditorReference ref : page.getEditorReferences()) { IEditorPart part = ref.getEditor(false); if (part != null) { IEditorInput input = part.getEditorInput(); if (input instanceof LocalizationEditorInput) { - LocalizationFile editedFile = ((LocalizationEditorInput) input) + ILocalizationFile editedFile = ((LocalizationEditorInput) input) .getLocalizationFile(); if (editedFile.getContext().equals(file.getContext()) - && editedFile.getName().equals(file.getName())) { + && editedFile.getPath().equals(file.getPath())) { return part; } } diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/ui/LocalizationSaveAsPopulator.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/ui/LocalizationSaveAsPopulator.java index 99e20b1819..f2edf90286 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/ui/LocalizationSaveAsPopulator.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/ui/LocalizationSaveAsPopulator.java @@ -43,6 +43,7 @@ import org.eclipse.ui.texteditor.IDocumentProvider; import com.raytheon.uf.common.localization.FileUpdatedMessage; import com.raytheon.uf.common.localization.FileUpdatedMessage.FileChangeType; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.ILocalizationFileObserver; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; @@ -69,9 +70,10 @@ import com.raytheon.viz.ui.EditorUtil; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 24, 2011 mschenke Initial creation - * Aug 29, 2014 #3527 mapeters Check for active editor to not - * be null before calling isDirty(). + * Mar 24, 2011 mschenke Initial creation + * Aug 29, 2014 #3527 mapeters Check for active editor to not + * be null before calling isDirty(). + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods * * * @@ -166,7 +168,7 @@ public class LocalizationSaveAsPopulator extends CompoundContributionItem { LocalizationLevel newLevel) { LocalizationEditorInput input = (LocalizationEditorInput) editor .getEditorInput(); - LocalizationFile fileToSave = input.getLocalizationFile(); + ILocalizationFile fileToSave = input.getLocalizationFile(); if (newLevel == fileToSave.getContext().getLocalizationLevel()) { String myContext = LocalizationManager.getContextName(newLevel); @@ -183,7 +185,7 @@ public class LocalizationSaveAsPopulator extends CompoundContributionItem { // get new level file IPathManager pm = PathManagerFactory.getPathManager(); - String name = fileToSave.getName(); + String name = fileToSave.getPath(); LocalizationContext newCtx = pm.getContext(fileToSave.getContext() .getLocalizationType(), newLevel); final LocalizationFile newFile = pm.getLocalizationFile(newCtx, name); @@ -249,9 +251,9 @@ public class LocalizationSaveAsPopulator extends CompoundContributionItem { private static void saveEditorAs(IEditorPart editor) { LocalizationEditorInput input = (LocalizationEditorInput) editor .getEditorInput(); - LocalizationFile fileToSave = input.getLocalizationFile(); + ILocalizationFile fileToSave = input.getLocalizationFile(); FileDialog fd = new FileDialog(editor.getSite().getShell(), SWT.SAVE); - fd.setFileName(LocalizationUtil.extractName(fileToSave.getName())); + fd.setFileName(LocalizationUtil.extractName(fileToSave.getPath())); fd.setOverwrite(true); fd.setFilterPath(System.getProperty("user.home")); diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/FileTreeView.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/FileTreeView.java index aa4c178961..8fa092ac17 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/FileTreeView.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/FileTreeView.java @@ -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 * 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. **/ @@ -87,14 +87,15 @@ import org.eclipse.ui.part.ViewPart; import com.raytheon.uf.common.localization.FileUpdatedMessage; import com.raytheon.uf.common.localization.FileUpdatedMessage.FileChangeType; +import com.raytheon.uf.common.localization.ILocalizationFile; +import com.raytheon.uf.common.localization.ILocalizationPathObserver; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.localization.LocalizationNotificationObserver; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; +import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -130,7 +131,7 @@ import com.raytheon.uf.viz.localization.service.ILocalizationService; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 26, 2010 mnash Initial creation - * Feb 13, 2013 1610 mschenke Fixed null pointer by repopulating LocalizationFileGroupData + * Feb 13, 2013 1610 mschenke Fixed null pointer by repopulating LocalizationFileGroupData * objects even if they weren't expanded * May 1, 2013 1967 njensen Fix for pydev 2.7 * Sep 17, 2013 2285 mschenke Made openFile refresh items if file not found @@ -142,7 +143,13 @@ import com.raytheon.uf.viz.localization.service.ILocalizationService; * Aug 24, 2015 4393 njensen Updates for observer changes * Oct 13, 2015 4410 bsteffen Allow localization perspective to mix * files for multiple Localization Types. - * + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * Nov 18, 2015 4834 njensen Updated to register file observing on PathManager + * Dec 03, 2015 4834 njensen Updated for ILocalizationFile changes + * Jan 06, 2016 4834 nabowle Fix single-user edit-save-edit-save. + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods + * Jan 15, 2016 5242 kbisanz Replaced LocalizationFile with + * ILocalizationFile where possible * * * @@ -151,21 +158,22 @@ import com.raytheon.uf.viz.localization.service.ILocalizationService; */ public class FileTreeView extends ViewPart implements IPartListener2, - ILocalizationService, IResourceChangeListener { + ILocalizationService, IResourceChangeListener, + ILocalizationPathObserver { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(FileTreeView.class); private static class FileTreeFileComparator implements - Comparator { + Comparator { @Override - public int compare(LocalizationFile o1, LocalizationFile o2) { + public int compare(ILocalizationFile o1, ILocalizationFile o2) { if (o1.isDirectory() && (o2.isDirectory() == false)) { return 1; } else if ((o1.isDirectory() == false) && o2.isDirectory()) { return -1; } else { - int nameVal = o1.getName().compareTo(o2.getName()); + int nameVal = o1.getPath().compareTo(o2.getPath()); if (nameVal == 0) { // exact same name, check levels LocalizationLevel l1 = o1.getContext() @@ -206,11 +214,11 @@ public class FileTreeView extends ViewPart implements IPartListener2, private class FileUpdateRefresher implements Runnable { - private final LocalizationFile file; + private final ILocalizationFile file; private final FileChangeType type; - public FileUpdateRefresher(LocalizationFile file, FileChangeType type) { + public FileUpdateRefresher(ILocalizationFile file, FileChangeType type) { this.file = file; this.type = type; } @@ -223,7 +231,7 @@ public class FileTreeView extends ViewPart implements IPartListener2, for (TreeItem appItem : tree.getItems()) { for (TreeItem rootItem : appItem.getItems()) { TreeItem found = find(rootItem, file.getContext(), - file.getName(), false); + file.getPath(), false); if (found != null) { /* * File found. If updated, set the time stamp to @@ -313,8 +321,9 @@ public class FileTreeView extends ViewPart implements IPartListener2, waitCursor = display.getSystemCursor(SWT.CURSOR_WAIT); site.getPage().addPartListener(this); - ((LocalizationNotificationObserver) PathManagerFactory.getPathManager() - .getObserver()).addGlobalFileChangeObserver(this); + + PathManagerFactory.getPathManager().addLocalizationPathObserver( + IPathManager.SEPARATOR, this); ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); @@ -341,9 +350,8 @@ public class FileTreeView extends ViewPart implements IPartListener2, } getSite().getPage().removePartListener(this); - ((LocalizationNotificationObserver) PathManagerFactory.getPathManager() - .getObserver()).removeGlobalFileChangeObserver(this); - + PathManagerFactory.getPathManager() + .removeLocalizationPathObserver(this); ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); } @@ -830,8 +838,8 @@ public class FileTreeView extends ViewPart implements IPartListener2, } } - final List fileList = new ArrayList(); - final List fileDataList = new ArrayList(); + final List fileList = new ArrayList<>(); + final List fileDataList = new ArrayList<>(); // get list of files selected if (selected.length > 0) { // Open File(s) list @@ -871,7 +879,7 @@ public class FileTreeView extends ViewPart implements IPartListener2, mgr.add(new CopyToAction(fileDataList.get(0), this)); mgr.add(new DeleteAction(getSite().getPage(), fileList - .toArray(new LocalizationFile[fileList.size()]))); + .toArray(new LocalizationFile[0]))); mgr.add(new Separator()); } else if ((selected.length == 1) @@ -885,7 +893,7 @@ public class FileTreeView extends ViewPart implements IPartListener2, .toArray(new LocalizationFile[fileList.size()]))); mgr.add(new Separator()); } else { - List toDelete = new ArrayList(); + List toDelete = new ArrayList<>(); for (TreeItem item : selected) { int prevSize = toDelete.size(); if (item.getData() instanceof FileTreeEntryData) { @@ -977,17 +985,18 @@ public class FileTreeView extends ViewPart implements IPartListener2, } /** - * Builds a list of {@link LocalizationFile}s starting at the item passed in + * Builds a list of {@link ILocalizationFile}s starting at the item passed + * in * * @param item * @param files * (option) list to add entries to * @return list of files */ - private List buildFileList(TreeItem item, - List files) { + private List buildFileList(TreeItem item, + List files) { if (files == null) { - files = new ArrayList(); + files = new ArrayList<>(); } FileTreeEntryData data = (FileTreeEntryData) item.getData(); @@ -1088,7 +1097,7 @@ public class FileTreeView extends ViewPart implements IPartListener2, IPathManager pathManager = PathManagerFactory.getPathManager(); boolean success = false; - List currentList = new ArrayList(); + List currentList = new ArrayList<>(); LocalizationFile[] files = pathManager.listFiles( getTreeSearchContexts(types), path, filter, false, !recursive); if (files == null) { @@ -1099,8 +1108,8 @@ public class FileTreeView extends ViewPart implements IPartListener2, for (LocalizationFile file : files) { if (checkName - && (file.getName().isEmpty() || data.getPath().equals( - file.getName()))) { + && (file.getPath().isEmpty() || data.getPath().equals( + file.getPath()))) { continue; } if (file.exists()) { @@ -1176,11 +1185,11 @@ public class FileTreeView extends ViewPart implements IPartListener2, FileTreeEntryData data = (FileTreeEntryData) parentItem.getData(); data.setRequestedChildren(true); PathData pd = data.getPathData(); - Map> processedFiles = new HashMap>(); - Set processedPaths = new HashSet(); + Map> processedFiles = new HashMap<>(); + Set processedPaths = new HashSet<>(); // we are expanding a folder for (LocalizationFile file : files) { - String name = file.getName(); + String name = file.getPath(); if (processedPaths.contains(name) == false) { FileTreeEntryData treeData = null; if (file.isDirectory()) { @@ -1195,7 +1204,7 @@ public class FileTreeView extends ViewPart implements IPartListener2, if (file.isDirectory() == false) { List entryFiles = processedFiles.get(name); if (entryFiles == null) { - entryFiles = new ArrayList(); + entryFiles = new ArrayList<>(); processedFiles.put(name, entryFiles); } entryFiles.add(file); @@ -1226,7 +1235,7 @@ public class FileTreeView extends ViewPart implements IPartListener2, PathData pd = fData.getPathData(); Set levels = new HashSet<>(); Set redundantLevels = new HashSet<>(); - for (LocalizationFile file : files) { + for (ILocalizationFile file : files) { LocalizationLevel level = file.getContext().getLocalizationLevel(); if (!levels.add(level)) { redundantLevels.add(level); @@ -1283,7 +1292,7 @@ public class FileTreeView extends ViewPart implements IPartListener2, */ private TreeItem addTreeItem(TreeItem parentItem, FileTreeEntryData treeData) { String name = treeData.getName(); - LocalizationFile file = null; + ILocalizationFile file = null; int idx = parentItem.getItemCount(); if (treeData instanceof LocalizationFileEntryData) { LocalizationFileEntryData entryData = (LocalizationFileEntryData) treeData; @@ -1381,16 +1390,16 @@ public class FileTreeView extends ViewPart implements IPartListener2, } /** - * Get the image for the provided LocalizationFile. + * Get the image for the provided ILocalizationFile. * * @param file - * The LocalizationFile + * The ILocalizationFile * @return The image */ - private Image getImage(LocalizationFile file) { + private Image getImage(ILocalizationFile file) { String name = null; if (file != null) { - name = file.getName(); + name = file.getPath(); } return getImage(name); } @@ -1422,9 +1431,9 @@ public class FileTreeView extends ViewPart implements IPartListener2, } } - private TreeItem find(LocalizationFile file, boolean populateToFind, + private TreeItem find(ILocalizationFile file, boolean populateToFind, boolean nearestParent) { - return find(file.getName(), file.getContext(), populateToFind, + return find(file.getPath(), file.getContext(), populateToFind, nearestParent); } @@ -1569,12 +1578,19 @@ public class FileTreeView extends ViewPart implements IPartListener2, && (docDelta.getKind() == IResourceDelta.CHANGED) && ((docDelta.getFlags() & IResourceDelta.CONTENT) == IResourceDelta.CONTENT)) { try { - LocalizationFile file = input.getLocalizationFile(); - if (file.getContext().getLocalizationLevel() - .isSystemLevel() == false) { - input.getLocalizationFile().save(); + ILocalizationFile file = input + .getLocalizationFile(); + /* + * TODO can't easily replace the deprecated save() + * call because if we use openOutputStream() it will + * overwrite the file contents + */ + if (!file.getContext().getLocalizationLevel() + .isSystemLevel() + && input.getLocalizationFile().save()) { + input.refreshLocalizationFile(); } - } catch (LocalizationOpFailedException e) { + } catch (LocalizationException e) { statusHandler.handle( Priority.PROBLEM, "Error saving file: " @@ -1604,13 +1620,13 @@ public class FileTreeView extends ViewPart implements IPartListener2, IPathManager pathManager = PathManagerFactory.getPathManager(); FileChangeType type = message.getChangeType(); - LocalizationFile file = pathManager.getLocalizationFile(context, + ILocalizationFile file = pathManager.getLocalizationFile(context, filePath); if (file != null) { if (((file.exists() == false) && ((type == FileChangeType.ADDED) || (type == FileChangeType.UPDATED))) || (file.exists() && (type == FileChangeType.DELETED))) { - System.out.println("Got weird state in update for " + file + System.err.println("Got weird state in update for " + file + ": exists=" + file.exists() + ", changeType=" + message.getChangeType()); } @@ -1784,4 +1800,30 @@ public class FileTreeView extends ViewPart implements IPartListener2, public boolean isShown(LocalizationLevel level) { return showSet.contains(level); } + + @Override + public void fileChanged(ILocalizationFile file) { + /* + * TODO rewrite this whole method to not use fileUpdated() and correctly + * refresh/update nodes as necessary + */ + FileChangeType t = null; + if (ILocalizationFile.NON_EXISTENT_CHECKSUM.equals(file.getCheckSum())) { + t = FileChangeType.DELETED; + } else { + /* + * TODO We don't have the previous checksum available here so we + * can't easily identify this change as an add vs update. We need to + * handle this cleanly somehow. + * + * Temporary fix: Go with ADDED + */ + t = FileChangeType.ADDED; + } + + FileUpdatedMessage fum = new FileUpdatedMessage(file.getContext(), + file.getPath(), t, file.getTimeStamp().getTime(), + file.getCheckSum()); + fileUpdated(fum); + } } diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/LocalizationFileDragNDropSource.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/LocalizationFileDragNDropSource.java index 2f727920c2..31ad830a9c 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/LocalizationFileDragNDropSource.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/LocalizationFileDragNDropSource.java @@ -20,12 +20,9 @@ package com.raytheon.uf.viz.localization.perspective.view; import java.io.File; -import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; import java.util.List; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.ViewerDropAdapter; import org.eclipse.swt.dnd.DND; @@ -35,23 +32,14 @@ import org.eclipse.swt.dnd.TransferData; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; -import com.raytheon.uf.common.localization.FileUpdatedMessage; -import com.raytheon.uf.common.localization.FileUpdatedMessage.FileChangeType; -import com.raytheon.uf.common.localization.ILocalizationFileObserver; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.localization.LocalizationUtil; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.localization.SaveableOutputStream; import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; -import com.raytheon.uf.common.localization.msgs.ListResponseEntry; 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.VizApp; import com.raytheon.uf.viz.localization.filetreeview.FileTreeEntryData; import com.raytheon.uf.viz.localization.filetreeview.LocalizationFileEntryData; import com.raytheon.uf.viz.localization.filetreeview.LocalizationFileGroupData; @@ -69,7 +57,8 @@ import com.raytheon.uf.viz.localization.perspective.view.actions.ImportFileActio * Jul 1, 2011 mschenke Initial creation * Oct 13, 2015 4410 bsteffen Allow localization perspective to mix * files for multiple Localization Types. - * + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * Jan 11, 2016 5242 kbisanz Deleted unused dropLocalizationFile(...) * * * @@ -120,7 +109,7 @@ public class LocalizationFileDragNDropSource extends ViewerDropAdapter if (toDelete != null) { try { toDelete.delete(); - } catch (LocalizationOpFailedException e) { + } catch (LocalizationException e) { UFStatus.getHandler().handle(Priority.PROBLEM, "Error deleting old file", e); } @@ -191,64 +180,6 @@ public class LocalizationFileDragNDropSource extends ViewerDropAdapter return false; } - private boolean dropLocalizationFile(FileTreeEntryData data, - ListResponseEntry toMoveData) { - IPathManager pm = PathManagerFactory.getPathManager(); - LocalizationFile toMove = pm.getLocalizationFile( - toMoveData.getContext(), toMoveData.getFileName()); - String fileName = LocalizationUtil.extractName(toMove.getName()); - String newName = data.getPath() + File.separator + fileName; - LocalizationType type = toMove.getContext().getLocalizationType(); - if (!data.getPathData().getTypes().contains(type)) { - type = data.getPathData().getTypes().get(0); - } - final LocalizationFile moveTo = pm.getLocalizationFile(pm.getContext( - type, toMoveData.getContext().getLocalizationLevel()), newName); - boolean move = true; - if (moveTo.exists()) { - move = MessageDialog.openQuestion(view.getSite().getShell(), - "Override File", "A file with the name '" + fileName - + "' already exists in the '" + data.getName() - + "' folder. Do you want to override it?"); - } - if (move) { - final Runnable select = new Runnable() { - @Override - public void run() { - view.selectFile(moveTo); - } - }; - // Make sure we select the file after the drop - if (moveTo.exists() == false) { - final ILocalizationFileObserver[] observers = new ILocalizationFileObserver[1]; - ILocalizationFileObserver observer = new ILocalizationFileObserver() { - @Override - public void fileUpdated(FileUpdatedMessage message) { - if (message.getChangeType() != FileChangeType.DELETED) { - view.fileUpdated(message); - VizApp.runAsync(select); - } - moveTo.removeFileUpdatedObserver(observers[0]); - } - }; - observers[0] = observer; - moveTo.addFileUpdatedObserver(observer); - } else { - VizApp.runAsync(select); - } - try (InputStream is = toMove.openInputStream(); - SaveableOutputStream os = moveTo.openOutputStream()) { - FileUtil.copy(is, os); - os.save(); - return true; - } catch (IOException | LocalizationException e) { - UFStatus.getHandler().handle(Priority.PROBLEM, - "Error copying file contents", e); - } - } - return false; - } - private boolean dropFile(List types, String dirPath, File[] toCopyFiles) { boolean oneGood = false; diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/AbstractToAction.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/AbstractToAction.java index 0835ce8ca8..5d5059778b 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/AbstractToAction.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/AbstractToAction.java @@ -41,7 +41,7 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 25, 2011 mschenke Initial creation + * Mar 25, 2011 mschenke Initial creation * * * @@ -65,21 +65,11 @@ public abstract class AbstractToAction extends Action implements IMenuCreator { return this; } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.action.Action#run() - */ @Override public void run() { } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.action.IMenuCreator#dispose() - */ @Override public void dispose() { if (menu != null) { @@ -87,13 +77,6 @@ public abstract class AbstractToAction extends Action implements IMenuCreator { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets - * .Menu) - */ @Override public Menu getMenu(Menu parent) { if (menu != null) { diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/CopyToAction.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/CopyToAction.java index 05a173c3e5..9de1fc2ea1 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/CopyToAction.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/CopyToAction.java @@ -35,7 +35,6 @@ import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.localization.SaveableOutputStream; import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -57,6 +56,8 @@ import com.raytheon.uf.viz.localization.service.ILocalizationService; * Nov 3, 2010 mschenke Initial creation * Oct 13, 2015 4410 bsteffen Allow localization perspective to mix * files for multiple Localization Types. + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods * * * @@ -84,14 +85,6 @@ public class CopyToAction extends AbstractToAction { this(data.getFile(), data.getPathData(), service); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.localization.perspective.view.actions.AbstractToAction - * #isLevelEnabled(com.raytheon.uf.common.localization.LocalizationContext. - * LocalizationLevel) - */ @Override protected boolean isLevelEnabled(LocalizationLevel level) { boolean enabled = super.isLevelEnabled(level); @@ -102,21 +95,12 @@ public class CopyToAction extends AbstractToAction { return enabled; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.localization.filetreeview.actions.AbstractToAction - * #run - * (com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel - * ) - */ @Override protected void run(LocalizationLevel level) { IPathManager pm = PathManagerFactory.getPathManager(); ILocalizationFile newFile = pm.getLocalizationFile( pm.getContext(file.getContext().getLocalizationType(), level), - file.getName()); + file.getPath()); removeAlternateTypeFiles(level); copyFile(newFile); } @@ -133,12 +117,12 @@ public class CopyToAction extends AbstractToAction { for (LocalizationType type : pathData.getTypes()) { if (type != file.getContext().getLocalizationType()) { - LocalizationFile altFile = pm.getLocalizationFile( - pm.getContext(type, level), file.getName()); + ILocalizationFile altFile = pm.getLocalizationFile( + pm.getContext(type, level), file.getPath()); if (altFile.exists()) { try { altFile.delete(); - } catch (LocalizationOpFailedException e) { + } catch (LocalizationException e) { statusHandler.handle(Priority.PROBLEM, "Unable to delete existing " + type.name() + " " + level + " file.", e); diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/DeleteAction.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/DeleteAction.java index 70f69dc755..40d1c000c3 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/DeleteAction.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/DeleteAction.java @@ -25,13 +25,14 @@ import java.util.List; import java.util.Map; import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorReference; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; @@ -42,6 +43,8 @@ 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.localization.perspective.editor.LocalizationEditorInput; +import com.raytheon.viz.ui.dialogs.ICloseCallback; +import com.raytheon.viz.ui.dialogs.SWTMessageBox; /** * Deletes the selected localization file @@ -55,6 +58,10 @@ import com.raytheon.uf.viz.localization.perspective.editor.LocalizationEditorInp * Nov 3, 2010 mschenke Initial creation * Feb 18, 2015 4132 mapeters Fixed issue with deleting overrides. * Jun 29, 2015 946 rferrel Do not allow delete of a protected level file. + * Nov 13, 2015 4946 mapeters Use SWTMessageBox instead of MessageDialog. + * Jan 15, 2016 5242 kbisanz Replaced LocalizationFile with + * ILocalizationFile where possible + * Jan 27, 2016 5054 randerso Cleaned up SWTMessageBox * * * @@ -92,28 +99,50 @@ public class DeleteAction extends Action { @Override public void run() { - String listOfFiles = ""; + StringBuilder listOfFiles = new StringBuilder(); for (int i = 0; i < toDelete.length; ++i) { - listOfFiles += LocalizationUtil.extractName(toDelete[i].getName()) - + "\n"; + listOfFiles.append(LocalizationUtil.extractName(toDelete[i] + .getPath())); + listOfFiles.append("\n"); } Shell shell = page.getWorkbenchWindow().getShell(); if (prompt) { - boolean choice = MessageDialog.openConfirm( - shell, - "Delete Confirmation", - listOfFiles - + String.format( - "\n\nAre you sure you want to delete %s?", - toDelete.length > 1 ? "these items" - : "this file")); - if (!choice) { - return; + StringBuilder msg = new StringBuilder(); + msg.append("Are you sure you want to delete "); + if (toDelete.length > 1) { + msg.append("these " + toDelete.length + " items"); + } else { + msg.append("this file"); } + msg.append("?\n\n").append(listOfFiles); + + SWTMessageBox messageDialog = new SWTMessageBox(shell, + "Delete Confirmation", msg.toString(), SWT.OK | SWT.CANCEL + | SWT.ICON_QUESTION); + + messageDialog.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + if (returnValue instanceof Integer) { + if ((int) returnValue == SWT.OK) { + deleteFiles(); + } + } + } + }); + + messageDialog.open(); } - List toClose = new ArrayList(); + } + + /** + * Delete the selected files and all associated file extension variations. + */ + private void deleteFiles() { + List toClose = new ArrayList<>(); // check for open editors and close them for (IEditorReference ref : page.getEditorReferences()) { IEditorInput input = null; @@ -125,10 +154,11 @@ public class DeleteAction extends Action { + "file was open (in order to close it)", e); } if (input instanceof LocalizationEditorInput) { - LocalizationFile editorFile = ((LocalizationEditorInput) input) + ILocalizationFile editorFile = ((LocalizationEditorInput) input) .getLocalizationFile(); - for (LocalizationFile file : toDelete) { - if ((editorFile.compareTo(file) == 0) + String editorFilePath = editorFile.getPath(); + for (ILocalizationFile file : toDelete) { + if ((editorFilePath.equals(file.getPath())) && editorFile.getContext() .equals(file.getContext())) { toClose.add(ref); @@ -144,7 +174,7 @@ public class DeleteAction extends Action { false); } - for (LocalizationFile file : toDelete) { + for (ILocalizationFile file : toDelete) { try { deleteFile(file); } catch (Exception e) { @@ -161,10 +191,10 @@ public class DeleteAction extends Action { * The file to delete * @throws Exception */ - private void deleteFile(LocalizationFile file) throws Exception { + private void deleteFile(ILocalizationFile file) throws Exception { if (file.isDirectory() == false) { // Check for file extension - String name = LocalizationUtil.extractName(file.getName()); + String name = LocalizationUtil.extractName(file.getPath()); String[] parts = name.split("[.]"); if (parts.length > 1) { @@ -174,11 +204,11 @@ public class DeleteAction extends Action { if (associated != null) { String[] extensions = associated.split(","); - String path = file.getName().substring(0, - file.getName().lastIndexOf(name)); + String path = file.getPath().substring(0, + file.getPath().lastIndexOf(name)); String prefix = ""; - for (int i = 0; i < parts.length - 1; ++i) { + for (int i = 0; i < (parts.length - 1); ++i) { if (i > 0) { prefix += "."; } @@ -193,7 +223,7 @@ public class DeleteAction extends Action { for (String extension : extensions) { String deletePath = path + "." + extension; - LocalizationFile result = pathManager + ILocalizationFile result = pathManager .getLocalizationFile(ctx, deletePath); if (result != null) { result.delete(); diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/ImportFileAction.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/ImportFileAction.java index 8fe13d2983..d98c33bbaf 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/ImportFileAction.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/ImportFileAction.java @@ -57,6 +57,7 @@ import com.raytheon.viz.ui.VizWorkbenchManager; * Jun 11, 2015 4541 skorolev Added NULL test for lf. * Oct 13, 2015 4410 bsteffen Allow localization perspective to mix * files for multiple Localization Types. + * Dec 03, 2015 4834 njensen Updated for ILocalizationFile changes * * * @@ -88,8 +89,7 @@ public class ImportFileAction extends Action { } public ImportFileAction(List contextTypes, - String directoryPath, - String[] filter) { + String directoryPath, String[] filter) { this(contextTypes, directoryPath); if (filter != null) { this.fileExtensionFilterArr = new String[filter.length]; @@ -182,7 +182,7 @@ public class ImportFileAction extends Action { ILocalizationFile file = existing.get(0); if (MessageDialog.openConfirm(VizWorkbenchManager.getInstance() .getCurrentWindow().getShell(), "Confirm Overwrite", - String.format(FORMAT_STRING, file.getName(), file + String.format(FORMAT_STRING, file.getPath(), file .getContext().getLocalizationLevel()))) { existing.clear(); } @@ -288,7 +288,7 @@ public class ImportFileAction extends Action { private void updateText() { ILocalizationFile file = existingFiles.get(curIdx); - messageLabel.setText(String.format(FORMAT_STRING, file.getName(), + messageLabel.setText(String.format(FORMAT_STRING, file.getPath(), file.getContext().getLocalizationLevel())); } diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/MoveFileAction.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/MoveFileAction.java index ea2db1338e..55106c7640 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/MoveFileAction.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/MoveFileAction.java @@ -50,6 +50,7 @@ import com.raytheon.uf.viz.localization.service.ILocalizationService; * Mar 25, 2011 mschenke Initial creation * Oct 13, 2015 4410 bsteffen Allow localization perspective to mix * files for multiple Localization Types. + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods * * * @@ -80,14 +81,6 @@ public class MoveFileAction extends CopyToAction { setEnabled(delete.isEnabled()); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.localization.perspective.view.actions.AbstractToAction - * #isLevelEnabled(com.raytheon.uf.common.localization.LocalizationContext. - * LocalizationLevel) - */ @Override protected boolean isLevelEnabled(LocalizationLevel level) { boolean enabled = super.isLevelEnabled(level); @@ -105,7 +98,7 @@ public class MoveFileAction extends CopyToAction { page.getWorkbenchWindow().getShell(), "Move Confirmation", "Are you sure you want to move " - + LocalizationUtil.extractName(file.getName()) + + LocalizationUtil.extractName(file.getPath()) + " to " + level + " replacing any existing file and deleting this file?"); @@ -113,7 +106,7 @@ public class MoveFileAction extends CopyToAction { IPathManager pm = PathManagerFactory.getPathManager(); final LocalizationFile newFile = pm.getLocalizationFile( pm.getContext(file.getContext().getLocalizationType(), - level), file.getName()); + level), file.getPath()); removeAlternateTypeFiles(level); // Make sure we select the file after the drop final ILocalizationFileObserver[] observers = new ILocalizationFileObserver[1]; @@ -121,7 +114,7 @@ public class MoveFileAction extends CopyToAction { @Override public void fileUpdated(FileUpdatedMessage message) { if (message.getContext().equals(newFile.getContext()) - && message.getFileName().equals(newFile.getName()) + && message.getFileName().equals(newFile.getPath()) && message.getChangeType() != FileChangeType.DELETED) { service.fileUpdated(message); VizApp.runAsync(new Runnable() { diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/PasteFileAction.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/PasteFileAction.java index b3bbdd5408..4d07d7a617 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/PasteFileAction.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/PasteFileAction.java @@ -21,6 +21,7 @@ package com.raytheon.uf.viz.localization.perspective.view.actions; import java.util.List; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; @@ -43,6 +44,8 @@ import com.raytheon.uf.viz.localization.service.ILocalizationService; * Dec 3, 2010 6305 mpduff Initial creation * Oct 13, 2015 4410 bsteffen Allow localization perspective to mix * files for multiple Localization Types. + * Jan 15, 2016 5242 kbisanz Replaced LocalizationFile with + * ILocalizationFile where possible * * * @@ -81,12 +84,12 @@ public class PasteFileAction extends CopyToAction { List types = dataToCopyTo.getPathData().getTypes(); LocalizationType type = file.getContext().getLocalizationType(); - if(!types.contains(type)){ + if (!types.contains(type)) { type = types.get(0); } LocalizationContext ctx = pm.getContext(type, level); - LocalizationFile newFile = pm.getLocalizationFile(ctx, + ILocalizationFile newFile = pm.getLocalizationFile(ctx, dataToCopyTo.getPath()); removeAlternateTypeFiles(level); copyFile(newFile); diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/RenameAction.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/RenameAction.java index 92afe7fc3c..8566ff1e7e 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/RenameAction.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/RenameAction.java @@ -31,6 +31,7 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.localization.FileUpdatedMessage; import com.raytheon.uf.common.localization.FileUpdatedMessage.FileChangeType; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.ILocalizationFileObserver; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; @@ -57,6 +58,7 @@ import com.raytheon.viz.ui.VizWorkbenchManager; * Apr 27, 2011 mschenke Initial creation * Oct 13, 2015 4410 bsteffen Allow localization perspective to mix * files for multiple Localization Types. + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods * * * @@ -107,13 +109,13 @@ public class RenameAction extends Action { } } - private LocalizationFile file; + private ILocalizationFile file; private ILocalizationService service; private boolean deleteOld; - public RenameAction(LocalizationFile file, ILocalizationService service, + public RenameAction(ILocalizationFile file, ILocalizationService service, boolean deleteOld) { super("Rename...", IAction.AS_PUSH_BUTTON); // Only set not enabled if we are deleting the old file and level is a @@ -125,13 +127,13 @@ public class RenameAction extends Action { this.deleteOld = deleteOld; } - public RenameAction(LocalizationFile file, ILocalizationService service) { + public RenameAction(ILocalizationFile file, ILocalizationService service) { this(file, service, true); } @Override public void run() { - String path = file.getName(); + String path = file.getPath(); String[] pathParts = LocalizationUtil.splitUnique(path); final String name = pathParts[pathParts.length - 1]; Shell parent = VizWorkbenchManager.getInstance().getCurrentWindow() diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.monitor.ffmp/META-INF/MANIFEST.MF index 835206dfaf..a3a5f338f2 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Ffmp Plug-in Bundle-SymbolicName: com.raytheon.uf.viz.monitor.ffmp;singleton:=true -Bundle-Version: 1.14.0.qualifier +Bundle-Version: 1.15.0.qualifier Bundle-Activator: com.raytheon.uf.viz.monitor.ffmp.Activator Bundle-Vendor: RAYTHEON Require-Bundle: org.eclipse.ui, @@ -14,7 +14,6 @@ Require-Bundle: org.eclipse.ui, com.raytheon.viz.ui;bundle-version="1.10.13", com.raytheon.uf.viz.monitor;bundle-version="1.11.1", com.raytheon.uf.common.dataplugin.ffmp;bundle-version="1.11.9", - org.apache.commons.lang;bundle-version="2.3.0", com.raytheon.uf.viz.d2d.core;bundle-version="1.11.15", com.raytheon.uf.viz.localization, com.raytheon.uf.common.serialization, diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitorConfiguration.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitorConfiguration.java old mode 100644 new mode 100755 index f9b8dba547..70cf84a43f --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitorConfiguration.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitorConfiguration.java @@ -19,15 +19,13 @@ **/ package com.raytheon.uf.viz.monitor.ffmp; -import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.Set; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.ffmpTable; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.tableFields; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.ffmpTable; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.tableFields; /** * FFMPMonitorConfiguration object stores configuration data specific to FFMP. @@ -38,6 +36,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.tableFields; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 29 June, 2009 2521 dhladky Initial creation + * Jan 04, 2016 5115 skorolev Corrected imports. * * * @@ -56,64 +55,17 @@ public class FFMPMonitorConfiguration { * Constructor */ public FFMPMonitorConfiguration() { -// reload(getStore()); - } - /** - * Save the configuration object to a file. - * - * @throws IOException - */ -// public void save() throws IOException { -// HierarchicalPreferenceStore store = getStore(); -// -// // Save SCAN Stuff here -// store.setValue(MonitorConfigConstants.SCAN_PLUGIN_NAME, pluginName); -// -// // cell table -// String[] tempTableAttributes = new String[ffmpTableAttributes.length]; -// -// for (int i = 0; i < tempTableAttributes.length; i++) { -// tempTableAttributes[i] = Boolean.toString(ffmpTableAttributes[i]); -// } -// -// store.setValue(MonitorConfigConstants.SCAN_TVS_TABLE_ATTRIB, -// tempTableAttributes); -// -// store.save(); -// } + } /** * @return HierarchicalPreferenceStore */ private HierarchicalPreferenceStore getStore() { - return (HierarchicalPreferenceStore) Activator.getDefault().getPreferenceStore(); + return (HierarchicalPreferenceStore) Activator.getDefault() + .getPreferenceStore(); } - /** - * Load the internal data structures from the HierarchicalPreferenceStore. - * - * @param store - * HierarchicalPreferenceStore - */ -// private void reload(HierarchicalPreferenceStore store) { -// // Load SCAN Stuff here -// // pluginName -// this.pluginName = store -// .getStringArray(MonitorConfigConstants.SCAN_PLUGIN_NAME); -// -// // cell table -// String[] tempTableAttributes = store -// .getStringArray(MonitorConfigConstants.SCAN_CELL_TABLE_ATTRIB); -// -// ffmpTableAttributes = new boolean[tempTableAttributes.length]; -// for (int i = 0; i < tempTableAttributes.length; i++) { -// this.ffmpTableAttributes[i] = Boolean -// .valueOf(tempTableAttributes[i]); -// } -// -// } - /** * Retrieve one set of values for all attributes on a given table. * @@ -133,7 +85,6 @@ public class FFMPMonitorConfiguration { String value = store.getString(table.toString(field)); map.put(table.toString(), value); } - return map; } @@ -151,15 +102,13 @@ public class FFMPMonitorConfiguration { HashMap map = new HashMap(); for (tableFields field : tableFields.values()) { - map.put(field.toString(), store - .getString(attribute.toString(field))); + map.put(field.toString(), + store.getString(attribute.toString(field))); } return map; } - - /** * Retrieve the threshold data for one of the SCAN tables. Only returns * those attributes that have thresholds other than the default "999" value. @@ -203,7 +152,6 @@ public class FFMPMonitorConfiguration { getStore().setValue(attribute.toString(field), value); } - /** * @return String[] pluginName */ @@ -242,6 +190,6 @@ public class FFMPMonitorConfiguration { * boolean[] */ public void setTableAttributes(ffmpTable table, boolean[] tableAttributes) { - this.ffmpTableAttributes = tableAttributes.clone(); + this.ffmpTableAttributes = tableAttributes.clone(); } } diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/FFTISliderCanvas.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/FFTISliderCanvas.java index b560d7c0fc..97438547fa 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/FFTISliderCanvas.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/FFTISliderCanvas.java @@ -39,6 +39,22 @@ import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; +/** + * FFTI Slider Canvas + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 05, 2015 #5070      randerso    Changed to use system font name (not AWT)
+ * 
+ * 
+ * + * @author randerso + * @version 1.0 + */ public class FFTISliderCanvas { private Composite parentComp; @@ -160,7 +176,8 @@ public class FFTISliderCanvas { display = this.parentComp.getDisplay(); this.attribVal = accumAttrib; - setValuesNoRedraw(attribVal.getMin(), attribVal.getMax(), attribVal.getInc(), attribVal.getRedThreshold(), + setValuesNoRedraw(attribVal.getMin(), attribVal.getMax(), + attribVal.getInc(), attribVal.getRedThreshold(), attribVal.getYellowThreshold()); init(); @@ -182,7 +199,7 @@ public class FFTISliderCanvas { upperLblRect = new Rectangle(0, 0, 0, 0); lowerLblRect = new Rectangle(0, 0, 0, 0); - labelFont = new Font(display, "Monospaced", 10, SWT.BOLD); + labelFont = new Font(display, "Monospace", 10, SWT.BOLD); mousePt = new Point(0, 0); upperRegion = new Region(display); lowerRegion = new Region(display); @@ -201,6 +218,7 @@ public class FFTISliderCanvas { canvas.setLayoutData(gd); canvas.addPaintListener(new PaintListener() { + @Override public void paintControl(PaintEvent e) { drawCanvas(e.gc); } @@ -209,12 +227,14 @@ public class FFTISliderCanvas { canvas.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { - if (upperRegion.contains(e.x, e.y) == true || upperLblRect.contains(e.x, e.y) == true) { + if (upperRegion.contains(e.x, e.y) == true + || upperLblRect.contains(e.x, e.y) == true) { mousePt.x = e.x; mousePt.y = e.y; mouseDown = true; moveUpper = true; - } else if (lowerRegion.contains(e.x, e.y) == true || lowerLblRect.contains(e.x, e.y) == true) { + } else if (lowerRegion.contains(e.x, e.y) == true + || lowerLblRect.contains(e.x, e.y) == true) { mousePt.x = e.x; mousePt.y = e.y; mouseDown = true; @@ -259,10 +279,12 @@ public class FFTISliderCanvas { gc.fillRectangle(barXCoord, barYCoord, barWidth, barHeight); gc.setBackground(yellowColor); - gc.fillRectangle(lowerArrowXCoord, barYCoord, barWidth + 25 - lowerArrowXCoord, barHeight); + gc.fillRectangle(lowerArrowXCoord, barYCoord, barWidth + 25 + - lowerArrowXCoord, barHeight); gc.setBackground(redColor); - gc.fillRectangle(upperArrowXCoord, barYCoord, barWidth + 25 - upperArrowXCoord, barHeight); + gc.fillRectangle(upperArrowXCoord, barYCoord, barWidth + 25 + - upperArrowXCoord, barHeight); gc.setForeground(blackColor); gc.drawRectangle(barXCoord, barYCoord, barWidth, barHeight); @@ -276,7 +298,8 @@ public class FFTISliderCanvas { private void updateUpperArrow(GC gc) { upperRegion.subtract(upperPtArray); - upperPtArray = new int[] { upperArrowXCoord, barBottomYCoord - barHeight - 3, upperArrowXCoord + 4, + upperPtArray = new int[] { upperArrowXCoord, + barBottomYCoord - barHeight - 3, upperArrowXCoord + 4, barBottomYCoord, upperArrowXCoord - 4, barBottomYCoord }; upperRegion.add(upperPtArray); @@ -301,7 +324,8 @@ public class FFTISliderCanvas { private void updateLowerArrow(GC gc) { lowerRegion.subtract(lowerPtArray); - lowerPtArray = new int[] { lowerArrowXCoord, barBottomYCoord - barHeight - 3, lowerArrowXCoord + 4, + lowerPtArray = new int[] { lowerArrowXCoord, + barBottomYCoord - barHeight - 3, lowerArrowXCoord + 4, barBottomYCoord, lowerArrowXCoord - 4, barBottomYCoord }; lowerRegion.add(lowerPtArray); @@ -314,7 +338,8 @@ public class FFTISliderCanvas { private void updateLowerLabel(GC gc) { gc.setForeground(yellowColor); lowerStr = calcDisplayString(lowerDisplayVal); - int lblXCoord = (int) (lowerArrowXCoord - ((double) textWidth * (double) lowerStr.length() / 2)); + int lblXCoord = (int) (lowerArrowXCoord - ((double) textWidth + * (double) lowerStr.length() / 2)); gc.drawString(lowerStr, lblXCoord, lowerLblYCoord, true); lowerLblRect.x = lblXCoord; lowerLblRect.y = lowerLblYCoord; @@ -379,17 +404,18 @@ public class FFTISliderCanvas { double xCoordAsValue = (xCoord - barXCoord) * incPerPixel + minValue; - if (xCoordAsValue >= this.maxValue) //no rounding for max value + if (xCoordAsValue >= this.maxValue) { return this.maxValue; + } if (incValue == .25) { return (Math.round(xCoordAsValue * 4.00)) / 4.00; } else if (incValue == .05) { - return (double) (Math.round(xCoordAsValue * 20.0) / 20.0); + return Math.round(xCoordAsValue * 20.0) / 20.0; } else if (incValue == .10) { return (Math.round(xCoordAsValue * 10.00)) / 10.00; } else { - return (double) Math.round(xCoordAsValue); + return Math.round(xCoordAsValue); } } @@ -402,12 +428,14 @@ public class FFTISliderCanvas { } private int calcValueToBarXCoord(double val) { - int result = (int) Math.round((val - minValue) / incPerPixel + barXCoord); + int result = (int) Math.round((val - minValue) / incPerPixel + + barXCoord); return result; } - private void setValuesNoRedraw(double min, double max, double inc, double startingUpperVal, double startingLowerVal) { + private void setValuesNoRedraw(double min, double max, double inc, + double startingUpperVal, double startingLowerVal) { if (max < min) { return; } @@ -417,7 +445,7 @@ public class FFTISliderCanvas { this.rangeValue = max - min; this.incValue = inc; - incPerPixel = this.rangeValue / (double) barWidth; + incPerPixel = this.rangeValue / barWidth; if (inc < 1.00) { displayAtInt = false; @@ -436,11 +464,12 @@ public class FFTISliderCanvas { public void setValues(FFTIAttribute attribVal) { this.attribVal = attribVal; - setValues(attribVal.getMin(), attribVal.getMax(), attribVal.getInc(), attribVal.getRedThreshold(), - attribVal.getYellowThreshold()); + setValues(attribVal.getMin(), attribVal.getMax(), attribVal.getInc(), + attribVal.getRedThreshold(), attribVal.getYellowThreshold()); } - public void setValues(double min, double max, double inc, double startingUpperVal, double startingLowerVal) { + public void setValues(double min, double max, double inc, + double startingUpperVal, double startingLowerVal) { setValuesNoRedraw(min, max, inc, startingUpperVal, startingLowerVal); canvas.redraw(); } @@ -456,12 +485,15 @@ public class FFTISliderCanvas { startingUpperVal = maxValue; startingLowerVal = maxValue; - setValues(this.minValue, this.maxValue, this.incValue, startingUpperVal, startingLowerVal); + setValues(this.minValue, this.maxValue, this.incValue, + startingUpperVal, startingLowerVal); } else if (upperDisplayVal > maxValue) { startingUpperVal = maxValue; - setValues(this.minValue, this.maxValue, this.incValue, startingUpperVal, getLowerValue()); + setValues(this.minValue, this.maxValue, this.incValue, + startingUpperVal, getLowerValue()); } else { - setValues(this.minValue, this.maxValue, this.incValue, getUpperValue(), getLowerValue()); + setValues(this.minValue, this.maxValue, this.incValue, + getUpperValue(), getLowerValue()); } } diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/ToggleCanvas.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/ToggleCanvas.java index 0c4c2e1cfe..7c06e0f10b 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/ToggleCanvas.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/ToggleCanvas.java @@ -45,6 +45,7 @@ import org.eclipse.swt.widgets.Display; * ------------ ---------- ----------- -------------------------- * ???????????? lvenable Initial creation * Oct 10, 2013 #2464 lvenable Fix font memory leak. + * Nov 05, 2015 #5070 randerso Changed to use system font name (not AWT) * * * @@ -124,7 +125,7 @@ public class ToggleCanvas { } private void init() { - labelFont = new Font(display, "Monospaced", 10, SWT.BOLD); + labelFont = new Font(display, "Monospace", 10, SWT.BOLD); parentComp.addDisposeListener(new DisposeListener() { @Override @@ -145,6 +146,7 @@ public class ToggleCanvas { canvas.setLayoutData(gd); canvas.addPaintListener(new PaintListener() { + @Override public void paintControl(PaintEvent e) { drawCanvas(e.gc); } diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPConfig.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPConfig.java index 4f1d40da37..5f0478ed49 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPConfig.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPConfig.java @@ -20,6 +20,7 @@ package com.raytheon.uf.viz.monitor.ffmp.ui.dialogs; import java.io.File; +import java.io.InputStream; import java.util.ArrayList; import java.util.EnumMap; import java.util.HashMap; @@ -32,9 +33,11 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; import com.raytheon.uf.common.dataplugin.ffmp.FFMPRecord.FIELDS; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.localization.SaveableOutputStream; import com.raytheon.uf.common.monitor.config.FFMPRunConfigurationManager; import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager; import com.raytheon.uf.common.monitor.xml.FFMPRunXML; @@ -61,6 +64,9 @@ import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPTableColumnXML; * Apr 12, 2013 1902 mpduff Speed up cell coloring. * Apr 15, 2013 1904 mpduff Don't allow this class to be nulled out * Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP. + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods + * and replace printStackTrace with + * statusHandler.error() * * * @@ -192,16 +198,16 @@ public class FFMPConfig { readDefaultFFMPConfigBasin(); } - private void readNewFFMPConfigBasin(LocalizationFile xmlFileName) { + private void readNewFFMPConfigBasin(ILocalizationFile xmlFileName) { ffmpCfgBasin = null; - try { - ffmpCfgBasin = JAXB.unmarshal(xmlFileName.getFile(), - FFMPConfigBasinXML.class); + try (InputStream strm = xmlFileName.openInputStream()) { + ffmpCfgBasin = JAXB.unmarshal(strm, FFMPConfigBasinXML.class); createThresholdManager(); } catch (Exception e) { - e.printStackTrace(); + statusHandler.error("Error reading FFMP Basin config " + + xmlFileName.getPath(), e); } } @@ -220,26 +226,26 @@ public class FFMPConfig { return; } - System.out.println("Path Config FFMP: " + file.getAbsolutePath()); - - ffmpCfgBasin = JAXB.unmarshal(file, - FFMPConfigBasinXML.class); + ffmpCfgBasin = JAXB.unmarshal(file, FFMPConfigBasinXML.class); createThresholdManager(); } catch (Exception e) { - e.printStackTrace(); + statusHandler.error("Error reading default FFMP Basin config " + + DEFAULT_CONFIG_XML, e); } } - public void saveFFMPBasinConfig(LocalizationFile xmlFileName) { - try { - JAXB.marshal(ffmpCfgBasin, xmlFileName.getFile()); + public void saveFFMPBasinConfig(ILocalizationFile xmlFileName) { + try (SaveableOutputStream strm = xmlFileName.openOutputStream()) { + JAXB.marshal(ffmpCfgBasin, strm); - xmlFileName.save(); + strm.save(); createThresholdManager(); } catch (Exception e) { - e.printStackTrace(); + statusHandler.error( + "Error saving FFMP Basin config " + xmlFileName.getPath(), + e); } } diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/LoadSaveConfigDlg.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/LoadSaveConfigDlg.java index b872e18d22..190675cc37 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/LoadSaveConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/LoadSaveConfigDlg.java @@ -39,11 +39,11 @@ import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; -import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; @@ -57,8 +57,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Initial creation - * Dec 6, 2012 1353 rferrel Make dialog non-blocking. - * Apr 01, 2013 1830 mpduff Don't allow base files. + * Dec 06, 2012 1353 rferrel Make dialog non-blocking. + * Apr 01, 2013 1830 mpduff Don't allow base files. + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods * * * @@ -87,9 +88,7 @@ public class LoadSaveConfigDlg extends CaveSWTDialog { private List cfgFileList; - private LocalizationFile[] locFiles; - - private TreeMap locFileMap; + private TreeMap locFileMap; private Text newFileNameTF; @@ -122,7 +121,7 @@ public class LoadSaveConfigDlg extends CaveSWTDialog { @Override protected void initializeComponents(Shell shell) { - locFileMap = new TreeMap(); + locFileMap = new TreeMap<>(); controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); createListControl(); @@ -278,7 +277,7 @@ public class LoadSaveConfigDlg extends CaveSWTDialog { LocalizationContext context = pm.getContext( LocalizationType.CAVE_STATIC, level); String newFileName = "ffmp/guiConfig/" + fileName; - LocalizationFile selectedFile = pm.getLocalizationFile(context, + ILocalizationFile selectedFile = pm.getLocalizationFile(context, newFileName); FFMPConfig.getInstance().saveFFMPBasinConfig(selectedFile); @@ -318,12 +317,12 @@ public class LoadSaveConfigDlg extends CaveSWTDialog { String[] extensions = new String[] { ".xml" }; IPathManager pm = PathManagerFactory.getPathManager(); - ArrayList contextList = new ArrayList(); + java.util.List contextList = new ArrayList<>(); contextList.add(pm.getContext(LocalizationType.CAVE_STATIC, LocalizationLevel.SITE)); contextList.add(pm.getContext(LocalizationType.CAVE_STATIC, LocalizationLevel.USER)); - locFiles = pm.listFiles(contextList + ILocalizationFile[] locFiles = pm.listFiles(contextList .toArray(new LocalizationContext[contextList.size()]), "ffmp/guiConfig", extensions, false, true); @@ -333,7 +332,7 @@ public class LoadSaveConfigDlg extends CaveSWTDialog { for (int i = 0; i < locFiles.length; i++) { locFileMap.put(locFiles[i].getContext().getLocalizationLevel() - + ":" + locFiles[i].getName(), locFiles[i]); + + ":" + locFiles[i].getPath(), locFiles[i]); } for (String str : locFileMap.keySet()) { diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPColorUtils.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPColorUtils.java index efb7eedea4..f242029b3b 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPColorUtils.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPColorUtils.java @@ -27,11 +27,13 @@ import org.eclipse.swt.graphics.RGB; import com.raytheon.uf.common.colormap.Color; import com.raytheon.uf.common.colormap.ColorMap; +import com.raytheon.uf.common.colormap.ColorMapException; +import com.raytheon.uf.common.colormap.ColorMapLoader; import com.raytheon.uf.common.colormap.IColorMap; import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; import com.raytheon.uf.common.dataplugin.ffmp.FFMPRecord; import com.raytheon.uf.common.dataplugin.ffmp.FFMPRecord.FIELDS; -import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.style.ParamLevelMatchCriteria; @@ -40,7 +42,6 @@ import com.raytheon.uf.common.style.StyleManager; import com.raytheon.uf.common.style.StyleRule; import com.raytheon.uf.common.style.StyleRuleset; import com.raytheon.uf.common.style.image.ImagePreferences; -import com.raytheon.uf.viz.core.drawables.ColorMapLoader; import com.raytheon.uf.viz.core.exception.VizException; /** @@ -53,11 +54,13 @@ import com.raytheon.uf.viz.core.exception.VizException; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 08/29/09 2152 D. Hladky Initial release - * 05/21/12 DR 14833 G. Zhang Error handling for invalid cmap + * 05/21/12 DR 14833 G. Zhang Error handling for invalid cmap * Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP. * Jun 10, 2013 2075 njensen Improved init time - * Sep 5, 2013 2051 mnash Moved style rule instantiation so that we don't get NPEs + * Sep 05, 2013 2051 mnash Moved style rule instantiation so that we don't get NPEs * Sep 28, 2015 4756 dhladky Multiple guidance style rules for FFMP. + * Dec 10, 2015 4834 njensen Use non-deprecated ColorMapLoader + * * * * @author dhladky @@ -65,7 +68,7 @@ import com.raytheon.uf.viz.core.exception.VizException; */ public class FFMPColorUtils { - + /** Status handler */ private final IUFStatusHandler statusHandler = UFStatus .getHandler(FFMPColorUtils.class); @@ -130,9 +133,9 @@ public class FFMPColorUtils { try { cxml = ColorMapLoader.loadColorMap(colormapfile); - } catch (VizException e) { - statusHandler.error("Error loading ColorMap file: field: " + field - + " time: " + time + " ffgName: " + ffgName + } catch (ColorMapException e) { + statusHandler.error("Error loading ColorMap file: field: " + + field + " time: " + time + " ffgName: " + ffgName + " TableLoad: " + tableLoad, e); } @@ -276,7 +279,7 @@ public class FFMPColorUtils { return qpeHourToUse; } - + private void parseFileNames(List fileArray) { double hour = 0.0; for (String fn : fileArray) { @@ -344,9 +347,9 @@ public class FFMPColorUtils { private List getQpeColorMapFiles() { List colormaps = new ArrayList(); - LocalizationFile[] files = ColorMapLoader.listColorMapFiles("ffmp"); - for (LocalizationFile file : files) { - String fn = file.getName(); + ILocalizationFile[] files = ColorMapLoader.listColorMapFiles("ffmp"); + for (ILocalizationFile file : files) { + String fn = file.getPath(); if (fn.indexOf("qpe") > 0) { colormaps.add(fn); } @@ -395,14 +398,11 @@ public class FFMPColorUtils { if (DEFAULT_PARAMNAME.equalsIgnoreCase(pn) && DEFAULT_COLORMAP.equalsIgnoreCase(cm)) { sr = srl; - System.out - .println("FFMPColorUtils.getDefaultColorMap(): StyleRule pn-cm value: " - + pn + "-" + cm); break; } } - + // get the colormapfile name String colormapfile = ((ImagePreferences) sr.getPreferences()) .getDefaultColormap(); @@ -410,8 +410,8 @@ public class FFMPColorUtils { // load the colormap try { cxml = ColorMapLoader.loadColorMap(colormapfile); - } catch (VizException e) { - e.printStackTrace(); + } catch (ColorMapException e) { + statusHandler.error("Error loading colormap " + colormapfile, e); } return cxml; diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java index 527f1b417f..662a5e9d40 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java @@ -202,6 +202,8 @@ import com.vividsolutions.jts.geom.Point; * Feb 13, 2015 4121 mpduff Change label caching. * Sep 28, 2015 4756 dhladky Multiple guidance sources. * Oct 26, 2015 5056 dhladky Simplified Guidance Interpolation. + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling + * * * * @author dhladky @@ -1254,7 +1256,7 @@ public class FFMPResource extends public void run() { if (font == null) { - font = target.initializeFont("Dialog", 11, null); + font = target.initializeFont("Dialog", 9, null); } font.setMagnification(getCapability( @@ -1263,7 +1265,7 @@ public class FFMPResource extends if (xfont == null) { IFont.Style[] styles = new IFont.Style[] { IFont.Style.BOLD }; - xfont = target.initializeFont("Monospace", 12, styles); + xfont = target.initializeFont("Monospace", 10, styles); } xfont.setMagnification(getCapability( @@ -3190,7 +3192,8 @@ public class FFMPResource extends ITimer timer = TimeUtil.getTimer(); timer.start(); FfmpTableConfig tableConfig = FfmpTableConfig.getInstance(); - String ffgGraphType = tableConfig.getTableConfigData(getSiteKey()).getFfgGraphType(); + String ffgGraphType = tableConfig.getTableConfigData(getSiteKey()) + .getFfgGraphType(); Long basinPfaf = null; Long dataId = null; FFMPVirtualGageBasinMetaData fvgbmd = null; @@ -3208,7 +3211,7 @@ public class FFMPResource extends } FFMPBasinMetaData mBasin = monitor.getTemplates(getSiteKey()).getBasin( - getSiteKey(), basinPfaf); + getSiteKey(), basinPfaf); FFMPGraphData fgd = null; // VGB if (fvgbmd != null) { @@ -3246,8 +3249,9 @@ public class FFMPResource extends for (Date date : rateBasin.getValues().keySet()) { if (date.before(minUriTime) || date.before(barrierTime) - || date.after(mostRecentRefTime)) + || date.after(mostRecentRefTime)) { continue;// DR 16148 + } double dtime = FFMPGuiUtils.getTimeDiff(mostRecentRefTime, date); @@ -3275,8 +3279,9 @@ public class FFMPResource extends for (Date date : qpeBasin.getValues().keySet()) { if (date.before(minUriTime) || date.before(barrierTime) - || date.after(mostRecentRefTime)) + || date.after(mostRecentRefTime)) { continue;// DR 16148 + } double dtime = FFMPGuiUtils.getTimeDiff(mostRecentRefTime, date); @@ -3337,8 +3342,8 @@ public class FFMPResource extends try { guidBasin = (FFMPGuidanceBasin) monitor.getGraphGuidanceBasin( - getProduct(), ffgGraphType, getSiteKey(), getDataKey(), null, - oldestRefTime, FFMPRecord.ALL, basinPfaf); + getProduct(), ffgGraphType, getSiteKey(), getDataKey(), + null, oldestRefTime, FFMPRecord.ALL, basinPfaf); ArrayList guidTimes = new ArrayList(); for (SourceXML ffgSource : getProduct().getGuidanceSourcesByType( ffgGraphType)) { @@ -3359,8 +3364,10 @@ public class FFMPResource extends fgd.setGuidanceTimes(guidTimes); guid = true; } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - "FFMPMonitor: getGraphData(): missing GUIDANCE dataset.", e); + statusHandler + .handle(Priority.PROBLEM, + "FFMPMonitor: getGraphData(): missing GUIDANCE dataset.", + e); } if (fvgbmd != null) { @@ -3388,7 +3395,8 @@ public class FFMPResource extends } catch (Exception e) { statusHandler .handle(Priority.PROBLEM, - "FFMPMonitor: getGraphData(): missing VIRTUAL dataset.", e); + "FFMPMonitor: getGraphData(): missing VIRTUAL dataset.", + e); } } diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogDataGenerator.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogDataGenerator.java old mode 100644 new mode 100755 index 630134bfbf..269ae3535f --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogDataGenerator.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogDataGenerator.java @@ -26,6 +26,7 @@ import java.util.Map; import com.raytheon.uf.common.dataplugin.fog.FogRecord; import com.raytheon.uf.common.dataplugin.fog.FogRecord.FOG_THREAT; import com.raytheon.uf.common.monitor.data.CommonConfig; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.viz.monitor.config.CommonTableConfig; import com.raytheon.uf.viz.monitor.config.CommonTableConfig.CellType; @@ -35,7 +36,6 @@ import com.raytheon.uf.viz.monitor.data.TableCellData; import com.raytheon.uf.viz.monitor.data.TableData; import com.raytheon.uf.viz.monitor.data.TableRowData; import com.raytheon.uf.viz.monitor.fog.threshold.FogThresholdMgr; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; /** * Generate Data for Fog Dialogs @@ -49,6 +49,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; * 12/07/09 dhladky Initial Creation. * Oct.29, 2012 1297 skorolev Changed HashMap to Map * Oct.31, 2012 1297 skorolev Clean code + * Dec 26, 2015 5114 skorolev Corrected imports. * * * @@ -58,9 +59,9 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; public class FogDataGenerator { - private CommonTableConfig ctc; + private final CommonTableConfig ctc; - private FogThresholdMgr ftm; + private final FogThresholdMgr ftm; /** * Generates Fog data diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java index 33a66a8e5a..90a5b60aca 100755 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java @@ -38,8 +38,8 @@ import com.raytheon.uf.common.dataplugin.fog.FogRecord.FOG_THREAT; import com.raytheon.uf.common.jms.notification.NotificationMessage; import com.raytheon.uf.common.monitor.MonitorAreaUtils; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; +import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -89,6 +89,7 @@ import com.vividsolutions.jts.geom.Geometry; * Mar 09, 2014 3888 dhladky Stopped processing when dialogs are null or disposed. * Sep 18, 2015 3873 skorolev Removed common definitions. Replaced deprecated NotificationMessage. * Dec 17, 2015 3873 dhladky Abstracted handling of dialogTime and Zone dialog events. + * Jan 04, 2016 5115 skorolev Corrected imports and replaced Mon.Name with App.Name. * * * @@ -143,7 +144,7 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { */ private FogMonitor() { pluginPatterns.add(fssPattern); - fogConfig = FSSObsMonitorConfigurationManager.getInstance(MonName.fog); + fogConfig = FSSObsMonitorConfigurationManager.getInstance(AppName.FOG); updateMonitoringArea(); initObserver(OBS, this); createDataStructures(); diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/threshold/FogThresholdMgr.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/threshold/FogThresholdMgr.java index 9a69ffa15a..2f4700df09 100755 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/threshold/FogThresholdMgr.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/threshold/FogThresholdMgr.java @@ -22,10 +22,10 @@ package com.raytheon.uf.viz.monitor.fog.threshold; import java.util.ArrayList; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.FogDisplay; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.FogMonitor; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.FogDisplay; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.FogMonitor; /** * This class manages the FOG thresholds for display and monitor. @@ -41,6 +41,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.FogMonitor; * May 20, 2014 3086 skorolev Cleaned code. * Sep 04, 2014 3220 skorolev Removed "site". * Sep 18, 2015 3873 skorolev Adjusted to AppName and removed areaConfigMgr. + * Dec 26, 2015 5114 skorolev Corrected imports. * * * diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogDisplayMeteoTab.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogDisplayMeteoTab.java old mode 100644 new mode 100755 index fa82e77f92..271af0a2ed --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogDisplayMeteoTab.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogDisplayMeteoTab.java @@ -29,14 +29,14 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.FogDisplay; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; import com.raytheon.uf.viz.monitor.data.RangesUtil; import com.raytheon.uf.viz.monitor.fog.threshold.FogDisplayMeteoData; import com.raytheon.uf.viz.monitor.fog.threshold.FogThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.FogDisplay; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; /** * Fog Display Meteo Table. @@ -48,6 +48,7 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 21, 2014 3086 skorolev Cleaned code + * Dec 26, 2015 5114 skorolev Corrected imports. * * * diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogDisplayWindTab.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogDisplayWindTab.java old mode 100644 new mode 100755 index bcd0a58828..c4337ff67d --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogDisplayWindTab.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogDisplayWindTab.java @@ -28,289 +28,308 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.FogDisplay; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; import com.raytheon.uf.viz.monitor.fog.threshold.FogDisplayWindData; import com.raytheon.uf.viz.monitor.fog.threshold.FogThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.FogDisplay; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; -public class FogDisplayWindTab extends TabItemComp implements IUpdateDisplayWind -{ +/** + * Fog Display Wind Table. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 26, 2015 5115       skorolev    Corrected imports.
+ * 
+ * 
+ * + * @author skorolev + * @version 1.0 + */ +public class FogDisplayWindTab extends TabItemComp implements + IUpdateDisplayWind { /** * Dialog used for editing the FOG display wind data. */ private FogDisplayWindEditDlg fogWindEditDlg; - + private ArrayList areaIDArray; - + private ArrayList fogDataArray; - - public FogDisplayWindTab(TabFolder parent, DataUsageKey duKey) - { + + public FogDisplayWindTab(TabFolder parent, DataUsageKey duKey) { super(parent, duKey); } - @Override - protected void createListHeader(Composite parentComp) - { + @Override + protected void createListHeader(Composite parentComp) { Composite lblComp = new Composite(parentComp, SWT.NONE); GridLayout gl = new GridLayout(5, false); - gl.horizontalSpacing = 0; + gl.horizontalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; lblComp.setLayout(gl); - + /* * Create filler label. */ GridData gd = new GridData(73, SWT.DEFAULT); Label fillerLbl = new Label(lblComp, SWT.CENTER); fillerLbl.setLayoutData(gd); - + /* * Wind */ Composite windComp = createGroupComposite(lblComp, 5, null); - createLabelComp(windComp, "Wind", "Speed(kt)", false); - createLabelComp(windComp, "Peak", "Wind(kt)", false); + createLabelComp(windComp, "Wind", "Speed(kt)", false); + createLabelComp(windComp, "Peak", "Wind(kt)", false); createLabelComp(windComp, "Gust", "Speed(kt)", false); createLabelComp(windComp, "Wind", "Dir(deg)\n(from)", false); createLabelComp(windComp, "Wind", "Dir(deg)\n(to)", false); - } - + } + /* * TODO: redo... */ - protected void populateList() - { - if (fogDataArray == null) - { + @Override + protected void populateList() { + if (fogDataArray == null) { createDataArray(); } - + boolean update = false; - if (dataList.getItemCount() > 0) - { + if (dataList.getItemCount() > 0) { update = true; } - + areaIDArray = new ArrayList(); - + String currentAreaID; - - StringBuilder sb = null; + + StringBuilder sb = null; FogDisplayWindData fdwd = null; - - for (int i = 0; i < fogDataArray.size(); i++) - { + + for (int i = 0; i < fogDataArray.size(); i++) { sb = new StringBuilder(); - + fdwd = fogDataArray.get(i); - + currentAreaID = fdwd.getAreaID(); areaIDArray.add(currentAreaID); - + sb.append(String.format(areaIdFmt, currentAreaID)); - + /* * Wind Speed */ - appendIntData(sb, fdwd.getWindWindSpeedR(), fdwd.getWindWindSpeedY()); - + appendIntData(sb, fdwd.getWindWindSpeedR(), + fdwd.getWindWindSpeedY()); + /* * Peak Wind */ appendIntData(sb, fdwd.getWindPeakR(), fdwd.getWindPeakY()); - + /* * Gust Speed */ appendIntData(sb, fdwd.getWindGustR(), fdwd.getWindGustY()); - + /* * Wind Direction: From */ - appendIntData(sb, fdwd.getWindDirFromY(),fdwd.getWindDirFromR()); - + appendIntData(sb, fdwd.getWindDirFromY(), fdwd.getWindDirFromR()); + /* * Wind Direction: To */ appendIntData(sb, fdwd.getWindDirToR(), fdwd.getWindDirToY()); - + /* * Add the line of data to the list. */ sb.append(" "); - - if (update == true) - { + + if (update == true) { dataList.setItem(i, sb.toString()); - } - else - { + } else { dataList.add(sb.toString()); - } + } } - - packListControls(); + + packListControls(); } - - private void createDataArray() - { + + private void createDataArray() { fogDataArray = new ArrayList(); - - FogThresholdMgr ftm = FogThresholdMgr.getInstance(); - + + FogThresholdMgr ftm = FogThresholdMgr.getInstance(); + String xmlKey; - String areaID; - + String areaID; + ThresholdsXML threshXML = ftm.getThresholdsXmlData(duKey); - + ArrayList areasArray = threshXML.getAreas(); - - for (AreaXML area : areasArray) - { + + for (AreaXML area : areasArray) { areaID = area.getAreaId(); FogDisplayWindData fdwd = new FogDisplayWindData(); - + fdwd.setAreaID(areaID); /* * Wind Speed */ xmlKey = FogDisplay.FOG_DISP_WIND_WIND_SPEED.getXmlKey(); - fdwd.setWindWindSpeedR(ftm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - fdwd.setWindWindSpeedY(ftm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + fdwd.setWindWindSpeedR(ftm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + fdwd.setWindWindSpeedY(ftm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); /* * Peak Wind */ xmlKey = FogDisplay.FOG_DISP_WIND_PEAK_WIND.getXmlKey(); - fdwd.setWindPeakR(ftm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - fdwd.setWindPeakY(ftm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + fdwd.setWindPeakR(ftm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + fdwd.setWindPeakY(ftm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); /* * Gust Speed */ xmlKey = FogDisplay.FOG_DISP_WIND_GUST_SPEED.getXmlKey(); - fdwd.setWindGustR(ftm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - fdwd.setWindGustY(ftm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + fdwd.setWindGustR(ftm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + fdwd.setWindGustY(ftm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); /* * Wind Direction: From */ xmlKey = FogDisplay.FOG_DISP_WIND_DIR_FROM.getXmlKey(); - fdwd.setWindDirFromR(ftm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - fdwd.setWindDirFromY(ftm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + fdwd.setWindDirFromR(ftm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + fdwd.setWindDirFromY(ftm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); /* * Wind Direction: To */ xmlKey = FogDisplay.FOG_DISP_WIND_DIR_TO.getXmlKey(); - fdwd.setWindDirToR(ftm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - fdwd.setWindDirToY(ftm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + fdwd.setWindDirToR(ftm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + fdwd.setWindDirToY(ftm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); + fogDataArray.add(fdwd); } } - - private FogDisplayWindData getDataAtFirstSelection() - { + + private FogDisplayWindData getDataAtFirstSelection() { int index = dataList.getSelectionIndex(); - - return fogDataArray.get(index); + + return fogDataArray.get(index); } - - private void updateFogDataArray(FogDisplayWindData fdwd) - { - int[] dataListIndexes = dataList.getSelectionIndices(); + + private void updateFogDataArray(FogDisplayWindData fdwd) { + int[] dataListIndexes = dataList.getSelectionIndices(); int currentIndex = 0; - - for (int i = 0; i < dataListIndexes.length; i++) - { + + for (int i = 0; i < dataListIndexes.length; i++) { currentIndex = dataListIndexes[i]; - + fogDataArray.get(currentIndex).updateData(fdwd); - } + } } - + @Override - public void commitDataToXML() - { + public void commitDataToXML() { FogThresholdMgr ftm = FogThresholdMgr.getInstance(); - + String xmlKey; String areaID; - - for (FogDisplayWindData fdwd : fogDataArray) - { + + for (FogDisplayWindData fdwd : fogDataArray) { areaID = fdwd.getAreaID(); - + /* * Wind Speed */ xmlKey = FogDisplay.FOG_DISP_WIND_WIND_SPEED.getXmlKey(); - ftm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, fdwd.getWindWindSpeedR()); - ftm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, fdwd.getWindWindSpeedY()); + ftm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + fdwd.getWindWindSpeedR()); + ftm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + fdwd.getWindWindSpeedY()); /* * Peak Wind */ xmlKey = FogDisplay.FOG_DISP_WIND_PEAK_WIND.getXmlKey(); - ftm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, fdwd.getWindPeakR()); - ftm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, fdwd.getWindPeakY()); + ftm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + fdwd.getWindPeakR()); + ftm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + fdwd.getWindPeakY()); /* * Gust Speed */ xmlKey = FogDisplay.FOG_DISP_WIND_GUST_SPEED.getXmlKey(); - ftm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, fdwd.getWindGustR()); - ftm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, fdwd.getWindGustY()); + ftm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + fdwd.getWindGustR()); + ftm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + fdwd.getWindGustY()); /* * Wind Direction: From */ xmlKey = FogDisplay.FOG_DISP_WIND_DIR_FROM.getXmlKey(); - ftm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, fdwd.getWindDirFromR()); - ftm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, fdwd.getWindDirFromY()); + ftm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + fdwd.getWindDirFromR()); + ftm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + fdwd.getWindDirFromY()); /* * Wind Direction: To */ xmlKey = FogDisplay.FOG_DISP_WIND_DIR_TO.getXmlKey(); - ftm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, fdwd.getWindDirToR()); - ftm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, fdwd.getWindDirToY()); + ftm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + fdwd.getWindDirToR()); + ftm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + fdwd.getWindDirToY()); } } - + @Override - public void reloadData() - { + public void reloadData() { dataList.removeAll(); fogDataArray.clear(); fogDataArray = null; - + populateList(); } @Override - protected void editDataAction() - { + protected void editDataAction() { FogDisplayWindData fdwd = getDataAtFirstSelection(); - - if (fogWindEditDlg == null) - { - fogWindEditDlg = new FogDisplayWindEditDlg(getParent().getShell(), fdwd, this); - fogWindEditDlg.open(); + + if (fogWindEditDlg == null) { + fogWindEditDlg = new FogDisplayWindEditDlg(getParent().getShell(), + fdwd, this); + fogWindEditDlg.open(); fogWindEditDlg = null; } } @Override - public void updateThresholdData(FogDisplayWindData fdwd) - { + public void updateThresholdData(FogDisplayWindData fdwd) { updateFogDataArray(fdwd); populateList(); } diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitorMeteoTab.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitorMeteoTab.java old mode 100644 new mode 100755 index 2ffc13567b..991099fa26 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitorMeteoTab.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitorMeteoTab.java @@ -29,14 +29,14 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.FogMonitor; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; import com.raytheon.uf.viz.monitor.data.RangesUtil; import com.raytheon.uf.viz.monitor.fog.threshold.FogMonitorMeteoData; import com.raytheon.uf.viz.monitor.fog.threshold.FogThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.FogMonitor; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; /** * Fog Monitor Meteo Table @@ -48,6 +48,7 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; * Date Ticket# Engineer Description * ------------ ---------- ----------- ------------- * May 21, 2014 3086 skorolev Cleaned code. + * Dec 26, 2015 5115 skorolev Corrected imports * * * diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java index 86dd5d97e8..415a81526f 100755 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java @@ -27,7 +27,6 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; @@ -56,6 +55,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Oct 27, 2014 3667 skorolev Cleaned code. * Feb 10, 2015 3886 skorolev Changed confirmation message. * Aug 17, 2015 3841 skorolev Corrected handleOkBtnSelection. + * Jan 04, 2016 5115 skorolev Replaced MonName with AppName. * * * @@ -148,7 +148,7 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { protected FSSObsMonitorConfigurationManager getInstance() { if (configMgr == null) { configMgr = FSSObsMonitorConfigurationManager - .getInstance(MonName.fog); + .getInstance(AppName.FOG); } return configMgr; } diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogZoneTableDlg.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogZoneTableDlg.java index cd7cbaa301..ab7de7453d 100755 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogZoneTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogZoneTableDlg.java @@ -28,8 +28,8 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; +import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.common.monitor.data.ObConst.DisplayVarName; import com.raytheon.uf.viz.monitor.IMonitor; @@ -62,6 +62,7 @@ import com.raytheon.uf.viz.monitor.ui.dialogs.ZoneTableDlg; * Sep 04, 2014 3220 skorolev Removed "site". Added check on dispose. * Sep 18, 2015 3873 skorolev Adjusted to AppName and MonName. * Dec 17, 2015 3873 dhladky Abstracted handling of dialogTime and Zone dialog events. + * Jan 04, 2015 5115 skorolev Corrected imports and replaced AppName with MonName. * * * @@ -195,6 +196,7 @@ public class FogZoneTableDlg extends ZoneTableDlg { @Override public void fireDialogShutdown(IMonitorListener iml) { Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { Iterator iter = getMonitorControlListeners() .iterator(); @@ -215,6 +217,7 @@ public class FogZoneTableDlg extends ZoneTableDlg { @Override public void fireKillMonitor() { Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { Iterator iter = getMonitorControlListeners() .iterator(); @@ -281,7 +284,7 @@ public class FogZoneTableDlg extends ZoneTableDlg { protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() { if (configMgr == null || configMgr.isPopulated()) { configMgr = FSSObsMonitorConfigurationManager - .getInstance(MonName.fog); + .getInstance(AppName.FOG); } return configMgr; } diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/resource/FogResource.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/resource/FogResource.java index 16c71cff3f..4998869637 100644 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/resource/FogResource.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/resource/FogResource.java @@ -75,6 +75,8 @@ import com.vividsolutions.jts.geom.Coordinate; * 16Jun2012 14386 zhao Fixed a bug causing auto update to fail; * also modified to keep only latest Fog record for each frame. * 29Jul2014 3465 mapeters Updated deprecated drawString() calls. + * 05Nov2015 5070 randerso Adjust font sizes for dpi scaling + * * * * @author dhladky @@ -112,7 +114,7 @@ public class FogResource extends private static float[] fogLabelValues = new float[] { 60.0f, 110.0f, 220.0f }; private GriddedImageDisplay gridDisplay = null; - + private Date refHour; /* The font used */ @@ -142,8 +144,7 @@ public class FogResource extends if (record == null) { return "No Fog Data Available"; } - return "Fog Threat Level " - + record.getDataTime().getLegendString(); + return "Fog Threat Level " + record.getDataTime().getLegendString(); } @Override @@ -167,20 +168,27 @@ public class FogResource extends if (!resourceData.dataObjectMap.containsKey(rh)) { try { record = resourceData.populateRecord(pdo); - resourceData.dataObjectMap.put(record.getRefHour().getTime(), record); - resourceData.gridImageMap.put(record.getRefHour().getTime(), null); + resourceData.dataObjectMap.put(record.getRefHour().getTime(), + record); + resourceData.gridImageMap.put(record.getRefHour().getTime(), + null); } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), + e); } - } else if ( resourceData.dataObjectMap.containsKey(rh) ) { - try { - record = resourceData.populateRecord(pdo); - resourceData.dataObjectMap.remove(record.getRefHour().getTime()); - resourceData.dataObjectMap.put(record.getRefHour().getTime(), record); + } else if (resourceData.dataObjectMap.containsKey(rh)) { + try { + record = resourceData.populateRecord(pdo); + resourceData.dataObjectMap + .remove(record.getRefHour().getTime()); + resourceData.dataObjectMap.put(record.getRefHour().getTime(), + record); resourceData.gridImageMap.remove(record.getRefHour().getTime()); - resourceData.gridImageMap.put(record.getRefHour().getTime(), null); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); + resourceData.gridImageMap.put(record.getRefHour().getTime(), + null); + } catch (VizException e) { + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), + e); } } } @@ -206,7 +214,7 @@ public class FogResource extends @Override protected void initInternal(IGraphicsTarget target) throws VizException { if (this.font == null) { - this.font = target.initializeFont("Dialog", 11, null); + this.font = target.initializeFont("Dialog", 9, null); } } @@ -224,8 +232,11 @@ public class FogResource extends } this.record = resourceData.dataObjectMap.get(refHour); if (record != null) { - if(record.getThreats()== null) needsUpdate=true; - if (resourceData.gridImageMap.get(refHour) != null && needsUpdate==false) { + if (record.getThreats() == null) { + needsUpdate = true; + } + if (resourceData.gridImageMap.get(refHour) != null + && needsUpdate == false) { gridDisplay = resourceData.gridImageMap.get(refHour); } else { if (needsUpdate) { @@ -235,7 +246,7 @@ public class FogResource extends gridDisplay = new GriddedImageDisplay(FloatBuffer.wrap(record .getThreats()), descriptor, record.getGridGeometry()); resourceData.gridImageMap.put(refHour, gridDisplay); - needsUpdate=false; + needsUpdate = false; } } if (!refHour.equals(previousDataTime)) { @@ -309,21 +320,21 @@ public class FogResource extends } catch (org.opengis.referencing.operation.TransformException e) { e.printStackTrace(); } - int select = (int) ((record.getNx() * (int) coor.y) + (int) coor.x); + int select = (record.getNx() * (int) coor.y) + (int) coor.x; if (select < record.getNx() * record.getNy() && select > 0 && coor.x > 0 && coor.x < record.getNx()) { inspect = "VIS value: " - + record.getVisArray()[(int) (record.getNx() * (int) coor.y) + + record.getVisArray()[record.getNx() * (int) coor.y + (int) coor.x] + "\n" + " IR 3.9 value: " - + record.getIR_3_9Array()[(int) (record.getNx() * (int) coor.y) + + record.getIR_3_9Array()[record.getNx() * (int) coor.y + (int) coor.x] + "\n" + " IR 10.7 value: " - + record.getIR_10_7Array()[(int) (record.getNx() * (int) coor.y) - + (int) coor.x] + "\n"; + + record.getIR_10_7Array()[record.getNx() + * (int) coor.y + (int) coor.x] + "\n"; } else { inspect = "NO DATA"; } @@ -416,15 +427,15 @@ public class FogResource extends monitor.closeDialog(); } - + @Override public void project(CoordinateReferenceSystem crs) throws VizException { - if (record != null) { - record.setGridGeometry2D(null); - resourceData.resetGridImgMap(); - needsUpdate = false; - issueRefresh(); - } + if (record != null) { + record.setGridGeometry2D(null); + resourceData.resetGridImgMap(); + needsUpdate = false; + issueRefresh(); + } } } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.monitor.safeseas/META-INF/MANIFEST.MF index f79bfc979d..f69d83b57a 100644 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Safeseas Plug-in Bundle-SymbolicName: com.raytheon.uf.viz.monitor.safeseas;singleton:=true -Bundle-Version: 1.14.0.qualifier +Bundle-Version: 1.15.0.qualifier Bundle-Vendor: RAYTHEON Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, @@ -20,7 +20,6 @@ Require-Bundle: org.eclipse.ui, com.raytheon.uf.viz.monitor.fog;bundle-version="1.12.1174" Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy -Import-Package: com.raytheon.viz.pointdata, - org.apache.commons.lang +Import-Package: com.raytheon.viz.pointdata Export-Package: com.raytheon.uf.viz.monitor.safeseas.resources Bundle-ClassPath: com.raytheon.uf.viz.monitor.safeseas.jar diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java old mode 100755 new mode 100644 index a22a284705..f67492628c --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java @@ -35,8 +35,8 @@ import com.raytheon.uf.common.dataplugin.fog.FogRecord.FOG_THREAT; import com.raytheon.uf.common.jms.notification.NotificationMessage; import com.raytheon.uf.common.monitor.MonitorAreaUtils; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; +import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -84,9 +84,9 @@ import com.vividsolutions.jts.geom.Geometry; * Apr 28, 2014 3086 skorolev Removed local getMonitorAreaConfig method. * Sep 04, 2014 3220 skorolev Updated configUpdate method and added updateMonitoringArea. * Sep 18, 2015 3873 skorolev Removed common definitions. Replaced deprecated NotificationMessage. - * Oct 19, 2015 3841 skorolev Corrected constructor. * Oct 21, 2015 3873 dhladky Get Obs load off UI thread. * Dec 17, 2015 3873 dhladky Abstracted handling of dialogTime and Zone dialog events. + * Jan 04, 2016 5115 skorolev Corrected imports and replaced AppName with MonName. * * * @@ -144,12 +144,11 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { private SafeSeasMonitor() { pluginPatterns.add(fssPattern); ssAreaConfig = FSSObsMonitorConfigurationManager - .getInstance(MonName.ss); + .getInstance(AppName.SAFESEAS); updateMonitoringArea(); initObserver(OBS, this); createDataStructures(); processProductAtStartup(); - obData.getZoneTableData(); readTableConfig(MonitorThresholdConfiguration.SAFESEAS_THRESHOLD_CONFIG); } @@ -183,6 +182,7 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { private void createDataStructures() { obData = new ObMultiHrsReports(CommonConfig.AppName.SAFESEAS); obData.setThresholdMgr(SSThresholdMgr.getInstance()); + obData.getZoneTableData(); algorithmData = new HashMap>(); } @@ -607,5 +607,5 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { } MonitoringArea.setPlatformMap(zones); } - + } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/threshold/SSThresholdMgr.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/threshold/SSThresholdMgr.java index ef15925e32..900f4dafaf 100755 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/threshold/SSThresholdMgr.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/threshold/SSThresholdMgr.java @@ -22,10 +22,10 @@ package com.raytheon.uf.viz.monitor.safeseas.threshold; import java.util.ArrayList; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SafeSeasDisplay; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SafeSeasMonitor; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasDisplay; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasMonitor; /** * This class manages the SafeSeas thresholds for display and monitor. @@ -41,6 +41,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasMonitor; * Apr 28, 2014 3086 skorolev Removed local getMonitorAreaConfig method. * Sep 04, 2014 3220 skorolev Removed "site". * Sep 18, 2015 3873 skorolev Adjusted to AppName and removed areaConfigMgr. + * Dec 26, 2015 5114 skorolev Corrected imports. * * * diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplayMeteoTab.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplayMeteoTab.java old mode 100644 new mode 100755 index ff66e05789..ee5215835b --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplayMeteoTab.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplayMeteoTab.java @@ -29,14 +29,14 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SafeSeasDisplay; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; import com.raytheon.uf.viz.monitor.data.RangesUtil; import com.raytheon.uf.viz.monitor.safeseas.threshold.SSDisplayMeteoData; import com.raytheon.uf.viz.monitor.safeseas.threshold.SSThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasDisplay; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; /** * SAFESEAS Display Meteo Table @@ -48,6 +48,7 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 21, 2014 3086 skorolev Cleaned code + * Dec 26, 2015 5114 skorolev Corrected imports. * * * diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplayProductTab.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplayProductTab.java old mode 100644 new mode 100755 index f7314482c9..7a63b1cf7b --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplayProductTab.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplayProductTab.java @@ -28,375 +28,437 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SafeSeasDisplay; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; import com.raytheon.uf.viz.monitor.safeseas.threshold.SSDisplayProductData; import com.raytheon.uf.viz.monitor.safeseas.threshold.SSThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasDisplay; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; -public class SSDisplayProductTab extends TabItemComp implements IUpdateDisplayProduct -{ +/** + * SAFESEAS Display Product Table. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 26, 2015 5115       skorolev    Corrected imports.
+ * 
+ * 
+ * + * @author skorolev + * @version 1.0 + */ +public class SSDisplayProductTab extends TabItemComp implements + IUpdateDisplayProduct { SSDisplayProductEditDlg productEditDlg; - + private ArrayList areaIDArray; - + private ArrayList ssDataArray; - - public SSDisplayProductTab(TabFolder parent, DataUsageKey duKey) - { + + public SSDisplayProductTab(TabFolder parent, DataUsageKey duKey) { super(parent, duKey); } - @Override - protected void createListHeader(Composite parentComp) - { + @Override + protected void createListHeader(Composite parentComp) { Composite lblComp = new Composite(parentComp, SWT.NONE); GridLayout gl = new GridLayout(5, false); - gl.horizontalSpacing = 0; + gl.horizontalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; lblComp.setLayout(gl); - + /* * Create filler label. */ GridData gd = new GridData(75, SWT.DEFAULT); Label fillerLbl = new Label(lblComp, SWT.CENTER); fillerLbl.setLayoutData(gd); - + /* * Small AirCraft Warning */ - Composite smallAircraftComp = createGroupComposite(lblComp, 4, "Small Craft Advisory"); + Composite smallAircraftComp = createGroupComposite(lblComp, 4, + "Small Craft Advisory"); createLabelComp(smallAircraftComp, "Wind", "Speed(kt)", false); createLabelComp(smallAircraftComp, "Gust", "Speed(kt)", false); - createLabelComp(smallAircraftComp, "Peak", "Wind(kt)", false); + createLabelComp(smallAircraftComp, "Peak", "Wind(kt)", false); createLabelComp(smallAircraftComp, "Wave", "Height(ft)", false); - + /* * Gale Warning */ - Composite galeWarningComp = createGroupComposite(lblComp, 3, "Gale Warning"); + Composite galeWarningComp = createGroupComposite(lblComp, 3, + "Gale Warning"); createLabelComp(galeWarningComp, "Wind", "Speed(kt)", false); createLabelComp(galeWarningComp, "Gust", "Speed(kt)", false); - createLabelComp(galeWarningComp, "Peak", "Wind(kt)", false); - + createLabelComp(galeWarningComp, "Peak", "Wind(kt)", false); + /* * Storm Warning */ - Composite stormWarningComp = createGroupComposite(lblComp, 3, "Storm Warning"); + Composite stormWarningComp = createGroupComposite(lblComp, 3, + "Storm Warning"); createLabelComp(stormWarningComp, "Wind", "Speed(kt)", false); createLabelComp(stormWarningComp, "Gust", "Speed(kt)", false); - createLabelComp(stormWarningComp, "Peak", "Wind(kt)", false); - + createLabelComp(stormWarningComp, "Peak", "Wind(kt)", false); + /* * HFWW (Hurricane Force Wind Warning) */ - Composite hfwwComp = createGroupComposite(lblComp, 3, "HFWW"); + Composite hfwwComp = createGroupComposite(lblComp, 3, "HFWW"); createLabelComp(hfwwComp, "Wind", "Speed(kt)", false); createLabelComp(hfwwComp, "Gust", "Speed(kt)", false); - createLabelComp(hfwwComp, "Peak", "Wind(kt)", false); - } - + createLabelComp(hfwwComp, "Peak", "Wind(kt)", false); + } + @Override - protected void populateList() - { - if (ssDataArray == null) - { + protected void populateList() { + if (ssDataArray == null) { createDataArray(); } - + boolean update = false; - if (dataList.getItemCount() > 0) - { + if (dataList.getItemCount() > 0) { update = true; } - + areaIDArray = new ArrayList(); - + String currentAreaID; - - StringBuilder sb = null; + + StringBuilder sb = null; SSDisplayProductData ssdpd = null; - - for (int i = 0; i < ssDataArray.size(); i++) - { + + for (int i = 0; i < ssDataArray.size(); i++) { sb = new StringBuilder(); - + ssdpd = ssDataArray.get(i); - + currentAreaID = ssdpd.getAreaID(); areaIDArray.add(currentAreaID); - + sb.append(String.format(areaIdFmt, currentAreaID)); - + /* * Small Craft Advisory */ - appendIntData(sb, ssdpd.getScaWindSpeedR(), ssdpd.getScaWindSpeedY()); - appendIntData(sb, ssdpd.getScaGustSpeedR(), ssdpd.getScaGustSpeedY()); + appendIntData(sb, ssdpd.getScaWindSpeedR(), + ssdpd.getScaWindSpeedY()); + appendIntData(sb, ssdpd.getScaGustSpeedR(), + ssdpd.getScaGustSpeedY()); appendIntData(sb, ssdpd.getScaPeakWindR(), ssdpd.getScaPeakWindY()); appendIntData(sb, ssdpd.getScaWaveHgtR(), ssdpd.getScaWaveHgtY()); - + /* * Gale Warning */ - appendIntData(sb, ssdpd.getGaleWindSpeedR(), ssdpd.getGaleWindSpeedY()); - appendIntData(sb, ssdpd.getGaleGustSpeedR(), ssdpd.getGaleGustSpeedY()); - appendIntData(sb, ssdpd.getGalePeakWindR(), ssdpd.getGalePeakWindY()); - + appendIntData(sb, ssdpd.getGaleWindSpeedR(), + ssdpd.getGaleWindSpeedY()); + appendIntData(sb, ssdpd.getGaleGustSpeedR(), + ssdpd.getGaleGustSpeedY()); + appendIntData(sb, ssdpd.getGalePeakWindR(), + ssdpd.getGalePeakWindY()); + /* * Storm Warning */ - appendIntData(sb, ssdpd.getStormWrnWindSpeedR(), ssdpd.getStormWrnWindSpeedY()); - appendIntData(sb, ssdpd.getStormWrnGustSpeedR(), ssdpd.getStormWrnGustSpeedY()); - appendIntData(sb, ssdpd.getStormWrnPeakWindR(), ssdpd.getStormWrnPeakWindY()); - + appendIntData(sb, ssdpd.getStormWrnWindSpeedR(), + ssdpd.getStormWrnWindSpeedY()); + appendIntData(sb, ssdpd.getStormWrnGustSpeedR(), + ssdpd.getStormWrnGustSpeedY()); + appendIntData(sb, ssdpd.getStormWrnPeakWindR(), + ssdpd.getStormWrnPeakWindY()); + /* * HFWW */ - appendIntData(sb, ssdpd.getHfwwWindSpeedR(), ssdpd.getHfwwWindSpeedY()); - appendIntData(sb, ssdpd.getHfwwGustSpeedR(), ssdpd.getHfwwGustSpeedY()); - appendIntData(sb, ssdpd.getHfwwPeakWindR(), ssdpd.getHfwwPeakWindY()); - + appendIntData(sb, ssdpd.getHfwwWindSpeedR(), + ssdpd.getHfwwWindSpeedY()); + appendIntData(sb, ssdpd.getHfwwGustSpeedR(), + ssdpd.getHfwwGustSpeedY()); + appendIntData(sb, ssdpd.getHfwwPeakWindR(), + ssdpd.getHfwwPeakWindY()); + /* * Append a space and add the data line to the list. */ sb.append(" "); - - if (update == true) - { + + if (update == true) { dataList.setItem(i, sb.toString()); - } - else - { + } else { dataList.add(sb.toString()); - } + } } - + packListControls(); } - - private void createDataArray() - { + + private void createDataArray() { ssDataArray = new ArrayList(); - - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - + + SSThresholdMgr sstm = SSThresholdMgr.getInstance(); + String xmlKey; - String areaID; - + String areaID; + ThresholdsXML threshXML = sstm.getThresholdsXmlData(duKey); - + ArrayList areasArray = threshXML.getAreas(); - - for (AreaXML area : areasArray) - { + + for (AreaXML area : areasArray) { areaID = area.getAreaId(); SSDisplayProductData ssdpd = new SSDisplayProductData(); - + ssdpd.setAreaID(areaID); /* * Small Craft Advisory */ xmlKey = SafeSeasDisplay.SS_DISP_PROD_SCA_WIND_SPEED.getXmlKey(); - ssdpd.setScaWindSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdpd.setScaWindSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdpd.setScaWindSpeedR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdpd.setScaWindSpeedY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_SCA_GUST_SPEED.getXmlKey(); - ssdpd.setScaGustSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdpd.setScaGustSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdpd.setScaGustSpeedR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdpd.setScaGustSpeedY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_SCA_PEAK_WIND.getXmlKey(); - ssdpd.setScaPeakWindR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdpd.setScaPeakWindY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdpd.setScaPeakWindR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdpd.setScaPeakWindY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_SCA_WAVE_HT.getXmlKey(); - ssdpd.setScaWaveHgtR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdpd.setScaWaveHgtY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdpd.setScaWaveHgtR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdpd.setScaWaveHgtY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Gale Warning */ xmlKey = SafeSeasDisplay.SS_DISP_PROD_GALE_WIND_SPEED.getXmlKey(); - ssdpd.setGaleWindSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdpd.setGaleWindSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdpd.setGaleWindSpeedR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdpd.setGaleWindSpeedY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_GALE_GUST_SPEED.getXmlKey(); - ssdpd.setGaleGustSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdpd.setGaleGustSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdpd.setGaleGustSpeedR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdpd.setGaleGustSpeedY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_GALE_PEAK_WIND.getXmlKey(); - ssdpd.setGalePeakWindR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdpd.setGalePeakWindY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdpd.setGalePeakWindR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdpd.setGalePeakWindY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Storm Warning */ xmlKey = SafeSeasDisplay.SS_DISP_PROD_STORM_WIND_SPEED.getXmlKey(); - ssdpd.setStormWrnWindSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdpd.setStormWrnWindSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdpd.setStormWrnWindSpeedR(sstm.getThresholdValue(duKey, + threshKeyR, areaID, xmlKey)); + ssdpd.setStormWrnWindSpeedY(sstm.getThresholdValue(duKey, + threshKeyY, areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_STORM_GUST_SPEED.getXmlKey(); - ssdpd.setStormWrnGustSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdpd.setStormWrnGustSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdpd.setStormWrnGustSpeedR(sstm.getThresholdValue(duKey, + threshKeyR, areaID, xmlKey)); + ssdpd.setStormWrnGustSpeedY(sstm.getThresholdValue(duKey, + threshKeyY, areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_STORM_PEAK_WIND.getXmlKey(); - ssdpd.setStormWrnPeakWindR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdpd.setStormWrnPeakWindY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdpd.setStormWrnPeakWindR(sstm.getThresholdValue(duKey, + threshKeyR, areaID, xmlKey)); + ssdpd.setStormWrnPeakWindY(sstm.getThresholdValue(duKey, + threshKeyY, areaID, xmlKey)); + /* * HFWW */ xmlKey = SafeSeasDisplay.SS_DISP_PROD_HFWW_WIND_SPEED.getXmlKey(); - ssdpd.setHfwwWindSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdpd.setHfwwWindSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdpd.setHfwwWindSpeedR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdpd.setHfwwWindSpeedY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_HFWW_GUST_SPEED.getXmlKey(); - ssdpd.setHfwwGustSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdpd.setHfwwGustSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdpd.setHfwwGustSpeedR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdpd.setHfwwGustSpeedY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_HFWW_PEAK_WIND.getXmlKey(); - ssdpd.setHfwwPeakWindR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdpd.setHfwwPeakWindY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdpd.setHfwwPeakWindR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdpd.setHfwwPeakWindY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Add data to the array. */ ssDataArray.add(ssdpd); } } - - private SSDisplayProductData getDataAtFirstSelection() - { + + private SSDisplayProductData getDataAtFirstSelection() { int index = dataList.getSelectionIndex(); - - return ssDataArray.get(index); + + return ssDataArray.get(index); } - - private void updateDataArray(SSDisplayProductData ssdpd) - { - int[] dataListIndexes = dataList.getSelectionIndices(); + + private void updateDataArray(SSDisplayProductData ssdpd) { + int[] dataListIndexes = dataList.getSelectionIndices(); int currentIndex = 0; - - for (int i = 0; i < dataListIndexes.length; i++) - { + + for (int i = 0; i < dataListIndexes.length; i++) { currentIndex = dataListIndexes[i]; - + ssDataArray.get(currentIndex).updateData(ssdpd); - } - } - + } + } + @Override - public void commitDataToXML() - { + public void commitDataToXML() { SSThresholdMgr stm = SSThresholdMgr.getInstance(); - + String xmlKey; String areaID; - - for (SSDisplayProductData ssdpd : ssDataArray) - { + + for (SSDisplayProductData ssdpd : ssDataArray) { areaID = ssdpd.getAreaID(); - + /* * Small Craft Advisory */ xmlKey = SafeSeasDisplay.SS_DISP_PROD_SCA_WIND_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdpd.getScaWindSpeedR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdpd.getScaWindSpeedY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdpd.getScaWindSpeedR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdpd.getScaWindSpeedY()); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_SCA_GUST_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdpd.getScaGustSpeedR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdpd.getScaGustSpeedY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdpd.getScaGustSpeedR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdpd.getScaGustSpeedY()); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_SCA_PEAK_WIND.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdpd.getScaPeakWindR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdpd.getScaPeakWindY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdpd.getScaPeakWindR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdpd.getScaPeakWindY()); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_SCA_WAVE_HT.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdpd.getScaWaveHgtR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdpd.getScaWaveHgtY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdpd.getScaWaveHgtR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdpd.getScaWaveHgtY()); + /* * Gale Warning */ xmlKey = SafeSeasDisplay.SS_DISP_PROD_GALE_WIND_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdpd.getGaleWindSpeedR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdpd.getGaleWindSpeedY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdpd.getGaleWindSpeedR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdpd.getGaleWindSpeedY()); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_GALE_GUST_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdpd.getGaleGustSpeedR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdpd.getGaleGustSpeedY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdpd.getGaleGustSpeedR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdpd.getGaleGustSpeedY()); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_GALE_PEAK_WIND.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdpd.getGalePeakWindR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdpd.getGalePeakWindY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdpd.getGalePeakWindR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdpd.getGalePeakWindY()); + /* * Storm Warning */ xmlKey = SafeSeasDisplay.SS_DISP_PROD_STORM_WIND_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdpd.getStormWrnWindSpeedR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdpd.getStormWrnWindSpeedY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdpd.getStormWrnWindSpeedR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdpd.getStormWrnWindSpeedY()); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_STORM_GUST_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdpd.getStormWrnGustSpeedR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdpd.getStormWrnGustSpeedY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdpd.getStormWrnGustSpeedR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdpd.getStormWrnGustSpeedY()); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_STORM_PEAK_WIND.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdpd.getStormWrnPeakWindR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdpd.getStormWrnPeakWindY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdpd.getStormWrnPeakWindR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdpd.getStormWrnPeakWindY()); + /* * HFWW */ xmlKey = SafeSeasDisplay.SS_DISP_PROD_HFWW_WIND_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdpd.getHfwwWindSpeedR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdpd.getHfwwWindSpeedY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdpd.getHfwwWindSpeedR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdpd.getHfwwWindSpeedY()); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_HFWW_GUST_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdpd.getHfwwGustSpeedR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdpd.getHfwwGustSpeedY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdpd.getHfwwGustSpeedR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdpd.getHfwwGustSpeedY()); + xmlKey = SafeSeasDisplay.SS_DISP_PROD_HFWW_PEAK_WIND.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdpd.getHfwwPeakWindR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdpd.getHfwwPeakWindY()); - } - } - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdpd.getHfwwPeakWindR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdpd.getHfwwPeakWindY()); + } + } + @Override - public void reloadData() - { + public void reloadData() { dataList.removeAll(); ssDataArray.clear(); ssDataArray = null; - + populateList(); } @Override - protected void editDataAction() - { + protected void editDataAction() { SSDisplayProductData sspdp = getDataAtFirstSelection(); - - if (productEditDlg == null) - { - productEditDlg = new SSDisplayProductEditDlg(getParent().getShell(), sspdp, this); + + if (productEditDlg == null) { + productEditDlg = new SSDisplayProductEditDlg( + getParent().getShell(), sspdp, this); productEditDlg.open(); productEditDlg = null; } } @Override - public void updateThresholdData(SSDisplayProductData sspdp) - { + public void updateThresholdData(SSDisplayProductData sspdp) { updateDataArray(sspdp); populateList(); } - } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplaySwellTab.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplaySwellTab.java old mode 100644 new mode 100755 index 6cabc17e8f..80893d8237 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplaySwellTab.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplaySwellTab.java @@ -28,313 +28,357 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SafeSeasDisplay; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; import com.raytheon.uf.viz.monitor.safeseas.threshold.SSDispMonSwellData; import com.raytheon.uf.viz.monitor.safeseas.threshold.SSThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasDisplay; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; -public class SSDisplaySwellTab extends TabItemComp implements IUpdateDisplayMonitorSwell -{ +/** + * SAFESEAS Display Swell Table. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 26, 2015 5115       skorolev    Corrected imports.
+ * 
+ * 
+ * + * @author skorolev + * @version 1.0 + */ +public class SSDisplaySwellTab extends TabItemComp implements + IUpdateDisplayMonitorSwell { private SSDispMonSwellEditDlg displaySwellEditDlg; - + private ArrayList areaIDArray; - + private ArrayList ssDataArray; - - public SSDisplaySwellTab(TabFolder parent, DataUsageKey duKey) - { + + public SSDisplaySwellTab(TabFolder parent, DataUsageKey duKey) { super(parent, duKey, true); } - @Override - protected void createListHeader(Composite parentComp) - { + @Override + protected void createListHeader(Composite parentComp) { Composite lblComp = new Composite(parentComp, SWT.NONE); GridLayout gl = new GridLayout(5, false); - gl.horizontalSpacing = 0; + gl.horizontalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; lblComp.setLayout(gl); - + /* * Create filler label. */ GridData gd = new GridData(75, SWT.DEFAULT); Label fillerLbl = new Label(lblComp, SWT.CENTER); fillerLbl.setLayoutData(gd); - + /* * Primary Swell */ - Composite priSwellComp = createGroupComposite(lblComp, 4, "Primary Swell"); + Composite priSwellComp = createGroupComposite(lblComp, 4, + "Primary Swell"); createLabelComp(priSwellComp, "Height(ft)", "", false); createLabelComp(priSwellComp, "Periods(s)", "", false); createLabelComp(priSwellComp, "Dir(deg)", "(from)", false); - createLabelComp(priSwellComp, "Dir(deg)", "(to)", false); - + createLabelComp(priSwellComp, "Dir(deg)", "(to)", false); + /* * Secondary Swell */ - Composite secSwellComp = createGroupComposite(lblComp, 4, "Secondary Swell"); + Composite secSwellComp = createGroupComposite(lblComp, 4, + "Secondary Swell"); createLabelComp(secSwellComp, "Height(ft)", "", false); createLabelComp(secSwellComp, "Periods(s)", "", false); createLabelComp(secSwellComp, "Dir(deg)", "(from)", false); createLabelComp(secSwellComp, "Dir(deg)", "(to)", false); - } - + } + @Override - protected void populateList() - { - if (ssDataArray == null) - { + protected void populateList() { + if (ssDataArray == null) { createDataArray(); } - + boolean update = false; - if (dataList.getItemCount() > 0) - { + if (dataList.getItemCount() > 0) { update = true; } - + areaIDArray = new ArrayList(); - + String currentAreaID; - - StringBuilder sb = null; + + StringBuilder sb = null; SSDispMonSwellData sssd = null; - - for (int i = 0; i < ssDataArray.size(); i++) - { + + for (int i = 0; i < ssDataArray.size(); i++) { sb = new StringBuilder(); - + sssd = ssDataArray.get(i); - + currentAreaID = sssd.getAreaID(); areaIDArray.add(currentAreaID); - - sb.append(String.format(areaIdFmt, currentAreaID)); - + + sb.append(String.format(areaIdFmt, currentAreaID)); + /* * Primary Swell */ - appendIntData(sb, sssd.getPriSwellHeightR(), sssd.getPriSwellHeightY()); - - double higherThreshold = Math.max(sssd.getPriSwellPeriodR(), sssd.getPriSwellPeriodY()); - double lowerThreshold = Math.min(sssd.getPriSwellPeriodR(), sssd.getPriSwellPeriodY()); - if ( rankSwellPeriodHigh ) { - sssd.setRankSwellPeriodHigh(true); - sssd.setPriSwellPeriodR(higherThreshold); - sssd.setPriSwellPeriodY(lowerThreshold); + appendIntData(sb, sssd.getPriSwellHeightR(), + sssd.getPriSwellHeightY()); + + double higherThreshold = Math.max(sssd.getPriSwellPeriodR(), + sssd.getPriSwellPeriodY()); + double lowerThreshold = Math.min(sssd.getPriSwellPeriodR(), + sssd.getPriSwellPeriodY()); + if (rankSwellPeriodHigh) { + sssd.setRankSwellPeriodHigh(true); + sssd.setPriSwellPeriodR(higherThreshold); + sssd.setPriSwellPeriodY(lowerThreshold); } else { - sssd.setRankSwellPeriodHigh(false); - sssd.setPriSwellPeriodR(lowerThreshold); - sssd.setPriSwellPeriodY(higherThreshold); + sssd.setRankSwellPeriodHigh(false); + sssd.setPriSwellPeriodR(lowerThreshold); + sssd.setPriSwellPeriodY(higherThreshold); } - appendIntData(sb, sssd.getPriSwellPeriodR(), sssd.getPriSwellPeriodY()); - - appendIntData(sb, sssd.getPriSwellDirFromY(), sssd.getPriSwellDirFromR()); - appendIntData(sb, sssd.getPriSwellDirToR(), sssd.getPriSwellDirToY()); - + appendIntData(sb, sssd.getPriSwellPeriodR(), + sssd.getPriSwellPeriodY()); + + appendIntData(sb, sssd.getPriSwellDirFromY(), + sssd.getPriSwellDirFromR()); + appendIntData(sb, sssd.getPriSwellDirToR(), + sssd.getPriSwellDirToY()); + /* * Secondary Swell */ - appendIntData(sb, sssd.getSecSwellHeightR(), sssd.getSecSwellHeightY()); - - higherThreshold = Math.max(sssd.getSecSwellPeriodR(), sssd.getSecSwellPeriodY()); - lowerThreshold = Math.min(sssd.getSecSwellPeriodR(), sssd.getSecSwellPeriodY()); - if ( rankSwellPeriodHigh ) { - //sssd.setRankSwellPeriodHigh(true); - sssd.setSecSwellPeriodR(higherThreshold); - sssd.setSecSwellPeriodY(lowerThreshold); + appendIntData(sb, sssd.getSecSwellHeightR(), + sssd.getSecSwellHeightY()); + + higherThreshold = Math.max(sssd.getSecSwellPeriodR(), + sssd.getSecSwellPeriodY()); + lowerThreshold = Math.min(sssd.getSecSwellPeriodR(), + sssd.getSecSwellPeriodY()); + if (rankSwellPeriodHigh) { + // sssd.setRankSwellPeriodHigh(true); + sssd.setSecSwellPeriodR(higherThreshold); + sssd.setSecSwellPeriodY(lowerThreshold); } else { - //sssd.setRankSwellPeriodHigh(false); - sssd.setSecSwellPeriodR(lowerThreshold); - sssd.setSecSwellPeriodY(higherThreshold); + // sssd.setRankSwellPeriodHigh(false); + sssd.setSecSwellPeriodR(lowerThreshold); + sssd.setSecSwellPeriodY(higherThreshold); } - appendIntData(sb, sssd.getSecSwellPeriodR(), sssd.getSecSwellPeriodY()); - appendIntData(sb, sssd.getSecSwellDirFromY(), sssd.getSecSwellDirFromR()); - appendIntData(sb, sssd.getSecSwellDirToR(), sssd.getSecSwellDirToY()); - + appendIntData(sb, sssd.getSecSwellPeriodR(), + sssd.getSecSwellPeriodY()); + appendIntData(sb, sssd.getSecSwellDirFromY(), + sssd.getSecSwellDirFromR()); + appendIntData(sb, sssd.getSecSwellDirToR(), + sssd.getSecSwellDirToY()); + /* * Append a space and add the data line to the list. */ sb.append(" "); - - if (update == true) - { + + if (update == true) { dataList.setItem(i, sb.toString()); - } - else - { + } else { dataList.add(sb.toString()); - } + } } - + packListControls(); } - - private void createDataArray() - { + + private void createDataArray() { ssDataArray = new ArrayList(); - - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - + + SSThresholdMgr sstm = SSThresholdMgr.getInstance(); + String xmlKey; - String areaID; - + String areaID; + ThresholdsXML threshXML = sstm.getThresholdsXmlData(duKey); - + ArrayList areasArray = threshXML.getAreas(); - - for (AreaXML area : areasArray) - { + + for (AreaXML area : areasArray) { areaID = area.getAreaId(); SSDispMonSwellData sssd = new SSDispMonSwellData(); - + sssd.setAreaID(areaID); /* * Primary Swell */ xmlKey = SafeSeasDisplay.SS_DISP_SWELL_PRIM_HT.getXmlKey(); - sssd.setPriSwellHeightR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setPriSwellHeightY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setPriSwellHeightR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setPriSwellHeightY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_SWELL_PRIM_PD.getXmlKey(); - sssd.setPriSwellPeriodR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setPriSwellPeriodY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setPriSwellPeriodR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setPriSwellPeriodY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_FROM.getXmlKey(); - sssd.setPriSwellDirFromR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setPriSwellDirFromY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setPriSwellDirFromR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setPriSwellDirFromY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_TO.getXmlKey(); - sssd.setPriSwellDirToR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setPriSwellDirToY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setPriSwellDirToR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setPriSwellDirToY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Secondary Swell */ xmlKey = SafeSeasDisplay.SS_DISP_SWELL_SEC_HT.getXmlKey(); - sssd.setSecSwellHeightR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setSecSwellHeightY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setSecSwellHeightR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setSecSwellHeightY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_SWELL_SEC_PD.getXmlKey(); - sssd.setSecSwellPeriodR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setSecSwellPeriodY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setSecSwellPeriodR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setSecSwellPeriodY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_FROM.getXmlKey(); - sssd.setSecSwellDirFromR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setSecSwellDirFromY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setSecSwellDirFromR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setSecSwellDirFromY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_TO.getXmlKey(); - sssd.setSecSwellDirToR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setSecSwellDirToY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setSecSwellDirToR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setSecSwellDirToY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Add data to array. */ ssDataArray.add(sssd); } } - - private SSDispMonSwellData getDataAtFirstSelection() - { + + private SSDispMonSwellData getDataAtFirstSelection() { int index = dataList.getSelectionIndex(); - - return ssDataArray.get(index); - } - - private void updateDataArray(SSDispMonSwellData sssd) - { - int[] dataListIndexes = dataList.getSelectionIndices(); - int currentIndex = 0; - - for (int i = 0; i < dataListIndexes.length; i++) - { - currentIndex = dataListIndexes[i]; - - ssDataArray.get(currentIndex).updateData(sssd); - } + + return ssDataArray.get(index); } - + + private void updateDataArray(SSDispMonSwellData sssd) { + int[] dataListIndexes = dataList.getSelectionIndices(); + int currentIndex = 0; + + for (int i = 0; i < dataListIndexes.length; i++) { + currentIndex = dataListIndexes[i]; + + ssDataArray.get(currentIndex).updateData(sssd); + } + } + @Override - public void commitDataToXML() - { + public void commitDataToXML() { SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - + String xmlKey; String areaID; - - for (SSDispMonSwellData sssd : ssDataArray) - { - - MonitorConfigConstants.setRankSwellPeriodHigh(rankSwellPeriodHigh); - + + for (SSDispMonSwellData sssd : ssDataArray) { + + MonitorConfigConstants.setRankSwellPeriodHigh(rankSwellPeriodHigh); + areaID = sssd.getAreaID(); - + /* * Primary Swell */ xmlKey = SafeSeasDisplay.SS_DISP_SWELL_PRIM_HT.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getPriSwellHeightR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getPriSwellHeightY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getPriSwellHeightR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getPriSwellHeightY()); + xmlKey = SafeSeasDisplay.SS_DISP_SWELL_PRIM_PD.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getPriSwellPeriodR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getPriSwellPeriodY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getPriSwellPeriodR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getPriSwellPeriodY()); + xmlKey = SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_FROM.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getPriSwellDirFromR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getPriSwellDirFromY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getPriSwellDirFromR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getPriSwellDirFromY()); + xmlKey = SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_TO.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getPriSwellDirToR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getPriSwellDirToY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getPriSwellDirToR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getPriSwellDirToY()); + /* * Secondary Swell */ xmlKey = SafeSeasDisplay.SS_DISP_SWELL_SEC_HT.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getSecSwellHeightR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getSecSwellHeightY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getSecSwellHeightR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getSecSwellHeightY()); + xmlKey = SafeSeasDisplay.SS_DISP_SWELL_SEC_PD.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getSecSwellPeriodR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getSecSwellPeriodY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getSecSwellPeriodR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getSecSwellPeriodY()); + xmlKey = SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_FROM.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getSecSwellDirFromR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getSecSwellDirFromY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getSecSwellDirFromR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getSecSwellDirFromY()); + xmlKey = SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_TO.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getSecSwellDirToR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getSecSwellDirToY()); - } + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getSecSwellDirToR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getSecSwellDirToY()); + } } @Override - public void reloadData() - { + public void reloadData() { dataList.removeAll(); ssDataArray.clear(); ssDataArray = null; - - populateList(); + + populateList(); } @Override - protected void editDataAction() - { + protected void editDataAction() { SSDispMonSwellData sssd = getDataAtFirstSelection(); - - if (displaySwellEditDlg == null) - { - displaySwellEditDlg = new SSDispMonSwellEditDlg(getParent().getShell(), sssd, this, true); + + if (displaySwellEditDlg == null) { + displaySwellEditDlg = new SSDispMonSwellEditDlg(getParent() + .getShell(), sssd, this, true); displaySwellEditDlg.open(); displaySwellEditDlg = null; } @@ -342,10 +386,9 @@ public class SSDisplaySwellTab extends TabItemComp implements IUpdateDisplayMoni } @Override - public void updateThresholdData(SSDispMonSwellData sssd) - { + public void updateThresholdData(SSDispMonSwellData sssd) { updateDataArray(sssd); populateList(); - + } } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplayWindTab.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplayWindTab.java old mode 100644 new mode 100755 index 6163da4e06..0033818e9a --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplayWindTab.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSDisplayWindTab.java @@ -28,287 +28,303 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SafeSeasDisplay; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; import com.raytheon.uf.viz.monitor.safeseas.threshold.SSDisplayWindData; import com.raytheon.uf.viz.monitor.safeseas.threshold.SSThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasDisplay; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; -public class SSDisplayWindTab extends TabItemComp implements IUpdateDisplayWind -{ +/** + * SAFESEAS Display Wind Table. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 26, 2015 5115       skorolev    Corrected imports.
+ * 
+ * 
+ * + * @author skorolev + * @version 1.0 + */ +public class SSDisplayWindTab extends TabItemComp implements IUpdateDisplayWind { private SSDisplayWindEditDlg windEditDlg; - + private ArrayList areaIDArray; - + private ArrayList ssDataArray; - - public SSDisplayWindTab(TabFolder parent, DataUsageKey duKey) - { + + public SSDisplayWindTab(TabFolder parent, DataUsageKey duKey) { super(parent, duKey); } - @Override - protected void createListHeader(Composite parentComp) - { + @Override + protected void createListHeader(Composite parentComp) { Composite lblComp = new Composite(parentComp, SWT.NONE); GridLayout gl = new GridLayout(5, false); - gl.horizontalSpacing = 0; + gl.horizontalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; lblComp.setLayout(gl); - + /* * Create filler label. */ GridData gd = new GridData(73, SWT.DEFAULT); Label fillerLbl = new Label(lblComp, SWT.CENTER); fillerLbl.setLayoutData(gd); - + /* * Wind */ Composite windComp = createGroupComposite(lblComp, 5, null); - createLabelComp(windComp, "Wind", "Speed(kt)", false); - createLabelComp(windComp, "Peak", "Wind(kt)", false); + createLabelComp(windComp, "Wind", "Speed(kt)", false); + createLabelComp(windComp, "Peak", "Wind(kt)", false); createLabelComp(windComp, "Gust", "Speed(kt)", false); createLabelComp(windComp, "Wind", "Dir(deg)\n(from)", false); createLabelComp(windComp, "Wind", "Dir(deg)\n(to)", false); - } - + } + @Override - protected void populateList() - { - if (ssDataArray == null) - { + protected void populateList() { + if (ssDataArray == null) { createDataArray(); } - + boolean update = false; - if (dataList.getItemCount() > 0) - { + if (dataList.getItemCount() > 0) { update = true; } - + areaIDArray = new ArrayList(); - + String currentAreaID; - - StringBuilder sb = null; + + StringBuilder sb = null; SSDisplayWindData ssdwd = null; - - for (int i = 0; i < ssDataArray.size(); i++) - { + + for (int i = 0; i < ssDataArray.size(); i++) { sb = new StringBuilder(); - + ssdwd = ssDataArray.get(i); - + currentAreaID = ssdwd.getAreaID(); areaIDArray.add(currentAreaID); - + sb.append(String.format(areaIdFmt, currentAreaID)); - + /* * Wind Speed */ appendIntData(sb, ssdwd.getWindSpeedR(), ssdwd.getWindSpeedY()); - + /* * Peak Wind */ appendIntData(sb, ssdwd.getPeakWindR(), ssdwd.getPeakWindY()); - + /* * Gust Speed */ appendIntData(sb, ssdwd.getGustSpeedR(), ssdwd.getGustSpeedY()); - + /* * Wind Direction From */ - appendIntData(sb, ssdwd.getWindDirFromY(),ssdwd.getWindDirFromR()); - + appendIntData(sb, ssdwd.getWindDirFromY(), ssdwd.getWindDirFromR()); + /* * Wind Direction To */ appendIntData(sb, ssdwd.getWindDirToR(), ssdwd.getWindDirToY()); - + /* * Append a space and add the data line to the list. */ - if (update == true) - { + if (update == true) { dataList.setItem(i, sb.toString()); - } - else - { + } else { dataList.add(sb.toString()); - } + } } - + packListControls(); } - - private void createDataArray() - { + + private void createDataArray() { ssDataArray = new ArrayList(); - - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - + + SSThresholdMgr sstm = SSThresholdMgr.getInstance(); + String xmlKey; - String areaID; - + String areaID; + ThresholdsXML threshXML = sstm.getThresholdsXmlData(duKey); - + ArrayList areasArray = threshXML.getAreas(); - - for (AreaXML area : areasArray) - { + + for (AreaXML area : areasArray) { areaID = area.getAreaId(); SSDisplayWindData ssdwd = new SSDisplayWindData(); - + ssdwd.setAreaID(areaID); - + /* * Wind Speed */ xmlKey = SafeSeasDisplay.SS_DISP_WIND_WIND_SPEED.getXmlKey(); - ssdwd.setWindSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdwd.setWindSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdwd.setWindSpeedR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdwd.setWindSpeedY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Peak Wind */ xmlKey = SafeSeasDisplay.SS_DISP_WIND_PEAK_WIND.getXmlKey(); - ssdwd.setPeakWindR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdwd.setPeakWindY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdwd.setPeakWindR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdwd.setPeakWindY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Gust Speed */ xmlKey = SafeSeasDisplay.SS_DISP_WIND_GUST_SPEED.getXmlKey(); - ssdwd.setGustSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdwd.setGustSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdwd.setGustSpeedR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdwd.setGustSpeedY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Wind Direction From */ xmlKey = SafeSeasDisplay.SS_DISP_WIND_DIR_FROM.getXmlKey(); - ssdwd.setWindDirFromR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdwd.setWindDirFromY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdwd.setWindDirFromR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdwd.setWindDirFromY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Wind Direction To */ xmlKey = SafeSeasDisplay.SS_DISP_WIND_DIR_TO.getXmlKey(); - ssdwd.setWindDirToR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssdwd.setWindDirToY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssdwd.setWindDirToR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssdwd.setWindDirToY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Add data to array. */ ssDataArray.add(ssdwd); } } - - private SSDisplayWindData getDataAtFirstSelection() - { - + + private SSDisplayWindData getDataAtFirstSelection() { + int index = dataList.getSelectionIndex(); - + return ssDataArray.get(index); - + } - - private void updateDataArray(SSDisplayWindData ssdwd) - { - int[] dataListIndexes = dataList.getSelectionIndices(); + + private void updateDataArray(SSDisplayWindData ssdwd) { + int[] dataListIndexes = dataList.getSelectionIndices(); int currentIndex = 0; - - for (int i = 0; i < dataListIndexes.length; i++) - { + + for (int i = 0; i < dataListIndexes.length; i++) { currentIndex = dataListIndexes[i]; - + ssDataArray.get(currentIndex).updateData(ssdwd); - } + } } - + @Override - public void commitDataToXML() - { + public void commitDataToXML() { SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - + String xmlKey; String areaID; - - for (SSDisplayWindData ssdwd : ssDataArray) - { + + for (SSDisplayWindData ssdwd : ssDataArray) { areaID = ssdwd.getAreaID(); - + /* * Wind Speed */ xmlKey = SafeSeasDisplay.SS_DISP_WIND_WIND_SPEED.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdwd.getWindSpeedR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdwd.getWindSpeedY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdwd.getWindSpeedR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdwd.getWindSpeedY()); + /* * Peak Wind */ xmlKey = SafeSeasDisplay.SS_DISP_WIND_PEAK_WIND.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdwd.getPeakWindR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdwd.getPeakWindY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdwd.getPeakWindR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdwd.getPeakWindY()); + /* * Gust Speed */ xmlKey = SafeSeasDisplay.SS_DISP_WIND_GUST_SPEED.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdwd.getGustSpeedR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdwd.getGustSpeedY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdwd.getGustSpeedR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdwd.getGustSpeedY()); + /* * Wind Direction From */ xmlKey = SafeSeasDisplay.SS_DISP_WIND_DIR_FROM.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdwd.getWindDirFromR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdwd.getWindDirFromY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdwd.getWindDirFromR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdwd.getWindDirFromY()); + /* * Wind Direction To */ xmlKey = SafeSeasDisplay.SS_DISP_WIND_DIR_TO.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssdwd.getWindDirToR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssdwd.getWindDirToY()); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssdwd.getWindDirToR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssdwd.getWindDirToY()); } } @Override - public void reloadData() - { + public void reloadData() { dataList.removeAll(); ssDataArray.clear(); ssDataArray = null; - + populateList(); } @Override - protected void editDataAction() - { + protected void editDataAction() { SSDisplayWindData ssdwd = getDataAtFirstSelection(); - - if (windEditDlg == null) - { - windEditDlg = new SSDisplayWindEditDlg(getParent().getShell(), ssdwd, this); + + if (windEditDlg == null) { + windEditDlg = new SSDisplayWindEditDlg(getParent().getShell(), + ssdwd, this); windEditDlg.open(); windEditDlg = null; } - } + } @Override - public void updateThresholdData(SSDisplayWindData ssdwd) - { + public void updateThresholdData(SSDisplayWindData ssdwd) { updateDataArray(ssdwd); populateList(); } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorMeteoTab.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorMeteoTab.java old mode 100644 new mode 100755 index d8ceb7207c..b459bd2796 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorMeteoTab.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorMeteoTab.java @@ -28,318 +28,318 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SafeSeasMonitor; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; import com.raytheon.uf.viz.monitor.data.RangesUtil; import com.raytheon.uf.viz.monitor.safeseas.threshold.SSMonitorMeteoData; import com.raytheon.uf.viz.monitor.safeseas.threshold.SSThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasMonitor; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; /** * SAFESEAS Monitor Meteo Table. * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Sep 17, 2014 2757       skorolev    Removed unnecessary printouts.
- *
+ * Dec 26, 2015 5114       skorolev    Corrected imports and replaced AppName with MonName.
+ * 
  * 
- * + * * @author skorolev - * @version 1.0 + * @version 1.0 */ -public class SSMonitorMeteoTab extends TabItemComp implements IUpdateMonitorMeteo -{ +public class SSMonitorMeteoTab extends TabItemComp implements + IUpdateMonitorMeteo { private SSMonitorMeteoEditDlg monitorMeteoEditDlg; - + private ArrayList areaIDArray; - + private ArrayList ssDataArray; - - public SSMonitorMeteoTab(TabFolder parent, DataUsageKey duKey) - { + + public SSMonitorMeteoTab(TabFolder parent, DataUsageKey duKey) { super(parent, duKey); } - @Override - protected void createListHeader(Composite parentComp) - { + @Override + protected void createListHeader(Composite parentComp) { Composite lblComp = new Composite(parentComp, SWT.NONE); GridLayout gl = new GridLayout(5, false); - gl.horizontalSpacing = 0; + gl.horizontalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; lblComp.setLayout(gl); - + /* * Create filler label. */ GridData gd = new GridData(75, SWT.DEFAULT); Label fillerLbl = new Label(lblComp, SWT.CENTER); fillerLbl.setLayoutData(gd); - + /* * Meteo */ - Composite meteoComp = createGroupComposite(lblComp, 5, null); - createLabelComp(meteoComp, "Wind", "Speed(kt)", false); - createLabelComp(meteoComp, "Peak", "Wind(kt)", false); + Composite meteoComp = createGroupComposite(lblComp, 5, null); + createLabelComp(meteoComp, "Wind", "Speed(kt)", false); + createLabelComp(meteoComp, "Peak", "Wind(kt)", false); createLabelComp(meteoComp, "Gust", "Speed(kt)", false); createLabelComp(meteoComp, "Wave", "Height(ft)", false); createLabelComp(meteoComp, "Vis(mi)", "", true); - } - + } + @Override - protected void populateList() - { - if (ssDataArray == null) - { + protected void populateList() { + if (ssDataArray == null) { createDataArray(); } - + boolean update = false; - if (dataList.getItemCount() > 0) - { + if (dataList.getItemCount() > 0) { update = true; } - + RangesUtil rangeUtil = RangesUtil.getInstance(); - + areaIDArray = new ArrayList(); - + String tmpVisStr; String currentAreaID; - + double visVal = 0.0; - - StringBuilder sb = null; + + StringBuilder sb = null; SSMonitorMeteoData ssmmd = null; - - for (int i = 0; i < ssDataArray.size(); i++) - { + + for (int i = 0; i < ssDataArray.size(); i++) { sb = new StringBuilder(); - + ssmmd = ssDataArray.get(i); - + currentAreaID = ssmmd.getAreaID(); areaIDArray.add(currentAreaID); - + sb.append(String.format(areaIdFmt, currentAreaID)); - + /* * Wind Speed */ appendIntData(sb, ssmmd.getWindSpeedR(), ssmmd.getWindSpeedY()); - + /* * Peak Wind */ appendIntData(sb, ssmmd.getPeakWindR(), ssmmd.getPeakWindY()); - + /* * Gust Wind */ appendIntData(sb, ssmmd.getGustSpeedR(), ssmmd.getGustSpeedY()); - + /* * Wave Height */ appendIntData(sb, ssmmd.getWaveHgtR(), ssmmd.getWaveHgtY()); - + /* * Visibility - */ - visVal = ssmmd.getVisR(); - tmpVisStr = rangeUtil.getVisString((int)visVal); + */ + visVal = ssmmd.getVisR(); + tmpVisStr = rangeUtil.getVisString((int) visVal); sb.append(String.format(dataFmt, tmpVisStr)); - - visVal = ssmmd.getVisY(); - tmpVisStr = rangeUtil.getVisString((int)visVal); - sb.append(String.format(dataFmt, tmpVisStr)); - + + visVal = ssmmd.getVisY(); + tmpVisStr = rangeUtil.getVisString((int) visVal); + sb.append(String.format(dataFmt, tmpVisStr)); + /* * Append a space and add the data line to the list. */ sb.append(" "); - - if (update == true) - { + + if (update == true) { dataList.setItem(i, sb.toString()); - } - else - { + } else { dataList.add(sb.toString()); - } + } } - + packListControls(); } - - private void createDataArray() - { + + private void createDataArray() { ssDataArray = new ArrayList(); - - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - + + SSThresholdMgr sstm = SSThresholdMgr.getInstance(); + String xmlKey; - String areaID; - + String areaID; + ThresholdsXML threshXML = sstm.getThresholdsXmlData(duKey); - + ArrayList areasArray = threshXML.getAreas(); - - for (AreaXML area : areasArray) - { + + for (AreaXML area : areasArray) { areaID = area.getAreaId(); SSMonitorMeteoData ssmmd = new SSMonitorMeteoData(); - + ssmmd.setAreaID(areaID); - + /* * Wind Speed */ xmlKey = SafeSeasMonitor.SS_MON_METEO_WIND_SPEED.getXmlKey(); - ssmmd.setWindSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssmmd.setWindSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssmmd.setWindSpeedR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssmmd.setWindSpeedY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Peak Wind */ xmlKey = SafeSeasMonitor.SS_MON_METEO_PEAK_WIND.getXmlKey(); - ssmmd.setPeakWindR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssmmd.setPeakWindY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssmmd.setPeakWindR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssmmd.setPeakWindY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Gust Speed */ xmlKey = SafeSeasMonitor.SS_MON_METEO_GUST_SPEED.getXmlKey(); - ssmmd.setGustSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssmmd.setGustSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssmmd.setGustSpeedR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + ssmmd.setGustSpeedY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Wave Height */ xmlKey = SafeSeasMonitor.SS_MON_METEO_WAVE_HT.getXmlKey(); - ssmmd.setWaveHgtR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssmmd.setWaveHgtY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + ssmmd.setWaveHgtR(sstm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + ssmmd.setWaveHgtY(sstm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); /* * Visibility */ xmlKey = SafeSeasMonitor.SS_MON_METEO_VIS.getXmlKey(); - ssmmd.setVisR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - ssmmd.setVisY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + ssmmd.setVisR(sstm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + ssmmd.setVisY(sstm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); + /* * Add data to array. */ ssDataArray.add(ssmmd); } } - - private SSMonitorMeteoData getDataAtFirstSelection() - { + + private SSMonitorMeteoData getDataAtFirstSelection() { int index = dataList.getSelectionIndex(); - - return ssDataArray.get(index); + + return ssDataArray.get(index); } - - private void updateDataArray(SSMonitorMeteoData ssmmd) - { - int[] dataListIndexes = dataList.getSelectionIndices(); + + private void updateDataArray(SSMonitorMeteoData ssmmd) { + int[] dataListIndexes = dataList.getSelectionIndices(); int currentIndex = 0; - - for (int i = 0; i < dataListIndexes.length; i++) - { + + for (int i = 0; i < dataListIndexes.length; i++) { currentIndex = dataListIndexes[i]; - + ssDataArray.get(currentIndex).updateData(ssmmd); - } + } } - + @Override - public void commitDataToXML() - { + public void commitDataToXML() { SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - + String xmlKey; String areaID; - - for (SSMonitorMeteoData ssmmd : ssDataArray) - { + + for (SSMonitorMeteoData ssmmd : ssDataArray) { areaID = ssmmd.getAreaID(); - + /* * Wind Speed */ xmlKey = SafeSeasMonitor.SS_MON_METEO_WIND_SPEED.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssmmd.getWindSpeedR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssmmd.getWindSpeedY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssmmd.getWindSpeedR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssmmd.getWindSpeedY()); + /* * Peak Wind */ xmlKey = SafeSeasMonitor.SS_MON_METEO_PEAK_WIND.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssmmd.getPeakWindR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssmmd.getPeakWindY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssmmd.getPeakWindR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssmmd.getPeakWindY()); + /* * Gust Speed */ xmlKey = SafeSeasMonitor.SS_MON_METEO_GUST_SPEED.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssmmd.getGustSpeedR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssmmd.getGustSpeedY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssmmd.getGustSpeedR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssmmd.getGustSpeedY()); + /* * Wave Height */ xmlKey = SafeSeasMonitor.SS_MON_METEO_WAVE_HT.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssmmd.getWaveHgtR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssmmd.getWaveHgtY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssmmd.getWaveHgtR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssmmd.getWaveHgtY()); + /* * Visibility */ xmlKey = SafeSeasMonitor.SS_MON_METEO_VIS.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssmmd.getVisR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssmmd.getVisY()); - } + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + ssmmd.getVisR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + ssmmd.getVisY()); + } } @Override - public void reloadData() - { + public void reloadData() { dataList.removeAll(); ssDataArray.clear(); ssDataArray = null; - - populateList(); + + populateList(); } @Override - protected void editDataAction() - { + protected void editDataAction() { SSMonitorMeteoData ssmmd = getDataAtFirstSelection(); - - if (monitorMeteoEditDlg == null) - { - monitorMeteoEditDlg = new SSMonitorMeteoEditDlg(getParent().getShell(), ssmmd, this); + + if (monitorMeteoEditDlg == null) { + monitorMeteoEditDlg = new SSMonitorMeteoEditDlg(getParent() + .getShell(), ssmmd, this); monitorMeteoEditDlg.open(); monitorMeteoEditDlg = null; } } - - @Override - public void updateThresholdData(SSMonitorMeteoData ssmmd) - { + public void updateThresholdData(SSMonitorMeteoData ssmmd) { updateDataArray(ssmmd); - populateList(); + populateList(); } } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorSwellTab.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorSwellTab.java old mode 100644 new mode 100755 index a28cc5db93..18a4eb3b9c --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorSwellTab.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorSwellTab.java @@ -28,320 +28,362 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SafeSeasMonitor; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; import com.raytheon.uf.viz.monitor.safeseas.threshold.SSDispMonSwellData; import com.raytheon.uf.viz.monitor.safeseas.threshold.SSThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasMonitor; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; -public class SSMonitorSwellTab extends TabItemComp implements IUpdateDisplayMonitorSwell -{ +/** + * SAFESEAS Monitor Swell Table. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 26, 2015 5115       skorolev    Corrected imports.
+ * 
+ * 
+ * + * @author skorolev + * @version 1.0 + */ +public class SSMonitorSwellTab extends TabItemComp implements + IUpdateDisplayMonitorSwell { private SSDispMonSwellEditDlg monitorSwellEditDlg; - + private ArrayList areaIDArray; - + private ArrayList ssDataArray; - - public SSMonitorSwellTab(TabFolder parent, DataUsageKey duKey) - { + + public SSMonitorSwellTab(TabFolder parent, DataUsageKey duKey) { super(parent, duKey, true); } - @Override - protected void createListHeader(Composite parentComp) - { + @Override + protected void createListHeader(Composite parentComp) { Composite lblComp = new Composite(parentComp, SWT.NONE); GridLayout gl = new GridLayout(5, false); - gl.horizontalSpacing = 0; + gl.horizontalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; lblComp.setLayout(gl); - + /* * Create filler label. */ GridData gd = new GridData(75, SWT.DEFAULT); Label fillerLbl = new Label(lblComp, SWT.CENTER); fillerLbl.setLayoutData(gd); - + /* * Primary Swell */ - Composite priSwellComp = createGroupComposite(lblComp, 4, "Primary Swell"); + Composite priSwellComp = createGroupComposite(lblComp, 4, + "Primary Swell"); createLabelComp(priSwellComp, "Height(ft)", "", false); createLabelComp(priSwellComp, "Periods(s)", "", false); createLabelComp(priSwellComp, "Dir(deg)", "(from)", false); - createLabelComp(priSwellComp, "Dir(deg)", "(to)", false); - + createLabelComp(priSwellComp, "Dir(deg)", "(to)", false); + /* * Secondary Swell */ - Composite secSwellComp = createGroupComposite(lblComp, 4, "Secondary Swell"); + Composite secSwellComp = createGroupComposite(lblComp, 4, + "Secondary Swell"); createLabelComp(secSwellComp, "Height(ft)", "", false); createLabelComp(secSwellComp, "Periods(s)", "", false); createLabelComp(secSwellComp, "Dir(deg)", "(from)", false); createLabelComp(secSwellComp, "Dir(deg)", "(to)", false); - } - + } + @Override - protected void populateList() - { - if (ssDataArray == null) - { + protected void populateList() { + if (ssDataArray == null) { createDataArray(); } - + boolean update = false; - if (dataList.getItemCount() > 0) - { + if (dataList.getItemCount() > 0) { update = true; } - + areaIDArray = new ArrayList(); - + String currentAreaID; - - StringBuilder sb = null; + + StringBuilder sb = null; SSDispMonSwellData sssd = null; - - for (int i = 0; i < ssDataArray.size(); i++) - { + + for (int i = 0; i < ssDataArray.size(); i++) { sb = new StringBuilder(); - + sssd = ssDataArray.get(i); - + currentAreaID = sssd.getAreaID(); areaIDArray.add(currentAreaID); - - sb.append(String.format(areaIdFmt, currentAreaID)); - + + sb.append(String.format(areaIdFmt, currentAreaID)); + /* * Primary Swell */ - appendIntData(sb, sssd.getPriSwellHeightR(), sssd.getPriSwellHeightY()); - - double higherThreshold = Math.max(sssd.getPriSwellPeriodR(), sssd.getPriSwellPeriodY()); - double lowerThreshold = Math.min(sssd.getPriSwellPeriodR(), sssd.getPriSwellPeriodY()); - if ( rankSwellPeriodHigh ) { - sssd.setRankSwellPeriodHigh(true); - sssd.setPriSwellPeriodR(higherThreshold); - sssd.setPriSwellPeriodY(lowerThreshold); + appendIntData(sb, sssd.getPriSwellHeightR(), + sssd.getPriSwellHeightY()); + + double higherThreshold = Math.max(sssd.getPriSwellPeriodR(), + sssd.getPriSwellPeriodY()); + double lowerThreshold = Math.min(sssd.getPriSwellPeriodR(), + sssd.getPriSwellPeriodY()); + if (rankSwellPeriodHigh) { + sssd.setRankSwellPeriodHigh(true); + sssd.setPriSwellPeriodR(higherThreshold); + sssd.setPriSwellPeriodY(lowerThreshold); } else { - sssd.setRankSwellPeriodHigh(false); - sssd.setPriSwellPeriodR(lowerThreshold); - sssd.setPriSwellPeriodY(higherThreshold); + sssd.setRankSwellPeriodHigh(false); + sssd.setPriSwellPeriodR(lowerThreshold); + sssd.setPriSwellPeriodY(higherThreshold); } - appendIntData(sb, sssd.getPriSwellPeriodR(), sssd.getPriSwellPeriodY()); - - appendIntData(sb, sssd.getPriSwellDirFromR(), sssd.getPriSwellDirFromY()); - appendIntData(sb, sssd.getPriSwellDirToR(), sssd.getPriSwellDirToY()); - + appendIntData(sb, sssd.getPriSwellPeriodR(), + sssd.getPriSwellPeriodY()); + + appendIntData(sb, sssd.getPriSwellDirFromR(), + sssd.getPriSwellDirFromY()); + appendIntData(sb, sssd.getPriSwellDirToR(), + sssd.getPriSwellDirToY()); + /* * Secondary Swell */ - appendIntData(sb, sssd.getSecSwellHeightR(), sssd.getSecSwellHeightY()); - - higherThreshold = Math.max(sssd.getSecSwellPeriodR(), sssd.getSecSwellPeriodY()); - lowerThreshold = Math.min(sssd.getSecSwellPeriodR(), sssd.getSecSwellPeriodY()); - if ( rankSwellPeriodHigh ) { - //sssd.setRankSwellPeriodHigh(true); - sssd.setSecSwellPeriodR(higherThreshold); - sssd.setSecSwellPeriodY(lowerThreshold); + appendIntData(sb, sssd.getSecSwellHeightR(), + sssd.getSecSwellHeightY()); + + higherThreshold = Math.max(sssd.getSecSwellPeriodR(), + sssd.getSecSwellPeriodY()); + lowerThreshold = Math.min(sssd.getSecSwellPeriodR(), + sssd.getSecSwellPeriodY()); + if (rankSwellPeriodHigh) { + // sssd.setRankSwellPeriodHigh(true); + sssd.setSecSwellPeriodR(higherThreshold); + sssd.setSecSwellPeriodY(lowerThreshold); } else { - //sssd.setRankSwellPeriodHigh(false); - sssd.setSecSwellPeriodR(lowerThreshold); - sssd.setSecSwellPeriodY(higherThreshold); + // sssd.setRankSwellPeriodHigh(false); + sssd.setSecSwellPeriodR(lowerThreshold); + sssd.setSecSwellPeriodY(higherThreshold); } - appendIntData(sb, sssd.getSecSwellPeriodR(), sssd.getSecSwellPeriodY()); - - appendIntData(sb, sssd.getSecSwellDirFromR(), sssd.getSecSwellDirFromY()); - appendIntData(sb, sssd.getSecSwellDirToR(), sssd.getSecSwellDirToY()); - + appendIntData(sb, sssd.getSecSwellPeriodR(), + sssd.getSecSwellPeriodY()); + + appendIntData(sb, sssd.getSecSwellDirFromR(), + sssd.getSecSwellDirFromY()); + appendIntData(sb, sssd.getSecSwellDirToR(), + sssd.getSecSwellDirToY()); + /* * Append a space and add the data line to the list. */ sb.append(" "); - - if (update == true) - { + + if (update == true) { dataList.setItem(i, sb.toString()); - } - else - { + } else { dataList.add(sb.toString()); - } + } } - + packListControls(); } - - private void createDataArray() - { + + private void createDataArray() { ssDataArray = new ArrayList(); - - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - + + SSThresholdMgr sstm = SSThresholdMgr.getInstance(); + String xmlKey; - String areaID; - + String areaID; + ThresholdsXML threshXML = sstm.getThresholdsXmlData(duKey); - + ArrayList areasArray = threshXML.getAreas(); - - for (AreaXML area : areasArray) - { + + for (AreaXML area : areasArray) { areaID = area.getAreaId(); SSDispMonSwellData sssd = new SSDispMonSwellData(); - + sssd.setAreaID(areaID); /* * Primary Swell */ xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_HT.getXmlKey(); - sssd.setPriSwellHeightR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setPriSwellHeightY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setPriSwellHeightR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setPriSwellHeightY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_PD.getXmlKey(); - sssd.setPriSwellPeriodR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setPriSwellPeriodY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setPriSwellPeriodR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setPriSwellPeriodY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_DIR_FROM.getXmlKey(); - sssd.setPriSwellDirFromR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setPriSwellDirFromY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setPriSwellDirFromR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setPriSwellDirFromY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_DIR_TO.getXmlKey(); - sssd.setPriSwellDirToR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setPriSwellDirToY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setPriSwellDirToR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setPriSwellDirToY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Secondary Swell */ xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_HT.getXmlKey(); - sssd.setSecSwellHeightR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setSecSwellHeightY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setSecSwellHeightR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setSecSwellHeightY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_PD.getXmlKey(); - sssd.setSecSwellPeriodR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setSecSwellPeriodY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setSecSwellPeriodR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setSecSwellPeriodY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_DIR_FROM.getXmlKey(); - sssd.setSecSwellDirFromR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setSecSwellDirFromY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setSecSwellDirFromR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setSecSwellDirFromY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_DIR_TO.getXmlKey(); - sssd.setSecSwellDirToR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sssd.setSecSwellDirToY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sssd.setSecSwellDirToR(sstm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sssd.setSecSwellDirToY(sstm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Add data to array. */ ssDataArray.add(sssd); } } - - private SSDispMonSwellData getDataAtFirstSelection() - { + + private SSDispMonSwellData getDataAtFirstSelection() { int index = dataList.getSelectionIndex(); - - return ssDataArray.get(index); - } - - private void updateDataArray(SSDispMonSwellData sssd) - { - int[] dataListIndexes = dataList.getSelectionIndices(); - int currentIndex = 0; - - for (int i = 0; i < dataListIndexes.length; i++) - { - currentIndex = dataListIndexes[i]; - - ssDataArray.get(currentIndex).updateData(sssd); - } + + return ssDataArray.get(index); } - + + private void updateDataArray(SSDispMonSwellData sssd) { + int[] dataListIndexes = dataList.getSelectionIndices(); + int currentIndex = 0; + + for (int i = 0; i < dataListIndexes.length; i++) { + currentIndex = dataListIndexes[i]; + + ssDataArray.get(currentIndex).updateData(sssd); + } + } + @Override - public void commitDataToXML() - { + public void commitDataToXML() { SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - + String xmlKey; String areaID; - - for (SSDispMonSwellData sssd : ssDataArray) - { + + for (SSDispMonSwellData sssd : ssDataArray) { areaID = sssd.getAreaID(); - + /* * Primary Swell */ xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_HT.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getPriSwellHeightR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getPriSwellHeightY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getPriSwellHeightR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getPriSwellHeightY()); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_PD.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getPriSwellPeriodR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getPriSwellPeriodY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getPriSwellPeriodR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getPriSwellPeriodY()); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_DIR_FROM.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getPriSwellDirFromR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getPriSwellDirFromY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getPriSwellDirFromR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getPriSwellDirFromY()); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_DIR_TO.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getPriSwellDirToR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getPriSwellDirToY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getPriSwellDirToR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getPriSwellDirToY()); + /* * Secondary Swell */ xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_HT.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getSecSwellHeightR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getSecSwellHeightY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getSecSwellHeightR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getSecSwellHeightY()); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_PD.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getSecSwellPeriodR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getSecSwellPeriodY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getSecSwellPeriodR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getSecSwellPeriodY()); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_DIR_FROM.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getSecSwellDirFromR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getSecSwellDirFromY()); - + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getSecSwellDirFromR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getSecSwellDirFromY()); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_DIR_TO.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getSecSwellDirToR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getSecSwellDirToY()); - } + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sssd.getSecSwellDirToR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sssd.getSecSwellDirToY()); + } } @Override - public void reloadData() - { + public void reloadData() { dataList.removeAll(); ssDataArray.clear(); ssDataArray = null; - - populateList(); + + populateList(); } @Override - protected void editDataAction() - { + protected void editDataAction() { SSDispMonSwellData sssd = getDataAtFirstSelection(); - - if (monitorSwellEditDlg == null) - { - monitorSwellEditDlg = new SSDispMonSwellEditDlg(getParent().getShell(), sssd, this, false); + + if (monitorSwellEditDlg == null) { + monitorSwellEditDlg = new SSDispMonSwellEditDlg(getParent() + .getShell(), sssd, this, false); monitorSwellEditDlg.open(); monitorSwellEditDlg = null; } - } + } @Override - public void updateThresholdData(SSDispMonSwellData sssd) - { + public void updateThresholdData(SSDispMonSwellData sssd) { updateDataArray(sssd); - populateList(); + populateList(); } } - diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java index 69e52d9916..2e7369935a 100755 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java @@ -27,7 +27,6 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; @@ -56,7 +55,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Oct 27, 2014 3667 skorolev Cleaned code. * Feb 10, 2015 3886 skorolev Changed confirmation message. * Aug 17, 2015 3841 skorolev Corrected handleOkBtnSelection. - * + * Dec 26, 2015 5115 skorolev Corrected imports. * * * @@ -150,7 +149,7 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { public FSSObsMonitorConfigurationManager getInstance() { if (configMgr == null) { configMgr = FSSObsMonitorConfigurationManager - .getInstance(MonName.ss); + .getInstance(AppName.SAFESEAS); } return configMgr; } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSZoneTableDlg.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSZoneTableDlg.java old mode 100755 new mode 100644 index adc9cc68c5..facc39bb34 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSZoneTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSZoneTableDlg.java @@ -29,8 +29,9 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.dataplugin.fog.FogRecord.FOG_THREAT; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; +import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.common.monitor.data.ObConst.DisplayVarName; import com.raytheon.uf.viz.monitor.IMonitor; @@ -41,7 +42,6 @@ import com.raytheon.uf.viz.monitor.events.IMonitorThresholdEvent; import com.raytheon.uf.viz.monitor.listeners.IMonitorListener; import com.raytheon.uf.viz.monitor.safeseas.SafeSeasMonitor; import com.raytheon.uf.viz.monitor.ui.dialogs.ZoneTableDlg; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; /** * SAFESEAS Zone Table Dialog @@ -328,7 +328,7 @@ public class SSZoneTableDlg extends ZoneTableDlg { protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() { if (configMgr == null || configMgr.isPopulated()) { configMgr = FSSObsMonitorConfigurationManager - .getInstance(MonName.ss); + .getInstance(AppName.SAFESEAS); } return configMgr; } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/DmdDisplayFilterDlg.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/DmdDisplayFilterDlg.java index 4542a1e54b..9fee948f49 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/DmdDisplayFilterDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/DmdDisplayFilterDlg.java @@ -51,6 +51,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Nov 12, 2009 3039 lvenable Initial creation. * 24 Jul 2013 #2143 skorolev Changes for non-blocking dialog. * Aug 15, 2013 2143 mpduff Remove resize. + * Nov 05, 2015 #5070 randerso Changed to use system font name (not AWT) + * * * * @author lvenable @@ -153,7 +155,7 @@ public class DmdDisplayFilterDlg extends CaveSWTDialog implements */ private void initData() { scanCfg = SCANConfig.getInstance(); - lrgLabelFont = new Font(getDisplay(), "Monospaced", 12, SWT.BOLD); + lrgLabelFont = new Font(getDisplay(), "Monospace", 12, SWT.BOLD); smLabelFont = new Font(getDisplay(), "Sans", 10, SWT.BOLD); } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/StormCellIdDisplayDlg.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/StormCellIdDisplayDlg.java index cfb0ffe75d..f33f33aef1 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/StormCellIdDisplayDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/StormCellIdDisplayDlg.java @@ -56,6 +56,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * 24 Jul 2013 #2143 skorolev Changes for non-blocking dialogs. * 15 Aug 2013 2143 mpduff Remove resize. + * 05 Nov 2015 #5070 randerso Changed to use system font name (not AWT) + * * * * @author @@ -240,7 +242,7 @@ public class StormCellIdDisplayDlg extends CaveSWTDialog implements protected void initializeComponents(Shell shell) { // Initialize all of the controls and layouts scanCfg = SCANConfig.getInstance(); - lrgLabelFont = new Font(getDisplay(), "Monospaced", 12, SWT.BOLD); + lrgLabelFont = new Font(getDisplay(), "Monospace", 12, SWT.BOLD); smLabelFont = new Font(getDisplay(), "Sans", 10, SWT.BOLD); attrUnitMap = scanCfg.getClutterAttributes(ScanTables.CELL); diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/ThreeValueSliderCanvas.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/ThreeValueSliderCanvas.java index 36331bed5a..82531c09d6 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/ThreeValueSliderCanvas.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/ThreeValueSliderCanvas.java @@ -41,6 +41,22 @@ import org.eclipse.swt.widgets.Display; import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables; +/** + * Three Value Slider Canvas + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 05, 2015 #5070      randerso    Changed to use system font name (not AWT)
+ * 
+ * 
+ * + * @author randerso + * @version 1.0 + */ public class ThreeValueSliderCanvas { private final Composite parentComp; @@ -202,7 +218,7 @@ public class ThreeValueSliderCanvas { midLblRect = new Rectangle(0, 0, 0, 0); lowerLblRect = new Rectangle(0, 0, 0, 0); - labelFont = new Font(display, "Monospaced", 10, SWT.BOLD); + labelFont = new Font(display, "Monospace", 10, SWT.BOLD); mousePt = new Point(0, 0); upperRegion = new Region(display); midRegion = new Region(display); @@ -222,6 +238,7 @@ public class ThreeValueSliderCanvas { canvas.setLayoutData(gd); canvas.addPaintListener(new PaintListener() { + @Override public void paintControl(PaintEvent e) { drawCanvas(e.gc); } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/TwoValueSliderCanvas.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/TwoValueSliderCanvas.java index da104f7c56..6d7362519d 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/TwoValueSliderCanvas.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/TwoValueSliderCanvas.java @@ -39,149 +39,188 @@ import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; -public class TwoValueSliderCanvas -{ +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 05, 2015 #5070      randerso    Changed to use system font name (not AWT)
+ * 
+ * 
+ * + * @author randerso + * @version 1.0 + */ +public class TwoValueSliderCanvas { + // TODO: is this class redundant with + // com.raytheon.viz.ui.widgets.TwoValueSliderCanvas private Composite parentComp; + private Display display; - + private Color blackColor; + private Color greyColor; + private Color arrowAndLabelColor; + private Color canvasBgColor; - + /* * Canvas information */ - private Canvas canvas; - private final int CANVAS_WIDTH = 250; + private Canvas canvas; + + private final int CANVAS_WIDTH = 250; + private final int CANVAS_HEIGHT = 50; - + /* * Bar information. */ private int barBottomYCoord = 45; + private int barWidth = 200; + private int barHeight = 10; + private int barXCoord = 25; + private int barYCoord = 35; - + /* * Upper arrow, label and values - */ + */ private Region upperRegion; - private int[] upperPtArray = new int[]{0,0}; + + private int[] upperPtArray = new int[] { 0, 0 }; + private int upperArrowXCoord = 150; + private Rectangle upperLblRect; + private String upperStr; + private int upperLblYCoord = 1; + private boolean moveUpper = false; + private Double upperDisplayVal = 0.0; - + /* * Lower arrow, label and values - */ + */ private Region lowerRegion; - private int[] lowerPtArray = new int[]{0,0}; + + private int[] lowerPtArray = new int[] { 0, 0 }; + private int lowerArrowXCoord = 50; + private Rectangle lowerLblRect; + private String lowerStr; + private int lowerLblYCoord = 14; + private Color middleColor; + private boolean moveLower = false; + private Double lowerDisplayVal = 0.0; - + /* * Mouse information. */ - private Point mousePt; + private Point mousePt; + private boolean mouseDown = false; - + /* * Font/text information */ private Font labelFont; + private int textWidth = 0; + private int textHeight = 0; - + /* * Min/Range/Increment information */ private double minValue = Double.NaN; + private double rangeValue = Double.NaN; + private double incValue = Double.NaN; - + private double incPerPixel = Double.NaN; + private boolean displayAtInt = false; - + private String formatStr; - - public TwoValueSliderCanvas(Composite parentComp, double min, double range, double inc, - double startingUpperVal, double startingLowerVal) - { + + public TwoValueSliderCanvas(Composite parentComp, double min, double range, + double inc, double startingUpperVal, double startingLowerVal) { this.parentComp = parentComp; - + display = this.parentComp.getDisplay(); - + setValuesNoRedraw(min, range, inc, startingUpperVal, startingLowerVal); - + init(); createCanvas(); } - - private void init() - { + + private void init() { canvasBgColor = new Color(display, 142, 122, 110); arrowAndLabelColor = display.getSystemColor(SWT.COLOR_WHITE); middleColor = new Color(display, 110, 150, 110); blackColor = display.getSystemColor(SWT.COLOR_BLACK); greyColor = display.getSystemColor(SWT.COLOR_GRAY); - - upperLblRect = new Rectangle(0,0,0,0); - lowerLblRect = new Rectangle(0,0,0,0); - - labelFont = new Font(display, "Monospaced", 10, SWT.BOLD); - mousePt = new Point(0,0); + + upperLblRect = new Rectangle(0, 0, 0, 0); + lowerLblRect = new Rectangle(0, 0, 0, 0); + + labelFont = new Font(display, "Monospace", 10, SWT.BOLD); + mousePt = new Point(0, 0); upperRegion = new Region(display); lowerRegion = new Region(display); - + makeCalculations(); } - - private void createCanvas() - { + + private void createCanvas() { canvas = new Canvas(parentComp, SWT.DOUBLE_BUFFERED | SWT.BORDER); - //canvas = new Canvas(shell, SWT.NO_BACKGROUND); + // canvas = new Canvas(shell, SWT.NO_BACKGROUND); GridData gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true); gd.heightHint = CANVAS_HEIGHT; gd.widthHint = CANVAS_WIDTH; - + canvas.setSize(CANVAS_WIDTH, CANVAS_HEIGHT); - + canvas.setLayoutData(gd); - canvas.addPaintListener(new PaintListener() - { - public void paintControl(PaintEvent e) - { + canvas.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { drawCanvas(e.gc); } }); - - canvas.addMouseListener(new MouseAdapter() - { + + canvas.addMouseListener(new MouseAdapter() { @Override - public void mouseDown(MouseEvent e) - { - if (upperRegion.contains(e.x, e.y) == true || - upperLblRect.contains(e.x, e.y) == true) - { + public void mouseDown(MouseEvent e) { + if (upperRegion.contains(e.x, e.y) == true + || upperLblRect.contains(e.x, e.y) == true) { mousePt.x = e.x; mousePt.y = e.y; mouseDown = true; moveUpper = true; - } - else if (lowerRegion.contains(e.x, e.y) == true || - lowerLblRect.contains(e.x, e.y) == true) - { + } else if (lowerRegion.contains(e.x, e.y) == true + || lowerLblRect.contains(e.x, e.y) == true) { mousePt.x = e.x; mousePt.y = e.y; mouseDown = true; @@ -190,80 +229,74 @@ public class TwoValueSliderCanvas } @Override - public void mouseUp(MouseEvent e) - { + public void mouseUp(MouseEvent e) { mouseDown = false; moveLower = false; moveUpper = false; - } + } }); - - canvas.addMouseMoveListener(new MouseMoveListener() - { + + canvas.addMouseMoveListener(new MouseMoveListener() { @Override - public void mouseMove(MouseEvent e) - { - handleMouseMove(e); - } + public void mouseMove(MouseEvent e) { + handleMouseMove(e); + } }); - - canvas.addDisposeListener(new DisposeListener() - { + + canvas.addDisposeListener(new DisposeListener() { @Override - public void widgetDisposed(DisposeEvent e) - { + public void widgetDisposed(DisposeEvent e) { upperRegion.dispose(); lowerRegion.dispose(); labelFont.dispose(); canvasBgColor.dispose(); middleColor.dispose(); - } + } }); } - - private void drawCanvas(GC gc) - { + + private void drawCanvas(GC gc) { gc.setAntialias(SWT.ON); gc.setFont(labelFont); gc.setBackground(canvasBgColor); - + gc.fillRectangle(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); - + gc.setBackground(greyColor); gc.fillRectangle(barXCoord, barYCoord, barWidth, barHeight); - + gc.setBackground(middleColor); - gc.fillRectangle(lowerArrowXCoord, barYCoord, barWidth+25-lowerArrowXCoord, barHeight); - + gc.fillRectangle(lowerArrowXCoord, barYCoord, barWidth + 25 + - lowerArrowXCoord, barHeight); + gc.setBackground(greyColor); - gc.fillRectangle(upperArrowXCoord, barYCoord, barWidth+25-upperArrowXCoord, barHeight); - + gc.fillRectangle(upperArrowXCoord, barYCoord, barWidth + 25 + - upperArrowXCoord, barHeight); + gc.setForeground(blackColor); gc.drawRectangle(barXCoord, barYCoord, barWidth, barHeight); - + updateLowerArrow(gc); updateLowerLabel(gc); - - updateUpperArrow(gc); + + updateUpperArrow(gc); updateUpperLabel(gc); } - - private void updateUpperArrow(GC gc) - { + + private void updateUpperArrow(GC gc) { upperRegion.subtract(upperPtArray); - upperPtArray = new int[]{upperArrowXCoord, barBottomYCoord - barHeight - 3, - upperArrowXCoord + 4, barBottomYCoord, - upperArrowXCoord - 4, barBottomYCoord}; + upperPtArray = new int[] { upperArrowXCoord, + barBottomYCoord - barHeight - 3, upperArrowXCoord + 4, + barBottomYCoord, upperArrowXCoord - 4, barBottomYCoord }; upperRegion.add(upperPtArray); - + gc.setBackground(arrowAndLabelColor); gc.fillPolygon(upperPtArray); gc.setForeground(blackColor); gc.drawPolygon(upperPtArray); } - - private void updateUpperLabel(GC gc) - { + + private void updateUpperLabel(GC gc) { gc.setForeground(arrowAndLabelColor); upperStr = calcDisplayString(upperDisplayVal); int lblXCoord = upperArrowXCoord - (textWidth * upperStr.length() / 2); @@ -273,173 +306,141 @@ public class TwoValueSliderCanvas upperLblRect.width = textWidth * upperStr.length(); upperLblRect.height = textHeight; } - - private void updateLowerArrow(GC gc) - { + + private void updateLowerArrow(GC gc) { lowerRegion.subtract(lowerPtArray); - lowerPtArray = new int[]{lowerArrowXCoord, barBottomYCoord - barHeight - 3, - lowerArrowXCoord + 4, barBottomYCoord, - lowerArrowXCoord - 4, barBottomYCoord}; + lowerPtArray = new int[] { lowerArrowXCoord, + barBottomYCoord - barHeight - 3, lowerArrowXCoord + 4, + barBottomYCoord, lowerArrowXCoord - 4, barBottomYCoord }; lowerRegion.add(lowerPtArray); - + gc.setBackground(arrowAndLabelColor); - gc.fillPolygon(lowerPtArray); + gc.fillPolygon(lowerPtArray); gc.setForeground(blackColor); gc.drawPolygon(lowerPtArray); } - - private void updateLowerLabel(GC gc) - { + + private void updateLowerLabel(GC gc) { gc.setForeground(arrowAndLabelColor); lowerStr = calcDisplayString(lowerDisplayVal); - int lblXCoord = (int)(lowerArrowXCoord - ((double)textWidth * (double)lowerStr.length() / 2)); + int lblXCoord = (int) (lowerArrowXCoord - ((double) textWidth + * (double) lowerStr.length() / 2)); gc.drawString(lowerStr, lblXCoord, lowerLblYCoord, true); lowerLblRect.x = lblXCoord; lowerLblRect.y = lowerLblYCoord; lowerLblRect.width = textWidth * lowerStr.length(); lowerLblRect.height = textHeight; } - - private void handleMouseMove(MouseEvent e) - { - if (mouseDown == false) - { + + private void handleMouseMove(MouseEvent e) { + if (mouseDown == false) { return; } - - if (moveUpper == true) - { + + if (moveUpper == true) { int xDiff = e.x - mousePt.x; upperArrowXCoord += xDiff; - if (upperArrowXCoord > 225) - { + if (upperArrowXCoord > 225) { upperArrowXCoord = 225; - } - else if (upperArrowXCoord < 25) - { + } else if (upperArrowXCoord < 25) { upperArrowXCoord = 25; - } - else if (upperArrowXCoord < lowerArrowXCoord) - { + } else if (upperArrowXCoord < lowerArrowXCoord) { upperArrowXCoord = lowerArrowXCoord; - } - + } + upperDisplayVal = calcDisplayValue(upperArrowXCoord); - } - else if (moveLower == true) - { + } else if (moveLower == true) { int xDiff = e.x - mousePt.x; lowerArrowXCoord += xDiff; - if (lowerArrowXCoord > 225) - { + if (lowerArrowXCoord > 225) { lowerArrowXCoord = 225; - } - else if (lowerArrowXCoord < 25) - { + } else if (lowerArrowXCoord < 25) { lowerArrowXCoord = 25; - } - else if (lowerArrowXCoord > upperArrowXCoord) - { + } else if (lowerArrowXCoord > upperArrowXCoord) { lowerArrowXCoord = upperArrowXCoord; - } + } lowerDisplayVal = calcDisplayValue(lowerArrowXCoord); } - + mousePt.x = e.x; mousePt.y = e.y; canvas.redraw(); } - - private void makeCalculations() - { + + private void makeCalculations() { Image image = new Image(display, 100, 100); GC gc = new GC(image); gc.setFont(labelFont); - + textWidth = gc.getFontMetrics().getAverageCharWidth(); - textHeight = gc.getFontMetrics().getHeight(); - + textHeight = gc.getFontMetrics().getHeight(); + gc.dispose(); image.dispose(); } - - private double calcDisplayValue(int xCoord) - { + + private double calcDisplayValue(int xCoord) { double xCoordAsValue = (xCoord - barXCoord) * incPerPixel + minValue; - if (incValue == .25) - { + if (incValue == .25) { return (Math.round(xCoordAsValue * 4.00)) / 4.00; - } - else if (incValue == .10) - { + } else if (incValue == .10) { return (Math.round(xCoordAsValue * 10.00)) / 10.00; - } - else - { - return (double)Math.round(xCoordAsValue); + } else { + return Math.round(xCoordAsValue); } } - - private String calcDisplayString(Double displVal) - { - if (displayAtInt == true) - { + + private String calcDisplayString(Double displVal) { + if (displayAtInt == true) { return String.format(formatStr, Math.round(displVal)); - } - else - { + } else { return String.format(formatStr, displVal); } } - - private int calcValueToBarXCoord(double val) - { - int result = (int)Math.round((val - minValue)/incPerPixel + barXCoord); - + + private int calcValueToBarXCoord(double val) { + int result = (int) Math.round((val - minValue) / incPerPixel + + barXCoord); + return result; } - - private void setValuesNoRedraw(double min, double range, double inc, double startingUpperVal, double startingLowerVal) - { + + private void setValuesNoRedraw(double min, double range, double inc, + double startingUpperVal, double startingLowerVal) { this.minValue = min; - this.rangeValue = (double)Math.round(range); + this.rangeValue = Math.round(range); this.incValue = inc; - - incPerPixel = this.rangeValue / (double)barWidth; - - if (inc < 1.00) - { + + incPerPixel = this.rangeValue / barWidth; + + if (inc < 1.00) { displayAtInt = false; formatStr = "%1.2f"; - } - else - { + } else { displayAtInt = true; formatStr = "%d"; } - + upperArrowXCoord = calcValueToBarXCoord(startingUpperVal); lowerArrowXCoord = calcValueToBarXCoord(startingLowerVal); - + upperDisplayVal = calcDisplayValue(upperArrowXCoord); lowerDisplayVal = calcDisplayValue(lowerArrowXCoord); } - - public void setValues(double min, double range, double inc, double startingUpperVal, double startingLowerVal) - { + + public void setValues(double min, double range, double inc, + double startingUpperVal, double startingLowerVal) { setValuesNoRedraw(min, range, inc, startingUpperVal, startingLowerVal); canvas.redraw(); } - - public double getUpperValue() - { + + public double getUpperValue() { return upperDisplayVal; } - - public double getLowerValue() - { + + public double getLowerValue() { return lowerDisplayVal; } } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/resource/ScanResource.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/resource/ScanResource.java index f137892327..e8217ded3e 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/resource/ScanResource.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/resource/ScanResource.java @@ -88,6 +88,8 @@ import com.vividsolutions.jts.geom.Coordinate; * May 09, 2014 3145 mpduff Dispose the ScanDrawer font * Aug 14, 2014 3523 mapeters Updated deprecated {@link DrawableString#textStyle} * assignments. + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling + * * * * @author dhladky @@ -183,8 +185,9 @@ public class ScanResource extends try { scan = (ScanRecord) pdo; if (scan.getIcao().equals(resourceData.icao) - && scan.getType().equals(getTable().name())) + && scan.getType().equals(getTable().name())) { addRecord(scan); + } } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, "Error updating SCAN resource", e); @@ -308,7 +311,7 @@ public class ScanResource extends if (getScanDrawer().font == null) { getScanDrawer().setFont( - target.initializeFont("Dialog", 11, null)); + target.initializeFont("Dialog", 9, null)); } if (getScan().getTableKeys(getTable(), resourceData.icao, @@ -418,9 +421,8 @@ public class ScanResource extends .getMagnification().floatValue(); DrawableString[] strings = new DrawableString[4]; - strings[0] = new DrawableString( - getScanDrawer().sdc.getAttrName(), getCapability( - ColorableCapability.class).getColor()); + strings[0] = new DrawableString(getScanDrawer().sdc.getAttrName(), + getCapability(ColorableCapability.class).getColor()); strings[0].basics.x = pixel[0]; strings[0].basics.y = pixel[1]; diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java old mode 100755 new mode 100644 index 2b54320588..1da18b3433 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java @@ -30,8 +30,8 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.jms.notification.NotificationMessage; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; +import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.viz.core.alerts.AlertMessage; import com.raytheon.uf.viz.monitor.IMonitor; import com.raytheon.uf.viz.monitor.Monitor; @@ -72,6 +72,10 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Sep 04, 2014 3220 skorolev Updated configUpdate method and added updateMonitoringArea. * Sep 18, 2015 3873 skorolev Removed common definitions. Replaced deprecated NotificationMessage. * Dec 17, 2015 3873 dhladky Abstracted handling of dialogTime and Zone dialog events. + * <<<<<<< HEAD + * ======= + * Jan 04, 2016 5115 skorolev Corrected imports and replaced AppName with MonName. + * >>>>>>> Omaha #5115 - Added AlertViz image management for FSSObs data. * * * @@ -98,7 +102,7 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener { * This object contains all observation data necessary for the table dialogs * and trending plots */ - private ObMultiHrsReports obData; + private final ObMultiHrsReports obData; /** Array of snow listeners **/ private final List snowResources = new ArrayList(); @@ -109,7 +113,7 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener { private SnowMonitor() { pluginPatterns.add(fssPattern); snowConfig = FSSObsMonitorConfigurationManager - .getInstance(MonName.snow); + .getInstance(AppName.SNOW); updateMonitoringArea(); initObserver(OBS, this); obData = new ObMultiHrsReports(CommonConfig.AppName.SNOW); @@ -343,11 +347,11 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener { } /** - * Event fire is different, Override. - * SnowResource sets the Drawtime. + * Event fire is different, Override. SnowResource sets the Drawtime. * * @param dialogTime */ + @Override public void updateDialogTime(Date dialogTime) { if (zoneDialog.linkedToFrame) { this.dialogTime = dialogTime; diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/threshold/SnowThresholdMgr.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/threshold/SnowThresholdMgr.java index ed385ac564..16c2145546 100755 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/threshold/SnowThresholdMgr.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/threshold/SnowThresholdMgr.java @@ -22,10 +22,10 @@ package com.raytheon.uf.viz.monitor.snow.threshold; import java.util.ArrayList; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SnowDisplay; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SnowMonitor; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowDisplay; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowMonitor; /** * This class manages the Snow thresholds for display and monitor. @@ -41,6 +41,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowMonitor; * May 21, 2014 3086 skorolev Cleaned code. * Sep 04, 2014 3220 skorolev Removed "site". * Sep 18, 2015 3873 skorolev Adjusted to AppName and removed areaConfigMgr. + * Dec 26, 2015 5114 skorolev Corrected imports. * * * diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayMeteoTab.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayMeteoTab.java old mode 100644 new mode 100755 index eb34fa2508..93c03a3616 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayMeteoTab.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayMeteoTab.java @@ -29,14 +29,14 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SnowDisplay; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; import com.raytheon.uf.viz.monitor.data.RangesUtil; import com.raytheon.uf.viz.monitor.snow.threshold.SnowDisplayMeteoData; import com.raytheon.uf.viz.monitor.snow.threshold.SnowThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowDisplay; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; /** * Snow Display Meteo Table. @@ -48,6 +48,7 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 21, 2014 3086 skorolev Cleaned code. + * Dec 26, 2015 5114 skorolev Corrected imports. * * * diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayProductTab.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayProductTab.java old mode 100644 new mode 100755 index 2054b28ce0..0718964e1c --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayProductTab.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayProductTab.java @@ -28,331 +28,374 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SnowDisplay; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; import com.raytheon.uf.viz.monitor.data.RangesUtil; import com.raytheon.uf.viz.monitor.snow.threshold.SnowDisplayProductData; import com.raytheon.uf.viz.monitor.snow.threshold.SnowThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowDisplay; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; -public class SnowDisplayProductTab extends TabItemComp implements IUpdateDisplayProduct -{ +/** + * SNOW Display Product Table. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 26, 2015 5115       skorolev    Corrected imports.
+ * 
+ * 
+ * + * @author skorolev + * @version 1.0 + */ +public class SnowDisplayProductTab extends TabItemComp implements + IUpdateDisplayProduct { private SnowDisplayProductEditDlg productEditDlg; - + private ArrayList areaIDArray; - + private ArrayList snowDataArray; - - public SnowDisplayProductTab(TabFolder parent, DataUsageKey duKey) - { + + public SnowDisplayProductTab(TabFolder parent, DataUsageKey duKey) { super(parent, duKey); } - @Override - protected void createListHeader(Composite parentComp) - { + @Override + protected void createListHeader(Composite parentComp) { Composite lblComp = new Composite(parentComp, SWT.NONE); GridLayout gl = new GridLayout(5, false); - gl.horizontalSpacing = 0; + gl.horizontalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; lblComp.setLayout(gl); - + /* * Create filler label. */ GridData gd = new GridData(68, SWT.DEFAULT); Label fillerLbl = new Label(lblComp, SWT.CENTER); fillerLbl.setLayoutData(gd); - + /* * Blizzard Warning */ - Composite blizzardComp = createGroupComposite(lblComp, 4, "Blizzard Warning"); + Composite blizzardComp = createGroupComposite(lblComp, 4, + "Blizzard Warning"); createLabelComp(blizzardComp, "Vis(mi)", "", true); createLabelComp(blizzardComp, "Wind", "Speed(kt)", false); createLabelComp(blizzardComp, "Gust", "Speed(kt)", false); - createLabelComp(blizzardComp, "Peak", "Wind(kt)", false); - + createLabelComp(blizzardComp, "Peak", "Wind(kt)", false); + /* * Freezing Precip */ - Composite freezePrecipComp = createGroupComposite(lblComp, 2, "Freezing Precip"); + Composite freezePrecipComp = createGroupComposite(lblComp, 2, + "Freezing Precip"); createLabelComp(freezePrecipComp, "Temp(F)", "", false); createLabelComp(freezePrecipComp, "Hourly", "Prcp(in)", false); - + /* * Heavy Snow Warning */ - Composite heavySnowWarnComp = createGroupComposite(lblComp, 3, "Heavy Snow Warning"); + Composite heavySnowWarnComp = createGroupComposite(lblComp, 3, + "Heavy Snow Warning"); createLabelComp(heavySnowWarnComp, "SNINCR", "Hr(in)", false); createLabelComp(heavySnowWarnComp, "SNINCR", "Tot(in)", false); createLabelComp(heavySnowWarnComp, "Snow", "Depth(in)", false); - } - + } + @Override - protected void populateList() - { - if (snowDataArray == null) - { + protected void populateList() { + if (snowDataArray == null) { createDataArray(); } - + boolean update = false; - if (dataList.getItemCount() > 0) - { + if (dataList.getItemCount() > 0) { update = true; } - + RangesUtil rangeUtil = RangesUtil.getInstance(); - + areaIDArray = new ArrayList(); - + String tmpVisStr; String currentAreaID; - + double visVal = 0.0; - - StringBuilder sb = null; + + StringBuilder sb = null; SnowDisplayProductData sdpd = null; - - for (int i = 0; i < snowDataArray.size(); i++) - { + + for (int i = 0; i < snowDataArray.size(); i++) { sb = new StringBuilder(); - + sdpd = snowDataArray.get(i); - + currentAreaID = sdpd.getAreaID(); areaIDArray.add(currentAreaID); - + sb.append(String.format(areaIdFmt, currentAreaID)); - + /* * Blizzard Warning - */ - visVal = sdpd.getBlizWrnVisR(); - tmpVisStr = rangeUtil.getVisString((int)visVal); + */ + visVal = sdpd.getBlizWrnVisR(); + tmpVisStr = rangeUtil.getVisString((int) visVal); sb.append(String.format(dataFmt, tmpVisStr)); - - visVal = sdpd.getBlizWrnVisY(); - tmpVisStr = rangeUtil.getVisString((int)visVal); + + visVal = sdpd.getBlizWrnVisY(); + tmpVisStr = rangeUtil.getVisString((int) visVal); sb.append(String.format(dataFmt, tmpVisStr)); - - appendIntData(sb, sdpd.getBlizWrnWindSpdR(), sdpd.getBlizWrnWindSpdY()); - appendIntData(sb, sdpd.getBlizWrnGustSpdR(), sdpd.getBlizWrnGustSpdY()); - appendIntData(sb, sdpd.getBlizWrnPeakWindR(), sdpd.getBlizWrnPeakWindY()); - + + appendIntData(sb, sdpd.getBlizWrnWindSpdR(), + sdpd.getBlizWrnWindSpdY()); + appendIntData(sb, sdpd.getBlizWrnGustSpdR(), + sdpd.getBlizWrnGustSpdY()); + appendIntData(sb, sdpd.getBlizWrnPeakWindR(), + sdpd.getBlizWrnPeakWindY()); + /* * Freezing Precip */ - appendIntData(sb, sdpd.getFrzPrecipTempR(), sdpd.getFrzPrecipTempY()); - appendDecimalData(sb, sdpd.getFrzPrecipHrlyPrcpR(), sdpd.getFrzPrecipHrlyPrcpY()); - + appendIntData(sb, sdpd.getFrzPrecipTempR(), + sdpd.getFrzPrecipTempY()); + appendDecimalData(sb, sdpd.getFrzPrecipHrlyPrcpR(), + sdpd.getFrzPrecipHrlyPrcpY()); + /* * Heavy Snow Warning - */ - appendIntData(sb, sdpd.getHvySnowSnincrHrR(), sdpd.getHvySnowSnincrHrY()); - appendIntData(sb, sdpd.getHvySnowSnincrTotR(), sdpd.getHvySnowSnincrTotY()); + */ + appendIntData(sb, sdpd.getHvySnowSnincrHrR(), + sdpd.getHvySnowSnincrHrY()); + appendIntData(sb, sdpd.getHvySnowSnincrTotR(), + sdpd.getHvySnowSnincrTotY()); appendIntData(sb, sdpd.getHvySnowDepthR(), sdpd.getHvySnowDepthY()); - + /* * Append a space and add the data line to the list. */ sb.append(" "); - - if (update == true) - { + + if (update == true) { dataList.setItem(i, sb.toString()); - } - else - { + } else { dataList.add(sb.toString()); - } + } } - + packListControls(); } - - private void createDataArray() - { + + private void createDataArray() { snowDataArray = new ArrayList(); - - SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - + + SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); + String xmlKey; - String areaID; - + String areaID; + ThresholdsXML threshXML = stm.getThresholdsXmlData(duKey); - + ArrayList areasArray = threshXML.getAreas(); - - for (AreaXML area : areasArray) - { + + for (AreaXML area : areasArray) { areaID = area.getAreaId(); SnowDisplayProductData sdpd = new SnowDisplayProductData(); - + sdpd.setAreaID(areaID); /* * Blizzard Warning */ xmlKey = SnowDisplay.SNOW_DISP_PROD_BLIZZ_VIS.getXmlKey(); - sdpd.setBlizWrnVisR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdpd.setBlizWrnVisY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sdpd.setBlizWrnVisR(stm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sdpd.setBlizWrnVisY(stm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SnowDisplay.SNOW_DISP_PROD_BLIZZ_WIND_SPEED.getXmlKey(); - sdpd.setBlizWrnWindSpdR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdpd.setBlizWrnWindSpdY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sdpd.setBlizWrnWindSpdR(stm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sdpd.setBlizWrnWindSpdY(stm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SnowDisplay.SNOW_DISP_PROD_BLIZZ_GUST_SPEED.getXmlKey(); - sdpd.setBlizWrnGustSpdR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdpd.setBlizWrnGustSpdY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sdpd.setBlizWrnGustSpdR(stm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sdpd.setBlizWrnGustSpdY(stm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SnowDisplay.SNOW_DISP_PROD_BLIZZ_PEAK_WIND.getXmlKey(); - sdpd.setBlizWrnPeakWindR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdpd.setBlizWrnPeakWindY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + sdpd.setBlizWrnPeakWindR(stm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sdpd.setBlizWrnPeakWindY(stm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); /* * Freezing Precip */ xmlKey = SnowDisplay.SNOW_DISP_PROD_FRZ_TEMP.getXmlKey(); - sdpd.setFrzPrecipTempR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdpd.setFrzPrecipTempY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sdpd.setFrzPrecipTempR(stm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sdpd.setFrzPrecipTempY(stm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SnowDisplay.SNOW_DISP_PROD_FRZ_HOURLY_PRECIP.getXmlKey(); - sdpd.setFrzPrecipHrlyPrcpR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdpd.setFrzPrecipHrlyPrcpY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sdpd.setFrzPrecipHrlyPrcpR(stm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sdpd.setFrzPrecipHrlyPrcpY(stm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Heavy Snow Warning */ xmlKey = SnowDisplay.SNOW_DISP_PROD_HSW_SNINCR_HOURLY.getXmlKey(); - sdpd.setHvySnowSnincrHrR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdpd.setHvySnowSnincrHrY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sdpd.setHvySnowSnincrHrR(stm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sdpd.setHvySnowSnincrHrY(stm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SnowDisplay.SNOW_DISP_PROD_HSW_SNINCR_TOTAL.getXmlKey(); - sdpd.setHvySnowSnincrTotR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdpd.setHvySnowSnincrTotY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sdpd.setHvySnowSnincrTotR(stm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sdpd.setHvySnowSnincrTotY(stm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + xmlKey = SnowDisplay.SNOW_DISP_PROD_HSW_SNOW_DEPTH.getXmlKey(); - sdpd.setHvySnowDepthR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdpd.setHvySnowDepthY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sdpd.setHvySnowDepthR(stm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sdpd.setHvySnowDepthY(stm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Add data to array. */ snowDataArray.add(sdpd); } } - - private SnowDisplayProductData getDataAtFirstSelection() - { + + private SnowDisplayProductData getDataAtFirstSelection() { int index = dataList.getSelectionIndex(); - - return snowDataArray.get(index); + + return snowDataArray.get(index); } - - private void updateDataArray(SnowDisplayProductData sdpd) - { - int[] dataListIndexes = dataList.getSelectionIndices(); + + private void updateDataArray(SnowDisplayProductData sdpd) { + int[] dataListIndexes = dataList.getSelectionIndices(); int currentIndex = 0; - - for (int i = 0; i < dataListIndexes.length; i++) - { + + for (int i = 0; i < dataListIndexes.length; i++) { currentIndex = dataListIndexes[i]; - + snowDataArray.get(currentIndex).updateData(sdpd); - } + } } - + @Override - public void commitDataToXML() - { + public void commitDataToXML() { SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - + String xmlKey; String areaID; - - for (SnowDisplayProductData sdpd : snowDataArray) - { + + for (SnowDisplayProductData sdpd : snowDataArray) { areaID = sdpd.getAreaID(); - + /* * Blizzard Warning */ xmlKey = SnowDisplay.SNOW_DISP_PROD_BLIZZ_VIS.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdpd.getBlizWrnVisR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdpd.getBlizWrnVisY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdpd.getBlizWrnVisR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdpd.getBlizWrnVisY()); + xmlKey = SnowDisplay.SNOW_DISP_PROD_BLIZZ_WIND_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdpd.getBlizWrnWindSpdR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdpd.getBlizWrnWindSpdY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdpd.getBlizWrnWindSpdR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdpd.getBlizWrnWindSpdY()); + xmlKey = SnowDisplay.SNOW_DISP_PROD_BLIZZ_GUST_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdpd.getBlizWrnGustSpdR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdpd.getBlizWrnGustSpdY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdpd.getBlizWrnGustSpdR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdpd.getBlizWrnGustSpdY()); + xmlKey = SnowDisplay.SNOW_DISP_PROD_BLIZZ_PEAK_WIND.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdpd.getBlizWrnPeakWindR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdpd.getBlizWrnPeakWindY()); + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdpd.getBlizWrnPeakWindR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdpd.getBlizWrnPeakWindY()); /* * Freezing Precip */ xmlKey = SnowDisplay.SNOW_DISP_PROD_FRZ_TEMP.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdpd.getFrzPrecipTempR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdpd.getFrzPrecipTempY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdpd.getFrzPrecipTempR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdpd.getFrzPrecipTempY()); + xmlKey = SnowDisplay.SNOW_DISP_PROD_FRZ_HOURLY_PRECIP.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdpd.getFrzPrecipHrlyPrcpR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdpd.getFrzPrecipHrlyPrcpY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdpd.getFrzPrecipHrlyPrcpR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdpd.getFrzPrecipHrlyPrcpY()); + /* * Heavy Snow Warning */ xmlKey = SnowDisplay.SNOW_DISP_PROD_HSW_SNINCR_HOURLY.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdpd.getHvySnowSnincrHrR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdpd.getHvySnowSnincrHrY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdpd.getHvySnowSnincrHrR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdpd.getHvySnowSnincrHrY()); + xmlKey = SnowDisplay.SNOW_DISP_PROD_HSW_SNINCR_TOTAL.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdpd.getHvySnowSnincrTotR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdpd.getHvySnowSnincrTotY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdpd.getHvySnowSnincrTotR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdpd.getHvySnowSnincrTotY()); + xmlKey = SnowDisplay.SNOW_DISP_PROD_HSW_SNOW_DEPTH.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdpd.getHvySnowDepthR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdpd.getHvySnowDepthY()); + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdpd.getHvySnowDepthR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdpd.getHvySnowDepthY()); } } @Override - public void reloadData() - { + public void reloadData() { dataList.removeAll(); snowDataArray.clear(); snowDataArray = null; - - populateList(); + + populateList(); } @Override - protected void editDataAction() - { + protected void editDataAction() { SnowDisplayProductData sdpd = getDataAtFirstSelection(); - - if (productEditDlg == null) - { - productEditDlg = new SnowDisplayProductEditDlg(getParent().getShell(), sdpd, this); + + if (productEditDlg == null) { + productEditDlg = new SnowDisplayProductEditDlg(getParent() + .getShell(), sdpd, this); productEditDlg.open(); productEditDlg = null; } - } + } @Override - public void updateThresholdData(SnowDisplayProductData sdpd) - { + public void updateThresholdData(SnowDisplayProductData sdpd) { updateDataArray(sdpd); - populateList(); + populateList(); } } diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayWindTab.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayWindTab.java old mode 100644 new mode 100755 index 050fa7db26..f0ea38fb09 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayWindTab.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayWindTab.java @@ -28,289 +28,306 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SnowDisplay; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; import com.raytheon.uf.viz.monitor.snow.threshold.SnowDisplayWindData; import com.raytheon.uf.viz.monitor.snow.threshold.SnowThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowDisplay; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; -public class SnowDisplayWindTab extends TabItemComp implements IUpdateDisplayWind -{ +/** + * SNOW Display Wind Table. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 26, 2015 5115       skorolev    Corrected imports.
+ * 
+ * 
+ * + * @author skorolev + * @version 1.0 + */ +public class SnowDisplayWindTab extends TabItemComp implements + IUpdateDisplayWind { private SnowDisplayWindEditDlg windEditDlg; - + private ArrayList areaIDArray; - + private ArrayList snowDataArray; - - public SnowDisplayWindTab(TabFolder parent, DataUsageKey duKey) - { + + public SnowDisplayWindTab(TabFolder parent, DataUsageKey duKey) { super(parent, duKey); } - @Override - protected void createListHeader(Composite parentComp) - { + @Override + protected void createListHeader(Composite parentComp) { Composite lblComp = new Composite(parentComp, SWT.NONE); GridLayout gl = new GridLayout(5, false); - gl.horizontalSpacing = 0; + gl.horizontalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; lblComp.setLayout(gl); - + /* * Create filler label. */ GridData gd = new GridData(73, SWT.DEFAULT); Label fillerLbl = new Label(lblComp, SWT.CENTER); fillerLbl.setLayoutData(gd); - + /* * Wind */ Composite windComp = createGroupComposite(lblComp, 5, null); - createLabelComp(windComp, "Wind", "Speed(kt)", false); - createLabelComp(windComp, "Peak", "Wind(kt)", false); + createLabelComp(windComp, "Wind", "Speed(kt)", false); + createLabelComp(windComp, "Peak", "Wind(kt)", false); createLabelComp(windComp, "Gust", "Speed(kt)", false); createLabelComp(windComp, "Wind", "Dir(deg)\n(from)", false); createLabelComp(windComp, "Wind", "Dir(deg)\n(to)", false); - } - + } + @Override - protected void populateList() - { - if (snowDataArray == null) - { + protected void populateList() { + if (snowDataArray == null) { createDataArray(); } - + boolean update = false; - if (dataList.getItemCount() > 0) - { + if (dataList.getItemCount() > 0) { update = true; } - + areaIDArray = new ArrayList(); - + String currentAreaID; - - StringBuilder sb = null; + + StringBuilder sb = null; SnowDisplayWindData sdwd = null; - - for (int i = 0; i < snowDataArray.size(); i++) - { + + for (int i = 0; i < snowDataArray.size(); i++) { sb = new StringBuilder(); - + sdwd = snowDataArray.get(i); - + currentAreaID = sdwd.getAreaID(); areaIDArray.add(currentAreaID); - + sb.append(String.format(areaIdFmt, currentAreaID)); - + /* * Wind Speed - */ - appendIntData(sb, sdwd.getWindWindSpeedR(), sdwd.getWindWindSpeedY()); - + */ + appendIntData(sb, sdwd.getWindWindSpeedR(), + sdwd.getWindWindSpeedY()); + /* * Peak Wind - */ + */ appendIntData(sb, sdwd.getWindPeakR(), sdwd.getWindPeakY()); - + /* * Gust Speed - */ + */ appendIntData(sb, sdwd.getWindGustR(), sdwd.getWindGustY()); - + /* * Wind Direction From - */ - appendIntData(sb, sdwd.getWindDirFromY(),sdwd.getWindDirFromR()); - + */ + appendIntData(sb, sdwd.getWindDirFromY(), sdwd.getWindDirFromR()); + /* * Wind Direction To - */ + */ appendIntData(sb, sdwd.getWindDirToR(), sdwd.getWindDirToY()); - + /* * Append a space and add the data line to the list. */ sb.append(" "); - - if (update == true) - { + + if (update == true) { dataList.setItem(i, sb.toString()); - } - else - { + } else { dataList.add(sb.toString()); - } + } } - + packListControls(); } - - private void createDataArray() - { + + private void createDataArray() { snowDataArray = new ArrayList(); - - SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - + + SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); + String xmlKey; - String areaID; - + String areaID; + ThresholdsXML threshXML = stm.getThresholdsXmlData(duKey); - + ArrayList areasArray = threshXML.getAreas(); - - for (AreaXML area : areasArray) - { + + for (AreaXML area : areasArray) { areaID = area.getAreaId(); SnowDisplayWindData sdwd = new SnowDisplayWindData(); - + sdwd.setAreaID(areaID); /* * Wind Speed */ xmlKey = SnowDisplay.SNOW_DISP_WIND_WIND_SPEED.getXmlKey(); - sdwd.setWindWindSpeedR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdwd.setWindWindSpeedY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + sdwd.setWindWindSpeedR(stm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sdwd.setWindWindSpeedY(stm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); /* * Peak Wind */ xmlKey = SnowDisplay.SNOW_DISP_WIND_PEAK_WIND.getXmlKey(); - sdwd.setWindPeakR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdwd.setWindPeakY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sdwd.setWindPeakR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + sdwd.setWindPeakY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); + /* * Gust Speed */ xmlKey = SnowDisplay.SNOW_DISP_WIND_GUST_SPEED.getXmlKey(); - sdwd.setWindGustR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdwd.setWindGustY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sdwd.setWindGustR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + sdwd.setWindGustY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); + /* * Wind Direction From */ xmlKey = SnowDisplay.SNOW_DISP_WIND_DIR_FROM.getXmlKey(); - sdwd.setWindDirFromR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdwd.setWindDirFromY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sdwd.setWindDirFromR(stm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sdwd.setWindDirFromY(stm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); + /* * Wind Direction From */ xmlKey = SnowDisplay.SNOW_DISP_WIND_DIR_TO.getXmlKey(); - sdwd.setWindDirToR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - sdwd.setWindDirToY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + sdwd.setWindDirToR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + sdwd.setWindDirToY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); + /* * Add data to array. */ snowDataArray.add(sdwd); } } - - private SnowDisplayWindData getDataAtFirstSelection() - { + + private SnowDisplayWindData getDataAtFirstSelection() { int index = dataList.getSelectionIndex(); - - return snowDataArray.get(index); + + return snowDataArray.get(index); } - - private void updateDataArray(SnowDisplayWindData sdwd) - { - int[] dataListIndexes = dataList.getSelectionIndices(); + + private void updateDataArray(SnowDisplayWindData sdwd) { + int[] dataListIndexes = dataList.getSelectionIndices(); int currentIndex = 0; - - for (int i = 0; i < dataListIndexes.length; i++) - { + + for (int i = 0; i < dataListIndexes.length; i++) { currentIndex = dataListIndexes[i]; - + snowDataArray.get(currentIndex).updateData(sdwd); - } - } - - @Override - public void commitDataToXML() - { - SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - - String xmlKey; - String areaID; - - for (SnowDisplayWindData sdwd : snowDataArray) - { - areaID = sdwd.getAreaID(); - - /* - * Wind Speed - */ - xmlKey = SnowDisplay.SNOW_DISP_WIND_WIND_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdwd.getWindWindSpeedR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdwd.getWindWindSpeedY()); - - /* - * Peak Wind - */ - xmlKey = SnowDisplay.SNOW_DISP_WIND_PEAK_WIND.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdwd.getWindPeakR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdwd.getWindPeakY()); - - /* - * Gust Speed - */ - xmlKey = SnowDisplay.SNOW_DISP_WIND_GUST_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdwd.getWindGustR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdwd.getWindGustY()); - - /* - * Wind Direction From - */ - xmlKey = SnowDisplay.SNOW_DISP_WIND_DIR_FROM.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdwd.getWindDirFromR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdwd.getWindDirFromY()); - - /* - * Wind Direction To - */ - xmlKey = SnowDisplay.SNOW_DISP_WIND_DIR_TO.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sdwd.getWindDirToR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sdwd.getWindDirToY()); } } @Override - public void reloadData() - { + public void commitDataToXML() { + SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); + + String xmlKey; + String areaID; + + for (SnowDisplayWindData sdwd : snowDataArray) { + areaID = sdwd.getAreaID(); + + /* + * Wind Speed + */ + xmlKey = SnowDisplay.SNOW_DISP_WIND_WIND_SPEED.getXmlKey(); + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdwd.getWindWindSpeedR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdwd.getWindWindSpeedY()); + + /* + * Peak Wind + */ + xmlKey = SnowDisplay.SNOW_DISP_WIND_PEAK_WIND.getXmlKey(); + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdwd.getWindPeakR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdwd.getWindPeakY()); + + /* + * Gust Speed + */ + xmlKey = SnowDisplay.SNOW_DISP_WIND_GUST_SPEED.getXmlKey(); + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdwd.getWindGustR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdwd.getWindGustY()); + + /* + * Wind Direction From + */ + xmlKey = SnowDisplay.SNOW_DISP_WIND_DIR_FROM.getXmlKey(); + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdwd.getWindDirFromR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdwd.getWindDirFromY()); + + /* + * Wind Direction To + */ + xmlKey = SnowDisplay.SNOW_DISP_WIND_DIR_TO.getXmlKey(); + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + sdwd.getWindDirToR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + sdwd.getWindDirToY()); + } + } + + @Override + public void reloadData() { dataList.removeAll(); snowDataArray.clear(); snowDataArray = null; - + populateList(); } - - @Override - protected void editDataAction() - { - SnowDisplayWindData sdwd = getDataAtFirstSelection(); - - if (windEditDlg == null) - { - windEditDlg = new SnowDisplayWindEditDlg(getParent().getShell(), sdwd, this); - windEditDlg.open(); - windEditDlg = null; - } - } @Override - public void updateThresholdData(SnowDisplayWindData sdwd) - { + protected void editDataAction() { + SnowDisplayWindData sdwd = getDataAtFirstSelection(); + + if (windEditDlg == null) { + windEditDlg = new SnowDisplayWindEditDlg(getParent().getShell(), + sdwd, this); + windEditDlg.open(); + windEditDlg = null; + } + } + + @Override + public void updateThresholdData(SnowDisplayWindData sdwd) { updateDataArray(sdwd); populateList(); } } - diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitorMeteoTab.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitorMeteoTab.java old mode 100644 new mode 100755 index c55baca499..b008b51aaa --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitorMeteoTab.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitorMeteoTab.java @@ -28,339 +28,364 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants.SnowMonitor; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; import com.raytheon.uf.viz.monitor.data.RangesUtil; import com.raytheon.uf.viz.monitor.snow.threshold.SnowMonitorMeteoData; import com.raytheon.uf.viz.monitor.snow.threshold.SnowThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowMonitor; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; -public class SnowMonitorMeteoTab extends TabItemComp implements IUpdateMonitorMeteo -{ +/** + * SNOW Monitor Meteo Table. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 26, 2015 5115       skorolev    Corrected imports.
+ * 
+ * 
+ * + * @author skorolev + * @version 1.0 + */ +public class SnowMonitorMeteoTab extends TabItemComp implements + IUpdateMonitorMeteo { private SnowMonitorMeteoEditDlg meteoEditDlg; - + private ArrayList areaIDArray; - + private ArrayList snowDataArray; - - public SnowMonitorMeteoTab(TabFolder parent, DataUsageKey duKey) - { + + public SnowMonitorMeteoTab(TabFolder parent, DataUsageKey duKey) { super(parent, duKey); } - @Override - protected void createListHeader(Composite parentComp) - { + @Override + protected void createListHeader(Composite parentComp) { Composite lblComp = new Composite(parentComp, SWT.NONE); GridLayout gl = new GridLayout(5, false); - gl.horizontalSpacing = 0; + gl.horizontalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; lblComp.setLayout(gl); - + /* * Create filler label. */ GridData gd = new GridData(74, SWT.DEFAULT); Label fillerLbl = new Label(lblComp, SWT.CENTER); fillerLbl.setLayoutData(gd); - + /* * Monitor Meteo */ Composite meteoComp = createGroupComposite(lblComp, 7, null); createLabelComp(meteoComp, "Wind", "Speed(kt)", false); - createLabelComp(meteoComp, "Peak", "Wind(kt)", false); - createLabelComp(meteoComp, "Gust", "Speed(kt)", false); + createLabelComp(meteoComp, "Peak", "Wind(kt)", false); + createLabelComp(meteoComp, "Gust", "Speed(kt)", false); createLabelComp(meteoComp, "Temp(F)", "", false); - createLabelComp(meteoComp, "Wind", "Chill(F)", false); + createLabelComp(meteoComp, "Wind", "Chill(F)", false); createLabelComp(meteoComp, "Vis(mi)", "", true); createLabelComp(meteoComp, "Snow", "Depth(in)", false); - } - + } + @Override - protected void populateList() - { - if (snowDataArray == null) - { + protected void populateList() { + if (snowDataArray == null) { createDataArray(); } - + boolean update = false; - if (dataList.getItemCount() > 0) - { + if (dataList.getItemCount() > 0) { update = true; } - + RangesUtil rangeUtil = RangesUtil.getInstance(); - + areaIDArray = new ArrayList(); - + String tmpVisStr; String currentAreaID; - + double visVal = 0.0; - - StringBuilder sb = null; + + StringBuilder sb = null; SnowMonitorMeteoData smmd = null; - - for (int i = 0; i < snowDataArray.size(); i++) - { + + for (int i = 0; i < snowDataArray.size(); i++) { sb = new StringBuilder(); - + smmd = snowDataArray.get(i); - + currentAreaID = smmd.getAreaID(); areaIDArray.add(currentAreaID); - + sb.append(String.format(areaIdFmt, currentAreaID)); - + /* * Wind Speed */ appendIntData(sb, smmd.getWindSpeedR(), smmd.getWindSpeedY()); - + /* * Peak Wind */ appendIntData(sb, smmd.getPeakWindR(), smmd.getPeakWindY()); - + /* * Gust Speed */ appendIntData(sb, smmd.getGustSpeedR(), smmd.getGustSpeedY()); - + /* * Temperature */ appendIntData(sb, smmd.getTempR(), smmd.getTempY()); - + /* * Wind Chill */ appendIntData(sb, smmd.getWindChillR(), smmd.getWindChillY()); - + /* * Visibility - */ - visVal = smmd.getVisR(); - tmpVisStr = rangeUtil.getVisString((int)visVal); + */ + visVal = smmd.getVisR(); + tmpVisStr = rangeUtil.getVisString((int) visVal); sb.append(String.format(dataFmt, tmpVisStr)); - - visVal = smmd.getVisY(); - tmpVisStr = rangeUtil.getVisString((int)visVal); + + visVal = smmd.getVisY(); + tmpVisStr = rangeUtil.getVisString((int) visVal); sb.append(String.format(dataFmt, tmpVisStr)); - + /* * Snow Depth */ appendIntData(sb, smmd.getSnowDepthR(), smmd.getSnowDepthY()); - + /* * Append a space and add the data line to the list. */ sb.append(" "); - - if (update == true) - { + + if (update == true) { dataList.setItem(i, sb.toString()); - } - else - { + } else { dataList.add(sb.toString()); - } + } } - + packListControls(); } - - private void createDataArray() - { + + private void createDataArray() { snowDataArray = new ArrayList(); - - SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - + + SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); + String xmlKey; - String areaID; - + String areaID; + ThresholdsXML threshXML = stm.getThresholdsXmlData(duKey); - + ArrayList areasArray = threshXML.getAreas(); - - for (AreaXML area : areasArray) - { + + for (AreaXML area : areasArray) { areaID = area.getAreaId(); SnowMonitorMeteoData smmd = new SnowMonitorMeteoData(); - + smmd.setAreaID(areaID); - + /* * Wind Speed */ xmlKey = SnowMonitor.SNOW_MON_METEO_WIND_SPEED.getXmlKey(); - smmd.setWindSpeedR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - smmd.setWindSpeedY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + smmd.setWindSpeedR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + smmd.setWindSpeedY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); + /* * Peak Wind */ xmlKey = SnowMonitor.SNOW_MON_METEO_PEAK_WIND.getXmlKey(); - smmd.setPeakWindR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - smmd.setPeakWindY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + smmd.setPeakWindR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + smmd.setPeakWindY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); + /* * Gust Speed */ xmlKey = SnowMonitor.SNOW_MON_METEO_GUST_SPEED.getXmlKey(); - smmd.setGustSpeedR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - smmd.setGustSpeedY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + smmd.setGustSpeedR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + smmd.setGustSpeedY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); + /* * Temperature */ xmlKey = SnowMonitor.SNOW_MON_METEO_TEMP.getXmlKey(); - smmd.setTempR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - smmd.setTempY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + smmd.setTempR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + smmd.setTempY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); + /* * Wind Chill */ xmlKey = SnowMonitor.SNOW_MON_METEO_WIND_CHILL.getXmlKey(); - smmd.setWindChillR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - smmd.setWindChillY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + smmd.setWindChillR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + smmd.setWindChillY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); /* * Visibility */ xmlKey = SnowMonitor.SNOW_MON_METEO_VIS.getXmlKey(); - smmd.setVisR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - smmd.setVisY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + smmd.setVisR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + smmd.setVisY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); /* * Snow Depth */ xmlKey = SnowMonitor.SNOW_MON_METEO_SNOW_DEPTH.getXmlKey(); - smmd.setSnowDepthR(stm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); - smmd.setSnowDepthY(stm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); - + smmd.setSnowDepthR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + smmd.setSnowDepthY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); + /* * Add data to array. */ snowDataArray.add(smmd); } } - - private SnowMonitorMeteoData getDataAtFirstSelection() - { + + private SnowMonitorMeteoData getDataAtFirstSelection() { int index = dataList.getSelectionIndex(); - - return snowDataArray.get(index); + + return snowDataArray.get(index); } - - private void updateDataArray(SnowMonitorMeteoData smmd) - { - int[] dataListIndexes = dataList.getSelectionIndices(); + + private void updateDataArray(SnowMonitorMeteoData smmd) { + int[] dataListIndexes = dataList.getSelectionIndices(); int currentIndex = 0; - - for (int i = 0; i < dataListIndexes.length; i++) - { + + for (int i = 0; i < dataListIndexes.length; i++) { currentIndex = dataListIndexes[i]; - + snowDataArray.get(currentIndex).updateData(smmd); - } + } } - + @Override - public void commitDataToXML() - { + public void commitDataToXML() { SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - + String xmlKey; String areaID; - - for (SnowMonitorMeteoData smmd : snowDataArray) - { + + for (SnowMonitorMeteoData smmd : snowDataArray) { areaID = smmd.getAreaID(); - + /* * Wind Speed */ xmlKey = SnowMonitor.SNOW_MON_METEO_WIND_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, smmd.getWindSpeedR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, smmd.getWindSpeedY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + smmd.getWindSpeedR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + smmd.getWindSpeedY()); + /* * Peak Wind */ xmlKey = SnowMonitor.SNOW_MON_METEO_PEAK_WIND.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, smmd.getPeakWindR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, smmd.getPeakWindY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + smmd.getPeakWindR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + smmd.getPeakWindY()); + /* * Gust Speed */ xmlKey = SnowMonitor.SNOW_MON_METEO_GUST_SPEED.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, smmd.getGustSpeedR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, smmd.getGustSpeedY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + smmd.getGustSpeedR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + smmd.getGustSpeedY()); + /* * Temperature */ xmlKey = SnowMonitor.SNOW_MON_METEO_TEMP.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, smmd.getTempR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, smmd.getTempY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + smmd.getTempR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + smmd.getTempY()); + /* * Wind Chill */ xmlKey = SnowMonitor.SNOW_MON_METEO_WIND_CHILL.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, smmd.getWindChillR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, smmd.getWindChillY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + smmd.getWindChillR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + smmd.getWindChillY()); + /* * Visibility */ xmlKey = SnowMonitor.SNOW_MON_METEO_VIS.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, smmd.getVisR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, smmd.getVisY()); - + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + smmd.getVisR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + smmd.getVisY()); + /* * Snow Depth */ xmlKey = SnowMonitor.SNOW_MON_METEO_SNOW_DEPTH.getXmlKey(); - stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, smmd.getSnowDepthR()); - stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, smmd.getSnowDepthY()); + stm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + smmd.getSnowDepthR()); + stm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + smmd.getSnowDepthY()); } } @Override - public void reloadData() - { + public void reloadData() { dataList.removeAll(); snowDataArray.clear(); snowDataArray = null; - - populateList(); + + populateList(); } @Override - protected void editDataAction() - { + protected void editDataAction() { SnowMonitorMeteoData smmd = getDataAtFirstSelection(); - - if (meteoEditDlg == null) - { - meteoEditDlg = new SnowMonitorMeteoEditDlg(getParent().getShell(), smmd, this); + + if (meteoEditDlg == null) { + meteoEditDlg = new SnowMonitorMeteoEditDlg(getParent().getShell(), + smmd, this); meteoEditDlg.open(); meteoEditDlg = null; } } - + @Override - public void updateThresholdData(SnowMonitorMeteoData smmd) - { + public void updateThresholdData(SnowMonitorMeteoData smmd) { updateDataArray(smmd); populateList(); } diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java index 22f91c669e..2691aa883f 100755 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java @@ -27,7 +27,6 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; @@ -56,6 +55,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Oct 27, 2014 3667 skorolev Cleaned code. * Feb 10, 2015 3886 skorolev Changed confirmation message. * Aug 17, 2015 3841 skorolev Corrected handleOkBtnSelection. + * Jan 04, 2016 5115 skorolev Corrected imports and replaced AppName with MonName. + * * * * @author mpduff @@ -137,7 +138,7 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { protected FSSObsMonitorConfigurationManager getInstance() { if (configMgr == null) { configMgr = FSSObsMonitorConfigurationManager - .getInstance(MonName.snow); + .getInstance(AppName.SNOW); } return configMgr; } diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowZoneTableDlg.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowZoneTableDlg.java old mode 100755 new mode 100644 index 3634639818..8b65b6848a --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowZoneTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowZoneTableDlg.java @@ -26,8 +26,8 @@ import java.util.List; import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; +import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.common.monitor.data.ObConst.DisplayVarName; import com.raytheon.uf.viz.monitor.IMonitor; @@ -57,6 +57,7 @@ import com.raytheon.uf.viz.monitor.ui.dialogs.ZoneTableDlg; * Sep 04, 2014 3220 skorolev Removed "site". Added check on dispose. * Sep 18, 2015 3873 skorolev Adjusted to AppName and MonName. * Dec 17, 2015 3873 dhladky Abstracted handling of dialogTime and Zone dialog events. + * Jan 04, 2016 5115 skorolev Corrected imports and replaced AppName with MonName. * * * @@ -264,7 +265,7 @@ public class SnowZoneTableDlg extends ZoneTableDlg { protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() { if (configMgr == null || configMgr.isPopulated()) { configMgr = FSSObsMonitorConfigurationManager - .getInstance(MonName.snow); + .getInstance(AppName.SNOW); } return configMgr; } diff --git a/cave/com.raytheon.uf.viz.monitor/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.monitor/META-INF/MANIFEST.MF index b4e473be09..c6da873345 100644 --- a/cave/com.raytheon.uf.viz.monitor/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.monitor/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Monitor Plug-in Bundle-SymbolicName: com.raytheon.uf.viz.monitor;singleton:=true -Bundle-Version: 1.14.0.qualifier +Bundle-Version: 1.15.0.qualifier Bundle-Activator: com.raytheon.uf.viz.monitor.Activator Bundle-Vendor: RAYTHEON Require-Bundle: org.eclipse.ui, @@ -13,7 +13,6 @@ Require-Bundle: org.eclipse.ui, org.geotools;bundle-version="2.4.0", com.raytheon.viz.alerts;bundle-version="1.10.13", com.raytheon.uf.common.monitor;bundle-version="1.11.17", - org.apache.commons.lang;bundle-version="2.3.0", com.raytheon.uf.common.wxmath Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.uf.viz.monitor, diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObMultiHrsReports.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObMultiHrsReports.java index 9fe3d14901..ac87f6a8c5 100755 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObMultiHrsReports.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObMultiHrsReports.java @@ -32,7 +32,6 @@ import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.ObConst; @@ -60,7 +59,8 @@ import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr; * Sep 04, 2014 3220 skorolev Updated getStationTableData method. * Sep 25, 2015 3873 skorolev Added multiHrsTabData. * Nov 12, 2015 3841 dhladky Augmented Slav's update fix. - * Dec 02 2015 3873 dhladky Pulled 3841 changes to 16.1.1. + * Dec 02 2015 3873 dhladky Pulled 3841 changes to 16.1.1. + * Jan 04, 2016 5115 skorolev Replaced Mon.Name with App.Name. * Jan 11 2016 5219 dhladky Fixed damage done to cache management by recent updates. * * @@ -84,7 +84,7 @@ public class ObMultiHrsReports { /** * application name (snow, fog, safeseas, etc) */ - private CommonConfig.AppName appName; + private final CommonConfig.AppName appName; /** * FSSObs records cache. Key is nominal time, value is ObHourReports object @@ -96,7 +96,7 @@ public class ObMultiHrsReports { */ private ConcurrentHashMap multiHrsTabData = new ConcurrentHashMap(); - private int maxFrames = ObConst.MAX_FRAMES; + private final int maxFrames = ObConst.MAX_FRAMES; private FSSObsMonitorConfigurationManager cfgMgr = null; @@ -107,15 +107,8 @@ public class ObMultiHrsReports { */ public ObMultiHrsReports(CommonConfig.AppName appName) { this.appName = appName; - if (appName.equals(AppName.FOG) || appName.equals(AppName.SAFESEAS)) { - if (appName.equals(AppName.FOG)) { - cfgMgr = FSSObsMonitorConfigurationManager - .getInstance(MonName.fog); - } else if (appName.equals(AppName.SAFESEAS)) { - cfgMgr = FSSObsMonitorConfigurationManager - .getInstance(MonName.ss); - } + cfgMgr = FSSObsMonitorConfigurationManager.getInstance(appName); initFogAlgCellType(); } } @@ -128,7 +121,7 @@ public class ObMultiHrsReports { */ public void addReport(ObReport report) { Date nominalTime = report.getRefHour(); - + /** * DR #8723: if wind speed is zero, wind direction should be N/A, not 0 */ @@ -616,7 +609,8 @@ public class ObMultiHrsReports { * Updates table cache */ public void updateTableCache() { - // rebuild the table cache + // clear and rebuild table data on config changes + multiHrsTabData.clear(); for (Date time : multiHrsReports.keySet()) { getZoneTableData(time); } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObTrendDataSet.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObTrendDataSet.java old mode 100644 new mode 100755 index d507935143..792f5456d6 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObTrendDataSet.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObTrendDataSet.java @@ -25,13 +25,16 @@ import java.util.TreeMap; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants; import com.raytheon.uf.common.monitor.data.ObConst; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.common.monitor.data.ObConst.ProductName; import com.raytheon.uf.common.monitor.data.ObConst.VarName; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr; import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr.ThresholdKey; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; + /** * This class models data for a SNOW/FOG/SAFESEAS trending plot. * @@ -40,7 +43,8 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Dec. 23, 2009 3424 zhao Initial creation. + * Dec.23, 2009 3424 zhao Initial creation. + * Dec 26, 2015 5114 skorolev Replaced MonitorConfigConstants import. * * * @@ -49,6 +53,8 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; */ public class ObTrendDataSet { + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(ObTrendDataSet.class); /** * application name (snow, fog, safeseas, etc) @@ -64,11 +70,12 @@ public class ObTrendDataSet { * the enumerated type representation of the trending variable */ private final ObConst.VarName varName; - + /** - * the enumerated type representation of product name for a trending variable + * the enumerated type representation of product name for a trending + * variable */ - private final ObConst.ProductName productName; + private final ObConst.ProductName productName; /** * the red threshold @@ -125,8 +132,9 @@ public class ObTrendDataSet { * @param appName * application name (snow, fog, safeseas) of enumerated-type */ - public ObTrendDataSet(String zone, ObConst.VarName varName, ObConst.ProductName productName, - CommonConfig.AppName appName, AbstractThresholdMgr thresholdMgr) { + public ObTrendDataSet(String zone, ObConst.VarName varName, + ObConst.ProductName productName, CommonConfig.AppName appName, + AbstractThresholdMgr thresholdMgr) { this.zone = zone; this.varName = varName; @@ -146,138 +154,138 @@ public class ObTrendDataSet { redThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.RED, zone, MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_VIS - .getXmlKey()) / 16; + .getXmlKey()) / 16; yellowThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.YELLOW, zone, MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_VIS - .getXmlKey()) / 16; + .getXmlKey()) / 16; } else if (varName == VarName.CEILING) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_CEILING - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_CEILING + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_CEILING - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_CEILING + .getXmlKey()); } else if (varName == VarName.WIND_DIR) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_DIR_FROM - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_DIR_FROM + .getXmlKey()); redThreshold_2 = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.RED, zone, MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_DIR_TO - .getXmlKey()); + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_DIR_FROM - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_DIR_FROM + .getXmlKey()); yellowThreshold_2 = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.YELLOW, zone, MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_DIR_TO - .getXmlKey()); + .getXmlKey()); } else if (varName == VarName.WIND_SPEED) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_WIND_SPEED - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_WIND_SPEED + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_WIND_SPEED - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_WIND_SPEED + .getXmlKey()); } else if (varName == VarName.MAX_WIND_SPEED) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_PEAK_WIND - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_PEAK_WIND + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_PEAK_WIND - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_PEAK_WIND + .getXmlKey()); } else if (varName == VarName.GUST_SPEED) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_GUST_SPEED - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_GUST_SPEED + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_GUST_SPEED - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_GUST_SPEED + .getXmlKey()); } else if (varName == VarName.TEMPERATURE) { redThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.RED, zone, MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_TEMP - .getXmlKey()); + .getXmlKey()); yellowThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.YELLOW, zone, MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_TEMP - .getXmlKey()); + .getXmlKey()); } else if (varName == VarName.DEWPOINT) { redThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.RED, zone, MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_DEWPT - .getXmlKey()); + .getXmlKey()); yellowThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.YELLOW, zone, MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_DEWPT - .getXmlKey()); + .getXmlKey()); } else if (varName == VarName.DEWPOINT_DEPR) { redThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.RED, zone, MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_T_TD - .getXmlKey()); + .getXmlKey()); yellowThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.YELLOW, zone, MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_T_TD - .getXmlKey()); + .getXmlKey()); } else if (varName == VarName.RELATIVE_HUMIDITY) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_REL_HUMIDITY - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_REL_HUMIDITY + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_REL_HUMIDITY - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_REL_HUMIDITY + .getXmlKey()); } else { - System.err.println("Unknow variable name = " + varName + statusHandler.warn("Unknow variable name = " + varName + " for FOG trend plot"); } @@ -285,212 +293,212 @@ public class ObTrendDataSet { if (varName == VarName.WIND_DIR) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_DIR_FROM - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_DIR_FROM + .getXmlKey()); redThreshold_2 = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_DIR_TO - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_DIR_TO + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_DIR_FROM - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_DIR_FROM + .getXmlKey()); yellowThreshold_2 = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_DIR_TO - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_DIR_TO + .getXmlKey()); } else if (varName == VarName.WIND_SPEED) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_WIND_SPEED - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_WIND_SPEED + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_WIND_SPEED - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_WIND_SPEED + .getXmlKey()); } else if (varName == VarName.MAX_WIND_SPEED) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_PEAK_WIND - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_PEAK_WIND + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_PEAK_WIND - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_PEAK_WIND + .getXmlKey()); } else if (varName == VarName.GUST_SPEED) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_GUST_SPEED - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_GUST_SPEED + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_GUST_SPEED - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_GUST_SPEED + .getXmlKey()); } else if (varName == VarName.TEMPERATURE) { redThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.RED, zone, MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_TEMP - .getXmlKey()); + .getXmlKey()); yellowThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.YELLOW, zone, MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_TEMP - .getXmlKey()); + .getXmlKey()); } else if (varName == VarName.DEWPOINT) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_DEWPT - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_DEWPT + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_DEWPT - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_DEWPT + .getXmlKey()); } else if (varName == VarName.VISIBILITY) { redThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.RED, zone, MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_VIS - .getXmlKey()) / 16; + .getXmlKey()) / 16; yellowThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.YELLOW, zone, MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_VIS - .getXmlKey()) / 16; + .getXmlKey()) / 16; } else if (varName == VarName.SEA_LEVEL_PRESS) { redThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.RED, zone, MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SLP - .getXmlKey()); + .getXmlKey()); yellowThreshold = (float) thresholdMgr.getThresholdValue( DataUsageKey.DISPLAY, ThresholdKey.YELLOW, zone, MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SLP - .getXmlKey()); + .getXmlKey()); } else if (varName == VarName.WIND_CHILL) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_WIND_CHILL - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_WIND_CHILL + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_WIND_CHILL - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_WIND_CHILL + .getXmlKey()); } else if (varName == VarName.FROSTBITE_TIME) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_FROSTBITE - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_FROSTBITE + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_FROSTBITE - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_FROSTBITE + .getXmlKey()); } else if (varName == VarName.HOURLY_PRECIP) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_HOURLY_PRECIP - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_HOURLY_PRECIP + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_HOURLY_PRECIP - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_HOURLY_PRECIP + .getXmlKey()); } else if (varName == VarName.SNOW_DEPTH) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SNOW_DEPTH - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SNOW_DEPTH + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SNOW_DEPTH - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SNOW_DEPTH + .getXmlKey()); } else if (varName == VarName.SNINCR_HOURLY) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SNINCR_HOURLY - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SNINCR_HOURLY + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SNINCR_HOURLY - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SNINCR_HOURLY + .getXmlKey()); } else if (varName == VarName.SNINCR_TOTAL) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SNINCR_TOTAL - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SNINCR_TOTAL + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SNINCR_TOTAL - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_SNINCR_TOTAL + .getXmlKey()); } else { - System.err.println("Unknow variable name = " + varName + statusHandler.warn("Unknow variable name = " + varName + " for SNOW trend plot"); } @@ -498,302 +506,506 @@ public class ObTrendDataSet { if (varName == VarName.WIND_DIR) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_DIR_FROM - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_DIR_FROM + .getXmlKey()); redThreshold_2 = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_DIR_TO - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_DIR_TO + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_DIR_FROM - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_DIR_FROM + .getXmlKey()); yellowThreshold_2 = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_DIR_TO - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_DIR_TO + .getXmlKey()); } else if (varName == VarName.WIND_SPEED) { - if ( productName == ProductName.SCA ) { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_WIND_SPEED.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_WIND_SPEED.getXmlKey()); - } else if ( productName == ProductName.GALE_WARNING ) { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_GALE_WIND_SPEED.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_GALE_WIND_SPEED.getXmlKey()); - } else if ( productName == ProductName.STORM_WARNING ) { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_STORM_WIND_SPEED.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_STORM_WIND_SPEED.getXmlKey()); - } else if ( productName == ProductName.HFWW ) { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_HFWW_WIND_SPEED.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_HFWW_WIND_SPEED.getXmlKey()); - } else { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_WIND_SPEED.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_WIND_SPEED.getXmlKey()); - } + if (productName == ProductName.SCA) { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_WIND_SPEED + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_WIND_SPEED + .getXmlKey()); + } else if (productName == ProductName.GALE_WARNING) { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_GALE_WIND_SPEED + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_GALE_WIND_SPEED + .getXmlKey()); + } else if (productName == ProductName.STORM_WARNING) { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_STORM_WIND_SPEED + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_STORM_WIND_SPEED + .getXmlKey()); + } else if (productName == ProductName.HFWW) { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_HFWW_WIND_SPEED + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_HFWW_WIND_SPEED + .getXmlKey()); + } else { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_WIND_SPEED + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_WIND_SPEED + .getXmlKey()); + } } else if (varName == VarName.MAX_WIND_SPEED) { - if ( productName == ProductName.SCA ) { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_PEAK_WIND.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_PEAK_WIND.getXmlKey()); - } else if ( productName == ProductName.GALE_WARNING ) { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_GALE_PEAK_WIND.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_GALE_PEAK_WIND.getXmlKey()); - } else if ( productName == ProductName.STORM_WARNING ) { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_STORM_PEAK_WIND.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_STORM_PEAK_WIND.getXmlKey()); - } else if ( productName == ProductName.HFWW ) { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_HFWW_PEAK_WIND.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_HFWW_PEAK_WIND.getXmlKey()); - } else { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_PEAK_WIND.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_PEAK_WIND.getXmlKey()); - } + if (productName == ProductName.SCA) { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_PEAK_WIND + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_PEAK_WIND + .getXmlKey()); + } else if (productName == ProductName.GALE_WARNING) { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_GALE_PEAK_WIND + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_GALE_PEAK_WIND + .getXmlKey()); + } else if (productName == ProductName.STORM_WARNING) { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_STORM_PEAK_WIND + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_STORM_PEAK_WIND + .getXmlKey()); + } else if (productName == ProductName.HFWW) { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_HFWW_PEAK_WIND + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_HFWW_PEAK_WIND + .getXmlKey()); + } else { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_PEAK_WIND + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_PEAK_WIND + .getXmlKey()); + } } else if (varName == VarName.GUST_SPEED) { - if ( productName == ProductName.SCA ) { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_GUST_SPEED.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_GUST_SPEED.getXmlKey()); - } else if ( productName == ProductName.GALE_WARNING ) { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_GALE_GUST_SPEED.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_GALE_GUST_SPEED.getXmlKey()); - } else if ( productName == ProductName.STORM_WARNING ) { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_STORM_GUST_SPEED.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_STORM_GUST_SPEED.getXmlKey()); - } else if ( productName == ProductName.HFWW ) { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_HFWW_GUST_SPEED.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_HFWW_GUST_SPEED.getXmlKey()); - } else { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_GUST_SPEED.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_GUST_SPEED.getXmlKey()); - } + if (productName == ProductName.SCA) { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_GUST_SPEED + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_GUST_SPEED + .getXmlKey()); + } else if (productName == ProductName.GALE_WARNING) { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_GALE_GUST_SPEED + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_GALE_GUST_SPEED + .getXmlKey()); + } else if (productName == ProductName.STORM_WARNING) { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_STORM_GUST_SPEED + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_STORM_GUST_SPEED + .getXmlKey()); + } else if (productName == ProductName.HFWW) { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_HFWW_GUST_SPEED + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_HFWW_GUST_SPEED + .getXmlKey()); + } else { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_GUST_SPEED + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_GUST_SPEED + .getXmlKey()); + } } else if (varName == VarName.VISIBILITY) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_VIS - .getXmlKey()) / 16; + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_VIS + .getXmlKey()) / 16; yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_VIS - .getXmlKey()) / 16; + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_VIS + .getXmlKey()) / 16; } else if (varName == VarName.TEMPERATURE) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_TEMP - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_TEMP + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_TEMP - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_TEMP + .getXmlKey()); } else if (varName == VarName.DEWPOINT) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_DEWPT - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_DEWPT + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_DEWPT - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_DEWPT + .getXmlKey()); } else if (varName == VarName.SEA_LEVEL_PRESS) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_SLP - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_SLP + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_SLP - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_SLP + .getXmlKey()); } else if (varName == VarName.SEA_SURFACE_TEMPERATURE) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_SST - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_SST + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_SST - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_SST + .getXmlKey()); } else if (varName == VarName.WAVE_HEIGHT) { - if ( productName == ProductName.SCA ) { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_WAVE_HT.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_WAVE_HT.getXmlKey()); - } else { - redThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.RED,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_WAVE_HT.getXmlKey()); - yellowThreshold = (float) thresholdMgr.getThresholdValue(DataUsageKey.DISPLAY,ThresholdKey.YELLOW,zone,MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_WAVE_HT.getXmlKey()); - } + if (productName == ProductName.SCA) { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_WAVE_HT + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_PROD_SCA_WAVE_HT + .getXmlKey()); + } else { + redThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_WAVE_HT + .getXmlKey()); + yellowThreshold = (float) thresholdMgr + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_WAVE_HT + .getXmlKey()); + } } else if (varName == VarName.WAVE_STEEPNESS) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_WAVE_STEEP - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_WAVE_STEEP + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_WAVE_STEEP - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_WAVE_STEEP + .getXmlKey()); } else if (varName == VarName.PRIM_SWELL_HT) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_HT - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_HT + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_HT - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_HT + .getXmlKey()); } else if (varName == VarName.PRIM_SWELL_PD) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_PD - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_PD + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_PD - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_PD + .getXmlKey()); } else if (varName == VarName.PRIM_SWELL_DIR) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_FROM - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_FROM + .getXmlKey()); redThreshold_2 = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_TO - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_TO + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_FROM - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_FROM + .getXmlKey()); yellowThreshold_2 = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_TO - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_TO + .getXmlKey()); } else if (varName == VarName.SEC_SWELL_HT) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_HT - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_HT + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_HT - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_HT + .getXmlKey()); } else if (varName == VarName.SEC_SWELL_PD) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_PD - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_PD + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_PD - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_PD + .getXmlKey()); } else if (varName == VarName.SEC_SWELL_DIR) { redThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_FROM - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_FROM + .getXmlKey()); redThreshold_2 = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.RED, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_TO - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.RED, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_TO + .getXmlKey()); yellowThreshold = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_FROM - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_FROM + .getXmlKey()); yellowThreshold_2 = (float) thresholdMgr - .getThresholdValue( - DataUsageKey.DISPLAY, - ThresholdKey.YELLOW, - zone, - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_TO - .getXmlKey()); + .getThresholdValue( + DataUsageKey.DISPLAY, + ThresholdKey.YELLOW, + zone, + MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_TO + .getXmlKey()); } else { - System.err.println("Unknow variable name = " + varName + statusHandler.warn("Unknow variable name = " + varName + " for SAFESEAS trend plot"); } @@ -811,11 +1023,11 @@ public class ObTrendDataSet { */ public void addDataPoint(Date obsTime, Float varValue) { if (varName == VarName.VISIBILITY && appName == AppName.SAFESEAS) { - if (varValue != ObConst.MISSING) { - varValue = varValue / TableUtil.milesPerNauticalMile; - } else { - varValue = ObConst.MISSING; - } + if (varValue != ObConst.MISSING) { + varValue = varValue / TableUtil.milesPerNauticalMile; + } else { + varValue = ObConst.MISSING; + } } // miss CLR and SKC in the Trend plot. if (varName == VarName.CEILING) { @@ -958,27 +1170,28 @@ public class ObTrendDataSet { float min = minValue; float max = maxValue; - //Adjust the min/max value, so it will at least cover two colors (red/yellow/green) - //there are six different cases: 1 above + 5 below - if (maxValue <= lowerThreshold) //values are below the lower threshold - max = lowerThreshold * 1.1f; - else if (minValue >= upperThreshold) //values are above upper threshold - min = upperThreshold * .9f; + // Adjust the min/max value, so it will at least cover two colors + // (red/yellow/green) + // there are six different cases: 1 above + 5 below + if (maxValue <= lowerThreshold) // values are below the lower threshold + max = lowerThreshold * 1.1f; + else if (minValue >= upperThreshold) // values are above upper threshold + min = upperThreshold * .9f; else if (maxValue < upperThreshold) { - max = upperThreshold ; //values covers across the lower threshold - if (minValue >= lowerThreshold) - min = lowerThreshold * .9f; //values are within the thresholds + max = upperThreshold; // values covers across the lower threshold + if (minValue >= lowerThreshold) + min = lowerThreshold * .9f; // values are within the thresholds } else if (minValue > lowerThreshold) - min = lowerThreshold; //values cover across the upper threshold + min = lowerThreshold; // values cover across the upper threshold float range = max - min; if (range > 5) { if (range > 1000) { increment = 200; } else if (range > 500) { - increment = 100; + increment = 100; } else if (range > 200) { - increment = 50; + increment = 50; } else if (range > 100) { increment = 20; } else if (range > 50) { @@ -989,8 +1202,8 @@ public class ObTrendDataSet { increment = 2; } - lowerLimit = (int)min; - upperLimit = (int)max; + lowerLimit = (int) min; + upperLimit = (int) max; if (lowerLimit > min) { lowerLimit -= increment; } @@ -1012,9 +1225,9 @@ public class ObTrendDataSet { } increment = 1000 * increment; lowerLimit = Float.valueOf(min * 1000) / increment * increment - * 0.001f; + * 0.001f; upperLimit = Float.valueOf(max * 1000) / increment * increment - * 0.001f; + * 0.001f; increment = increment / 1000; if (lowerLimit > min) { lowerLimit -= increment; @@ -1030,9 +1243,9 @@ public class ObTrendDataSet { } increment = 10 * increment; lowerLimit = Float.valueOf(min * 10) / increment * increment - * 0.1f; + * 0.1f; upperLimit = Float.valueOf(max * 10) / increment * increment - * 0.1f; + * 0.1f; increment = increment / 10; if (lowerLimit > min) { lowerLimit -= increment; diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObZoneHourReports.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObZoneHourReports.java index 649955f0d9..58c03bb87e 100755 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObZoneHourReports.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObZoneHourReports.java @@ -25,13 +25,13 @@ import java.util.List; import java.util.Map; import com.raytheon.uf.common.monitor.data.CommonConfig; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants; import com.raytheon.uf.common.monitor.data.ObConst; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.monitor.config.CommonTableConfig.CellType; import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; /** * This class is a container of ObStnHourReports objects for caller-specified @@ -46,6 +46,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; * Dec. 1, 2009 3424 zhao Initial creation. * Jan 25, 2010 4281 zhao Modified updateWorstValuesFog method. * Sep 18, 2015 3873 skorolev Added moving platform's reports.Replaced MonitoringArea with areaConfig. + * Dec 26, 2015 5114 skorolev Replaced MonitorConfigConstants import. * * * @@ -62,16 +63,16 @@ public class ObZoneHourReports { private Date nominalTime; /** Monitoring area */ - private String zone; + private final String zone; /** Thresholds manager */ - private AbstractThresholdMgr thresholdMgr; + private final AbstractThresholdMgr thresholdMgr; /** application name (snow, fog, safeseas, etc) */ - private CommonConfig.AppName appName; + private final CommonConfig.AppName appName; /** key is station id, value is ObStnHourReports object */ - private HashMap zoneHourReports; + private final HashMap zoneHourReports; /** * this object stores worst values of the observation variables reported diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/TableUtil.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/TableUtil.java index b51298a54b..754e65871b 100755 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/TableUtil.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/TableUtil.java @@ -29,6 +29,7 @@ import com.raytheon.uf.common.geospatial.SpatialQueryFactory; import com.raytheon.uf.common.monitor.MonitorAreaUtils; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants; import com.raytheon.uf.common.monitor.data.ObConst; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.common.monitor.xml.AreaIdXML; @@ -38,7 +39,6 @@ import com.raytheon.uf.viz.monitor.config.CommonTableConfig; import com.raytheon.uf.viz.monitor.config.CommonTableConfig.CellType; import com.raytheon.uf.viz.monitor.config.CommonTableConfig.ObsHistType; import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; /** * Moved some common utility methods related to @@ -57,6 +57,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; * May 23, 2014 3086 skorolev Corrected ObsHistType. Cleaned code. * Sep 18, 2015 3873 skorolev Added coordinates in the hover text for a newly added zones.Corrected code for Fog and SNOW table data. * Oct 22, 2015 3873 dhladky Cached off the zone/station hover texts. + * Dec 26, 2015 5114 skorolev Replaced MonitorConfigConstants import. * * * @@ -68,18 +69,19 @@ public final class TableUtil { private static final IUFStatusHandler statusHandler = UFStatus .getHandler(TableUtil.class); - + /** Conversion coefficient of nautical miles to statute miles. */ public static final float milesPerNauticalMile = 1.15078f; /** Singleton instance of this class */ private static TableUtil tableUtil = new TableUtil(); + /** Hover text lookup map **/ public Map zoneHoverTextMap = null; + /** station text lookup map **/ public Map stationHoverTextMap = null; - /** * Actual initialization if necessary * @@ -92,12 +94,12 @@ public final class TableUtil { return tableUtil; } - + private TableUtil() { zoneHoverTextMap = new ConcurrentHashMap(); stationHoverTextMap = new ConcurrentHashMap(); } - + /** * Returns the nominal time for a caller-specified time (to be consistent * with D2D, here "Nominal time" is defined as the hour of an one-hour @@ -1005,9 +1007,9 @@ public final class TableUtil { String zone = zoneXML.getAreaId(); String hoverText = tableUtil.zoneHoverTextMap.get(zone); - + if (hoverText == null) { - + ISpatialQuery sq = null; String sql = null; hoverText = zone.substring(0, 2) + ", "; @@ -1035,7 +1037,7 @@ public final class TableUtil { Object[] res = (Object[]) results[0]; hoverText += (String) res[0]; } else { - hoverText += (String) results[0].toString(); + hoverText += results[0].toString(); } } else { if (zoneXML.getCLat() != null) { @@ -1044,9 +1046,10 @@ public final class TableUtil { } } } catch (Exception e) { - statusHandler.error("Unable to query Zone Hover Text: sql: "+sql, e); + statusHandler.error("Unable to query Zone Hover Text: sql: " + + sql, e); } - + tableUtil.zoneHoverTextMap.put(zone, hoverText); } @@ -1061,14 +1064,13 @@ public final class TableUtil { */ private static String getStationHoverText(String stnId) { - String hoverText = tableUtil.stationHoverTextMap.get(stnId); - + if (hoverText == null) { - + String sql = "select catalogtype, name from common_obs_spatial where ( catalogtype=1 or catalogtype=33 or catalogtype = 32 or catalogtype=1000) and stationid = '" + stnId + "'"; - + ISpatialQuery sq = null; Integer stnType = null; String stnName = null; @@ -1097,12 +1099,13 @@ public final class TableUtil { } } catch (Exception e) { - statusHandler.error("Unable to query Station Hover Text: sql: "+sql, e); + statusHandler.error("Unable to query Station Hover Text: sql: " + + sql, e); } tableUtil.stationHoverTextMap.put(stnId, hoverText); } - + return hoverText; } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/AbstractThresholdMgr.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/AbstractThresholdMgr.java index 0d933eb8c5..45da73458a 100755 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/AbstractThresholdMgr.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/AbstractThresholdMgr.java @@ -31,20 +31,20 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; +import com.raytheon.uf.common.monitor.config.ThresholdMgr; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants; import com.raytheon.uf.common.monitor.data.ObConst; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; +import com.raytheon.uf.common.monitor.xml.AreaThresholdXML; +import com.raytheon.uf.common.monitor.xml.AreaXML; +import com.raytheon.uf.common.monitor.xml.ThresholdsXML; 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.localization.LocalizationManager; import com.raytheon.uf.viz.monitor.config.CommonTableConfig.CellType; import com.raytheon.uf.viz.monitor.filename.DefaultFilenameMgr; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; -import com.raytheon.uf.viz.monitor.xml.AreaThresholdXML; -import com.raytheon.uf.viz.monitor.xml.AreaXML; -import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; /** * Abstract threshold manager class used for FOG, SNOW, and SAFESEAS. @@ -59,6 +59,7 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; * Feb 16, 2011 #7346 zhao added getDirectionalThresholdValueCellType(...) * Apr 28, 2014 3086 skorolev Updated getAreaConfigMgr method. * Sep 18, 2015 3873 skorolev Added getCfgMgr(). + * Dec 26, 2015 5114 skorolev Corrected imports and file path for default thresholds. * * * @@ -159,7 +160,7 @@ public abstract class AbstractThresholdMgr { */ if (defaultFileNameMgr.getDefaultThresholdFilename() != null && defaultFileNameMgr.getDefaultThresholdFilename().length() > 0) { - boolean fileNameValid = validateFileName(getDisplayThresholdPath() + boolean fileNameValid = validateFileName(getThresholdPath(DataUsageKey.DISPLAY) + defaultFileNameMgr.getDefaultThresholdFilename()); if (defaultFileNameMgr.getDefaultThresholdFilename().compareTo( @@ -169,13 +170,13 @@ public abstract class AbstractThresholdMgr { displayThreshMgr = new ThresholdMgr(currFullDisplayXmlFileName); loadDefaultDisplayThreshold(); } else { - currFullDisplayXmlFileName = getDisplayThresholdPath() + currFullDisplayXmlFileName = getThresholdPath(DataUsageKey.DISPLAY) + defaultFileNameMgr.getDefaultThresholdFilename(); displayThreshMgr = new ThresholdMgr(currFullDisplayXmlFileName); displayThreshMgr.readThresholdXml(); } } else { - currFullDisplayXmlFileName = getDisplayThresholdPath() + currFullDisplayXmlFileName = getThresholdPath(DataUsageKey.DISPLAY) + defDisplayThreshName; displayThreshMgr = new ThresholdMgr(currFullDisplayXmlFileName); loadDefaultDisplayThreshold(); @@ -184,7 +185,7 @@ public abstract class AbstractThresholdMgr { /* * Setup the monitor threshold manager */ - currFullMonitorXmlFileName = getMonitorThresholdPath() + currFullMonitorXmlFileName = getThresholdPath(DataUsageKey.MONITOR) + defMonitorThreshName; monitorThreshMgr = new ThresholdMgr(currFullMonitorXmlFileName); @@ -204,7 +205,7 @@ public abstract class AbstractThresholdMgr { private boolean validateFileName(String pathAndFileName) { IPathManager pm = PathManagerFactory.getPathManager(); LocalizationContext context = pm.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.SITE); + LocalizationType.COMMON_STATIC, LocalizationLevel.SITE); LocalizationFile locFile = pm.getLocalizationFile(context, pathAndFileName); @@ -456,7 +457,7 @@ public abstract class AbstractThresholdMgr { public void setDefaultDisplayFileName(String fileName) { if (fileName == null) { defaultFileNameMgr.setDefaultThresholdFilename(""); - currFullDisplayXmlFileName = getDisplayThresholdPath() + currFullDisplayXmlFileName = getThresholdPath(DataUsageKey.DISPLAY) + defDisplayThreshName; return; } @@ -481,7 +482,8 @@ public abstract class AbstractThresholdMgr { loadDefaultDisplayThreshold(); return; } - currFullDisplayXmlFileName = getDisplayThresholdPath() + fileName; + currFullDisplayXmlFileName = getThresholdPath(DataUsageKey.DISPLAY) + + fileName; displayThreshMgr.setFullPathFileName(currFullDisplayXmlFileName); displayThreshMgr.readThresholdXml(); } @@ -493,7 +495,7 @@ public abstract class AbstractThresholdMgr { String filename = defaultFileNameMgr.getDefaultThresholdFilename(); if (filename == null || filename.trim().length() == 0) { - currFullDisplayXmlFileName = getDisplayThresholdPath() + currFullDisplayXmlFileName = getThresholdPath(DataUsageKey.DISPLAY) + defDisplayThreshName; List areaIDs = null; try { @@ -507,10 +509,11 @@ public abstract class AbstractThresholdMgr { ArrayList threshKeys = getThresholdKeys(DataUsageKey.DISPLAY); statusHandler.handle(Priority.DEBUG, "---- " + currFullDisplayXmlFileName); - displayThreshMgr.createConfigFromDefaults( + displayThreshMgr.createDisplayConfigFromDefaults( currFullDisplayXmlFileName, areaIDs, threshKeys); } else { - currFullDisplayXmlFileName = getDisplayThresholdPath() + filename; + currFullDisplayXmlFileName = getThresholdPath(DataUsageKey.DISPLAY) + + filename; displayThreshMgr.setFullPathFileName(currFullDisplayXmlFileName); displayThreshMgr.readThresholdXml(); } @@ -532,8 +535,8 @@ public abstract class AbstractThresholdMgr { // Sort the area IDs Collections.sort(areaIDs); ArrayList threshKeys = getThresholdKeys(DataUsageKey.MONITOR); - monitorThreshMgr.createConfigFromDefaults(currFullMonitorXmlFileName, - areaIDs, threshKeys); + monitorThreshMgr.createMonitorConfigFromDefaults( + currFullMonitorXmlFileName, areaIDs, threshKeys); } /** @@ -546,7 +549,8 @@ public abstract class AbstractThresholdMgr { if (newFileName.trim().compareTo(defDisplayThreshName) == 0) { return; } - currFullDisplayXmlFileName = getDisplayThresholdPath() + newFileName; + currFullDisplayXmlFileName = getThresholdPath(DataUsageKey.DISPLAY) + + newFileName; displayThreshMgr.setFullPathFileName(currFullDisplayXmlFileName); displayThreshMgr.saveThresholdXml(); } @@ -605,12 +609,12 @@ public abstract class AbstractThresholdMgr { * * @return File path. */ - public String getDisplayThresholdPath() { + public String getThresholdPath(DataUsageKey usage) { String fs = String.valueOf(File.separatorChar); StringBuilder sb = new StringBuilder(); sb.append(appName.name().toLowerCase()).append(fs); sb.append("threshold").append(fs); - sb.append("display").append(fs); + sb.append(usage.name().toLowerCase()).append(fs); return sb.toString(); } @@ -621,10 +625,9 @@ public abstract class AbstractThresholdMgr { */ public String getMonitorThresholdPath() { String fs = String.valueOf(File.separatorChar); - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new StringBuilder("monitoring"); + sb.append(fs); sb.append(appName.name().toLowerCase()).append(fs); - sb.append("threshold").append(fs); - sb.append("monitor").append(fs); return sb.toString(); } @@ -753,13 +756,14 @@ public abstract class AbstractThresholdMgr { FSSObsMonitorConfigurationManager mgr = null; switch (this.appName) { case FOG: - mgr = FSSObsMonitorConfigurationManager.getInstance(MonName.fog); + mgr = FSSObsMonitorConfigurationManager.getInstance(AppName.FOG); break; case SAFESEAS: - mgr = FSSObsMonitorConfigurationManager.getInstance(MonName.ss); + mgr = FSSObsMonitorConfigurationManager + .getInstance(AppName.SAFESEAS); break; case SNOW: - mgr = FSSObsMonitorConfigurationManager.getInstance(MonName.snow); + mgr = FSSObsMonitorConfigurationManager.getInstance(AppName.SNOW); break; default: statusHandler.error("Unable to handle unknown appName: " diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitorDisplayThreshDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitorDisplayThreshDlg.java old mode 100644 new mode 100755 index 41418b7f6d..775ff02ad3 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitorDisplayThreshDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitorDisplayThreshDlg.java @@ -51,7 +51,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * ------------ ---------- ----------- -------------------------- * Apr 6, 2009 lvenable Initial creation * Jun 17, 2010 5551,5548 skorolev Add "Open" and "Help" menu itemsec - * Dec 6, 2012 #1351 skorolev Changes for non-blocking dialogs. + * Dec 6, 2012 #1351 skorolev Changes for non-blocking dialogs. + * Dec 26, 2015 5114 skorolev Corrected menu actions according to getThresholdPath. * * * @@ -206,6 +207,7 @@ public abstract class MonitorDisplayThreshDlg extends CaveSWTDialog { MenuItem exitMI = new MenuItem(fileMenu, SWT.NONE); exitMI.setText("Exit"); exitMI.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { close(); } @@ -237,6 +239,7 @@ public abstract class MonitorDisplayThreshDlg extends CaveSWTDialog { MenuItem open = new MenuItem(fileMenu, SWT.NONE); open.setText("Open"); open.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { menuOpenAction(); } @@ -245,6 +248,7 @@ public abstract class MonitorDisplayThreshDlg extends CaveSWTDialog { MenuItem saveAsMI = new MenuItem(fileMenu, SWT.NONE); saveAsMI.setText("Save As..."); saveAsMI.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { menuSaveAsAction(); } @@ -253,6 +257,7 @@ public abstract class MonitorDisplayThreshDlg extends CaveSWTDialog { MenuItem selectAsDefaultMI = new MenuItem(fileMenu, SWT.NONE); selectAsDefaultMI.setText("Select As Default..."); selectAsDefaultMI.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { menuSelectAsDefaultAction(); } @@ -261,6 +266,7 @@ public abstract class MonitorDisplayThreshDlg extends CaveSWTDialog { MenuItem loadDefaultMI = new MenuItem(fileMenu, SWT.NONE); loadDefaultMI.setText("Load Default"); loadDefaultMI.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { menuLoadDefaultAction(); } @@ -269,6 +275,7 @@ public abstract class MonitorDisplayThreshDlg extends CaveSWTDialog { MenuItem deleteMI = new MenuItem(fileMenu, SWT.NONE); deleteMI.setText("Delete"); deleteMI.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { menuDeleteAction(); } @@ -285,6 +292,7 @@ public abstract class MonitorDisplayThreshDlg extends CaveSWTDialog { MenuItem saveMI = new MenuItem(fileMenu, SWT.NONE); saveMI.setText("Save"); saveMI.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { menuSaveAction(); } @@ -314,6 +322,7 @@ public abstract class MonitorDisplayThreshDlg extends CaveSWTDialog { commitBtn.setText("Commit Changes"); commitBtn.setLayoutData(gd); commitBtn.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { commitChangeAction(); close(); @@ -329,7 +338,7 @@ public abstract class MonitorDisplayThreshDlg extends CaveSWTDialog { if (deleteDlg == null) { AbstractThresholdMgr atm = getThresholdMgr(); deleteDlg = new LoadSaveDeleteSelectDlg(shell, DialogType.DELETE, - atm.getDisplayThresholdPath(), + atm.getThresholdPath(DataUsageKey.DISPLAY), atm.getDefaultFileName(DataUsageKey.DISPLAY)); deleteDlg.setCloseCallback(new ICloseCallback() { @Override @@ -374,7 +383,7 @@ public abstract class MonitorDisplayThreshDlg extends CaveSWTDialog { if (saveAsDlg == null) { AbstractThresholdMgr atm = getThresholdMgr(); saveAsDlg = new LoadSaveDeleteSelectDlg(shell, DialogType.SAVE_AS, - atm.getDisplayThresholdPath(), + atm.getThresholdPath(DataUsageKey.DISPLAY), atm.getDefaultFileName(DataUsageKey.DISPLAY)); saveAsDlg.setCloseCallback(new ICloseCallback() { @Override @@ -407,7 +416,8 @@ public abstract class MonitorDisplayThreshDlg extends CaveSWTDialog { if (selectDlg == null) { AbstractThresholdMgr atm = getThresholdMgr(); selectDlg = new LoadSaveDeleteSelectDlg(shell, - DialogType.SELECT_DEFAULT, atm.getDisplayThresholdPath(), + DialogType.SELECT_DEFAULT, + atm.getThresholdPath(DataUsageKey.DISPLAY), atm.getDefaultFileName(DataUsageKey.DISPLAY)); selectDlg.setCloseCallback(new ICloseCallback() { @Override @@ -448,7 +458,7 @@ public abstract class MonitorDisplayThreshDlg extends CaveSWTDialog { if (openDlg == null) { AbstractThresholdMgr atm = getThresholdMgr(); openDlg = new LoadSaveDeleteSelectDlg(shell, DialogType.OPEN, - atm.getDisplayThresholdPath(), null); + atm.getThresholdPath(DataUsageKey.DISPLAY), null); openDlg.setCloseCallback(new ICloseCallback() { @Override public void dialogClosed(Object returnValue) { diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/TableComp.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/TableComp.java old mode 100644 new mode 100755 index 27bf30cf6f..ead81948eb --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/TableComp.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/TableComp.java @@ -46,13 +46,13 @@ import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import com.raytheon.uf.common.monitor.data.CommonConfig; +import com.raytheon.uf.common.monitor.data.MonitorConfigConstants; import com.raytheon.uf.viz.monitor.config.CommonTableConfig; import com.raytheon.uf.viz.monitor.config.CommonTableConfig.SortDirection; import com.raytheon.uf.viz.monitor.data.ColumnAttribData; import com.raytheon.uf.viz.monitor.data.TableCellData; import com.raytheon.uf.viz.monitor.data.TableData; import com.raytheon.uf.viz.monitor.data.TableRowData; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; /** * Abstract table composite that is the main foundation for a table displaying @@ -66,6 +66,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; * Apr 7, 2009 lvenable Initial creation * Oct 7, 2013 #2436 lvenable Disposed of the sort color. * Nov 7, 2013 DR 16703 gzhang Check in code for Lee for FFMP and Safeseas + * Dec 26, 2015 5114 skorolev Corrected imports. * * * @@ -187,6 +188,7 @@ public abstract class TableComp extends Composite { packColumns(); this.addDisposeListener(new DisposeListener() { + @Override public void widgetDisposed(DisposeEvent arg0) { tiFont.dispose(); lineColor.dispose(); @@ -257,6 +259,7 @@ public abstract class TableComp extends Composite { * cell and also draw a blue line to show the selected row. */ table.addListener(SWT.PaintItem, new Listener() { + @Override public void handleEvent(Event event) { table.deselectAll(); event.gc.setForeground(lineColor); @@ -281,10 +284,10 @@ public abstract class TableComp extends Composite { TableItem ti = (TableItem) event.item; int idx = table.indexOf(ti); if (idx == table.getItemCount() - 1) { - event.gc.drawLine(rect.x, rect.y + rect.height - 2, rect.x - + rect.width, rect.y + rect.height - 2); + event.gc.drawLine(rect.x, rect.y + rect.height - 2, rect.x + + rect.width, rect.y + rect.height - 2); } - + if (tableIndex >= 0) { event.gc.setForeground(parent.getDisplay().getSystemColor( SWT.COLOR_BLUE)); diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ZoneTableDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ZoneTableDlg.java old mode 100755 new mode 100644 diff --git a/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfMovementResource.java b/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfMovementResource.java index 3504c84349..f5013b6f81 100644 --- a/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfMovementResource.java +++ b/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfMovementResource.java @@ -29,8 +29,6 @@ import org.eclipse.swt.graphics.RGB; import com.raytheon.uf.common.dataplugin.bufrncwf.BUFRncwf; import com.raytheon.uf.common.dataplugin.bufrncwf.NCWFFeature; -import com.raytheon.uf.common.dataquery.requests.RequestConstraint; -import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.common.pointdata.PointDataContainer; import com.raytheon.uf.common.pointdata.PointDataView; import com.raytheon.uf.common.time.DataTime; @@ -54,8 +52,9 @@ import com.vividsolutions.jts.geom.Coordinate; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 16, 2009 bsteffen Initial creation - * Jul 24, 2014 3429 mapeters Updated deprecated drawLine() calls. + * Sep 16, 2009 bsteffen Initial creation + * Jul 24, 2014 3429 mapeters Updated deprecated drawLine() calls. + * Feb 04, 2016 5310 tgurney Remove dependency on dataURI * * * @@ -168,7 +167,8 @@ public class NcwfMovementResource extends // Draw the body of the arrow DrawableLine line = new DrawableLine(); line.setCoordinates(centerPixel[0], centerPixel[1], centerPixel[2]); - line.addPoint(or_centerPixel[0], or_centerPixel[1], or_centerPixel[2]); + line.addPoint(or_centerPixel[0], or_centerPixel[1], + or_centerPixel[2]); line.basics.color = color; line.width = 1.5f; lines.add(line); @@ -181,8 +181,8 @@ public class NcwfMovementResource extends } private DrawableLine createArrowHead(IGraphicsTarget target, - double[] center, - Double length, Double dir, RGB color) throws VizException { + double[] center, Double length, Double dir, RGB color) + throws VizException { double[] pointPixel = target.getPointOnCircle(center[0], center[1], center[2], length, dir + 210); @@ -191,8 +191,7 @@ public class NcwfMovementResource extends line.setCoordinates(pointPixel[0], pointPixel[1], pointPixel[2]); line.addPoint(center[0], center[1], center[2]); double[] pointPixel2 = target.getPointOnCircle(center[0], center[1], - center[2], - length, dir + 150); + center[2], length, dir + 150); line.addPoint(pointPixel2[0], pointPixel2[1], pointPixel2[2]); line.basics.color = color; line.width = 1.5f; @@ -209,21 +208,13 @@ public class NcwfMovementResource extends if (!recordsMap.containsKey(displayedDataTime)) { recordsMap.put(displayedDataTime, new ArrayList()); } - RequestConstraint constraint = new RequestConstraint(); - constraint.setConstraintType(ConstraintType.IN); - - for (BUFRncwf r : records) { - - constraint.addToConstraintValueList(r.getDataURI()); - } - Map constraints = new HashMap(); - constraints.put("dataURI", constraint); // Request the point data PointDataContainer pdc = PointDataRequest.requestPointDataAllLevels( displayedDataTime, resourceData.getMetadataMap().get("pluginName") - .getConstraintValue(), parameters, null, constraints); + .getConstraintValue(), parameters, null, + resourceData.getMetadataMap()); for (int uriCounter = 0; uriCounter < pdc.getAllocatedSz(); uriCounter++) { PointDataView pdv = pdc.readRandom(uriCounter); @@ -253,6 +244,7 @@ public class NcwfMovementResource extends this.recordsToParse.get(displayedDataTime).clear(); } + @Override protected void addRecord(BUFRncwf obj) { if (!recordsToParse.containsKey(obj.getDataTime())) { recordsToParse.put(obj.getDataTime(), new ArrayList()); diff --git a/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfPolygonResource.java b/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfPolygonResource.java index 92e2fa5fb4..cb012eb26c 100644 --- a/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfPolygonResource.java +++ b/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfPolygonResource.java @@ -53,7 +53,8 @@ import com.vividsolutions.jts.geom.GeometryFactory; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 16, 2009 bsteffen Initial creation + * Sep 16, 2009 bsteffen Initial creation + * Feb 04, 2016 5310 tgurney Remove dependency on dataURI * * * @@ -175,14 +176,12 @@ public class NcwfPolygonResource extends DataTime dataTime = null; for (BUFRncwf r : records) { - constraint.addToConstraintValueList(r.getDataURI()); dataTime = r.getDataTime(); } - Map constraints = new HashMap(); - constraints.put("dataURI", constraint); PointDataContainer pdc = PointDataRequest.requestPointDataAllLevels( dataTime, resourceData.getMetadataMap().get("pluginName") - .getConstraintValue(), parameters, null, constraints); + .getConstraintValue(), parameters, null, + resourceData.getMetadataMap()); for (int uriCounter = 0; uriCounter < pdc.getAllocatedSz(); uriCounter++) { PointDataView pdv = pdc.readRandom(uriCounter); @@ -206,6 +205,7 @@ public class NcwfPolygonResource extends } + @Override protected void addRecord(BUFRncwf obj) { DataTime time = calculateBinTime(obj.getDataTime()); diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrquikscat/utility/edex_static/base/distribution/bufrquikscat.xml b/cave/com.raytheon.uf.viz.points/localization/menus/tools/points-index.xml similarity index 85% rename from edexOsgi/com.raytheon.uf.edex.plugin.bufrquikscat/utility/edex_static/base/distribution/bufrquikscat.xml rename to cave/com.raytheon.uf.viz.points/localization/menus/tools/points-index.xml index a0053ff004..2d5bc24df6 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.bufrquikscat/utility/edex_static/base/distribution/bufrquikscat.xml +++ b/cave/com.raytheon.uf.viz.points/localization/menus/tools/points-index.xml @@ -18,6 +18,8 @@ See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for further_licensing_information. --> - - ^ISXX.* - + + + + diff --git a/cave/com.raytheon.uf.viz.points/localization/menus/tools/points-menu.xml b/cave/com.raytheon.uf.viz.points/localization/menus/tools/points-menu.xml new file mode 100644 index 0000000000..f945d21685 --- /dev/null +++ b/cave/com.raytheon.uf.viz.points/localization/menus/tools/points-menu.xml @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/PointsDataManager.java b/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/PointsDataManager.java index 8f10dd20a6..b9a328aad4 100644 --- a/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/PointsDataManager.java +++ b/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/PointsDataManager.java @@ -22,7 +22,6 @@ package com.raytheon.uf.viz.points; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -51,6 +50,7 @@ import org.geotools.referencing.datum.DefaultEllipsoid; import com.raytheon.uf.common.awipstools.GetWfoCenterPoint; import com.raytheon.uf.common.localization.FileUpdatedMessage; import com.raytheon.uf.common.localization.FileUpdatedMessage.FileChangeType; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.ILocalizationFileObserver; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; @@ -58,8 +58,8 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.localization.SaveableOutputStream; import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -89,6 +89,10 @@ import com.vividsolutions.jts.geom.Coordinate; * Dec 05, 2012 #1364 rferrel Replace File.Separator with IPathManager.SEPARATOR * to work correctly on all platforms. * Oct 20, 2014 #3418 dlovely Fixed a possible NPE in loadPoint. + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * Dec 09, 2015 4834 njensen updates for API changes to LocalizationFile + * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods + * Feb 12, 2016 #5242 dgilling Remove calls to deprecated Localization APIs. * * * @@ -396,7 +400,7 @@ public class PointsDataManager implements ILocalizationFileObserver { */ private void storePoint(LocalizationFile dir, Point point, String fileName) { LocalizationFile lFile = pathMgr.getLocalizationFile(userCtx, dir - .getName().trim() + IPathManager.SEPARATOR + fileName); + .getPath().trim() + IPathManager.SEPARATOR + fileName); try { marshalPointToXmlFile(point, lFile); @@ -445,7 +449,7 @@ public class PointsDataManager implements ILocalizationFileObserver { processRequests(); } } else { - String dirPath = pointsDir.getName().trim(); + String dirPath = pointsDir.getPath().trim(); String name = D2D_POINTS_GROUP.replace(' ', PointUtilities.DELIM_CHAR); String path = dirPath + IPathManager.SEPARATOR + name; @@ -454,7 +458,7 @@ public class PointsDataManager implements ILocalizationFileObserver { if (!d2dDir.isDirectory()) { try { d2dDir.delete(); - } catch (LocalizationOpFailedException e) { + } catch (LocalizationException e) { statusHandler.handle(Priority.PROBLEM, "Unable to create group: " + D2D_POINTS_GROUP); return points; @@ -530,7 +534,7 @@ public class PointsDataManager implements ILocalizationFileObserver { */ private Coordinate loadHome() { LocalizationFile lFile = pathMgr.getLocalizationFile( - pointsDir.getContext(), pointsDir.getName().trim() + pointsDir.getContext(), pointsDir.getPath().trim() + IPathManager.SEPARATOR + HOME_LOCATION_FILE); Point point = null; if (lFile.exists()) { @@ -555,7 +559,7 @@ public class PointsDataManager implements ILocalizationFileObserver { points.clear(); childrenKeyMap.clear(); - String path = pointsDir.getName().trim(); + String path = pointsDir.getPath().trim(); LocalizationFile[] files = pathMgr.listFiles(userCtx, path, new String[] { POINT_FILENAME_EXT }, true, false); @@ -682,7 +686,7 @@ public class PointsDataManager implements ILocalizationFileObserver { * @return lFile */ private LocalizationFile getGroupDir(Point point) { - String path = (pointsDir.getName() + point.getGroup().replace(' ', + String path = (pointsDir.getPath() + point.getGroup().replace(' ', PointUtilities.DELIM_CHAR)); LocalizationFile dir = pathMgr.getLocalizationFile(userCtx, path); return dir; @@ -765,7 +769,7 @@ public class PointsDataManager implements ILocalizationFileObserver { */ private String getPointFilename(Point point) { StringBuilder sb = new StringBuilder(); - sb.append(pointsDir.getName().trim()); + sb.append(pointsDir.getPath().trim()); String group = point.getGroup(); if (!group.startsWith(IPathManager.SEPARATOR)) { sb.append(IPathManager.SEPARATOR); @@ -786,7 +790,7 @@ public class PointsDataManager implements ILocalizationFileObserver { private String getPointDirName(Point node) { String group = node.getGroup(); StringBuilder sb = new StringBuilder(); - sb.append(pointsDir.getName().trim()); + sb.append(pointsDir.getPath().trim()); if (group.length() > 0) { if (group.startsWith(IPathManager.SEPARATOR) == false) { sb.append(IPathManager.SEPARATOR); @@ -884,22 +888,22 @@ public class PointsDataManager implements ILocalizationFileObserver { * * @param parentNode * @return groupNode - * @throws LocalizationOpFailedException + * @throws LocalizationException */ public IPointNode createTempGroup(IPointNode parentNode) - throws LocalizationOpFailedException { + throws LocalizationException { Point parent = (Point) parentNode; String path = getPointDirName(parent); StringBuilder sb = new StringBuilder(path); - LocalizationFile[] dirs = pathMgr.listStaticFiles(sb.toString(), + ILocalizationFile[] dirs = pathMgr.listStaticFiles(sb.toString(), new String[0], false, false); sb.append(IPathManager.SEPARATOR).append(GROUP_TEMP_PREFIX); int end = sb.length(); List names = new ArrayList(); - for (LocalizationFile lf : dirs) { - names.add(lf.getName().trim()); + for (ILocalizationFile lf : dirs) { + names.add(lf.getPath().trim()); } int cnt = 0; @@ -960,7 +964,7 @@ public class PointsDataManager implements ILocalizationFileObserver { put(key, point); childrenKeyMap.get(newParentKey).add(key); } else { - Point newGroup = new GroupNode((Point) point); + Point newGroup = new GroupNode(point); String newGroupKey = newParentKey + IPathManager.SEPARATOR + point.getName(); newGroup.setGroup(newGroupKey); @@ -1021,7 +1025,7 @@ public class PointsDataManager implements ILocalizationFileObserver { private IPointNode createGroup(String parent, String name) { StringBuilder sb = new StringBuilder(); sb.append(parent); - sb.replace(0, pointsDir.getName().trim().length(), ""); + sb.replace(0, pointsDir.getPath().trim().length(), ""); sb.append(IPathManager.SEPARATOR).append(name); Point gPoint = new GroupNode(name); gPoint.setGroup(sb.toString().replace(PointUtilities.DELIM_CHAR, ' ')); @@ -1035,20 +1039,17 @@ public class PointsDataManager implements ILocalizationFileObserver { LocalizationFile[] files = pathMgr.listFiles(userCtx, parent, new String[] {}, false, false); for (LocalizationFile lf : files) { - if (groupPath.equals(lf.getName().trim())) { + if (groupPath.equals(lf.getPath().trim())) { return null; } } - try { - // Must create a file in the directory to force its creation. - String p = lFile.getName().trim() + IPathManager.SEPARATOR - + GROUP_INFO; - LocalizationFile lf = pathMgr.getLocalizationFile(userCtx, p); - OutputStream outStream = lf.openOutputStream(); + // Must create a file in the directory to force its creation. + String p = lFile.getPath().trim() + IPathManager.SEPARATOR + GROUP_INFO; + ILocalizationFile lf = pathMgr.getLocalizationFile(userCtx, p); + try (SaveableOutputStream outStream = lf.openOutputStream()) { outStream.write(gPoint.getGroup().getBytes()); - outStream.close(); - lf.save(); + outStream.save(); } catch (LocalizationException e) { statusHandler.handle(Priority.PROBLEM, "Unable to create the group: " + gPoint.getGroup(), e); @@ -1075,13 +1076,13 @@ public class PointsDataManager implements ILocalizationFileObserver { * @return groups */ public String[] getGroupList() { - LocalizationFile[] files = pathMgr.listFiles(userCtx, pointsDir - .getName().trim(), new String[] {}, true, false); + ILocalizationFile[] files = pathMgr.listFiles(userCtx, pointsDir + .getPath().trim(), new String[] {}, true, false); String[] groups = new String[files.length - 1]; - int start = files[0].getName().trim().length(); + int start = files[0].getPath().trim().length(); for (int index = 1; index < files.length; ++index) { - LocalizationFile lf = files[index]; - groups[index - 1] = lf.getName().trim().substring(start) + ILocalizationFile lf = files[index]; + groups[index - 1] = lf.getPath().trim().substring(start) .replace(PointUtilities.DELIM_CHAR, ' '); } Arrays.sort(groups); @@ -1113,13 +1114,6 @@ public class PointsDataManager implements ILocalizationFileObserver { } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.common.localization.ILocalizationFileObserver#fileUpdated - * (com.raytheon.uf.common.localization.FileUpdatedMessage) - */ @Override public void fileUpdated(FileUpdatedMessage message) { String fileName = new File(message.getFileName()).getName(); @@ -1160,7 +1154,7 @@ public class PointsDataManager implements ILocalizationFileObserver { boolean stateChange = false; StringBuilder sb = new StringBuilder(message.getFileName()); - sb.replace(0, pointsDir.getName().length(), ""); + sb.replace(0, pointsDir.getPath().length(), ""); sb.replace(sb.lastIndexOf(IPathManager.SEPARATOR), sb.length(), ""); String groupKey = sb.toString().replace(PointUtilities.DELIM_CHAR, ' '); @@ -1298,7 +1292,7 @@ public class PointsDataManager implements ILocalizationFileObserver { boolean stateChange = false; StringBuilder sb = new StringBuilder(message.getFileName()); sb.setLength(sb.lastIndexOf(IPathManager.SEPARATOR)); - sb.replace(0, pointsDir.getName().length(), ""); + sb.replace(0, pointsDir.getPath().length(), ""); String key = sb.toString().replace(PointUtilities.DELIM_CHAR, ' '); String parentKey = null; int index = key.lastIndexOf(IPathManager.SEPARATOR); @@ -1364,7 +1358,7 @@ public class PointsDataManager implements ILocalizationFileObserver { deleteKey); try { lFile.delete(); - } catch (LocalizationOpFailedException e) { + } catch (LocalizationException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); } @@ -1505,9 +1499,6 @@ public class PointsDataManager implements ILocalizationFileObserver { * ADDED if file was successfully created. * * @param point - * @return returns true if point was successfully added, false otherwise, - * for example when a duplicate point name exists and forceOverwrite - * was false */ private void storePoint(Point point) { LocalizationFile dir = getGroupDir(point); @@ -1522,7 +1513,6 @@ public class PointsDataManager implements ILocalizationFileObserver { * DELETE if file removal is successful. * * @param point - * @return */ public void deletePoint(final Point point) { IPointNode parentNode = getParent(point); @@ -1589,10 +1579,8 @@ public class PointsDataManager implements ILocalizationFileObserver { lFile = pathMgr.getLocalizationFile(userCtx, name); } try { - if (!lFile.delete()) { - statusHandler.error("Unable to remove file: " + lFile); - } - } catch (LocalizationOpFailedException e1) { + lFile.delete(); + } catch (LocalizationException e1) { statusHandler.handle(Priority.PROBLEM, "Error deleting locatization file from server: " + lFile); } @@ -1739,10 +1727,10 @@ public class PointsDataManager implements ILocalizationFileObserver { */ private void marshalPointToXmlFile(Point point, LocalizationFile lFile) throws LocalizationException, IOException { - OutputStream stream = lFile.openOutputStream(); - JAXB.marshal(point, stream); - stream.close(); - lFile.save(); + try (SaveableOutputStream outStream = lFile.openOutputStream()) { + JAXB.marshal(point, outStream); + outStream.save(); + } } /** @@ -1755,14 +1743,8 @@ public class PointsDataManager implements ILocalizationFileObserver { */ private Point unmarshalPointFromXmlFile(LocalizationFile lFile) throws LocalizationException, IOException { - InputStream stream = null; - try { - stream = lFile.openInputStream(); - return JAXB.unmarshal(stream, Point.class); - } finally { - if (stream != null) { - stream.close(); - } + try (InputStream inStream = lFile.openInputStream()) { + return JAXB.unmarshal(inStream, Point.class); } } diff --git a/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/data/PointSize.java b/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/data/PointSize.java index c27965e39d..02b9478dfb 100644 --- a/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/data/PointSize.java +++ b/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/data/PointSize.java @@ -29,6 +29,7 @@ package com.raytheon.uf.viz.points.data; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Aug 08, 2012 #875 rferrel Initial Creation. + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling * * * @@ -38,7 +39,7 @@ package com.raytheon.uf.viz.points.data; public enum PointSize { - SMALL(12), DEFAULT(14), LARGE(18), EXTRA_LARGE(24), XXL(30); + SMALL(10), DEFAULT(12), LARGE(15), EXTRA_LARGE(20), XXL(25); private static final String POINTS_NAME = " pt"; diff --git a/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/ui/action/PointEditAction.java b/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/ui/action/PointEditAction.java index 039875cba8..b1b934ad6d 100644 --- a/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/ui/action/PointEditAction.java +++ b/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/ui/action/PointEditAction.java @@ -19,7 +19,8 @@ ******************************************************************************************/ package com.raytheon.uf.viz.points.ui.action; -import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; import com.raytheon.uf.viz.points.ui.dialog.PointsMgrDialog; import com.raytheon.uf.viz.points.ui.layer.PointsToolLayer; @@ -35,6 +36,7 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Sep 27, 2012 875 rferrel Initial creation + * Jan 15, 2015 5054 randerso Properly parented Dialog to CAVE window * * * @@ -63,7 +65,9 @@ public class PointEditAction extends AbstractRightClickAction { @Override public void run() { if (dialog == null || dialog.getShell() == null || dialog.isDisposed()) { - dialog = new PointsMgrDialog(Display.getCurrent().getShells()[0], + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(); + dialog = new PointsMgrDialog(shell, (PointsToolLayer) getSelectedRsc()); dialog.setBlockOnOpen(false); dialog.open(); diff --git a/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/ui/dialog/PointsMgrDialog.java b/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/ui/dialog/PointsMgrDialog.java index 84bc8e8a8e..b421186774 100644 --- a/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/ui/dialog/PointsMgrDialog.java +++ b/cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/ui/dialog/PointsMgrDialog.java @@ -63,7 +63,7 @@ import org.eclipse.swt.widgets.TreeColumn; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.PlatformUI; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; +import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -87,12 +87,13 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * October-2010 epolster Initial Creation. + * October-2010 epolster Initial Creation. * Jul 31, 2012 #875 rferrel Integrated into CAVE. * Oct 2, 2012 #1234 rferrel Clicking on new group/point when no * node selected will now add the new * to the root node. * Apr 01, 2014 #2976 lvenable Added SWT dispose checks in runAsync call. + * Nov 30, 2015 4834 njensen Remove LocalizationOpFailedException * * * @@ -353,6 +354,7 @@ public class PointsMgrDialog extends CaveJFACEDialog implements && !getShell().getDisplay().isDisposed()) { loadTreeInput(); getShell().getDisplay().syncExec(new Runnable() { + @Override public void run() { pointsTreeViewer.setInput(getTableInput()); } @@ -424,7 +426,7 @@ public class PointsMgrDialog extends CaveJFACEDialog implements setCursorBusy(true); editSelectedNode = true; selectedNode = dataManager.createTempGroup(parentNode); - } catch (LocalizationOpFailedException e1) { + } catch (LocalizationException e1) { statusHandler.handle( Priority.PROBLEM, "Unable to create a temporary group under: " @@ -546,6 +548,7 @@ public class PointsMgrDialog extends CaveJFACEDialog implements final Text modText = new Text(composite, SWT.NONE); final int inset = showBorder ? 1 : 0; composite.addListener(SWT.Resize, new Listener() { + @Override public void handleEvent(Event e) { Rectangle rect = composite.getClientArea(); modText.setBounds(rect.x + inset, rect.y + inset, rect.width @@ -553,6 +556,7 @@ public class PointsMgrDialog extends CaveJFACEDialog implements } }); Listener textListener = new Listener() { + @Override public void handleEvent(final Event e) { switch (e.type) { case SWT.KeyUp: diff --git a/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/image/PointSetDataCallback.java b/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/image/PointSetDataCallback.java index 467578d92a..7428853166 100644 --- a/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/image/PointSetDataCallback.java +++ b/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/image/PointSetDataCallback.java @@ -20,11 +20,18 @@ package com.raytheon.uf.viz.pointset.image; import java.io.FileNotFoundException; +import java.nio.ByteBuffer; import java.nio.DoubleBuffer; import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; +import java.util.Map; + +import javax.measure.unit.Unit; import com.raytheon.uf.common.colormap.image.ColorMapData; import com.raytheon.uf.common.colormap.image.ColorMapData.ColorMapDataType; +import com.raytheon.uf.common.dataplugin.pointset.PointSetConstants; import com.raytheon.uf.common.dataplugin.pointset.PointSetRecord; import com.raytheon.uf.common.datastorage.DataStoreFactory; import com.raytheon.uf.common.datastorage.IDataStore; @@ -43,8 +50,9 @@ import com.raytheon.uf.viz.core.exception.VizException; * SOFTWARE HISTORY * * Date Ticket# Engineer Description - * ------------- -------- --------- -------------------------- + * ------------- -------- --------- ------------------------------------- * Aug 28, 2015 4709 bsteffen Initial creation + * Jan 25, 2016 5208 bsteffen Support scale, offset and int types. * * * @@ -56,10 +64,16 @@ public class PointSetDataCallback implements private final PointSetRecord record; + private Unit dataUnit; + public PointSetDataCallback(PointSetRecord record) { this.record = record; } + public Unit getDataUnit() { + return dataUnit; + } + @Override public ColorMapData getColorMapData() throws VizException { IDataStore store = DataStoreFactory.getDataStore(record @@ -67,17 +81,53 @@ public class PointSetDataCallback implements try { IDataRecord record = store.retrieve(this.record.getDataURI(), DataStoreFactory.DEF_DATASET_NAME, Request.ALL); + dataUnit = this.record.getParameter().getUnit(); + Map attrs = record.getDataAttributes(); + if (attrs != null) { + Number offset = (Number) attrs + .get(PointSetConstants.ADD_OFFSET); + Number scale = (Number) attrs + .get(PointSetConstants.SCALE_FACTOR); + + if (offset != null) { + double offsetVal = offset.doubleValue(); + if (offsetVal != 0.0) { + dataUnit = dataUnit.plus(offsetVal); + } + } + if (scale != null) { + double scaleVal = scale.doubleValue(); + if (scaleVal != 0.0) { + dataUnit = dataUnit.times(scaleVal); + } + } + } Object data = record.getDataObject(); if (data instanceof float[]) { float[] fdata = (float[]) data; return new ColorMapData(FloatBuffer.wrap(fdata), new int[] { fdata.length }, ColorMapDataType.FLOAT, - this.record.getParameter().getUnit()); + dataUnit); } else if (data instanceof double[]) { - double[] fdata = (double[]) data; - return new ColorMapData(DoubleBuffer.wrap(fdata), - new int[] { fdata.length }, ColorMapDataType.DOUBLE, - this.record.getParameter().getUnit()); + double[] ddata = (double[]) data; + return new ColorMapData(DoubleBuffer.wrap(ddata), + new int[] { ddata.length }, ColorMapDataType.DOUBLE, + dataUnit); + } else if (data instanceof byte[]) { + byte[] bdata = (byte[]) data; + return new ColorMapData(ByteBuffer.wrap(bdata), + new int[] { bdata.length }, + ColorMapDataType.SIGNED_BYTE, dataUnit); + } else if (data instanceof short[]) { + short[] sdata = (short[]) data; + return new ColorMapData(ShortBuffer.wrap(sdata), + new int[] { sdata.length }, ColorMapDataType.SHORT, + dataUnit); + } else if (data instanceof int[]) { + int[] idata = (int[]) data; + return new ColorMapData(IntBuffer.wrap(idata), + new int[] { idata.length }, ColorMapDataType.INT, + dataUnit); } else { throw new VizException("Unsupported data of type " + data.getClass().getSimpleName()); diff --git a/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/image/PointSetImagePreferences.java b/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/image/PointSetImagePreferences.java new file mode 100644 index 0000000000..85b1663c56 --- /dev/null +++ b/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/image/PointSetImagePreferences.java @@ -0,0 +1,67 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.pointset.image; + +import javax.measure.unit.Unit; + +import com.raytheon.uf.common.dataplugin.pointset.PointSetRecord; +import com.raytheon.uf.common.parameter.Parameter; +import com.raytheon.uf.common.style.image.ColorMapParameterFactory; +import com.raytheon.uf.common.style.image.ImagePreferences; + +/** + * Custom version of {@link ImagePreferences} that uses the units from the + * record as display units. This is only useful if there is no other style rule. + * This can be used to pass the unit information from the {@link PointSetRecord} + * to the {@link ColorMapParameterFactory}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer  Description
+ * ------------- -------- --------- ---------------------
+ * Jan 25, 2016  5208     bsteffen  Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ +public class PointSetImagePreferences extends ImagePreferences { + + private final Parameter parameter; + + public PointSetImagePreferences(Parameter parameter) { + super(); + this.parameter = parameter; + } + + @Override + public Unit getDisplayUnits() { + return parameter.getUnit(); + } + + @Override + public String getDisplayUnitLabel() { + return parameter.getUnitString(); + } + +} diff --git a/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/rsc/PointSetFrame.java b/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/rsc/PointSetFrame.java index 8bf6885886..cd7fe066cd 100644 --- a/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/rsc/PointSetFrame.java +++ b/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/rsc/PointSetFrame.java @@ -43,8 +43,9 @@ import com.raytheon.uf.viz.pointset.image.PointSetLocationCallback; * SOFTWARE HISTORY * * Date Ticket# Engineer Description - * ------------- -------- --------- -------------------------- + * ------------- -------- --------- -------------------------------------------- * Aug 28, 2015 4709 bsteffen Initial creation + * Jan 25, 2016 5208 bsteffen Ensure correct units are used for conversion * * * @@ -62,6 +63,8 @@ public class PointSetFrame { private ITriangulatedImage image; + private PointSetDataCallback dataCallback; + private volatile boolean staged = false; public PointSetFrame(PointSetRecord record, PointSetResource resource) { @@ -98,7 +101,7 @@ public class PointSetFrame { double dataValue = image.getDataValue(x, y); if (displayUnit != null) { - UnitConverter converter = record.getParameter().getUnit() + UnitConverter converter = dataCallback.getDataUnit() .getConverterTo(displayUnit); dataValue = converter.convert(dataValue); } @@ -113,9 +116,10 @@ public class PointSetFrame { ColorMapCapability.class).getColorMapParameters(); ITriangulatedImageExtension triangleExt = target .getExtension(ITriangulatedImageExtension.class); + this.dataCallback = new PointSetDataCallback(record); this.image = triangleExt.initializeImage(colorMapParameters, new PointSetLocationCallback(resource.getDescriptor(), - record), new PointSetDataCallback(record)); + record), dataCallback); return false; } else if (staged) { ITriangulatedImageExtension triangleExt = target diff --git a/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/rsc/PointSetResource.java b/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/rsc/PointSetResource.java index 3a7e2fb3fe..c6b79dd883 100644 --- a/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/rsc/PointSetResource.java +++ b/cave/com.raytheon.uf.viz.pointset/src/com/raytheon/uf/viz/pointset/rsc/PointSetResource.java @@ -26,11 +26,11 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.ShortBuffer; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import javax.measure.converter.UnitConverter; import javax.measure.unit.Unit; import javax.measure.unit.UnitFormat; @@ -44,6 +44,7 @@ import com.raytheon.uf.common.colormap.image.ColorMapData; import com.raytheon.uf.common.colormap.image.ColorMapData.ColorMapDataType; import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; import com.raytheon.uf.common.dataplugin.PluginDataObject; +import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.pointset.PointSetRecord; import com.raytheon.uf.common.geospatial.ReferencedCoordinate; import com.raytheon.uf.common.numeric.UnsignedNumbers; @@ -54,6 +55,9 @@ import com.raytheon.uf.common.style.StyleManager; import com.raytheon.uf.common.style.StyleManager.StyleType; import com.raytheon.uf.common.style.StyleRule; import com.raytheon.uf.common.style.image.ColorMapParameterFactory; +import com.raytheon.uf.common.style.level.Level.LevelType; +import com.raytheon.uf.common.style.level.RangeLevel; +import com.raytheon.uf.common.style.level.SingleLevel; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.util.BufferUtil; import com.raytheon.uf.viz.core.IGraphicsTarget; @@ -66,6 +70,7 @@ import com.raytheon.uf.viz.core.rsc.IResourceDataChanged.ChangeType; import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability; import com.raytheon.uf.viz.pointset.image.PointSetDataCallback; +import com.raytheon.uf.viz.pointset.image.PointSetImagePreferences; import com.vividsolutions.jts.geom.Coordinate; /** @@ -76,8 +81,9 @@ import com.vividsolutions.jts.geom.Coordinate; * SOFTWARE HISTORY * * Date Ticket# Engineer Description - * ------------- -------- --------- -------------------------- + * ------------- -------- --------- --------------------- * Aug 28, 2015 4709 bsteffen Initial creation + * Jan 25, 2016 5208 bsteffen Better default style * * * @@ -112,19 +118,16 @@ public class PointSetResource extends public ColorMapParameters createColorMapParameters(PointSetRecord record) throws VizException { ParamLevelMatchCriteria matchCriteria = new ParamLevelMatchCriteria(); - matchCriteria.setParameterName(Arrays.asList(record.getParameter() - .getAbbreviation())); - // TODO convert level to a style level. - //matchCriteria.setLevels(new ArrayList()); - matchCriteria.setCreatingEntityNames(Arrays.asList(record + matchCriteria.setParameterName(Collections.singletonList(record + .getParameter().getAbbreviation())); + matchCriteria.setLevels(Collections + .singletonList(convertLevelForStyle(record.getLevel()))); + matchCriteria.setCreatingEntityNames(Collections.singletonList(record .getDatasetId())); try { styleRule = StyleManager.getInstance().getStyleRule( StyleType.IMAGERY, matchCriteria); - if (styleRule != null) { - return ColorMapParameterFactory.build(styleRule, record - .getParameter().getUnit()); - } else { + if (styleRule == null) { ColorMapData data = new PointSetDataCallback(record) .getColorMapData(); ColorMapDataType type = data.getDataType(); @@ -144,15 +147,91 @@ public class PointSetResource extends max = val; } } - - return ColorMapParameterFactory.build(min, max, - data.getDataUnit(), matchCriteria); + styleRule = new StyleRule(); + styleRule.setPreferences(new PointSetImagePreferences(record + .getParameter())); + float[] factoryData = { min, max }; + return ColorMapParameterFactory.build(styleRule, factoryData, + null, data.getDataUnit()); } + return ColorMapParameterFactory.build(styleRule, record + .getParameter().getUnit()); + } catch (StyleException e) { throw new VizException(e); } } + /** + * Convert a com.raytheon.uf.common.dataplugin.level.Level into a + * com.raytheon.uf.common.style.level.Level + */ + protected com.raytheon.uf.common.style.level.Level convertLevelForStyle( + Level level) { + LevelType type = LevelType.DEFAULT; + String master = level.getMasterLevel().getName(); + if (master.equalsIgnoreCase("MB")) { + type = LevelType.PRESSURE; + } else if (master.equalsIgnoreCase("FHAG")) { + type = LevelType.HEIGHT_AGL; + } else if (master.equalsIgnoreCase("FH")) { + type = LevelType.HEIGHT_AGL; + } else if (master.equalsIgnoreCase("SFC")) { + type = LevelType.SURFACE; + } else if (master.equalsIgnoreCase("K")) { + type = LevelType.THETA; + } else if (master.equals("BL")) { + type = LevelType.MB_AGL; + } else { + /* + * Many masterlevels match the type so attempt valueOf, it is normal + * for this to fail for many obscure master levels. + */ + try { + type = LevelType.valueOf(master); + } catch (IllegalArgumentException e) { + type = LevelType.DEFAULT; + } + } + Unit unitsIn = level.getMasterLevel().getUnit(); + if (level.isLevelTwoValid()) { + RangeLevel result = new RangeLevel(type); + result.setLowerValue(level.getLevelonevalue()); + result.setUpperValue(level.getLeveltwovalue()); + /* + * This is a bit roundabout but it is the only way that + * com.raytheon.uf.common.style.level.Level exposes units + */ + Unit unitsOut = result.getUpperMeasure().getUnit(); + if (unitsIn != null && !unitsIn.equals(unitsOut) + && unitsIn.isCompatible(unitsOut)) { + UnitConverter converter = unitsIn.getConverterTo(unitsOut); + double lowerValue = level.getLevelonevalue(); + double upperValue = level.getLeveltwovalue(); + lowerValue = converter.convert(lowerValue); + upperValue = converter.convert(upperValue); + result.setLowerValue(lowerValue); + result.setUpperValue(upperValue); + } + return result; + } else { + SingleLevel result = new SingleLevel(type); + result.setValue(level.getLevelonevalue()); + /* + * This is a bit roundabout but it is the only way that + * com.raytheon.uf.common.style.level.Level exposes units + */ + Unit unitsOut = result.getMeasure().getUnit(); + if (unitsIn != null && !unitsIn.equals(unitsOut) + && unitsIn.isCompatible(unitsOut)) { + double value = level.getLevelonevalue(); + value = unitsIn.getConverterTo(unitsOut).convert(value); + result.setValue(value); + } + return result; + } + } + private float extractVal(ColorMapDataType type, Buffer buffer) throws VizException { switch (type) { @@ -255,7 +334,7 @@ public class PointSetResource extends AbstractStylePreferences prefs = styleRule.getPreferences(); String prefsUnitStr = prefs.getDisplayUnitLabel(); if (prefsUnitStr != null) { - unitStr = prefs.getDisplayUnitLabel(); + unitStr = prefsUnitStr; } } else { ColorMapParameters parameters = getCapability( @@ -280,8 +359,7 @@ public class PointSetResource extends boolean includeLevel = true; if (styleRule != null) { AbstractStylePreferences prefs = styleRule.getPreferences(); - includeLevel = !prefs.getDisplayFlags() - .hasFlag("NoPlane"); + includeLevel = !prefs.getDisplayFlags().hasFlag("NoPlane"); } String datasetIdPart = frame.getRecord().getDatasetId(); String levelPart = ""; @@ -289,8 +367,7 @@ public class PointSetResource extends levelPart = " " + record.getLevel(); } String paramPart = " " + record.getParameter().getName() + " (" - + getDisplayUnitString(record) - + ")"; + + getDisplayUnitString(record) + ")"; return datasetIdPart + levelPart + paramPart; } } diff --git a/cave/com.raytheon.uf.viz.productbrowser.datalisting/src/com/raytheon/uf/viz/productbrowser/datalisting/DataListingProductBrowserDefinition.java b/cave/com.raytheon.uf.viz.productbrowser.datalisting/src/com/raytheon/uf/viz/productbrowser/datalisting/DataListingProductBrowserDefinition.java index 032dbdb88c..7f978a4d3a 100644 --- a/cave/com.raytheon.uf.viz.productbrowser.datalisting/src/com/raytheon/uf/viz/productbrowser/datalisting/DataListingProductBrowserDefinition.java +++ b/cave/com.raytheon.uf.viz.productbrowser.datalisting/src/com/raytheon/uf/viz/productbrowser/datalisting/DataListingProductBrowserDefinition.java @@ -39,9 +39,11 @@ import com.raytheon.uf.common.serialization.comm.RequestRouter; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.core.DescriptorMap; +import com.raytheon.uf.viz.core.RecordFactory; import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay; import com.raytheon.uf.viz.core.drawables.IRenderableDisplay; import com.raytheon.uf.viz.core.drawables.ResourcePair; +import com.raytheon.uf.viz.core.exception.NoPluginException; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.map.IMapDescriptor; import com.raytheon.uf.viz.core.map.MapDescriptor; @@ -79,13 +81,15 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener; * Date Ticket# Engineer Description * ------------- -------- --------- -------------------------- * Jun 04, 2015 4153 bsteffen Initial creation + * Nov 03, 2015 5030 mapeters Quietly handle CAVE & EDEX plugins being out of sync * * * * @author bsteffen * @version 1.0 */ -public abstract class DataListingProductBrowserDefinition implements PreferenceBasedDataDefinition { +public abstract class DataListingProductBrowserDefinition implements + PreferenceBasedDataDefinition { private static final transient IUFStatusHandler logger = UFStatus .getHandler(DataListingProductBrowserDefinition.class); @@ -106,22 +110,22 @@ public abstract class DataListingProductBrowserDefinition implements PreferenceB @Override public List getPreferences() { - return Arrays.asList(enabledPreference, orderPreference, formatPreference); + return Arrays.asList(enabledPreference, orderPreference, + formatPreference); } protected boolean isEnabled() { return (Boolean) enabledPreference.getValue(); } - + protected boolean isFormatted() { return (Boolean) formatPreference.getValue(); } - + protected String[] getOrderedKeys() { return (String[]) orderPreference.getValue(); } - - + protected Map createKeyValMap(String[] selection) { Map keyVals = new HashMap<>(); int index = 1; @@ -136,13 +140,16 @@ public abstract class DataListingProductBrowserDefinition implements PreferenceB return keyVals; } - public DataListingProductBrowserDefinition(String displayName, DataListing listing) { + public DataListingProductBrowserDefinition(String displayName, + DataListing listing) { this.displayName = displayName; this.listing = listing; - this.enabledPreference = ProductBrowserPreferenceConstants.createEnabledPreference(); - this.formatPreference = ProductBrowserPreferenceConstants.createFormatPreference(); - this.orderPreference = ProductBrowserPreferenceConstants.createOrderPreference(listing.getKeys().toArray( - new String[0])); + this.enabledPreference = ProductBrowserPreferenceConstants + .createEnabledPreference(); + this.formatPreference = ProductBrowserPreferenceConstants + .createFormatPreference(); + this.orderPreference = ProductBrowserPreferenceConstants + .createOrderPreference(listing.getKeys().toArray(new String[0])); new ProductBrowserPreferenceListener(displayName, enabledPreference); new ProductBrowserPreferenceListener(displayName, formatPreference); @@ -151,7 +158,8 @@ public abstract class DataListingProductBrowserDefinition implements PreferenceB } private static String createDisplayName(String pluginName) { - return Character.toUpperCase(pluginName.charAt(0)) + pluginName.substring(1); + return Character.toUpperCase(pluginName.charAt(0)) + + pluginName.substring(1); } @Override @@ -159,14 +167,29 @@ public abstract class DataListingProductBrowserDefinition implements PreferenceB if (!isEnabled()) { return false; } + + try { + RecordFactory.getInstance().getPluginClass(listing.getPluginName()); + } catch (NoPluginException e) { + String msg = "Unable to display " + + displayName + + " data in Product Browser because the server does not support the " + + listing.getPluginName() + " plugin"; + logger.debug(msg); + return false; + } + DbQueryRequest request = new DbQueryRequest(); - request.setConstraints(listing.getRequestConstraints(Collections. emptyMap())); + request.setConstraints(listing.getRequestConstraints(Collections + . emptyMap())); request.setLimit(1); try { - DbQueryResponse response = (DbQueryResponse) RequestRouter.route(request); + DbQueryResponse response = (DbQueryResponse) RequestRouter + .route(request); return response.getNumResults() > 0; } catch (Exception e) { - logger.error("Error initializing product browser data for " + displayName, e); + logger.error("Error initializing product browser data for " + + displayName, e); return false; } } @@ -174,7 +197,8 @@ public abstract class DataListingProductBrowserDefinition implements PreferenceB @Override public List getLabels(String[] selection) { if (selection.length == 0) { - ProductBrowserLabel label = new ProductBrowserLabel(displayName, listing.getPluginName()); + ProductBrowserLabel label = new ProductBrowserLabel(displayName, + listing.getPluginName()); label.setProduct(listing.getKeys().isEmpty()); return Collections.singletonList(label); } @@ -182,26 +206,34 @@ public abstract class DataListingProductBrowserDefinition implements PreferenceB String nextKey = getOrderedKeys()[keyVals.size()]; try { if (isFormatted()) { - Map formattedMap = listing.getFormattedValues(nextKey, keyVals); - List labels = new ArrayList<>(formattedMap.size()); + Map formattedMap = listing.getFormattedValues( + nextKey, keyVals); + List labels = new ArrayList<>( + formattedMap.size()); for (Entry entry : formattedMap.entrySet()) { - ProductBrowserLabel label = new ProductBrowserLabel(entry.getValue(), entry.getKey()); - label.setProduct(selection.length >= listing.getKeys().size()); + ProductBrowserLabel label = new ProductBrowserLabel( + entry.getValue(), entry.getKey()); + label.setProduct(selection.length >= listing.getKeys() + .size()); labels.add(label); } return labels; } else { Collection values = listing.getValues(nextKey, keyVals); - List labels = new ArrayList<>(values.size()); + List labels = new ArrayList<>( + values.size()); for (String value : values) { - ProductBrowserLabel label = new ProductBrowserLabel(value, value); - label.setProduct(selection.length >= listing.getKeys().size()); + ProductBrowserLabel label = new ProductBrowserLabel(value, + value); + label.setProduct(selection.length >= listing.getKeys() + .size()); labels.add(label); } return labels; } } catch (Exception e) { - logger.error("Error querying " + nextKey + " for " + displayName + " in the product browser.", e); + logger.error("Error querying " + nextKey + " for " + displayName + + " in the product browser.", e); return Collections.emptyList(); } } @@ -209,9 +241,11 @@ public abstract class DataListingProductBrowserDefinition implements PreferenceB @Override public String getProductInfo(String[] selection) { StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(PluginDataObject.PLUGIN_NAME_ID + " = " + listing.getPluginName()); + stringBuilder.append(PluginDataObject.PLUGIN_NAME_ID + " = " + + listing.getPluginName()); int index = 1; - for (Entry entry : createKeyValMap(selection).entrySet()) { + for (Entry entry : createKeyValMap(selection) + .entrySet()) { if (index >= selection.length) { break; } @@ -231,7 +265,8 @@ public abstract class DataListingProductBrowserDefinition implements PreferenceB public void loadResource(String[] selection, DisplayType displayType) { Map keyVals = createKeyValMap(selection); AbstractResourceData resourceData = createResourceData(keyVals); - ResourcePair resourcePair = createResourcePair(resourceData, displayType); + ResourcePair resourcePair = createResourcePair(resourceData, + displayType); try { AbstractRenderableDisplay display = createRenderableDisplay(resourcePair); AbstractEditor editor = createOrOpenEditor(display); @@ -239,7 +274,8 @@ public abstract class DataListingProductBrowserDefinition implements PreferenceB b.setDisplays(new AbstractRenderableDisplay[] { display }); new BundleProductLoader(editor, b).schedule(); } catch (VizException e) { - logger.error("Failed to load resource of type " + resourceData.getClass().getSimpleName(), e); + logger.error("Failed to load resource of type " + + resourceData.getClass().getSimpleName(), e); } } @@ -259,21 +295,25 @@ public abstract class DataListingProductBrowserDefinition implements PreferenceB * this will fall back to using UiUtil. */ protected AbstractEditor createOrOpenEditor(IRenderableDisplay display) { - String editorId = DescriptorMap.getEditorId(display.getDescriptor().getClass().getName()); + String editorId = DescriptorMap.getEditorId(display.getDescriptor() + .getClass().getName()); IEditorPart editorPart = EditorUtil.getActiveEditor(); - if (editorPart != null && editorId.equals(editorPart.getEditorSite().getId())) { + if (editorPart != null + && editorId.equals(editorPart.getEditorSite().getId())) { return (AbstractEditor) editorPart; } editorPart = EditorUtil.findEditor(editorId); if (editorPart != null) { return (AbstractEditor) editorPart; } - IWorkbenchWindow window = VizWorkbenchManager.getInstance().getCurrentWindow(); + IWorkbenchWindow window = VizWorkbenchManager.getInstance() + .getCurrentWindow(); /* * This part allows the perspective manager to make an editor which may * have some customizations. */ - AbstractVizPerspectiveManager mgr = VizPerspectiveListener.getInstance(window).getActivePerspectiveManager(); + AbstractVizPerspectiveManager mgr = VizPerspectiveListener.getInstance( + window).getActivePerspectiveManager(); if (mgr != null) { AbstractEditor editor = mgr.openNewEditor(); if (editor == null) { @@ -287,14 +327,17 @@ public abstract class DataListingProductBrowserDefinition implements PreferenceB return UiUtil.createOrOpenEditor(editorId, display); } - protected abstract AbstractResourceData createResourceData(Map keyVals); + protected abstract AbstractResourceData createResourceData( + Map keyVals); - protected ResourcePair createResourcePair(AbstractResourceData resourceData, DisplayType displayType) { + protected ResourcePair createResourcePair( + AbstractResourceData resourceData, DisplayType displayType) { ResourcePair pair = new ResourcePair(); pair.setResourceData(resourceData); LoadProperties loadProperties = new LoadProperties(); if (displayType != null) { - loadProperties.getCapabilities().getCapability(resourceData, DisplayTypeCapability.class) + loadProperties.getCapabilities() + .getCapability(resourceData, DisplayTypeCapability.class) .setDisplayType(displayType); } pair.setLoadProperties(loadProperties); @@ -302,11 +345,11 @@ public abstract class DataListingProductBrowserDefinition implements PreferenceB return pair; } - protected AbstractRenderableDisplay createRenderableDisplay(ResourcePair resourcePair) throws VizException { + protected AbstractRenderableDisplay createRenderableDisplay( + ResourcePair resourcePair) throws VizException { IMapDescriptor mapDescriptor = new MapDescriptor(); mapDescriptor.getResourceList().add(resourcePair); return new MapRenderableDisplay(mapDescriptor); } - } diff --git a/cave/com.raytheon.uf.viz.profiler/localization/menus/upperair/baseEastNPN.xml b/cave/com.raytheon.uf.viz.profiler/localization/menus/upperair/baseEastNPN.xml index 1dfd7a51c4..019f49cc0f 100644 --- a/cave/com.raytheon.uf.viz.profiler/localization/menus/upperair/baseEastNPN.xml +++ b/cave/com.raytheon.uf.viz.profiler/localization/menus/upperair/baseEastNPN.xml @@ -20,7 +20,7 @@ --> @@ -80,7 +80,7 @@ diff --git a/cave/com.raytheon.uf.viz.profiler/src/com/raytheon/uf/viz/profiler/ProfilerResource.java b/cave/com.raytheon.uf.viz.profiler/src/com/raytheon/uf/viz/profiler/ProfilerResource.java index db5167b6ac..2fb20f122b 100644 --- a/cave/com.raytheon.uf.viz.profiler/src/com/raytheon/uf/viz/profiler/ProfilerResource.java +++ b/cave/com.raytheon.uf.viz.profiler/src/com/raytheon/uf/viz/profiler/ProfilerResource.java @@ -62,9 +62,9 @@ import com.vividsolutions.jts.geom.Coordinate; /** * Handles profiler data - * + * *
- *
+ * 
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
@@ -85,8 +85,10 @@ import com.vividsolutions.jts.geom.Coordinate;
  * 08/14/2014         3523 mapeters    Updated deprecated {@link DrawableString#textStyle}
  *                                     assignments.
  * 07/22/2015          688 nabowle     Synchronize plotObjects access.
+ * 05/11/2015         5070 randerso    Adjust font sizes for dpi scaling
+ * 
  * 
- * + * * @author dhladky * @version 1.0 */ @@ -126,7 +128,7 @@ public class ProfilerResource extends /** * Required method for getting data - * + * * @param resourceData * @param loadProperties */ @@ -176,7 +178,7 @@ public class ProfilerResource extends incX = (ProfilerUtils.profilerRectangle.width / NUM_PROFILE_STAFFS); incYheight = ProfilerUtils.profilerRectangle.height / MAX_Y; - this.font = target.initializeFont("Dialog", 11, null); + this.font = target.initializeFont("Dialog", 9, null); ColorMapParameters params = getCapability(ColorMapCapability.class) .getColorMapParameters(); @@ -261,7 +263,8 @@ public class ProfilerResource extends earliestTime = Math.min(earliestTime, validTime); latestTime = Math.max(latestTime, validTime); } - long earliestRequestTime = earliestTime - NUM_PROFILE_STAFFS * 3600000; + long earliestRequestTime = earliestTime - NUM_PROFILE_STAFFS + * 3600000; List requestTimes = new ArrayList(); for (DataTime time : resourceData.getAvailableTimes()) { long validTime = time.getValidTime().getTimeInMillis(); @@ -312,7 +315,7 @@ public class ProfilerResource extends /** * Set the width scalar - * + * * @param props * @return */ @@ -325,7 +328,7 @@ public class ProfilerResource extends /** * get the scale width value - * + * * @return */ private double getScaleWidth() { @@ -334,7 +337,7 @@ public class ProfilerResource extends /** * Set the height scalar - * + * * @param props * @return */ @@ -347,7 +350,7 @@ public class ProfilerResource extends /** * Get the scalar height - * + * * @return */ private double getScaleHeight() { @@ -356,7 +359,7 @@ public class ProfilerResource extends /** * gets the pixel coverage for this image - * + * * @return */ private PixelCoverage getPixelCoverage(Coordinate c) { @@ -375,7 +378,7 @@ public class ProfilerResource extends /** * iterate through our list of profile plots and draw images - * + * * @throws VizException */ private void drawProfiles(PaintProperties paintProps) throws VizException { @@ -413,7 +416,7 @@ public class ProfilerResource extends /** * Create profile windBards - * + * * @param profile * @throws VizException */ @@ -453,7 +456,7 @@ public class ProfilerResource extends } /** - * + * * @param index * @param level * @return @@ -481,14 +484,15 @@ public class ProfilerResource extends /** * @throws VizException - * + * */ public void drawXAxis(PaintProperties paintProps, Double magnification) throws VizException { // left edge of graph DrawableLine[] lines = new DrawableLine[2]; lines[0] = new DrawableLine(); - lines[0].setCoordinates(ProfilerUtils.profilerRectangle.x, + lines[0].setCoordinates( + ProfilerUtils.profilerRectangle.x, (ProfilerUtils.profilerRectangle.y + ProfilerUtils.profilerRectangle.height)); lines[0].addPoint(ProfilerUtils.profilerRectangle.x, ProfilerUtils.profilerRectangle.y); @@ -537,9 +541,11 @@ public class ProfilerResource extends // draw right edge lines[1] = new DrawableLine(); - lines[1].setCoordinates((ProfilerUtils.profilerRectangle.x + ProfilerUtils.profilerRectangle.width), + lines[1].setCoordinates( + (ProfilerUtils.profilerRectangle.x + ProfilerUtils.profilerRectangle.width), (ProfilerUtils.profilerRectangle.y + ProfilerUtils.profilerRectangle.height)); - lines[1].addPoint((ProfilerUtils.profilerRectangle.x + ProfilerUtils.profilerRectangle.width), + lines[1].addPoint( + (ProfilerUtils.profilerRectangle.x + ProfilerUtils.profilerRectangle.width), ProfilerUtils.profilerRectangle.y); lines[1].basics.color = ProfilerUtils.GRAPH_COLOR; lines[1].width = ProfilerUtils.GRAPH_LINE_WIDTH; @@ -551,7 +557,7 @@ public class ProfilerResource extends /** * @throws VizException - * + * */ public void drawYAxis(PaintProperties paintProps, Double magnification) throws VizException { @@ -713,7 +719,7 @@ public class ProfilerResource extends } /** - * + * * @param height * @return */ @@ -723,7 +729,7 @@ public class ProfilerResource extends } /** - * + * * @param w * @return */ diff --git a/cave/com.raytheon.uf.viz.python.swt/src/com/raytheon/uf/viz/python/swt/Window.java b/cave/com.raytheon.uf.viz.python.swt/src/com/raytheon/uf/viz/python/swt/Window.java index 1a622a7eac..5e0c442f65 100644 --- a/cave/com.raytheon.uf.viz.python.swt/src/com/raytheon/uf/viz/python/swt/Window.java +++ b/cave/com.raytheon.uf.viz.python.swt/src/com/raytheon/uf/viz/python/swt/Window.java @@ -30,14 +30,15 @@ import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.python.swt.widgets.Widget; /** - * TODO Add Description + * Allows opening a jface Window from Python * *
  * 
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Jul 14, 2009            chammack     Initial creation
+ * Jul 14, 2009            chammack    Initial creation
+ * Jan 14, 2016 5054       randerso    Eliminate dummy shell
  * 
  * 
* @@ -52,7 +53,7 @@ public class Window extends org.eclipse.jface.window.Window { protected List widgetList; public Window(String title, List widgetList) { - super(new Shell()); + super((Shell) null); this.title = title; this.widgetList = widgetList; } diff --git a/cave/com.raytheon.uf.viz.radarapps.fsi/localization/menus/tools/fsi-tools-index.xml b/cave/com.raytheon.uf.viz.radarapps.fsi/localization/menus/tools/fsi-tools-index.xml new file mode 100644 index 0000000000..a81f8e219c --- /dev/null +++ b/cave/com.raytheon.uf.viz.radarapps.fsi/localization/menus/tools/fsi-tools-index.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.radarapps.fsi/localization/menus/tools/fsi-tools-menu.xml b/cave/com.raytheon.uf.viz.radarapps.fsi/localization/menus/tools/fsi-tools-menu.xml new file mode 100644 index 0000000000..5899163698 --- /dev/null +++ b/cave/com.raytheon.uf.viz.radarapps.fsi/localization/menus/tools/fsi-tools-menu.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.radarapps.rps/src/com/raytheon/uf/viz/radarapps/rps/ListEditorWindow.java b/cave/com.raytheon.uf.viz.radarapps.rps/src/com/raytheon/uf/viz/radarapps/rps/ListEditorWindow.java index bb9effca67..5144fe520c 100644 --- a/cave/com.raytheon.uf.viz.radarapps.rps/src/com/raytheon/uf/viz/radarapps/rps/ListEditorWindow.java +++ b/cave/com.raytheon.uf.viz.radarapps.rps/src/com/raytheon/uf/viz/radarapps/rps/ListEditorWindow.java @@ -100,9 +100,9 @@ import com.raytheon.uf.viz.radarapps.products.ui.RadarProductUI; /** * RPS List Editor window - * + * *
- *
+ * 
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
@@ -111,8 +111,9 @@ import com.raytheon.uf.viz.radarapps.products.ui.RadarProductUI;
  * 2013-01-31   DR 15458   D. Friedman Send RPS list so that it will be
  *                                     accepted for any VCP.
  * 2015-06-10   4498       nabowle     Rename Util->RcmUtil
+ * 2016-01-20   5271       bkowal      Code cleanup.
  * 
- * + * */ public class ListEditorWindow { private static final transient IUFStatusHandler statusHandler = UFStatus @@ -452,8 +453,9 @@ public class ListEditorWindow { protected void onClose(ShellEvent e) { e.doit = false; - if (!checkUnsaved()) + if (!checkUnsaved()) { return; + } // TODO: reset if just going to make invisible... listEditor.dispose(); } @@ -479,8 +481,9 @@ public class ListEditorWindow { SendRpsList msg = new SendRpsList(); msg.radarIDs = Arrays.asList(rpg); msg.requests = Arrays.asList(listEditor.getRpsList().getRequests()); - /* Specify that the RadarServer should accept this list no matter - * what VCP the RPG is currently using. + /* + * Specify that the RadarServer should accept this list no matter what + * VCP the RPG is currently using. */ msg.vcp = RpsList.UNSPECIFIED_VCP; String error = null; @@ -566,10 +569,11 @@ public class ListEditorWindow { RadarProduct rp = ProductInfo.getInstance().getPoductForCode( req.productCode); - Collection variants = ProductInfo.getInstance().select( - new ProductInfo.Selector(null, rp.mnemonic, null, null)); StringBuilder sb = new StringBuilder(); if (rp != null) { + Collection variants = ProductInfo.getInstance() + .select(new ProductInfo.Selector(null, rp.mnemonic, null, + null)); if (rp.name != null) sb.append(rp.name); /* @@ -645,7 +649,6 @@ public class ListEditorWindow { sb.append(String.format("Product #%d", req.productCode)); } return sb.toString(); - // return element.toString(); } private VCPInfo chooseVcp(String message) { @@ -738,45 +741,6 @@ public class ListEditorWindow { return listEditor.saveList(); } - private void onStoreList() { - if (!sendCheck()) - return; - - StoreDialog sd = new StoreDialog(getShell(), listEditor); - if (sd.open() == Window.OK) { - if (!checkListLength(sd.getRadarIDs(), sd.getVcps())) - return; - - RcmClient client = RadarApps.getRcmSystem().getClient(); - for (int vcp : sd.getVcps()) { - SendRpsList msg = new SendRpsList(); - msg.radarIDs = sd.getRadarIDs(); - if (msg.radarIDs.size() == 0) - return; - msg.requests = Arrays.asList(listEditor.getRpsList() - .getRequests()); - msg.vcp = vcp; - msg.store = true; - - String error = null; - try { - ReplyObj ro = client.sendRequest(msg, 2000); - error = ro.error; - } catch (IOException e) { - error = e.toString(); - } - if (error != null) { - MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR - | SWT.OK); - mb.setText("Error"); - mb.setMessage(error); - mb.open(); - } else - listEditor.setDirty(false); - } - } - } - private boolean sendCheck() { if (listEditor.getRequestList().size() >= 1) return true; diff --git a/cave/com.raytheon.uf.viz.spellchecker/src/com/raytheon/uf/viz/spellchecker/text/SpellCheckTextViewer.java b/cave/com.raytheon.uf.viz.spellchecker/src/com/raytheon/uf/viz/spellchecker/text/SpellCheckTextViewer.java index c4045b7b7d..cbcda315f7 100644 --- a/cave/com.raytheon.uf.viz.spellchecker/src/com/raytheon/uf/viz/spellchecker/text/SpellCheckTextViewer.java +++ b/cave/com.raytheon.uf.viz.spellchecker/src/com/raytheon/uf/viz/spellchecker/text/SpellCheckTextViewer.java @@ -66,7 +66,7 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; +import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.core.VizApp; @@ -81,15 +81,16 @@ import com.raytheon.uf.viz.spellchecker.jobs.EnhancedSpellCheckJob; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jun 18, 2014 3453 rblum Initial creation - * Aug 06, 2014 3453 rblum Refreshing all viewers on enable/ - * disable of spell checking. - * Aug 18, 2014 3453 rblum Added the spell check dictionary - * to site level localization. - * Oct 01, 2014 3453 rblum Allow MB3 click anywhere in the textbox - * to enable/disable spellcheck. - * Mar 27, 2015 4138 dhladky Guava name change. - * Apr 14, 2015 4362 mapeters Allow external contribution of menu items. + * Jun 18, 2014 3453 rblum Initial creation + * Aug 06, 2014 3453 rblum Refreshing all viewers on enable/ + * disable of spell checking. + * Aug 18, 2014 3453 rblum Added the spell check dictionary + * to site level localization. + * Oct 01, 2014 3453 rblum Allow MB3 click anywhere in the textbox + * to enable/disable spellcheck. + * Mar 27, 2015 4138 dhladky Guava name change. + * Apr 14, 2015 4362 mapeters Allow external contribution of menu items. + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException * * * @@ -387,7 +388,7 @@ public class SpellCheckTextViewer extends TextViewer implements if (lf != null) { lf.save(); } - } catch (LocalizationOpFailedException exception) { + } catch (LocalizationException exception) { statusHandler.error( "Unable to save dictionary into localization", exception); diff --git a/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF index 4ebf054218..01bae8cbac 100644 --- a/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Stats Bundle-SymbolicName: com.raytheon.uf.viz.stats;singleton:=true -Bundle-Version: 1.14.0.qualifier +Bundle-Version: 1.15.0.qualifier Bundle-Vendor: RAYTHEON Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, @@ -13,8 +13,7 @@ Require-Bundle: org.eclipse.ui, com.raytheon.uf.common.util;bundle-version="1.12.1174", com.google.guava;bundle-version="1.0.0", com.raytheon.uf.common.units;bundle-version="1.0.0", - com.raytheon.uf.common.event;bundle-version="1.0.0", - org.apache.commons.lang;bundle-version="2.3.0" + com.raytheon.uf.common.event;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.uf.viz.stats.collector, diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/ColorManagerDlg.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/ColorManagerDlg.java deleted file mode 100644 index f26367d842..0000000000 --- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/ColorManagerDlg.java +++ /dev/null @@ -1,356 +0,0 @@ -/** - * 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.stats.ui; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.ColorDialog; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Tree; - -import com.raytheon.uf.common.stats.data.GraphData; -import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase; - -/** - * TODO Add Description - * - *
- *
- * SOFTWARE HISTORY
- *
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Oct 18, 2012            mpduff     Initial creation
- *
- * 
- * - * @author mpduff - * @version 1.0 - */ - -public class ColorManagerDlg extends CaveSWTDialogBase { - private Composite mainComp; - - private final IColorSelection callback; - - private Button individualRdo; - - private Tree selectionTree; - - private final GraphData graphData; - - private final List
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ActivateSiteComponent.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ActivateSiteComponent.java index 7bb314ed0e..938223afca 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ActivateSiteComponent.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ActivateSiteComponent.java @@ -19,9 +19,6 @@ **/ package com.raytheon.viz.gfe; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - import com.raytheon.viz.gfe.dialogs.sbu.SiteActivationDlg; import com.raytheon.viz.ui.personalities.awips.AbstractAWIPSComponent; @@ -34,8 +31,10 @@ import com.raytheon.viz.ui.personalities.awips.AbstractAWIPSComponent; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Aug 15, 2011 bphillip Initial creation + * Aug 15, 2011 bphillip Initial creation * Oct 26, 2012 1287 rferrel Force blocking of SiteActivationDlg. + * Jan 26, 2015 5054 randerso Use null shell as parent, + * Results in display as parent for jface dialogs * * * @@ -54,8 +53,7 @@ public class ActivateSiteComponent extends AbstractAWIPSComponent { */ @Override protected void startInternal(String componentName) throws Exception { - SiteActivationDlg dlg = new SiteActivationDlg(new Shell( - Display.getCurrent())); + SiteActivationDlg dlg = new SiteActivationDlg(null); dlg.setBlockOnOpen(true); dlg.open(); } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/Activator.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/Activator.java index d2c70bbc84..5b953508ca 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/Activator.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/Activator.java @@ -19,8 +19,8 @@ **/ package com.raytheon.viz.gfe; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -43,6 +43,10 @@ import com.raytheon.viz.gfe.dialogs.GFEConfigDialog; * Oct 30, 2012 1298 rferrel Must be a blocking dialog. * Dec 09, 2013 #2367 dgilling Remove shutdown of ProcedureJob and * SmartToolJob. + * Oct 28, 2015 #5054 randerso Make GfeConfigDlg parented by workbench window if + * workbench is running. + * Jan 26, 2015 #5054 randerso If no workbench is running use null shell as parent, + * Results in display as parent for jface dialogs * * * @@ -113,10 +117,15 @@ public class Activator extends AbstractUIPlugin implements BundleActivator { public PythonPreferenceStore getPreferenceStore() { synchronized (this) { if (pythonPrefs == null) { - if (cfgDlg == null || cfgDlg.getShell() == null + if ((cfgDlg == null) || (cfgDlg.getShell() == null) || cfgDlg.isDisposed()) { - cfgDlg = new GFEConfigDialog( - new Shell(Display.getDefault())); + Shell shell = null; + if (PlatformUI.isWorkbenchRunning()) { + shell = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getShell(); + } + + cfgDlg = new GFEConfigDialog(shell); // Must keep as a blocking dialog for eclipse plugins to // work properly. cfgDlg.setBlockOnOpen(true); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ClearPracticeGrids.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ClearPracticeGrids.java index b4839370fe..635d0a26c5 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ClearPracticeGrids.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ClearPracticeGrids.java @@ -30,17 +30,16 @@ import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable; import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable.LockMode; -import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerMsg; import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; import com.raytheon.uf.common.dataplugin.gfe.server.request.LockRequest; +import com.raytheon.uf.common.gfe.ifpclient.IFPClient; 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.TimeRange; -import com.raytheon.viz.gfe.GFEServerException; import com.raytheon.viz.gfe.core.DataManager; +import com.raytheon.viz.gfe.core.DataManagerUIFactory; import com.raytheon.viz.gfe.core.IParmManager; -import com.raytheon.viz.gfe.core.internal.IFPClient; import com.raytheon.viz.gfe.core.parm.Parm; /** @@ -53,6 +52,7 @@ import com.raytheon.viz.gfe.core.parm.Parm; * ------------ ---------- ----------- -------------------------- * Apr 10, 2010 #4475 randerso Initial creation * May 02, 2013 1949 rjpeter Change ServerResponse return type. + * Nov 18, 2015 5129 dgilling Support new IFPClient. * * * @author randerso @@ -64,7 +64,7 @@ public class ClearPracticeGrids extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - DataManager dataManager = DataManager.getCurrentInstance(); + DataManager dataManager = DataManagerUIFactory.getCurrentInstance(); if (dataManager == null) { return null; } @@ -74,57 +74,42 @@ public class ClearPracticeGrids extends AbstractHandler { String s = dataManager.getSiteID() + "_GRID_Prac_Fcst_00000000_0000"; DatabaseID dbid = new DatabaseID(s); - try { - // for each parmId in the database - ParmID[] parmList = pm.getAvailableParms(dbid); - for (ParmID parmID : parmList) { - // if the parm exists - Parm parm = pm.getParm(parmID); - if (parm != null) { + // for each parmId in the database + ParmID[] parmList = pm.getAvailableParms(dbid); + for (ParmID parmID : parmList) { + // if the parm exists + Parm parm = pm.getParm(parmID); + if (parm != null) { - TimeRange tr = parm.getInventorySpan(); - if (tr.getDuration() > 0) { - // break any locks held by others - List locks = parm.getLockTable() - .lockedByOther(); - if (locks.size() > 0) { - ArrayList lreq = new ArrayList(); - for (TimeRange lock : locks) { - lreq.add(new LockRequest(parmID, lock, - LockMode.BREAK_LOCK)); - } - ServerResponse> sr = client - .requestLockChange(lreq); - if (!sr.isOkay()) { - List messages = sr.getMessages(); - StringBuilder msg = new StringBuilder( - "Error attempting to remove locks."); - for (ServerMsg serverMsg : messages) { - msg.append("\n").append( - serverMsg.getMessage()); - } - statusHandler.handle(Priority.PROBLEM, - msg.toString()); - } + TimeRange tr = parm.getInventorySpan(); + if (tr.getDuration() > 0) { + // break any locks held by others + List locks = parm.getLockTable().lockedByOther(); + if (!locks.isEmpty()) { + List lreq = new ArrayList(); + for (TimeRange lock : locks) { + lreq.add(new LockRequest(parmID, lock, + LockMode.BREAK_LOCK)); + } + ServerResponse> sr = client + .requestLockChange(lreq); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "Error attempting to remove locks: %s", + sr.message())); } - - // delete all grids - parm.deleteTR(tr); - parm.saveParameter(tr); } + + // delete all grids + parm.deleteTR(tr); + parm.saveParameter(tr); } } - - statusHandler.handle(Priority.SIGNIFICANT, - "Prac_Fcst database has been cleared."); - - } catch (GFEServerException e) { - statusHandler - .handle(Priority.PROBLEM, - "Unexpected exception while attempting to clear practice grids", - e); } + statusHandler.handle(Priority.SIGNIFICANT, + "Prac_Fcst database has been cleared."); + return null; } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ClearPracticeVTECTable.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ClearPracticeVTECTable.java index 643b04e9d8..24720e8485 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ClearPracticeVTECTable.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ClearPracticeVTECTable.java @@ -21,7 +21,7 @@ package com.raytheon.viz.gfe.actions; /** - * TODO Add Description + * Action handler to clear practice active table. * *
  *
@@ -30,6 +30,7 @@ package com.raytheon.viz.gfe.actions;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Apr 23, 2010            wkwock     Initial creation
+ * Nov 17, 2015  #5129     dgilling   Support new IFPClient.
  *
  * 
* @@ -40,40 +41,38 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import com.raytheon.uf.common.activetable.ActiveTableMode; +import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.viz.gfe.Activator; -import com.raytheon.viz.gfe.constants.StatusConstants; import com.raytheon.viz.gfe.core.DataManager; +import com.raytheon.viz.gfe.core.DataManagerUIFactory; public class ClearPracticeVTECTable extends AbstractHandler { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(ClearPracticeVTECTable.class); + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(ClearPracticeVTECTable.class); - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - try { - DataManager dm = DataManager.getCurrentInstance(); - if (dm != null) { - dm.getClient().clearPracticeTable(dm.getSiteID()); - - statusHandler.handle(Priority.SIGNIFICANT, - "Practice VTEC table has been cleared."); - } else { - statusHandler.handle(Priority.PROBLEM, - "Failed to clear practice VTEC table"); - } - - } catch (VizException e) { - statusHandler.handle( - Priority.PROBLEM, - "Unexpected exception while attempting to clear practice VTEC table", - e); - } - - return null; - } + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + DataManager dm = DataManagerUIFactory.getCurrentInstance(); + if (dm != null) { + ServerResponse sr = dm.getClient().clearVTECTable( + ActiveTableMode.PRACTICE); + if (!sr.isOkay()) { + statusHandler + .error(String.format( + "Failed to clear practice VTEC table: %s", + sr.message())); + } else { + statusHandler.handle(Priority.SIGNIFICANT, + "Practice VTEC table has been cleared."); + } + } else { + statusHandler.handle(Priority.PROBLEM, + "Failed to clear practice VTEC table"); + } + return null; + } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ShowDeleteSelectionTimeRangeDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ShowDeleteSelectionTimeRangeDialog.java index 5561b8d732..2f26ffa0c1 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ShowDeleteSelectionTimeRangeDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ShowDeleteSelectionTimeRangeDialog.java @@ -37,6 +37,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * Jan 23, 2008 Eric Babin Initial Creation * Oct 25, 2012 1287 rferrel Changes for non-blocking ShowDeleteSelectionTimeRangeDialog. * Aug 27, 2015 4749 njensen Now extends GfeShowDialogHandler + * Dec 02, 2015 5129 dgilling Support modified dialog constructor. * * * @@ -46,6 +47,7 @@ public class ShowDeleteSelectionTimeRangeDialog extends GfeShowDialogHandler { @Override protected CaveJFACEDialog createDialog(Shell shell, DataManager dm, ExecutionEvent event) { - return new SaveDeleteSelectTRDialog(shell, dm, "Delete"); + return new SaveDeleteSelectTRDialog(shell, + dm.getSelectTimeRangeManager(), "Delete"); } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ShowIscRequestReplyDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ShowIscRequestReplyDialog.java index c6e004df8c..8d96bd0789 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ShowIscRequestReplyDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ShowIscRequestReplyDialog.java @@ -42,6 +42,7 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeOperations; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Sep 15, 2015 #4858 dgilling Initial creation + * Nov 30, 2015 #5129 dgilling Add DataManager instance as a field. * * * @@ -65,16 +66,19 @@ public class ShowIscRequestReplyDialog extends AbstractHandler { if (iscRequestDlg == null || iscRequestDlg.getShell() == null || iscRequestDlg.isDisposed()) { - iscRequestDlg = new ISCRequestReplyDlg(shell); - iscRequestDlg.setCloseCallback(new ICloseCallback() { + DataManager dm = DataManagerUIFactory.getCurrentInstance(); + if (dm != null) { + iscRequestDlg = new ISCRequestReplyDlg(dm, shell); + iscRequestDlg.setCloseCallback(new ICloseCallback() { - @Override - public void dialogClosed(Object returnValue) { - iscRequestDlg = null; + @Override + public void dialogClosed(Object returnValue) { + iscRequestDlg = null; - } - }); - iscRequestDlg.open(); + } + }); + iscRequestDlg.open(); + } } else { iscRequestDlg.bringToTop(); } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ShowSaveSelectionTimeRangeDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ShowSaveSelectionTimeRangeDialog.java index bf7a75250e..8a7b85f904 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ShowSaveSelectionTimeRangeDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/ShowSaveSelectionTimeRangeDialog.java @@ -38,6 +38,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * Nov 11, 2008 1213 wdougherty Use SelectTimeRangeContainer * Oct 25, 2012 1287 rferrel Code changes for non-blocking SaveDeleteSelectTRDialog. * Aug 27, 2015 4749 njensen Now extends GfeShowDialogHandler + * Dec 02, 2015 5129 dgilling Support modified dialog constructor. * * * @@ -47,6 +48,7 @@ public class ShowSaveSelectionTimeRangeDialog extends GfeShowDialogHandler { @Override protected CaveJFACEDialog createDialog(Shell shell, DataManager dm, ExecutionEvent event) { - return new SaveDeleteSelectTRDialog(shell, dm, "Save"); + return new SaveDeleteSelectTRDialog(shell, + dm.getSelectTimeRangeManager(), "Save"); } } \ No newline at end of file diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/config/ConfigCatalog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/config/ConfigCatalog.java index 63be999edb..133ab9e8bf 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/config/ConfigCatalog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/config/ConfigCatalog.java @@ -19,7 +19,6 @@ **/ package com.raytheon.viz.gfe.config; -import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -29,6 +28,8 @@ import java.util.Set; import jep.JepException; import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil; +import com.raytheon.uf.common.localization.ILocalizationFile; +import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; @@ -50,6 +51,7 @@ import com.raytheon.uf.common.util.FileUtil; * Jan 21, 2010 randerso Initial creation * Jul 08, 2014 3361 njensen Consolidated code * Sep 29, 2014 2975 njensen Only look up files in CAVE_STATIC + * Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs. * * * @@ -82,22 +84,20 @@ public class ConfigCatalog { * @return true if config file is hidden */ public boolean isHidden(String name) { - LocalizationFile lf = getFile(name); - File file = lf.getFile(); boolean rtnVal = false; - if (file == null || !file.exists()) { + + LocalizationFile lf = getFile(name); + if (lf == null || !lf.exists()) { throw new IllegalArgumentException("No such GFE config file: " + name); } else { - // Look for HideConfigFile = True in the file - PythonScript pscript = null; - try { - String configPath = GfePyIncludeUtil.getConfigIncludePath(); - String vtecPath = GfePyIncludeUtil.getVtecIncludePath(); + String configPath = GfePyIncludeUtil.getConfigIncludePath(); + String vtecPath = GfePyIncludeUtil.getVtecIncludePath(); - pscript = new PythonScript(file.getAbsolutePath(), - PyUtil.buildJepIncludePath(configPath, vtecPath), - getClass().getClassLoader(), preEvals); + // Look for HideConfigFile = True in the file + try (PythonScript pscript = new PythonScript(lf.getFile() + .getAbsolutePath(), PyUtil.buildJepIncludePath(configPath, + vtecPath), getClass().getClassLoader(), preEvals)) { Boolean scriptValue = (Boolean) pscript.execute( "checkHideConfigFile", null); rtnVal = scriptValue.booleanValue(); @@ -108,10 +108,6 @@ public class ConfigCatalog { Priority.PROBLEM, "Error loading GFE config file: " + e.getLocalizedMessage(), e); - } finally { - if (pscript != null) { - pscript.dispose(); - } } } return rtnVal; @@ -122,8 +118,8 @@ public class ConfigCatalog { * * @return the localization files for the procedures. */ - public LocalizationFile[] getFiles() { - LocalizationFile[] procFiles = PathManagerFactory.getPathManager() + public ILocalizationFile[] getFiles() { + ILocalizationFile[] procFiles = PathManagerFactory.getPathManager() .listStaticFiles(LocalizationType.CAVE_STATIC, GfePyIncludeUtil.CONFIG, new String[] { EXTENSION }, false, true); @@ -136,9 +132,8 @@ public class ConfigCatalog { * @return the simple names of the procedures. */ public Collection getNames() { - Collection result = new HashSet(); - LocalizationFile[] procFiles = getFiles(); - result = scriptNames(procFiles); + ILocalizationFile[] procFiles = getFiles(); + Collection result = scriptNames(procFiles); return result; } @@ -148,8 +143,8 @@ public class ConfigCatalog { * @return The localization file for the script */ public LocalizationFile getFile(String scriptName) { - String fname = GfePyIncludeUtil.CONFIG + File.separator + scriptName - + EXTENSION; + String fname = GfePyIncludeUtil.CONFIG + IPathManager.SEPARATOR + + scriptName + EXTENSION; LocalizationFile file = PathManagerFactory.getPathManager() .getStaticLocalizationFile(LocalizationType.CAVE_STATIC, fname); return file; @@ -163,16 +158,14 @@ public class ConfigCatalog { * the array of LocalizationFiles. * @return a Collection of simple script names with no duplicates. */ - protected Collection scriptNames(LocalizationFile[] scriptFiles) { + protected Collection scriptNames(ILocalizationFile[] scriptFiles) { Set procs = new HashSet(); - String fname = null; - String[] fsplit = null; - String script = null; if (scriptFiles != null) { - for (LocalizationFile file : scriptFiles) { - fname = file.getName(); - fsplit = fname.split(FileUtil.fileSeparatorRegex); - script = fsplit[fsplit.length - 1].replaceAll("\\.py$", ""); + for (ILocalizationFile file : scriptFiles) { + String fname = file.getPath(); + String[] fsplit = fname.split(FileUtil.fileSeparatorRegex); + String script = fsplit[fsplit.length - 1].replaceAll("\\.py$", + ""); procs.add(script); } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/DataManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/DataManager.java index b5c18c84dd..39bc1146aa 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/DataManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/DataManager.java @@ -20,22 +20,28 @@ package com.raytheon.viz.gfe.core; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.commons.lang3.StringUtils; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.ui.IWorkbenchWindow; +import com.raytheon.uf.common.activetable.ActiveTableMode; import com.raytheon.uf.common.activetable.ActiveTableRecord; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; import com.raytheon.uf.common.dataplugin.gfe.request.GetIscSendStatusRequest.IscSendStatus; +import com.raytheon.uf.common.dataplugin.gfe.request.IscRequestQueryRequest.IscQueryResponse; import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; +import com.raytheon.uf.common.gfe.ifpclient.IFPClient; import com.raytheon.uf.common.message.WsId; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; @@ -44,14 +50,13 @@ import com.raytheon.uf.common.time.ISimulatedTimeChangeListener; import com.raytheon.uf.common.time.SimulatedTime; import com.raytheon.uf.common.time.TimeRange; import com.raytheon.uf.viz.core.VizApp; -import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.localization.LocalizationManager; import com.raytheon.uf.viz.core.notification.jobs.NotificationManagerJob; import com.raytheon.viz.core.mode.CAVEMode; import com.raytheon.viz.gfe.GFEServerException; import com.raytheon.viz.gfe.core.internal.DataMgrInitStatus; import com.raytheon.viz.gfe.core.internal.GFEParmCacheInitJob; import com.raytheon.viz.gfe.core.internal.GFETopoManager; -import com.raytheon.viz.gfe.core.internal.IFPClient; import com.raytheon.viz.gfe.core.internal.NotificationRouter; import com.raytheon.viz.gfe.core.internal.ParmManager; import com.raytheon.viz.gfe.core.internal.ReferenceSetManager; @@ -104,6 +109,7 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeProhibitedOpException; * 08/14/2015 4750 dgilling Remove use of PythonScript in doIscRequestQuery. * 08/20/2015 4749 dgilling Ensure TextProductManager is disposed on dispose. * 09/15/2015 4858 dgilling Disable ISC when DRT mode is enabled. + * 11/18/2015 5129 dgilling Support new IFPClient. * * * @author chammack @@ -195,7 +201,7 @@ public class DataManager implements ISimulatedTimeChangeListener { private Map officeTypeDict; - private HashSet knownOfficeTypes; + private Set knownOfficeTypes; private List allSites; @@ -204,7 +210,7 @@ public class DataManager implements ISimulatedTimeChangeListener { private final SmartToolJobPool toolJobPool; private boolean previousIscSendState; - + private final AtomicBoolean smartToolsInitialized; private final AtomicBoolean proceduresInitialized; @@ -231,7 +237,8 @@ public class DataManager implements ISimulatedTimeChangeListener { throws GFEServerException { this.spatialDisplayManager = factory.createSpatialDisplayManager(this, discriminator); - this.client = new IFPClient(VizApp.getWsId(), this); + this.client = new IFPClient(VizApp.getWsId(), LocalizationManager + .getInstance().getSite()); this.router = new NotificationRouter(this.getSiteID()); NotificationManagerJob.addObserver("edex.alerts.gfe", this.router); @@ -260,23 +267,25 @@ public class DataManager implements ISimulatedTimeChangeListener { this.editActionProcessor = new EditActionProcessor(this); // get office type information, convert to Dictionary - this.allSites = client.getKnownSites(); - List allOT = client.getKnownOfficeTypes(); - this.officeTypeDict = new HashMap(); - for (int i = 0; i < allSites.size(); i++) { - officeTypeDict.put(allSites.get(i), allOT.get(i)); - } + ServerResponse> sr = client + .getKnownSitesWithOfficeType(); + this.officeTypeDict = Collections.unmodifiableMap(sr.getPayload()); + this.allSites = Collections.unmodifiableList(new ArrayList<>( + this.officeTypeDict.keySet())); this.officeType = officeTypeDict.get(this.siteId); // determine all known office types - this.knownOfficeTypes = new HashSet(allOT); + this.knownOfficeTypes = Collections + .unmodifiableSet(new HashSet(this.officeTypeDict + .values())); ISCInitJob iscInitJob = new ISCInitJob(this); iscInitJob.setSystem(true); iscInitJob.schedule(); // get the ISC states - IscSendStatus iscSendStatus = client.getIscSendStatus(); + ServerResponse sr2 = client.iscSendStatus(); + IscSendStatus iscSendStatus = sr2.getPayload(); this.sendISConSave = iscSendStatus.isSendISConSave(); this.sendISConPublish = iscSendStatus.isSendISConPublish(); this.requestISC = iscSendStatus.isRequestISC(); @@ -431,12 +440,8 @@ public class DataManager implements ISimulatedTimeChangeListener { */ public synchronized String getSiteID() { if (siteId == null) { - try { - siteId = getClient().getSiteID().get(0); - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, "Unable to get site ID", - e); - } + ServerResponse sr = getClient().getSiteID(); + siteId = sr.getPayload(); } return siteId; } @@ -489,16 +494,24 @@ public class DataManager implements ISimulatedTimeChangeListener { } /** - * Return the inventory for a parm + * Obtains and returns the current server inventory for the specified + * weather element identifier. * * @param parmID - * @return inventory for the parm - * - * @throws GFEServerException + * Weather element to retrieve inventory for. + * @return inventory for the parm. In the case of failure, an empty list + * will be returned. */ - public List serverParmInventory(final ParmID parmID) - throws GFEServerException { - return this.client.getGridInventory(parmID); + public List serverParmInventory(final ParmID parmID) { + ServerResponse> sr = client.getGridInventory(parmID); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "Unable to obtain serverParmInventory for %s: %s", parmID, + sr.message())); + return Collections.emptyList(); + } + + return sr.getPayload(); } /** @@ -610,53 +623,49 @@ public class DataManager implements ISimulatedTimeChangeListener { } /** - * @return A List of Objects, the active table. - * @throws VizException + * Returns the current vtecActiveTable, based upon the current + * {@code CAVEMode}. + * + * @return The current active table. */ - public List getActiveTable() throws VizException { - List result = getClient().getVTECActiveTable(siteId); - return result; + public List getActiveTable() { + ActiveTableMode tableName = (CAVEMode.getMode() == CAVEMode.PRACTICE) ? ActiveTableMode.PRACTICE + : ActiveTableMode.OPERATIONAL; + ServerResponse> sr = getClient() + .getVTECActiveTable(tableName); + if (!sr.isOkay()) { + statusHandler.error("Unable to obtain vtecActiveTable: " + + sr.message()); + } + return sr.getPayload(); } - @SuppressWarnings("unchecked") - public Object[] doIscRequestQuery() { - String xml = null; - List parmsWanted = new ArrayList(); - Map>>> domainDict = null; - Map serverDictS2T = null; - Map> serverDictT2S = null; - - try { - ServerResponse> sResponse = client.iscRequestQuery(); - if (!sResponse.isOkay()) { - return null; - } - List response = sResponse.getPayload(); - xml = (String) response.get(0); - List parmList = (List) response.get(2); - for (String p : parmList) { - parmsWanted.add(p.replace("_SFC", "")); - } - - Map obj = (Map) response.get(1); - domainDict = (Map>>>) obj - .get("domains"); - serverDictS2T = (Map) obj.get("serverDictS2T"); - serverDictT2S = (Map>) obj - .get("serverDictT2S"); - } catch (GFEServerException e) { - statusHandler - .handle(Priority.PROBLEM, - "Server Problem: Unable to get server info from iscRequestQuery", - e); + public IscQueryResponse doIscRequestQuery() { + ServerResponse sr = client.iscRequestQuery(); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "Unable to get server info from iscRequestQuery: %s", + sr.message())); + return new IscQueryResponse(); } - return new Object[] { xml, parmsWanted, domainDict, serverDictS2T, - serverDictT2S }; + Collection parmsWanted = Collections.emptyList(); + Collection parms = sr.getPayload().getRequestedParms(); + parmsWanted = new ArrayList<>(parms.size()); + for (String parm : parms) { + parmsWanted.add(parm.replace("_SFC", StringUtils.EMPTY)); + } + + return new IscQueryResponse(sr.getPayload().getDomainDict(), sr + .getPayload().getServerDictT2S(), parmsWanted); } - public void makeISCRequest(String xmlreq) throws GFEServerException { - client.iscMakeISCRequest(xmlreq); + public void makeISCRequest(String xmlRequest) { + ServerResponse sr = client.iscRequestMake(xmlRequest); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "Unable to process iscRequestMake: %s", sr.message())); + } } public String officeType(String site) { diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/IReferenceSetManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/IReferenceSetManager.java index e411006a46..237496a05f 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/IReferenceSetManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/IReferenceSetManager.java @@ -26,10 +26,12 @@ import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DFloat; import com.raytheon.uf.common.dataplugin.gfe.reference.GroupID; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID; +import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator; import com.raytheon.viz.gfe.core.msgs.IEditAreaGroupInvChangedListener; import com.raytheon.viz.gfe.core.msgs.IReferenceSetChangedListener; import com.raytheon.viz.gfe.core.msgs.IReferenceSetIDChangedListener; import com.raytheon.viz.gfe.core.msgs.IReferenceSetInvChangedListener; +import com.raytheon.viz.gfe.query.QueryScript; /** * Public interface for ReferenceSetManager @@ -42,6 +44,8 @@ import com.raytheon.viz.gfe.core.msgs.IReferenceSetInvChangedListener; * 02/14/2013 #1506 mnash Move away from using QueryScript on the UI thread * 02/26/2013 #1708 randerso Remove evaluateRefSet from public interface * Aug 13, 2015 4749 njensen Extends DisposableManager + * Nov 18, 2015 5129 dgilling Remove UI-related arguments from deleteRefSet. + * Dec 16, 2015 4816 dgilling Add getPythonThreadPool. * * * @@ -151,11 +155,9 @@ public interface IReferenceSetManager extends DisposableManager { * works, returns true. * * @param refID - * @param withVerification * @return true if successful */ - public abstract boolean deleteRefSet(final ReferenceID refID, - boolean withVerification); + public abstract boolean deleteRefSet(final ReferenceID refID); /** * Undo for Reference Sets. Uses _prevRefSet @@ -342,4 +344,14 @@ public interface IReferenceSetManager extends DisposableManager { * @return true is query will recurse */ public boolean willRecurse(String name, String query); + + /** + * Returns a reference to the {@link PythonJobCoordinator} so other classes + * can evaluate query-based edit areas using this + * {@code IReferenceSetManager}'s thread pool. + * + * @return {@code PythonJobCoordinator} for evaluating query-based edit + * areas. + */ + public PythonJobCoordinator getPythonThreadPool(); } \ No newline at end of file diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISelectTimeRangeManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISelectTimeRangeManager.java index 353ee90721..8e1aced8db 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISelectTimeRangeManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISelectTimeRangeManager.java @@ -19,6 +19,8 @@ **/ package com.raytheon.viz.gfe.core; +import java.util.TimeZone; + import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange; import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange.Mode; @@ -33,6 +35,7 @@ import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange.Mode; * Dec 3, 2009 randerso Initial creation * Aug 1, 2012 #965 dgilling Change location of SelectTimeRange. * Aug 13, 2015 4749 njensen Extends DisposableManager + * Dec 02, 2015 5129 dgilling Add getTimeZone. * * * @@ -78,4 +81,10 @@ public interface ISelectTimeRangeManager extends DisposableManager { */ public void remove(String name); + /** + * Returns the local site's time zone. + * + * @return + */ + public TimeZone getTimeZone(); } \ No newline at end of file diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/SampleSetMgrInitJob.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/SampleSetMgrInitJob.java index 8b9357d62e..df782e4ac9 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/SampleSetMgrInitJob.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/SampleSetMgrInitJob.java @@ -37,6 +37,7 @@ import com.raytheon.viz.gfe.core.internal.SampleSetManager; * ------------ ---------- ----------- -------------------------- * Jan 25, 2011 njensen Initial creation * Sep 09, 2014 #3592 randerso Removed unused DataManager parameter to SampleSetManager constructor + * Nov 19, 2014 #5129 dgilling Pass IFPClient into constructor. * * * @@ -61,7 +62,7 @@ public class SampleSetMgrInitJob extends Job { */ @Override protected IStatus run(IProgressMonitor monitor) { - dataMgr.sampleSetManager = new SampleSetManager(); + dataMgr.sampleSetManager = new SampleSetManager(dataMgr.getClient()); dataMgr.getInitStatus().setSampleSetMgrDone(true); return Status.OK_STATUS; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/SelectTRMgrInitJob.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/SelectTRMgrInitJob.java index 8f69e402a5..a831078ea4 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/SelectTRMgrInitJob.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/SelectTRMgrInitJob.java @@ -19,11 +19,16 @@ **/ package com.raytheon.viz.gfe.core; +import java.util.TimeZone; + import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; +import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; import com.raytheon.viz.gfe.core.internal.SelectTimeRangeManager; /** @@ -36,6 +41,7 @@ import com.raytheon.viz.gfe.core.internal.SelectTimeRangeManager; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jan 25, 2011 njensen Initial creation + * Dec 02, 2015 #5129 dgilling Support modified constructor. * * * @@ -45,6 +51,9 @@ import com.raytheon.viz.gfe.core.internal.SelectTimeRangeManager; public class SelectTRMgrInitJob extends Job { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(getClass()); + private DataManager dataMgr; public SelectTRMgrInitJob(DataManager dm) { @@ -52,15 +61,19 @@ public class SelectTRMgrInitJob extends Job { this.dataMgr = dm; } - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime. - * IProgressMonitor) - */ @Override protected IStatus run(IProgressMonitor monitor) { - dataMgr.selectTimeRangeManager = new SelectTimeRangeManager(dataMgr); + ServerResponse sr = dataMgr.getClient().getSiteTimeZone( + dataMgr.getSiteID()); + TimeZone tz; + if (sr.isOkay()) { + tz = TimeZone.getTimeZone(sr.getPayload()); + } else { + statusHandler.error("Unable to retrieve GFE time zone, using GMT"); + tz = TimeZone.getTimeZone("GMT"); + } + + dataMgr.selectTimeRangeManager = new SelectTimeRangeManager(tz); dataMgr.getInitStatus().setSelectTRMgrDone(true); return Status.OK_STATUS; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/UIFormat.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/UIFormat.java index 86b7b67460..34288277c9 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/UIFormat.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/UIFormat.java @@ -25,7 +25,7 @@ import java.util.Arrays; import java.util.List; import java.util.TimeZone; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/DiscreteGridData.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/DiscreteGridData.java index 7545ad856c..95bc1a1c6e 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/DiscreteGridData.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/DiscreteGridData.java @@ -25,7 +25,7 @@ import java.util.Arrays; import java.util.Date; import java.util.List; -import org.apache.commons.lang.mutable.MutableByte; +import org.apache.commons.lang3.mutable.MutableByte; import org.geotools.geometry.jts.JTS; import org.opengis.metadata.spatial.PixelOrientation; import org.opengis.referencing.FactoryException; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/WeatherGridData.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/WeatherGridData.java index a2e03963c5..610638f62e 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/WeatherGridData.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/WeatherGridData.java @@ -24,7 +24,7 @@ import java.util.Arrays; import java.util.Date; import java.util.List; -import org.apache.commons.lang.mutable.MutableByte; +import org.apache.commons.lang3.mutable.MutableByte; import org.geotools.geometry.jts.JTS; import org.opengis.metadata.spatial.PixelOrientation; import org.opengis.referencing.FactoryException; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractSpatialDisplayManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractSpatialDisplayManager.java index 57428c73fd..dc70e03d93 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractSpatialDisplayManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractSpatialDisplayManager.java @@ -25,11 +25,10 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.apache.commons.lang.Validate; +import org.apache.commons.lang3.Validate; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; -import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.DataTime; @@ -42,7 +41,6 @@ import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.ResourceList; import com.raytheon.uf.viz.core.rsc.ResourceProperties; -import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability; import com.raytheon.viz.gfe.Activator; import com.raytheon.viz.gfe.GFEOperationFailedException; import com.raytheon.viz.gfe.actions.ShowISCMarkersAction; @@ -164,6 +162,7 @@ public abstract class AbstractSpatialDisplayManager implements * * @see com.raytheon.viz.gfe.core.ISpatialDisplayManager#getActivatedParm() */ + @Override public Parm getActivatedParm() { return activeParm; } @@ -186,6 +185,7 @@ public abstract class AbstractSpatialDisplayManager implements * addActivatedParmChangedListener * (com.raytheon.viz.gfe.core.msgs.IActivatedParmChangedListener) */ + @Override public void addActivatedParmChangedListener( IActivatedParmChangedListener listener) { Validate.notNull(listener, "Attempting to add null listener"); @@ -199,6 +199,7 @@ public abstract class AbstractSpatialDisplayManager implements * removeActivatedParmChangedListener * (com.raytheon.viz.gfe.core.msgs.IActivatedParmChangedListener) */ + @Override public void removeActivatedParmChangedListener( IActivatedParmChangedListener parmChangeListener) { this.activatedParmChangedListeners.remove(parmChangeListener); @@ -238,6 +239,7 @@ public abstract class AbstractSpatialDisplayManager implements * addGridVisibilityChangedListener * (com.raytheon.viz.gfe.core.msgs.IGridVisibilityChangedListener) */ + @Override public void addGridVisibilityChangedListener( IGridVisibilityChangedListener listener) { Validate.notNull(listener, "Attempting to add null listener"); @@ -251,6 +253,7 @@ public abstract class AbstractSpatialDisplayManager implements * removeGridVisibilityChangedListener * (com.raytheon.viz.gfe.core.msgs.IGridVisibilityChangedListener) */ + @Override public void removeGridVisibilityChangedListener( IGridVisibilityChangedListener parmChangeListener) { this.gridVisibilityChangedListeners.remove(parmChangeListener); @@ -491,6 +494,7 @@ public abstract class AbstractSpatialDisplayManager implements * com.raytheon.viz.gfe.core.ISpatialDisplayManager#activateParm(com.raytheon * .viz.gfe.core.parm.Parm) */ + @Override public void activateParm(Parm parmToActivate) throws GFEOperationFailedException { // Keep any resources on descriptors in sync @@ -504,11 +508,11 @@ public abstract class AbstractSpatialDisplayManager implements if (props.isSystemResource()) { continue; } - Parm parm = ((GFEResource) rsc).getParm(); + Parm parm = rsc.getParm(); if (parm.equals(parmToActivate)) { props.setVisible(true); } - ((GFEResource) rsc).reset(); + rsc.reset(); } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/GFETopoManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/GFETopoManager.java index d96e0ed720..ee3178d7b2 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/GFETopoManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/GFETopoManager.java @@ -27,23 +27,25 @@ import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.viz.gfe.GFEServerException; import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.core.ITopoManager; /** * GFETopoMgr manages the set of topography data sets available from the * ifpServer. - * + *

* All parms now use the same topo data, since the assumption is that all parms * in a database have the same exact GridLocation. * *

+ * 
  * SOFTWARE HISTORY
- * Date			Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * Jul  2, 2008		#1160	randerso	Initial creation
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jul 02, 2008     #1160   randerso    Initial creation
  * Nov 20, 2013     #2331   randerso    Re-implemented to better match A1 design
+ * Nov 18, 2015     #5129   dgilling    Updates for new IFPClient.
  * 
  * 
* @@ -85,19 +87,14 @@ public class GFETopoManager implements ITopoManager { if (compositeTopo == null) { GridLocation gloc = dataManager.getParmManager() .compositeGridLocation(); - try { - ServerResponse sr = this.dataManager - .getClient().getTopoData(gloc); - if (!sr.isOkay()) { - statusHandler - .error("Error getting topography data from IFPServer: " - + sr.message()); - } - compositeTopo = sr.getPayload(); - } catch (GFEServerException e) { - statusHandler.error( - "Error getting topography data from IFPServer: ", e); + ServerResponse sr = dataManager.getClient() + .getTopoData(gloc); + if (!sr.isOkay()) { + statusHandler + .error("Error getting topography data from IFPServer: " + + sr.message()); } + compositeTopo = sr.getPayload(); } return compositeTopo; } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/IFPClient.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/IFPClient.java deleted file mode 100644 index f45a73494d..0000000000 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/IFPClient.java +++ /dev/null @@ -1,821 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ - -package com.raytheon.viz.gfe.core.internal; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -import com.raytheon.uf.common.activetable.ActiveTableMode; -import com.raytheon.uf.common.activetable.ActiveTableRecord; -import com.raytheon.uf.common.activetable.request.ClearPracticeVTECTableRequest; -import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID; -import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation; -import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo; -import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; -import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteDefinition; -import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteKey; -import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData; -import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID; -import com.raytheon.uf.common.dataplugin.gfe.request.AbstractGfeRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.CommitGridsRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.CreateNewDbRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetActiveTableRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetClientsRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetDbInventoryRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetDiscreteDefinitionRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetGridDataRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetGridHistoryRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetGridInventoryRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetGridParmInfoRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetIscSendStatusRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetIscSendStatusRequest.IscSendStatus; -import com.raytheon.uf.common.dataplugin.gfe.request.GetKnownOfficeTypesRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetKnownSitesRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetLockTablesRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetOfficialDbNameRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetParmListRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetTopoDataRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GetWXDefinitionRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.GridLocRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.IscCreateDomainDictRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.IscGetRequestXmlRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.IscMakeRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.IscRequestQueryRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.LockChangeRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.SaveGfeGridRequest; -import com.raytheon.uf.common.dataplugin.gfe.request.SendIscGridRequest; -import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable; -import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerMsg; -import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; -import com.raytheon.uf.common.dataplugin.gfe.server.request.CommitGridRequest; -import com.raytheon.uf.common.dataplugin.gfe.server.request.GetGridRequest; -import com.raytheon.uf.common.dataplugin.gfe.server.request.LockRequest; -import com.raytheon.uf.common.dataplugin.gfe.server.request.LockTableRequest; -import com.raytheon.uf.common.dataplugin.gfe.server.request.SaveGridRequest; -import com.raytheon.uf.common.dataplugin.gfe.server.request.SendISCRequest; -import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice; -import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice; -import com.raytheon.uf.common.dataplugin.gfe.weather.WeatherSubKey; -import com.raytheon.uf.common.dataplugin.gfe.weather.WxDefinition; -import com.raytheon.uf.common.message.WsId; -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.TimeRange; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.localization.LocalizationManager; -import com.raytheon.uf.viz.core.requests.ThriftClient; -import com.raytheon.viz.core.mode.CAVEMode; -import com.raytheon.viz.gfe.Activator; -import com.raytheon.viz.gfe.GFEServerException; -import com.raytheon.viz.gfe.core.DataManager; -import com.raytheon.viz.gfe.core.IParmManager; -import com.raytheon.viz.gfe.core.IReferenceSetManager; -import com.raytheon.viz.gfe.core.parm.Parm; - -/** - * This class provides the interface to the IFPServer. - * - *
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 4/10/08      875        bphillip    Initial Creation
- * 4/17/08      1075       randerso    Created temporary static grid location data
- * 4/18/08      875        bphillip    Refined save functionality
- * 06/17/08     #940       bphillip    Implemented GFE Locking
- * 01/29/09     #1271      njensen     Moved communication from ProductSrv to GfeSrv
- * 06/11/09     #1947      rjpeter     Fixed null pointers.
- * 07/09/09     #2590      njensen     Site ID from preferences and sent on all requests.
- * 09/22/09     #3058      rjpeter     Removed GFE Edex dependency.
- * 05/02/13     #1969      randerso    Added createNewDb method
- * 06/06/13     #2073      dgilling    Make getGridInventory() better match A1,
- *                                     fix warnings.
- * 11/20/2013   #2331      randerso    Added getTopoData method
- * 04/03/2014   #2737      randerso    Moved clientISCSendStatus to SaveGFEGridRequest
- * 04/09/2014   #3004      dgilling    Support moved ClearPracticeVTECTableRequest.
- * 07/01/2014   #3149      randerso    Changed getGridData to handle limited number of grids returned 
- *                                     and re-request if not all data returned
- * 09/23/14     #3648      randerso    Changed getParmList to return results even if some DbIds
- *                                     have errors
- * 
- * 
- * - * @author bphillip - * @version 1.0 - */ -public class IFPClient { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(IFPClient.class); - - // we pull the site ID from CAVE configuration because the server - // can run as multiple sites but the client can only be one - private static final String siteID = LocalizationManager.getInstance() - .getCurrentSite(); - - /** The workstationID of the owner of this IFPClient instance */ - private final WsId workstationID; - - private DataManager dataManager; - - /** - * Creates a new IFPClient - * - * @param wsId - * The workstationID of the creator - */ - public IFPClient(WsId wsId, DataManager dataManager) { - this.dataManager = dataManager; - workstationID = wsId; - try { - // get and set the WxDefinition - WxDefinition wxDef = getWXDefinition(); - WeatherSubKey.setWxDefinition(siteID, wxDef); - - // get and set the DiscreteDefinition - DiscreteDefinition dDef = getDiscreteDefinition(); - DiscreteKey.setDiscreteDefinition(siteID, dDef); - - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); - - } - } - - /** - * Gets a list of ParmIDs for the provided databaseID from the IFPServer - * - * @param id - * The database ID for which to get the ParmIDs - * @return The list of parms for the provided databaseID - * @throws GFEServerException - * - */ - public List getParmList(DatabaseID id) throws GFEServerException { - return getParmList(Arrays.asList(new DatabaseID[] { id })); - } - - /** - * Gets a list of ParmIDs for the provided list of databaseIDs from the - * IFPServer - * - * @param ids - * The list of databaseIDS for which to get the parmIDs - * @return The list of parms for the provided list of databaseIDs - * @throws GFEServerException - * - */ - @SuppressWarnings("unchecked") - public List getParmList(List ids) - throws GFEServerException { - GetParmListRequest request = new GetParmListRequest(); - request.setDbIds(ids); - ServerResponse sr = makeRequest(request, false); - List parmIds = (List) sr.getPayload(); - if (!sr.isOkay()) { - String msg = formatSRMessage(sr); - if (parmIds != null && !parmIds.isEmpty()) { - // got something so display an error message and continue - statusHandler.error(msg); - } else { - // got nothing so throw exception - throw new GFEServerException(msg); - } - } - - return parmIds; - } - - /** - * Gets the grid parm info for the specified parmIDs from the IFPServer - * - * @param parmIds - * The parm IDs to get parm info for - * @return The parm information - * @throws GFEServerException - * - */ - @SuppressWarnings("unchecked") - public List getGridParmInfo(List parmIds) - throws GFEServerException { - GetGridParmInfoRequest request = new GetGridParmInfoRequest(); - request.setParmIds(parmIds); - ServerResponse sr = makeRequest(request); - return (List) sr.getPayload(); - } - - public GridParmInfo getGridParmInfo(ParmID parmId) - throws GFEServerException { - List gpi = getGridParmInfo(Arrays - .asList(new ParmID[] { parmId })); - if ((gpi == null) || gpi.isEmpty()) { - return null; - } else { - return gpi.get(0); - } - } - - /** - * Gets the localized site ID for this GFE instance - * - * @return The site ID for this GFE instance - * @throws GFEServerException - * - */ - public List getSiteID() throws GFEServerException { - List siteIds = new ArrayList(); - siteIds.add(siteID); - return siteIds; - } - - /** - * Returns the time zone of the localized site - * - * @return the time zone - * @throws GFEServerException - */ - public String getSiteTimeZone() throws GFEServerException { - return getDBGridLocation().getTimeZone(); - } - - /** - * Returns the grid inventory for a given parmId - * - * @param parmId - * The parmId to get the inventory for - * @return A map of TimeRange(as a string) to the inventory as a list of - * GFERecords - * @throws GFEServerException - */ - public List getGridInventory(ParmID parmId) - throws GFEServerException { - Map> inventory = getGridInventory(Arrays - .asList(new ParmID[] { parmId })); - List times = inventory.get(parmId); - if (times == null) { - times = Collections.emptyList(); - } - return times; - } - - /** - * Gets the inventory of GFERecords from the IFPServer for the specified - * list of parmIds - * - * @param parmIds - * The parmIDs to get the inventory - * @return The inventory of GFERecords - * @throws GFEServerException - * - */ - @SuppressWarnings("unchecked") - public Map> getGridInventory(List parmIds) - throws GFEServerException { - GetGridInventoryRequest request = new GetGridInventoryRequest(); - request.setParmIds(parmIds); - ServerResponse>> response = (ServerResponse>>) makeRequest( - request, false); - return response.getPayload(); - } - - /** - * Requests a lock change identified by a single lock request. - * - * @param lockRequest - * The lock request - * @return The server response containing the changed lock tables - * @throws GFEServerException - */ - public ServerResponse> requestLockChange( - LockRequest lockRequest) throws GFEServerException { - ArrayList lreq = new ArrayList(); - lreq.add(lockRequest); - return requestLockChange(lreq); - } - - /** - * Requests a lock change identified by a list of lock requests - * - * @param lreq - * The lock requests - * @return The server response containing the changed lock tables - * @throws GFEServerException - */ - @SuppressWarnings("unchecked") - public ServerResponse> requestLockChange( - List lreq) throws GFEServerException { - LockChangeRequest request = new LockChangeRequest(); - request.setRequests(lreq); - ServerResponse sr = makeRequest(request); - return (ServerResponse>) sr; - } - - /** - * Gets the list of available databases from the IFPServer - * - * @return The list of available databases - * @throws GFEServerException - * - */ - @SuppressWarnings("unchecked") - public List getAvailableDbs() throws GFEServerException { - GetDbInventoryRequest request = new GetDbInventoryRequest(); - ServerResponse sr = makeRequest(request); - return (List) sr.getPayload(); - } - - @SuppressWarnings("unchecked") - public List getClients() throws GFEServerException { - GetClientsRequest request = new GetClientsRequest(); - ServerResponse sr = makeRequest(request); - return (List) sr.getPayload(); - } - - /** - * Retrieves the lock table from the server for this parm object.
- * This is a temporary method and will be replaced by a lock notification - * system to prevent large amounts of server requests when many parms are - * being saved - * - * @param parmId - * The parm to get the lock table for - * @return The lock table for the specified parm - * @throws GFEServerException - * - */ - @SuppressWarnings("unchecked") - public LockTable getLockTable(ParmID parmId) throws GFEServerException { - List ltReq = new ArrayList(); - ltReq.add(new LockTableRequest(parmId)); - GetLockTablesRequest request = new GetLockTablesRequest(); - request.setRequests(ltReq); - ServerResponse sr = makeRequest(request); - return ((List) sr.getPayload()).get(0); - } - - /** - * Gets a LockTable identified by a single database id - * - * @param dbId - * The database id - * @return The requested table - * @throws GFEServerException - */ - public List getLockTable(DatabaseID dbId) - throws GFEServerException { - List request = Arrays - .asList(new LockTableRequest[] { new LockTableRequest(dbId) }); - return getLockTable(request); - } - - /** - * Gets a list of LockTables identified by a list of lock table requests - * - * @param ltrList - * The list of lock table requests - * @return The list of LockTables - * @throws GFEServerException - */ - @SuppressWarnings("unchecked") - public List getLockTable(List ltrList) - throws GFEServerException { - GetLockTablesRequest request = new GetLockTablesRequest(); - request.setRequests(ltrList); - ServerResponse sr = makeRequest(request); - return (List) sr.getPayload(); - } - - /** - * Gets the grid location of the localized GFE instance - * - * @return The grid location of the localized GFE instance - * @throws GFEServerException - */ - @SuppressWarnings("unchecked") - public GridLocation getDBGridLocation() throws GFEServerException { - GridLocRequest request = new GridLocRequest(); - ServerResponse> sr = (ServerResponse>) makeRequest(request); - if (sr.isOkay()) { - return (GridLocation) sr.getPayload().get(0); - } else { - return null; - } - } - - /** - * Saves the parm information to the server - * - * @param requests - * the save grid requests - * @throws GFEServerException - */ - public ServerResponse saveGrids(List requests) - throws GFEServerException { - ServerResponse response = null; - if (!requests.isEmpty()) { - SaveGfeGridRequest request = new SaveGfeGridRequest( - dataManager.clientISCSendStatus(), requests); - response = makeRequest(request); - } - logResponse(response); - return response; - } - - /** - * Gets the list of known sites from the server - * - * @return The list of known sites from the server - * @throws GFEServerException - */ - @SuppressWarnings("unchecked") - public List getKnownSites() throws GFEServerException { - return (List) makeRequest(new GetKnownSitesRequest()) - .getPayload(); - } - - /** - * Gets the list of known office types from the server - * - * @return The list of known office types from the server - * @throws GFEServerException - */ - @SuppressWarnings("unchecked") - public List getKnownOfficeTypes() throws GFEServerException { - return (List) makeRequest(new GetKnownOfficeTypesRequest()) - .getPayload(); - } - - public IscSendStatus getIscSendStatus() throws GFEServerException { - GetIscSendStatusRequest request = new GetIscSendStatusRequest(); - request.setSiteID(siteID); - return (IscSendStatus) makeRequest(request).getPayload(); - } - - /** - * Logs a message to the message display - * - * @param message - * The message to display - */ - private void logMessage(String message) { - Status statusMessage = new Status(IStatus.INFO, Activator.PLUGIN_ID, - message + "\n"); - Activator.getDefault().getLog().log(statusMessage); - } - - /** - * Logs error messages contained in a ServerResponse object - * - * @param sr - * The ServerResponse object containing the messages - */ - private void logResponse(ServerResponse sr) { - for (ServerMsg msg : sr.getMessages()) { - logMessage(msg.getMessage()); - } - } - - /** - * Gets the discrete definition - * - * @return The discrete definition - * @throws GFEServerException - */ - @SuppressWarnings("unchecked") - public DiscreteDefinition getDiscreteDefinition() throws GFEServerException { - GetDiscreteDefinitionRequest request = new GetDiscreteDefinitionRequest(); - ServerResponse sr = (ServerResponse) makeRequest(request); - if (!sr.isOkay()) { - StringBuilder msg = new StringBuilder( - "Unable to retrieve DiscreteDefinition: "); - for (ServerMsg s : sr.getMessages()) { - msg.append("\n ").append(s.getMessage()); - } - - statusHandler.handle(Priority.PROBLEM, msg.toString()); - } - return sr.getPayload(); - } - - /** - * Gets the Wx Definition from the server - * - * @return The Wx Definition - * @throws GFEServerException - */ - @SuppressWarnings("unchecked") - public WxDefinition getWXDefinition() throws GFEServerException { - GetWXDefinitionRequest request = new GetWXDefinitionRequest(); - ServerResponse sr = (ServerResponse) makeRequest(request); - if (!sr.isOkay()) { - StringBuilder msg = new StringBuilder( - "Unable to retrieve WxDefinition: "); - for (ServerMsg s : sr.getMessages()) { - msg.append("\n ").append(s.getMessage()); - } - - statusHandler.handle(Priority.PROBLEM, msg.toString()); - } - return sr.getPayload(); - } - - /** - * Makes a call to ReferenceSetManager to retrieve an ArrayList of - * ReferenceData - * - * @param need - * @return an ArrayList of ReferenceData - */ - public List getReferenceData(ArrayList need) { - IReferenceSetManager ref = dataManager.getRefManager(); - - return ref.getReferenceData(need); - } - - /** - * Makes a call to ReferenceSetManager to retrieve an ArrayList of - * ReferenceID objects - * - * @return an ArrayList of ReferenceID - */ - public List getReferenceInventory() { - IReferenceSetManager ref = dataManager.getRefManager(); - List refList = ref.getAvailableSets(); - - return refList; - } - - /** - * Gets the grid data based on a parmID and a list of time ranges - * - * @param parmId - * @param gridTimes - * @return List of grid slices - * @throws GFEServerException - */ - @SuppressWarnings("unchecked") - public List getGridData(ParmID parmId, List gridTimes) - throws GFEServerException { - GetGridRequest req = new GetGridRequest(parmId, gridTimes); - GetGridDataRequest request = new GetGridDataRequest(); - request.addRequest(req); - - List slices = new ArrayList(gridTimes.size()); - while (slices.size() < gridTimes.size()) { - ServerResponse> resp = (ServerResponse>) makeRequest(request); - slices.addAll(resp.getPayload()); - - // if no slices returned (shouldn't happen unless server code is - // broken) - if (slices.isEmpty()) { - String msg = "No data returned from GetGridDataRequest for " - + parmId + " for times:" + req.getTimes(); - statusHandler.error(msg); - throw new GFEServerException(msg); - } - - // if not all slices returned - if (slices.size() < gridTimes.size()) { - // request remaining times. - req.setTimes(gridTimes.subList(slices.size(), gridTimes.size())); - } - } - - return slices; - } - - /** - * Gets a parm, if there is no parm in the ParmManager it adds it based on - * parmId - * - * @param parmId - * @param parmMan - * @return a parm - */ - public Parm getParm(ParmID parmId, IParmManager parmMan) { - Parm parm = parmMan.getParm(parmId); - if (parm == null) { - parm = parmMan.addParm(parmId, true, false); - parm = parmMan.getParm(parmId); - } - return parm; - } - - /** - * Commits a list of grids to the official database via a list of commit - * grid requests - * - * @param requests - * The commit grid requests - * @return The ServerResponse containing any server side messages - * @throws GFEServerException - */ - public ServerResponse commitGrid(List requests) - throws GFEServerException { - - CommitGridsRequest commitRequest = new CommitGridsRequest(); - commitRequest.setCommits(requests); - ServerResponse sr = makeRequest(commitRequest); - return sr; - } - - /** - * Commits a single grid to the official database - * - * @param req - * The commitGridRequest - * @throws GFEServerException - */ - public ServerResponse commitGrid(CommitGridRequest req) - throws GFEServerException { - List requests = new ArrayList(); - requests.add(req); - return commitGrid(requests); - } - - /** - * Gets the official database name for this localized instance of GFE - * - * @return The official database name - * @throws GFEServerException - */ - @SuppressWarnings("unchecked") - public ServerResponse> getOfficialDBName() - throws GFEServerException { - GetOfficialDbNameRequest request = new GetOfficialDbNameRequest(); - return (ServerResponse>) makeRequest(request); - } - - public List getVTECActiveTable(String siteId) - throws VizException { - CAVEMode mode = dataManager.getOpMode(); - ActiveTableMode atMode = ActiveTableMode.OPERATIONAL; - if (mode.equals(CAVEMode.PRACTICE)) { - atMode = ActiveTableMode.PRACTICE; - } - return getVTECActiveTable(siteId, atMode); - } - - @SuppressWarnings("unchecked") - public List getVTECActiveTable(String siteId, - ActiveTableMode mode) throws VizException { - GetActiveTableRequest request = new GetActiveTableRequest(); - request.setRequestedSiteId(SiteMap.getInstance().getSite4LetterId( - siteId)); - request.setMode(mode); - ServerResponse sr = makeRequest(request); - return (List) sr.getPayload(); - } - - public ServerResponse sendISC(List req) - throws GFEServerException { - SendIscGridRequest request = new SendIscGridRequest(); - request.setRequests(req); - return makeRequest(request); - } - - @SuppressWarnings("unchecked") - public ServerResponse> iscRequestQuery() - throws GFEServerException { - IscRequestQueryRequest request = new IscRequestQueryRequest(); - return (ServerResponse>) makeRequest(request); - } - - @SuppressWarnings("unchecked") - public ServerResponse iscGetDomainDict(String xml) - throws GFEServerException { - IscCreateDomainDictRequest request = new IscCreateDomainDictRequest(); - request.setXml(xml); - return (ServerResponse) makeRequest(request); - } - - public String iscGetRequestXML(String xml, List selectedServers, - List selectedWE) throws GFEServerException { - IscGetRequestXmlRequest request = new IscGetRequestXmlRequest(); - request.setXml(xml); - request.setSelectedServers(selectedServers); - request.setSelectedWEList(selectedWE); - return (String) makeRequest(request).getPayload(); - } - - public void iscMakeISCRequest(String xmlRequest) throws GFEServerException { - IscMakeRequest task = new IscMakeRequest(); - task.setXml(xmlRequest); - makeRequest(task); - } - - public ServerResponse makeRequest(AbstractGfeRequest request) - throws GFEServerException { - return makeRequest(request, true); - } - - private ServerResponse makeRequest(AbstractGfeRequest request, - boolean throwExceptionsBasedOnResponse) throws GFEServerException { - ServerResponse rval = null; - - try { - // System.out.println("IFPClient.makeRequest: " - // + request.getClass().getSimpleName()); - request.setWorkstationID(workstationID); - request.setSiteID(siteID); - Object obj = ThriftClient.sendRequest(request); - - if (obj instanceof ServerResponse) { - rval = (ServerResponse) obj; - } else { - throw new GFEServerException( - "Received invalid response object from GFE Server. Received [" - + obj.getClass().getName() + "] excepted [" - + ServerResponse.class.getName()); - } - } catch (VizException e) { - throw new GFEServerException(e); - } - - if ((throwExceptionsBasedOnResponse) && (rval != null) - && (!rval.isOkay())) { - String msg = formatSRMessage(rval); - throw new GFEServerException(msg); - - } - - return rval; - } - - private String formatSRMessage(ServerResponse rval) { - StringBuilder sb = new StringBuilder(); - if (rval.getMessages().size() > 1) { - sb.append("Errors "); - } else { - sb.append("Error "); - } - sb.append("occurred on GFE server: "); - Iterator iter = rval.getMessages().iterator(); - while (iter.hasNext()) { - sb.append(iter.next().getMessage()); - if (iter.hasNext()) { - sb.append(", "); - } - } - String msg = sb.toString(); - return msg; - } - - public void clearPracticeTable(String siteId) throws VizException { - try { - ClearPracticeVTECTableRequest request = new ClearPracticeVTECTableRequest( - SiteMap.getInstance().getSite4LetterId(siteId), - workstationID); - ThriftClient.sendRequest(request); - } catch (VizException e) { - throw new GFEServerException( - "Could not clear practice active table.", e); - } - } - - public ServerResponse getGridHistory(ParmID parmID, - List timeRanges) throws GFEServerException { - GetGridHistoryRequest request = new GetGridHistoryRequest(); - request.setParmID(parmID); - request.setTimeRanges(timeRanges); - return makeRequest(request); - } - - public ServerResponse createNewDb(DatabaseID dbId) - throws GFEServerException { - CreateNewDbRequest request = new CreateNewDbRequest(dbId); - return makeRequest(request); - } - - public ServerResponse getTopoData(GridLocation gloc) - throws GFEServerException { - GetTopoDataRequest request = new GetTopoDataRequest(gloc); - return (ServerResponse) makeRequest(request, false); - } -} diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ParmManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ParmManager.java index 1f93cf831b..89564455c4 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ParmManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ParmManager.java @@ -50,12 +50,14 @@ import com.raytheon.uf.common.dataplugin.gfe.server.notify.DBInvChangeNotificati import com.raytheon.uf.common.dataplugin.gfe.server.notify.GridHistoryUpdateNotification; import com.raytheon.uf.common.dataplugin.gfe.server.notify.GridUpdateNotification; import com.raytheon.uf.common.dataplugin.gfe.server.notify.LockNotification; +import com.raytheon.uf.common.dataplugin.gfe.server.request.LockTableRequest; import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.LocalizationUtil; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.site.notify.SiteActivationNotification; @@ -148,6 +150,8 @@ import com.raytheon.viz.gfe.types.MutableInteger; * 10/30/2014 #3775 randerso Changed to createMutableDb before getting initial database inventory * 01/13/2015 #3955 randerso Changed getProductDatabase() to return mutableDb for EditTopo * 03/12/2015 #4246 randerso Changes to support VCModules at base, site, and user levels + * 11/17/2015 #5129 dgilling Changes to support new IFPClient + * 02/05/2016 #5242 dgilling Remove calls to deprecated Localization APIs. * * * @author chammack @@ -458,7 +462,14 @@ public class ParmManager implements IParmManager, IMessageClient { Message.registerInterest(this, EnableDisableTopoMsg.class); // Get the composite grid location - this.gloc = dataManager.getClient().getDBGridLocation(); + ServerResponse sr = dataManager.getClient() + .getDBGridLocation(); + this.gloc = sr.getPayload(); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "Unable to get DBGridLocation from ifpServer: %s", + sr.message())); + } this.systemTimeRange = recalcSystemTimeRange(); this.parmIDCacheServer = new HashMap>(); @@ -549,55 +560,47 @@ public class ParmManager implements IParmManager, IMessageClient { * Determines the name of the database that is used by products. This is the * official database identifier or if none, the mutable database id. * - * @return - * @throws GFEServerException + * @return The {@code DatabaseID} of the official database. */ private DatabaseID determineProductDatabase() { - DatabaseID mutableDb = this.getMutableDatabase(); - CAVEMode opMode = CAVEMode.getMode(); if (opMode.equals(CAVEMode.PRACTICE) || opMode.equals(CAVEMode.TEST)) { return mutableDb; } - ServerResponse> sr; - try { - sr = this.dataManager.getClient().getOfficialDBName(); - List databases = sr.getPayload(); + ServerResponse> sr = dataManager.getClient() + .getOfficialDBName(); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "Unable to get official DB names: %s", sr.message())); + return new DatabaseID(); + } - if (!sr.isOkay()) { - statusHandler.handle(Priority.PROBLEM, - "Network problem: Unable to get official DB names.\n" - + sr); - } + List databases = sr.getPayload(); - // if no official databases, then use the mutable database - if (databases.isEmpty()) { - return mutableDb; - } + // if no official databases, then use the mutable database + if (databases.isEmpty()) { + return mutableDb; + } - // the official database names from the server don't include the - // model time, so see if we can add a model time in if appropriate. - for (int i = 0; i < databases.size(); i++) { - // find a match for siteid, type and format with the mutable - if (mutableDb.getSiteId().equals(databases.get(i).getSiteId()) - && mutableDb.getDbType().equals( - databases.get(i).getDbType()) - && mutableDb.getFormat().equals( - databases.get(i).getFormat())) { - // found a match -- now put the model time from the mutable - // database onto this database - DatabaseID off = databases.get(i); - return new DatabaseID(off.getSiteId(), off.getFormat(), - off.getDbType(), off.getModelName(), - mutableDb.getModelTime()); - - } + /* + * the official database names from the server don't include the model + * time, so see if we can add a model time in if appropriate. + */ + for (DatabaseID db : databases) { + // find a match for siteid, type and format with the mutable + if ((mutableDb.getSiteId().equals(db.getSiteId())) + && (mutableDb.getDbType().equals(db.getDbType())) + && (mutableDb.getFormat().equals(db.getFormat()))) { + /* + * found a match -- now put the model time from the mutable + * database onto this database + */ + return new DatabaseID(db.getSiteId(), db.getFormat(), + db.getDbType(), db.getModelName(), + mutableDb.getModelTime()); } - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, - "Network problem: Unable to get official DB names.", e); } // can't find an official database that matches the mutable database @@ -803,10 +806,10 @@ public class ParmManager implements IParmManager, IMessageClient { } if (!uncachedDbs.isEmpty()) { - // retrieve cache - try { - List results = dataManager.getClient().getParmList( - uncachedDbs); + ServerResponse> sr = dataManager.getClient() + .getParmList(uncachedDbs); + if (sr.isOkay()) { + List results = sr.getPayload(); parmIDs.addAll(results); // add results to parmIDCache @@ -849,9 +852,9 @@ public class ParmManager implements IParmManager, IMessageClient { } } } - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, - "Error retrieving all parm IDs", e); + } else { + statusHandler.error(String.format( + "Error retrieving all parm IDs: %s", sr.message())); } } @@ -861,9 +864,10 @@ public class ParmManager implements IParmManager, IMessageClient { @Override public ParmID[] getAvailableParms(DatabaseID dbID) { - // a derivation from AWIPS1: - // short-circuit the checks and just return an empty array back - // if we have an invalid DatabaseID + /* + * a derivation from AWIPS1: short-circuit the checks and just return an + * empty array back if we have an invalid DatabaseID + */ if ((dbID == null) || (!dbID.isValid())) { return new ParmID[0]; } @@ -878,19 +882,19 @@ public class ParmManager implements IParmManager, IMessageClient { if (cacheParmIDs != null) { parmIds = new ArrayList(cacheParmIDs); } else { - if (this.availableServerDatabases.contains(dbID)) { - try { - parmIds = dataManager.getClient().getParmList(dbID); - } catch (GFEServerException e) { - statusHandler - .handle(Priority.PROBLEM, - "Unable to get parm list of db: " - + dbID.toString(), e); - } - - // cache the result for next time - synchronized (this.parmIDCacheServer) { - this.parmIDCacheServer.put(dbID, parmIds); + if (availableServerDatabases.contains(dbID)) { + ServerResponse> sr = dataManager.getClient() + .getParmList(dbID); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "Unable to access parm list: %s", sr.message())); + return new ParmID[0]; + } else { + parmIds = sr.getPayload(); + // cache the result for next time + synchronized (this.parmIDCacheServer) { + this.parmIDCacheServer.put(dbID, parmIds); + } } } } @@ -1412,7 +1416,7 @@ public class ParmManager implements IParmManager, IMessageClient { // returns the pointer. // --------------------------------------------------------------------------- private Parm createDbParmInternal(final ParmID pid, boolean mutableParm, - boolean displayable) throws GFEServerException { + boolean displayable) { if (getParm(pid) != null) { return null; @@ -1422,10 +1426,28 @@ public class ParmManager implements IParmManager, IMessageClient { return null; } - GridParmInfo gpi = dataManager.getClient().getGridParmInfo(pid); + ServerResponse sr1 = dataManager.getClient() + .getGridParmInfo(pid); + if (!sr1.isOkay()) { + statusHandler.error(String.format( + "Couldn't get GridParmInfo for parm %s: %s", pid, + sr1.message())); + return null; + } + GridParmInfo gpi = sr1.getPayload(); - return new DbParm(pid, gpi, mutableParm, displayable, this.dataManager); + ServerResponse> sr2 = dataManager.getClient() + .getLockTable(new LockTableRequest(pid)); + List lt = sr2.getPayload(); + if ((!sr2.isOkay()) || (lt.size() != 1)) { + statusHandler.error(String.format( + "Couldn't get lockTable for parm %s: %s", pid, + sr2.message())); + return null; + } + return new DbParm(pid, gpi, mutableParm, displayable, dataManager, + lt.get(0)); } private Parm createVirtualCalculatedParm(final VCModule module, @@ -2892,16 +2914,16 @@ public class ParmManager implements IParmManager, IMessageClient { * @return A filtered list of available databases. */ private List getDatabaseInventory() { - List dbIds = null; - - try { - dbIds = dataManager.getClient().getAvailableDbs(); - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); - return new ArrayList(0); + ServerResponse> sr = dataManager.getClient() + .getDbInventory(); + if (!sr.isOkay()) { + statusHandler.error(String.format("GetDbInventory fail: %s", + sr.message())); + return Collections.emptyList(); } - return filterDbIds(dbIds); + List dbs = sr.getPayload(); + return filterDbIds(dbs); } /** @@ -3109,15 +3131,9 @@ public class ParmManager implements IParmManager, IMessageClient { FileUtil.join("gfe", "vcmodule"), new String[] { "py" }, false, true); for (LocalizationFile lf : files) { - try { - String modName = lf.getFile(false).getName() - .split("\\.(?=[^\\.]+$)")[0]; - modMap.put(modName, lf); - } catch (LocalizationException e) { - statusHandler.error( - "Error getting local file name for VCModule " + lf, - e); - } + String modName = LocalizationUtil.extractName(lf.getPath()) + .replace(".py", ""); + modMap.put(modName, lf); } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ReferenceSetManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ReferenceSetManager.java index bd96d063c7..fcc57ee4a2 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ReferenceSetManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ReferenceSetManager.java @@ -24,11 +24,9 @@ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.lang.ref.WeakReference; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -52,6 +50,7 @@ import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData.CoordinateType; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData.RefType; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID; +import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; import com.raytheon.uf.common.localization.FileUpdatedMessage; import com.raytheon.uf.common.localization.FileUpdatedMessage.FileChangeType; import com.raytheon.uf.common.localization.ILocalizationFileObserver; @@ -64,9 +63,9 @@ import com.raytheon.uf.common.localization.LocalizationUtil; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.localization.SaveableOutputStream; import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory; import com.raytheon.uf.common.python.concurrent.IPythonExecutor; import com.raytheon.uf.common.python.concurrent.IPythonJobListener; +import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory; import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; @@ -87,7 +86,6 @@ import com.raytheon.viz.gfe.query.QueryScript; import com.raytheon.viz.gfe.query.QueryScriptExecutor; import com.raytheon.viz.gfe.query.QueryScriptFactory; import com.raytheon.viz.gfe.query.QueryScriptRecurseExecutor; -import com.raytheon.viz.gfe.ui.AccessMgr; import com.vividsolutions.jts.geom.Envelope; /** @@ -114,7 +112,10 @@ import com.vividsolutions.jts.geom.Envelope; * Aug 13, 2015 4749 njensen Shut down coordinator on dispose() * Aug 26, 2015 4807 randerso Change refDataCache so it will release unused edit areas * Clean up deprecations and old style logging. - * Aug 27, 2015 4947 njensen Fixed removeReferenceSetIDChangedListener() + * Aug 27, 2015 4947 njensen Fixed removeReferenceSetIDChangedListener() + * Nov 18, 2015 5129 dgilling Use new IFPClient for get/save/delete + * of reference data. + * Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API. * * * @@ -123,13 +124,18 @@ import com.vividsolutions.jts.geom.Envelope; */ public class ReferenceSetManager implements IReferenceSetManager, IMessageClient, ISpatialEditorTimeChangedListener { + private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(ReferenceSetManager.class); - private static final String EDIT_AREAS_DIR = FileUtil.join("gfe", + private static final String QUERY_THREAD_POOL_NAME = "gfequeryscript"; + + private static final int NUM_QUERY_THREADS = 1; + + public static final String EDIT_AREAS_DIR = FileUtil.join("gfe", "editAreas"); - private static final String EDIT_AREA_GROUPS_DIR = FileUtil.join("gfe", + public static final String EDIT_AREA_GROUPS_DIR = FileUtil.join("gfe", "editAreaGroups"); /** @@ -235,21 +241,20 @@ public class ReferenceSetManager implements IReferenceSetManager, */ private void getInventory() { // load the complete list of edit areas - List refIDs = new ArrayList(); - IPathManager pm = PathManagerFactory.getPathManager(); - LocalizationFile[] contents = pm.listStaticFiles( - LocalizationType.COMMON_STATIC, EDIT_AREAS_DIR, - new String[] { ".xml" }, false, true); - if (contents != null) { - for (LocalizationFile lf : contents) { - String s = LocalizationUtil.extractName(lf.getName()); - String area = s.replace(".xml", ""); - refIDs.add(new ReferenceID(area, false, lf.getContext() - .getLocalizationLevel())); - } + List refIDs; + ServerResponse> sr = dataManager.getClient() + .getReferenceInventory(); + if (sr.isOkay()) { + refIDs = sr.getPayload(); + } else { + refIDs = Collections.emptyList(); + statusHandler.error(String.format( + "Unable to update inventory from IFPServer: %s", + sr.message())); } // load the edit area group lists + IPathManager pm = PathManagerFactory.getPathManager(); LocalizationFile[] groupFiles = pm.listStaticFiles( LocalizationType.COMMON_STATIC, EDIT_AREA_GROUPS_DIR, new String[] { ".txt" }, false, true); @@ -280,8 +285,8 @@ public class ReferenceSetManager implements IReferenceSetManager, * @param lf */ private void loadGroup(LocalizationFile lf) { - String groupName = Paths.get(lf.getName()).getFileName().toString() - .replace(".txt", ""); + String groupName = LocalizationUtil.extractName(lf.getPath()).replace( + ".txt", ""); GroupID group = new GroupID(groupName, lf.isProtected(), lf .getContext().getLocalizationLevel()); if (group.equals("Misc")) { @@ -542,9 +547,10 @@ public class ReferenceSetManager implements IReferenceSetManager, @SuppressWarnings("unchecked") public ReferenceSetManager(DataManager dataManager) { // ready the PythonJobCoordinator - AbstractPythonScriptFactory factory = new QueryScriptFactory( + PythonInterpreterFactory factory = new QueryScriptFactory( dataManager); - coordinator = PythonJobCoordinator.newInstance(factory); + coordinator = new PythonJobCoordinator<>(NUM_QUERY_THREADS, + QUERY_THREAD_POOL_NAME, factory); // MessageClient("ReferenceSetMgr", msgHandler); this.dataManager = dataManager; @@ -747,31 +753,18 @@ public class ReferenceSetManager implements IReferenceSetManager, } } - String filePath = FileUtil.join(EDIT_AREAS_DIR, refSetID.getName() - + ".xml"); - LocalizationFile lf = PathManagerFactory.getPathManager() - .getStaticLocalizationFile(LocalizationType.COMMON_STATIC, - filePath); - - if (lf != null) { - try (InputStream in = lf.openInputStream()) { - refData = (ReferenceData) ReferenceData.getJAXBManager() - .unmarshalFromInputStream(in); - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - "Error reading xml file " + lf.toString(), e); - } + // get it from ifpServer + ServerResponse sr = dataManager.getClient() + .getReferenceData(refSetID); + if (sr.isOkay()) { + refData = sr.getPayload(); } else { - statusHandler.handle(Priority.PROBLEM, - "Unable to find reference data " + refSetID); + statusHandler.error(String.format( + "Failure to get reference data [%s] from IFPServer: %s", + refSetID.getName(), sr.message())); } if (refData != null) { - refData.setId(new ReferenceID(refSetID.getName(), false, lf - .getContext().getLocalizationLevel())); - refData.setGloc(dataManager.getParmManager() - .compositeGridLocation()); - // Convert to AWIPS, and then produce a grid if (!refData.isQuery()) { refData.getGrid(); @@ -849,22 +842,12 @@ public class ReferenceSetManager implements IReferenceSetManager, refData.setPolygons(null, CoordinateType.LATLON); } - IPathManager pm = PathManagerFactory.getPathManager(); - - LocalizationContext ctx = pm.getContext(LocalizationType.COMMON_STATIC, - LocalizationLevel.USER); - LocalizationFile lf = pm.getLocalizationFile( - ctx, - FileUtil.join(EDIT_AREAS_DIR, refData.getId().getName() - + ".xml")); - - // save locally and then to server - try (SaveableOutputStream out = lf.openOutputStream()) { - ReferenceData.getJAXBManager().marshalToStream(refData, out); - out.save(); - } catch (Exception e) { - statusHandler.error("Error saving reference set " - + refData.getId().getName() + " to " + lf.toString(), e); + ServerResponse sr = dataManager.getClient().saveReferenceData( + Arrays.asList(refData)); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "UNable to save ReferenceData: %s with IFPServer: %s", + refData.getId().getName(), sr.message())); return false; } @@ -883,29 +866,17 @@ public class ReferenceSetManager implements IReferenceSetManager, * com.raytheon.edex.plugin.gfe.reference.ReferenceID) */ @Override - public boolean deleteRefSet(final ReferenceID refID, - boolean withVerification) { - IPathManager pm = PathManagerFactory.getPathManager(); - - LocalizationContext ctx = pm.getContext(LocalizationType.COMMON_STATIC, - LocalizationLevel.USER); - LocalizationFile lf = pm.getLocalizationFile(ctx, - FileUtil.join(EDIT_AREAS_DIR, refID.getName() + ".xml")); - - if ((lf != null) - && (!withVerification || AccessMgr.verifyDelete(lf.getName(), - LocalizationType.COMMON_STATIC, false))) { - try { - lf.delete(); - return true; - } catch (LocalizationException e) { - statusHandler.handle(Priority.PROBLEM, - "Unable to delete edit area " + refID.getName() - + " from server.", e); - } + public boolean deleteRefSet(final ReferenceID refID) { + ServerResponse sr = dataManager.getClient().deleteReferenceData( + Arrays.asList(refID)); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "Unable to delete ReferenceData: %s with IFPServer: %s", + refID.getName(), sr.message())); + return false; } - return false; + return true; } /* @@ -1682,7 +1653,7 @@ public class ReferenceSetManager implements IReferenceSetManager, IPythonExecutor executor = new QueryScriptExecutor( "evaluate", argMap); try { - coordinator.submitAsyncJob(executor, listener); + coordinator.submitJobWithCallback(executor, listener); } catch (Exception e) { statusHandler.handle(Priority.ERROR, "Unable to submit job to ExecutorService", e); @@ -1705,7 +1676,7 @@ public class ReferenceSetManager implements IReferenceSetManager, IPythonExecutor executor = new QueryScriptExecutor( "evaluate", argMap); try { - ea = coordinator.submitSyncJob(executor); + ea = coordinator.submitJob(executor).get(); } catch (Exception e) { statusHandler.handle(Priority.ERROR, "Failed to evaluate query: " + query, e); @@ -1723,7 +1694,7 @@ public class ReferenceSetManager implements IReferenceSetManager, argMap); int result = 0; try { - result = coordinator.submitSyncJob(executor); + result = coordinator.submitJob(executor).get(); } catch (Exception e) { statusHandler.handle(Priority.ERROR, "Unable to submit job to ExecutorService", e); @@ -1823,4 +1794,9 @@ public class ReferenceSetManager implements IReferenceSetManager, }; evaluateActiveRefSet(listener); } + + @Override + public PythonJobCoordinator getPythonThreadPool() { + return coordinator; + } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/SampleSetManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/SampleSetManager.java index 7a9af4c856..a058e700ee 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/SampleSetManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/SampleSetManager.java @@ -19,7 +19,8 @@ **/ package com.raytheon.viz.gfe.core.internal; -import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -36,28 +37,27 @@ import org.geotools.referencing.GeodeticCalculator; import com.raytheon.uf.common.dataplugin.gfe.sample.SampleData; import com.raytheon.uf.common.dataplugin.gfe.sample.SampleId; +import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; +import com.raytheon.uf.common.gfe.ifpclient.IFPClient; import com.raytheon.uf.common.localization.FileUpdatedMessage; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.ILocalizationFileObserver; import com.raytheon.uf.common.localization.IPathManager; -import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.LocalizationUtil; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; import com.raytheon.uf.common.serialization.SerializationException; 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.viz.gfe.Activator; import com.raytheon.viz.gfe.GFEException; import com.raytheon.viz.gfe.core.ISampleSetManager; import com.raytheon.viz.gfe.core.msgs.ISampleSetChangedListener; import com.raytheon.viz.gfe.edittool.GridID; -import com.raytheon.viz.gfe.ui.AccessMgr; import com.vividsolutions.jts.geom.Coordinate; /** @@ -65,9 +65,9 @@ import com.vividsolutions.jts.geom.Coordinate; * *
  * SOFTWARE HISTORY
- * Date			Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * Apr 14, 2008	879			rbell	    Initial creation
+ * Date         Ticket#     Engineer    Description
+ * ------------ ----------  ----------- --------------------------
+ * Apr 14, 2008 879         rbell       Initial creation
  * 11Jun2008    #1193       ebabin      Updates for toggling lat/lon for sample set.
  * Apr 9, 2009  1288        rjpeter     Added ISampleSetChangedListener handling.
  * Aug 6, 2013  1561        njensen     Use pm.listFiles() instead of pm.listStaticFiles()
@@ -75,6 +75,10 @@ import com.vividsolutions.jts.geom.Coordinate;
  * Sep 08, 2104 #3592       randerso    Changed to use new pm listStaticFiles().
  *                                      Reworked inventory to use a map to better handle
  *                                      files at multiple localization levels
+ * Nov 12, 2015 4834        njensen     Changed LocalizationOpFailedException to LocalizationException
+ * Nov 19, 2015 5129        dgilling    Support new IFPClient.
+ * Feb 10, 2016 5242        dgilling    Remove calls to deprecated Localization APIs.
+ * 
  * 
* * @author rbell @@ -86,11 +90,13 @@ public class SampleSetManager implements ISampleSetManager, private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(SampleSetManager.class); - private static final String SAMPLE_SETS_DIR = FileUtil.join("gfe", - "sampleSets"); + public static final String SAMPLE_SETS_DIR = "gfe" + IPathManager.SEPARATOR + + "sampleSets"; private static final String MARKER_NAME = "ISC_Marker_Set"; + private final IFPClient ifpClient; + private SampleId loadedSet; private SortedMap inventory; @@ -112,34 +118,33 @@ public class SampleSetManager implements ISampleSetManager, * * Gets the initial sample inventory. */ - public SampleSetManager() { + public SampleSetManager(IFPClient ifpClient) { this.loadedSet = new SampleId(); - this.inventory = new TreeMap(); - this.locations = new ArrayList(); this.markerLocations = new HashMap>(); this.sampleSetChangedListeners = new HashSet(); - this.pathManager = PathManagerFactory.getPathManager(); + this.ifpClient = ifpClient; - this.sampleSetDir = pathManager.getLocalizationFile(pathManager - .getContext(LocalizationType.COMMON_STATIC, - LocalizationLevel.BASE), SAMPLE_SETS_DIR); - - // initialize the inventory - LocalizationFile[] files = pathManager.listStaticFiles( - LocalizationType.COMMON_STATIC, SAMPLE_SETS_DIR, - new String[] { ".xml" }, true, true); - - for (LocalizationFile lf : files) { - String name = LocalizationUtil.extractName(lf.getName()).replace( - ".xml", ""); - this.inventory.put(name, new SampleId(name, false, lf.getContext() - .getLocalizationLevel())); + this.inventory = new TreeMap(); + ServerResponse> sr = this.ifpClient.getSampleInventory(); + if (sr.isOkay()) { + for (SampleId id : sr.getPayload()) { + this.inventory.put(id.getName(), id); + } + } else { + statusHandler.error(String.format( + "Unable to get sample inventory from IFPServer: %s", + sr.message())); } + + this.pathManager = PathManagerFactory.getPathManager(); + this.sampleSetDir = this.pathManager.getLocalizationFile( + this.pathManager.getContext(LocalizationType.COMMON_STATIC, + LocalizationLevel.BASE), SAMPLE_SETS_DIR); this.sampleSetDir.addFileUpdatedObserver(this); // load default sample points @@ -157,23 +162,11 @@ public class SampleSetManager implements ISampleSetManager, getMarkerPoints(); } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.ISampleSetManager#dispose() - */ @Override public void dispose() { this.sampleSetDir.removeFileUpdatedObserver(this); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.ISampleSetManager#sampleSetLocations(java.lang - * .String) - */ @Override public List sampleSetLocations(final String setName) { // verify set in inventory @@ -189,55 +182,34 @@ public class SampleSetManager implements ISampleSetManager, String fileName = FileUtil.join(SAMPLE_SETS_DIR, sampleId.getName() + ".xml"); - LocalizationFile lf = this.pathManager.getLocalizationFile( - this.pathManager.getContext(LocalizationType.COMMON_STATIC, + ILocalizationFile lf = pathManager.getLocalizationFile( + pathManager.getContext(LocalizationType.COMMON_STATIC, sampleId.getAccess()), fileName); - File file = null; - try { - file = lf.getFile(true); - } catch (LocalizationException e) { - if (file == null) { - statusHandler.error("An error occurred retrieving SampleSet: " - + fileName, e); - return Collections.emptyList(); - } + List points = Collections.emptyList(); + try (InputStream inStream = lf.openInputStream()) { + SampleData sampleData = SampleData.getJAXBManager() + .unmarshalFromInputStream(inStream); + points = sampleData.getPoints(); + } catch (IOException | LocalizationException | SerializationException e) { + statusHandler.error("Unable to load sampledata: " + lf, e); } - SampleData sampleData = null; - try { - sampleData = SampleData.getJAXBManager().unmarshalFromXmlFile( - file.getAbsolutePath()); - } catch (Exception e) { - statusHandler.error("Unable to load sampledata: " + file, e); - return Collections.emptyList(); - } - - return sampleData.getPoints(); + return points; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.ISampleSetManager#loadSampleSet(com.raytheon - * .edex.plugin.gfe.sample.SampleId, - * com.raytheon.viz.gfe.core.internal.SampleSetManager.SampleSetLoadMode) - */ @Override public void loadSampleSet(final SampleId sampleId, SampleSetLoadMode loadMode) { - File f = this.pathManager.getStaticFile(FileUtil.join(SAMPLE_SETS_DIR, - sampleId.getName() + ".xml")); - - SampleData sampleData = null; - try { - sampleData = SampleData.getJAXBManager().unmarshalFromXmlFile( - f.getPath()); - sampleData.setSampleId(sampleId); - } catch (Exception e) { - statusHandler.error("Unable to load sampledata: " + f); + ServerResponse sr = ifpClient.getSampleData(sampleId); + if (!sr.isOkay()) { + statusHandler + .error(String + .format("Failure to get sample data from from IFPServer for [%s]: %s", + sampleId.getName(), sr.message())); + return; } + SampleData sampleData = sr.getPayload(); // set the loadedSet flag appropriately if ((loadMode == SampleSetLoadMode.REPLACE) @@ -256,11 +228,6 @@ public class SampleSetManager implements ISampleSetManager, return; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.ISampleSetManager#clearSamples() - */ @Override public void clearSamples() { mergeSamples(new ArrayList(), SampleSetLoadMode.REPLACE); @@ -269,12 +236,6 @@ public class SampleSetManager implements ISampleSetManager, return; } - /* - * (non-Javadoc) - * - * @seecom.raytheon.viz.gfe.core.ISampleSetManager#addAnchoredSample(com. - * vividsolutions.jts.geom.Coordinate) - */ @Override public void addAnchoredSample(final Coordinate sampleLocation) { mergeSamples(Arrays.asList(sampleLocation), SampleSetLoadMode.ADD); @@ -283,26 +244,12 @@ public class SampleSetManager implements ISampleSetManager, return; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredSample(com. - * vividsolutions.jts.geom.Coordinate) - */ @Override public void removeAnchoredSample(final Coordinate sampleLocation) { removeAnchoredSample(sampleLocation, ISampleSetManager.DEFAULT_THRESHOLD); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredSample(com. - * vividsolutions.jts.geom.Coordinate, float) - */ @Override public void removeAnchoredSample(final Coordinate sampleLocation, float threshold) { @@ -313,12 +260,6 @@ public class SampleSetManager implements ISampleSetManager, return; } - /* - * (non-Javadoc) - * - * @seecom.raytheon.viz.gfe.core.ISampleSetManager#addAnchoredMarker(com. - * vividsolutions.jts.geom.Coordinate) - */ @Override public void addAnchoredMarker(final Coordinate location, final GridID gid) { String set = activeMarkerSet(gid); @@ -331,25 +272,11 @@ public class SampleSetManager implements ISampleSetManager, saveSampleSet(locations, new SampleId(set)); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredMarker(com. - * vividsolutions.jts.geom.Coordinate) - */ @Override public void removeAnchoredMarker(final Coordinate location, final GridID gid) { removeAnchoredMarker(location, gid, ISampleSetManager.DEFAULT_THRESHOLD); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredMarker(com. - * vividsolutions.jts.geom.Coordinate, float) - */ @Override public void removeAnchoredMarker(final Coordinate location, final GridID gid, float threshold) { @@ -375,13 +302,6 @@ public class SampleSetManager implements ISampleSetManager, fireSampleSetChangedListeners(); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.ISampleSetManager#anchoredMarkerAtLocation( - * com.vividsolutions.jts.geom.Coordinate, float) - */ @Override public boolean anchoredMarkerAtLocation(final Coordinate location, final GridID gid, float threshold) { @@ -403,90 +323,42 @@ public class SampleSetManager implements ISampleSetManager, return false; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.ISampleSetManager#saveSampleSet(com.vividsolutions - * .jts.geom.Coordinate[], com.raytheon.edex.plugin.gfe.sample.SampleId) - */ @Override public boolean saveSampleSet(final List sampleLocations, final SampleId sampleId) { - SampleData sd = new SampleData(sampleId, sampleLocations); - LocalizationContext lc = this.pathManager.getContext( - LocalizationType.COMMON_STATIC, LocalizationLevel.USER); - - LocalizationFile file = this.pathManager.getLocalizationFile(lc, - FileUtil.join(SAMPLE_SETS_DIR, sampleId.getName() + ".xml")); - - try { - SampleData.getJAXBManager().marshalToXmlFile(sd, - file.getFile().getPath()); - file.save(); - } catch (LocalizationOpFailedException e) { - statusHandler.handle(Priority.PROBLEM, - "Error saving to localization server", e); - } catch (SerializationException e) { - statusHandler.handle(Priority.PROBLEM, "Error serializing to file", - e); + ServerResponse sr = ifpClient.saveSampleData(Arrays.asList(sd)); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "Failure to save sample data to IFPServer for [%s]: %s", + sampleId.getName(), sr.message())); } return true; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.ISampleSetManager#saveActiveSampleSet(com.raytheon - * .edex.plugin.gfe.sample.SampleId) - */ @Override public boolean saveActiveSampleSet(final SampleId sampleId) { this.loadedSet = sampleId; return saveSampleSet(this.locations, sampleId); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.ISampleSetManager#deleteSampleSet(com.raytheon - * .edex.plugin.gfe.sample.SampleId) - */ @Override public boolean deleteSampleSet(final SampleId sampleId) { - - LocalizationContext ctx = this.pathManager.getContext( - LocalizationType.COMMON_STATIC, LocalizationLevel.USER); - LocalizationFile lf = this.pathManager.getLocalizationFile(ctx, - FileUtil.join(SAMPLE_SETS_DIR, sampleId.getName() + ".xml")); - - if ((lf != null) - && (AccessMgr.verifyDelete(lf.getName(), - LocalizationType.COMMON_STATIC, false))) { - try { - lf.delete(); - return true; - } catch (LocalizationException e) { - statusHandler.handle(Priority.PROBLEM, "Unable to sample set " - + sampleId.getName() + " from server.", e); - } + ServerResponse sr = ifpClient.deleteSampleData(Arrays + .asList(sampleId)); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "Failure to delete sample set [%s]: %s", + sampleId.getName(), sr.message())); + } else if (sampleId.getName().equals(loadedSet.getName())) { + loadedSet = new SampleId(); } - return false; + return true; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.common.localization.ILocalizationFileObserver#fileUpdated - * (com.raytheon.uf.common.localization.FileUpdatedMessage) - */ @Override public void fileUpdated(FileUpdatedMessage message) { @@ -543,12 +415,6 @@ public class SampleSetManager implements ISampleSetManager, fireSampleSetChangedListeners(); } - /** - * mergeSamples(...) with default threshold - * - * @param mergeSet - * @param mergeMode - */ private void mergeSamples(final List mergeSet, SampleSetLoadMode mergeMode) { mergeSamples(mergeSet, mergeMode, ISampleSetManager.DEFAULT_THRESHOLD); @@ -620,32 +486,17 @@ public class SampleSetManager implements ISampleSetManager, } } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.ISampleSetManager#getLoadedSet() - */ @Override public SampleId getLoadedSet() { return this.loadedSet; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.ISampleSetManager#getInventory() - */ @Override public SampleId[] getInventory() { return this.inventory.values().toArray( new SampleId[this.inventory.size()]); } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.ISampleSetManager#getInventoryAsStrings() - */ @Override public String[] getInventoryAsStrings() { String[] retVal = new String[this.inventory.size()]; @@ -668,41 +519,21 @@ public class SampleSetManager implements ISampleSetManager, } } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.ISampleSetManager#getLocations() - */ @Override public List getLocations() { return new ArrayList(this.locations); } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.ISampleSetManager#getMarkerLocations() - */ @Override public Map> getMarkerLocations() { return this.markerLocations; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.ISampleSetManager#isShowLatLon() - */ @Override public boolean isShowLatLon() { return showLatLon; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.ISampleSetManager#setShowLatLon(boolean) - */ @Override public void setShowLatLon(boolean showLatLon) { this.showLatLon = showLatLon; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/SelectTimeRangeManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/SelectTimeRangeManager.java index 5e0a862885..95c2e4d233 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/SelectTimeRangeManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/SelectTimeRangeManager.java @@ -22,7 +22,6 @@ package com.raytheon.viz.gfe.core.internal; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; -import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayList; @@ -35,18 +34,19 @@ import java.util.TreeMap; import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange; import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange.Mode; import com.raytheon.uf.common.localization.FileUpdatedMessage; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.ILocalizationFileObserver; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.localization.SaveableOutputStream; +import com.raytheon.uf.common.localization.exception.LocalizationException; 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.viz.gfe.GFEServerException; -import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.core.ISelectTimeRangeManager; import com.raytheon.viz.gfe.core.msgs.SelectTimeRangesChangedMsg; @@ -59,10 +59,12 @@ import com.raytheon.viz.gfe.core.msgs.SelectTimeRangesChangedMsg; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Dec 3, 2009 #3135 randerso Initial creation - * Aug 1, 2012 #965 dgilling Change location of SelectTimeRange. - * Aug 6, 2013 #1561 njensen Use pm.listFiles() instead of pm.listStaticFiles() - * Sep 8, 2104 #3592 randerso Changed to use new pm listStaticFiles() + * Dec 03, 2009 #3135 randerso Initial creation + * Aug 01, 2012 #965 dgilling Change location of SelectTimeRange. + * Aug 06, 2013 #1561 njensen Use pm.listFiles() instead of pm.listStaticFiles() + * Sep 08, 2014 #3592 randerso Changed to use new pm listStaticFiles() + * Nov 18, 2015 #5129 dgilling Support new IFPClient. + * Feb 05, 2016 #5242 dgilling Remove calls to deprecated Localization APIs. * * * @@ -89,16 +91,9 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager, private LocalizationFile selectTRDir; - public SelectTimeRangeManager(DataManager dataManager) { + public SelectTimeRangeManager(TimeZone timeZone) { // Find the referenced time zone - timeZone = TimeZone.getTimeZone("GMT"); - try { - timeZone = TimeZone.getTimeZone(dataManager.getClient() - .getDBGridLocation().getTimeZone()); - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, - "Unable to retrieve GFE time zone, using GMT", e); - } + this.timeZone = timeZone; this.pathManager = PathManagerFactory.getPathManager(); selectTRDir = pathManager.getLocalizationFile(pathManager.getContext( @@ -123,12 +118,11 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager, return inventory; } - private SelectTimeRange loadTimeRange(LocalizationFile lf) { - String rangeName = rangeNameFromFileName(lf.getName()); + private SelectTimeRange loadTimeRange(ILocalizationFile lf) { + String rangeName = rangeNameFromFileName(lf.getPath()); - BufferedReader in = null; - try { - in = new BufferedReader(new InputStreamReader(lf.openInputStream())); + try (BufferedReader in = new BufferedReader(new InputStreamReader( + lf.openInputStream()))) { String[] s = in.readLine().split("\\s+"); int start = Integer.parseInt(s[0]); int end = Integer.parseInt(s[1]); @@ -143,19 +137,9 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager, return range; } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, - "Error reading SELECTTR file " - + lf.getFile().getAbsolutePath(), e); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException e) { - statusHandler.handle(Priority.PROBLEM, - "Error closing file " - + lf.getFile().getAbsolutePath(), e); - } - } + "Error reading SELECTTR file " + lf.toString(), e); } + return null; } @@ -166,47 +150,34 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager, @Override public void save(String name, int start, int end, Mode mode) { - LocalizationFile lf = pathManager.getLocalizationFile(pathManager + ILocalizationFile lf = pathManager.getLocalizationFile(pathManager .getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.USER), FileUtil.join(FILE_PATH, FileUtil.mangle(name) + FILE_EXT)); - BufferedWriter out = null; - try { - out = new BufferedWriter(new OutputStreamWriter( - lf.openOutputStream())); + try (SaveableOutputStream lfStream = lf.openOutputStream(); + BufferedWriter out = new BufferedWriter(new OutputStreamWriter( + lfStream))) { out.write(String.format("%d %d %d", start, end, mode.ordinal())); out.close(); - out = null; - lf.save(); + lfStream.save(); } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, - "Error writing SELECTTR file " - + lf.getFile().getAbsolutePath(), e); - } finally { - try { - if (out != null) { - out.close(); - } - } catch (IOException e) { - statusHandler.handle(Priority.PROBLEM, "Error closing file " - + lf.getFile().getAbsolutePath(), e); - } + "Error writing SELECTTR file " + lf.toString(), e); } } @Override public void remove(String name) { - LocalizationFile lf = pathManager.getLocalizationFile(pathManager + ILocalizationFile lf = pathManager.getLocalizationFile(pathManager .getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.USER), FileUtil.join(FILE_PATH, FileUtil.mangle(name) + FILE_EXT)); try { lf.delete(); - } catch (Exception e) { + } catch (LocalizationException e) { statusHandler.handle(Priority.PROBLEM, - "Error deleting SELECTTR file " - + lf.getFile().getAbsolutePath(), e); + "Error deleting SELECTTR file " + lf.toString(), e); } } @@ -287,4 +258,9 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager, "")); return rangeName; } + + @Override + public TimeZone getTimeZone() { + return timeZone; + } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/WEGroupManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/WEGroupManager.java index 97ad8cd333..d63e943045 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/WEGroupManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/WEGroupManager.java @@ -19,7 +19,8 @@ **/ package com.raytheon.viz.gfe.core.internal; -import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -36,15 +37,17 @@ import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; import com.raytheon.uf.common.dataplugin.gfe.weatherelement.WEGroup; import com.raytheon.uf.common.localization.FileUpdatedMessage; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.ILocalizationFileObserver; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.LocalizationUtil; import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.localization.SaveableOutputStream; import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.serialization.SingleTypeJAXBManager; import com.raytheon.uf.common.status.IUFStatusHandler; @@ -66,7 +69,9 @@ import com.raytheon.viz.gfe.core.IWEGroupManager; * ------------ ---------- ----------- -------------------------- * Jun 05, 2008 chammack Initial creation * Sep 30, 2013 2361 njensen Use JAXBManager for XML - * Aug 13, 2015 4749 njensen Implemented dispose() + * Aug 13, 2015 4749 njensen Implemented dispose() + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs. * * * @@ -145,32 +150,25 @@ public class WEGroupManager implements IWEGroupManager, private void loadGroups() { IPathManager pathManager = PathManagerFactory.getPathManager(); - LocalizationContext[] contexts = pathManager .getLocalSearchHierarchy(LocalizationType.CAVE_STATIC); - LocalizationFile[] files = pathManager.listFiles(contexts, WEGROUP_DIR, - new String[] { ".xml" }, false, true); + ILocalizationFile[] files = pathManager.listFiles(contexts, + WEGROUP_DIR, new String[] { ".xml" }, false, true); - this.inventory = new LinkedHashMap>(); - for (LocalizationFile lf : files) { - try { - File file = lf.getFile(false); - String fn = file.getName(); - LocalizationLevel levelType = lf.getContext() - .getLocalizationLevel(); + inventory = new LinkedHashMap>(); + for (ILocalizationFile lf : files) { + String fn = LocalizationUtil.extractName(lf.getPath()); + LocalizationLevel levelType = lf.getContext() + .getLocalizationLevel(); - Set inventoryList = this.inventory.get(levelType); - if (inventoryList == null) { - inventoryList = new HashSet(); - this.inventory.put(levelType, inventoryList); - } - String s = construct(fn); - if (s != null) { - inventoryList.add(s); - } - } catch (LocalizationException e) { - statusHandler.handle(Priority.PROBLEM, - "Error retrieving WE Group inventory", e); + Set inventoryList = inventory.get(levelType); + if (inventoryList == null) { + inventoryList = new HashSet(); + inventory.put(levelType, inventoryList); + } + String s = construct(fn); + if (s != null) { + inventoryList.add(s); } } } @@ -195,41 +193,20 @@ public class WEGroupManager implements IWEGroupManager, return displayName + SUFFIX; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.IWEGroupManager#save(java.lang.String, - * com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID[], - * com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID[]) - */ @Override public void save(String name, ParmID[] parmIDs, ParmID[] availableParmIDs) { WEGroup group = new WEGroup(name, parmIDs, availableParmIDs); this.save(name, group); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.internal.IWEGroupManager#remove(java.lang.String - * ) - */ @Override public boolean remove(String name) { return this.delete(name); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.internal.IWEGroupManager#getParmIDs(java.lang - * .String, com.raytheon.edex.plugin.gfe.db.objects.ParmID[]) - */ @Override public ParmID[] getParmIDs(String name, ParmID[] availableParmIDs) { - LocalizationFile file = this.getLocalizationFile(name); + ILocalizationFile file = getLocalizationFile(name); if (file == null || !file.exists()) { statusHandler.handle(Priority.PROBLEM, "Error loading weather element group \"" + name @@ -238,25 +215,17 @@ public class WEGroupManager implements IWEGroupManager, } WEGroup weGroup = null; - try { - weGroup = jaxb.unmarshalFromXmlFile(file.getFile().getPath()); + try (InputStream inStream = file.openInputStream()) { + weGroup = jaxb.unmarshalFromInputStream(inStream); } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, "Error getting weather element group", e); + return new ParmID[0]; } return getParmIDs(weGroup, availableParmIDs); - } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.internal.IWEGroupManager#getParmIDs(com.raytheon - * .edex.plugin.gfe.weatherElement.WEGroup, - * com.raytheon.edex.plugin.gfe.db.objects.ParmID[]) - */ @Override public ParmID[] getParmIDs(final WEGroup bundle, final ParmID[] availableParmIDs) { @@ -288,13 +257,6 @@ public class WEGroupManager implements IWEGroupManager, return parmIDs.toArray(new ParmID[parmIDs.size()]); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.internal.AbstractFileBasedManager#getInventory - * () - */ @Override public List getInventory() { List completeList = new ArrayList(); @@ -317,11 +279,6 @@ public class WEGroupManager implements IWEGroupManager, return Collections.unmodifiableList(completeList); } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.IWEGroupManager#getDefaultGroup() - */ @Override public String getDefaultGroup() { String defaultGroup = Activator.getDefault().getPreferenceStore() @@ -332,12 +289,6 @@ public class WEGroupManager implements IWEGroupManager, return defaultGroup; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.IWEGroupManager#isProtected(java.lang.String ) - */ @Override public boolean isProtected(String name) { LocalizationFile file = getLocalizationFile(name); @@ -365,7 +316,7 @@ public class WEGroupManager implements IWEGroupManager, file.delete(); inventory.get(context.getLocalizationLevel()).remove(object); return true; - } catch (LocalizationOpFailedException e) { + } catch (LocalizationException e) { statusHandler.handle(Priority.PROBLEM, "Error deleting from localization server", e); } @@ -375,18 +326,19 @@ public class WEGroupManager implements IWEGroupManager, } private void save(String key, WEGroup objectToSave) { - IPathManager pm = PathManagerFactory.getPathManager(); - LocalizationContext lc = pm.getContext(LocalizationType.CAVE_STATIC, LocalizationLevel.USER); - - LocalizationFile file = pm.getLocalizationFile(lc, + ILocalizationFile file = pm.getLocalizationFile(lc, FileUtil.join(WEGROUP_DIR, getName(key))); - try { - jaxb.marshalToXmlFile(objectToSave, file.getFile().getPath()); - file.save(); - } catch (LocalizationOpFailedException e) { + try (SaveableOutputStream out = file.openOutputStream()) { + jaxb.marshalToStream(objectToSave, out); + out.save(); + } catch (IOException e) { + String msg = String.format("Error writing to WEGroup file %s: %s", + file, e.getLocalizedMessage()); + statusHandler.error(msg); + } catch (LocalizationException e) { statusHandler.handle(Priority.PROBLEM, "Error saving to localization server", e); } catch (SerializationException e) { @@ -394,10 +346,10 @@ public class WEGroupManager implements IWEGroupManager, e); } - Set list = this.inventory.get(LocalizationLevel.USER); + Set list = inventory.get(LocalizationLevel.USER); if (list == null) { list = new HashSet(); - this.inventory.put(LocalizationLevel.USER, list); + inventory.put(LocalizationLevel.USER, list); } list.add(key); } @@ -426,13 +378,6 @@ public class WEGroupManager implements IWEGroupManager, return Collections.unmodifiableList(completeList); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.common.localization.ILocalizationFileObserver#fileUpdated - * (com.raytheon.uf.common.localization.FileUpdatedMessage) - */ @Override public void fileUpdated(FileUpdatedMessage message) { loadGroups(); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ABVParmID.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ABVParmID.java index f6918039b2..2a6660451c 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ABVParmID.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ABVParmID.java @@ -24,7 +24,7 @@ import java.util.Collections; import java.util.List; import java.util.StringTokenizer; -import org.apache.commons.lang.mutable.MutableInt; +import org.apache.commons.lang3.mutable.MutableInt; import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/DbParm.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/DbParm.java index eae2dd4356..bb897c5471 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/DbParm.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/DbParm.java @@ -33,9 +33,9 @@ import org.eclipse.core.runtime.Status; import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory; import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord; -import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo.GridType; import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation; import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo; +import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo.GridType; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteKey; import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable; @@ -43,6 +43,7 @@ import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable.LockMode; import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable.LockStatus; import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerMsg; import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; +import com.raytheon.uf.common.dataplugin.gfe.server.request.GetGridRequest; import com.raytheon.uf.common.dataplugin.gfe.server.request.LockRequest; import com.raytheon.uf.common.dataplugin.gfe.server.request.SaveGridRequest; import com.raytheon.uf.common.dataplugin.gfe.slice.DiscreteGridSlice; @@ -61,7 +62,6 @@ import com.raytheon.uf.common.time.util.ITimer; import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.viz.gfe.Activator; import com.raytheon.viz.gfe.GFEOperationFailedException; -import com.raytheon.viz.gfe.GFEServerException; import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.core.GfeClientConfig; import com.raytheon.viz.gfe.core.griddata.AbstractGridData; @@ -85,6 +85,7 @@ import com.raytheon.viz.gfe.core.griddata.IGridData; * 04/23/13 #1949 rjpeter Added logging of number of records. * 06/26/13 #2044 randerso Fixed error message priority * 04/03/2014 #2737 randerso Moved clientSendStatus from SaveGridRequest to SaveGFEGridRequest + * 11/17/2015 #5129 dgilling Support new IFPClient. * * * @author chammack @@ -99,8 +100,9 @@ public class DbParm extends Parm { .getHandler("GFE:"); public DbParm(ParmID parmID, GridParmInfo gridInfo, boolean mutable, - boolean displayable, DataManager dataMgr) throws GFEServerException { + boolean displayable, DataManager dataMgr, LockTable lt) { super(parmID, gridInfo, mutable, displayable, dataMgr); + this.lockTable = lt; TimeRange tr = TimeRange.allTimes(); try { @@ -121,12 +123,6 @@ public class DbParm extends Parm { + " during loading"); } } - - if ((this.dataManager != null) - && (this.dataManager.getClient() != null)) { - this.lockTable = this.dataManager.getClient().getLockTable( - this.getParmID()); - } } /* @@ -156,18 +152,17 @@ public class DbParm extends Parm { // --------------------------------------------------------------------------- private IGridData[] getGridsFromDb(final TimeRange timeRange, boolean populate) throws GFEOperationFailedException { - - List invTR; - try { - invTR = this.dataManager.getClient().getGridInventory(getParmID()); - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, - "Unable to retrieve gridded data [inventory] for " - + getParmID(), e); + ServerResponse> sr = dataManager.getClient() + .getGridInventory(getParmID()); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "Unable to retrieve gridded data [inventory] for %s: %s", + getParmID(), sr.message())); return new IGridData[0]; // empty sequence } // now filter out those grids which are not of interest + List invTR = sr.getPayload(); List desiredTR = new ArrayList(); for (TimeRange tr : invTR) { if (tr.overlaps(timeRange)) { @@ -195,47 +190,41 @@ public class DbParm extends Parm { // Makes a request for the data grids, converts the data slices into // GridData*. // --------------------------------------------------------------------------- - @SuppressWarnings("unchecked") private IGridData[] getGridsFromDb(List gridTimes, boolean populate, Map> histories) { // success = true; List dataSlices = null; // want populated if (populate) { - if (gridTimes.size() == 0) { + if (gridTimes.isEmpty()) { return new IGridData[0]; // nothing to do } - try { - dataSlices = this.dataManager.getClient().getGridData( - getParmID(), gridTimes); - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - "Unable to retrieve gridded data [get data] for " - + getParmID(), e); + GetGridRequest ggr = new GetGridRequest(getParmID(), gridTimes); + ServerResponse> sr = dataManager.getClient() + .getGridData(ggr); + if (!sr.isOkay()) { + statusHandler + .error(String + .format("Unable to retrieve gridded data [get data] for %s: %s", + getParmID(), sr.message())); // success = false; return new IGridData[0]; // empty sequence } + dataSlices = sr.getPayload(); + // want empty shell } else { if (histories == null) { - try { - ServerResponse sr = this.dataManager.getClient() - .getGridHistory(getParmID(), gridTimes); - histories = (Map>) sr - .getPayload(); - if (!sr.isOkay() || (histories.size() != gridTimes.size())) { - statusHandler.handle(Priority.PROBLEM, - "Unable to retrieve gridded data [history] for " - + getParmID() + sr); - // success = false; - return new IGridData[0]; // empty sequence - } - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - "Unable to retrieve gridded data [history] for " - + getParmID(), e); + ServerResponse>> sr = dataManager + .getClient().getGridHistory(getParmID(), gridTimes); + histories = sr.getPayload(); + if ((!sr.isOkay()) || (histories.size() != gridTimes.size())) { + statusHandler + .error(String + .format("Unable to retrieve gridded data [history] for %s: %s", + getParmID(), sr.message())); // success = false; return new IGridData[0]; // empty sequence } @@ -481,46 +470,42 @@ public class DbParm extends Parm { @Override protected boolean requestLock(List lreq) { - if (ignoreLocks()) { return true; } ITimer timer = TimeUtil.getTimer(); timer.start(); - ServerResponse> sr; - try { - sr = this.dataManager.getClient().requestLockChange(lreq); - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, - "Error requesting lock change", e); - return false; - } + ServerResponse> sr = this.dataManager.getClient() + .requestLockChange(lreq); timer.stop(); perfLog.logDuration("Server lock change for " + this.getParmID() + " " + lreq.size() + " time ranges", timer.getElapsedTime()); - timer.reset(); - timer.start(); - List lockTableList = sr.getPayload(); - for (LockTable lt : lockTableList) { - // it is for our parm - if (lt.getParmId().equals(this.getParmID())) { - lockTableArrived(lt); // treat as a notification - } - // it is for another parm - else { - Parm otherParm = this.dataManager.getParmManager().getParm( - lt.getParmId()); - if (otherParm != null) { - otherParm.lockTableArrived(lt); + if (sr.isOkay()) { + timer.reset(); + timer.start(); + List lockTableList = sr.getPayload(); + for (LockTable lt : lockTableList) { + // it is for our parm + if (lt.getParmId().equals(getParmID())) { + lockTableArrived(lt); // treat as a notification + } + // it is for another parm + else { + Parm otherParm = dataManager.getParmManager().getParm( + lt.getParmId()); + if (otherParm != null) { + otherParm.lockTableArrived(lt); + } } } - } - timer.stop(); - perfLog.logDuration("Processing lock tables", timer.getElapsedTime()); - for (ServerMsg msg : sr.getMessages()) { - statusHandler.error(msg.getMessage()); + timer.stop(); + perfLog.logDuration("Processing lock tables", + timer.getElapsedTime()); + } else { + statusHandler.error(String.format( + "Failed to process lock request: %s", sr.message())); } return sr.isOkay(); @@ -699,16 +684,9 @@ public class DbParm extends Parm { private boolean doSave(List sgr) { boolean success = true; - ServerResponse sr = null; - try { - sr = dataManager.getClient().saveGrids(sgr); - } catch (GFEServerException e) { - statusHandler - .handle(Priority.PROBLEM, - "Save data request not granted for " + getParmID() - + ". \n", e); - return false; - } + + ServerResponse sr = dataManager.getClient().saveGridData(sgr, + dataManager.clientISCSendStatus()); if (!sr.isOkay()) { StringBuilder sb = new StringBuilder(); sb.append("Save data request not granted for "); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ParmListeners.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ParmListeners.java index 340b772e17..6b17fc033c 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ParmListeners.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ParmListeners.java @@ -19,7 +19,7 @@ **/ package com.raytheon.viz.gfe.core.parm; -import org.apache.commons.lang.Validate; +import org.apache.commons.lang3.Validate; import org.eclipse.core.runtime.ListenerList; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ParmOp.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ParmOp.java index fd1f6351d7..4dff55fdac 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ParmOp.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ParmOp.java @@ -21,6 +21,7 @@ package com.raytheon.viz.gfe.core.parm; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.Iterator; @@ -46,7 +47,9 @@ import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable.LockMode; import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; import com.raytheon.uf.common.dataplugin.gfe.server.request.CommitGridRequest; import com.raytheon.uf.common.dataplugin.gfe.server.request.LockRequest; +import com.raytheon.uf.common.dataplugin.gfe.server.request.LockTableRequest; import com.raytheon.uf.common.dataplugin.gfe.server.request.SendISCRequest; +import com.raytheon.uf.common.gfe.ifpclient.IFPClient; import com.raytheon.uf.common.status.IPerformanceStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.PerformanceStatus; @@ -65,7 +68,6 @@ import com.raytheon.viz.gfe.PythonPreferenceStore; import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.core.IParmManager; import com.raytheon.viz.gfe.core.griddata.IGridData; -import com.raytheon.viz.gfe.core.internal.IFPClient; import com.raytheon.viz.gfe.core.parm.Parm.InterpState; import com.raytheon.viz.gfe.core.parm.ParmState.InterpMode; import com.raytheon.viz.gfe.core.wxvalue.WxValue; @@ -93,6 +95,7 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeProhibitedOpException; * 08/20/2014 #1664 randerso Fixed invalid thread access * 09/15/2015 #4858 dgilling Disable publish and ISC send when DRT * mode is enabled. + * 11/18/2015 #5129 dgilling Support new IFPClient. * * * @@ -440,9 +443,9 @@ public class ParmOp { */ public boolean breakLock(final ParmID parmId, final TimeRange... times) { // parm exists? - Parm p = this.dataManager.getParmManager().getParm(parmId); + Parm p = dataManager.getParmManager().getParm(parmId); if (p != null) { - p.breakLock(times); + return p.breakLock(times); } // parm not in existence @@ -451,15 +454,16 @@ public class ParmOp { for (TimeRange tr : times) { lreq.add(new LockRequest(parmId, tr, LockMode.BREAK_LOCK)); } - try { - this.dataManager.getClient().requestLockChange(lreq); - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, - "Error attempting to break locks", e); - return false; + + ServerResponse> sr = dataManager.getClient() + .requestLockChange(lreq); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "Couldn't break locks for ParmID %s: %s", parmId, + sr.message())); } + return sr.isOkay(); } - return true; } /** @@ -468,14 +472,24 @@ public class ParmOp { * @return the lock table * @throws GFEServerException */ - public List mutableDbLockTable() throws GFEServerException { - if (!this.dataManager.getParmManager().getMutableDatabase().isValid()) { - return null; + public List mutableDbLockTable() { + DatabaseID mutableDb = dataManager.getParmManager() + .getMutableDatabase(); + if (!mutableDb.isValid()) { + return Collections.emptyList(); } - return this.dataManager.getClient().getLockTable( - this.dataManager.getParmManager().getMutableDatabase()); + LockTableRequest ltr = new LockTableRequest(mutableDb); + ServerResponse> sr = dataManager.getClient() + .getLockTable(ltr); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "Couldn't get lockTable for database %s: %s", mutableDb, + sr.message())); + return Collections.emptyList(); + } + return sr.getPayload(); } /** @@ -486,19 +500,18 @@ public class ParmOp { */ public void publish(List req) throws SimulatedTimeProhibitedOpException { - CAVEMode mode = CAVEMode.getMode(); - if (!SimulatedTimeOperations.isTransmitAllowed()) { throw SimulatedTimeOperations .constructProhibitedOpException("Publish GFE grids"); } + CAVEMode mode = CAVEMode.getMode(); if (mode.equals(CAVEMode.PRACTICE) || mode.equals(CAVEMode.TEST)) { statusHandler.handle(Priority.EVENTA, "PUBLISH Simulated. "); return; } - if (req.size() == 0) { + if (req.isEmpty()) { statusHandler .handle(Priority.EVENTA, "PUBLISH: Nothing to publish"); return; @@ -513,7 +526,7 @@ public class ParmOp { final ConcurrentLinkedQueue> okSrs = new ConcurrentLinkedQueue>(); final AtomicBoolean allOk = new AtomicBoolean(true); - final IFPClient client = this.dataManager.getClient(); + final IFPClient client = dataManager.getClient(); // spawn separate jobs final CountDownLatch latch = new CountDownLatch(MAX_CONCURRENT_JOBS); @@ -524,23 +537,15 @@ public class ParmOp { try { CommitGridRequest req = null; while ((req = requests.poll()) != null) { - try { - ServerResponse sr = client - .commitGrid(Arrays - .asList(new CommitGridRequest[] { req })); - if (sr.isOkay()) { - okSrs.add(sr); - } else { - allOk.set(false); - statusHandler.handle(Priority.PROBLEM, - "PUBLISH problem: Unable to publish grid " - + sr.toString()); - } - } catch (GFEServerException e) { + ServerResponse sr = client.commitGrid(req); + if (sr.isOkay()) { + okSrs.add(sr); + } else { allOk.set(false); - statusHandler.handle(Priority.PROBLEM, - "PUBLISH problem: Unable to publish grids. " - + e.getLocalizedMessage(), e); + statusHandler + .error(String + .format("PUBLISH problem: Unable to publish grid: %s", + sr.message())); } } } finally { @@ -1073,13 +1078,12 @@ public class ParmOp { */ public void sendISC(List req) throws SimulatedTimeProhibitedOpException { - CAVEMode mode = CAVEMode.getMode(); - if (!SimulatedTimeOperations.isTransmitAllowed()) { throw SimulatedTimeOperations .constructProhibitedOpException("Send ISC grids"); } + CAVEMode mode = CAVEMode.getMode(); if (mode.equals(CAVEMode.PRACTICE) || mode.equals(CAVEMode.TEST)) { statusHandler.handle(Priority.EVENTA, "SEND ISC Simulated. "); return; @@ -1119,53 +1123,41 @@ public class ParmOp { .getStringArray("ISC_neverSendParms")); // filter out some of the requests that are not desired - for (int i = 0; i < req.size(); i++) { + for (SendISCRequest r : req) { // check parm name - if (skipParms.contains(req.get(i).getParmId().getParmName())) { + if (skipParms.contains(r.getParmId().getParmName())) { continue; } // adjust time limits - TimeRange tr = req.get(i).getTimeRange() - .intersection(limitTime); - if (tr.equals(new TimeRange())) { + TimeRange tr = r.getTimeRange().intersection(limitTime); + if (!tr.isValid()) { continue; } - // now adjust for server's grid inventory and expand tr to - // include the entire grid - List inv = new ArrayList(); - try { - inv = dataManager.serverParmInventory(req.get(i) - .getParmId()); - } catch (GFEServerException e) { - statusHandler.handle( - Priority.PROBLEM, - "Unable to get server parm inventory: " - + e.getLocalizedMessage(), e); - } - for (int j = 0; j < inv.size(); j++) { - if (inv.get(j).overlaps(tr)) { - tr = tr.combineWith(inv.get(j)); - } else if (inv.get(j).getStart().after(tr.getEnd())) { // efficienty + /* + * now adjust for server's grid inventory and expand tr to + * include the entire grid + */ + List inv = dataManager.serverParmInventory(r + .getParmId()); + for (TimeRange invTR : inv) { + if (invTR.overlaps(tr)) { + tr = tr.combineWith(invTR); + } else if (invTR.getStart().after(tr.getEnd())) { continue; } } - requests.add(new SendISCRequest(req.get(i).getParmId(), tr)); + requests.add(new SendISCRequest(r.getParmId(), tr)); } - } - ServerResponse sr = null; - try { - sr = dataManager.getClient().sendISC(requests); - if (!sr.isOkay()) { - statusHandler.handle(Priority.PROBLEM, - "SEND ISC problem: Unable to send ISC grids. " + sr); - } - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, - "SEND ISC problem: Unable to send ISC grids. " + sr); + + ServerResponse sr = dataManager.getClient().sendISC(requests); + if (!sr.isOkay()) { + statusHandler.error(String.format( + "SEND ISC problem: Unable to send ISC grids: %s", + sr.message())); } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/AbstractScriptUtil.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/AbstractScriptUtil.java index 9cd233ca9c..6828c7702c 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/AbstractScriptUtil.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/AbstractScriptUtil.java @@ -17,16 +17,13 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -/** - * - */ + package com.raytheon.viz.gfe.core.script; import java.io.File; -import java.io.FileWriter; import java.io.IOException; +import java.io.OutputStreamWriter; import java.util.Properties; -import java.util.regex.Pattern; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; @@ -40,8 +37,8 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.localization.SaveableOutputStream; import com.raytheon.uf.common.python.PythonFileFilter; -import com.raytheon.uf.common.util.FileUtil; import com.raytheon.uf.viz.core.localization.LocalizationManager; import com.raytheon.viz.gfe.Activator; import com.raytheon.viz.gfe.GFEException; @@ -56,83 +53,31 @@ import com.raytheon.viz.gfe.smarttool.SmartToolConstants; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- + * ??? wldougher Initial creation * Sep 09, 2013 #2033 dgilling Use new templates directory. + * Jan 18, 2016 4834 njensen Fix creating files, deleted dead code * * * * @author wldougher * */ -public abstract class AbstractScriptUtil implements IScriptUtil { +public abstract class AbstractScriptUtil implements PythonFileTemplate { protected IPathManager pathManager; /** * Constructor. */ - public AbstractScriptUtil() { + protected AbstractScriptUtil() { pathManager = PathManagerFactory.getPathManager(); } - /** - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#copy(java.lang.String, - * java.lang.String, - * com.raytheon.uf.common.localization.LocalizationContext. - * LocalizationLevel, - * com.raytheon.viz.gfe.core.script.IScriptUtil.Overwrite) - */ - @Override - public LocalizationFile copy(String source, String dest, - LocalizationLevel toLevel, Overwrite mode) throws GFEException { - LocalizationFile src = find(source, null); - LocalizationFile dst = null; - String scriptType = getScriptType(); - if (src == null || !src.exists()) { - throw new GFEException(String.format("%s %s does not exist.", - scriptType, source)); - } else { - LocalizationLevel srcLevel = src.getContext() - .getLocalizationLevel(); - if (source.equals(dest) && srcLevel.equals(toLevel)) { - String msg = String.format( - "Attempt to copy %s %s at %s level to itself.", - scriptType, source, srcLevel); - throw new GFEException(msg); - } else { - IPathManager pathManager = PathManagerFactory.getPathManager(); - LocalizationContext ctx = pathManager.getContext( - LocalizationType.CAVE_STATIC, toLevel); - String destPath = getScriptTypePathPrefix() + File.separator - + scripted(dest); - dst = pathManager.getLocalizationFile(ctx, destPath); - if (mode == Overwrite.SAFE && dst.exists()) { - dst = null; - } else { - try { - FileUtil.copyFile(src.getFile(), dst.getFile()); - dst.save(); - } catch (Exception e) { - throw new GFEException(String.format( - "Error copying %s %s to %s.", scriptType, - source, dest), e); - } - } - } - } - return dst; - } - - /** - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#createNew(java.lang. - * String, - * com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel - * , com.raytheon.viz.gfe.core.script.IScriptUtil.Overwrite) - */ @Override public LocalizationFile createNew(String script, LocalizationLevel level, Overwrite mode) throws GFEException { String scriptFName; - scriptFName = scripted(script); + scriptFName = normalize(script); String path = getScriptTypePathPrefix() + File.separator + scriptFName; LocalizationContext context = pathManager.getContext( LocalizationType.CAVE_STATIC, level); @@ -146,19 +91,6 @@ public abstract class AbstractScriptUtil implements IScriptUtil { throw new GFEException( "Attempt to create existing file in SAFE mode"); } else { - File outFile = locFile.getFile(); - File parentDir = outFile.getParentFile(); - if (!parentDir.exists()) { - parentDir.mkdirs(); - } - FileWriter fileWriter = null; - try { - fileWriter = new FileWriter(outFile); - } catch (IOException e) { - throw new GFEException("Error creating file writer for " - + getScriptType() + " " + script, e); - } - // Set up the velocity context and template initVelocity(); VelocityContext vctx = new VelocityContext(); @@ -168,98 +100,28 @@ public abstract class AbstractScriptUtil implements IScriptUtil { Template template = getVelocityTemplate(); // Generate the local file. - boolean throwing = false; - try { - template.merge(vctx, fileWriter); + try (SaveableOutputStream sos = locFile.openOutputStream(); + OutputStreamWriter writer = new OutputStreamWriter(sos)) { + template.merge(vctx, writer); + writer.close(); + sos.save(); + // refresh the reference in memory + locFile = pathManager.getLocalizationFile(context, path); } catch (Exception e) { - throwing = true; - throw new GFEException("Error in velocity merge for " - + getScriptType() + " " + script, e); - } finally { - try { - fileWriter.close(); - } catch (IOException e) { - if (!throwing) { - throw new GFEException("Error closing file writer for " - + getScriptType() + " " + script, e); - } - } - } - - // Propagate local file to the server. - try { - locFile.save(); - } catch (Exception e) { - throw new GFEException("Error saving " + getScriptType() + " " - + script, e); + throw new GFEException( + "Error creating new file " + scriptFName, e); } } return locFile; } - /** - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#delete(java.lang.String, - * com - * .raytheon.uf.common.localization.LocalizationContext.LocalizationLevel) - */ - @Override - public void delete(String name, LocalizationLevel level) - throws GFEException { - String srcPath = scripted(name); - String pycPath = srcPath.replaceAll(Pattern.quote(".py") + "$", ".pyc"); - String pyoPath = srcPath.replaceAll(Pattern.quote(".py") + "$", ".pyo"); - LocalizationLevel fileLevel = LocalizationLevel.BASE; - LocalizationLevel pycLevel = LocalizationLevel.BASE; - LocalizationLevel pyoLevel = LocalizationLevel.BASE; - - LocalizationFile file = find(srcPath, level); - LocalizationFile pycFile = find(pycPath, level); - LocalizationFile pyoFile = find(pyoPath, level); - - // If level was null we may have source and bytecode files at multiple - // levels. Find the highest localization level. - LocalizationLevel highest = LocalizationLevel.BASE; - if (file != null) { - fileLevel = file.getContext().getLocalizationLevel(); - highest = fileLevel; - } - if (pycFile != null) { - pycLevel = pycFile.getContext().getLocalizationLevel(); - highest = pycLevel.compareTo(highest) > 0 ? pycLevel : highest; - } - if (pyoFile != null) { - pyoLevel = pyoFile.getContext().getLocalizationLevel(); - highest = pyoLevel.compareTo(highest) > 0 ? pyoLevel : highest; - } - - // Don't delete files less localized than highest. - if (fileLevel.compareTo(highest) < 0) { - file = null; - } - if (pycLevel.compareTo(highest) < 0) { - pycFile = null; - } - if (pyoLevel.compareTo(highest) < 0) { - pyoFile = null; - } - - innerDelete(file, srcPath, fileLevel); - innerDelete(pycFile, pycPath, pycLevel); - innerDelete(pyoFile, pyoPath, pyoLevel); - } - - /** - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#find(java.lang.String, - * com - * .raytheon.uf.common.localization.LocalizationContext.LocalizationLevel) - */ @Override public LocalizationFile find(String name, LocalizationLevel level) throws GFEException { LocalizationFile result = null; String path = getScriptTypePathPrefix() + File.separator + name; - path = scripted(path); + path = normalize(path); if (level == null) { result = pathManager.getStaticLocalizationFile(path); } else { @@ -273,21 +135,6 @@ public abstract class AbstractScriptUtil implements IScriptUtil { return result; } - /** - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#getScriptType() - */ - @Override - abstract public String getScriptType(); - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.script.IScriptUtil#getScriptTypePathPrefix() - */ - @Override - abstract public String getScriptTypePathPrefix(); - /** * Get the velocity template. This mostly serves to convert the many * exception types thrown by Velocity.getTemplate() to a GFEException. @@ -341,54 +188,6 @@ public abstract class AbstractScriptUtil implements IScriptUtil { } } - /** - * Do the actual deletion of a localization file. If file is null, no action - * is taken. Otherwise, file is deleted locally, and on the server, if it - * exists there. - * - * @param file - * The file to delete. May be null. - * @param name - * The name of file, for error reporting. - * @param level - * The localization level of file - * @throws GFEException - */ - protected void innerDelete(LocalizationFile file, String name, - LocalizationLevel level) throws GFEException { - if (file == null) { - ; // ignore deletion of non-existent file - } else if (file.isAvailableOnServer()) { - try { - file.delete(); - } catch (Exception e) { - String msg = String.format("Error deleting %s %s at level %s", - getScriptType(), name, level); - throw new GFEException(msg, e); - } - } else if (file.exists()) { - File jFile = file.getFile(); - jFile.delete(); - } - } - - /** - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#rename(java.lang.String, - * java.lang.String, - * com.raytheon.uf.common.localization.LocalizationContext. - * LocalizationLevel, - * com.raytheon.viz.gfe.core.script.IScriptUtil.Overwrite) - */ - @Override - public LocalizationFile rename(String source, String dest, - LocalizationLevel toLevel, Overwrite mode) throws GFEException { - LocalizationFile dst; - LocalizationFile src = find(source, null); - dst = copy(source, dest, toLevel, mode); - delete(source, src.getContext().getLocalizationLevel()); - return dst; - } - /** * Add ".py" to name if it doesn't end with ".py", ".pyc", or ".pyo" and * return the result. @@ -398,7 +197,7 @@ public abstract class AbstractScriptUtil implements IScriptUtil { * @return the decorated name. */ @Override - public String scripted(String name) { + public String normalize(String name) { String result = null; if (name.endsWith(PythonFileFilter.EXTENSION) || name.endsWith(".pyo") || name.endsWith(".pyc")) { diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/CopyInputValidator.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/CopyInputValidator.java index 2fc4c74ff3..e2127023c1 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/CopyInputValidator.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/CopyInputValidator.java @@ -38,7 +38,7 @@ public class CopyInputValidator implements IInputValidator { protected String scriptf; - protected IScriptUtil util; + protected PythonFileTemplate util; private static final Pattern VALID_NAME = Pattern .compile("^[\\p{Alpha}_]+\\w*"); @@ -51,10 +51,10 @@ public class CopyInputValidator implements IInputValidator { * @param util * The script utility object that will do the work. */ - public CopyInputValidator(String script, IScriptUtil util) { + public CopyInputValidator(String script, PythonFileTemplate util) { this.script = script; this.util = util; - this.scriptf = util.scripted(script); + this.scriptf = util.normalize(script); } /** @@ -72,7 +72,7 @@ public class CopyInputValidator implements IInputValidator { if (!VALID_NAME.matcher(newText.trim()).matches()) { return "Only letters, digits, and underscores are allowed."; } - String newfname = util.scripted(newText); + String newfname = util.normalize(newText); if (scriptf.equals(newfname)) { return script + " cannot be copied to itself."; } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/IScriptUtil.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/PythonFileTemplate.java similarity index 51% rename from cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/IScriptUtil.java rename to cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/PythonFileTemplate.java index 4188b68484..4b250f1ef6 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/IScriptUtil.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/PythonFileTemplate.java @@ -22,47 +22,40 @@ */ package com.raytheon.viz.gfe.core.script; -import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; +import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.viz.gfe.GFEException; /** - * An interface describing several common actions on user-defined scripts. + * An interface for generating new python files based on a template. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * ???                     wldougher   Initial creation
+ * Jan 19, 2016   4834     njensen     Rename, refactor, clean up
+ * 
+ * 
* * @author wldougher * */ -public interface IScriptUtil { +public interface PythonFileTemplate { + public enum Overwrite { OVERWRITE, SAFE - }; - - /** - * Copy script to the new file toScript at localization level toLevel. If - * source and dest are the equal, toLevel must be different from the - * localization level of source. If dest already exists and mode is SAFE, - * dest will not be overwritten and the returned localization file will be - * null. - * - * @param source - * the simple name of the source script - * @param dest - * the simple name of the destination script - * @param mode - * Whether processing should proceed if dest already exists. - * @return A reference to toScript, which may be null if the copy fails. - * @throws GFEException - * if script and toScript have the same name and level or if the - * copy cannot complete due to file or network errors. - */ - public LocalizationFile copy(String source, String dest, - LocalizationLevel toLevel, Overwrite mode) throws GFEException; + } /** * Create a new script at the designated localization level. Implementations * may initialize the contents of the new script however they desire. * * @param script + * @param level + * @param mode * @return A reference to the newly created script, or null if the script * could not be created. */ @@ -70,29 +63,7 @@ public interface IScriptUtil { Overwrite mode) throws GFEException; /** - * Delete the script with the designated name at the designated localization - * level. - * - * @param name - * The simple name of the script. - * @param level - * the localization level at which the script should be deleted. - * @throws GFEException - * if underlying file or network operations fail. - */ - public void delete(String name, LocalizationLevel level) - throws GFEException; - - /** - * The type of file to pass to PythonUtil.openPythonFile() when editing - * scripts of this type. - * - * @return the file type string - */ - public String getFileType(); - - /** - * The type of script this utility handles. Implementors should return this + * The type of script this utility handles. Implementers should return this * in capitalized case, i.e., "Procedure", for use in error messages. * * @return the script type string @@ -116,21 +87,6 @@ public interface IScriptUtil { public LocalizationFile find(String name, LocalizationLevel level) throws GFEException; - /** - * Rename source to dest. This should be equivalent to calling copy() - * followed by delete(). - * - * @param source - * the simple name of the source script - * @param dest - * the simple name of the destination script - * @param mode - * Whether processing should proceed if dest already exists. - * @return A reference to the renamed file. - */ - public LocalizationFile rename(String source, String dest, - LocalizationLevel toLevel, Overwrite mode) throws GFEException; - /** * Convert a simple name to the name of a script file. For example, * "Extrapolate" might become "Extrapolate.py". @@ -139,14 +95,14 @@ public interface IScriptUtil { * The undecorated name * @return The name of the script file derived from name. */ - public String scripted(String name); + public String normalize(String name); - /** - * Get the path prefix used in building localization filenames. For example, - * the path prefix for Procedures is "gfe/userPython/procedures", or - * GfePyIncludeUtil.PROCEDURES. - * - * @return The path prefix - */ - public abstract String getScriptTypePathPrefix(); + /** + * Get the path prefix used in building localization filenames. For example, + * the path prefix for Procedures is "gfe/userPython/procedures", or + * GfePyIncludeUtil.PROCEDURES. + * + * @return The path prefix + */ + public abstract String getScriptTypePathPrefix(); } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/action/NewAction.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/action/NewAction.java index 2ee6e38ae5..89557f5862 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/action/NewAction.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/script/action/NewAction.java @@ -23,8 +23,8 @@ package com.raytheon.viz.gfe.core.script.action; import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IInputValidator; +import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; @@ -36,37 +36,43 @@ import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.viz.gfe.GFEException; import com.raytheon.viz.gfe.PythonUtil; import com.raytheon.viz.gfe.core.script.ExistMode; -import com.raytheon.viz.gfe.core.script.IScriptUtil; -import com.raytheon.viz.gfe.core.script.IScriptUtil.Overwrite; import com.raytheon.viz.gfe.core.script.NewInputValidator; +import com.raytheon.viz.gfe.core.script.PythonFileTemplate; +import com.raytheon.viz.gfe.core.script.PythonFileTemplate.Overwrite; import com.raytheon.viz.gfe.dialogs.ScriptNameInputDialog; /** * An Action for creating a new instance of a script. * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * ???                     wldougher   Initial creation
+ * Jan 19, 2016  4834      njensen     Cleaned up warnings
+ *
+ * 
+ * * @author wldougher * */ public class NewAction extends Action { + private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(NewAction.class); - protected IScriptUtil util; + protected PythonFileTemplate util; /** - * @param selected * @param util */ - public NewAction(IScriptUtil util) { + public NewAction(PythonFileTemplate util) { super("New..."); this.util = util; } - /** - * - * - * @see org.eclipse.jface.action.Action#run() - */ @Override public void run() { Shell parent = Display.getCurrent().getActiveShell(); @@ -76,7 +82,7 @@ public class NewAction extends Action { + type, "Name", "My" + type, validator, util); dialog.setMode(ExistMode.ERR_EXISTS); int rtnCode = dialog.open(); - if (rtnCode == Dialog.OK) { + if (rtnCode == Window.OK) { String script = dialog.getValue().trim(); try { // since createNew() will only return if a LocalizationFile is diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/BreakLockDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/BreakLockDialog.java index 9b5b6e98a6..a6f05bbd6b 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/BreakLockDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/BreakLockDialog.java @@ -21,6 +21,7 @@ package com.raytheon.viz.gfe.dialogs; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.TimeZone; @@ -40,10 +41,10 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; import com.raytheon.uf.common.dataplugin.gfe.server.lock.Lock; import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable; +import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; 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.viz.gfe.GFEServerException; import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.core.UIFormat; import com.raytheon.viz.gfe.core.UIFormat.FilterType; @@ -61,6 +62,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * Feb 20, 2008 ebabin Initial Creation * Jun 30, 2008 ebabin Updates for status of break lock. * Sep 20, 2012 #1190 dgilling Use new WsId.getHostName() method. + * Nov 17, 2015 #5129 dgilling Support new IFPClient. * * * @@ -106,8 +108,8 @@ public class BreakLockDialog extends CaveJFACEDialog { super(parent); this.dataManager = dataManager; - this.uiFormat = new UIFormat(DataManager.getCurrentInstance() - .getParmManager(), FilterType.MUTABLE, FilterType.MUTABLE); + this.uiFormat = new UIFormat(this.dataManager.getParmManager(), + FilterType.MUTABLE, FilterType.MUTABLE); this.setShellStyle(SWT.TITLE | SWT.MODELESS | SWT.CLOSE); try { @@ -118,19 +120,21 @@ public class BreakLockDialog extends CaveJFACEDialog { } } - protected void initLockData() throws GFEServerException { + protected void initLockData() { List lockTables = dataManager.getParmOp() .mutableDbLockTable(); + ServerResponse> sr = dataManager.getClient() + .getClientList(); List clients; - try { - clients = dataManager.getClient().getClients(); - } catch (GFEServerException e) { + if (!sr.isOkay()) { statusHandler - .handle(Priority.PROBLEM, - "Unable to retrieve client info. All locks will appear as orphans", - e); - clients = new ArrayList(); + .error(String + .format("Unable to retrieve client info: %s. All locks will appear as orphans", + sr.message())); + clients = Collections.emptyList(); + } else { + clients = sr.getPayload(); } this.clientLocks = new ArrayList(); @@ -245,15 +249,10 @@ public class BreakLockDialog extends CaveJFACEDialog { } private void breakLocks(Object[] locks) { - - DataManager dm = DataManager.getCurrentInstance(); - if (dm == null) { - return; - } - for (Object obj : locks) { Lock lock = (Lock) obj; - dm.getParmOp().breakLock(lock.getParmId(), lock.getTimeRange()); + dataManager.getParmOp().breakLock(lock.getParmId(), + lock.getTimeRange()); } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ConfigUtil.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ConfigUtil.java index f82a7a458a..cea76518fb 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ConfigUtil.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ConfigUtil.java @@ -23,7 +23,7 @@ import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil; import com.raytheon.viz.gfe.core.script.AbstractScriptUtil; /** - * TODO Add Description + * An implementation of PythonFileTemplate for making new Configs. * *
  *
@@ -31,15 +31,17 @@ import com.raytheon.viz.gfe.core.script.AbstractScriptUtil;
  *
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Oct 8, 2010            mpduff     Initial creation
+ * Oct 08, 2010            mpduff      Initial creation
+ * Jan 19, 2016  4834      njensen     Removed dead method
  *
  * 
- * + * * @author mpduff - * @version 1.0 + * @version 1.0 */ public class ConfigUtil extends AbstractScriptUtil { + private static final String TEMPLATE_FILENAME = "config.vm"; private static final String scriptType = "Config"; @@ -51,39 +53,19 @@ public class ConfigUtil extends AbstractScriptUtil { super(); } - /** - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#getScriptType() - */ @Override public String getScriptType() { return scriptType; } - /** - * @see com.raytheon.viz.gfe.core.script.AbstractScriptUtil#getScriptTypePathPrefix - * () - */ @Override public String getScriptTypePathPrefix() { return GfePyIncludeUtil.CONFIG; } - /** - * @see com.raytheon.viz.gfe.core.script.AbstractScriptUtil#getVelocityTemplateName - * () - */ @Override protected String getVelocityTemplateName() { return TEMPLATE_FILENAME; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#getFileType() - */ - @Override - public String getFileType() { - return "CONFIG"; - } } \ No newline at end of file diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/CreateFromScratchDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/CreateFromScratchDialog.java index 6bb169e0b2..cc359d2214 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/CreateFromScratchDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/CreateFromScratchDialog.java @@ -31,9 +31,10 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Scale; import org.eclipse.swt.widgets.Shell; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.viz.gfe.GFEOperationFailedException; import com.raytheon.viz.gfe.GFEPreference; -import com.raytheon.viz.gfe.core.DataManager; +import com.raytheon.viz.gfe.core.DataManagerUIFactory; import com.raytheon.viz.gfe.core.parm.Parm; import com.raytheon.viz.gfe.core.parm.Parm.CreateFromScratchMode; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; @@ -45,8 +46,11 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Feb 26, 2008 Eric Babin Initial Creation + * Feb 26, 2008 Eric Babin Initial Creation * Oct 24, 2012 1287 rferrel Changes for non-blocking dialog. + * Nov 30, 2015 5133 kbisanz In durationScaleChanged(), ensure + * intervalScale is valid before + * accessing it. * * * @@ -116,7 +120,7 @@ public class CreateFromScratchDialog extends CaveJFACEDialog { intervalScale = new Scale(top, SWT.HORIZONTAL); intervalScale.setMinimum(quantum); - intervalScale.setMaximum(24); + intervalScale.setMaximum(TimeUtil.HOURS_PER_DAY); intervalScale.setIncrement(quantum); intervalScale.setPageIncrement(quantum); intervalScale.setSelection(this.createInterval); @@ -145,7 +149,7 @@ public class CreateFromScratchDialog extends CaveJFACEDialog { durationScale = new Scale(top, SWT.HORIZONTAL); durationScale.setMinimum(quantum); - durationScale.setMaximum(24); + durationScale.setMaximum(TimeUtil.HOURS_PER_DAY); durationScale.setSelection(this.createDuration); data = new GridData(200, SWT.DEFAULT); durationScale.setLayoutData(data); @@ -174,17 +178,19 @@ public class CreateFromScratchDialog extends CaveJFACEDialog { } private void durationScaleChanged() { - if (durationScale.getSelection() >= intervalScale.getSelection()) { + if (displayInterval + && durationScale.getSelection() >= intervalScale.getSelection()) { durationScale.setSelection(intervalScale.getSelection()); } durationLabel.setText(Integer.toString(durationScale.getSelection())); } private void commonTC() { - Parm[] parms = DataManager.getCurrentInstance().getParmManager() - .getSelectedParms(); + Parm[] parms = DataManagerUIFactory.getCurrentInstance() + .getParmManager().getSelectedParms(); - int minRepeatInterval = 24 * 3600; + int minRepeatInterval = TimeUtil.HOURS_PER_DAY + * TimeUtil.SECONDS_PER_HOUR; this.displayInterval = true; this.displayDuration = true; int compositeRepeat = 0; @@ -218,13 +224,14 @@ public class CreateFromScratchDialog extends CaveJFACEDialog { // lets the user select intervals up to 100 hours, but the dialog // ignores them and uses 24 hours. // It's better to not show the slider at all in this case. - if (minRepeatInterval >= 24 * 3600) { + if (minRepeatInterval >= TimeUtil.HOURS_PER_DAY + * TimeUtil.SECONDS_PER_HOUR) { displayInterval = false; } - this.quantum = minRepeatInterval / 3600; - this.createDuration = compositeDuration / 3600; - this.createInterval = compositeRepeat / 3600; + this.quantum = minRepeatInterval / TimeUtil.SECONDS_PER_HOUR; + this.createDuration = compositeDuration / TimeUtil.SECONDS_PER_HOUR; + this.createInterval = compositeRepeat / TimeUtil.SECONDS_PER_HOUR; int configInterval = GFEPreference .getIntPreference("CreateScratchDefaultInterval"); @@ -233,7 +240,7 @@ public class CreateFromScratchDialog extends CaveJFACEDialog { // Sanity check config values. configInterval = Math.max(0, configInterval); - configInterval = Math.min(configInterval, 24); + configInterval = Math.min(configInterval, TimeUtil.HOURS_PER_DAY); configDuration = Math.max(0, configDuration); configDuration = Math.min(configDuration, configInterval); @@ -273,11 +280,12 @@ public class CreateFromScratchDialog extends CaveJFACEDialog { createDuration = durationScale.getSelection(); } - DataManager + DataManagerUIFactory .getCurrentInstance() .getParmOp() - .createFromScratchSelected(mode, createInterval * 3600, - createDuration * 3600); + .createFromScratchSelected(mode, + createInterval * TimeUtil.SECONDS_PER_HOUR, + createDuration * TimeUtil.SECONDS_PER_HOUR); } catch (GFEOperationFailedException e) { e.printStackTrace(); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/DefineRefSetDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/DefineRefSetDialog.java index 64da57feb2..2308d201f1 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/DefineRefSetDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/DefineRefSetDialog.java @@ -55,17 +55,14 @@ import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData.CoordinateType; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData.RefType; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID; -import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory; import com.raytheon.uf.common.python.concurrent.IPythonExecutor; import com.raytheon.uf.common.python.concurrent.IPythonJobListener; -import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator; 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.VizApp; import com.raytheon.viz.gfe.Activator; import com.raytheon.viz.gfe.core.DataManager; -import com.raytheon.viz.gfe.core.DataManagerUIFactory; import com.raytheon.viz.gfe.core.IParmManager; import com.raytheon.viz.gfe.core.IReferenceSetManager; import com.raytheon.viz.gfe.core.IReferenceSetManager.RefSetMode; @@ -81,7 +78,6 @@ import com.raytheon.viz.gfe.core.wxvalue.WeatherWxValue; import com.raytheon.viz.gfe.core.wxvalue.WxValue; import com.raytheon.viz.gfe.query.QueryScript; import com.raytheon.viz.gfe.query.QueryScriptExecutor; -import com.raytheon.viz.gfe.query.QueryScriptFactory; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; import com.raytheon.viz.ui.dialogs.ICloseCallback; import com.raytheon.viz.ui.widgets.ToggleSelectList; @@ -106,7 +102,8 @@ import com.vividsolutions.jts.geom.MultiPolygon; * Feb 14, 2013 mnash Move QueryScript to use new Python concurrency implementation * Jan 13, 2015 3955 randerso Improve handling of Topo parm for Standard Terrain editing * Jun 24, 2015 14401 yteng Check whether activeDisplay is disposed before update - * Aug 27, 2015 4749 njensen Reused reference to PythonJobCoordinator instance + * Aug 27, 2015 4749 njensen Reused reference to PythonJobCoordinator instance + * Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API. * * * @@ -853,12 +850,8 @@ public class DefineRefSetDialog extends CaveJFACEDialog implements } private void submit() { + Map argMap = new HashMap(1, 1f); final String s = this.queryField.getText().trim(); - AbstractPythonScriptFactory factory = new QueryScriptFactory( - DataManagerUIFactory.getCurrentInstance()); - PythonJobCoordinator coordinator = PythonJobCoordinator - .getInstance(factory.getName()); - Map argMap = new HashMap(); argMap.put("expression", s); IPythonExecutor executor = new QueryScriptExecutor( "evaluate", argMap); @@ -881,22 +874,21 @@ public class DefineRefSetDialog extends CaveJFACEDialog implements addToHistory(s); if (activeDisplay != null - || !activeDisplay.isDisposed()) + || !activeDisplay.isDisposed()) { activeDisplay.setText(s); + } - if (queryField != null && !queryField.isDisposed()) + if (queryField != null && !queryField.isDisposed()) { queryField.setText(""); + } } }; }); } }; - try { - coordinator.submitAsyncJob(executor, listener); - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - "Unable to submit job to ExecutorService", e); - } + + refSetMgr.getPythonThreadPool().submitJobWithCallback(executor, + listener); } /* diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/FormatterLauncherDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/FormatterLauncherDialog.java index 5b5c9336b7..4db84d84c8 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/FormatterLauncherDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/FormatterLauncherDialog.java @@ -56,7 +56,6 @@ import org.eclipse.ui.contexts.IContextService; import org.eclipse.ui.plugin.AbstractUIPlugin; import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID; -import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; import com.raytheon.uf.common.dataplugin.gfe.textproduct.ProductDefinition; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; @@ -66,7 +65,6 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager; import com.raytheon.viz.core.mode.CAVEMode; import com.raytheon.viz.gfe.Activator; import com.raytheon.viz.gfe.GFEPreference; -import com.raytheon.viz.gfe.GFEServerException; import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.dialogs.formatterlauncher.ConfigData; import com.raytheon.viz.gfe.dialogs.formatterlauncher.IProductTab; @@ -101,6 +99,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Feb 12, 2014 2801 randerso Added prompting if formatter is run against non-normal database * Jul 29, 2015 4263 dgilling Support changes to TextProductManager. * Aug 24, 2015 4749 dgilling Reorganize dialog close and dispose. + * Nov 18, 2015 5129 dgilling Support new IFPClient. * * * @@ -1092,17 +1091,7 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements * @return The Official Data source */ private DatabaseID getOfficialDataSource() { - DatabaseID source = null; - try { - ServerResponse> sr = dataMgr.getClient() - .getOfficialDBName(); - source = sr.getPayload().get(0); - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, - "Unable to determine official db", e); - } - - return source; + return dataMgr.getParmManager().getProductDB(); } /** diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/GFEConfigDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/GFEConfigDialog.java index 885b065b5e..9627bc22d0 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/GFEConfigDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/GFEConfigDialog.java @@ -21,10 +21,11 @@ package com.raytheon.viz.gfe.dialogs; import java.io.BufferedReader; import java.io.BufferedWriter; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.Writer; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; @@ -46,6 +47,7 @@ import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -53,21 +55,24 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Monitor; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; -import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; +import com.raytheon.uf.common.localization.SaveableOutputStream; +import com.raytheon.uf.common.localization.exception.LocalizationException; 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.SimulatedTime; import com.raytheon.uf.common.util.FileUtil; import com.raytheon.viz.gfe.Activator; @@ -80,10 +85,14 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket//    Engineer    Description
+ * Date         Ticket     Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Apr 30, 2009            randerso     Initial creation
+ * Apr 30, 2009            randerso    Initial creation
  * Oct 30, 2012 1298       rferrel     Code cleanup for non-blocking dialog.
+ * Oct 28, 2015 5054       randerso    Place GfeConfigDialog on current monitor if 
+ *                                     parent shell is not visible.
+ * Nov 12, 2015 4834       njensen     Changed LocalizationOpFailedException to LocalizationException
+ * Feb 05, 2016 5242       dgilling    Remove calls to deprecated Localization APIs.
  * 
  * 
* @@ -174,6 +183,29 @@ public class GFEConfigDialog extends CaveJFACEDialog { newShell.setText("GFE Startup"); } + @Override + protected Point getInitialLocation(Point initialSize) { + Point loc = super.getInitialLocation(initialSize); + + if (!getParentShell().isVisible()) { + // center on current monitor + Display display = getShell().getDisplay(); + Monitor[] monitors = display.getMonitors(); + + Point cursor = display.getCursorLocation(); + for (Monitor m : monitors) { + Rectangle b = m.getBounds(); + if (b.contains(cursor)) { + loc.x = b.x + (b.width - initialSize.x) / 2; + loc.y = b.y + (b.height - initialSize.y) / 2; + break; + } + } + } + + return loc; + } + /* * (non-Javadoc) * @@ -302,7 +334,7 @@ public class GFEConfigDialog extends CaveJFACEDialog { private Image nextImage() { int imageNumber = randomSplash(); String imageName = "SSa" + imageNumber + ".gif"; - ImageDescriptor id = Activator.imageDescriptorFromPlugin( + ImageDescriptor id = AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, FileUtil.join("images", imageName)); return id.createImage(); } @@ -381,60 +413,38 @@ public class GFEConfigDialog extends CaveJFACEDialog { IPathManager pathMgr = PathManagerFactory.getPathManager(); LocalizationContext context = pathMgr.getContext( LocalizationType.CAVE_STATIC, LocalizationLevel.USER); - LocalizationFile lf = pathMgr.getLocalizationFile(context, LAST_CONFIG); - File file = lf.getFile(); + ILocalizationFile lf = pathMgr + .getLocalizationFile(context, LAST_CONFIG); - BufferedWriter out = null; - try { - out = new BufferedWriter(new FileWriter(file)); + try (SaveableOutputStream outStream = lf.openOutputStream(); + Writer out = new BufferedWriter(new OutputStreamWriter( + outStream))) { out.write(config); + out.close(); + outStream.save(); } catch (IOException e) { - statusHandler.handle(Priority.PROBLEM, - "Error saving config file selection", e); - } finally { - if (out != null) { - try { - out.close(); - } catch (IOException e) { - // nothing to do - } - } - } - - try { - lf.save(); - } catch (LocalizationOpFailedException e) { - statusHandler.handle(Priority.PROBLEM, - "Error saving config file selection", e); + statusHandler.error("Error writing config file selection", e); + } catch (LocalizationException e) { + statusHandler.error("Error saving config file selection", e); } } private void loadLastConfig() { - config = null; - IPathManager pathMgr = PathManagerFactory.getPathManager(); LocalizationContext context = pathMgr.getContext( LocalizationType.CAVE_STATIC, LocalizationLevel.USER); - LocalizationFile lf = pathMgr.getLocalizationFile(context, LAST_CONFIG); - File file = lf.getFile(); + ILocalizationFile lf = pathMgr + .getLocalizationFile(context, LAST_CONFIG); - if (file.exists()) { - BufferedReader in = null; - try { - in = new BufferedReader(new FileReader(file)); + config = null; + if (lf.exists()) { + try (InputStream inStream = lf.openInputStream(); + BufferedReader in = new BufferedReader( + new InputStreamReader(inStream))) { config = in.readLine(); - } catch (IOException e) { - statusHandler.handle(Priority.PROBLEM, - "Error loading config file selection", e); + } catch (IOException | LocalizationException e) { + statusHandler.error("Error loading config file selection", e); config = null; - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException e) { - // nothing to do - } - } } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/NewTextProductDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/NewTextProductDialog.java index 2c6e799b11..c2aefb496c 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/NewTextProductDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/NewTextProductDialog.java @@ -38,8 +38,8 @@ import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.viz.gfe.GFEException; import com.raytheon.viz.gfe.PythonUtil; -import com.raytheon.viz.gfe.core.script.IScriptUtil; -import com.raytheon.viz.gfe.core.script.IScriptUtil.Overwrite; +import com.raytheon.viz.gfe.core.script.PythonFileTemplate; +import com.raytheon.viz.gfe.core.script.PythonFileTemplate.Overwrite; import com.raytheon.viz.gfe.textproduct.TextProductTableUtil; import com.raytheon.viz.gfe.textproduct.TextProductUtil; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; @@ -126,7 +126,7 @@ public class NewTextProductDialog extends CaveJFACEDialog { return; } - IScriptUtil util = null; + PythonFileTemplate util = null; if (isSmart) { util = new TextProductUtil(); } else { diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/NewToolDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/NewToolDialog.java index bdbb693174..eeaa14e077 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/NewToolDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/NewToolDialog.java @@ -39,7 +39,8 @@ import org.eclipse.ui.PlatformUI; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.viz.gfe.core.DataManager; +import com.raytheon.viz.gfe.core.DataManagerUIFactory; +import com.raytheon.viz.gfe.core.IParmManager; import com.raytheon.viz.gfe.core.parm.Parm; import com.raytheon.viz.gfe.smarttool.SmartToolEdit; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; @@ -53,6 +54,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * ------------ ---------- ----------- -------------------------- * Feb 20, 2008 njensen Initial creation * Nov 12, 2012 1298 rferrel Changes for non-blocking dialog. + * Jan 19, 2016 4834 njensen Cleaned up warnings * * * @@ -77,13 +79,6 @@ public class NewToolDialog extends CaveJFACEDialog { setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets - * .Shell) - */ @Override protected void configureShell(Shell shell) { super.configureShell(shell); @@ -92,11 +87,6 @@ public class NewToolDialog extends CaveJFACEDialog { } } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) - */ @Override protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.OK_ID) { @@ -124,30 +114,14 @@ public class NewToolDialog extends CaveJFACEDialog { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse - * .swt.widgets.Composite) - */ @Override protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets - * .Composite) - */ @Override protected Control createDialogArea(final Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); @@ -180,8 +154,8 @@ public class NewToolDialog extends CaveJFACEDialog { // select the active parm if not null otherwise select the first parm in // the list - Parm parm = DataManager.getCurrentInstance().getSpatialDisplayManager() - .getActivatedParm(); + Parm parm = DataManagerUIFactory.getCurrentInstance() + .getSpatialDisplayManager().getActivatedParm(); if (parm != null) { parms.setSelection(new String[] { parm.getParmID().getParmName() }); } else { @@ -195,12 +169,9 @@ public class NewToolDialog extends CaveJFACEDialog { public String[] getParms() { IWorkbenchWindow window = PlatformUI.getWorkbench() .getActiveWorkbenchWindow(); - ParmID[] parms = DataManager - .getInstance(window) - .getParmManager() - .getAvailableParms( - DataManager.getInstance(window).getParmManager() - .getMutableDatabase()); + IParmManager pm = DataManagerUIFactory.getInstance(window) + .getParmManager(); + ParmID[] parms = pm.getAvailableParms(pm.getMutableDatabase()); java.util.List parmNames = new ArrayList( parms.length + 2); for (ParmID p : parms) { diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ProcessMonitorDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ProcessMonitorDialog.java index 0119ed590c..7f8b45a4ea 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ProcessMonitorDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ProcessMonitorDialog.java @@ -35,6 +35,7 @@ import java.util.TimeZone; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.GC; @@ -70,6 +71,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * Mar 7, 2008 Eric Babin Initial Creation * 02/12/2013 #1597 randerso Modified TaskOutputDialog to support GFE Performance metrics * 05/28/2014 #2841 randerso Fixed some NPEs and layout issues + * 11/12/2015 #5106 dgilling Improve load times for large log files. * * * @@ -373,7 +375,7 @@ public class ProcessMonitorDialog extends CaveJFACEDialog implements private AbstractGfeTask task; - private Text logText; + private StyledText logText; /** * @param parentShell @@ -414,8 +416,8 @@ public class ProcessMonitorDialog extends CaveJFACEDialog implements cmdText.setLayoutData(layoutData); cmdText.setText(task.getCommand()); - logText = new Text(comp, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY - | SWT.H_SCROLL | SWT.V_SCROLL); + logText = new StyledText(comp, SWT.BORDER | SWT.H_SCROLL + | SWT.V_SCROLL); layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.widthHint = this.convertWidthInCharsToPixels(120); layoutData.heightHint = this.convertHeightInCharsToPixels(24); @@ -424,7 +426,7 @@ public class ProcessMonitorDialog extends CaveJFACEDialog implements SWT.COLOR_BLACK)); logText.setForeground(logText.getDisplay().getSystemColor( SWT.COLOR_WHITE)); - + logText.setEditable(false); logText.setText(getLogFileContents()); Composite timeComp = new Composite(comp, SWT.NONE); @@ -581,6 +583,7 @@ public class ProcessMonitorDialog extends CaveJFACEDialog implements // do nothing } } + return s; } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ProductScriptsDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ProductScriptsDialog.java index b2be2290ca..1abda98efb 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ProductScriptsDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ProductScriptsDialog.java @@ -77,6 +77,7 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList; * for Png Images... is rebuilt after * return from the dialog. * Sep 15, 2015 4858 dgilling Disable all features in DRT mode. + * Nov 18, 2015 5129 dgilling Support new IFPClient. * * * @@ -185,8 +186,9 @@ public class ProductScriptsDialog extends CaveJFACEDialog { gmtTime.setTimeZone(TimeZone.getTimeZone("GMT")); SimpleDateFormat localTime = new SimpleDateFormat( TIME_FORMAT_STRING); - localTime.setTimeZone(TimeZone.getTimeZone(dataManager - .getClient().getSiteTimeZone())); + localTime.setTimeZone(TimeZone + .getTimeZone(dataManager.getParmManager() + .compositeGridLocation().getTimeZone())); String curLocalTime = localTime.format(curTime); String curGMTTime = gmtTime.format(curTime); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteEditAreaGroupDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteEditAreaGroupDialog.java index 6689b505f8..16ef47a8da 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteEditAreaGroupDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteEditAreaGroupDialog.java @@ -40,12 +40,18 @@ import org.eclipse.swt.widgets.Text; import com.raytheon.uf.common.dataplugin.gfe.reference.GroupID; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID; +import com.raytheon.uf.common.localization.ILocalizationFile; +import com.raytheon.uf.common.localization.IPathManager; +import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; +import com.raytheon.uf.common.localization.PathManagerFactory; 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.viz.gfe.core.IReferenceSetManager; +import com.raytheon.viz.gfe.core.IReferenceSetManager.RefSetMode; +import com.raytheon.viz.gfe.core.internal.ReferenceSetManager; import com.raytheon.viz.gfe.ui.AccessMgr; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; import com.raytheon.viz.ui.widgets.ToggleSelectList; @@ -57,8 +63,10 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 11, 2008 Eric Babin Initial Creation + * Mar 11, 2008 Eric Babin Initial Creation * Oct 24, 2012 1287 rferrel Code clean part of non-blocking dialog. + * Nov 18, 2015 5129 dgilling Code cleanup to support ReferenceSetManager changes. + * Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs. * * * @@ -344,13 +352,39 @@ public class SaveDeleteEditAreaGroupDialog extends CaveJFACEDialog { * @param withVerify */ private void deleteArea(String areaName, boolean withVerify) { - // Note: Area will be deleted from all groups by - // UIReferenceSetMgr which processes deletions for - // incoming ReferenceSetInventoryChanged messages + /* + * Note: Area will be deleted from all groups by UIReferenceSetMgr which + * processes deletions for incoming ReferenceSetInventoryChanged + * messages + */ ReferenceID id = new ReferenceID(areaName); if (id.isValid()) { - refSetManager.deleteRefSet(id, withVerify); + if (withVerify) { + IPathManager pm = PathManagerFactory.getPathManager(); + LocalizationContext ctx = pm.getContext( + LocalizationType.COMMON_STATIC, LocalizationLevel.USER); + ILocalizationFile lf = pm.getLocalizationFile(ctx, + ReferenceSetManager.EDIT_AREAS_DIR + + IPathManager.SEPARATOR + id.getName() + + ".xml"); + boolean verify = AccessMgr.verifyDelete(lf.getPath(), lf + .getContext().getLocalizationType(), false); + if (!verify) { + return; + } + } + + /* + * Check to see if deleting active reference set. If so, clear the + * active reference set + */ + ReferenceID activeId = refSetManager.getActiveRefSet().getId(); + if (id.equals(activeId)) { + refSetManager.incomingRefSet(refSetManager.emptyRefSet(), + RefSetMode.REPLACE); + } + refSetManager.deleteRefSet(id); } } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteRefDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteRefDialog.java index 07a611f3a5..95bbba02b2 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteRefDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteRefDialog.java @@ -44,11 +44,19 @@ import org.eclipse.swt.widgets.Text; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData.RefType; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID; +import com.raytheon.uf.common.localization.ILocalizationFile; +import com.raytheon.uf.common.localization.IPathManager; +import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; +import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; +import com.raytheon.uf.common.localization.PathManagerFactory; 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.viz.gfe.core.IReferenceSetManager; +import com.raytheon.viz.gfe.core.IReferenceSetManager.RefSetMode; +import com.raytheon.viz.gfe.core.internal.ReferenceSetManager; +import com.raytheon.viz.gfe.ui.AccessMgr; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; import com.raytheon.viz.ui.widgets.ToggleSelectList; @@ -62,6 +70,8 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList; * ------------ ---------- ----------- -------------------------- * Sep 10, 2010 randerso Initial creation * Oct 24, 2012 1287 rferrel Code clean up part of non-blocking dialog. + * Nov 18, 2015 5129 dgilling Code cleanup to support ReferenceSetManager changes. + * Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs. * * * @@ -328,17 +338,37 @@ public class SaveDeleteRefDialog extends CaveJFACEDialog { } private boolean deleteRef() { - // Note: Area will be deleted from all groups by - // UIReferenceSetMgr which processes deletions for - // incoming ReferenceSetInventoryChanged messages + /* + * Note: Area will be deleted from all groups by UIReferenceSetMgr which + * processes deletions for incoming ReferenceSetInventoryChanged + * messages + */ - ReferenceID id = new ReferenceID(this.identifier.getText()); - if (id.isValid() && !this.protectedSets.contains(id.getName()) - && this.sets.contains(id.getName())) { - // Check to see if deleting active reference set - // If so, clear the active reference set + ReferenceID id = new ReferenceID(identifier.getText()); + if ((id.isValid()) && (!protectedSets.contains(id.getName())) + && (sets.contains(id.getName()))) { + IPathManager pm = PathManagerFactory.getPathManager(); + LocalizationContext ctx = pm.getContext( + LocalizationType.COMMON_STATIC, LocalizationLevel.USER); + ILocalizationFile lf = pm.getLocalizationFile(ctx, + ReferenceSetManager.EDIT_AREAS_DIR + IPathManager.SEPARATOR + + id.getName() + ".xml"); + boolean verify = AccessMgr.verifyDelete(lf.getPath(), lf + .getContext().getLocalizationType(), false); + if (!verify) { + return false; + } + /* + * Check to see if deleting active reference set. If so, clear the + * active reference set + */ + ReferenceID activeId = refSetMgr.getActiveRefSet().getId(); + if (id.equals(activeId)) { + refSetMgr.incomingRefSet(refSetMgr.emptyRefSet(), + RefSetMode.REPLACE); + } // LogStream.logUse("Delete", this.lbox.name()) - return this.refSetMgr.deleteRefSet(id, true); + return refSetMgr.deleteRefSet(id); } else { String message = "Edit Area " + id.getName() diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteSampleSetDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteSampleSetDialog.java index bbb9b17e6c..988bea1e8c 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteSampleSetDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteSampleSetDialog.java @@ -39,11 +39,18 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import com.raytheon.uf.common.dataplugin.gfe.sample.SampleId; +import com.raytheon.uf.common.localization.ILocalizationFile; +import com.raytheon.uf.common.localization.IPathManager; +import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; +import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; +import com.raytheon.uf.common.localization.PathManagerFactory; 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.viz.gfe.core.ISampleSetManager; +import com.raytheon.viz.gfe.core.internal.SampleSetManager; +import com.raytheon.viz.gfe.ui.AccessMgr; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; /** @@ -56,6 +63,8 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * Mar 07, 2008 Eric Babin Initial Creation * Oct 24, 2012 1287 rferrel Code clean up for non-blocking dialog. * Sep 15, 2014 3592 randerso Re-implemented to match A1 + * Nov 19, 2014 5129 dgilling Support SampleSetManager changes. + * Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs. * * * @@ -224,10 +233,21 @@ public class SaveDeleteSampleSetDialog extends CaveJFACEDialog { private void deleteSample(String name) { SampleId id = new SampleId(name); - if (id.isValid() && !this.protectedSets.contains(name) - && this.sets.contains(name)) { + if ((id.isValid()) && (!protectedSets.contains(name)) + && (sets.contains(name))) { + IPathManager pm = PathManagerFactory.getPathManager(); + LocalizationContext ctx = pm.getContext( + LocalizationType.COMMON_STATIC, LocalizationLevel.USER); + ILocalizationFile lf = pm.getLocalizationFile(ctx, + SampleSetManager.SAMPLE_SETS_DIR + id.getName() + ".xml"); + boolean verify = AccessMgr.verifyDelete(lf.getPath(), lf + .getContext().getLocalizationType(), false); + if (!verify) { + return; + } + // LogStream.logUse("Delete", name); - this.sampleSetMgr.deleteSampleSet(id); + sampleSetMgr.deleteSampleSet(id); } else { String message = "Sample Set " + name + " is protected " + "or an invalid name. "; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteSelectTRDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteSelectTRDialog.java index 906cd408d1..7814e912c0 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteSelectTRDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteSelectTRDialog.java @@ -48,8 +48,7 @@ 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.SimulatedTime; -import com.raytheon.viz.gfe.GFEServerException; -import com.raytheon.viz.gfe.core.DataManager; +import com.raytheon.viz.gfe.core.ISelectTimeRangeManager; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; import com.raytheon.viz.ui.widgets.SpinScale; @@ -64,6 +63,7 @@ import com.raytheon.viz.ui.widgets.SpinScale; * Dec 7, 2009 randerso Initial creation * Aug 1, 2012 #965 dgilling Change location of SelectTimeRange. * Oct 25, 2012 #1287 rferrel Code cleanup part of non-blocking dialogs. + * Nov 18, 2015 #5129 dgilling Support new IFPClient. * * * @@ -75,12 +75,12 @@ public class SaveDeleteSelectTRDialog extends CaveJFACEDialog { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(SaveDeleteSelectTRDialog.class); - private DataManager dataManager; + private final ISelectTimeRangeManager selectTRMgr; + + private final TimeZone timeZone; private String optionStr; - private TimeZone timeZone; - private List ids = new ArrayList(); private List protectedIds = new ArrayList(); @@ -101,30 +101,23 @@ public class SaveDeleteSelectTRDialog extends CaveJFACEDialog { private boolean first = true; - public SaveDeleteSelectTRDialog(Shell parent, DataManager dataManager, - String optionStr) { + public SaveDeleteSelectTRDialog(Shell parent, + ISelectTimeRangeManager selectTRMgr, String optionStr) { super(parent); - this.dataManager = dataManager; + this.selectTRMgr = selectTRMgr; this.optionStr = optionStr; // Need to get them listed in order by time range - String[] names = dataManager.getSelectTimeRangeManager().inventory(); + String[] names = this.selectTRMgr.inventory(); - try { - timeZone = TimeZone.getTimeZone(dataManager.getClient() - .getDBGridLocation().getTimeZone()); - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, - "Error retrieving GFE time zone", e); - timeZone = TimeZone.getDefault(); - } + this.timeZone = this.selectTRMgr.getTimeZone(); if (optionStr.equals("Save")) { ids.addAll(Arrays.asList(names)); } else { for (String name : names) { - if (dataManager.getSelectTimeRangeManager().getRange(name) - .getLevel().equals(LocalizationLevel.USER)) { + if (this.selectTRMgr.getRange(name).getLevel() + .equals(LocalizationLevel.USER)) { ids.add(name); } else { protectedIds.add(name); @@ -317,8 +310,7 @@ public class SaveDeleteSelectTRDialog extends CaveJFACEDialog { String[] items = timeRangeList.getSelection(); for (String id : items) { if (optionStr.equals("Save")) { - SelectTimeRange range = dataManager.getSelectTimeRangeManager() - .getRange(id); + SelectTimeRange range = selectTRMgr.getRange(id); identifierField.setText(id); stopScale.setSelection(range.getEnd()); startScale.setSelection(range.getStart()); @@ -339,9 +331,8 @@ public class SaveDeleteSelectTRDialog extends CaveJFACEDialog { } else { mode = Mode.ZULU; } - dataManager.getSelectTimeRangeManager().save(id, - startScale.getSelection(), stopScale.getSelection(), - mode); + selectTRMgr.save(id, startScale.getSelection(), + stopScale.getSelection(), mode); super.okPressed(); } else { String message = "TimeRange " + id @@ -365,7 +356,7 @@ public class SaveDeleteSelectTRDialog extends CaveJFACEDialog { return; } - dataManager.getSelectTimeRangeManager().remove(id[0]); + selectTRMgr.remove(id[0]); super.okPressed(); } else { String message = "TimeRange " + id[0] diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ScriptNameInputDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ScriptNameInputDialog.java index b979dce414..8ae7055f57 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ScriptNameInputDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ScriptNameInputDialog.java @@ -30,11 +30,9 @@ import com.raytheon.uf.common.localization.LocalizationFile; 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.Activator; import com.raytheon.viz.gfe.GFEException; -import com.raytheon.viz.gfe.constants.StatusConstants; import com.raytheon.viz.gfe.core.script.ExistMode; -import com.raytheon.viz.gfe.core.script.IScriptUtil; +import com.raytheon.viz.gfe.core.script.PythonFileTemplate; /** * A dialog for the user to input the name of a script. @@ -43,9 +41,10 @@ import com.raytheon.viz.gfe.core.script.IScriptUtil; * */ public class ScriptNameInputDialog extends InputDialog { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(ScriptNameInputDialog.class); + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(ScriptNameInputDialog.class); - protected IScriptUtil util; + protected PythonFileTemplate util; protected ExistMode mode; @@ -63,10 +62,11 @@ public class ScriptNameInputDialog extends InputDialog { * @param validator * The validator to apply to the input field. This is called for * each character typed. + * @param util */ public ScriptNameInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue, - IInputValidator validator, IScriptUtil util) { + IInputValidator validator, PythonFileTemplate util) { super(parentShell, dialogTitle, dialogMessage, initialValue, validator); this.util = util; mode = ExistMode.NONE; @@ -89,8 +89,7 @@ public class ScriptNameInputDialog extends InputDialog { super.okPressed(); } } catch (GFEException e) { - statusHandler.handle(Priority.PROBLEM, - "Error validating name", e); + statusHandler.handle(Priority.PROBLEM, "Error validating name", e); } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/CallToActionsDlg.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/CallToActionsDlg.java index 41f729df1a..e98b5107ff 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/CallToActionsDlg.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/CallToActionsDlg.java @@ -22,7 +22,7 @@ package com.raytheon.viz.gfe.dialogs.formatterlauncher; import java.util.ArrayList; import java.util.List; -import org.apache.commons.lang.WordUtils; +import org.apache.commons.lang3.text.WordUtils; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/OutputLogComp.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/OutputLogComp.java index 9cb5d653f3..914df4fa78 100755 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/OutputLogComp.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/OutputLogComp.java @@ -52,6 +52,8 @@ import com.raytheon.viz.gfe.tasks.TaskManager; * ------------ ---------- ----------- -------------------------- * 18 APR 2008 ### lvenable Initial creation * 29 MAY 2014 #2841 randerso Fix NPE when formatter fails to queue + * 12 NOV 2015 #5106 dgilling Disable word-wrap to improve performance + * for large log files. * * * @@ -125,8 +127,7 @@ public class OutputLogComp extends Composite { private void initializeComponents() { GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); outputLogST = new StyledText(this, SWT.BORDER | SWT.MULTI - | SWT.V_SCROLL); - outputLogST.setWordWrap(true); + | SWT.V_SCROLL | SWT.H_SCROLL); outputLogST.setFont(textFont); outputLogST.setEditable(false); outputLogST.setLayoutData(gd); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/ProductEditorComp.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/ProductEditorComp.java index 7fecf3b170..44934afc53 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/ProductEditorComp.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/ProductEditorComp.java @@ -100,6 +100,7 @@ import com.raytheon.uf.common.jms.notification.INotificationObserver; import com.raytheon.uf.common.jms.notification.NotificationException; import com.raytheon.uf.common.jms.notification.NotificationMessage; import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -182,6 +183,9 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeOperations; * match the current time * 01/21/2016 18505 lshi Resent product should have same WMO, MND, and segment times * as original product. + * 02/05/2016 5242 dgilling Remove calls to deprecated Localization APIs. + * 02/10/2016 5337 dgilling Prevent CAN products past VTEC end time + * from being transmitted. * * * @author lvenable @@ -1529,10 +1533,11 @@ public class ProductEditorComp extends Composite implements throw new VizException(msg); } - // Give 30 minutes of slack to a couple of action codes - // check the ending time and transmission time - if ((action.equals("EXP") || action.equals("CAN")) - && (vtecEnd != null)) { + /* + * Give 30 minutes of slack for EXP action code, check the ending + * time and transmission time + */ + if ((action.equals("EXP")) && (vtecEnd != null)) { vtecEnd.setTime(vtecEnd.getTime() + (30 * TimeUtil.MILLIS_PER_MINUTE)); } @@ -2425,7 +2430,7 @@ public class ProductEditorComp extends Composite implements String product = null; try { product = readFile(file); - } catch (IOException ex) { + } catch (IOException | LocalizationException ex) { statusHandler.handle(Priority.PROBLEM, "Failed to load product " + pil, ex); return; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/isc/ISCRequestReplyDlg.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/isc/ISCRequestReplyDlg.java index 4aab706e08..4e6e14d96b 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/isc/ISCRequestReplyDlg.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/isc/ISCRequestReplyDlg.java @@ -19,11 +19,23 @@ **/ package com.raytheon.viz.gfe.dialogs.isc; +import java.io.StringWriter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -33,11 +45,14 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import com.raytheon.uf.common.dataplugin.gfe.request.IscRequestQueryRequest.IscQueryResponse; 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.viz.gfe.GFEServerException; import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; @@ -54,6 +69,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Oct 24. 2008 1287 rferrel Made dialog non-blocking. * Dec 28, 2012 DR15587 jzeng Query weather elements from fcst DB * Aug 14, 2015 4750 dgilling Remove broken query. + * Nov 30, 2015 5129 dgilling Support new IFPClient. * * * @@ -65,6 +81,8 @@ public class ISCRequestReplyDlg extends CaveSWTDialog { private final transient IUFStatusHandler statusHandler = UFStatus .getHandler(ISCRequestReplyDlg.class); + private final DataManager dataManager; + private ListManager domainList; private ListManager gridSrcList; @@ -73,16 +91,12 @@ public class ISCRequestReplyDlg extends CaveSWTDialog { private Label gridSrcLbl; - private DataManager dataMgr; - private List weList; private Map>>> domainDict; private Map> serverDictT2S; - private String xml; - private boolean iscAvailable; /** @@ -91,12 +105,12 @@ public class ISCRequestReplyDlg extends CaveSWTDialog { * @param parent * Parent shell. */ - public ISCRequestReplyDlg(Shell parent) { + public ISCRequestReplyDlg(DataManager dataManager, Shell parent) { super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.DO_NOT_BLOCK); setText("ISC Request/Reply"); - dataMgr = DataManager.getCurrentInstance(); - iscAvailable = dataMgr.requestISC(); + this.dataManager = dataManager; + this.iscAvailable = this.dataManager.requestISC(); } @Override @@ -220,30 +234,30 @@ public class ISCRequestReplyDlg extends CaveSWTDialog { sepLbl.setLayoutData(gd); } - @SuppressWarnings("unchecked") private void initializeData() { - Object[] response = dataMgr.doIscRequestQuery(); - this.xml = (String) response[0]; - this.weList = (List) response[1]; - Collections.sort(this.weList); + IscQueryResponse response = dataManager.doIscRequestQuery(); - domainDict = (Map>>>) response[2]; - serverDictT2S = (Map>) response[4]; + weList = new ArrayList<>(response.getRequestedParms()); + Collections.sort(weList); + + domainDict = response.getDomainDict(); + serverDictT2S = response.getServerDictT2S(); // output the list of servers and their priority - String s = "\n"; - for (String key : this.domainDict.keySet()) { - s += "DOMAIN=" + key + "\n"; - ArrayList> servers = (ArrayList>) this.domainDict + StringBuilder s = new StringBuilder("\n"); + for (String key : domainDict.keySet()) { + s.append("DOMAIN=").append(key).append('\n'); + List> servers = (List>) domainDict .get(key); for (Map server : servers) { - s += " mhs=" + server.get("mhsid") + " host=" - + server.get("host") + " port=" + server.get("port") - + "\n"; + s.append(" mhs=").append(server.get("mhsid")).append(" host=") + .append(server.get("host")).append(" port=") + .append(server.get("port")).append('\n'); } } - statusHandler.info("DomainDict servers:" + s); + statusHandler.handle(Priority.EVENTB, + "DomainDict servers:" + s.toString()); } private void populateDomainList() { @@ -260,37 +274,166 @@ public class ISCRequestReplyDlg extends CaveSWTDialog { private void populateWEList() { this.weatherElemList.clearList(); - this.weatherElemList.addItemToList(weList.toArray(new String[] {})); + this.weatherElemList.addItemToList(weList.toArray(new String[0])); this.weatherElemList.selectAll(); this.weatherElemList.deselectAll(); } public void makeRequest() { if (iscAvailable) { - try { - List weatherElements = null; - if (this.domainList.getSelectedItems().isEmpty()) { - statusHandler.handle(Priority.PROBLEM, - "No Domain has been selected"); - return; - } - if (this.gridSrcList.getSelectedItems().isEmpty()) { - statusHandler.handle(Priority.PROBLEM, - "No Grid Source has been selected"); - return; - } - if (this.weatherElemList.getSelectedItems().isEmpty()) { - weatherElements = this.weatherElemList.getItems(); - } else { - weatherElements = this.weatherElemList.getSelectedItems(); - } - String response = dataMgr.getClient().iscGetRequestXML(xml, - this.gridSrcList.getSelectedItems(), weatherElements); - dataMgr.makeISCRequest(response); - } catch (GFEServerException e) { + List weatherElements = null; + if (domainList.getSelectedItems().isEmpty()) { statusHandler.handle(Priority.PROBLEM, - "Server Problem: Error making request", e); + "No Domain has been selected"); + return; } + + List selectedServers = gridSrcList.getSelectedItems(); + if (selectedServers.isEmpty()) { + statusHandler.handle(Priority.PROBLEM, + "No Grid Source has been selected"); + return; + } + if (weatherElemList.getSelectedItems().isEmpty()) { + weatherElements = weatherElemList.getItems(); + } else { + weatherElements = weatherElemList.getSelectedItems(); + } + + Document doc = null; + try { + doc = IrtAccess.getIscRequestXML(selectedServers, + weatherElements, serverDictT2S); + } catch (DOMException | ParserConfigurationException e) { + statusHandler.error( + "Unable to create XML document for request.", e); + return; + } + + // output the list of servers and their priority + StringBuilder s = new StringBuilder("\n"); + for (String key : domainDict.keySet()) { + s.append("DOMAIN=").append(key).append('\n'); + for (String serverT : selectedServers) { + Map server = serverDictT2S.get(serverT); + if (key.equals(server.get("site"))) { + s.append(" mhs=").append(server.get("mhsid")) + .append(" host=").append(server.get("host")) + .append(" port=").append(server.get("port")) + .append('\n'); + } + } + } + statusHandler.handle(Priority.EVENTB, + "Chosen request servers:" + s.toString()); + + // send to ifpServer + String xmlreq = StringUtils.EMPTY; + try { + xmlreq = IrtAccess.convertXMLToString(doc); + } catch (TransformerException e) { + statusHandler.error( + "Unable to write XML document for request.", e); + return; + } + + dataManager.makeISCRequest(xmlreq); + } + } + + private static class IrtAccess { + + private IrtAccess() { + throw new AssertionError(); + } + + public static Document getIscRequestXML(List selectedServers, + List weatherElements, + Map> serverDictT2S) + throws DOMException, ParserConfigurationException { + DocumentBuilderFactory factory = DocumentBuilderFactory + .newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + + Document doc = builder.newDocument(); + Element iscReqE = doc.createElement("iscrequest"); + doc.appendChild(iscReqE); + List> destinations = new ArrayList<>(); + for (String serverT : selectedServers) { + Map server = serverDictT2S.get(serverT); + destinations.add(server); + } + addDestinationXML(iscReqE, destinations); + Element welistE = doc.createElement("welist"); + iscReqE.appendChild(welistE); + for (String we : weatherElements) { + Element weE = doc.createElement("parm"); + weE.appendChild(doc.createTextNode(we)); + welistE.appendChild(weE); + } + + return doc; + } + + public static String convertXMLToString(Document doc) + throws TransformerException { + TransformerFactory tFactory = TransformerFactory.newInstance(); + Transformer transformer = tFactory.newTransformer(); + + DOMSource source = new DOMSource(doc); + StringWriter writer = new StringWriter(); + StreamResult result = new StreamResult(writer); + transformer.transform(source, result); + return writer.getBuffer().toString(); + } + + private static Element addDestinationXML(Element root, + List> serverInfos) { + Element destinationsE = root.getOwnerDocument().createElement( + "destinations"); + root.appendChild(destinationsE); + for (Map serverInfo : serverInfos) { + addAddressXML(destinationsE, serverInfo); + } + return destinationsE; + } + + private static Element addAddressXML(Element root, + Map serverInfo) { + Element addressE = root.getOwnerDocument().createElement("address"); + root.appendChild(addressE); + + Element mhsidE = root.getOwnerDocument().createElement("mhsid"); + String mhsidText = MapUtils.getString(serverInfo, "mhsid", "?"); + mhsidE.appendChild(root.getOwnerDocument() + .createTextNode(mhsidText)); + addressE.appendChild(mhsidE); + + Element serverE = root.getOwnerDocument().createElement("server"); + String serverText = MapUtils.getString(serverInfo, "host", "?"); + serverE.appendChild(root.getOwnerDocument().createTextNode( + serverText)); + addressE.appendChild(serverE); + + Element portE = root.getOwnerDocument().createElement("port"); + String portText = MapUtils.getString(serverInfo, "port", "?"); + portE.appendChild(root.getOwnerDocument().createTextNode(portText)); + addressE.appendChild(portE); + + Element protocolE = root.getOwnerDocument().createElement( + "protocol"); + String protocolText = MapUtils.getString(serverInfo, "protocol", + "?"); + protocolE.appendChild(root.getOwnerDocument().createTextNode( + protocolText)); + addressE.appendChild(protocolE); + + Element siteE = root.getOwnerDocument().createElement("site"); + String siteText = MapUtils.getString(serverInfo, "site", "?"); + siteE.appendChild(root.getOwnerDocument().createTextNode(siteText)); + addressE.appendChild(siteE); + + return addressE; } } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/ServiceBackupDlg.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/ServiceBackupDlg.java index e6697c37e6..3e2ce9898e 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/ServiceBackupDlg.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/ServiceBackupDlg.java @@ -33,7 +33,7 @@ import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.eclipse.core.runtime.FileLocator; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.SWT; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/PencilTool.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/PencilTool.java index b2e6e24bac..c29e316e28 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/PencilTool.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/PencilTool.java @@ -59,6 +59,8 @@ import com.vividsolutions.jts.geom.Coordinate; * ------------ ---------- ----------- -------------------------- * 05/01/2008 chammack Added Pencil Influence * 04/16/2009 2262 rjpeter Updated to handle mouse movements off the extent + * 01/28/2016 5295 dgilling Fix handling of ISC grids with different + * time constraints from Fcst grid. * * * @author chammack @@ -136,8 +138,8 @@ public class PencilTool extends AbstractFreeformTool { // isc mode, and fcst grid if (iscMode && fcstGrid) { - GridID gid = new GridID(grid.getParm(), grid.getGridTime() - .getStart()); + GridID gid = new GridID(grid.getParm(), dataManager + .getSpatialDisplayManager().getSpatialEditorTime()); return iscDataPoint(gid, new Point((int) gridCoord.x, (int) gridCoord.y)); } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/makehazard/MakeHazardDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/makehazard/MakeHazardDialog.java index 98f3813fd5..001f500b22 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/makehazard/MakeHazardDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/makehazard/MakeHazardDialog.java @@ -39,8 +39,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; @@ -53,7 +51,6 @@ import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; @@ -85,6 +82,7 @@ import com.raytheon.uf.common.time.TimeRange; import com.raytheon.uf.viz.core.RGBColors; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.zoneselector.AbstractZoneSelector.IZoneSelectionListener; import com.raytheon.viz.core.mode.CAVEMode; import com.raytheon.viz.gfe.Activator; import com.raytheon.viz.gfe.PythonPreferenceStore; @@ -96,29 +94,30 @@ import com.raytheon.viz.gfe.core.griddata.IGridData; import com.raytheon.viz.gfe.core.parm.Parm; import com.raytheon.viz.gfe.product.TextDBUtil; import com.raytheon.viz.gfe.ui.zoneselector.ZoneSelector; -import com.raytheon.viz.gfe.ui.zoneselector.ZoneSelector.IZoneSelectionListener; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.statusline.StatusMessage.Importance; import com.raytheon.viz.ui.statusline.StatusStore; /** * Make Hazard Dialog - * + * *
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer     Description
  * ------------ ---------- -----------  --------------------------
- * 	Jun 5, 2008				Eric Babin  Initial Creation
- *  Sep 27,2010 5813        gzhou       get etn from param pattern hazXXXnnn
- *  Feb 28,2012 14436		mli		    Add RP.S - Rip Current
- *  Apr 03,2012 436         randerso    Reworked dialog to be called by Python MakeHazard procedure
- *  Apr 09,2012 436         randerso    Merged RNK's MakeHazards_Elevation procedure
- *  May 30,2012 2028        randerso    Cleaned up dialog layout
- *  Nov 13,2014 646         lshi        Fixed hard coded endTimeSlider's Max value
- *  Jul 30,2015 17770       lshi        Add handling for AT, EP, CP and WP basins
- *
+ * Jun 05, 2008            Eric Babin   Initial Creation
+ * Sep 27, 2010 5813       gzhou        get etn from param pattern hazXXXnnn
+ * Feb 28, 2012 14436      mli          Add RP.S - Rip Current
+ * Apr 03, 2012 436        randerso     Reworked dialog to be called by Python MakeHazard procedure
+ * Apr 09, 2012 436        randerso     Merged RNK's MakeHazards_Elevation procedure
+ * May 30, 2012 2028       randerso     Cleaned up dialog layout
+ * Nov 13, 2014 646        lshi         Fixed hard coded endTimeSlider's Max value
+ * Jul 30, 2015 17770      lshi         Add handling for AT, EP, CP and WP basins
+ * Jan 14, 2016 5239       randerso     Fixed Zones included/not included labels not always visible
+ * Feb 05, 2016 5316       randerso     Moved AbstractZoneSelector to separate project
+ * 
  * 
- * + * * @author ebabin * @version 1.0 */ @@ -130,8 +129,6 @@ public class MakeHazardDialog extends CaveSWTDialog implements private static final String DEFAULT_MAP_COLOR = "red"; - private static final int LEGEND_HEIGHT = 16; - private static final double DEFAULT_AREA_THRESHOLD = 0.10; private static final String ZONES_MSG = "USING MAP SELECTIONS"; @@ -167,7 +164,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements /** * Used by hazard start and end Time. - * + * */ private int toHours = 96; @@ -220,10 +217,6 @@ public class MakeHazardDialog extends CaveSWTDialog implements private Composite topComp; - private Canvas excluded; - - private Canvas included; - private Map comboDict; private String currentHazardType; @@ -234,13 +227,13 @@ public class MakeHazardDialog extends CaveSWTDialog implements private org.eclipse.swt.widgets.List hazardGroupList; - private static final String[] WMO_TITLES = { - "NATIONAL HURRICANE CENTER", //NHC - "NATIONAL WEATHER SERVICE TIYAN", //GUM - "CENTRAL PACIFIC HURRICANE CENTER" //CPHC + private static final String[] WMO_TITLES = { "NATIONAL HURRICANE CENTER", // NHC + "NATIONAL WEATHER SERVICE TIYAN", // GUM + "CENTRAL PACIFIC HURRICANE CENTER" // CPHC }; - private static final Map BASINS = ImmutableMap.of("AT", "10", "EP", "20", "CP", "30", "WP", "40"); + private static final Map BASINS = ImmutableMap.of("AT", + "10", "EP", "20", "CP", "30", "WP", "40"); public MakeHazardDialog(Shell parent, DataManager dataManager, String colorName, int defaultMapWidth, int timeScaleEndTime, @@ -372,13 +365,13 @@ public class MakeHazardDialog extends CaveSWTDialog implements TimeRange timeRange = null; Parm parm = null; String parmName = null; - if (parms != null && parms.length == 1) { + if ((parms != null) && (parms.length == 1)) { parm = parms[0]; parmName = parm.getParmID().getParmName(); } // Check for an ETN or segment # - if (parmName != null && parmName.startsWith("haz")) { + if ((parmName != null) && parmName.startsWith("haz")) { // DR 5813 // parmName example: hazXXXnnn @@ -387,7 +380,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements while (Character.isDigit(parmName.charAt(--index))) { } - if (index < parmName.length() - 1) { + if (index < (parmName.length() - 1)) { String etn = parmName.substring(index + 1); if (Integer.parseInt(etn) > 0) { this.etnSegNumberField.setText(etn); @@ -397,7 +390,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements timeRange = determineTimeRange(parm); - if (parmName == null || !parmName.startsWith("haz")) { + if ((parmName == null) || !parmName.startsWith("haz")) { setTRSliders(timeRange); return; } @@ -405,7 +398,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements IGridData[] grids = null; if (timeRange != null) { grids = parm.getGridInventory(timeRange); - if (grids == null || grids.length != 1) { + if ((grids == null) || (grids.length != 1)) { timeRange = null; } else { timeRange = grids[0].getGridTime(); @@ -455,10 +448,10 @@ public class MakeHazardDialog extends CaveSWTDialog implements updateTime(startHour, startTimeLabel); int endHour = (int) (endLong - zeroLong) / (60 * 60 * 1000); - if (endHour < startHour + 1) { + if (endHour < (startHour + 1)) { endHour = startHour + 1; } - if (endHour > toHours + 1) { + if (endHour > (toHours + 1)) { statusHandler.handle(Priority.VERBOSE, "Hazard end time is beyond date slider limit"); endHour = toHours + 1; @@ -475,7 +468,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements * preview() process. Currently, we don't implement preview(), but we * probably will at some point in the future. When we do, we can get rid of * this method and let preview() do this for us like AWIPS I did. - * + * * @param parm * @return */ @@ -484,7 +477,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements .getSpatialEditorTime(); TimeRange timeRange = dataManager.getParmOp().getSelectionTimeRange(); - if (timeRange != null && timeRange.isValid()) { + if ((timeRange != null) && timeRange.isValid()) { if (!timeRange.contains(seTime)) { statusHandler .handle(Priority.PROBLEM, @@ -495,7 +488,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements timeRange = null; if (parm != null) { timeRange = parm.getParmState().getSelectedTimeRange(); - if (timeRange != null && !timeRange.isValid()) { + if ((timeRange != null) && !timeRange.isValid()) { timeRange = null; } } @@ -508,9 +501,9 @@ public class MakeHazardDialog extends CaveSWTDialog implements } } - if (timeRange != null && parm != null) { + if ((timeRange != null) && (parm != null)) { IGridData[] grids = parm.getGridInventory(timeRange); - if (grids != null && grids.length > 1) { + if ((grids != null) && (grids.length > 1)) { // There should be a yes/no dialog pop up... } } @@ -522,7 +515,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements * Figure out the hazard type (i.e., "Winter Weather") and db tables to use, * based on phen_sig. The same phensig sometimes appears in multiple hazard * types, so pick the one that draws from the most db tables. - * + * * @param phen_sig */ protected void pickDefaultCategory(String phen_sig) { @@ -531,11 +524,11 @@ public class MakeHazardDialog extends CaveSWTDialog implements Map> hazDict = getHazardsDictionary(); for (Map.Entry> entry : hazDict.entrySet()) { List phenSigsForType = entry.getValue(); - if (phenSigsForType != null && phenSigsForType.contains(phen_sig)) { + if ((phenSigsForType != null) && phenSigsForType.contains(phen_sig)) { String entryHazardType = entry.getKey(); List entryHazTables = mapNames.get(entryHazardType); - if (hazTables == null - || hazTables.size() < entryHazTables.size()) { + if ((hazTables == null) + || (hazTables.size() < entryHazTables.size())) { hazardType = entryHazardType; hazTables = entryHazTables; } @@ -578,7 +571,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements * Create the hazard in response to the run or run/dismiss button. Indicate * whether the run succeeded so run/dismiss knows whether it's OK to close * the dialog. - * + * * @return true if the hazard was created, false otherwise. */ private boolean doRunInternal(boolean dismiss) { @@ -698,7 +691,8 @@ public class MakeHazardDialog extends CaveSWTDialog implements if (baseEtnCode != null) { nationalBase = baseEtnCode; } else { - statusHandler.warn("Undefined basin ID: " + baseETN + ", defaulting to AT"); + statusHandler.warn("Undefined basin ID: " + baseETN + + ", defaulting to AT"); } String stormNum = altFileName.substring(2, 4); tropicalETN = nationalBase + stormNum; @@ -869,37 +863,33 @@ public class MakeHazardDialog extends CaveSWTDialog implements showMapLabelsButton.setText("Map Labels"); comp = new Composite(buttonComp, SWT.NONE); - layout = new GridLayout(1, false); + layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginWidth = 0; comp.setLayout(layout); - layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + layoutData = new GridData(SWT.RIGHT, SWT.FILL, true, true); comp.setLayoutData(layoutData); - excluded = new Canvas(comp, SWT.NONE); - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.heightHint = LEGEND_HEIGHT; - excluded.setLayoutData(gd); - excluded.addPaintListener(new PaintListener() { + GC gc = new GC(getDisplay()); + int height = gc.getFontMetrics().getHeight(); + gc.dispose(); - @Override - public void paintControl(PaintEvent e) { - paintLegend(e.gc, zoneSelector.getNoZoneColor(), - "Zones not included"); - } - }); + Label label = new Label(comp, SWT.NONE); + label.setBackground(new Color(getDisplay(), zoneSelector + .getNoZoneColor())); + gd = new GridData(height, height); + label.setLayoutData(gd); - included = new Canvas(comp, SWT.NONE); - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.heightHint = 16; - included.setLayoutData(gd); - included.addPaintListener(new PaintListener() { + label = new Label(comp, SWT.NONE); + label.setText("Zones not included"); - @Override - public void paintControl(PaintEvent e) { - paintLegend(e.gc, mapColor, "Zones included"); - } - }); + label = new Label(comp, SWT.NONE); + label.setBackground(new Color(getDisplay(), mapColor)); + gd = new GridData(height, height); + label.setLayoutData(gd); + + label = new Label(comp, SWT.NONE); + label.setText("Zones included"); showMapLabelsButton.addSelectionListener(new SelectionAdapter() { @Override @@ -961,21 +951,6 @@ public class MakeHazardDialog extends CaveSWTDialog implements usingLabel.setText(EDIT_AREA_MSG); } - private void paintLegend(GC gc, RGB color, String text) { - Color bg = new Color(getDisplay(), color); - gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WHITE)); - gc.setBackground(bg); - int height = gc.getFontMetrics().getHeight(); - gc.fillRectangle(height, 0, height, height); - gc.drawRectangle(height, 0, height, height); - - gc.setBackground(CAVEMode.getBackgroundColor()); - gc.setForeground(CAVEMode.getForegroundColor()); - gc.drawText(text, height * 2 - + gc.getFontMetrics().getAverageCharWidth(), 0); - bg.dispose(); - } - private void createSelectHazardComponent(Composite hazardComp) { GridLayout gl = new GridLayout(2, false); gl.marginHeight = 0; @@ -998,7 +973,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements selectedHazardList = new org.eclipse.swt.widgets.List(hazardGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.heightHint = selectedHazardList.getItemHeight() * 16 + gd.heightHint = (selectedHazardList.getItemHeight() * 16) + selectedHazardList.getBorderWidth(); selectedHazardList.setLayoutData(gd); @@ -1035,8 +1010,8 @@ public class MakeHazardDialog extends CaveSWTDialog implements hazardGroupList = new org.eclipse.swt.widgets.List(hazardTypeGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.heightHint = hazardGroupList.getItemHeight() - * Math.min(12, groups.size()) + gd.heightHint = (hazardGroupList.getItemHeight() * Math.min(12, + groups.size())) + hazardGroupList.getBorderWidth(); hazardGroupList.setLayoutData(gd); hazardGroupList.addSelectionListener(selAdapt); @@ -1133,7 +1108,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements * Event handler for when the user moves the slider. This updates * the slider label and changes the end time slider if the end time * is before the start time. - * + * * @param e * The event that caused this handler to be called. */ @@ -1181,7 +1156,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements gd.minimumWidth = 200; endTimeSlider.setLayoutData(gd); - toHours = this.timeScaleEndTime; //#646 + toHours = this.timeScaleEndTime; // #646 endTimeSlider.setMinimum(1); endTimeSlider.setMaximum(toHours + 1); endTimeSlider.setIncrement(1); @@ -1198,7 +1173,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements * Event handler for when the user moves the slider. This updates * the slider label and changes the start time slider if the end * time is before the start time. - * + * * @param e * The event that caused this handler to be called. */ @@ -1315,7 +1290,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements * Add selection hours to hazardStartTime (that * is, the default starting time), and set the text of label to * the result, formatted by dateFormatter. - * + * * @param selection * The integer slider value selected by the user. * @param label @@ -1348,7 +1323,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements * Set the hazard type in the radio button control. If the hazard type is * changed, the radio button selection listener will fire, changing and * clearing selectedHazardList as a side effect. - * + * * @param hazardType * the hazard type to select. */ @@ -1368,7 +1343,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements if (laData != null) { String label = eaName; String display = (String) laData.get(1); - if (display != null && !display.isEmpty()) { + if ((display != null) && !display.isEmpty()) { label = display; } leCombo.add(label); @@ -1397,12 +1372,12 @@ public class MakeHazardDialog extends CaveSWTDialog implements * Set the selection in selectedHazardList to the first item that starts * with phen_sig. If phen_sig is null or an empty string, clears all * selections. - * + * * @param phen_sig * The phen_sig to select */ public void setHazard(String phen_sig) { - if (phen_sig == null || phen_sig.length() == 0) { + if ((phen_sig == null) || (phen_sig.length() == 0)) { selectedHazardList.deselectAll(); return; } @@ -1443,7 +1418,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements @SuppressWarnings("unchecked") List zoneList = (List) laData.get(2); - if (zoneList != null && !zoneList.isEmpty()) { + if ((zoneList != null) && !zoneList.isEmpty()) { Map comboDict = new HashMap( zoneList.size()); for (String z : zoneList) { @@ -1481,7 +1456,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements List zoneIdsToShow = getAreaList(grid2DBit); // Select the zones - if (zoneIdsToShow != null && zoneIdsToShow.size() > 0) { + if ((zoneIdsToShow != null) && (zoneIdsToShow.size() > 0)) { usingLabel.setText(ZONES_MSG); for (String z : zoneIdsToShow) { this.comboDict.put(z, 1); @@ -1500,7 +1475,7 @@ public class MakeHazardDialog extends CaveSWTDialog implements /* * (non-Javadoc) - * + * * @see * com.raytheon.viz.gfe.ui.zoneselector.ZoneSelector.IZoneSelectionListener * #zonesSelected() diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureFactory.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureFactory.java index 7050b39f34..3429eac9da 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureFactory.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureFactory.java @@ -26,7 +26,7 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.python.PyUtil; import com.raytheon.uf.common.python.PythonIncludePathUtil; -import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory; +import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory; import com.raytheon.uf.common.util.FileUtil; import com.raytheon.viz.gfe.core.DataManager; @@ -41,21 +41,22 @@ import com.raytheon.viz.gfe.core.DataManager; * Feb 25, 2010 4108 ryu Add user/site directories to include path * May 20, 2015 4509 njensen Added time and dataaccess to include path * Jul 27, 2015 #4263 dgilling Refactor and make abstract. + * Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API. * * * + * `1 + * * @author njensen * @version 1.0 */ -public abstract class ProcedureFactory extends - AbstractPythonScriptFactory { +public abstract class ProcedureFactory + implements PythonInterpreterFactory { protected final DataManager dataMgr; - public ProcedureFactory(String name, int numThreads, - final DataManager dataMgr) { - super(name, numThreads); + public ProcedureFactory(final DataManager dataMgr) { this.dataMgr = dataMgr; } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureMetadataManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureMetadataManager.java index 0d392d3acf..f78fe3b68e 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureMetadataManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureMetadataManager.java @@ -53,6 +53,7 @@ import com.raytheon.viz.gfe.smartscript.FieldDefinition; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jul 24, 2015 #4263 dgilling Initial creation + * Dec 14, 2015 #4816 dgilling Support refactored PythonJobCoordinator API. * * * @@ -66,6 +67,10 @@ public final class ProcedureMetadataManager implements private final IUFStatusHandler statusHandler = UFStatus .getHandler(getClass()); + private static final String THREAD_POOL_NAME = "procedure-metadata"; + + private static final int NUM_POOL_THREADS = 1; + private final PythonJobCoordinator jobCoordinator; private final Map metadata; @@ -79,7 +84,8 @@ public final class ProcedureMetadataManager implements public ProcedureMetadataManager(final DataManager dataMgr) { ProcedureMetadataScriptFactory scriptFactory = new ProcedureMetadataScriptFactory( dataMgr); - this.jobCoordinator = PythonJobCoordinator.newInstance(scriptFactory); + this.jobCoordinator = new PythonJobCoordinator<>(NUM_POOL_THREADS, + THREAD_POOL_NAME, scriptFactory); this.metadata = new HashMap<>(); this.accessLock = new Object(); @@ -109,7 +115,7 @@ public final class ProcedureMetadataManager implements } }; try { - jobCoordinator.submitAsyncJob(executor, listener); + jobCoordinator.submitJobWithCallback(executor, listener); } catch (Exception e1) { statusHandler.error("Error initializing procedure metadata.", e1); } @@ -199,7 +205,7 @@ public final class ProcedureMetadataManager implements } }; try { - jobCoordinator.submitAsyncJob(executor, listener); + jobCoordinator.submitJobWithCallback(executor, listener); } catch (Exception e1) { statusHandler.error("Error updating procedure metadata.", e1); } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureMetadataScriptFactory.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureMetadataScriptFactory.java index 881673ab48..240aabe8ef 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureMetadataScriptFactory.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureMetadataScriptFactory.java @@ -33,6 +33,7 @@ import com.raytheon.viz.gfe.core.DataManager; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jul 24, 2015 #4263 dgilling Initial creation + * Dec 14, 2015 #4816 dgilling Support refactored PythonJobCoordinator API. * * * @@ -43,21 +44,10 @@ import com.raytheon.viz.gfe.core.DataManager; public final class ProcedureMetadataScriptFactory extends ProcedureFactory { - private static final String SCRIPT_EXECUTOR_NAME = "procedure-metadata"; - - private static final int EXECUTOR_NUM_THREADS = 1; - public ProcedureMetadataScriptFactory(final DataManager dataMgr) { - super(SCRIPT_EXECUTOR_NAME, EXECUTOR_NUM_THREADS, dataMgr); + super(dataMgr); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory# - * createPythonScript() - */ @Override public ProcedureMetadataController createPythonScript() throws JepException { return new ProcedureMetadataController(buildScriptPath(), diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureRunnerScriptFactory.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureRunnerScriptFactory.java index dbde3c6590..a7271861b6 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureRunnerScriptFactory.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureRunnerScriptFactory.java @@ -33,6 +33,7 @@ import com.raytheon.viz.gfe.core.DataManager; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jul 25, 2015 #4263 dgilling Initial creation + * Dec 14, 2015 #4816 dgilling Support refactored PythonJobCoordinator API. * * * @@ -43,17 +44,8 @@ import com.raytheon.viz.gfe.core.DataManager; public final class ProcedureRunnerScriptFactory extends ProcedureFactory { - /* - * These constants that are passed to the super constructor only matter if - * procedure execution gets hooked into our python concurrent execution - * framework. Since it isn't we use dummy values for now... - */ - private static final String SCRIPT_EXECUTOR_NAME = "procedure-runner"; - - private static final int EXECUTOR_NUM_THREADS = 0; - public ProcedureRunnerScriptFactory(final DataManager dataMgr) { - super(SCRIPT_EXECUTOR_NAME, EXECUTOR_NUM_THREADS, dataMgr); + super(dataMgr); } /* diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProceduresAdapter.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProceduresAdapter.java index 5f0cc8a81a..67ef145baa 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProceduresAdapter.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProceduresAdapter.java @@ -23,7 +23,7 @@ import org.eclipse.jface.action.IMenuManager; import com.raytheon.uf.viz.localization.adapter.LocalizationPerspectiveAdapter; import com.raytheon.uf.viz.localization.filetreeview.FileTreeEntryData; -import com.raytheon.viz.gfe.core.script.IScriptUtil; +import com.raytheon.viz.gfe.core.script.PythonFileTemplate; import com.raytheon.viz.gfe.core.script.action.NewAction; import com.raytheon.viz.gfe.procedures.util.ProcedureUtil; @@ -55,7 +55,7 @@ public class ProceduresAdapter extends LocalizationPerspectiveAdapter { @Override public boolean addContextMenuItems(IMenuManager menuMgr, FileTreeEntryData[] selectedData) { - IScriptUtil util = new ProcedureUtil(); + PythonFileTemplate util = new ProcedureUtil(); NewAction newAction = new NewAction(util); menuMgr.add(newAction); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/util/ProcedureUtil.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/util/ProcedureUtil.java index 2873dfcaae..740dfc5389 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/util/ProcedureUtil.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/util/ProcedureUtil.java @@ -26,7 +26,18 @@ import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil; import com.raytheon.viz.gfe.core.script.AbstractScriptUtil; /** - * A concrete implementation of IScriptUtil for working with Procedure scripts. + * An implementation of PythonFileTemplate for making new Procedures. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * ???                     wldougher   Initial creation
+ * Jan 19, 2016  4834      njensen     Removed dead method
+ *
+ * 
* * @author wldougher * @@ -44,39 +55,19 @@ public class ProcedureUtil extends AbstractScriptUtil { super(); } - /** - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#getScriptType() - */ @Override public String getScriptType() { return scriptType; } - /** - * @see com.raytheon.viz.gfe.core.script.AbstractScriptUtil#getScriptTypePathPrefix - * () - */ @Override public String getScriptTypePathPrefix() { return GfePyIncludeUtil.PROCEDURES; } - /** - * @see com.raytheon.viz.gfe.core.script.AbstractScriptUtil#getVelocityTemplateName - * () - */ @Override protected String getVelocityTemplateName() { return TEMPLATE_FILENAME; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#getFileType() - */ - @Override - public String getFileType() { - return "PROCEDURE"; - } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/product/ProductFileUtil.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/product/ProductFileUtil.java index 00a3851eb4..82b7a381f6 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/product/ProductFileUtil.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/product/ProductFileUtil.java @@ -22,10 +22,14 @@ package com.raytheon.viz.gfe.product; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; import java.io.Writer; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; @@ -35,8 +39,10 @@ import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.LocalizationUtil; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; +import com.raytheon.uf.common.localization.SaveableOutputStream; +import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.time.SimulatedTime; import com.raytheon.uf.common.util.FileUtil; import com.raytheon.viz.core.mode.CAVEMode; @@ -49,6 +55,8 @@ import com.raytheon.viz.core.mode.CAVEMode; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 11 Feb 2010 4132 ryu Initial creation + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs. * * * @@ -101,7 +109,7 @@ public class ProductFileUtil { ArrayList names = new ArrayList(); String regex = "2\\d{7}_\\d{6}_" + pil; for (LocalizationFile f : files) { - String fname = f.getFile().getName(); + String fname = LocalizationUtil.extractName(f.getPath()); if (fname.matches(regex)) { names.add(fname); } @@ -132,54 +140,56 @@ public class ProductFileUtil { } static public void writeFile(String text, File file) throws IOException { - if (!file.exists()) { - if (file.getParentFile() != null) { - file.getParentFile().mkdirs(); - } - } + Path filePath = file.toPath(); + Files.createDirectories(filePath); - Writer out = null; - try { - out = new BufferedWriter(new FileWriter(file)); - out.write(text); - } finally { - if (out != null) { - out.close(); - } + try (Writer out = Files.newBufferedWriter(filePath, + StandardCharsets.UTF_8)) { + writeFile(text, out); } } static public String readFile(File file) throws IOException { - StringBuilder builder = new StringBuilder(); - BufferedReader in = null; - try { - in = new BufferedReader(new FileReader(file)); - String line; - while ((line = in.readLine()) != null) { - builder.append(line); - builder.append(System.getProperty("line.separator")); - } - } finally { - if (in != null) { - in.close(); - } + try (BufferedReader in = Files.newBufferedReader(file.toPath(), + StandardCharsets.UTF_8)) { + return readFile(in); } - - return builder.toString(); } static public void writeFile(String text, LocalizationFile localizationFile) - throws IOException, LocalizationOpFailedException { - File file = localizationFile.getFile(); - writeFile(text, file); - - localizationFile.save(); + throws IOException, LocalizationException { + try (SaveableOutputStream outStream = localizationFile + .openOutputStream(); + Writer out = new BufferedWriter(new OutputStreamWriter( + outStream))) { + writeFile(text, out); + out.close(); + outStream.save(); + } } static public String readFile(LocalizationFile localizationFile) - throws IOException { - File file = localizationFile.getFile(); - return readFile(file); + throws IOException, LocalizationException { + try (InputStream inStream = localizationFile.openInputStream(); + BufferedReader in = new BufferedReader(new InputStreamReader( + inStream))) { + return readFile(in); + } } + private static String readFile(BufferedReader reader) throws IOException { + StringBuilder contents = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + contents.append(line); + contents.append(System.getProperty("line.separator")); + } + + return contents.toString(); + } + + private static void writeFile(String text, Writer writer) + throws IOException { + writer.write(text); + } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/query/QueryScriptFactory.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/query/QueryScriptFactory.java index a79dbfe509..2167b65740 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/query/QueryScriptFactory.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/query/QueryScriptFactory.java @@ -23,7 +23,7 @@ import java.io.IOException; import jep.JepException; -import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory; +import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -38,7 +38,8 @@ import com.raytheon.viz.gfe.core.DataManager; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Feb 7, 2013 mnash Initial creation + * Feb 07, 2013 mnash Initial creation + * Dec 14, 2015 #4816 dgilling Rewrite based on PythonInterpreterFactory. * * * @@ -46,8 +47,8 @@ import com.raytheon.viz.gfe.core.DataManager; * @version 1.0 */ -public class QueryScriptFactory extends - AbstractPythonScriptFactory { +public class QueryScriptFactory implements + PythonInterpreterFactory { private static final IUFStatusHandler statusHandler = UFStatus .getHandler(QueryScriptFactory.class); @@ -57,25 +58,9 @@ public class QueryScriptFactory extends * */ public QueryScriptFactory(DataManager dataMgr) { - this("gfequeryscript", 1); this.manager = dataMgr; } - /** - * @param name - * @param maxThreads - */ - public QueryScriptFactory(String name, int maxThreads) { - super(name, maxThreads); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory# - * createPythonScript() - */ @Override public QueryScript createPythonScript() { try { diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEFonts.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEFonts.java index b9029f1fc8..d7aa5e7cda 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEFonts.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEFonts.java @@ -34,7 +34,7 @@ import com.raytheon.viz.gfe.Activator; import com.raytheon.viz.gfe.GFEPreference; /** - * TODO Add Description + * Get appropriate SWT or GL font based on GFE preferences * *
  * 
@@ -42,11 +42,12 @@ import com.raytheon.viz.gfe.GFEPreference;
  * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Oct 14, 2010            randerso     Initial creation
- * Apr 27, 2011 #9250      bkowal       getStyle and getName are now used to
- *                                      get the style and name associated with
- *                                      a FontData object.
- * Nov 20, 2013 #2488      randerso     Changed to use DejaVu fonts
+ * Oct 14, 2010            randerso    Initial creation
+ * Apr 27, 2011 #9250      bkowal      getStyle and getName are now used to
+ *                                     get the style and name associated with
+ *                                     a FontData object.
+ * Nov 20, 2013 #2488      randerso    Changed to use DejaVu fonts
+ * Nov 05, 2015 #5070      randerso    Remove scale factor for GLFonts (was adjusting for DPI)
  * 
  * 
* @@ -151,8 +152,7 @@ public class GFEFonts { style = new IFont.Style[0]; } - IFont font = target.initializeFont(fd.getName(), fd.height * 1.2f, - style); + IFont font = target.initializeFont(fd.getName(), fd.height, style); font.setSmoothing(false); font.setScaleFont(false); return font; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/ZoneDbResourceData.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/ZoneDbResourceData.java deleted file mode 100644 index bfd53a188b..0000000000 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/ZoneDbResourceData.java +++ /dev/null @@ -1,539 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.gfe.rsc; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlTransient; - -import org.eclipse.swt.graphics.RGB; - -import com.raytheon.uf.viz.core.drawables.IDescriptor; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.rsc.AbstractNameGenerator; -import com.raytheon.uf.viz.core.rsc.AbstractResourceData; -import com.raytheon.uf.viz.core.rsc.AbstractVizResource; -import com.raytheon.uf.viz.core.rsc.LoadProperties; -import com.raytheon.viz.gfe.rsc.zones.ZoneDbResource; - -/** - * - * Resource data for Zones in the database. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date          Ticket#  Engineer    Description
- * ------------- -------- ----------- --------------------------
- * Oct 28, 2013  2491     bsteffen    Add @XmlTransient
- * 
- * 
- * - * @author wldougher - * @version 1.0 - */ -@XmlTransient -public class ZoneDbResourceData extends AbstractResourceData { - - public static final RGB DEFAULT_BACKGROUND_COLOR = new RGB(50, 50, 50); - - public static final RGB DEFAULT_CWA_COLOR = new RGB(184, 134, 11); - - public static final RGB DEFAULT_OUTLINE_COLOR = new RGB(0, 0, 0); - - public static final RGB DEFAULT_LABEL_COLOR = new RGB(200, 200, 200); - - public static final RGB DEFAULT_SELECTION_COLOR = new RGB(200, 0, 0); - - public static final String LABEL_KEY = "LABEL"; - - public static final String CWA_KEY = "CWA"; - - public static final String OUTLINE_KEY = "OUTLINE"; - - public static final Integer NO_GROUP = Integer.valueOf(-1); - - public static final Integer SELECTION_GROUP = Integer.valueOf(0); - - /** The human readable name */ - @XmlElement(required = true) - private String mapName = null; - - /** All the maps DB table names to take data from */ - @XmlElement(required = true) - private List allTables; - - /** The Maps DB table names for visible zones */ - @XmlElement(required = true) - private List tables; - - /** - * Constraints (other than the bounding box) to apply to the queries. The - * constraints are tied to the table to which they apply. - */ - @XmlElement - private Map constraintsMap; - - /** - * The columns (other than geometry) to query. The columns are tied to the - * table they come from. The query columns for all tables must be - * union-compatible. - */ - @XmlElement - private Map queryColumnsMap; - - @XmlElement - private Map colorMap; - - /** - * Constructor. - */ - public ZoneDbResourceData() { - super(); - colorMap = new HashMap(); - this.setBackgroundColor(DEFAULT_BACKGROUND_COLOR); - this.setCwaColor(DEFAULT_CWA_COLOR); - this.setLabelColor(DEFAULT_LABEL_COLOR); - this.setOutlineColor(DEFAULT_OUTLINE_COLOR); - this.setSelectionColor(DEFAULT_SELECTION_COLOR); - this.nameGenerator = new AbstractNameGenerator() { - - @Override - public String getName(AbstractVizResource resource) { - return mapName; - } - - }; - allTables = new ArrayList(); - tables = new ArrayList(); - constraintsMap = new HashMap(); - queryColumnsMap = new HashMap(); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.core.rsc.AbstractResourceData#construct(com.raytheon - * .uf.viz.core.comm.LoadProperties, - * com.raytheon.uf.viz.core.drawables.IDescriptor) - */ - @Override - public ZoneDbResource construct(LoadProperties loadProperties, - IDescriptor descriptor) throws VizException { - return new ZoneDbResource(this, loadProperties); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.core.rsc.AbstractResourceData#update(java.lang.Object - * ) - */ - @Override - public void update(Object updateData) { - // TODO Auto-generated method stub - - } - - /** - * @return the mapName - */ - public String getMapName() { - return mapName; - } - - /** - * @param mapName - * the mapName to set - */ - public void setMapName(String mapName) { - this.mapName = mapName; - } - - /** - * @return the mainTable - */ - public String getMainTable() { - return tables.get(0); - } - - /** - * @param mainTable - * the mainTable to set - */ - public void setMainTable(String mainTable) { - tables.clear(); - addTable(mainTable); - } - - /** - * @return the constraints - */ - public String[] getConstraints() { - String mainTable = getMainTable(); - return constraintsMap.get(mainTable); - } - - /** - * @param table - * @return constraints - */ - public String[] getConstraints(String table) { - return constraintsMap.get(table); - } - - /** - * @param constraints - * the constraints to set - */ - public void setConstraints(String[] constraints) { - String mainTable = getMainTable(); - constraintsMap.put(mainTable, constraints); - } - - /** - * @param table - * @param constraints - */ - public void setConstraints(String table, String[] constraints) { - constraintsMap.put(table, constraints); - } - - /** - * @return the zoneEdgeColor - */ - public RGB getOutlineColor() { - RGB outlineColor = colorMap.get(OUTLINE_KEY); - if (outlineColor == null) { - outlineColor = DEFAULT_OUTLINE_COLOR; - setOutlineColor(outlineColor); - } - return outlineColor; - } - - /** - * @param outlineColor - * the outlineColor to set - */ - public void setOutlineColor(RGB outlineColor) { - colorMap.put(OUTLINE_KEY, outlineColor); - } - - /** - * @return the cwaColor - */ - public RGB getCwaColor() { - RGB cwaColor = colorMap.get(CWA_KEY); - if (cwaColor == null) { - cwaColor = DEFAULT_CWA_COLOR; - setCwaColor(cwaColor); - } - return cwaColor; - } - - /** - * @param cwaColor - * the cwaColor to set - */ - public void setCwaColor(RGB cwaColor) { - colorMap.put(CWA_KEY, cwaColor); - } - - /** - * @return the backgroundColor - */ - public RGB getBackgroundColor() { - RGB backgroundColor = colorMap.get(NO_GROUP); - if (backgroundColor == null) { - backgroundColor = DEFAULT_BACKGROUND_COLOR; - setBackgroundColor(backgroundColor); - } - return backgroundColor; - } - - /** - * @param backgroundColor - * the backgroundColor to set - */ - public void setBackgroundColor(RGB backgroundColor) { - colorMap.put(NO_GROUP, backgroundColor); - } - - /** - * @return the labelColor - */ - public RGB getLabelColor() { - RGB labelColor = colorMap.get(LABEL_KEY); - if (labelColor == null) { - labelColor = DEFAULT_LABEL_COLOR; - setLabelColor(labelColor); - } - return labelColor; - } - - /** - * @param labelColor - * the labelColor to set - */ - public void setLabelColor(RGB labelColor) { - colorMap.put(LABEL_KEY, labelColor); - } - - /** - * @return the selectionColor - */ - public RGB getSelectionColor() { - - RGB selectionColor = colorMap.get(SELECTION_GROUP); - if (selectionColor == null) { - selectionColor = DEFAULT_SELECTION_COLOR; - setSelectionColor(selectionColor); - } - return selectionColor; - } - - /** - * @param selectionColor - * the selectionColor to set - */ - public void setSelectionColor(RGB selectionColor) { - colorMap.put(SELECTION_GROUP, selectionColor); - } - - /** - * @return the tables - */ - public List getTables() { - return tables; - } - - /** - * @param tables - * the tables to set - */ - public void setTables(List tables) { - this.tables = tables; - for (String table : tables) { - if (!allTables.contains(table)) { - allTables.add(table); - } - } - } - - /** - * Clear the entire list of visible tables - */ - public void clearTables() { - tables.clear(); - } - - /** - * Clear all the queried tables, visible and hidden. - */ - public void clearAllTables() { - allTables.clear(); - clearTables(); - } - - /** - * Add a table to the list of visible tables. - * - * @param table - * The table to add - */ - public void addTable(String table) { - tables.add(table); - if (!allTables.contains(table)) { - allTables.add(table); - } - } - - /** - * Remove a table from the list of shown tables. - * - * @param table - */ - public void removeTable(String table) { - tables.remove(table); - } - - /** - * @return the constraintsMap - */ - public Map getConstraintsMap() { - return constraintsMap; - } - - /** - * @param constraintsMap - * the constraintsMap to set - */ - public void setConstraintsMap(Map constraintsMap) { - this.constraintsMap = constraintsMap; - } - - /** - * @param queryColumnsMap - * the queryColumnsMap to set - */ - public void setQueryColumnsMap(Map queryColumnsMap) { - this.queryColumnsMap = queryColumnsMap; - } - - /** - * @return the queryColumnsMap - */ - public Map getQueryColumnsMap() { - return queryColumnsMap; - } - - /** - * @param table - * @return - */ - public String[] getQueryColumns(String table) { - return queryColumnsMap.get(table); - } - - /** - * @param table - * @param queryColumns - */ - public void setQueryColumns(String table, String[] queryColumns) { - queryColumnsMap.put(table, queryColumns); - } - - /** - * Some applications (GHG Monitor, for one) need to query the database for - * zone geometry from more tables than those shown on the map. - * - * @return the allTables - */ - public List getAllTables() { - return allTables; - } - - /** - * @param allTables - * the allTables to set - */ - public void setAllTables(List allTables) { - this.allTables = allTables; - } - - /** - * - * @return - */ - public Map getColorMap() { - return colorMap; - } - - /** - * Set the color map. - * - * @param colorMap - * The color map to set. - */ - public void setColorMap(Map colorMap) { - this.colorMap = colorMap; - // Make sure hidden colors are present - getBackgroundColor(); - getOutlineColor(); - getCwaColor(); - getLabelColor(); - getSelectionColor(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || obj instanceof ZoneDbResourceData == false) { - return false; - } - ZoneDbResourceData other = (ZoneDbResourceData) obj; - - if (this.tables != null && other.tables == null) { - return false; - } else if (this.tables == null && other.tables != null) { - return false; - } else if (this.tables != null - && this.tables.equals(other.tables) == false) { - return false; - } - - if (this.queryColumnsMap != null && other.queryColumnsMap == null) { - return false; - } else if (this.queryColumnsMap == null - && other.queryColumnsMap != null) { - return false; - } else if (this.queryColumnsMap != null - && this.queryColumnsMap.equals(other.queryColumnsMap) == false) { - return false; - } - - if (this.mapName != null && other.mapName == null) { - return false; - } else if (this.mapName == null && other.mapName != null) { - return false; - } else if (this.mapName != null - && this.mapName.equals(other.mapName) == false) { - return false; - } - - if (this.constraintsMap != null && other.constraintsMap == null) { - return false; - } else if (this.constraintsMap == null && other.constraintsMap != null) { - return false; - } else if (this.constraintsMap != null - && this.constraintsMap.equals(other.constraintsMap) == false) { - return false; - } - - if (this.colorMap != null && other.colorMap == null) { - return false; - } else if (this.colorMap == null && other.colorMap != null) { - return false; - } else if (this.colorMap != null - && this.colorMap.equals(other.colorMap) == false) { - return false; - } - - if (this.allTables != null && other.allTables == null) { - return false; - } else if (this.allTables == null && other.allTables != null) { - return false; - } else if (this.allTables != null - && this.allTables.equals(other.allTables) == false) { - return false; - } - - return true; - } -} diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/zones/ShapeBuilderJob.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/zones/ShapeBuilderJob.java deleted file mode 100644 index f56c66ee74..0000000000 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/zones/ShapeBuilderJob.java +++ /dev/null @@ -1,393 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -/** - * - */ -package com.raytheon.viz.gfe.rsc.zones; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Random; -import java.util.concurrent.ArrayBlockingQueue; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.swt.graphics.RGB; - -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.drawables.IDescriptor; -import com.raytheon.uf.viz.core.drawables.IShadedShape; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.viz.core.rsc.jts.JTSCompiler; -import com.raytheon.viz.core.rsc.jts.JTSCompiler.PointStyle; -import com.vividsolutions.jts.geom.Geometry; -import com.vividsolutions.jts.io.ParseException; -import com.vividsolutions.jts.io.WKBReader; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- *                         wldougher   Initial creation.
- * Aug 01, 2014 3471       mapeters    Updated deprecated createShadedShape() calls.
- * Aug 13, 2014 3492       mapeters    Updated deprecated createWireframeShape() calls.
- * 
- * 
- * - * @author wldougher - * - */ -public class ShapeBuilderJob extends Job { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(ShapeBuilderJob.class); - - private static final int QUEUE_SIZE = 1; - - protected ArrayBlockingQueue requestQueue; - - protected ArrayBlockingQueue responseQueue; - - protected final WKBReader wkbReader; - - protected String cwaID; - - protected IDescriptor descriptor; - - protected TabNameComp tabNameComp; - - protected ZoneNameComp zoneNameComp; - - protected Random rand; - - public ShapeBuilderJob(String cwaID, IDescriptor descriptor) { - super("Building shapes..."); - this.cwaID = cwaID; - this.descriptor = descriptor; - requestQueue = new ArrayBlockingQueue(QUEUE_SIZE); - responseQueue = new ArrayBlockingQueue(QUEUE_SIZE); - tabNameComp = new TabNameComp(); - wkbReader = new WKBReader(); - zoneNameComp = new ZoneNameComp(); - rand = new Random(); - } - - /** - * - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - protected IStatus run(IProgressMonitor monitor) { - if (monitor.isCanceled()) { - return Status.CANCEL_STATUS; - } - // long startTime = System.currentTimeMillis(); - - ShapeBuilderRequest request = requestQueue.poll(); - if (request != null) { - - ShapeBuilderResponse response = process(request); - - // Put the response on the queue - long millis = 0L; - boolean interrupted = false; - while (!responseQueue.offer(response) && !interrupted - && !monitor.isCanceled()) { - responseQueue.poll(); - try { - Thread.sleep(millis); - } catch (InterruptedException e) { - interrupted = true; - } - millis = 100L; - } - // Trigger another paint() call; the original one probably - // finished long ago. - request.target.setNeedsRefresh(true); - } - - // statusHandler.handle(Priority.VERBOSE, - // "ShapeBuilderJob completed in " - // + (System.currentTimeMillis() - startTime) + " ms"); - return Status.OK_STATUS; - } - - /** - * @param request - * @return - */ - protected ShapeBuilderResponse process(ShapeBuilderRequest request) { - ShapeBuilderResponse response = new ShapeBuilderResponse(); - response.id = request.id; - response.groups = request.groups; - // response.groupShapes = request.groupShapes; - response.colorMap = request.colorMap; - response.tables = request.tables; - - // Nothing can be done if the first database query hasn't completed - if (request.dbData != null && (request.shaded || request.outlined)) { - // statusHandler.handle(Priority.VERBOSE, - // "Processing shapebuilder request " + request.id - // + " because " + request.reason); - buildBasicMap(request, response); - if (request.shaded) { - buildGroupShapes(request, response); - } - } - return response; - } - - /** - * Build the background and wireframe shapes outline and cwaOutline. - * - * @param request - * The request for new shapes. - * @param response - * The response to fill in. - * @return response, with modifications. - */ - protected ShapeBuilderResponse buildBasicMap(ShapeBuilderRequest request, - ShapeBuilderResponse response) { - - boolean needBackground = request.shaded - && (request.background == null || !request.background - .isDrawable()); - boolean needOutlines = request.outlined; - needOutlines &= (request.outline == null - || !request.outline.isDrawable() || request.cwaOutline == null || !request.cwaOutline - .isDrawable()); - if (needBackground || needOutlines) { - // When request.shaded==false or request.outlined==false, this - // does more work than it needs to. Currently, all the users of this - // class are both shaded and outlined, so the extra logic has not - // been fully implemented. - response.background = request.target.createShadedShape(false, - descriptor.getGridGeometry(), true); - response.outline = request.target.createWireframeShape(false, - descriptor); - response.cwaOutline = request.target.createWireframeShape(false, - descriptor); - JTSCompiler compiler = new JTSCompiler(response.background, - response.outline, descriptor, PointStyle.CROSS); - JTSCompiler cwaCompiler = new JTSCompiler(null, - response.cwaOutline, descriptor, PointStyle.CROSS); - - RGB backgroundColor = getColor(request, - Integer.valueOf(ZoneDbResource.NO_GROUP)); - byte[] emptyByteArray = new byte[0]; - for (String table : request.tables) { - // Use binary search to find the start and end indices for table - DbData key = new DbData(emptyByteArray, table, "", ""); - DbData afterKey = new DbData(emptyByteArray, table + " ", "", - ""); - int tstart = Arrays.binarySearch(request.dbData, key, - tabNameComp); - int tend = Arrays.binarySearch(request.dbData, afterKey, - tabNameComp); - tstart = (tstart < 0) ? -(tstart + 1) : tstart; - tend = (tend < 0) ? -(tend + 1) : tend; - - for (int dbIdx = tstart; dbIdx < tend; dbIdx++) { - DbData rec = request.dbData[dbIdx]; - try { - // add the zone geometry to outline - Geometry geom = wkbReader.read(rec.wkb); - compiler.handle(geom, backgroundColor); - if (rec.cwa.startsWith(cwaID)) { - // add the zone geometry to the cwa outline - geom = wkbReader.read(rec.wkb); - cwaCompiler.handle(geom); - } - } catch (ParseException e) { - statusHandler.handle(Priority.PROBLEM, - "Error parsing geometry for zone " + rec.zone, - e); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error handling geometry for zone " + rec.zone, - e); - } - } - } - - if (request.shaded) { - response.background.compile(); - } else { - response.background = null; - } - - if (request.outlined) { - response.outline.compile(); - response.cwaOutline.compile(); - } else { - response.outline = null; - response.cwaOutline = null; - } - } - - return response; - } - - /** - * Build the shaded shapes for the colored groups. - * - * @param request - * The request for new shapes - * @param response - */ - protected ShapeBuilderResponse buildGroupShapes( - ShapeBuilderRequest request, ShapeBuilderResponse response) { - int groupCount = request.groups.size(); - if (request.dbData != null && request.shaded) { - - // Make sure the response has enough room for the new shapes. - if (request.groupShapes == null) { - response.groupShapes = new ArrayList(groupCount); - } else { - // Keep known group shapes - response.groupShapes = request.groupShapes; - response.groupShapes.ensureCapacity(groupCount); - } - - int groupNum = 0; - for (List group : request.groups) { - RGB color = getColor(request, Integer.valueOf(groupNum)); - - IShadedShape groupShape = request.target.createShadedShape( - false, descriptor.getGridGeometry(), true); - JTSCompiler groupCompiler = new JTSCompiler(groupShape, null, - descriptor, PointStyle.CROSS); - - if (group != null) { - for (String groupZone : group) { - DbData[] dataA = findZoneData(request, groupZone); - for (DbData data : dataA) { - // create a geometry from it - try { - Geometry geom = wkbReader.read(data.wkb); - groupCompiler.handle(geom, color); - } catch (ParseException e) { - statusHandler.handle(Priority.PROBLEM, - "Error parsing geometry for zone " - + groupZone, e); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error handling geometry for zone " - + groupZone, e); - } - } - } - } - - groupShape.compile(); - if (groupNum >= request.groupShapes.size()) { - response.groupShapes.add(groupShape); - } else { - response.groupShapes.set(groupNum, groupShape); - } - groupNum++; - } - - } - return response; - } - - /** - * Find the database records for the zone with the given ID. Uses the - * zoneData array, which must be sorted by zone. - * - * 2010-11-18: Allow multiple records for the same zone ID. - * - * @param zoneID - * The ID of the zone to look up. - * @return the DbData for the zone - */ - protected DbData[] findZoneData(ShapeBuilderRequest request, String zoneID) { - if (request.zoneData != null) { - int zdIndex = -1; - int from = -1; - int to = -1; - // If there are multiple records, binarySearch gives no guarantee - // it will find the first. Look for the first entry AFTER zoneID - DbData key = new DbData(new byte[0], "", "", zoneID + "\t"); - zdIndex = Arrays.binarySearch(request.zoneData, key, zoneNameComp); - zdIndex = (zdIndex < 0) ? -(zdIndex + 1) : zdIndex; - from = zdIndex; - to = zdIndex; - // Now walk the list backwards starting at to-1 until we - // find an entry that doesn't have the right zoneID - // (there will usually only be one or two) - for (zdIndex--; zdIndex >= 0 - && zoneID.equals(request.zoneData[zdIndex].zone); zdIndex--) { - from = zdIndex; - } - return Arrays.copyOfRange(request.zoneData, from, to); - } else { - return new DbData[0]; - } - } - - /** - * Get the color that has been chosen for the designated object. If no color - * has been set, return a random color. - * - * @param key - * The object to look up - * @return The color in which the object should be drawn. - */ - protected RGB getColor(ShapeBuilderRequest request, Object key) { - if (request.colorMap == null) { - request.colorMap = new HashMap(); - } - RGB color = request.colorMap.get(key); - if (color == null) { - color = new RGB(rand.nextInt(206) + 50, rand.nextInt(206) + 50, - rand.nextInt(206) + 50); - request.colorMap.put(key, color); - } - - return color; - } - - /** - * @return the cwaID - */ - public String getCwaID() { - return cwaID; - } - - /** - * @param cwaID - * the cwaID to set - */ - public void setCwaID(String cwaID) { - this.cwaID = cwaID; - } - -} diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/zones/ZoneDbResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/zones/ZoneDbResource.java deleted file mode 100644 index 92a1cd2f4a..0000000000 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/zones/ZoneDbResource.java +++ /dev/null @@ -1,2237 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -/** - * - */ -package com.raytheon.viz.gfe.rsc.zones; - -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.commons.lang.StringUtils; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.JobChangeAdapter; -import org.eclipse.swt.graphics.RGB; -import org.geotools.coverage.grid.GeneralGridGeometry; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.TransformException; - -import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DBit; -import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData; -import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID; -import com.raytheon.uf.common.geospatial.MapUtil; -import com.raytheon.uf.common.geospatial.ReferencedCoordinate; -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.DrawableString; -import com.raytheon.uf.viz.core.IGraphicsTarget; -import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; -import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle; -import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle; -import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment; -import com.raytheon.uf.viz.core.PixelExtent; -import com.raytheon.uf.viz.core.catalog.DirectDbQuery; -import com.raytheon.uf.viz.core.catalog.DirectDbQuery.QueryLanguage; -import com.raytheon.uf.viz.core.drawables.IFont; -import com.raytheon.uf.viz.core.drawables.IShadedShape; -import com.raytheon.uf.viz.core.drawables.IWireframeShape; -import com.raytheon.uf.viz.core.drawables.PaintProperties; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.map.MapDescriptor; -import com.raytheon.uf.viz.core.rsc.AbstractVizResource; -import com.raytheon.uf.viz.core.rsc.LoadProperties; -import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability; -import com.raytheon.viz.gfe.GFEPreference; -import com.raytheon.viz.gfe.core.DataManager; -import com.raytheon.viz.gfe.rsc.GFEFonts; -import com.raytheon.viz.gfe.rsc.ZoneDbResourceData; -import com.raytheon.viz.gfe.rsc.ZoneGroupableCapability; -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.Envelope; -import com.vividsolutions.jts.geom.Geometry; -import com.vividsolutions.jts.geom.GeometryFactory; -import com.vividsolutions.jts.geom.Point; -import com.vividsolutions.jts.io.ParseException; -import com.vividsolutions.jts.io.WKBReader; - -/** - * This class use to obtain Zone's database resource. It associates mapping with - * zone's name (ID) geomentry and maintains groupings of zones. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- *                         wldougher     Initial creation
- * Jul 11, 2011 9928       rferrel       moveGroup now takes list of groups.
- * Jun 24, 2013 2134       randerso      Fixed NullPointerException in fitToCWA.
- * Aug 14, 2014 3523       mapeters      Updated deprecated {@link DrawableString#textStyle} 
- *                                       assignments.
- * 
- * 
- * - * @author wldougher - * @version 1.0 - */ -public class ZoneDbResource extends - AbstractVizResource { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(ZoneDbResource.class); - - /** The name of the DB from which maps should be read */ - private static final String MAP_DB = "maps"; - - private static final String MAP_SCHEMA = "mapdata"; - - public static final String PUBLIC_TABLE = "zone"; - - public static final String COUNTY_TABLE = "county"; - - public static final String FIREWX_TABLE = "firewxzones"; - - public static final String MARINE_TABLE = "marinezones"; - - public static final String OFFSHORE_TABLE = "offshore"; - - public static final String HIGHSEA_TABLE = "highsea"; - - public static final String[] PUBLIC_FIELDS = { "'" + PUBLIC_TABLE + "'", - "state || 'Z' || zone AS zonelabel", "CWA" }; - - public static final String[] FIPS_FIELDS = { "'" + COUNTY_TABLE + "'", - "state || 'C' || substr(fips,3) AS zonelabel", "CWA" }; - - public static final String[] FIREWX_FIELDS = { "'" + FIREWX_TABLE + "'", - "state || 'Z' || zone AS zonelabel", "CWA" }; - - public static final String[] MARINE_FIELDS = { "'" + MARINE_TABLE + "'", - "id as zonelabel", "wfo" }; - - public static final String[] OFFSHORE_FIELDS = { - "'" + OFFSHORE_TABLE + "'", "id as zonelabel", "wfo" }; - - public static final String[] HIGHSEA_FIELDS = { "'" + HIGHSEA_TABLE + "'", - "'HISEA'||gid as zonelabel", "wfo" }; - - private static final double EXPANSION_FACTOR = 0.5; - - public static final int SELECTION_GROUP = 0; - - /** Fraction used by fitToCWA() to calculate margin width */ - private static final double BUFFER_MULT = 0.05; - - public static final int NO_GROUP = -1; - - private static final double MIN_LABEL_DISTANCE = 100; - - /** - * FORMATTER_LAUNCHER, type. displays multiple zones, and multiple colors. - * GHG_MONITOR, displays "clickable zones" as one color, (related to - * hazards) MAKE_HAZARD type. displays 1 zone, all as same color. - */ - public enum DisplayType { - FORMATTER_LAUNCHER, GHG_MONITOR, MAKE_HAZARD, SINGLE_ZONE_ALLOWABLE - } - - private DisplayType displayType; - - // Available simplification levels by table name - protected Map> availSimpLevMap; - - // Previous simplification level by table name - protected Map simpLevMap; - - // The site ID from the data manager - protected String siteID; - - // The cwa ID set by callers - protected String cwaID; - - // Whether this resource needs to be repainted. - protected boolean dirty; - - // Like dirty, but stronger: database read needed during paint. - protected boolean filthy; - - // The background area - protected IShadedShape background; - - // The shapes for the colored groups - protected ArrayList groupShapes; - - // The zone borders for all visible zones - protected IWireframeShape outline; - - // The zone borders for zones in this site's CWA - protected IWireframeShape cwaOutline; - - // A list of the current zone groups - protected List> groups; - - // A list of the zone groups on the previous call to paint() - protected List> oldGroups; - - // The current graphics target (only valid inside paint()) - protected IGraphicsTarget target; - - // The current paint properties (only valid inside paint()) - protected PaintProperties paintProps; - - // A reader to convert byte arrays to Geometries - protected WKBReader wkbReader; - - // Instance of the comparator for sorting by table name - protected TabNameComp tabNameComp; - - // Instance of the comparator for sorting by zone name - protected ZoneNameComp zoneNameComp; - - // Records in the current query, sorted by table name - protected DbData[] dbData; - - // Records in the current query, sorted by zone - protected DbData[] zoneData; - - // tables visible when queryJob was last scheduled - protected List oldQTables; - - // tables visible when shapeBuilderJob was last scheduled - protected List oldSTables; - - // Map of colors to use - protected Map colorMap; - - // For generating random colors - protected Random rand; - - // The job that queries the database - protected QueryJob queryJob; - - protected ShapeBuilderJob shapeBuilderJob; - - // The pixel extent of the previous call to paint() - protected PixelExtent oldScreenExtent; - - // The simplification levels of the previous call to paint() - protected List oldSimpLevels; - - protected boolean runShapeJob; - - protected Envelope boundingEnvelope; - - protected HashMap zoneMap; - - protected int dbRqNum; - - protected int shpRqNum; - - // Map from zone IDs to geometry centroids - protected HashMap> labelMap; - - protected String geometryType; - - protected List zoneChangeListeners; - - private boolean labelZones; - - private Double scaleX; - - private Double scaleY; - - private IFont labelFont; - - /** - * Constructor. - * - * @param resourceData - * The ZoneDbResourceData that influence's this resource's - * appearance. - * @param loadProperties - * Data-loading options used by superclass ctor. - */ - public ZoneDbResource(ZoneDbResourceData resourceData, - LoadProperties loadProperties) { - super(resourceData, loadProperties); - rand = new Random(System.currentTimeMillis()); - availSimpLevMap = new HashMap>(); - simpLevMap = new HashMap(); - queryJob = new QueryJob("Querying Database..."); - groups = new ArrayList>(SELECTION_GROUP + 1); - groups.add(new ArrayList()); - groupShapes = new ArrayList(); - colorMap = new HashMap(); - Map rdColorMap = resourceData.getColorMap(); - if (rdColorMap != null) { - colorMap.putAll(rdColorMap); - } - wkbReader = new WKBReader(); - tabNameComp = new TabNameComp(); - zoneNameComp = new ZoneNameComp(); - runShapeJob = true; - displayType = DisplayType.FORMATTER_LAUNCHER; - getCapability(OutlineCapability.class).setOutlineOn(true); - getCapability(OutlineCapability.class).setLineStyle(LineStyle.SOLID); - dbRqNum = 0; - shpRqNum = 0; - zoneChangeListeners = new ArrayList(1); - } - - /** - * @see com.raytheon.uf.viz.core.rsc.AbstractVizResource#disposeInternal() - */ - @Override - protected void disposeInternal() { - if (background != null) { - background.dispose(); - background = null; - } - - for (IShadedShape groupShape : groupShapes) { - if (groupShape != null) { - groupShape.dispose(); - } - } - groupShapes.clear(); - - if (outline != null) { - outline.dispose(); - outline = null; - } - - if (cwaOutline != null) { - cwaOutline.dispose(); - cwaOutline = null; - } - - // dispose of labels and group labels? - - if (labelFont != null) { - labelFont.dispose(); - labelFont = null; - } - } - - /** - * @see com.raytheon.uf.viz.core.rsc.AbstractVizResource#initInternal(com.raytheon.uf.viz.core.IGraphicsTarget) - */ - @Override - protected void initInternal(IGraphicsTarget target) throws VizException { - siteID = DataManager.getCurrentInstance().getSiteID(); - cwaID = siteID; - // find the available simplification levels - for (String table : resourceData.getAllTables()) { - List levels = querySimpLevels(table); - availSimpLevMap.put(table, levels); - } - shapeBuilderJob = new ShapeBuilderJob(cwaID, descriptor); - } - - /** - * The paint routine. - *

- * Painting is a three-stage process: the database is queried to obtain a - * cache of geometries for the zones, the geometries are compiled into - * wireframes and shaded shapes, and the wireframes and shaded shapes are - * painted to the screen (by paintShapes()). The first two stages can take - * significant amounts of time, so they are done in separate threads to keep - * the GUI thread responsive. - *

- *

- * Not all stages are necessary for each repaint. If the map is only being - * repainted because it was hidden by another window, a call to - * paintShapes() is all that needs to be done. If zones have changed color - * due to zone selection or colormap changes, or if labels have been turned - * on or off, some shapes may need to be compiled but the database does not - * need to be queried. - *

- *

- * It is important to avoid excess database reads. The maps database - * typically resides on the EDEX server and is shared by all users. In the - * past, database reads were generated with every mouse move. This bogged - * down the server and the network with database requests, causing delays - * not only for users of this class, but also for other users in unrelated - * applications. - *

- *

- * Database reads should ONLY be needed when: - *

    - *
  • Initializing the resource.
  • - *
  • Changing tables (PUBLIC to FIREWX, for example).
  • - *
  • Displaying a different region.
  • - *
  • Changing zoom simplification levels (the geometries are read from a - * different column).
  • - *
  • The maps database has been updated.
  • - *
- * Database reads are NOT needed when: - *
    - *
  • Selecting/deselecting zones.
  • - *
  • Showing/hiding zone names or group numbers.
  • - *
  • Changing zone colors.
  • - *
- *

- * - * @see com.raytheon.uf.viz.core.drawables.IRenderable#paintInternal(com.raytheon.uf.viz.core.IGraphicsTarget, - * com.raytheon.uf.viz.core.drawables.PaintProperties) - */ - @Override - protected void paintInternal(IGraphicsTarget target, - PaintProperties paintProps) throws VizException { - PixelExtent screenExtent = (PixelExtent) paintProps.getView() - .getExtent(); - // compute an estimate of degrees per pixel - double yc = screenExtent.getCenter()[1]; - double x1 = screenExtent.getMinX(); - double x2 = screenExtent.getMaxX(); - double[] c1 = descriptor.pixelToWorld(new double[] { x1, yc }); - double[] c2 = descriptor.pixelToWorld(new double[] { x2, yc }); - int screenHeight = paintProps.getCanvasBounds().height; - int screenWidth = paintProps.getCanvasBounds().width; - - if (screenWidth == 0) { - return; - } - double dppX = Math.abs(c2[0] - c1[0]) / screenWidth; - - this.target = target; - this.paintProps = paintProps; - this.scaleX = Double.valueOf(screenWidth / screenExtent.getWidth()); - this.scaleY = Double.valueOf(screenHeight / screenExtent.getHeight()); - - Envelope screenEnv = screenExtent.getEnvelope(); - - // See if we've zoomed in or out enough to need to read again. - List allTables = resourceData.getAllTables(); - List simpLevels = new ArrayList(allTables.size()); - for (String table : allTables) { - simpLevels.add(this.simpLvlSuffix(table, dppX)); - } - - if (paintProps.isZooming()) { - target.setNeedsRefresh(true); - } else { - if (oldScreenExtent == null || oldSimpLevels == null || isFilthy() - || !oldScreenExtent.getEnvelope().covers(screenEnv) - || !oldSimpLevels.equals(simpLevels) - || !resourceData.getTables().equals(oldQTables)) { - String dbReadReason = ""; - if (oldScreenExtent == null) { - dbReadReason = "oldScreenExtent == null"; - } else if (oldSimpLevels == null) { - dbReadReason = "oldSimpLevels == null"; - } else if (isFilthy()) { - dbReadReason = "isFilthy()"; - } else if (!oldScreenExtent.getEnvelope().covers(screenEnv)) { - dbReadReason = "!oldScreenExtent.getEnvelope().covers(screenEnv)"; - } else if (!oldSimpLevels.equals(simpLevels)) { - dbReadReason = "!oldSimpLevels.equals(simpLevels)"; - } else { - List rdgt = resourceData.getTables(); - dbReadReason = "!resourceData.getTables().equals(oldQTables))" - + "\nresourceData.getTables().size():" - + ((rdgt == null) ? null : rdgt.size()) - + "\noldQTables.size():" - + ((oldQTables == null) ? null : oldQTables.size()); - } - PixelExtent expandedExtent = getExpandedExtent(screenExtent); - oldScreenExtent = expandedExtent; - oldSimpLevels = simpLevels; - List rdTables = resourceData.getTables(); - if (rdTables == null) { - oldQTables = null; - } else { - oldQTables = new ArrayList(rdTables); - } - String query = buildQuery(expandedExtent, dppX); - QueryRequest qreq = new QueryRequest(); - qreq.query = query; - qreq.target = target; - queryJob.requestQueue.clear(); - queryJob.requestQueue.offer(qreq); - queryJob.schedule(); - dbRqNum = (dbRqNum + 1) % 10000; - // log(Priority.VERBOSE, "Database query " + dbRqNum - // + " scheduled." + "Reason: " + dbReadReason); - setFilthy(false); - } - - DbData[] rspA = queryJob.responseQueue.poll(); - if (rspA != null) { - // log(Priority.VERBOSE, "Database response received."); - dbData = rspA; - Arrays.sort(dbData, tabNameComp); - zoneData = new DbData[rspA.length]; - System.arraycopy(rspA, 0, zoneData, 0, rspA.length); - Arrays.sort(zoneData, zoneNameComp); - createZoneMap(); - createLabelMap(); - } - buildShapes(rspA); - setDirty(false); - } - - paintShapes(); - this.target = null; - this.paintProps = null; - this.scaleX = null; - this.scaleY = null; - } - - /** - * Get the state of the filthy flag. - * - * @return the filthy state. - */ - public boolean isFilthy() { - return filthy; - } - - /** - * Set the filthy flag to filthy. - *

- * Filthy is a stronger version of dirty, indicating that new geometries - * need to be loaded before repainting. The flag is automatically cleared - * when paintInternal() kicks off a new query job. - * - * @param filthy - * the value to set - */ - public void setFilthy(boolean filthy) { - this.filthy = filthy; - } - - /** - * Send a status message at the given priority, usually Priority.VERBOSE. - * - * @param priority - * The priority of the message to log - * @param message - */ - protected void log(Priority priority, String message) { - statusHandler.handle(priority, "ZoneDbResource: " + message); - } - - /** - * Create the map from zone IDs to centroid coordinates - */ - protected void createLabelMap() { - labelMap = new HashMap>(); - int numGeometries; - Geometry geom; - Geometry poly; - List rcList; - ReferencedCoordinate rc; - for (DbData data : dbData) { - geom = null; - try { - geom = wkbReader.read(data.wkb); - } catch (ParseException e) { - statusHandler.handle(Priority.PROBLEM, - "Error parsing geometry for zone " + data.zone, e); - } - - if (geom != null) { - rcList = labelMap.get(data.zone); - if (rcList == null) { - rcList = new ArrayList(2); - labelMap.put(data.zone, rcList); - } - numGeometries = geom.getNumGeometries(); - for (int geomNum = 0; geomNum < numGeometries; geomNum++) { - poly = geom.getGeometryN(geomNum); - rc = new ReferencedCoordinate(poly.getCentroid() - .getCoordinate()); - rcList.add(rc); - } - } - } - } - - /** - * Create the map from geometries to zone IDs - */ - protected void createZoneMap() { - zoneMap = new HashMap(); - for (DbData item : dbData) { - try { - Geometry geom = wkbReader.read(item.wkb); - zoneMap.put(geom, item.zone); - } catch (ParseException e) { - statusHandler.handle(Priority.PROBLEM, - "Error parsing geometry for zone " + item.zone, e); - } - } - } - - /** - * Build the query string to get information from the maps database. - * - * @param extent - * The PixelExtent over which the query applies - * @param dppX - * Degrees (longitude) per pixel in the X direction - * @return An SQL query string - * @throws VizException - */ - protected String buildQuery(PixelExtent extent, double dppX) - throws VizException { - // enter("buildQuery{PE}"); - - Envelope env = null; - try { - CoordinateReferenceSystem crs = descriptor.getCRS(); - Envelope evl = descriptor.pixelToWorld(extent, crs); - ReferencedEnvelope ref = new ReferencedEnvelope(evl, crs); - env = ref.transform(MapUtil.LATLON_PROJECTION, true); - } catch (Exception e) { - throw new VizException("Error transforming extent", e); - } - - // leave("buildQuery{PE}"); - return buildQuery(env, dppX); - } - - /** - * @param env - * The Envelope over which the query applies - * @param dppX - * Degrees (longitude) per pixel in the X direction - * @return An SQL query string - */ - protected String buildQuery(Envelope env, double dppX) { - // enter("buildQuery"); - StringBuilder sb = new StringBuilder(); - String union = ""; - List allTables = null; - allTables = new ArrayList(resourceData.getAllTables()); - for (String table : allTables) { - String suffix = simpLvlSuffix(table, dppX); - String geometryField = "main.the_geom" + suffix; - String geoConstraint = String.format( - "%s && ST_SetSrid('BOX3D(%f %f, %f %f)'::box3d,4326)", - geometryField, env.getMinX(), env.getMinY(), env.getMaxX(), - env.getMaxY()); - - sb.append(union); - sb.append("SELECT"); - sb.append(" AsBinary("); - sb.append(geometryField); - sb.append(")"); - String[] queryColumns = resourceData.getQueryColumns(table); - for (String queryCol : queryColumns) { - sb.append(", "); - sb.append(queryCol); - } - sb.append(" FROM "); - sb.append(MAP_SCHEMA).append(".").append(table); - sb.append(" AS main"); - sb.append(" WHERE "); - sb.append(geoConstraint); - String[] constraints = resourceData.getConstraints(table); - if (constraints != null) { - for (String constraint : constraints) { - sb.append(" AND "); - sb.append(constraint); - } - } - - union = " UNION "; - } - sb.append(";"); - // leave("buildQuery"); - return sb.toString(); - } - - /** - * @return - */ - protected String buildEAQuery() { - StringBuilder sb = new StringBuilder(); - String union = ""; - List allTables = null; - allTables = new ArrayList(resourceData.getAllTables()); - for (String table : allTables) { - sb.append(union); - sb.append("SELECT "); - String[] queryColumns = resourceData.getQueryColumns(table); - for (int i = 0; i < queryColumns.length; i++) { - sb.append(queryColumns[i]); - if (i < queryColumns.length - 1) { - sb.append(", "); - } - } - sb.append(" FROM "); - sb.append(MAP_SCHEMA).append(".").append(table); - sb.append(" AS main"); - sb.append(" WHERE "); - String[] constraints = resourceData.getConstraints(table); - if (constraints != null) { - for (int i = 0; i < constraints.length; i++) { - sb.append(constraints[i]); - if (i < constraints.length - 1) { - sb.append(" AND "); - } - } - } - - union = " UNION "; - } - sb.append(";"); - return sb.toString(); - } - - /** - * Figure out which shapes need to be rebuilt and destroy any shapes that - * are out of date, setting any pointers to them to null. - */ - protected ShapeBuilderRequest dropObsoleteShapes(boolean newDbData) { - // enter("dropObsoleteShapes"); - boolean killBackground = false; - boolean killOutline = false; - boolean killShapes = false; - - ShapeBuilderRequest request = new ShapeBuilderRequest(); - - request.target = target; - request.dbData = dbData; - request.zoneData = zoneData; - // Copy groups into the request - request.groups = new ArrayList>(groups.size()); - for (List group : groups) { - request.groups.add(new ArrayList(group)); - } - request.tables = new ArrayList(resourceData.getTables()); - request.background = background; - request.outline = outline; - request.cwaOutline = cwaOutline; - if (groupShapes != null) { - request.groupShapes = new ArrayList(groupShapes); - } - - if (colorMap == null) { - colorMap = new HashMap(); - } - - Map rdColorMap = resourceData.getColorMap(); - if (rdColorMap == null) { - request.colorMap = new HashMap(); - } else { - request.colorMap = new HashMap(rdColorMap); - } - - request.shaded = true; - - OutlineCapability outCap = getCapability(OutlineCapability.class); - if ((outCap != null) && outCap.isOutlineOn()) { - request.outlined = true; - } - - // if the database response has changed OR a redraw is being forced - // the background, outlines, and shapes all need rebuilt. - if (newDbData) { - killBackground = true; - killOutline = true; - killShapes = true; - runShapeJob = true; - } - - // if the visible table has changed - List chosenTables = resourceData.getTables(); - if ((chosenTables == null) || !chosenTables.equals(oldSTables)) { - killBackground = true; - killOutline = true; - if (chosenTables != null) { - oldSTables = new ArrayList(chosenTables); - } - runShapeJob = true; - } - - // if the color map has changed - if (!colorMap.equals(request.colorMap)) { - colorMap = request.colorMap; - killShapes = true; - runShapeJob = true; - } - - if (killBackground) { - request.background = null; - } - if (killOutline) { - request.outline = null; - request.cwaOutline = null; - } - - if (killShapes) { - // Get rid of all the shapes - if (request.groupShapes != null) { - for (int idx = 0; idx < request.groupShapes.size(); idx++) { - request.groupShapes.set(idx, null); - } - } - request.reason = newDbData ? "new database response" - : "new color map"; - } else { - // if the membership of any group has changed - int groupNum; - boolean kill; - StringBuilder reasonReason = new StringBuilder(); - for (groupNum = 0; groupNum < request.groups.size(); groupNum++) { - kill = false; - if (oldGroups == null) { - // Need to build shape for the new group - reasonReason.append(" oldGroups is null"); - kill = true; - } else if (groupNum >= oldGroups.size()) { - // Need to build shape for the new group - reasonReason.append(" gn>").append(oldGroups.size()); - kill = true; - } else if (!(request.groups.get(groupNum).equals(oldGroups - .get(groupNum)))) { - // Need to build for changed zone membership - reasonReason.append(String.format(" g[%d]!=old %s!=%s", - groupNum, request.groups.get(groupNum).toString(), - oldGroups.get(groupNum).toString())); - kill = true; - } - if (kill) { - if (groupNum < groupShapes.size()) { - request.groupShapes.set(groupNum, null); - } else { - request.groupShapes.add(null); - } - request.reason = "Groups changed" + reasonReason; - runShapeJob = true; - } - } - for (; groupNum < request.groupShapes.size(); groupNum++) { - if (request.groupShapes.get(groupNum) != null) { - // Rebuild to remove shapes for groups that are gone - request.groupShapes.set(groupNum, null); - if (request.reason == null) { - request.reason = "Extra group shapes"; - } - runShapeJob = true; - } - } - } - // leave("dropObsoleteShapes"); - return request; - } - - /** - * Build the shapes that will be drawn to the screen. - */ - protected void buildShapes(Object rspA) { - // enter("buildShapes"); - if (dbData != null) { - - ShapeBuilderRequest request = dropObsoleteShapes(rspA != null); - - if (runShapeJob) { - - oldGroups = new ArrayList>(groups.size()); - for (List group : groups) { - oldGroups.add(new ArrayList(group)); - } - groups.clear(); - for (List group : request.groups) { - groups.add(new ArrayList(group)); - } - shpRqNum = (shpRqNum + 1) % 10000; - request.id = shpRqNum; - while (!shapeBuilderJob.requestQueue.offer(request)) { - shapeBuilderJob.requestQueue.poll(); - } - shapeBuilderJob.schedule(); - runShapeJob = false; - // log(Priority.VERBOSE, "ShapeBuilderJob " + shpRqNum - // + " scheduled."); - } - - // Get the shapes from shapeBuilderJob (request may have been sent - // in an earlier paint() call). - ShapeBuilderResponse rsp = shapeBuilderJob.responseQueue.poll(); - if (rsp != null) { - - // log(Priority.VERBOSE, "ShapeBuilderJob response " + rsp.id - // + " received."); - if (rsp.background != null) { - if (background != null) { - background.reset(); - } - background = rsp.background; - // log(Priority.VERBOSE, "background replaced."); - } - if (rsp.outline != null) { - if (outline != null) { - outline.reset(); - } - outline = rsp.outline; - // log(Priority.VERBOSE, "outline replaced."); - } - if (rsp.cwaOutline != null) { - if (cwaOutline != null) { - cwaOutline.reset(); - } - cwaOutline = rsp.cwaOutline; - // log(Priority.VERBOSE, "cwaOutline replaced."); - } - if (rsp.groupShapes != null) { - if (groupShapes != null) { - int dispCount = 0; - int rspSize = (rsp.groupShapes == null) ? 0 - : rsp.groupShapes.size(); - // Dispose of any group shapes that have been - // replaced - for (int groupNum = 0; groupNum < groupShapes.size(); groupNum++) { - IShadedShape shape = groupShapes.get(groupNum); - if (shape != null) { - if ((groupNum >= rspSize) - || (shape != rsp.groupShapes - .get(groupNum))) { - shape.dispose(); - dispCount++; - } - } - } - if (dispCount > 0) { - // log(Priority.VERBOSE, "" + dispCount - // + " group shapes disposed."); - } - } - groupShapes = rsp.groupShapes; - } - colorMap.putAll(rsp.colorMap); - Map rdColorMap = resourceData.getColorMap(); - if (colorMap.size() > rdColorMap.size()) { - for (Object obj : colorMap.keySet()) { - if (!rdColorMap.containsKey(obj)) { - rdColorMap.put(obj, colorMap.get(obj)); - } - } - } - } - } - // leave("buildShapes"); - } - - /** - * Paint the shapes created by buildShapes(). This method should only be - * called from within paint(). - * - * @param target - * The graphics target on which to paint the shapes - * @param paintProps - * the paint properties supplied to paint() - * @throws VizException - * if thrown by target.drawXXX() methods - */ - protected void paintShapes() throws VizException { - float alpha = paintProps.getAlpha(); - - // Draw the colored areas - // draw the background - if ((background != null) && background.isDrawable()) { - target.drawShadedShape(background, alpha); - } - - // Draw the zone outlines on top of the shaded shapes - OutlineCapability outCap = getCapability(OutlineCapability.class); - if ((outCap != null) && outCap.isOutlineOn()) { - if ((outline != null) && outline.isDrawable() - && (cwaOutline != null) && cwaOutline.isDrawable()) { - // draw zones in group color - // (in single selection mode, selection is first group) - if (groupShapes != null) { - for (IShadedShape groupShape : groupShapes) { - if ((groupShape != null) && groupShape.isDrawable()) { - target.drawShadedShape(groupShape, alpha); - } - } - } - } - - int outlineWidth = outCap.getOutlineWidth(); - LineStyle lineStyle = outCap.getLineStyle(); - - // Draw the zone outlines - if ((outline != null) && outline.isDrawable()) { - target.drawWireframeShape(outline, - resourceData.getOutlineColor(), outlineWidth, lineStyle); - } - - // Draw the highlighted zone outlines on top of the zone borders - // (for zones that are in this site's CWA) - if ((cwaOutline != null) && cwaOutline.isDrawable()) { - target.drawWireframeShape(cwaOutline, - resourceData.getCwaColor(), outlineWidth, lineStyle); - } - } - - // Draw the labels on top of everything else - if (labelMap != null) { - paintLabels(); - } - } - - /** - * Return the available simplification levels for the specified table. - * - * @return the levels - */ - protected List querySimpLevels(String table) { - List levels = null; - try { - StringBuilder query = new StringBuilder( - "SELECT f_geometry_column FROM public.geometry_columns WHERE f_table_schema='"); - query.append(MAP_SCHEMA); - query.append("' AND f_table_name='"); - query.append(table); - query.append("' AND f_geometry_column LIKE 'the_geom_%' order by f_geometry_column asc;"); - List results = DirectDbQuery.executeQuery( - query.toString(), MAP_DB, QueryLanguage.SQL); - - levels = new ArrayList(results.size()); - for (Object[] obj : results) { - String s = ((String) obj[0]).substring(9).replace('_', '.'); - levels.add(Double.parseDouble(s)); - } - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error querying available levels", e); - } - - return levels; - } - - /** - * Get the color that has been chosen for the designated object. If no color - * has been set, return a random color. - * - * @param key - * The object to look up - * @return The color in which the object should be drawn. - */ - protected RGB getColor(Object key) { - if (colorMap == null) { - colorMap = new HashMap(); - } - RGB color = colorMap.get(key); - if (color == null) { - color = new RGB(rand.nextInt(206) + 50, rand.nextInt(206) + 50, - rand.nextInt(206) + 50); - colorMap.put(key, color); - } - - return color; - } - - /** - * @return the dirty flag - */ - public boolean isDirty() { - return dirty; - } - - /** - * @param dirty - * the dirty flag value to set - */ - public void setDirty(boolean dirty) { - this.dirty = dirty; - } - - /** - * Expand the screen extent by EXPANSION_FACTOR. - * - * @param screenExtent - * The extent of the screen in pixel coordinates. - * - * @return the expanded pixel extent - */ - protected PixelExtent getExpandedExtent(PixelExtent screenExtent) { - PixelExtent expandedExtent = screenExtent.clone(); - expandedExtent.getEnvelope().expandBy( - expandedExtent.getWidth() * EXPANSION_FACTOR, - expandedExtent.getHeight() * EXPANSION_FACTOR); - return expandedExtent; - } - - /** - * Get the suffix for the_geom in queries against table based on the degrees - * per pixel estimate. - * - * @param table - * The name of the table in the query - * @param dpp - * The degrees per pixel estimate - * @return The simplification level suffix. - */ - protected String simpLvlSuffix(String table, double dpp) { - String suffix = ""; - double simpLev = 0.0; - List levels = availSimpLevMap.get(table); - if (levels != null) { - for (double level : levels) { - if (dpp < level) { - break; - } - simpLev = level; - } - } - if (simpLev > 0.0) { - DecimalFormat df = new DecimalFormat("0.######"); - suffix = "_" - + StringUtils.replaceChars(df.format(simpLev), '.', '_'); - } - return suffix; - } - - /** - * Returns a copy of the zoneGroupings list. - *

- * The original code in ZoneFileResource was much more complicated, but it - * seemed anxious to make certain that callers received a copy of a list of - * strings, not the original list. The calls to Collections.unmodifiableList - * generate warnings, so they are suppressed. It would be used on a per-line - * basis, but the compiler gets confused. - * - * @return the list of zone groupings. Each zone grouping is a List of - * Strings, the zone IDs of the zones in the group. - */ - public List> getZoneGroupings() { - - List> rtnVal = new ArrayList>(groups.size()); - for (List zoneGrouping : groups) { - rtnVal.add(Collections.unmodifiableList(zoneGrouping)); - } - - rtnVal = Collections.unmodifiableList(rtnVal); - - return rtnVal; - } - - public void setLabelZones(boolean labelZones) { - this.labelZones = labelZones; - refreshSelections(); - } - - public void setLabelGroups(boolean labelGroups) { - getCapability(ZoneGroupableCapability.class).setZoneGrouping( - labelGroups); - refreshSelections(); - } - - /** - * Add missing zones into one or more groups. - * - * @param includeAllZones - * - True add zone labels - * @param addToOneGroup - * - True add missing zones to first group otherwise put each - * missing zone its own group - * @return msg - Message indicating what zones were added - */ - public String setIncludeAllZones(boolean includeAllZones, - boolean addToOneGroup) { - StringBuilder sb = new StringBuilder(); - if (includeAllZones && (zoneData != null)) { - List missing = new ArrayList(); - for (DbData zoneRec : zoneData) { - boolean found = false; - for (List group : groups) { - if (group.contains(zoneRec.zone)) { - found = true; - break; - } - } - if (!found && !missing.contains(zoneRec.zone)) { - missing.add(zoneRec.zone); - sb.append(zoneRec.zone).append(","); - } - } - - List group = null; - if (addToOneGroup) { - group = groups.get(0); - for (String zone : missing) { - group.add(zone); - } - } else { - // When only an empty group remove so zone numbers start at one. - if (groups.size() == 1 && groups.get(0).size() == 0) { - groups.clear(); - } - - for (String zone : missing) { - group = new ArrayList(); - group.add(zone); - groups.add(group); - } - } - - if (sb.length() > 0) { - signalZonesChanged(); - sb.insert(0, "Missing zones have been added ["); - sb.replace(sb.length() - 1, sb.length(), "]"); - } - } - return sb.toString(); - } - - /** - * Remove all zones from any group. - */ - public void clearAllZones() { - groups.clear(); - groups.add(new ArrayList()); - signalZonesChanged(); - } - - public Envelope getBoundingEnvelope() { - return this.boundingEnvelope; - } - - public void setBoundingEnvelope(Envelope boundingEnvelope) { - this.boundingEnvelope = boundingEnvelope; - setFilthy(true); - } - - public void setMakeHazardType() { - displayType = DisplayType.MAKE_HAZARD; - } - - public void setGHGType() { - displayType = DisplayType.GHG_MONITOR; - } - - public void setSingleAllowableType() { - displayType = DisplayType.SINGLE_ZONE_ALLOWABLE; - } - - /** - * @return the colorMap - */ - public Map getColorMap() { - return resourceData.getColorMap(); - } - - /** - * @param colorMap - * the colorMap to set - */ - public void setColorMap(Map colorMap) { - resourceData.setColorMap(colorMap); - } - - /** - * Set the site ID of the CWA site. - * - * @param cwaIdentifier - * The site ID of the CWA site. - */ - public void setCwaId(String cwaIdentifier) { - cwaID = cwaIdentifier; - if (shapeBuilderJob != null) { - shapeBuilderJob.setCwaID(cwaID); - } - setFilthy(true); - } - - /** - * Re-calculate the bounding box to center the view around the CWA, with a - * "reasonable" margin. The CWA column and CWA ID must be set before this - * method is called, so that the database can be queried for the CWA - * geometry. Although it's somewhat redundant, setBoundingEnvelope() should - * be called before this method, since this method will not set a bounding - * geometry if there are database or geometry-parsing errors. - */ - public void fitToCWA() { - - if ((cwaID == null) || "".equals(cwaID)) { - throw new IllegalStateException("The CWA ID has not been set."); - } - - // build a query - StringBuilder query = new StringBuilder(); - query.append("SELECT"); - query.append(" AsBinary(ST_Envelope(ST_Collect(ST_Envelope(main.the_geom))))"); - query.append(" FROM"); - query.append(" ").append(MAP_SCHEMA).append(".").append(PUBLIC_TABLE) - .append(" as main"); - query.append(" WHERE"); - query.append(" main.cwa LIKE '").append(cwaID).append("%'"); - query.append(" UNION ("); - query.append("SELECT"); - query.append(" AsBinary(ST_Envelope(ST_Collect(ST_Envelope(main.the_geom))))"); - query.append(" FROM"); - query.append(" ").append(MAP_SCHEMA).append(".").append(MARINE_TABLE) - .append(" as main"); - query.append(" WHERE"); - query.append(" main.wfo LIKE '").append(cwaID).append("%'"); - query.append(")"); - query.append(" UNION ("); - query.append("SELECT"); - query.append(" AsBinary(ST_Envelope(ST_Collect(ST_Envelope(main.the_geom))))"); - query.append(" FROM"); - query.append(" ").append(MAP_SCHEMA).append(".").append(OFFSHORE_TABLE) - .append(" as main"); - query.append(" WHERE"); - query.append(" main.wfo LIKE '").append(cwaID).append("%'"); - query.append(")"); - query.append(";"); - - Exception failure = null; - Geometry cwaGeometry = null; - try { - // Get the geometries in the CWA - List result = DirectDbQuery.executeQuery( - query.toString(), MAP_DB, QueryLanguage.SQL); - if ((result != null) && (result.size() > 0)) { - WKBReader wkbReader = new WKBReader(); - Geometry geometry = null; - // Combine the geometries in the CWA into one geometry - for (Object[] row : result) { - byte[] wkb = (byte[]) row[0]; - // areas w/o marine zones return a row containing null - if (wkb != null) { - geometry = wkbReader.read(wkb); - if (cwaGeometry == null) { - cwaGeometry = geometry; - } else { - cwaGeometry = cwaGeometry.union(geometry); - } - } - } - } - } catch (VizException e) { - failure = e; - } catch (ParseException e) { - failure = e; - } - - if (failure == null) { - if (cwaGeometry == null) { - failure = new IllegalArgumentException( - "The CWA query returned no records."); - } else if (cwaGeometry.isEmpty()) { - failure = new IllegalArgumentException( - "The CWA geometry is empty."); - } - } - - if (failure == null) { - // calculate a bounding geometry from cwaGeometry - Geometry cwaBBox = cwaGeometry.getEnvelope(); - // double cwaDist = cwaBBox.getArea(); - // cwaDist = Math.sqrt(cwaDist); - // cwaDist *= BUFFER_MULT; - // Geometry shrinkWrapGeometry = cwaBBox.buffer(cwaDist); - // setBoundingEnvelope(shrinkWrapGeometry.getEnvelopeInternal()); - setBoundingEnvelope(cwaBBox.getEnvelopeInternal()); - } else { - statusHandler - .handle(Priority.PROBLEM, - "Error fitting view to CWA - default bounding geometry will be used", - failure); - } - } - - /** - * Return the geometry to which the clicked point belongs. - * - * @param aLatLon - * Coordinates of a point in Latitude/Longitude space - * @return the Geometry (within this resource) in which aLatLon lies, or - * null if the point lies outside all this resource's geometries. - */ - public Geometry clickOnExistingGeometry(Coordinate aLatLon) { - Point p = new GeometryFactory().createPoint(aLatLon); - for (Geometry g : zoneMap.keySet()) { - if (g.contains(p)) { - return g; - } - } - return null; - } - - /** - * @param zones - * @param groupNum - */ - public void addZone(List zones, int groupNum) { - updateZones(zones, groupNum); - } - - /** - * Add the specified geometries to the group indicated by zoneIndex - * - * @param geoms - * The geometries to add to the group - * @param zoneIndex - * The group number to which the geometries should be added. - */ - public void updateZones(List geoms, int zoneIndex) { - if (zoneIndex < NO_GROUP) { - throw new IllegalArgumentException("Illegal zone index " - + zoneIndex); - } - for (Geometry geometry : geoms) { - // get the zone id for the geometry - String zoneId = zoneMap.get(geometry); - // remove that zone ID from all groups - updateZone(zoneId, zoneIndex); - } - } - - /** - * Adds a single zone ID to the indicated group. - * - * @param zoneId - * The zone ID string, i.e., 'NEZ007'. - * @param zoneIndex - * The group number to assign the group to. - */ - public void updateZone(String zoneId, int zoneIndex) { - - if (zoneId != null) { - for (List zoneGroup : groups) { - zoneGroup.remove(zoneId); - } - if (zoneIndex >= 0) { - while (zoneIndex > groups.size() - 1) { - groups.add(new ArrayList()); - } - Map rscCmap = resourceData.getColorMap(); - if (rscCmap != null) { - Integer ziInteger = Integer.valueOf(zoneIndex); - RGB idxColor = rscCmap.get(ziInteger); - if (idxColor == null) { - idxColor = new RGB(rand.nextInt(206) + 50, - rand.nextInt(206) + 50, rand.nextInt(206) + 50); - rscCmap.put(ziInteger, idxColor); - } - } - // add zoneId to zoneIndex'th group - List zoneGroup = groups.get(zoneIndex); - // sort zones within group so trivial changes don't cause - // shaded shape generation - String[] zoneGroupA = zoneGroup.toArray(new String[0]); - int idx = Arrays.binarySearch(zoneGroupA, zoneId); - if (idx < 0) { - idx = Math.abs(idx) - 1; - } - zoneGroup.add(idx, zoneId); - } - } - signalZonesChanged(); - } - - /** - * Get the group number for geom. If geom is not in a group, return -1. - * - * @param geom - * The geometry whose group # is to be determined. - * @return The group number for the geometry, or -1 if the geometry is not - * in any group. - */ - public int getZoneIndex(Geometry geom) { - String zoneId = zoneMap.get(geom); - return getZoneIndex(zoneId); - } - - /** - * Get the zone ID from the geometry. - * - * @param geom - * - Geometry for the zone - * @return zoneId - when geom is associated with a zone otherwise null - */ - public String getZoneId(Geometry geom) { - return zoneMap.get(geom); - } - - /** - * Get the group number for the zone with the given ID. If zoneId is not in - * a group, return -1. - * - * @param zoneId - * the The zone ID whose group # is to be determined. - * @return The group number for the zone ID, or -1 if the zone ID is not in - * any group. - */ - public int getZoneIndex(String zoneId) { - for (int i = 0; i < groups.size(); i++) { - List group = groups.get(i); - if ((group != null) && group.contains(zoneId)) { - return i; - } - } - return NO_GROUP; - } - - /** - * - */ - public void refreshSelections() { - setDirty(true); - } - - public void compactList() { - // remove empty groups - int i = 0; - while (i < groups.size()) { - if (groups.get(i).size() > 0) { - i++; - } else { - groups.remove(i); - } - } - } - - /** - * Move or clear the list of groups based on the desired zone operation. - * - * @param selectedGroups - * - List of groups to move/clear - * @param operation - * The zone operation to perform - */ - // public void moveGroup(final List> selectedGroups, - // final ZoneOperation operation) { - // - // // Nothing to do return without marking dirty. - // if (selectedGroups.size() == 0) { - // return; - // } - // - // // clean up the groups then get a sorted list of the indices. - // cleanup(groups); - // int selIdx = 0; - // int[] selectedIndices = new int[selectedGroups.size()]; - // for (List group : selectedGroups) { - // selectedIndices[selIdx++] = groups.indexOf(group); - // } - // Arrays.sort(selectedIndices); - // - // int idx = -1; - // List temp; - // switch (operation) { - // case CLEAR: - // for (idx = 0; idx < selectedIndices.length; ++idx) { - // groups.get(selectedIndices[idx]).clear(); - // } - // break; - // case MOVE_DOWN: - // selIdx = selectedIndices.length - 1; - // if (selectedIndices[selIdx] < groups.size() - 1) { - // for (selIdx = selectedIndices.length - 1; selIdx >= 0; --selIdx) { - // idx = selectedIndices[selIdx]; - // temp = groups.get(idx + 1); - // groups.set(idx + 1, groups.get(idx)); - // groups.set(idx, temp); - // } - // } - // break; - // case MOVE_UP: - // selIdx = 0; - // if (selectedIndices[selIdx] > 0) { - // for (selIdx = 0; selIdx < selectedIndices.length; ++selIdx) { - // idx = selectedIndices[selIdx]; - // temp = groups.get(idx - 1); - // groups.set(idx - 1, groups.get(idx)); - // groups.set(idx, temp); - // } - // } - // break; - // case MOVE_TO_BOTTOM: - // selIdx = selectedIndices.length - 1; - // if (selectedIndices[selIdx] < groups.size() - 1) { - // int delta = groups.size() - selectedIndices[selIdx] - 1; - // for (selIdx = selectedIndices.length - 1; selIdx >= 0; --selIdx) { - // idx = selectedIndices[selIdx]; - // temp = groups.remove(idx); - // groups.add(idx + delta, temp); - // } - // } - // break; - // case MOVE_TO_TOP: - // selIdx = 0; - // if (selectedIndices[selIdx] > 0) { - // int delta = selectedIndices[selIdx]; - // for (selIdx = 0; selIdx < selectedIndices.length; ++selIdx) { - // idx = selectedIndices[selIdx]; - // temp = groups.remove(idx); - // groups.add(idx - delta, temp); - // } - // // cleanup(groups); - // } - // break; - // default: - // statusHandler.handle(Priority.PROBLEM, "Unknown move code " - // + operation); - // } - // - // setDirty(true); - // } - - /** - * Remove nulls and empty lists from list. - * - * @param list - * a list of lists, possibly containing nulls - */ - private void cleanup(List> list) { - Iterator> it = list.iterator(); - while (it.hasNext()) { - List litem = it.next(); - if ((litem == null) || litem.isEmpty()) { - it.remove(); - } - } - } - - /** - * Get the geometry type string from the database metadata. - * - * @return the geometry type string - */ - protected String getGeometryType() { - if (geometryType == null) { - try { - String table = resourceData.getMainTable(); - StringBuilder query = new StringBuilder( - "SELECT type FROM public.geometry_columns WHERE f_table_schema='"); - query.append(MAP_SCHEMA); - query.append("' AND f_table_name='"); - query.append(table); - query.append("' LIMIT 1;"); - List results = DirectDbQuery.executeQuery( - query.toString(), MAP_DB, QueryLanguage.SQL); - - geometryType = (String) results.get(0)[0]; - } catch (Throwable e) { - statusHandler.handle(Priority.PROBLEM, - "Error querying geometry type", e); - } - } - - return geometryType; - } - - /** - * @return true if the zones in the resource are described by lines. - */ - protected boolean isLineal() { - return getGeometryType().endsWith("LINESTRING"); - } - - /** - * @return true if the zones in the resource are described by polygons. - */ - protected boolean isPolygonal() { - return getGeometryType().endsWith("POLYGON"); - } - - /** - * @return true if the zones in the resource are described by points. - */ - protected boolean isPuntal() { - return getGeometryType().endsWith("POINT"); - } - - public void setZoneIdsToShow(String[] zoneIdsToShow) { - groups.get(SELECTION_GROUP).clear(); - List selectedZones = expandZones(zoneIdsToShow); - for (String zoneId : selectedZones) { - updateZone(zoneId, SELECTION_GROUP); - } - refreshSelections(); - } - - /** - * The GeoID of a warning sometimes contains entries of the form NEZ001>003. - * This is a shorthand for NEZ001, NEZ002, NEZ003. This method takes the - * input array of strings and creates a List of strings consisting of the - * expanded zone entries. - * - * @param zoneIdsToShow - * A list of zone IDs, possibly containing consecutive-zone - * shorthand. - * @return The input list, with zone shorthand expanded. - */ - private List expandZones(String[] zoneIdsToShow) { - List selectedZones = null; - if (zoneIdsToShow == null) { - selectedZones = new ArrayList(0); - } else { - // A pattern for multi-zone regions. - Pattern consecZonePat = Pattern - .compile("\\s*(\\w{2})(\\w+)(\\d{3})>(\\d{3})\\s*"); - - // The number of selected zones will be at least the same length - // as zoneIdsToShow - selectedZones = new ArrayList(zoneIdsToShow.length); - - for (String zid : zoneIdsToShow) { - - Matcher csecMatch = consecZonePat.matcher(zid); - if (csecMatch.matches()) { - // Extract the pieces of the zones from the match - String st = csecMatch.group(1); - String ztype = csecMatch.group(2); - String startDigits = csecMatch.group(3); - String endDigits = csecMatch.group(4); - - // Convert the start and end strings to integers - int startNum = Integer.valueOf(startDigits); - int endNum = Integer.valueOf(endDigits); - - // Loop from start to end inclusive, generating expanded - // zone IDs - String expanded = null; - for (int zoneNum = startNum; zoneNum <= endNum; zoneNum++) { - expanded = String - .format("%s%s%03d", st, ztype, zoneNum); - selectedZones.add(expanded); - } - - } else { - selectedZones.add(zid); - } - - } - } - - return selectedZones; - } - - /** - * Find the list of zones (in allTables, not just the visible ones) that - * contain the specified coordinate. - * - * @param aLatLon - * a Coordinate - * @return An array of zone ID strings - */ - public String[] getOverlappingZones(Coordinate aLatLon) { - Geometry coordGeom = new GeometryFactory().createPoint(aLatLon); - ArrayList overlappingZones = new ArrayList(); - for (Geometry geom : zoneMap.keySet()) { - if (geom.contains(coordGeom)) { - overlappingZones.add(zoneMap.get(geom)); - } - } - return overlappingZones.toArray(new String[0]); - } - - /** - * Get the zone IDs of all zones that geom overlaps. - *

- * This method was written to help initialize the map in MakeHazardDialog - * from a temporary hazard grid. When it runs, paint() may not have been - * called and/or the database query in paint() may not have completed. We - * also can't use paint()'s method of setting a "try again" flag and letting - * the system re-invoke the method. Furthermore, paint() might actually be - * running, so it could steal our database response if we used the same - * query job. - *

- * The net result of the conditions listed above is that this method has to - * perform its own database query with a local QueryJob and wait for it to - * complete. A listener that notifies the main thread when the query job - * completes is attached to the query job, the query job is scheduled, and - * the main thread waits to be notified. The UI is frozen while we wait, so - * a timed wait is used. This may cause a null to be returned erroneously if - * the database connection is slow. - *

- * The listener is never removed from the job because both are local and go - * out of scope when the method ends. - *

- * This method is also used in MakeHazard to get the zones overlapped by the - * edit area when the user doesn't select any zones in the map. - * - * @param geom - * The geometry that defines the area. - * @param areaThreshold - * A fraction (0.0<=threshold<=1.0) that describes how much of - * the zone's area must be overlapped by the geometry for its ID - * to be in the returned list. - * @return an array of zone IDs - */ - public String[] getOverlappingZones(Geometry geom, double areaThreshold) { - String[] result = null; - - Envelope env = getBoundingEnvelope(); - QueryRequest queryRequest = new QueryRequest(); - queryRequest.query = buildQuery(env, 0.0); - queryRequest.target = null; - QueryJob lqj = new QueryJob("Get overlapping zones"); - lqj.requestQueue.clear(); - lqj.requestQueue.add(queryRequest); - lqj.addJobChangeListener(new JobChangeAdapter() { - @Override - public void done(IJobChangeEvent event) { - synchronized (ZoneDbResource.this) { - ZoneDbResource.this.notify(); - } - } - }); - synchronized (this) { - // calling schedule inside synch block ensures wait() sees notify() - lqj.schedule(); - try { - wait(25L * 1000L); - } catch (InterruptedException e) { - statusHandler - .handle(Priority.VERBOSE, - "GetOverlappingZones(Geometry): Interrupted during wait()."); - } - } - DbData[] rslt = lqj.responseQueue.poll(); - if (rslt == null) { - // error or slow connection; not sure which - statusHandler - .handle(Priority.VERBOSE, - "GetOverlappingZones(Geometry): No database response was received."); - } else { - List zoneIDs = new ArrayList(rslt.length); - Geometry db_geom; - for (DbData data : rslt) { - db_geom = null; - try { - db_geom = wkbReader.read(data.wkb); - Geometry intersectGeom = db_geom.intersection(geom); - if (intersectGeom.getArea() >= db_geom.getArea() - * areaThreshold) { - zoneIDs.add(data.zone); - } - } catch (ParseException e) { - statusHandler.handle(Priority.PROBLEM, - "Error parsing database geometry.", e); - } - } - result = zoneIDs.toArray(new String[zoneIDs.size()]); - } - - return result; - } - - public String[] getAreaList(Grid2DBit mask, DataManager dm, - double areaThreshold) { - String[] result = null; - - QueryRequest queryRequest = new QueryRequest(); - queryRequest.query = buildEAQuery(); - queryRequest.target = null; - MakeHazardQueryJob lqj = new MakeHazardQueryJob("Get overlapping zones"); - lqj.requestQueue.clear(); - lqj.requestQueue.add(queryRequest); - lqj.addJobChangeListener(new JobChangeAdapter() { - @Override - public void done(IJobChangeEvent event) { - synchronized (ZoneDbResource.this) { - ZoneDbResource.this.notify(); - } - } - }); - synchronized (this) { - // calling schedule inside synch block ensures wait() sees notify() - lqj.schedule(); - try { - wait(25L * 1000L); - } catch (InterruptedException e) { - statusHandler - .handle(Priority.VERBOSE, - "GetOverlappingZones(Geometry): Interrupted during wait()."); - } - } - MakeHazardDbData[] rslt = lqj.responseQueue.poll(); - if (rslt == null) { - // error or slow connection; not sure which - statusHandler - .handle(Priority.VERBOSE, - "GetOverlappingZones(Geometry): No database response was received."); - } else { - List zoneIDs = new ArrayList(rslt.length); - List refIds = new ArrayList(rslt.length); - for (MakeHazardDbData data : rslt) { - refIds.add(new ReferenceID(data.zone)); - } - - List refDataList = dm.getRefManager() - .getReferenceData(refIds); - for (ReferenceData refData : refDataList) { - Grid2DBit editAreaMask = refData.getGrid(); - Grid2DBit intersect = editAreaMask.and(mask); - float ratio = (float) intersect.numberOfBitsSet() - / (float) editAreaMask.numberOfBitsSet(); - if (ratio >= areaThreshold) { - zoneIDs.add(refData.getId().getName()); - } - } - - result = zoneIDs.toArray(new String[zoneIDs.size()]); - } - - return result; - } - - /** - * Return the group # of the first group that contains no zone IDs, or 1 if - * no groups have zone IDs or the display type has been set to MAKE_HAZARD - * or SINGLE_ZONE_ALLOWABLE. - * - * @return A group number - */ - public int getNextIndex() { - - int index = 0; - if (!groups.isEmpty() - && (displayType != DisplayType.SINGLE_ZONE_ALLOWABLE) - && (displayType != DisplayType.MAKE_HAZARD)) { - for (index = 0; index < groups.size(); index++) { - List group = groups.get(index); - if (group.isEmpty()) { - break; - } - } - } - return index; - } - - /** - * Move a list of zone IDs to the group with the designated index. - * - * @param zoneIds - * A list of zone IDs to assign to the group. - * @param index - * A group number. - */ - public void setGroup(List zoneIds, int index) { - if (index < NO_GROUP) { - throw new IllegalArgumentException("Illegal zone index " + index); - } - for (String zoneId : zoneIds) { - updateZone(zoneId, index); - } - } - - /** - * Add the listener to the listeners that are called when zones change. - * - * @param listener - */ - public void addZoneChangeListener(IZoneChangeListener listener) { - if (!zoneChangeListeners.contains(listener)) { - zoneChangeListeners.add(listener); - } - } - - /** - * Remove the specified listener from the list of zone change listeners, if - * it is in the list. - * - * @param listener - */ - public void removeZoneChangeListener(IZoneChangeListener listener) { - zoneChangeListeners.remove(listener); - } - - /** - * Remove all the zone change listeners. - */ - public void removeAllZoneChangeListeners() { - zoneChangeListeners.clear(); - } - - /** - * Notify listeners that zones have changed. - */ - public void signalZonesChanged() { - for (IZoneChangeListener listener : zoneChangeListeners) { - listener.zoneChanged(); - } - } - - // public List getEditAreaZones(Float areaThreshold) { - // IReferenceSetManager refMgr = DataManager.getCurrentInstance() - // .getRefManager(); - // ReferenceData refData = refMgr.getActiveRefSet(); - // Geometry geom = refData.getPolygons(CoordinateType.GRID); - // String[] zones = getOverlappingZones(geom, areaThreshold); - // return null; - // } - - /** - * Paint the zone and/or group labels. - * - * @throws VizException - * if thrown by paintLabelSet() - */ - protected void paintLabels() throws VizException { - // Draw the labels on top of everything else - if (labelFont == null) { - int fontNum = 2; - if (GFEPreference.contains("ZoneMapLabel_font")) { - fontNum = GFEPreference.getIntPreference("ZoneMapLabel_font"); - } - - labelFont = GFEFonts.getFont(target, fontNum); - } - - if (labelZones) { - paintZoneLabels(); - } - - if (getCapability(ZoneGroupableCapability.class).isZoneGrouping()) { - paintGroupLabels(); - } - } - - /** - * Paint the labels for zones. - * - * @throws VizException - * if thrown by paintLabelSet() - */ - protected void paintZoneLabels() throws VizException { - RGB color = resourceData.getLabelColor(); - GeneralGridGeometry mapGeometry = descriptor.getGridGeometry(); - List refCoordList; - HorizontalAlignment horiz = HorizontalAlignment.CENTER; - VerticalAlignment vert = VerticalAlignment.BOTTOM; - - Collection tables = resourceData.getTables(); - - if (isPuntal()) { - horiz = HorizontalAlignment.LEFT; - vert = VerticalAlignment.TOP; - } - - // draw zone labels - List alreadyDrawn = new ArrayList( - labelMap.size()); - for (DbData data : dbData) { - if (tables.contains(data.tableName)) { - refCoordList = labelMap.get(data.zone); - if (refCoordList != null) { - paintLabelSet(" " + data.zone, labelFont, null, color, - horiz, vert, refCoordList, mapGeometry, "" - + data.zone, alreadyDrawn); - } - } - } - } - - /** - * Paint the labels for groups. - * - * @throws VizException - * if thrown by paintLabelSet() - */ - protected void paintGroupLabels() throws VizException { - RGB color = resourceData.getLabelColor(); - GeneralGridGeometry mapGeometry = descriptor.getGridGeometry(); - List refCoordList; - HorizontalAlignment horiz = HorizontalAlignment.CENTER; - VerticalAlignment vert = VerticalAlignment.TOP; - - if (isPuntal()) { - horiz = HorizontalAlignment.LEFT; - vert = VerticalAlignment.TOP; - } - - // draw group labels - List alreadyDrawn = new ArrayList( - labelMap.size()); - for (Collection group : groups) { - int groupNum = groups.indexOf(group); - if (group != null) { - for (String zone : group) { - refCoordList = labelMap.get(zone); - if (refCoordList != null) { - paintLabelSet(" " + (groupNum + 1), labelFont, - IGraphicsTarget.TextStyle.DROP_SHADOW, color, - horiz, vert, refCoordList, mapGeometry, "" - + zone, alreadyDrawn); - } - } - } - } - } - - /** - * Paint text, with the specified appearance options, at the locations given - * by refCoordList. The referenced coordinates are converted to screen - * coordinates with mapGeometry. Labels are filtered according to a distance - * function; any label whose coordinates are too close to a label that has - * already been drawn is skipped. As each label is painted, its location is - * added to the list of labels that have already been drawn. - *

- * The distance function (abs(xdiff)+abs(ydiff)) is the same one used in - * AWIPS I. - *

- * The "too close" value is given by MIN_LABEL_DISTANCE. - * - * @param text - * The text to draw - * @param font - * The font in which to draw the text - * @param style - * The style in which to draw the text - * @param color - * The color in which to draw the text - * @param horiz - * The horizontal alignment of the text - * @param vert - * The vertical alignment of the text - * @param refCoordList - * The list of referenced coordinates at which to draw the text - * @param mapGeometry - * The geometry used to convert referenced coordinates to pixel - * coordinates - * @param alreadyDrawn - * The pixel coordinates of labels that have already been drawn. - * @throws VizException - * if thrown by target.drawString - */ - protected void paintLabelSet(String text, IFont font, - IGraphicsTarget.TextStyle style, RGB color, - HorizontalAlignment horiz, VerticalAlignment vert, - List refCoordList, - GeneralGridGeometry mapGeometry, String zone, - List alreadyDrawn) throws VizException { - - Coordinate coord; - DrawableString ds = new DrawableString("", color); - ds.font = font; - ds.addTextStyle(TextStyle.DROP_SHADOW); - ds.horizontalAlignment = horiz; - ds.verticallAlignment = vert; - refcLoop: for (ReferencedCoordinate refCoord : refCoordList) { - try { - coord = refCoord.asPixel(mapGeometry); - for (LabelTuple old : alreadyDrawn) { - if (old.zone.equals(zone) && old.text.equals(text)) { - double distance = scaleX * Math.abs(old.x - coord.x) - + scaleY * Math.abs(old.y - coord.y); - if (distance < MIN_LABEL_DISTANCE) { - continue refcLoop; - } - } - } - ds.setText(text, color); - ds.setCoordinates(coord.x, coord.y); - target.drawStrings(ds); - alreadyDrawn.add(new LabelTuple(coord.x, coord.y, text, zone)); - } catch (TransformException e) { - statusHandler.handle(Priority.PROBLEM, - "Error transforming geometry for " + text, e); - } catch (FactoryException e) { - statusHandler.handle(Priority.PROBLEM, "FactoryException for " - + text, e); - } - } - } - - /** - * A class for keeping track of which labels have been drawn. - * - *

-     * 
-     * SOFTWARE HISTORY
-     * 
-     * Date         Ticket#    Engineer    Description
-     * ------------ ---------- ----------- --------------------------
-     * Oct 13, 2010            wldougher     Initial creation
-     * 
-     * 
- * - * @author wldougher - * @version 1.0 - */ - private class LabelTuple { - public double x; - - public double y; - - public String text; - - public String zone; - - public LabelTuple(double x, double y, String text, String zone) { - this.x = x; - this.y = y; - this.text = text; - this.zone = zone; - } - } - - // private LinkedList methodNames = new LinkedList(); - - // private LinkedList methodDates = new LinkedList(); - - // private void enter(String methodName) { - // methodNames.push(methodName); - // methodDates.push(new Long(System.currentTimeMillis())); - // log(Priority.VERBOSE, methodName + "() entered."); - // } - - // private void leave(String methodName) { - // long now = System.currentTimeMillis(); - // int idx = methodNames.indexOf(methodName); - // if (idx < 0) { - // log(Priority.VERBOSE, - // "leave() called without matching enter() for " + methodName - // + "()."); - // return; - // } - // String name = null; - // Long stime = null; - // StringBuilder sb = new StringBuilder(); - // long dur = 0; - // do { - // name = methodNames.pop(); - // stime = methodDates.pop(); - // dur = now - stime.longValue(); - // sb.setLength(0); - // sb.append(name).append("() completed. duration=").append(dur) - // .append(" ms"); - // if (!name.equals(methodName)) { - // sb.append(" (unmatched)"); - // } - // log(Priority.VERBOSE, sb.toString()); - // } while (!name.equals(methodName)); - // } -} diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/sampler/HistoSampler.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/sampler/HistoSampler.java index 8421dc68cf..a19b7ddb3d 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/sampler/HistoSampler.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/sampler/HistoSampler.java @@ -28,29 +28,34 @@ import java.util.List; import java.util.Map; import java.util.Set; +import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID; +import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice; +import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice; +import com.raytheon.uf.common.gfe.ifpclient.IFPClient; 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.TimeRange; -import com.raytheon.viz.gfe.GFEServerException; -import com.raytheon.viz.gfe.core.DataManager; -import com.raytheon.viz.gfe.core.internal.IFPClient; /** * Samples grid data and creates histogram * *
+ * 
  * SOFTWARE HISTORY
- * Date			Ticket#		Engineer	
- * ------------	----------	-----------	--------------------------
- * Jun 5, 2008	1167		mnash	     Initial creation
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 05, 2008 1167        mnash        Initial creation
  * Jul 11, 2008 1167        mnash        Fixed responses from IFPClient
- * Sep 3, 2008  1283        njensen      Fixed issues
+ * Sep 03, 2008 1283        njensen      Fixed issues
  * Aug 19, 2009 2899        njensen      Maps for performance boost on getParmHisto()
+ * Dec 09, 2015 5129        dgilling     Support new IFPClient.
+ * 
  * 
* * @author mnash @@ -98,10 +103,8 @@ public class HistoSampler { * * @param client * @param requests - * @throws GFEServerException */ - public HistoSampler(IFPClient client, ArrayList requests) - throws GFEServerException { + public HistoSampler(IFPClient client, ArrayList requests) { _valid = true; statusHandler.handle(Priority.DEBUG, "Requests " + requests); // convert ids to reference data objects @@ -270,27 +273,26 @@ public class HistoSampler { private List getReferenceData(IFPClient client, final List requests) { // determine list of edit areas to retrieve - ArrayList need = new ArrayList( - requests.size()); - for (int i = 0; i < requests.size(); i++) { - if (requests.get(i).isRefID() - && (need.contains(requests.get(i).areaID()) == false)) { - need.add(requests.get(i).areaID()); + List need = new ArrayList(requests.size()); + for (SamplerRequest request : requests) { + if (request.isRefID() && (!need.contains(request.areaID()))) { + need.add(request.areaID()); } } + // retrieve them - List refAreas = client.getReferenceData(need); - for (int i = 0; i < refAreas.size(); i++) { - if (refAreas.get(i) == null) { - statusHandler.handle(Priority.PROBLEM, "Edit area : " + i - + " not available in server"); - _valid = false; - } else { - refAreas.get(i).getGrid(); - } - if ((i == refAreas.size()) && (_valid == false)) { - return new ArrayList(0); - } + ServerResponse> sr = client.getReferenceData(need); + if (!sr.isOkay()) { + statusHandler + .error(String.format( + "Some edit areas not available in server: %s", + sr.message())); + _valid = false; + return Collections.emptyList(); + } + List refAreas = sr.getPayload(); + for (ReferenceData area : refAreas) { + area.getGrid(); } // put in the reference data objects in place of the reference ids in @@ -354,9 +356,17 @@ public class HistoSampler { } private List requestedGrids(IFPClient client, ParmID parmID, - List sampleTR) throws GFEServerException { + List sampleTR) { // get the inventory for this parm - List gridTimes = client.getGridInventory(parmID); + ServerResponse> sr = client.getGridInventory(parmID); + if (!sr.isOkay()) { + _valid = false; + statusHandler.error(String.format( + "Unable to get grid inventory for: %s %s", parmID, + sr.message())); + return Collections.emptyList(); + } + List gridTimes = sr.getPayload(); // create the needed grid list and return it List ret = new ArrayList(gridTimes.size()); @@ -396,18 +406,17 @@ public class HistoSampler { private List getGrids(IFPClient client, ParmID parmID, List gridTimes) { - - List data; - try { - data = SamplerGridSliceCache.getData(client, parmID, gridTimes); - // data = client.getGridData(parmID, gridTimes); - } catch (GFEServerException e) { + ServerResponse> sr = SamplerGridSliceCache.getData( + client, parmID, gridTimes); + if (!sr.isOkay()) { _valid = false; - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); - data = new ArrayList(0); + statusHandler.error(String.format( + "Getting Grid Data problem for: %s %s", parmID, + sr.message())); + return Collections.emptyList(); } - return data; + return sr.getPayload(); } /** @@ -438,8 +447,26 @@ public class HistoSampler { * @return */ private IGridSlice getTopoGrid(IFPClient client) { - return DataManager.getCurrentInstance().getTopoManager() - .getCompositeTopo(); + // get the grid location + ServerResponse sr = client.getDBGridLocation(); + if (!sr.isOkay()) { + _valid = false; + statusHandler.error(String.format( + "Problem obtaining dbGridLocation: %s", sr.message())); + return null; + } + GridLocation gloc = sr.getPayload(); + + // get the topography grid + ServerResponse sr2 = client.getTopoData(gloc); + if (!sr.isOkay()) { + _valid = false; + statusHandler.error(String.format( + "Problem obtaining topography grid: %s", sr2.message())); + return null; + } + + return sr2.getPayload(); } /** @@ -449,20 +476,19 @@ public class HistoSampler { * @return the ISC ref data */ public List getISCReferenceData(IFPClient client) { - ArrayList idsISC = new ArrayList(); - - List idsAll = client.getReferenceInventory(); - - if (idsAll.isEmpty()) { + ServerResponse> sr = client.getReferenceInventory(); + if (!sr.isOkay()) { _valid = false; - statusHandler.handle(Priority.PROBLEM, - "Error getting ISC Edit Areas"); + statusHandler.error(String.format( + "Error getting ISC Edit Areas: %s", sr.message())); } + List idsAll = sr.getPayload(); // Get the ISC ids + List idsISC = new ArrayList(); for (ReferenceID id : idsAll) { String name = id.getName(); - if ((name.length() > 4) && name.startsWith("ISC_")) { + if ((name.length() > 4) && (name.startsWith("ISC_"))) { idsISC.add(id); } } @@ -471,22 +497,20 @@ public class HistoSampler { // "ISC edit areas: " + idsISC.toString()); // get the ReferenceData objects - List refAreas = client.getReferenceData(idsISC); - for (int i = 0; i < refAreas.size(); i++) { - if (refAreas.get(i) == null) { - statusHandler.handle(Priority.PROBLEM, "ISC edit area " + i - + " not available in server"); - _valid = false; - continue; - } - - refAreas.get(i).getGrid(); - - if ((i == refAreas.size()) && (_valid == false)) { - return Collections.emptyList(); - } + ServerResponse> sr2 = client + .getReferenceData(idsISC); + if (!sr2.isOkay()) { + statusHandler.error(String.format( + "Some ISC edit areas not available in server: %s", + sr.message())); + _valid = false; + return Collections.emptyList(); } + List refAreas = sr2.getPayload(); + for (ReferenceData refArea : refAreas) { + refArea.getGrid(); + } return refAreas; } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/sampler/SamplerGridSliceCache.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/sampler/SamplerGridSliceCache.java index ec4377101a..990cc81289 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/sampler/SamplerGridSliceCache.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/sampler/SamplerGridSliceCache.java @@ -26,10 +26,11 @@ import java.util.List; import java.util.Map; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; +import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; +import com.raytheon.uf.common.dataplugin.gfe.server.request.GetGridRequest; import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice; +import com.raytheon.uf.common.gfe.ifpclient.IFPClient; import com.raytheon.uf.common.time.TimeRange; -import com.raytheon.viz.gfe.GFEServerException; -import com.raytheon.viz.gfe.core.internal.IFPClient; /** * Caches the results of a call to IFPClient.getGridData(ParmID, @@ -62,8 +63,8 @@ public class SamplerGridSliceCache { private static Map>> cache = new HashMap>>(); - public static List getData(IFPClient client, ParmID parmId, - List gridTimes) throws GFEServerException { + public static ServerResponse> getData(IFPClient client, + ParmID parmId, List gridTimes) { List result = new ArrayList(); List needToRequest = new ArrayList(); long thread = Thread.currentThread().getId(); @@ -92,9 +93,12 @@ public class SamplerGridSliceCache { } } - if (needToRequest.size() > 0) { - List retrieved = client.getGridData(parmId, - needToRequest); + ServerResponse> ssr = new ServerResponse<>(); + if (!needToRequest.isEmpty()) { + ServerResponse> sr = client + .getGridData(new GetGridRequest(parmId, needToRequest)); + ssr.addMessages(sr); + List retrieved = sr.getPayload(); // for (IGridSlice slice : retrieved) { // slice.setUseCache(true); // } @@ -103,8 +107,8 @@ public class SamplerGridSliceCache { } Collections.sort(result); - - return result; + ssr.setPayload(result); + return ssr; } public static void remove(long thread) { diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/SmartToolEdit.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/SmartToolEdit.java index 7d0c472f82..fc50cdef8c 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/SmartToolEdit.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/SmartToolEdit.java @@ -20,8 +20,8 @@ package com.raytheon.viz.gfe.smarttool; import java.io.File; -import java.io.FileWriter; import java.io.IOException; +import java.io.OutputStreamWriter; import java.util.Properties; import org.apache.velocity.Template; @@ -40,6 +40,7 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.localization.SaveableOutputStream; import com.raytheon.uf.common.python.PythonFileFilter; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; @@ -53,11 +54,12 @@ import com.raytheon.viz.gfe.PythonUtil; * *
  * SOFTWARE HISTORY
- * Date			Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * Mar 20, 2008				njensen	    Initial creation
- * Sep 25, 2008 1562        askripsky   Moved methods out to
+ * Date         Ticket#     Engineer    Description
+ * ------------ ----------  ----------- --------------------------
+ * Mar 20, 2008             njensen     Initial creation
+ * Sep 25, 2008  1562       askripsky   Moved methods out to
  * Sep 09, 2013 #2033       dgilling    Use new templates directory.
+ * Jan 18, 2016  4834       njensen     Fix creating new files, deleted dead code
  * 
  * 
* @@ -66,6 +68,15 @@ import com.raytheon.viz.gfe.PythonUtil; */ public class SmartToolEdit { + + /* + * TODO Functionality should be consolidated to an extension of + * AbstractScriptUtil to follow the same pattern as when creating other new + * python files for GFE. Currently AbstractScriptUtil does not support extra + * args to velocity like the parmToEdit so it will need to be further + * improved before that is possible. + */ + private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(SmartToolEdit.class); @@ -102,23 +113,22 @@ public class SmartToolEdit { IPathManager pathMgr = PathManagerFactory.getPathManager(); LocalizationContext cx = pathMgr.getContext( LocalizationType.CAVE_STATIC, LocalizationLevel.USER); - localizationFile = PathManagerFactory.getPathManager() - .getLocalizationFile( - cx, - GfePyIncludeUtil.SMART_TOOLS + File.separator - + toolFilename); - if (localizationFile != null) { - File file = localizationFile.getFile(); - if (!file.getParentFile().exists()) { - file.getParentFile().mkdirs(); + String filename = GfePyIncludeUtil.SMART_TOOLS + + IPathManager.SEPARATOR + toolFilename; + localizationFile = pathMgr.getLocalizationFile(cx, filename); + if (!localizationFile.isProtected()) { + try (SaveableOutputStream sos = localizationFile + .openOutputStream(); + OutputStreamWriter writer = new OutputStreamWriter( + sos)) { + template.merge(context, writer); + writer.close(); + sos.save(); + // refresh reference in memory + localizationFile = pathMgr.getLocalizationFile(cx, + filename); + PythonUtil.openPythonFile(localizationFile); } - - FileWriter fw = new FileWriter(localizationFile.getFile()); - - template.merge(context, fw); - fw.close(); - localizationFile.save(); - PythonUtil.openPythonFile(localizationFile); } else { // Display Protected file message Shell shell = PlatformUI.getWorkbench() @@ -140,66 +150,4 @@ public class SmartToolEdit { return localizationFile; } - public static LocalizationFile initializeNewUtility(String utilityName) { - LocalizationFile localizationFile = null; - - String toolFilename = new String(utilityName); - if (!toolFilename.endsWith(PythonFileFilter.EXTENSION)) { - toolFilename += PythonFileFilter.EXTENSION; - } - - try { - File templateFile = new File(FileLocator.resolve( - FileLocator.find(Activator.getDefault().getBundle(), - new Path(SmartToolConstants.TEMPLATES_DIR), null)) - .getPath()); - - try { - Properties p = new Properties(); - p.setProperty("file.resource.loader.path", - templateFile.getPath()); - Velocity.init(p); - VelocityContext context = new VelocityContext(); - - context.put("itemName", utilityName); - String author = LocalizationManager.getInstance() - .getCurrentUser(); - context.put("author", author); - - Template template = null; - template = Velocity.getTemplate("utility.vm"); - - IPathManager pathMgr = PathManagerFactory.getPathManager(); - LocalizationContext cx = pathMgr.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.USER); - localizationFile = PathManagerFactory.getPathManager() - .getLocalizationFile( - cx, - GfePyIncludeUtil.UTILITIES + File.separator - + toolFilename); - File file = localizationFile.getFile(); - if (!file.getParentFile().exists()) { - file.getParentFile().mkdirs(); - } - - FileWriter fw = new FileWriter(localizationFile.getFile()); - - template.merge(context, fw); - fw.close(); - - localizationFile.save(); - - PythonUtil.openPythonFile(localizationFile); - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - "Error creating new utility", e); - } - } catch (IOException e) { - statusHandler.error( - "Error retrieving templates directory for new utility.", e); - } - - return localizationFile; - } - } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/TextFileUtil.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/TextFileUtil.java index cc08bd2b7b..5e5f9b9311 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/TextFileUtil.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/TextFileUtil.java @@ -22,7 +22,6 @@ package com.raytheon.viz.gfe.smarttool; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Paths; @@ -33,8 +32,8 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.localization.SaveableOutputStream; import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; import com.raytheon.uf.common.python.PythonFileFilter; import com.raytheon.viz.gfe.GFEOperationFailedException; @@ -48,6 +47,8 @@ import com.raytheon.viz.gfe.GFEOperationFailedException; * ------------ ---------- ----------- -------------------------- * Apr 28, 2009 njensen Initial creation * Apr 20, 2015 4027 randerso Changes to support GFE formatter auto tests + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs. * * * @@ -93,7 +94,7 @@ public class TextFileUtil { LocalizationContext ctx = PATH_MGR.getContext(source.getContext() .getLocalizationType(), LocalizationLevel.USER); - LocalizationFile destLf = getTextFile(ctx, source.getName()); + LocalizationFile destLf = getTextFile(ctx, source.getPath()); return destLf; } @@ -124,8 +125,7 @@ public class TextFileUtil { } public static void makeWritableCopy(String source, String fileType, - String dest, boolean deleteFlag) throws IOException, - GFEOperationFailedException { + String dest, boolean deleteFlag) throws GFEOperationFailedException { LocalizationFile srcLf = getTextFile(source, fileType); if ((srcLf.getContext().getLocalizationLevel() == LocalizationLevel.BASE) || (srcLf.getContext().getLocalizationLevel() == LocalizationLevel.CONFIGURED) @@ -139,7 +139,6 @@ public class TextFileUtil { getPathFromType(dest, fileType)); try { copy(srcLf, destLf); - destLf.save(); } catch (Exception e) { throw new GFEOperationFailedException( "Unable to save localization file", e); @@ -169,7 +168,7 @@ public class TextFileUtil { Files.createDirectories(dir.toPath()); try (InputStream in = srcLf.openInputStream(); - OutputStream out = destLf.openOutputStream()) { + SaveableOutputStream out = destLf.openOutputStream()) { // Transfer bytes from in to out byte[] buf = new byte[1024]; @@ -177,11 +176,12 @@ public class TextFileUtil { while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } + out.save(); } } public static void deleteTextFile(LocalizationFile lf) - throws LocalizationOpFailedException, IOException { + throws LocalizationException, IOException { if (lf.getContext().getLocalizationLevel() .equals(LocalizationLevel.USER) && lf.getContext().getContextName().equals("GFETEST")) { diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/Tool.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/Tool.java index 0c9bce4441..d464e6ebd8 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/Tool.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/Tool.java @@ -34,7 +34,6 @@ import org.eclipse.swt.widgets.Display; import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory; import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData; -import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory; import com.raytheon.uf.common.python.concurrent.IPythonExecutor; import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator; import com.raytheon.uf.common.status.IPerformanceStatusHandler; @@ -56,7 +55,6 @@ import com.raytheon.viz.gfe.core.parm.Parm; import com.raytheon.viz.gfe.core.parm.ParmState; import com.raytheon.viz.gfe.query.QueryScript; import com.raytheon.viz.gfe.query.QueryScriptExecutor; -import com.raytheon.viz.gfe.query.QueryScriptFactory; import com.raytheon.viz.gfe.smarttool.SmartToolException.ErrorType; import com.raytheon.viz.gfe.smarttool.script.SmartToolRunnerController; @@ -77,6 +75,7 @@ import com.raytheon.viz.gfe.smarttool.script.SmartToolRunnerController; * Aug 27, 2015 4749 njensen Call shutdown() on PythonJobCoordinator * Sep 16, 2015 4871 randerso Return modified varDict from Tool * 10/08/2015 18125 bhunder Modified CANCEL_MSG_START to work with Jep updates + * Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API. * * * @@ -127,22 +126,21 @@ public class Tool { * @throws SmartToolException */ public Tool(IParmManager aParmMgr, Parm anInputParm, String aToolName, + PythonJobCoordinator coordinator, SmartToolRunnerController aTool) throws SmartToolException { - parmMgr = aParmMgr; - inputParm = anInputParm; - toolName = aToolName; - tool = aTool; + this.parmMgr = aParmMgr; + this.inputParm = anInputParm; + this.toolName = aToolName; + this.tool = aTool; + this.coordinator = coordinator; - AbstractPythonScriptFactory factory = new QueryScriptFactory( - DataManagerUIFactory.getCurrentInstance()); - coordinator = PythonJobCoordinator.newInstance(factory); try { - if (!tool.isInstantiated(toolName)) { - tool.instantiatePythonScript(toolName); + if (!this.tool.isInstantiated(toolName)) { + this.tool.instantiatePythonScript(toolName); } } catch (JepException e) { throw new SmartToolException("Error instantiating python tool " - + toolName + ": " + e.getMessage()); + + this.toolName + ": " + e.getMessage()); } } @@ -511,8 +509,8 @@ public class Tool { IPythonExecutor executor = new QueryScriptExecutor( "evaluate", argMap); try { - Tool.this.trueEditArea = coordinator - .submitSyncJob(executor); + Tool.this.trueEditArea = coordinator.submitJob( + executor).get(); } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, "Error re-evaluating edit area " @@ -689,7 +687,6 @@ public class Tool { } } parmMgr.deleteTemporaryParms(); - coordinator.shutdown(); // Report Skipped or Created Grids String msg = "Tool: " + toolname + " -- "; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/UtilitiesScriptUtil.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/UtilitiesScriptUtil.java index 4b242c3f75..9af22df4a7 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/UtilitiesScriptUtil.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/UtilitiesScriptUtil.java @@ -23,7 +23,7 @@ import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil; import com.raytheon.viz.gfe.core.script.AbstractScriptUtil; /** - * TODO Add Description + * An implementation of PythonFileTemplate for making new Utilities. * *
  * 
@@ -31,7 +31,8 @@ import com.raytheon.viz.gfe.core.script.AbstractScriptUtil;
  * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * May 3, 2011            dgilling     Initial creation
+ * May 03, 2011            dgilling    Initial creation
+ * Jan 19, 2016  4834      njensen     Removed dead method
  * 
  * 
* @@ -52,45 +53,16 @@ public class UtilitiesScriptUtil extends AbstractScriptUtil { super(); } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#getFileType() - */ - @Override - public String getFileType() { - return SCRIPT_TYPE.toUpperCase(); - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.script.AbstractScriptUtil#getScriptType() - */ @Override public String getScriptType() { return SCRIPT_TYPE; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.script.AbstractScriptUtil#getScriptTypePathPrefix - * () - */ @Override public String getScriptTypePathPrefix() { return GfePyIncludeUtil.UTILITIES; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.gfe.core.script.AbstractScriptUtil#getVelocityTemplateName - * () - */ @Override protected String getVelocityTemplateName() { return TEMPLATE_FILENAME; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolFactory.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolFactory.java index 829ce0d678..572a04d7c0 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolFactory.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolFactory.java @@ -26,7 +26,7 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.python.PyUtil; import com.raytheon.uf.common.python.PythonIncludePathUtil; -import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory; +import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory; import com.raytheon.uf.common.util.FileUtil; import com.raytheon.viz.gfe.core.DataManager; @@ -41,6 +41,7 @@ import com.raytheon.viz.gfe.core.DataManager; * Jul 9, 2009 2454 ryu Put user and site's python scripts on path for import * May 20, 2015 4509 njensen Added time and dataaccess to include path * Jul 23, 2015 4263 dgilling Refactored to support changes to SmartToolController. + * Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API. * * * @@ -48,14 +49,12 @@ import com.raytheon.viz.gfe.core.DataManager; * @version 1.0 */ -public abstract class SmartToolFactory extends - AbstractPythonScriptFactory { +public abstract class SmartToolFactory + implements PythonInterpreterFactory { protected final DataManager dataMgr; - public SmartToolFactory(String name, int numThreads, - final DataManager dataMgr) { - super(name, numThreads); + public SmartToolFactory(final DataManager dataMgr) { this.dataMgr = dataMgr; } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolJobPool.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolJobPool.java index 80ae1a63cd..5a4015d86d 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolJobPool.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolJobPool.java @@ -358,7 +358,8 @@ public class SmartToolJobPool { dataMgr.getParmOp().clearUndoParmList(); } Tool tool = new Tool(dataMgr.getParmManager(), request - .getPreview().getParm(), ea.getItemName(), controller); + .getPreview().getParm(), ea.getItemName(), dataMgr + .getRefManager().getPythonThreadPool(), controller); tool.execute(ea.getItemName(), request.getPreview().getParm(), ea.getRefSet(), ea.getTimeRange(), request.getVarDict(), ea.getMissingDataMode(), monitor); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolMetadataManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolMetadataManager.java index 9176485503..ecef15d7e1 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolMetadataManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolMetadataManager.java @@ -58,6 +58,7 @@ import com.raytheon.viz.gfe.smartscript.FieldDefinition; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jul 20, 2015 #4263 dgilling Initial creation + * Dec 14, 2015 #4816 dgilling Support refactored PythonJobCoordinator API. * * * @@ -70,6 +71,10 @@ public class SmartToolMetadataManager implements ILocalizationFileObserver { private final IUFStatusHandler statusHandler = UFStatus .getHandler(getClass()); + private static final String THREAD_POOL_NAME = "smart-tool-metadata"; + + private static final int NUM_POOL_THREADS = 1; + private final PythonJobCoordinator jobCoordinator; private final Map toolMetadata; @@ -85,7 +90,8 @@ public class SmartToolMetadataManager implements ILocalizationFileObserver { public SmartToolMetadataManager(final DataManager dataMgr) { SmartToolMetadataScriptFactory scriptFactory = new SmartToolMetadataScriptFactory( dataMgr); - this.jobCoordinator = PythonJobCoordinator.newInstance(scriptFactory); + this.jobCoordinator = new PythonJobCoordinator<>(NUM_POOL_THREADS, + THREAD_POOL_NAME, scriptFactory); this.toolMetadata = new HashMap<>(); this.accessLock = new Object(); @@ -117,7 +123,7 @@ public class SmartToolMetadataManager implements ILocalizationFileObserver { } }; try { - jobCoordinator.submitAsyncJob(executor, listener); + jobCoordinator.submitJobWithCallback(executor, listener); } catch (Exception e1) { statusHandler.error("Error initializing smart tool metadata.", e1); } @@ -247,13 +253,6 @@ public class SmartToolMetadataManager implements ILocalizationFileObserver { } } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.common.localization.ILocalizationFileObserver#fileUpdated - * (com.raytheon.uf.common.localization.FileUpdatedMessage) - */ @Override public void fileUpdated(FileUpdatedMessage message) { SmartToolMetadataExecutor executor = new SmartToolMetadataExecutor( @@ -272,7 +271,7 @@ public class SmartToolMetadataManager implements ILocalizationFileObserver { } }; try { - jobCoordinator.submitAsyncJob(executor, listener); + jobCoordinator.submitJobWithCallback(executor, listener); } catch (Exception e1) { statusHandler.error("Error updating smart tool metadata.", e1); } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolMetadataScriptFactory.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolMetadataScriptFactory.java index 22ca0751f2..9ada5da393 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolMetadataScriptFactory.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolMetadataScriptFactory.java @@ -33,6 +33,7 @@ import com.raytheon.viz.gfe.core.DataManager; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jul 22, 2015 #4263 dgilling Initial creation + * Dec 14, 2015 #4816 dgilling Support refactored PythonJobCoordinator API. * * * @@ -43,21 +44,10 @@ import com.raytheon.viz.gfe.core.DataManager; public final class SmartToolMetadataScriptFactory extends SmartToolFactory { - private static final String SCRIPT_EXECUTOR_NAME = "smart-tool-metadata"; - - private static final int EXECUTOR_NUM_THREADS = 1; - public SmartToolMetadataScriptFactory(final DataManager dataMgr) { - super(SCRIPT_EXECUTOR_NAME, EXECUTOR_NUM_THREADS, dataMgr); + super(dataMgr); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory# - * createPythonScript() - */ @Override public SmartToolMetadataController createPythonScript() throws JepException { return new SmartToolMetadataController(getScriptPath(), diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolRunnerScriptFactory.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolRunnerScriptFactory.java index 3bc4c9e027..932e396d08 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolRunnerScriptFactory.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolRunnerScriptFactory.java @@ -33,6 +33,7 @@ import com.raytheon.viz.gfe.core.DataManager; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jul 25, 2015 #4263 dgilling Initial creation + * Dec 14, 2015 #4816 dgilling Support refactored PythonJobCoordinator API. * * * @@ -43,26 +44,10 @@ import com.raytheon.viz.gfe.core.DataManager; public final class SmartToolRunnerScriptFactory extends SmartToolFactory { - /* - * These constants that are passed to the super constructor only matter if - * procedure execution gets hooked into our python concurrent execution - * framework. Since it isn't we use dummy values for now... - */ - private static final String SCRIPT_EXECUTOR_NAME = "smart-tool-runner"; - - private static final int EXECUTOR_NUM_THREADS = 0; - public SmartToolRunnerScriptFactory(final DataManager dataMgr) { - super(SCRIPT_EXECUTOR_NAME, EXECUTOR_NUM_THREADS, dataMgr); + super(dataMgr); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory# - * createPythonScript() - */ @Override public SmartToolRunnerController createPythonScript() throws JepException { return new SmartToolRunnerController(getScriptPath(), getIncludePath(), diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/CombinationsFileUtil.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/CombinationsFileUtil.java index 911b63c269..9483bb62ec 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/CombinationsFileUtil.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/CombinationsFileUtil.java @@ -39,16 +39,19 @@ import jep.JepException; import com.raytheon.uf.common.dataplugin.gfe.exception.GfeException; import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil; import com.raytheon.uf.common.dataplugin.gfe.request.SaveCombinationsFileRequest; +import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; +import com.raytheon.uf.common.gfe.ifpclient.IFPClient; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.LocalizationUtil; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.localization.SaveableOutputStream; import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; import com.raytheon.uf.common.python.PyUtil; +import com.raytheon.uf.common.python.PythonIncludePathUtil; import com.raytheon.uf.common.python.PythonScript; import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.serialization.SingleTypeJAXBManager; @@ -56,8 +59,8 @@ 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.viz.gfe.GFEException; import com.raytheon.viz.gfe.core.DataManagerUIFactory; -import com.raytheon.viz.gfe.core.internal.IFPClient; import com.raytheon.viz.gfe.textformatter.CombinationsFileUtil.ComboData.Entry; /** @@ -78,6 +81,9 @@ import com.raytheon.viz.gfe.textformatter.CombinationsFileUtil.ComboData.Entry; * Sep 08, 2014 #3592 randerso Changed to use only list site level files as all * combo files are saved to the site level * Oct 07, 2015 #4695 dgilling Code cleanup to remove compile warnings. + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * Nov 18, 2015 #5129 dgilling Support new IFPClient. + * Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs. * * * @@ -152,8 +158,8 @@ public class CombinationsFileUtil { } public static String fileToId(LocalizationFile file) { - File f = new File(file.getName()); - String id = f.getName().replace(".xml", ""); + String id = LocalizationUtil.extractName(file.getPath()).replace( + ".xml", ""); id = FileUtil.unmangle(id); return id; @@ -178,8 +184,7 @@ public class CombinationsFileUtil { } } - public static void deleteComboData(String id) - throws LocalizationOpFailedException { + public static void deleteComboData(String id) throws LocalizationException { LocalizationFile lf = idToFile(id); lf.delete(); } @@ -212,7 +217,7 @@ public class CombinationsFileUtil { throws SerializationException, IOException, LocalizationException { LocalizationFile lf = idToFile(id); try (InputStream in = lf.openInputStream()) { - ComboData comboData = (ComboData) jaxb.unmarshalFromInputStream(in); + ComboData comboData = jaxb.unmarshalFromInputStream(in); Map comboDict = new HashMap( comboData.combos.size()); @@ -268,10 +273,11 @@ public class CombinationsFileUtil { HashMap map = new HashMap(); map.put("comboName", comboName); for (int retryCount = 0; retryCount < MAX_TRIES; retryCount++) { - try (PythonScript python = new PythonScript(scriptPath, + try (PythonScript python = new PythonScript( + scriptPath, PyUtil.buildJepIncludePath( GfePyIncludeUtil.getCombinationsIncludePath(), - GfePyIncludeUtil.getCommonPythonIncludePath()), + PythonIncludePathUtil.getCommonPythonIncludePath()), CombinationsFileUtil.class.getClassLoader())) { Object com = python.execute("getCombinations", map); combos = (List>) com; @@ -304,24 +310,26 @@ public class CombinationsFileUtil { * * @param zoneGroupList * @param filename - * @throws Exception - * @throws IOException + * @throws GFEException */ public static void generateAutoCombinationsFile( - List> zoneGroupList, String filename) throws Exception { + List> zoneGroupList, String filename) + throws GFEException { IFPClient ifpc = DataManagerUIFactory.getCurrentInstance().getClient(); SaveCombinationsFileRequest req = new SaveCombinationsFileRequest(); req.setFileName(filename); req.setCombos(zoneGroupList); - try { - statusHandler.info("Saving combinations file: " + filename); - ifpc.makeRequest(req); + + statusHandler.info("Saving combinations file: " + filename); + ServerResponse sr = ifpc.makeRequest(req); + if (sr.isOkay()) { statusHandler.info("Successfully saved combinations file: " + filename); - } catch (Exception e) { - statusHandler.error("Error saving combinations file: " + filename, - e); - throw e; + } else { + String message = String.format( + "Error saving combinations file %s: %s", filename, + sr.message()); + throw new GFEException(message); } } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/FormatterScriptFactory.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/FormatterScriptFactory.java index e623c76505..78ce5d334b 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/FormatterScriptFactory.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/FormatterScriptFactory.java @@ -28,8 +28,8 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.python.PyUtil; -import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory; import com.raytheon.uf.common.python.PythonIncludePathUtil; +import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory; import com.raytheon.uf.common.util.FileUtil; import com.raytheon.viz.gfe.python.GfeCavePyIncludeUtil; @@ -45,6 +45,7 @@ import com.raytheon.viz.gfe.python.GfeCavePyIncludeUtil; * Tests path for GFE formatter auto tests * Jul 28, 2015 4263 dgilling Refactor based on AbstractPythonScriptFactory. * Aug 21, 2015 4509 dgilling Added time and dataaccess to include path. + * Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API. * * * @@ -52,16 +53,8 @@ import com.raytheon.viz.gfe.python.GfeCavePyIncludeUtil; * @version 1.0 */ -public class FormatterScriptFactory extends - AbstractPythonScriptFactory { - - private static final String SCRIPT_EXECUTOR_NAME = "text-product-metadata"; - - private static final int EXECUTOR_NUM_THREADS = 1; - - public FormatterScriptFactory() { - super(SCRIPT_EXECUTOR_NAME, EXECUTOR_NUM_THREADS); - } +public class FormatterScriptFactory implements + PythonInterpreterFactory { private static String buildScriptPath() { IPathManager pathMgr = PathManagerFactory.getPathManager(); @@ -88,13 +81,6 @@ public class FormatterScriptFactory extends return include; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory# - * createPythonScript() - */ @Override public FormatterScript createPythonScript() throws JepException { return new FormatterScript(buildScriptPath(), buildIncludePath(), diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextFormatter.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextFormatter.java index 9f6a6d6dd8..0fd4e97e0a 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextFormatter.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextFormatter.java @@ -64,6 +64,7 @@ import com.raytheon.viz.gfe.tasks.AbstractGfeTask; * Aug 20, 2015 #4749 dgilling Add cleanUp. * Aug 26, 2015 #4804 dgilling Support ability to run TextFormatters * from SmartScript. + * Dec 08, 2015 #5129 dgilling Pass IFPClient to getVarDict. * * * @@ -289,6 +290,7 @@ public class TextFormatter extends AbstractGfeTask { map.put("dspName", dataManager.getTextProductMgr().getDisplayName(productName)); map.put("dataMgr", dataManager); + map.put("ifpClient", dataManager.getClient().getPythonClient()); map.put("issuedBy", issuedBy); map.put("dataSource", new DatabaseID(dbId).getModelName()); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextProductManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextProductManager.java index 1c4f0c8dc3..a6c422211a 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextProductManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextProductManager.java @@ -61,6 +61,7 @@ import com.raytheon.viz.gfe.core.IAsyncStartupObjectListener; * in a non-GUI environment like GFE formatter auto-tests * Jul 30, 2015 4263 dgilling Major refactor so this object can be initialized off * UI thread. + * Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API. * * * @@ -73,6 +74,10 @@ public class TextProductManager implements ILocalizationFileObserver { private final IUFStatusHandler statusHandler = UFStatus .getHandler(getClass()); + private static final String METADATA_THREAD_POOL_NAME = "text-product-metadata"; + + private static final int NUM_METADATA_THREADS = 1; + private String issuedBy; private final PythonJobCoordinator jobCoordinator; @@ -95,8 +100,8 @@ public class TextProductManager implements ILocalizationFileObserver { public TextProductManager() { this.issuedBy = ""; - FormatterScriptFactory factory = new FormatterScriptFactory(); - this.jobCoordinator = PythonJobCoordinator.newInstance(factory); + this.jobCoordinator = new PythonJobCoordinator<>(NUM_METADATA_THREADS, + METADATA_THREAD_POOL_NAME, new FormatterScriptFactory()); IPathManager pm = PathManagerFactory.getPathManager(); LocalizationContext baseContext = pm.getContext( @@ -129,7 +134,7 @@ public class TextProductManager implements ILocalizationFileObserver { } }; try { - jobCoordinator.submitAsyncJob(executor, listener); + jobCoordinator.submitJobWithCallback(executor, listener); } catch (Exception e) { statusHandler.error("Error building text product inventory.", e); } @@ -270,9 +275,9 @@ public class TextProductManager implements ILocalizationFileObserver { String officeTimeZone) { Collection timeZones = Collections.emptyList(); try { - timeZones = jobCoordinator - .submitSyncJob(new TextProductTimeZonesExecutor(zones, - officeTimeZone)); + timeZones = jobCoordinator.submitJob( + new TextProductTimeZonesExecutor(zones, officeTimeZone)) + .get(); } catch (Exception e) { statusHandler.error("Exception getting time zones.", e); } @@ -338,7 +343,7 @@ public class TextProductManager implements ILocalizationFileObserver { } }; try { - jobCoordinator.submitAsyncJob(executor, listener); + jobCoordinator.submitJobWithCallback(executor, listener); } catch (Exception e) { statusHandler.error("Error updating text product inventory.", e); } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextProductUtil.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextProductUtil.java index 2030c9bfa0..d39cdb8000 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextProductUtil.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextProductUtil.java @@ -26,7 +26,18 @@ import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil; import com.raytheon.viz.gfe.core.script.AbstractScriptUtil; /** - * A concrete implementation of IScriptUtil for working with Procedure scripts. + * An implementation of PythonFileTemplate for making new Text Products. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * ???                     wldougher   Initial creation
+ * Jan 19, 2016  4834      njensen     Removed dead method
+ *
+ * 
* * @author wldougher * @@ -37,9 +48,6 @@ public class TextProductUtil extends AbstractScriptUtil { private static final String SCRIPT_TYPE = "Text Product"; - /** - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#getScriptType() - */ @Override public String getScriptType() { return SCRIPT_TYPE; @@ -49,32 +57,14 @@ public class TextProductUtil extends AbstractScriptUtil { return SCRIPT_TYPE; } - /** - * @see com.raytheon.viz.gfe.core.script.AbstractScriptUtil#getScriptTypePathPrefix - * () - */ @Override public String getScriptTypePathPrefix() { return GfePyIncludeUtil.TEXT_PRODUCTS; } - /** - * @see com.raytheon.viz.gfe.core.script.AbstractScriptUtil#getVelocityTemplateName - * () - */ @Override protected String getVelocityTemplateName() { return TEMPLATE_FILENAME; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#getFileType() - */ - @Override - public String getFileType() { - return "TEXT_PRODUCT"; - } - } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextProductUtils.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextProductUtils.java index c99893da4b..5844c2eec7 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextProductUtils.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextProductUtils.java @@ -21,31 +21,16 @@ package com.raytheon.viz.gfe.textproduct; import java.io.File; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; - -import com.raytheon.uf.common.localization.IPathManager; -import com.raytheon.uf.common.localization.LocalizationContext; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; -import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.localization.PathManagerFactory; -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.exception.VizException; - /** * Utilities for text products * *
  * SOFTWARE HISTORY
- * Date			Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * Sept 23, 2008			askripsky	Initial creation
+ * Date         Ticket#     Engineer    Description
+ * ------------ ----------  ----------- --------------------------
+ * Sept 23, 2008            askripsky   Initial creation
  * Sept 09, 2013  #2033     dgilling    Remove dead code.
+ * Feb  05, 2016  #5242     dgilling    Remove dead code.
  * 
  * 
* @@ -54,8 +39,6 @@ import com.raytheon.uf.viz.core.exception.VizException; */ public class TextProductUtils { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(TextProductUtils.class); // Extension of text products public static final String EXTENSION = ".py"; @@ -83,181 +66,4 @@ public class TextProductUtils { // Root path for Utilities public final static String UTILITIES_PATH = TEXT_PRODUCTS_ROOT_PATH + File.separator + "utilities"; - - /** - * Copies the source file - * - * @param oldFileName - * The file to be copied - * @param newFileName - * The destination file - * @param type - * Designates whether the file is a product or a utility - * @throws VizException - * Exception if the file doesn't get copied correctly - */ - public static void copyFile(String oldFileName, String newFileName, - String type) throws VizException { - // Make sure the new name has the correct extension - if (!newFileName.endsWith(EXTENSION)) { - newFileName += EXTENSION; - } - - // Get file from catalogue - LocalizationFile oldFile = TextProductCatalogue.getInstance().getEntry( - oldFileName, type); - - // Get new file for the Site - LocalizationFile newFile = newTextProductFile(newFileName, type); - - // Make a copy to the Site location - try { - // Copy file - FileUtil.copyFile(oldFile.getFile(), newFile.getFile()); - - newFile.save(); - - // Add entry to catalogue - TextProductCatalogue.getInstance().addEntry(newFileName, newFile, - type); - - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - "Error copying text product", e); - } - } - - /** - * Deletes a text product or utility. - * - * @param toolToDelete - * the name of the tool - * @throws VizException - */ - public static void deleteTextProduct(String textProductToDelete, - String textProductType) throws VizException { - // Retrieve a handle to the actual file - LocalizationFile file = TextProductCatalogue.getInstance().getEntry( - textProductToDelete, textProductType); - - if (file.getContext().getLocalizationLevel() != LocalizationLevel.BASE) { - if ((file != null) && file.getFile().exists()) { - try { - file.delete(); - - TextProductCatalogue.getInstance().removeEntry( - textProductToDelete, textProductType); - } catch (Exception e) { - throw new VizException(e); - } - } - } else { - throw new VizException("Can't delete base text product " - + textProductToDelete); - } - } - - private static LocalizationFile newTextProductFile(String newName, - String type) throws VizException { - - IPathManager pathMgr = PathManagerFactory.getPathManager(); - - // Get context for the Site - LocalizationContext cx = pathMgr.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.SITE); - - // Build the path to the new file - String path = (type.equals(PRODUCT) ? PRODUCTS_PATH : UTILITIES_PATH) - + File.separator + newName; - - // Verify the extension is correct - if (!path.endsWith(EXTENSION)) { - path += EXTENSION; - } - - // the created file - LocalizationFile rval = PathManagerFactory.getPathManager() - .getLocalizationFile(cx, path); - - // Check to see if the file exists - // If not, create it - File file = rval.getFile(); - if (!file.exists()) { - try { - // Check to see if the directory exists - File dir = file.getParentFile(); - - if (!dir.exists()) { - dir.mkdirs(); - } - - file.createNewFile(); - - } catch (Exception e) { - throw new VizException(e); - } - } - - return rval; - } - - public static LocalizationLevel getLocalizationLevel(String entryName, - String entryType) { - return TextProductCatalogue.getInstance() - .getEntry(entryName, entryType).getContext() - .getLocalizationLevel(); - } - - public static void renameFile(String oldName, String newName, String type) - throws VizException { - - // Verify the extension is correct - if (!newName.endsWith(EXTENSION)) { - newName += EXTENSION; - } - - // Rename the localization file and entry - try { - copyFile(oldName, newName, type); - deleteTextProduct(oldName, type); - } catch (Exception e) { - throw new VizException(e); - } - } - - public static boolean promptForOverwrite(String name, String type) { - boolean okToOverwrite = true; - - if (!name.endsWith(EXTENSION)) { - name += EXTENSION; - } - - LocalizationFile preexistingFile = TextProductCatalogue.getInstance() - .getEntry(name, type); - - if (preexistingFile != null) { - // Initialize the confirmation prompt - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(); - - if (preexistingFile.getContext().getLocalizationLevel() == LocalizationLevel.BASE) { - // Do you want to create a site copy? - String prompt = name - + " exists at the BASE Level and cannot be modified.\nDo you" - + " want to make a copy that can be modified at the SITE Level?"; - - okToOverwrite = MessageDialog.openConfirm(shell, - "Item Overwrite", prompt); - } else { - // A Site file - String prompt = name - + " already exists.\nDo you want to overwrite it?"; - - okToOverwrite = MessageDialog.openConfirm(shell, - "Item Overwrite", prompt); - } - } - - return okToOverwrite; - } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextUtilityAdapter.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextUtilityAdapter.java index 2854b3575e..3dfcb16ac5 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextUtilityAdapter.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextUtilityAdapter.java @@ -23,7 +23,7 @@ import org.eclipse.jface.action.IMenuManager; import com.raytheon.uf.viz.localization.adapter.LocalizationPerspectiveAdapter; import com.raytheon.uf.viz.localization.filetreeview.FileTreeEntryData; -import com.raytheon.viz.gfe.core.script.IScriptUtil; +import com.raytheon.viz.gfe.core.script.PythonFileTemplate; import com.raytheon.viz.gfe.core.script.action.NewAction; /** @@ -53,7 +53,7 @@ public class TextUtilityAdapter extends LocalizationPerspectiveAdapter { @Override public boolean addContextMenuItems(IMenuManager menuMgr, FileTreeEntryData[] selectedData) { - IScriptUtil util = new TextUtilityUtil(); + PythonFileTemplate util = new TextUtilityUtil(); NewAction newAction = new NewAction(util); menuMgr.add(newAction); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextUtilityUtil.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextUtilityUtil.java index 04041e4565..25394f855c 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextUtilityUtil.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/TextUtilityUtil.java @@ -22,13 +22,23 @@ */ package com.raytheon.viz.gfe.textproduct; -import java.io.File; - import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil; +import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.viz.gfe.core.script.AbstractScriptUtil; /** - * A concrete implementation of IScriptUtil for working with Procedure scripts. + * An implementation of PythonFileTemplate for making new Text Utilities. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * ???                     wldougher   Initial creation
+ * Jan 19, 2016  4834      njensen     Removed dead method
+ *
+ * 
* * @author wldougher * @@ -39,44 +49,22 @@ public class TextUtilityUtil extends AbstractScriptUtil { private static final String SCRIPT_TYPE = "Utility"; - private static final String FILETYPE = "TEXT_PRODUCT"; - private static final String PATH_PREFIX = GfePyIncludeUtil.TEXT_UTILITIES - + File.separator + "regular"; + + IPathManager.SEPARATOR + "regular"; - /** - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#getScriptType() - */ @Override public String getScriptType() { return SCRIPT_TYPE; } - /** - * @see com.raytheon.viz.gfe.core.script.AbstractScriptUtil#getScriptTypePathPrefix - * () - */ @Override public String getScriptTypePathPrefix() { return PATH_PREFIX; } - /** - * @see com.raytheon.viz.gfe.core.script.AbstractScriptUtil#getVelocityTemplateName - * () - */ @Override protected String getVelocityTemplateName() { return TEMPLATE_FILENAME; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.gfe.core.script.IScriptUtil#getFileType() - */ - @Override - public String getFileType() { - return FILETYPE; - } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/action/TextProductDeleteAction.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/action/TextProductDeleteAction.java deleted file mode 100644 index 6ac9b27001..0000000000 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/action/TextProductDeleteAction.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.gfe.textproduct.action; - -import org.eclipse.jface.action.Action; - -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; -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.viz.gfe.Activator; -import com.raytheon.viz.gfe.GFEException; -import com.raytheon.viz.gfe.constants.StatusConstants; -import com.raytheon.viz.gfe.core.script.IScriptUtil; -import com.raytheon.viz.gfe.ui.AccessMgr; - -/** - * Action to delete a text product. - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jul 30, 2010            dgilling     Initial creation
- * 
- * 
- * - * @author dgilling - * @version 1.0 - */ - -public class TextProductDeleteAction extends Action { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(TextProductDeleteAction.class); - protected String scriptName; - - protected IScriptUtil util; - - /** - * Constructor - * - * @param scriptName - * The simple name of the script to be deleted. - * @param util - * The utility object that will actually delete the script - */ - public TextProductDeleteAction(String scriptName, IScriptUtil util) { - super("Delete"); - this.scriptName = scriptName; - this.util = util; - } - - /** - * Delete the procedure this action is tied to. - * - * @see org.eclipse.jface.action.Action#run() - */ - @Override - public void run() { - if (AccessMgr.verifyDelete(util.scripted(scriptName), - LocalizationType.CAVE_STATIC, false)) { - try { - // Delete the script - util.delete(scriptName, LocalizationLevel.USER); - statusHandler.handle(Priority.VERBOSE, - "USER " + util.getScriptType() + " " + scriptName - + " deleted."); - } catch (GFEException e) { - statusHandler.handle(Priority.PROBLEM, - "Error deleting USER " + util.getScriptType() + " " - + scriptName, e); - } - } - } -} diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/action/TextProductSiteAction.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/action/TextProductSiteAction.java deleted file mode 100644 index 5df95fa1c0..0000000000 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/action/TextProductSiteAction.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.gfe.textproduct.action; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Display; - -import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; -import com.raytheon.uf.common.localization.LocalizationFile; -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.viz.gfe.Activator; -import com.raytheon.viz.gfe.GFEException; -import com.raytheon.viz.gfe.constants.StatusConstants; -import com.raytheon.viz.gfe.core.script.IScriptUtil; -import com.raytheon.viz.gfe.core.script.IScriptUtil.Overwrite; - -/** - * An action to upgrade a text product to the SITE localization level. - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jul 29, 2010            dgilling     Initial creation
- * 
- * 
- * - * @author dgilling - * @version 1.0 - */ - -public class TextProductSiteAction extends Action { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(TextProductSiteAction.class); - - private static final Pattern OVR_PATTERN = Pattern.compile( - "(.+?)_?overrides", Pattern.CASE_INSENSITIVE); - - String script; - - IScriptUtil util; - - /** - * @param script - * The simple name of the script, i.e., "OAX_APD" - * @param util - * The script utility instance that provides low-level - * script-manipulation methods - */ - public TextProductSiteAction(String script, IScriptUtil util) { - super("Make SITE"); - this.script = script; - this.util = util; - } - - /** - * @see org.eclipse.jface.action.Action#run() - */ - @Override - public void run() { - String scriptType = util.getScriptType(); - LocalizationFile source = null; - try { - source = util.find(script, null); - } catch (GFEException e) { - String message = String.format( - "An error occurred while finding '%s'", script); - statusHandler.handle(Priority.PROBLEM, message, e); - return; - } - - // Make sure the source exists - if (source == null) { - String message = String.format("%s '%s' does not exist", - util.getScriptType(), script); - MessageDialog.openError(Display.getCurrent().getActiveShell(), - "Does Not Exist", message); - statusHandler.handle(Priority.PROBLEM, message); - return; - } - - LocalizationLevel srcLevel = source.getContext().getLocalizationLevel(); - - String dest = script; - Matcher ovrMatch = OVR_PATTERN.matcher(script); - boolean isOverride = ovrMatch.matches(); - - if (isOverride) { - // strip "overrides" or "_overrides" from destination name - dest = ovrMatch.group(1); - } - - if (LocalizationLevel.BASE == srcLevel) { - // source is BASE, we can't downgrade it - String message = String - .format("%s '%s' is at BASE level and cannot be moved to SITE level.", - scriptType, script); - MessageDialog.openInformation( - Display.getCurrent().getActiveShell(), "Cannot Move Base", - message); - return; - } - - if (LocalizationLevel.SITE == srcLevel && !isOverride) { - // nothing to do - String message = String.format("%s '%s' is already at SITE level.", - scriptType, script); - MessageDialog.openInformation( - Display.getCurrent().getActiveShell(), message, message); - return; - } - - LocalizationFile destlf = null; - try { - destlf = util.find(dest, LocalizationLevel.SITE); - } catch (GFEException e1) { - String message = String.format("Error during search for %s '%s'", - scriptType, dest); - statusHandler.handle(Priority.PROBLEM, message); - return; - } - - if (destlf != null - && destlf.getFile().getPath() - .contains(GfePyIncludeUtil.TEXT_PRODUCTS)) { - // destination already exists. Confirm overwrite. - String message = String - .format("%s '%s' already exists at SITE level!\n" - + "Confirm that you want to overwrite it from %s at %s level:", - scriptType, dest, script, srcLevel.toString()); - boolean confirmed = MessageDialog.openConfirm(Display.getCurrent() - .getActiveShell(), "Confirm Overwrite", message); - if (confirmed) { - try { - destlf.delete(); - } catch (Exception e) { - String errMessage = String.format("Error deleting %s '%s'", - scriptType, dest); - statusHandler.handle(Priority.PROBLEM, errMessage, e); - } - } else { - return; - } - } - - try { - util.copy(script, dest, LocalizationLevel.SITE, Overwrite.SAFE); - source.delete(); - String message = String.format("%s '%s' set as SITE", scriptType, - dest); - statusHandler.handle(Priority.VERBOSE, message); - } catch (Exception e) { - String message = String.format("Error moving %s to SITE", script); - statusHandler.handle(Priority.PROBLEM, message, e); - } - } -} diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/action/TextProductSiteOverrideAction.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/action/TextProductSiteOverrideAction.java deleted file mode 100644 index 13b83ac110..0000000000 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textproduct/action/TextProductSiteOverrideAction.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.raytheon.viz.gfe.textproduct.action; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Display; - -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; -import com.raytheon.uf.common.localization.LocalizationFile; -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.viz.gfe.Activator; -import com.raytheon.viz.gfe.GFEException; -import com.raytheon.viz.gfe.constants.StatusConstants; -import com.raytheon.viz.gfe.core.script.IScriptUtil; -import com.raytheon.viz.gfe.core.script.IScriptUtil.Overwrite; - -/** - * An action to upgrade a a text product and make it the SITE override script. - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jul 30, 2010            dgilling     Initial creation
- * 
- * 
- * - * @author dgilling - * @version 1.0 - */ -public class TextProductSiteOverrideAction extends Action { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(TextProductSiteOverrideAction.class); - - private static final Pattern OVR_PATTERN = Pattern.compile( - "(.+?)_?overrides", Pattern.CASE_INSENSITIVE); - - String script; - - IScriptUtil util; - - public TextProductSiteOverrideAction(String script, IScriptUtil util) { - super("Make SITE Override"); - this.script = script; - this.util = util; - } - - /** - * @see org.eclipse.jface.action.Action#run() - */ - @Override - public void run() { - String scriptType = util.getScriptType(); - LocalizationFile source = null; - try { - source = util.find(script, null); - } catch (GFEException e) { - String message = String.format( - "An error occurred while finding '%s'", script); - statusHandler.handle(Priority.PROBLEM, message, e); - return; - } - - // Make sure the source exists - if (source == null) { - String message = String.format("%s '%s' does not exist", - util.getScriptType(), script); - MessageDialog.openError(Display.getCurrent().getActiveShell(), - "Does Not Exist", message); - statusHandler.handle(Priority.PROBLEM, message); - return; - } - - LocalizationLevel srcLevel = source.getContext().getLocalizationLevel(); - - String dest = script; - Matcher ovrMatch = OVR_PATTERN.matcher(script); - boolean isOverride = ovrMatch.matches(); - - if (isOverride) { - // strip "override" or "_override" from destination name - dest = ovrMatch.group(1); - } - - if (srcLevel.isSystemLevel()) { - // source is BASE, we can't downgrade it - String message = String.format( - "%s '%s' cannot be moved to SITE level.", scriptType, - script); - MessageDialog.openInformation( - Display.getCurrent().getActiveShell(), "Cannot Move Base", - message); - return; - } - - if (LocalizationLevel.SITE == srcLevel) { - // nothing to do, in two flavors: - String message = null; - if (isOverride) { - message = String.format( - "%s '%s' is already the site override.", scriptType, - script); - - } else { - message = String.format("'%s' is the SITE %s.\n" - + "It cannot be made the SITE override.", script, - scriptType); - } - MessageDialog.openInformation( - Display.getCurrent().getActiveShell(), message, message); - return; - } - - dest = dest + "_OVERRIDE"; - LocalizationFile destlf = null; - try { - destlf = util.find(dest, LocalizationLevel.SITE); - } catch (GFEException e1) { - String message = String.format("Error during search for %s '%s'", - scriptType, dest); - statusHandler.handle(Priority.PROBLEM, message); - return; - } - - if (destlf != null) { - // destination already exists. Confirm overwrite. - String message = String - .format("%s '%s' already exists at SITE level!\n" - + "Confirm that you want to overwrite it from %s at %s level:", - scriptType, dest, script, srcLevel.toString()); - boolean confirmed = MessageDialog.openConfirm(Display.getCurrent() - .getActiveShell(), "Confirm Overwrite", message); - if (confirmed) { - try { - destlf.delete(); - } catch (Exception e) { - String errMessage = String.format("Error deleting %s '%s'", - scriptType, dest); - statusHandler.handle(Priority.PROBLEM, errMessage, e); - } - } else { - return; - } - } - - try { - util.copy(script, dest, LocalizationLevel.SITE, Overwrite.SAFE); - source.delete(); - String message = String.format("%s '%s' set as SITE", scriptType, - dest); - statusHandler.handle(Priority.VERBOSE, message); - } catch (Exception e) { - String message = String.format("Error ", script); - statusHandler.handle(Priority.PROBLEM, message, e); - } - } -} diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/runtimeui/ValuesDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/runtimeui/ValuesDialog.java index 91c713b680..a81f0804e1 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/runtimeui/ValuesDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/runtimeui/ValuesDialog.java @@ -27,6 +27,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.python.swt.ButtonConstant; @@ -42,12 +43,13 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * *
  * SOFTWARE HISTORY
- * Date			Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * Jun 3, 2008	1164		jelkins     Initial creation
- * Oct 15, 2008             njensen     Static methods to keep UI
- *                                      thread working
- * Mar 28, 2013 1790        rferrel     Make dialog modal except when the static openDialog is used.
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 03, 2008 1164       jelkins     Initial creation
+ * Oct 15, 2008            njensen     Static methods to keep UI
+ *                                     thread working
+ * Mar 28, 2013 1790       rferrel     Make dialog modal except when the static openDialog is used.
+ * Jan 15, 2015 5054       randerso    Remove unnecessary new Shell
  * 
  * 
* @@ -299,7 +301,9 @@ public class ValuesDialog extends CaveJFACEDialog { @Override public void run() { - syncedDialog = new ValuesDialog(new Shell(), title, fieldDefs, + Shell shell = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getShell(); + syncedDialog = new ValuesDialog(shell, title, fieldDefs, dataMgr); syncedDialog.setShellStyle(SWT.MODELESS | SWT.TITLE | SWT.RESIZE); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/zoneselector/ZoneSelector.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/zoneselector/ZoneSelector.java index 73d1705074..9e38dda64f 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/zoneselector/ZoneSelector.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/zoneselector/ZoneSelector.java @@ -34,10 +34,11 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.RGBColors; import com.raytheon.uf.viz.core.rsc.IInputHandler; +import com.raytheon.uf.viz.zoneselector.AbstractZoneSelector; +import com.raytheon.uf.viz.zoneselector.ZoneSelectorResource; import com.raytheon.viz.gfe.Activator; import com.raytheon.viz.gfe.PythonPreferenceStore; import com.raytheon.viz.gfe.dialogs.formatterlauncher.IZoneCombiner; @@ -54,6 +55,8 @@ import com.raytheon.viz.ui.input.InputAdapter; * ------------ ---------- ----------- -------------------------- * Aug 11, 2011 randerso Initial creation * Aug 31, 2015 4749 njensen Overrode dispose() + * Feb 05, 2016 5316 randerso Moved AbstractZoneSelector to separate project + * Code cleanup * * * @@ -62,13 +65,6 @@ import com.raytheon.viz.ui.input.InputAdapter; */ public class ZoneSelector extends AbstractZoneSelector { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(ZoneSelector.class); - - public static interface IZoneSelectionListener { - public void zoneSelected(String zone); - } - private static final int NO_GROUP = -1; IInputHandler theMouseListener = new InputAdapter() { @@ -83,23 +79,11 @@ public class ZoneSelector extends AbstractZoneSelector { */ private static final int MB2 = 2; - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.input.IInputHandler#handleDoubleClick(int, - * int) - */ @Override public boolean handleDoubleClick(int x, int y, int button) { return false; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDown(int, - * int, int) - */ @Override public boolean handleMouseDown(int x, int y, int mouseButton) { switch (mouseButton) { @@ -118,12 +102,6 @@ public class ZoneSelector extends AbstractZoneSelector { return true; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDownMove(int, - * int, int) - */ @Override public boolean handleMouseDownMove(int x, int y, int mouseButton) { switch (mouseButton) { @@ -135,34 +113,16 @@ public class ZoneSelector extends AbstractZoneSelector { return true; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseHover(int, - * int) - */ @Override public boolean handleMouseHover(int x, int y) { return false; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseMove(int, - * int) - */ @Override public boolean handleMouseMove(int x, int y) { return false; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseUp(int, int, - * int) - */ @Override public boolean handleMouseUp(int x, int y, int mouseButton) { switch (mouseButton) { @@ -200,8 +160,6 @@ public class ZoneSelector extends AbstractZoneSelector { // current color map private List colors; - private RGB noZoneColor; - // state flag, whether to label the zone groups private boolean labelZoneGroups; @@ -217,11 +175,22 @@ public class ZoneSelector extends AbstractZoneSelector { private String pressZone; + /** + * @param parent + * @param gloc + * @param lclFmtrDialog + */ public ZoneSelector(Composite parent, GridLocation gloc, IZoneCombiner lclFmtrDialog) { this(parent, gloc, lclFmtrDialog, null); } + /** + * @param parent + * @param gloc + * @param lclFmtrDialog + * @param selectCB + */ public ZoneSelector(Composite parent, GridLocation gloc, IZoneCombiner lclFmtrDialog, IZoneSelectionListener selectCB) { super(parent, gloc, selectCB); @@ -236,8 +205,6 @@ public class ZoneSelector extends AbstractZoneSelector { "black")); backColor = RGBColors.getRGBColor(config( "ZoneCombiner_backgroundColor", "gray40")); - - registerMouseHandler(theMouseListener); } @Override @@ -246,8 +213,20 @@ public class ZoneSelector extends AbstractZoneSelector { super.dispose(); } - // command to set the state of include all zones. If it has changed, - // redo the combo dictionary and redraw. + @Override + protected void registerHandlers(IDisplayPane pane) { + super.registerHandlers(pane); + + registerMouseHandler(theMouseListener); + } + + /** + * Command to set the state of include all zones. + * + * If it has changed, redo the combo dictionary and redraw. + * + * @param includeAllZones + */ public void setIncludeAllZones(boolean includeAllZones) { if (this.includeAllZones != includeAllZones) { this.includeAllZones = includeAllZones; @@ -257,7 +236,11 @@ public class ZoneSelector extends AbstractZoneSelector { } } - // command to limit combos to one group + /** + * Command to limit combos to one group + * + * @param limitOneGroup + */ public void setLimitToOneGroup(boolean limitOneGroup) { if (this.limitToOneGroup != limitOneGroup) { this.limitToOneGroup = limitOneGroup; @@ -270,9 +253,14 @@ public class ZoneSelector extends AbstractZoneSelector { } } + /** + * @param mapNames + * @param comboDict + * @param colors + */ public void setMap(List mapNames, Map comboDict, List colors) { - super.setMap(mapNames); + super.setMap(mapNames, false); setMapInternal(mapRscList, comboDict, colors); } @@ -307,23 +295,35 @@ public class ZoneSelector extends AbstractZoneSelector { cleanUpCombosOfUnknownZones(); } - // get current list of colors + /** + * @return current list of colors + */ public List getColors() { return this.colors; } - // get current combinations + /** + * @return current combinations + */ public Map getCombos() { return this.comboDict; } - // update colors command + /** + * update colors command + * + * @param colors + */ public void updateColors(List colors) { this.colors = colors; this.updateCombos(this.comboDict); } - // command to label the zone groups + /** + * command to label the zone groups + * + * @param labelZoneGroups + */ public void setLabelZoneGroups(boolean labelZoneGroups) { if (labelZoneGroups == this.labelZoneGroups) { return; @@ -334,7 +334,11 @@ public class ZoneSelector extends AbstractZoneSelector { } } - // update combo dictionary with different combinations + /** + * update combo dictionary with different combinations + * + * @param comboDict + */ public void updateCombos(Map comboDict) { if (this.limitToOneGroup) { comboDict = this.setOneGroup(comboDict); @@ -370,7 +374,7 @@ public class ZoneSelector extends AbstractZoneSelector { + Math.abs(y - this.pressLocation.y); // drag - if (diff >= 10 && this.pressZone != null) { + if ((diff >= 10) && (this.pressZone != null)) { // get the zones that were selected List zones = this.selectedZones(x, y); @@ -481,10 +485,10 @@ public class ZoneSelector extends AbstractZoneSelector { } else { // make some extra colors Random random = new Random(); - while (groupNumber - this.colors.size() > 0) { - RGB rgb = new RGB(random.nextInt(210 - 30 + 1) + 30, - random.nextInt(210 - 30 + 1) + 30, - +random.nextInt(210 - 30 + 1) + 30); + while ((groupNumber - this.colors.size()) > 0) { + RGB rgb = new RGB(random.nextInt((210 - 30) + 1) + 30, + random.nextInt((210 - 30) + 1) + 30, + +random.nextInt((210 - 30) + 1) + 30); this.colors.add(rgb); } return this.getGroupColor(groupNumber); @@ -532,7 +536,7 @@ public class ZoneSelector extends AbstractZoneSelector { // deal with the group label this.setZoneGroupLabel(zone, group); - if (doCallback && this.selectCB != null) { + if (doCallback && (this.selectCB != null)) { this.selectCB.zoneSelected(zone); } } @@ -550,7 +554,7 @@ public class ZoneSelector extends AbstractZoneSelector { } } - if (deletedEans.size() > 0 && this.lclFmtrDialog != null) { + if ((deletedEans.size() > 0) && (this.lclFmtrDialog != null)) { this.lclFmtrDialog.setStatusText("S", "Removed Unknown Edit Areas: " + deletedEans); } @@ -574,7 +578,7 @@ public class ZoneSelector extends AbstractZoneSelector { // sets the zone to the given color, does not affect the combinations private void setZone(String zoneName, RGB color) { for (ZoneSelectorResource mapRsc : this.mapRscList) { - mapRsc.setZone(zoneName, color); + mapRsc.setZone(color, zoneName); } // this.update_idletasks(); @@ -658,6 +662,9 @@ public class ZoneSelector extends AbstractZoneSelector { return groupings; } + /** + * @return the no zone color + */ public RGB getNoZoneColor() { return this.noZoneColor; } diff --git a/cave/com.raytheon.viz.ghg/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.ghg/META-INF/MANIFEST.MF index 06291e71a4..ceb8daf19f 100644 --- a/cave/com.raytheon.viz.ghg/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.ghg/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: GHG Plug-in Bundle-SymbolicName: com.raytheon.viz.ghg;singleton:=true -Bundle-Version: 1.14.0.qualifier +Bundle-Version: 1.16.0.qualifier Bundle-Activator: com.raytheon.viz.ghg.Activator Bundle-Vendor: Raytheon Require-Bundle: org.eclipse.ui, @@ -10,19 +10,17 @@ Require-Bundle: org.eclipse.ui, com.raytheon.viz.ui, com.raytheon.viz.core, org.geotools, - com.raytheon.viz.gfe, com.raytheon.viz.alerts, org.jep, - com.raytheon.uf.common.message;bundle-version="1.11.31", + com.raytheon.uf.common.message, com.raytheon.uf.common.dataplugin.gfe, + com.raytheon.uf.common.gfe.ifpclient, com.raytheon.uf.common.site, - com.raytheon.uf.viz.core.maps;bundle-version="1.12.1174" + com.raytheon.uf.viz.core.maps, + com.raytheon.uf.viz.zoneselector, + org.apache.commons.lang3;bundle-version="3.4.0" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Import-Package: com.raytheon.uf.common.activetable, - com.raytheon.uf.common.dataplugin.gfe, - com.raytheon.uf.common.dataplugin.gfe.db.objects, - com.raytheon.uf.common.dataplugin.gfe.reference, - com.raytheon.uf.common.dataplugin.gfe.slice, com.raytheon.uf.common.python Bundle-ClassPath: com.raytheon.viz.ghg.jar diff --git a/cave/com.raytheon.viz.ghg/plugin.xml b/cave/com.raytheon.viz.ghg/plugin.xml index 839d35dd33..eb94da33e7 100644 --- a/cave/com.raytheon.viz.ghg/plugin.xml +++ b/cave/com.raytheon.viz.ghg/plugin.xml @@ -34,4 +34,15 @@ commandId="com.raytheon.viz.ghg.openGhgMonitor"> + + + + + + diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/GhgMonitorAction.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/GhgMonitorAction.java index 8f773bbd8a..dfbdf01602 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/GhgMonitorAction.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/GhgMonitorAction.java @@ -25,6 +25,7 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; +import com.raytheon.viz.ghg.exception.GhgMissingDataException; import com.raytheon.viz.ghg.monitor.GhgMonitorDlg; /** @@ -32,11 +33,12 @@ import com.raytheon.viz.ghg.monitor.GhgMonitorDlg; * *
  * SOFTWARE HISTORY
- * Date			Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * Mar 26, 2008 1033		lvenable	Initial creation
+ * Date         Ticket#     Engineer    Description
+ * ------------ ----------  ----------- --------------------------
+ * Mar 26, 2008 1033        lvenable    Initial creation
  * Nov 15, 2012 1298        rferrel     Changes for non-blocking GhgMonitorDlg.
  * Mar 28, 2013 1790        rferrel     Bug fix for non-blocking dialogs.
+ * Dec 16, 2015 5184        dgilling    Handle GhgMissingDataException.
  * 
  * 
* @@ -50,10 +52,15 @@ public class GhgMonitorAction extends AbstractHandler { @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { if (monitorDlg == null || monitorDlg.isDisposed()) { - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(); - monitorDlg = new GhgMonitorDlg(shell); - monitorDlg.open(); + try { + Shell shell = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getShell(); + monitorDlg = new GhgMonitorDlg(shell); + monitorDlg.open(); + } catch (GhgMissingDataException e) { + throw new ExecutionException( + "Could not retrieve data needed for GHG monitor.", e); + } } else { monitorDlg.bringToTop(); } diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/exception/GhgMissingDataException.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/exception/GhgMissingDataException.java new file mode 100644 index 0000000000..e24d201de1 --- /dev/null +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/exception/GhgMissingDataException.java @@ -0,0 +1,44 @@ +package com.raytheon.viz.ghg.exception; + +/** + * Exception to throw if GHG Monitor can not load data it needs to initialize + * the application. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 16, 2015  #5184     dgilling     Initial creation
+ * 
+ * 
+ * + * @author dgilling + * @version 1.0 + */ +public final class GhgMissingDataException extends Exception { + + private static final long serialVersionUID = 9066782113765709566L; + + public GhgMissingDataException() { + super(); + } + + public GhgMissingDataException(String message, Throwable cause, + boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public GhgMissingDataException(String message, Throwable cause) { + super(message, cause); + } + + public GhgMissingDataException(String message) { + super(message); + } + + public GhgMissingDataException(Throwable cause) { + super(cause); + } +} diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GHGSpatialViewer.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GHGSpatialViewer.java index 9ed6acbfec..8faa0d4f1b 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GHGSpatialViewer.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GHGSpatialViewer.java @@ -33,12 +33,15 @@ import org.eclipse.swt.widgets.Event; import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.RGBColors; import com.raytheon.uf.viz.core.rsc.IInputHandler; -import com.raytheon.viz.gfe.ui.zoneselector.AbstractZoneSelector; -import com.raytheon.viz.gfe.ui.zoneselector.ZoneSelector.IZoneSelectionListener; -import com.raytheon.viz.gfe.ui.zoneselector.ZoneSelectorResource; +import com.raytheon.uf.viz.zoneselector.AbstractZoneSelector; +import com.raytheon.uf.viz.zoneselector.ZoneSelectorResource; +import com.raytheon.viz.ghg.monitor.event.AbstractGhgMonitorEvent.GhgEventListener; +import com.raytheon.viz.ghg.monitor.event.GhgMonitorZoneSelectionEvent; import com.raytheon.viz.ui.input.InputAdapter; +import com.raytheon.viz.ui.input.PanHandler; /** * GHG Spatial Viewer @@ -49,7 +52,8 @@ import com.raytheon.viz.ui.input.InputAdapter; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Aug 23, 2011 randerso Initial creation + * Aug 23, 2011 randerso Initial creation + * Feb 05, 2016 #5316 randerso Fleshed out implementation * * * @@ -58,22 +62,62 @@ import com.raytheon.viz.ui.input.InputAdapter; */ public class GHGSpatialViewer extends AbstractZoneSelector { - // TODO: This is a start at converting the GHGMonitor to use the classes - // created for the ZoneSelector. Unforturnately it will require significant - // refactoring of GHGMonitor to get this to work and we don't have time or a - // pressing need to do this now. private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(GHGSpatialViewer.class); + /** + * Enumeration defining the available zoom level. + */ + public enum ZoomLevel { + /** 1x zoom (No Zoom) */ + ZOOM_1("No Zoom", 1), + + /** 2x zoom */ + ZOOM_2("x2", 2), + + /** 4x zoom */ + ZOOM_4("x4", 4), + + /** 6x zoom */ + ZOOM_6("x6", 6), + + /** 8x zoom */ + ZOOM_8("x8", 8), + + /** 12x zoom */ + ZOOM_12("x12", 12), + + /** 16x zoom */ + ZOOM_16("x16", 16); + + private String displayName; + + private int level; + + private ZoomLevel(String displayName, int level) { + this.displayName = displayName; + this.level = level; + } + + @Override + public String toString() { + return displayName; + } + + public int getZoomLevel() { + return level; + } + } + private static final Map> mapConfigure; static { mapConfigure = new LinkedHashMap>(); mapConfigure.put("FIPS", Arrays.asList("Counties", "Marine_Zones")); mapConfigure.put("Public", Arrays.asList("Zones")); mapConfigure.put("FireWx", Arrays.asList("FireWxZones")); - mapConfigure.put("Marine", Arrays.asList("Marine_Zones" - /* , "OffshoreMZones" */)); + mapConfigure.put("Marine", + Arrays.asList("Marine_Zones", "Offshore_Marine_Zones")); } IInputHandler theMouseListener = new InputAdapter() { @@ -188,6 +232,14 @@ public class GHGSpatialViewer extends AbstractZoneSelector { private Point pressInfo; + private List zoneSelectionListenerList = new ArrayList<>(); + + /** + * @param parent + * @param myWfo + * @param gloc + * @param callback + */ public GHGSpatialViewer(Composite parent, String myWfo, GridLocation gloc, IZoneSelectionListener callback) { super(parent, gloc, callback); @@ -224,7 +276,7 @@ public class GHGSpatialViewer extends AbstractZoneSelector { // click? if (diff < 10) { List zones = this.selectedZones(x, y); - if (this.selectCB != null && !zones.isEmpty()) { + if ((this.selectCB != null) && !zones.isEmpty()) { this.selectCB.zoneSelected(zones.get(0)); } } @@ -234,7 +286,7 @@ public class GHGSpatialViewer extends AbstractZoneSelector { public void setMap(String mapName) { this.mapName = mapName; List mapList = mapConfigure.get(mapName); - super.setMap(mapList); + super.setMap(mapList, true); for (ZoneSelectorResource rsc : mapRscList) { rsc.setMyWfo(this.myWfo); @@ -246,11 +298,87 @@ public class GHGSpatialViewer extends AbstractZoneSelector { setMapInternal(mapRscList); } - public List knownMaps() { + public static List knownMaps() { return new ArrayList(mapConfigure.keySet()); } public String getCurrentMap() { return this.mapName; } + + @Override + protected void registerHandlers(IDisplayPane pane) { + super.registerHandlers(pane); + registerMouseHandler(new PanHandler(this)); + + registerMouseHandler(new InputAdapter() { + private boolean drag = false; + + @Override + public boolean handleMouseUp(int x, int y, int mouseButton) { + if (mouseButton == 1) { + if (!drag) { + List zones = selectedZones(x, y); + GhgMonitorZoneSelectionEvent evt = new GhgMonitorZoneSelectionEvent(); + evt.setHighlightedZones(zones); + fireZoneSelectionEvent(evt); + } + this.drag = false; + } + return false; + } + + @Override + public boolean handleMouseDownMove(int x, int y, int mouseButton) { + if (mouseButton == 1) { + this.drag = true; + } + return false; + } + }); + } + + /** + * @param selectionColor + * @param highlightedZones + */ + public void setHighlightedZones(RGB selectionColor, + String... highlightedZones) { + for (ZoneSelectorResource rsc : mapRscList) { + rsc.clearZones(); + rsc.setZone(selectionColor, highlightedZones); + } + } + + /** + * Add a listener to the list. + * + * @param listener + */ + public void addSelectionListener(GhgEventListener listener) { + if (!zoneSelectionListenerList.contains(listener)) { + zoneSelectionListenerList.add(listener); + } + } + + /** + * Remove a listener from the list. + * + * @param listener + */ + public void removeSelectionListener(GhgEventListener listener) { + zoneSelectionListenerList.remove(listener); + } + + /** + * Fire the map change event. + * + * @param event + * The GhgMonitorZoneSelectionEvent object + */ + private void fireZoneSelectionEvent(GhgMonitorZoneSelectionEvent event) { + for (GhgEventListener listener : zoneSelectionListenerList) { + listener.notifyUpdate(event); + } + } } diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgAlertDlg.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgAlertDlg.java index 40cb924411..cfc7cfc681 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgAlertDlg.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgAlertDlg.java @@ -48,6 +48,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * 25 MAR 2008 N/A lvenable Initial creation * 15 NOV 2012 1298 rferrel Changes for non-blocking dialog. + * 05 FEB 2016 5316 randerso Code cleanup * * * @@ -86,7 +87,7 @@ public class GhgAlertDlg extends CaveSWTDialog { GhgConfigData.AlertsFilterEnum.PhenSig, GhgConfigData.AlertsFilterEnum.Pil }; - public static Map filterToEnumMap = new HashMap() { + private static Map filterToEnumMap = new HashMap() { private static final long serialVersionUID = 6183513849706287870L; { @@ -323,6 +324,9 @@ public class GhgAlertDlg extends CaveSWTDialog { } } + /** + * @param alerts + */ public void setAlerts(GhgAlertsConfigData alerts) { this.alerts = alerts.clone(); } diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgColorDlg.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgColorDlg.java index 0f5d2a620f..6200b8f570 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgColorDlg.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgColorDlg.java @@ -47,8 +47,9 @@ import com.raytheon.viz.ui.dialogs.colordialog.IColorWheelChange; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * 25 MAR 2008 N/A lvenable Initial creation - * 28 NOV 2012 1353 rferrel Changes for non-blocking dialog. + * 25 Mar 2008 N/A lvenable Initial creation + * 28 Nov 2012 1353 rferrel Changes for non-blocking dialog. + * 08 Feb 2016 5316 randerso Fix monitor selection background color * * * @@ -365,6 +366,7 @@ public class GhgColorDlg extends CaveSWTDialog implements IColorWheelChange { * Change the color of the label foreground or background color based on the * selection in the color wheels. */ + @Override public void colorChange(RGB rgb, String colorWheelTitle) { if (colorWheelTitle.compareTo(TEXT_COLOR) == 0) { labelForeGroundColor.dispose(); @@ -412,7 +414,7 @@ public class GhgColorDlg extends CaveSWTDialog implements IColorWheelChange { rgb = (RGB) monitorSelectionsRdo.getData(FOREGROUND_KEY); ghgConfigData.getMonitorSelectionsColors().setForegroundRgb(rgb); - rgb = (RGB) monitorSelectionsRdo.getData(FOREGROUND_KEY); + rgb = (RGB) monitorSelectionsRdo.getData(BACKGROUND_KEY); ghgConfigData.getMonitorSelectionsColors().setBackgroundRgb(rgb); rgb = (RGB) testProductRdo.getData(FOREGROUND_KEY); diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgDisplayManager.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgDisplayManager.java deleted file mode 100644 index 79f1f41028..0000000000 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgDisplayManager.java +++ /dev/null @@ -1,335 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.ghg.monitor; - -import java.util.ArrayList; -import java.util.List; - -import com.raytheon.uf.common.activetable.ActiveTableRecord; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.viz.gfe.core.DataManager; -import com.raytheon.viz.ghg.Activator; -import com.raytheon.viz.ghg.constants.StatusConstants; -import com.raytheon.viz.ghg.monitor.constants.GhgMenuConstants; -import com.raytheon.viz.ghg.monitor.data.GhgConfigData.DataEnum; -import com.raytheon.viz.ghg.monitor.data.GhgConfigData; -import com.raytheon.viz.ghg.monitor.data.GhgData; -import com.raytheon.viz.ghg.monitor.event.GhgMonitorFilterChangeEvent; -import com.raytheon.viz.ghg.monitor.event.GhgMonitorTableSelectionEvent; -import com.raytheon.viz.ghg.monitor.event.GhgMonitorZoneSelectionEvent; -import com.raytheon.viz.ghg.monitor.listener.GhgMonitorFilterChangeListener; -import com.raytheon.viz.ghg.monitor.listener.GhgMonitorTableSelectionListener; -import com.raytheon.viz.ghg.monitor.listener.GhgMonitorZoneSelectionListener; - -/** - * The GHG Monitor display manager. - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * May 10, 2010            mpduff     Initial creation
- * Apr 9, 2014  15769      ryu        Moved attribute identifyTestData to configuration, as in A1.
- * 
- * 
- * - * @author mpduff - * @version 1.0 - */ - -public class GhgDisplayManager { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(GhgDisplayManager.class); - /** - * Single instance of this class type. - */ - private static GhgDisplayManager instance = null; - - /** - * Zoom level of the map. - */ - private int zoomLevel = 0; - - /** - * Zone type to display. - */ - private GhgMenuConstants.ShowMap zoneDisplay; - - /** - * Show label flag. - */ - private boolean showLabels = false; - - /** - * List of GhgData records - */ - private List dataList = new ArrayList(); - - private DataEnum sortColumn; - - /** - * Flag for changes to filter - */ - private boolean filterChanged = false; - - /** - * Filter change listener list - */ - private ArrayList filterChangeListenerList = new ArrayList(); - - /** - * Map zone selection listener list - */ - private ArrayList zoneSelectionListenerList = new ArrayList(); - - /** - * Table selection listener list - */ - private ArrayList tableSelectionListenerList = new ArrayList(); - - /** - * Private constructor for this singleton. - */ - private GhgDisplayManager() { - - } - - /** - * Get the singleton instance of this class. - * - * @return The one instance of this class - */ - public static synchronized GhgDisplayManager getInstance() { - if (instance == null) { - instance = new GhgDisplayManager(); - } - - return instance; - } - - /** - * Gets the ActiveTable records and returns them as a List. The - * list is based on the configuration selections. - * - * @return List list of GhgData objects - */ - public List getTableData() { - List activeTableList = null; - - dataList.clear(); - try { - activeTableList = DataManager.getCurrentInstance().getActiveTable(); - for (ActiveTableRecord rec : activeTableList) { - GhgData data = new GhgData(rec); - dataList.add(data); - } - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error getting ActiveTable", e); - return new ArrayList(); - } - - return new ArrayList(dataList); - } - - /** - * @return the zoomLevel - */ - public int getZoomLevel() { - return zoomLevel; - } - - /** - * @param zoomLevel - * the zoomLevel to set - */ - public void setZoomLevel(int zoomLevel) { - this.zoomLevel = zoomLevel; - } - - /** - * @return the zoneDisplay - */ - public GhgMenuConstants.ShowMap getZoneDisplay() { - return zoneDisplay; - } - - /** - * @param zoneDisplay - * the zoneDisplay to set - */ - public void setZoneDisplay(GhgMenuConstants.ShowMap zoneDisplay) { - this.zoneDisplay = zoneDisplay; - } - - /** - * @return the showLabels - */ - public boolean isShowLabels() { - return showLabels; - } - - /** - * @param showLabels - * the showLabels to set - */ - public void setShowLabels(boolean showLabels) { - this.showLabels = showLabels; - } - - /** - * @return the sortColumn - */ - public DataEnum getSortColumn() { - return sortColumn; - } - - /** - * @param sortColumn - * the sortColumn to set - */ - public void setSortColumn(DataEnum sortColumn) { - this.sortColumn = sortColumn; - } - - /** - * @return the filterChanged - */ - public boolean isFilterChanged() { - return filterChanged; - } - - /** - * @param filterChanged - * the filterChanged to set - */ - public void setFilterChanged(boolean filterChanged) { - this.filterChanged = filterChanged; - GhgMonitorFilterChangeEvent evt = new GhgMonitorFilterChangeEvent( - "Filter"); - evt.setFilterChanged(filterChanged); - fireFilterChangeEvent(evt); - } - - /** - * Fire event so listeners are aware of change. - * - * @param evt - * The GhgMonitorFilterChangeEvent - */ - private void fireFilterChangeEvent(GhgMonitorFilterChangeEvent evt) { - for (GhgMonitorFilterChangeListener listener : filterChangeListenerList) { - listener.notifyUpdate(evt); - } - } - - /** - * Add a listener to the list. - * - * @param gmcl - */ - public void addGhgMonitorFilterChangeListener( - GhgMonitorFilterChangeListener gmcl) { - filterChangeListenerList.add(gmcl); - } - - /** - * Remove a listener from the list. - * - * @param gmcl - */ - public void removeGhgMonitorChangeListener( - GhgMonitorFilterChangeListener gmcl) { - if (filterChangeListenerList.contains(gmcl)) { - filterChangeListenerList.remove(gmcl); - } - } - - /** - * Add a listener to the list. - * - * @param gmzsl - */ - public void addGhgMonitorZoneSelectionListener( - GhgMonitorZoneSelectionListener gmzsl) { - zoneSelectionListenerList.add(gmzsl); - } - - /** - * Remove a listener from the list. - * - * @param gmzsl - */ - public void removeGhgMonitorZoneSelectionListener( - GhgMonitorZoneSelectionListener gmzsl) { - if (zoneSelectionListenerList.contains(gmzsl)) { - zoneSelectionListenerList.remove(gmzsl); - } - } - - /** - * Add a listener to the list. - * - * @param gmtsl - */ - public void addGhgMonitorTableSelectionListener( - GhgMonitorTableSelectionListener gmtsl) { - tableSelectionListenerList.add(gmtsl); - } - - /** - * Remove a listener from the list. - * - * @param gmtsl - */ - public void removeGhgMonitorTableSelectionListener( - GhgMonitorTableSelectionListener gmtsl) { - if (tableSelectionListenerList.contains(gmtsl)) { - tableSelectionListenerList.remove(gmtsl); - } - } - - /** - * Fire the table change event. - * - * @param evt - * The GhgMonitorTableSelectionEvent object - */ - public void fireTableSelectionEvent(GhgMonitorTableSelectionEvent evt) { - for (GhgMonitorTableSelectionListener listener : tableSelectionListenerList) { - listener.notifyUpdate(evt); - } - } - - /** - * Fire the map change event. - * - * @param evt - * The GhgMonitorZoneSelectionEvent object - */ - public void fireMapChangeEvent(GhgMonitorZoneSelectionEvent evt) { - for (GhgMonitorZoneSelectionListener listener : zoneSelectionListenerList) { - listener.notifyUpdate(evt); - } - } -} diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgFilterDlg.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgFilterDlg.java index d2810e83b0..6758eb7d8b 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgFilterDlg.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgFilterDlg.java @@ -21,10 +21,8 @@ package com.raytheon.viz.ghg.monitor; import java.util.ArrayList; 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.TreeSet; @@ -39,16 +37,16 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Shell; +import com.raytheon.uf.common.activetable.ActiveTableMode; import com.raytheon.uf.common.activetable.ActiveTableRecord; +import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteDefinition; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID; +import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; +import com.raytheon.uf.common.gfe.ifpclient.IFPClient; 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.viz.core.exception.VizException; -import com.raytheon.viz.gfe.GFEServerException; -import com.raytheon.viz.gfe.core.DataManager; -import com.raytheon.viz.gfe.core.IReferenceSetManager; +import com.raytheon.viz.core.mode.CAVEMode; import com.raytheon.viz.ghg.monitor.data.GhgConfigData; import com.raytheon.viz.ghg.monitor.data.GhgConfigData.AlertsFilterEnum; import com.raytheon.viz.ghg.monitor.data.GhgData; @@ -64,9 +62,11 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 25 MAR 2008 N/A lvenable Initial creation - * 17Jun2008 1157 MW Fegan Hooked in configuration. + * 17 Jun 2008 1157 MW Fegan Hooked in configuration. * 28 Nov 2012 1353 rferrel Changes for non-blocking dialog. * 28 Mar 2014 15769 ryu Removed "include OrgPil" check button. + * 16 Dec 2015 5184 dgilling Remove viz.gfe dependencies. + * 05 Feb 2016 5316 randerso Code cleanup * * * @@ -78,6 +78,12 @@ public class GhgFilterDlg extends CaveSWTDialog { private final IUFStatusHandler statusHandler = UFStatus .getHandler(GhgFilterDlg.class); + private final IFPClient ifpClient; + + private final DiscreteDefinition ddef; + + private final GhgFilterEngine filterEngine; + /** * Composite containing the list controls. */ @@ -105,18 +111,6 @@ public class GhgFilterDlg extends CaveSWTDialog { GhgConfigData.AlertsFilterEnum.ETN, GhgConfigData.AlertsFilterEnum.Seg }; - public static Map filterToEnumMap = new HashMap() { - - private static final long serialVersionUID = 6183513849706287870L; - { - put(GhgConfigData.AlertsFilterEnum.Action, - GhgConfigData.vtecActionNames); - put(GhgConfigData.AlertsFilterEnum.PhenSig, GhgConfigData - .getInstance().getPhenSigCodes()); - put(GhgConfigData.AlertsFilterEnum.Pil, GhgConfigData.vtecPILNames); - } - }; - /** * Array of filter group containers that contain the list controls. */ @@ -157,7 +151,7 @@ public class GhgFilterDlg extends CaveSWTDialog { */ private Button incPastEventsChk; - //private Button incOrgPilEvents; + // private Button incOrgPilEvents; private GhgDataFilter filter = null; @@ -186,12 +180,20 @@ public class GhgFilterDlg extends CaveSWTDialog { * * @param parent * Parent Shell. + * @param filter + * @param ifpClient + * @param ddef + * @param siteID4char */ - public GhgFilterDlg(Shell parent, GhgDataFilter filter) { + public GhgFilterDlg(Shell parent, GhgDataFilter filter, + IFPClient ifpClient, DiscreteDefinition ddef, String siteID4char) { super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); setText("GHG Monitor Filter Dialog"); this.filter = filter; + this.ifpClient = ifpClient; + this.ddef = ddef; + this.filterEngine = new GhgFilterEngine(siteID4char); } @Override @@ -239,7 +241,7 @@ public class GhgFilterDlg extends CaveSWTDialog { filter.includeAlerts = incAlertsChk.getSelection(); filter.includeMapSelections = incMapSelectionsChk.getSelection(); filter.includePastEvents = incPastEventsChk.getSelection(); - //filter.includeOrgPilEvents = incOrgPilEvents.getSelection(); + // filter.includeOrgPilEvents = incOrgPilEvents.getSelection(); filter.name = ""; @@ -270,7 +272,7 @@ public class GhgFilterDlg extends CaveSWTDialog { incAlertsChk.setSelection(filter.includeAlerts); incMapSelectionsChk.setSelection(filter.includeMapSelections); incPastEventsChk.setSelection(filter.includePastEvents); - //incOrgPilEvents.setSelection(filter.includeOrgPilEvents); + // incOrgPilEvents.setSelection(filter.includeOrgPilEvents); } /** @@ -572,26 +574,23 @@ public class GhgFilterDlg extends CaveSWTDialog { } }); - //incOrgPilEvents = new Button(filterOverrideGroup, SWT.CHECK); - //incOrgPilEvents.setText("Include OrgPil Events"); - //incOrgPilEvents.setSelection(filter.includeOrgPilEvents); - //incOrgPilEvents.addSelectionListener(new SelectionAdapter() { + // incOrgPilEvents = new Button(filterOverrideGroup, SWT.CHECK); + // incOrgPilEvents.setText("Include OrgPil Events"); + // incOrgPilEvents.setSelection(filter.includeOrgPilEvents); + // incOrgPilEvents.addSelectionListener(new SelectionAdapter() { - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse - * .swt.events.SelectionEvent) - */ /* - @Override - public void widgetSelected(SelectionEvent e) { - filter.includeOrgPilEvents = incOrgPilEvents.getSelection(); - updateDisplay(); - } - }); - */ + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse + * .swt.events.SelectionEvent) + */ + /* + * @Override public void widgetSelected(SelectionEvent e) { + * filter.includeOrgPilEvents = incOrgPilEvents.getSelection(); + * updateDisplay(); } }); + */ } /** @@ -621,57 +620,78 @@ public class GhgFilterDlg extends CaveSWTDialog { */ private void initListData() { // wfos (based on ISC edit areas) - DataManager dm = DataManager.getCurrentInstance(); - IReferenceSetManager refSetManager = dm.getRefManager(); - List rIdList = refSetManager.getAvailableSets(); - - try { - // get list of known sites (WFOs) and geoIds - List knownSites = dm.knownSites(); - - for (int i = 0; i < rIdList.size(); i++) { - ReferenceID refId = rIdList.get(i); - String name = refId.getName(); - if ((name.length() == 7) && name.startsWith("ISC_") - && knownSites.contains(name.substring(4))) { - String wfo4 = SiteMap.getInstance().getSite4LetterId( - name.substring(4)); - wfoList.add(wfo4); - } else if ((name.length() == 6) && !name.contains("_")) { - geoIdList.add(name); - } - } - - if (wfoList.contains("KWNS") == false) { - wfoList.add("KWNS"); - } - if (wfoList.contains("KNHC") == false) { - wfoList.add("KNHC"); - } - - // Get the VTEC active table - List activeTableList = DataManager - .getCurrentInstance().getActiveTable(); - - // Get the etn and seg values, these are based on actual data - Set etnSet = new TreeSet(); - Set segSet = new TreeSet(); - for (ActiveTableRecord rec : activeTableList) { - etnSet.add(rec.getEtn()); - segSet.add(String.valueOf(rec.getSeg())); - - etnArr = etnSet.toArray(new String[etnSet.size()]); - segArr = segSet.toArray(new String[segSet.size()]); - } - - // Sort the lists - Collections.sort(wfoList); - Collections.sort(geoIdList); - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); + ServerResponse> sr = ifpClient + .getReferenceInventory(); + List rIdList; + if (sr.isOkay()) { + rIdList = sr.getPayload(); + } else { + statusHandler.error(String.format( + "Error retrieving reference set inventory: %s", + sr.message())); + rIdList = Collections.emptyList(); } + + // get list of known sites (WFOs) and geoIds + ServerResponse> sr2 = ifpClient.getKnownSites(); + List knownSites; + if (sr2.isOkay()) { + knownSites = sr2.getPayload(); + } else { + statusHandler.error(String.format( + "Error retrieving known sites: %s", sr2.message())); + knownSites = Collections.emptyList(); + } + + for (int i = 0; i < rIdList.size(); i++) { + ReferenceID refId = rIdList.get(i); + String name = refId.getName(); + if ((name.length() == 7) && name.startsWith("ISC_") + && knownSites.contains(name.substring(4))) { + String wfo4 = SiteMap.getInstance().getSite4LetterId( + name.substring(4)); + wfoList.add(wfo4); + } else if ((name.length() == 6) && !name.contains("_")) { + geoIdList.add(name); + } + } + + if (wfoList.contains("KWNS") == false) { + wfoList.add("KWNS"); + } + if (wfoList.contains("KNHC") == false) { + wfoList.add("KNHC"); + } + + // Get the VTEC active table + CAVEMode opMode = CAVEMode.getMode(); + ActiveTableMode tableName = (opMode == CAVEMode.PRACTICE) ? ActiveTableMode.PRACTICE + : ActiveTableMode.OPERATIONAL; + ServerResponse> sr3 = ifpClient + .getVTECActiveTable(tableName); + List activeTableList; + if (sr3.isOkay()) { + activeTableList = sr3.getPayload(); + } else { + statusHandler.error(String.format( + "Error retrieving known sites: %s", sr3.message())); + activeTableList = Collections.emptyList(); + } + + // Get the etn and seg values, these are based on actual data + Set etnSet = new TreeSet(); + Set segSet = new TreeSet(); + for (ActiveTableRecord rec : activeTableList) { + etnSet.add(rec.getEtn()); + segSet.add(String.valueOf(rec.getSeg())); + + etnArr = etnSet.toArray(new String[etnSet.size()]); + segArr = segSet.toArray(new String[segSet.size()]); + } + + // Sort the lists + Collections.sort(wfoList); + Collections.sort(geoIdList); } /** @@ -682,68 +702,71 @@ public class GhgFilterDlg extends CaveSWTDialog { /* update the state of the filter boxes */ if (showCurrentHazardsChk.getSelection()) { // Get data from the active table and update the lists accordingly - try { - List tableDataList = DataManager - .getCurrentInstance().getActiveTable(); + CAVEMode opMode = CAVEMode.getMode(); + ActiveTableMode tableName = (opMode == CAVEMode.PRACTICE) ? ActiveTableMode.PRACTICE + : ActiveTableMode.OPERATIONAL; + ServerResponse> sr = ifpClient + .getVTECActiveTable(tableName); + List tableDataList; + if (sr.isOkay()) { + tableDataList = sr.getPayload(); + } else { + statusHandler.error(String.format( + "Error retrieving active table: %s", sr.message())); + tableDataList = Collections.emptyList(); + } - // compile the data for each list - Set actionSet = new HashSet(); - Set phenSigSet = new HashSet(); - Set pilSet = new HashSet(); - Set wfoSet = new HashSet(); - Set geoIdSet = new HashSet(); - Set etnSet = new HashSet(); - Set segSet = new HashSet(); + // compile the data for each list + Set actionSet = new HashSet(); + Set phenSigSet = new HashSet(); + Set pilSet = new HashSet(); + Set wfoSet = new HashSet(); + Set geoIdSet = new HashSet(); + Set etnSet = new HashSet(); + Set segSet = new HashSet(); - // Get the data from the activeTable - for (ActiveTableRecord rec : tableDataList) { - GhgData data = new GhgData(rec); + // Get the data from the activeTable + for (ActiveTableRecord rec : tableDataList) { + GhgData data = new GhgData(rec, ddef.getHazardDescription( + "Hazards_SFC", rec.getPhensig())); - if (GhgFilterEngine.filterCheck(data)) { - actionSet.add(data.getAction()); - phenSigSet.add(data.getPhenSig()); - pilSet.add(data.getPil()); - wfoSet.add(data.getWfo()); - geoIdSet.add(data.getGeoId()); - etnSet.add(data.getEtn()); - segSet.add(data.getSegNum()); - } + if (filterEngine.filterCheck(data)) { + actionSet.add(data.getAction()); + phenSigSet.add(data.getPhenSig()); + pilSet.add(data.getPil()); + wfoSet.add(data.getWfo()); + geoIdSet.add(data.getGeoId()); + etnSet.add(data.getEtn()); + segSet.add(data.getSegNum()); } + } - for (int i = 0; i < filterArray.length - 2; i++) { - GhgConfigData.AlertsFilterEnum type = filterArray[i]; - GhgFilterListGroup group = listGroupArray.get(i); + for (int i = 0; i < (filterArray.length - 2); i++) { + GhgConfigData.AlertsFilterEnum type = filterArray[i]; + GhgFilterListGroup group = listGroupArray.get(i); - if (type == AlertsFilterEnum.Action) { - group.setListValues(actionSet - .toArray(new String[actionSet.size()])); - } else if (type == AlertsFilterEnum.PhenSig) { - group.setListValues(phenSigSet - .toArray(new String[phenSigSet.size()])); - } else if (type == AlertsFilterEnum.Pil) { - group.setListValues(pilSet.toArray(new String[pilSet - .size()])); - } else if (type == AlertsFilterEnum.WFO) { - group.setListValues(wfoSet.toArray(new String[wfoSet - .size()])); - } else if (type == AlertsFilterEnum.GeoId) { - group.setListValues(geoIdSet - .toArray(new String[geoIdSet.size()])); - } else if (type == AlertsFilterEnum.ETN) { - group.setListValues(etnSet.toArray(new String[etnSet - .size()])); - } else if (type == AlertsFilterEnum.Seg) { - group.setListValues(segSet.toArray(new String[segSet - .size()])); - } + if (type == AlertsFilterEnum.Action) { + group.setListValues(actionSet.toArray(new String[actionSet + .size()])); + } else if (type == AlertsFilterEnum.PhenSig) { + group.setListValues(phenSigSet + .toArray(new String[phenSigSet.size()])); + } else if (type == AlertsFilterEnum.Pil) { + group.setListValues(pilSet.toArray(new String[pilSet.size()])); + } else if (type == AlertsFilterEnum.WFO) { + group.setListValues(wfoSet.toArray(new String[wfoSet.size()])); + } else if (type == AlertsFilterEnum.GeoId) { + group.setListValues(geoIdSet.toArray(new String[geoIdSet + .size()])); + } else if (type == AlertsFilterEnum.ETN) { + group.setListValues(etnSet.toArray(new String[etnSet.size()])); + } else if (type == AlertsFilterEnum.Seg) { + group.setListValues(segSet.toArray(new String[segSet.size()])); } - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), - e); } } else { // reset the list data - for (int i = 0; i < filterArray.length - 2; i++) { + for (int i = 0; i < (filterArray.length - 2); i++) { GhgConfigData.AlertsFilterEnum type = filterArray[i]; GhgFilterListGroup group = listGroupArray.get(i); switch (type) { diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgFontDlg.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgFontDlg.java index 197b8a7b4a..1ab41a2ea6 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgFontDlg.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgFontDlg.java @@ -44,8 +44,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 25 MAR 2008 N/A lvenable Initial creation - * 17Jun2008 1157 MW Fegan Added interaction with GHG Configuration. + * 17 JUN 2008 1157 MW Fegan Added interaction with GHG Configuration. * 28 NOV 2012 1353 rferrel Changes for non-blocking dialog. + * 05 Feb 2016 #5316 randerso Code cleanup * * * @@ -125,6 +126,7 @@ public class GhgFontDlg extends CaveSWTDialog { * * @param parent * Parent Shell. + * @param config */ public GhgFontDlg(Shell parent, GhgConfigData config) { super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgMapComp.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgMapComp.java deleted file mode 100644 index c770f8fc0b..0000000000 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgMapComp.java +++ /dev/null @@ -1,320 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.ghg.monitor; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.operation.TransformException; - -import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation; -import com.raytheon.uf.common.geospatial.MapUtil; -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.IDisplayPane; -import com.raytheon.uf.viz.core.drawables.IRenderableDisplay; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.localization.LocalizationManager; -import com.raytheon.uf.viz.core.map.MapDescriptor; -import com.raytheon.uf.viz.core.maps.display.PlainMapRenderableDisplay; -import com.raytheon.uf.viz.core.rsc.LoadProperties; -import com.raytheon.viz.gfe.core.DataManager; -import com.raytheon.viz.gfe.rsc.ZoneDbResourceData; -import com.raytheon.viz.gfe.rsc.zones.ZoneDbResource; -import com.raytheon.viz.ghg.Activator; -import com.raytheon.viz.ghg.constants.StatusConstants; -import com.raytheon.viz.ghg.monitor.constants.GhgMenuConstants; -import com.raytheon.viz.ghg.monitor.data.GhgConfigData; -import com.raytheon.viz.ui.panes.VizDisplayPane; -import com.vividsolutions.jts.geom.Envelope; - -/** - * Contains the GHG Monitor Map and handles all interactions with the map. - * - *
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 30May2008    1157       MW Fegan    Initial Creation.
- * 17Nov2008               wdougherty  Extra refresh() in paint handler removed.
- * 
- * 
- * - * @author mfegan - * @version 1.0 - */ - -public class GhgMapComp extends Composite implements IMenuSelectionClient { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(GhgMapComp.class); - /** - * The zoom level. - */ - private int zoomLevel = 0; - - /** - * The Zone File resource. - */ - private ZoneDbResource zoneDbResource; - - /** Map Action Handler */ - private GhgMapManager mapManager; - - /** - * Constructor. - * - * @param parent - * parent of this component. - */ - public GhgMapComp(Composite parent) { - super(parent, SWT.NONE); - init(); - } - - /** - * Performs steps needed to create the widget. - */ - private void init() { - GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); - GridLayout gl = new GridLayout(1, false); - gl.verticalSpacing = 1; - gl.marginHeight = 1; - setLayout(gl); - setLayoutData(gd); - - try { - initializeComponents(); - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - e.getLocalizedMessage(), e); - } - - this.pack(); - - addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - - } - }); - } - - /** - * Performs steps needed to initialize components. - * - * @throws FactoryException - * @throws TransformException - * @throws VizException - */ - private void initializeComponents() throws TransformException, - FactoryException, VizException { - // First thing, give the zone resource a bounding geometry. - GridLocation gloc = DataManager.getCurrentInstance().getParmManager() - .compositeGridLocation(); - Envelope env = MapUtil.getBoundingEnvelope(gloc); - - // Create a plain map renderable display - IRenderableDisplay renderableDisplay = new PlainMapRenderableDisplay( - new MapDescriptor(MapUtil.getGridGeometry(gloc))); - - // Create resource data for the zone resource - ZoneDbResourceData resourceData = new ZoneDbResourceData(); - List allTables = new ArrayList(4); - allTables.add(ZoneDbResource.COUNTY_TABLE); - allTables.add(ZoneDbResource.FIREWX_TABLE); - allTables.add(ZoneDbResource.MARINE_TABLE); - allTables.add(ZoneDbResource.PUBLIC_TABLE); - allTables.add(ZoneDbResource.OFFSHORE_TABLE); - resourceData.setQueryColumns(ZoneDbResource.COUNTY_TABLE, - ZoneDbResource.FIPS_FIELDS); - resourceData.setQueryColumns(ZoneDbResource.FIREWX_TABLE, - ZoneDbResource.FIREWX_FIELDS); - resourceData.setQueryColumns(ZoneDbResource.MARINE_TABLE, - ZoneDbResource.MARINE_FIELDS); - resourceData.setQueryColumns(ZoneDbResource.PUBLIC_TABLE, - ZoneDbResource.PUBLIC_FIELDS); - resourceData.setQueryColumns(ZoneDbResource.OFFSHORE_TABLE, - ZoneDbResource.OFFSHORE_FIELDS); - resourceData.setAllTables(allTables); - resourceData.setMainTable(ZoneDbResource.PUBLIC_TABLE); - - RGB selectionColor = GhgConfigData.getInstance() - .getMapSelectionsColors().getBackgroundRgb(); - resourceData.setSelectionColor(selectionColor); - resourceData.setMapName("GHG Monitor Map"); - - // Create the zone resource - zoneDbResource = resourceData.construct(new LoadProperties(), - renderableDisplay.getDescriptor()); - zoneDbResource.setBoundingEnvelope(env); - // Tell the zone resource which value is the local CWA/site id - zoneDbResource.setCwaId(LocalizationManager.getInstance() - .getCurrentSite()); - zoneDbResource.fitToCWA(); - zoneDbResource.setGHGType(); - - // Create the map manager - mapManager = new GhgMapManager(this); - mapManager.createComponent(this); - - // Add the zone resource to the display - renderableDisplay.getDescriptor().getResourceList().add(zoneDbResource); - - // Add the renderable display - mapManager.addPane(renderableDisplay); - } - - @Override - public void notifyMenuSelection(String menu, Object event, Object data) { - ZoneDbResourceData zdrd = zoneDbResource.getResourceData(); - switch ((GhgMenuConstants.MapMenuActions) event) { - case SHOW_LABELS: - zoneDbResource.setLabelZones((Boolean) data); - break; - case SHOW_MAP: - switch ((GhgMenuConstants.ShowMap) data) { - case SHOW_FIPS: - // FIPS shows both counties and marine zones - List tables = new ArrayList(2); - tables.add(ZoneDbResource.COUNTY_TABLE); - tables.add(ZoneDbResource.MARINE_TABLE); - zdrd.setTables(tables); - zdrd.setQueryColumns(ZoneDbResource.COUNTY_TABLE, - ZoneDbResource.FIPS_FIELDS); - zdrd.setQueryColumns(ZoneDbResource.MARINE_TABLE, - ZoneDbResource.MARINE_FIELDS); - break; - case SHOW_FIRE: - zoneDbResource.getResourceData().setMainTable( - ZoneDbResource.FIREWX_TABLE); - zdrd.setQueryColumns(ZoneDbResource.FIREWX_TABLE, - ZoneDbResource.FIREWX_FIELDS); - break; - case SHOW_MARINE: - zoneDbResource.getResourceData().setMainTable( - ZoneDbResource.MARINE_TABLE); - zdrd.setQueryColumns(ZoneDbResource.MARINE_TABLE, - ZoneDbResource.MARINE_FIELDS); - break; - case SHOW_PUBLIC: - zoneDbResource.getResourceData().setMainTable( - ZoneDbResource.PUBLIC_TABLE); - zdrd.setQueryColumns(ZoneDbResource.PUBLIC_TABLE, - ZoneDbResource.PUBLIC_FIELDS); - break; - } - zoneDbResource.setDirty(true); - break; - case ZOOM_MAP: - zoomLevel = ((GhgMenuConstants.ZoomLevel) data).getZoomLevel(); - GhgDisplayManager.getInstance().setZoomLevel(zoomLevel); - } - } - - /** - * Update the selected zoom. - */ - public void updateZoom() { - double zLev = GhgDisplayManager.getInstance().getZoomLevel(); - for (IDisplayPane dspPane : mapManager.getDisplayPanes()) { - // Reset the zoom - dspPane.setZoomLevel(1.0f); - dspPane.scaleToClientArea(); - - // Zoom into selected zoom level - ((VizDisplayPane) dspPane).zoom(1 / zLev); - } - - mapManager.refresh(); - } - - public void updateZone() { - GhgMenuConstants.ShowMap zoneType = GhgDisplayManager.getInstance() - .getZoneDisplay(); - ZoneDbResourceData zdrd = zoneDbResource.getResourceData(); - - switch (zoneType) { - case SHOW_FIPS: - // FIPS shows both counties and marine zones - List tables = new ArrayList(2); - tables.add(ZoneDbResource.COUNTY_TABLE); - tables.add(ZoneDbResource.MARINE_TABLE); - zdrd.setTables(tables); - zdrd.setQueryColumns(ZoneDbResource.COUNTY_TABLE, - ZoneDbResource.FIPS_FIELDS); - zdrd.setQueryColumns(ZoneDbResource.MARINE_TABLE, - ZoneDbResource.MARINE_FIELDS); - break; - case SHOW_FIRE: - zdrd.setMainTable(ZoneDbResource.FIREWX_TABLE); - zdrd.setQueryColumns(ZoneDbResource.FIREWX_TABLE, - ZoneDbResource.FIREWX_FIELDS); - break; - case SHOW_MARINE: - zdrd.setMainTable(ZoneDbResource.MARINE_TABLE); - zdrd.setQueryColumns(ZoneDbResource.MARINE_TABLE, - ZoneDbResource.MARINE_FIELDS); - break; - case SHOW_PUBLIC: - zdrd.setMainTable(ZoneDbResource.PUBLIC_TABLE); - zdrd.setQueryColumns(ZoneDbResource.PUBLIC_TABLE, - ZoneDbResource.PUBLIC_FIELDS); - break; - } - - zoneDbResource.setFilthy(true); - } - - public void updateLabels() { - zoneDbResource.setLabelZones(GhgDisplayManager.getInstance() - .isShowLabels()); - zoneDbResource.setDirty(true); - } - - public void updateMapColors() { - GhgConfigData config = GhgConfigData.getInstance(); - ZoneDbResourceData rData = zoneDbResource.getResourceData(); - rData.setSelectionColor(config.getMapSelectionsColors() - .getBackgroundRgb()); - } - - public void refresh() { - mapManager.refresh(); - } - - @Override - public void dispose() { - super.dispose(); - mapManager.dispose(); - } - - @Override - public boolean setFocus() { - mapManager.setFocus(); - return super.setFocus(); - } -} diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgMapManager.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgMapManager.java deleted file mode 100644 index a5edae980b..0000000000 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgMapManager.java +++ /dev/null @@ -1,255 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.ghg.monitor; - -import java.util.List; - -import org.eclipse.swt.widgets.Composite; - -import com.raytheon.uf.viz.core.IDisplayPane; -import com.raytheon.uf.viz.core.datastructure.LoopProperties; -import com.raytheon.viz.gfe.rsc.zones.ZoneDbResource; -import com.raytheon.viz.ghg.monitor.data.GhgConfigData; -import com.raytheon.viz.ghg.monitor.event.GhgMonitorTableSelectionEvent; -import com.raytheon.viz.ghg.monitor.event.GhgMonitorZoneSelectionEvent; -import com.raytheon.viz.ghg.monitor.listener.GhgMonitorTableSelectionListener; -import com.raytheon.viz.ghg.utilities.GhgDragDetector; -import com.raytheon.viz.ui.input.InputAdapter; -import com.raytheon.viz.ui.input.PanHandler; -import com.raytheon.viz.ui.panes.PaneManager; -import com.vividsolutions.jts.geom.Coordinate; - -/** - * GHG Monitor Map Manager is an interface between the map and the Monitoring - * dialog. - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * May 11, 2010            mpduff     Initial creation
- * Aug 27, 2013  #2301     dgilling   Fix mouse handler registration so they
- *                                    can't trigger events until map is loaded.
- * 
- * 
- * - * @author mpduff - * @version 1.0 - */ - -public class GhgMapManager extends PaneManager implements - GhgMonitorTableSelectionListener { - - private class GhgMapInputAdapter extends InputAdapter { - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseUp(int, int, - * int) - */ - @Override - public boolean handleMouseUp(int x, int y, int mouseButton) { - if (mouseButton == 1) { - if (!dragDetector.isDrag()) { - GhgConfigData config = GhgConfigData.getInstance(); - Coordinate c = translateClick(x, y); - - ZoneDbResource zdbr = getZoneResource(); - - if (c != null) { - selectedZones = zdbr.getOverlappingZones(c); - } else { - selectedZones = new String[0]; - } - - setHighlightedZones(selectedZones); - GhgMonitorZoneSelectionEvent evt = new GhgMonitorZoneSelectionEvent( - this); - evt.setHighlightedZones(selectedZones); - GhgDisplayManager.getInstance().fireMapChangeEvent(evt); - - // Set color to map selection color - getZoneResource().getResourceData().setSelectionColor( - config.getMapSelectionsColors().getBackgroundRgb()); - getZoneResource().setDirty(true); - refresh(); - } - } - - dragDetector.setDrag(false); - - return false; - } - } - - /** - * Zones that the user has selected (with the mouse). - */ - private String[] selectedZones; - - /** The looping properties */ - private LoopProperties loopProperties; - - /** The drag detector */ - private GhgDragDetector dragDetector; - - /** - * Constructor - */ - GhgMapManager(Composite parent) { - selectedZones = new String[0]; - loopProperties = new LoopProperties(); - GhgDisplayManager.getInstance().addGhgMonitorTableSelectionListener( - this); - } - - /** - * Create the dialog - * - * @param parent - * The parent composite - */ - public void createComponent(Composite parent) { - initializeComponents(this, parent); - } - - /** - * Get the display resource - * - * @return The ZoneDbResource - */ - public ZoneDbResource getZoneResource() { - IDisplayPane activePane = getActiveDisplayPane(); - List zoneRscs = activePane.getDescriptor() - .getResourceList() - .getResourcesByTypeAsType(ZoneDbResource.class); - if (zoneRscs.size() > 0) { - return zoneRscs.get(0); - } - return null; - } - - /** - * Set Label Zones flag. - * - * @param labelZones - * true to label, false to not label - */ - public void setLabelZones(boolean labelZones) { - if (getZoneResource() != null) { - getZoneResource().setLabelZones(labelZones); - } - } - - @Override - public void dispose() { - super.dispose(); - GhgDisplayManager.getInstance().removeGhgMonitorTableSelectionListener( - this); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ghg.monitor.listener.GhgMonitorTableSelectionListener - * #notifyUpdate - * (com.raytheon.viz.ghg.monitor.event.GhgMonitorTableSelectionEvent) - */ - @Override - public void notifyUpdate(GhgMonitorTableSelectionEvent evt) { - String[] highlightedZones = evt.getHighlightedZones(); - setHighlightedZones(highlightedZones); - ZoneDbResource zoneRsc = getZoneResource(); - if (zoneRsc != null) { - zoneRsc.getResourceData() - .setSelectionColor(evt.getSelectionColor()); - zoneRsc.setDirty(true); - } - refresh(); - } - - /** - * Set the zone IDs to highlight. This will cause the zones listed to be - * drawn in the highlighted color the next time the zone resource is - * painted. - * - * @param highlightedZones - * the highlightedZones to set - */ - public void setHighlightedZones(String[] highlightedZones) { - if (getZoneResource() != null) { - getZoneResource().setZoneIdsToShow(highlightedZones); - refresh(); - } - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.viz.core.IDisplayPaneContainer#getLoopProperties() - */ - @Override - public LoopProperties getLoopProperties() { - return loopProperties; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.core.IDisplayPaneContainer#setLoopProperties(com. - * raytheon.uf.viz.core.datastructure.LoopProperties) - */ - @Override - public void setLoopProperties(LoopProperties loopProperties) { - this.loopProperties = loopProperties; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.viz.core.IDisplayPaneContainer#refresh() - */ - @Override - public void refresh() { - if (getZoneResource() != null) { - getZoneResource().refreshSelections(); - super.refresh(); - } - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ui.panes.PaneManager#registerHandlers(com.raytheon.uf - * .viz.core.IDisplayPane) - */ - @Override - protected void registerHandlers(IDisplayPane pane) { - super.registerHandlers(pane); - registerMouseHandler(new GhgMapInputAdapter()); - registerMouseHandler(new PanHandler(this)); - dragDetector = new GhgDragDetector(); - registerMouseHandler(dragDetector); - } -} diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgMonitorDlg.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgMonitorDlg.java index e0377cc6a3..651fd2282b 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgMonitorDlg.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgMonitorDlg.java @@ -27,6 +27,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -37,6 +38,7 @@ import java.util.Timer; import java.util.TimerTask; import java.util.TreeSet; +import org.apache.commons.lang3.ArrayUtils; import org.eclipse.jface.action.ContributionItem; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; @@ -57,11 +59,18 @@ import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Table; +import com.raytheon.uf.common.activetable.ActiveTableMode; +import com.raytheon.uf.common.activetable.ActiveTableRecord; import com.raytheon.uf.common.activetable.VTECChange; import com.raytheon.uf.common.activetable.VTECTableChangeNotification; +import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation; +import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteDefinition; +import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; +import com.raytheon.uf.common.gfe.ifpclient.IFPClient; import com.raytheon.uf.common.jms.notification.INotificationObserver; import com.raytheon.uf.common.jms.notification.NotificationException; import com.raytheon.uf.common.jms.notification.NotificationMessage; +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; @@ -69,11 +78,11 @@ import com.raytheon.uf.common.time.SimulatedTime; import com.raytheon.uf.viz.core.RGBColors; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.localization.LocalizationManager; import com.raytheon.uf.viz.core.notification.jobs.NotificationManagerJob; import com.raytheon.viz.core.mode.CAVEMode; -import com.raytheon.viz.gfe.GFEServerException; -import com.raytheon.viz.gfe.core.DataManager; -import com.raytheon.viz.ghg.monitor.constants.GhgMenuConstants; +import com.raytheon.viz.ghg.exception.GhgMissingDataException; +import com.raytheon.viz.ghg.monitor.GHGSpatialViewer.ZoomLevel; import com.raytheon.viz.ghg.monitor.data.GhgAlertCheckData; import com.raytheon.viz.ghg.monitor.data.GhgAlertData; import com.raytheon.viz.ghg.monitor.data.GhgAlertsConfigData; @@ -85,12 +94,12 @@ import com.raytheon.viz.ghg.monitor.data.GhgConfigData.FeatureEnum; import com.raytheon.viz.ghg.monitor.data.GhgConfigData.SelectionEnum; import com.raytheon.viz.ghg.monitor.data.GhgData; import com.raytheon.viz.ghg.monitor.data.GhgDataFilter; +import com.raytheon.viz.ghg.monitor.event.AbstractGhgMonitorEvent; +import com.raytheon.viz.ghg.monitor.event.AbstractGhgMonitorEvent.GhgEventListener; import com.raytheon.viz.ghg.monitor.event.GhgMonitorFilterChangeEvent; import com.raytheon.viz.ghg.monitor.event.GhgMonitorTableSelectionEvent; import com.raytheon.viz.ghg.monitor.event.GhgMonitorZoneSelectionEvent; import com.raytheon.viz.ghg.monitor.filter.GhgFilterEngine; -import com.raytheon.viz.ghg.monitor.listener.GhgMonitorFilterChangeListener; -import com.raytheon.viz.ghg.monitor.listener.GhgMonitorZoneSelectionListener; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.dialogs.ICloseCallback; import com.raytheon.viz.ui.statusline.EdgeLayout; @@ -120,6 +129,10 @@ import com.raytheon.viz.ui.statusline.StatusStore; * 10 Apr 2014 15769 ryu Modify default configuration and menus to match A1. * Bring monitor to front before sending alert. * Adjusted delay for timer so it fires at the top of a minute. + * Dec 16, 2015 #5184 dgilling Remove viz.gfe dependencies. + * Feb 05, 2016 #5316 randerso Moved notification registration into GHGMonitorDlg + * Switched to use GhgSpatialViewer + * * * * @author lvenable @@ -127,13 +140,32 @@ import com.raytheon.viz.ui.statusline.StatusStore; * */ public class GhgMonitorDlg extends CaveSWTDialog implements - GhgMonitorFilterChangeListener, GhgMonitorZoneSelectionListener, - INotificationObserver { + INotificationObserver, GhgEventListener { + private static final String HAZARDS_PARM_NAME = "Hazards_SFC"; + + private static final String DEFAULT_MAP = "Public"; + + private static final ZoomLevel DEFAULT_ZOOM = GHGSpatialViewer.ZoomLevel.ZOOM_1; + private final IUFStatusHandler statusHandler = UFStatus .getHandler(GhgMonitorDlg.class); private static final Map labelToEnumMap; + private ActiveTableMode activeTableName; + + private final IFPClient ifpClient; + + private DiscreteDefinition discreteDef; + + private String myWFO; + + private String my4WFO; + + private GridLocation gridLocation; + + private GhgFilterEngine filterEngine; + private GhgAlertDlg alertDlg; private GhgColorDlg colorDlg; @@ -200,7 +232,7 @@ public class GhgMonitorDlg extends CaveSWTDialog implements /** * Composite class containing the GHG Map Display */ - protected GhgMapComp ghgMapComponent; + protected GHGSpatialViewer ghgSpatialViewer; /** * Sash Form used to adjust the area a composite takes up. @@ -210,7 +242,7 @@ public class GhgMonitorDlg extends CaveSWTDialog implements private FilterDisplay filterDisplay; private Menu columnsMenu; - + private MenuItem identifyTestMI; /** @@ -252,23 +284,70 @@ public class GhgMonitorDlg extends CaveSWTDialog implements * * @param parent * Parent Shell. + * @throws GhgMissingDataException */ - public GhgMonitorDlg(Shell parent) { + public GhgMonitorDlg(Shell parent) throws GhgMissingDataException { super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.INDEPENDENT_SHELL - | CAVE.DO_NOT_BLOCK); + | CAVE.PERSPECTIVE_INDEPENDENT | CAVE.DO_NOT_BLOCK); - // Register as a listener to the display manager and VTECActiveTable - GhgDisplayManager.getInstance().addGhgMonitorFilterChangeListener(this); + CAVEMode opMode = CAVEMode.getMode(); + activeTableName = (opMode == CAVEMode.PRACTICE) ? ActiveTableMode.PRACTICE + : ActiveTableMode.OPERATIONAL; + + // connection to ifpServer + this.ifpClient = connectToIFPServer(LocalizationManager.getInstance() + .getSite()); + + /* + * Using DiscreteDefinition in place of access to VTECTable to get + * Hazard Description + */ + ServerResponse sr = this.ifpClient + .getDiscreteDefinition(); + if (sr.isOkay()) { + this.discreteDef = sr.getPayload(); + } else { + throw new GhgMissingDataException(String.format( + "Unable to retrieve DiscreteDefinition: %s", sr.message())); + } + + this.filterEngine = new GhgFilterEngine(my4WFO); + + // setup for receiving notification messages from ifpServer NotificationManagerJob.addObserver("edex.alerts.vtec", this); } + private IFPClient connectToIFPServer(String site) + throws GhgMissingDataException { + IFPClient ifpClient = new IFPClient(VizApp.getWsId(), site); + + ServerResponse sr2 = ifpClient.getSiteID(); + if (sr2.isOkay()) { + this.myWFO = sr2.getPayload(); + this.my4WFO = SiteMap.getInstance().getSite4LetterId(this.myWFO); + } else { + throw new GhgMissingDataException(String.format( + "Unable to retrieve site ID: %s", sr2.message())); + } + + ServerResponse sr3 = ifpClient.getDBGridLocation(); + if (sr3.isOkay()) { + this.gridLocation = sr3.getPayload(); + } else { + throw new GhgMissingDataException(String.format( + "Unable to retrieve GridLocation: %s", sr3.message())); + } + + return ifpClient; + } + /** * Initialize the dialog's configuration */ private void initializeConfiguration() { // Load the default configuration file. // If this fails, fall back to the hardcoded defaults. - GhgConfigData configuration = GhgConfigData.getInstance(); + GhgConfigData configuration = GhgConfigData.buildInstance(); try { // Try and read a saved config file @@ -284,9 +363,11 @@ public class GhgMonitorDlg extends CaveSWTDialog implements @Override protected void disposed() { // Remove the listener from the list - GhgDisplayManager.getInstance().removeGhgMonitorChangeListener(this); - GhgDisplayManager.getInstance().removeGhgMonitorZoneSelectionListener( - this); + + ghgTableComp.removeSelectionListener(this); + ghgSpatialViewer.removeSelectionListener(this); + GhgConfigData.getInstance().removeFilterChangeListener(this); + NotificationManagerJob.removeObserver("edex.alerts.vtec", this); if (timer != null) { @@ -310,15 +391,11 @@ public class GhgMonitorDlg extends CaveSWTDialog implements // Read in config files initializeConfiguration(); - String activeTableName = "active"; - String practiceText = ""; - DataManager dm = DataManager.getCurrentInstance(); - - CAVEMode mode = dm.getOpMode(); - if (mode.equals(CAVEMode.PRACTICE)) { - activeTableName = "PRACTICE"; - practiceText = " [PRACTICE MODE]"; - } + CAVEMode mode = CAVEMode.getMode(); + String activeTableName = (!mode.equals(CAVEMode.PRACTICE)) ? "active" + : "PRACTICE"; + String practiceText = (!mode.equals(CAVEMode.PRACTICE)) ? "" + : " [PRACTICE MODE]"; // Set up the title bar text String userId = System.getProperty("user.name"); @@ -592,147 +669,41 @@ public class GhgMonitorDlg extends CaveSWTDialog implements // ----------------------------------------------------- // Create all the items in the Map dropdown menu // ----------------------------------------------------- + for (String map : GHGSpatialViewer.knownMaps()) { + MenuItem item = new MenuItem(mapMenu, SWT.RADIO); + item.setData(map); + item.setText("Show " + map); + item.setSelection(DEFAULT_MAP.equals(map)); + item.addSelectionListener(new SelectionAdapter() { - // Show Marine menu item - MenuItem showMarineMI = new MenuItem(mapMenu, SWT.RADIO); - showMarineMI.setText("Show Marine"); - showMarineMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - GhgDisplayManager.getInstance().setZoneDisplay( - GhgMenuConstants.ShowMap.SHOW_MARINE); - ghgMapComponent.updateZone(); - clearSelections(); - } - }); - - // Show FIPS menu item - MenuItem showFipsMI = new MenuItem(mapMenu, SWT.RADIO); - showFipsMI.setText("Show FIPS"); - showFipsMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - GhgDisplayManager.getInstance().setZoneDisplay( - GhgMenuConstants.ShowMap.SHOW_FIPS); - ghgMapComponent.updateZone(); - clearSelections(); - } - }); - - // Show Public menu item - MenuItem showPublicMI = new MenuItem(mapMenu, SWT.RADIO); - showPublicMI.setText("Show Public"); - showPublicMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - GhgDisplayManager.getInstance().setZoneDisplay( - GhgMenuConstants.ShowMap.SHOW_PUBLIC); - ghgMapComponent.updateZone(); - clearSelections(); - } - }); - showPublicMI.setSelection(true); - - // Show Fire Wx menu item - MenuItem showFireWxMI = new MenuItem(mapMenu, SWT.RADIO); - showFireWxMI.setText("Show FireWx"); - showFireWxMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - GhgDisplayManager.getInstance().setZoneDisplay( - GhgMenuConstants.ShowMap.SHOW_FIRE); - ghgMapComponent.updateZone(); - clearSelections(); - } - }); + @Override + public void widgetSelected(SelectionEvent e) { + MenuItem item = (MenuItem) e.widget; + if (item.getSelection()) { + showMap((String) item.getData()); + } + } + }); + } // Menu Separator new MenuItem(mapMenu, SWT.SEPARATOR); - // No Zoom menu item - MenuItem noZoomMI = new MenuItem(mapMenu, SWT.RADIO); - noZoomMI.setText("No Zoom"); - noZoomMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - GhgDisplayManager.getInstance().setZoomLevel( - GhgMenuConstants.ZoomLevel.ZOOM_NO_ZOOM.getZoomLevel()); - ghgMapComponent.updateZoom(); - } - }); - noZoomMI.setSelection(true); - - // x2 Zoom menu item - MenuItem x2ZoomMI = new MenuItem(mapMenu, SWT.RADIO); - x2ZoomMI.setText("x2"); - x2ZoomMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - GhgDisplayManager.getInstance().setZoomLevel( - GhgMenuConstants.ZoomLevel.ZOOM_2.getZoomLevel()); - ghgMapComponent.updateZoom(); - } - }); - - // x4 Zoom menu item - MenuItem x4ZoomMI = new MenuItem(mapMenu, SWT.RADIO); - x4ZoomMI.setText("x4"); - x4ZoomMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - GhgDisplayManager.getInstance().setZoomLevel( - GhgMenuConstants.ZoomLevel.ZOOM_4.getZoomLevel()); - ghgMapComponent.updateZoom(); - } - }); - - // x6 Zoom menu item - MenuItem x6ZoomMI = new MenuItem(mapMenu, SWT.RADIO); - x6ZoomMI.setText("x6"); - x6ZoomMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - GhgDisplayManager.getInstance().setZoomLevel( - GhgMenuConstants.ZoomLevel.ZOOM_6.getZoomLevel()); - ghgMapComponent.updateZoom(); - } - }); - - // x8 Zoom menu item - MenuItem x8ZoomMI = new MenuItem(mapMenu, SWT.RADIO); - x8ZoomMI.setText("x8"); - x8ZoomMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - GhgDisplayManager.getInstance().setZoomLevel( - GhgMenuConstants.ZoomLevel.ZOOM_8.getZoomLevel()); - ghgMapComponent.updateZoom(); - } - }); - - // x12 Zoom menu item - MenuItem x12ZoomMI = new MenuItem(mapMenu, SWT.RADIO); - x12ZoomMI.setText("x12"); - x12ZoomMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - GhgDisplayManager.getInstance().setZoomLevel( - GhgMenuConstants.ZoomLevel.ZOOM_12.getZoomLevel()); - ghgMapComponent.updateZoom(); - } - }); - - // x16 Zoom menu item - MenuItem x16ZoomMI = new MenuItem(mapMenu, SWT.RADIO); - x16ZoomMI.setText("x16"); - x16ZoomMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - GhgDisplayManager.getInstance().setZoomLevel( - GhgMenuConstants.ZoomLevel.ZOOM_16.getZoomLevel()); - ghgMapComponent.updateZoom(); - } - }); + for (ZoomLevel zoom : ZoomLevel.values()) { + MenuItem item = new MenuItem(mapMenu, SWT.RADIO); + item.setText(zoom.toString()); + item.setData(zoom); + item.setSelection(DEFAULT_ZOOM.equals(zoom)); + item.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + MenuItem item = (MenuItem) e.widget; + if (item.getSelection()) { + zoomMap((ZoomLevel) item.getData()); + } + } + }); + } // Menu Separator new MenuItem(mapMenu, SWT.SEPARATOR); @@ -742,14 +713,22 @@ public class GhgMonitorDlg extends CaveSWTDialog implements showLabelsMI.setText("Show Labels"); showLabelsMI.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent event) { - GhgDisplayManager.getInstance().setShowLabels( - showLabelsMI.getSelection()); - ghgMapComponent.updateLabels(); + public void widgetSelected(SelectionEvent e) { + MenuItem item = (MenuItem) e.widget; + ghgSpatialViewer.setLabelZones(item.getSelection()); } }); } + private void showMap(String mapName) { + ghgSpatialViewer.setMap(mapName); + clearSelections(); + } + + private void zoomMap(ZoomLevel zoom) { + ghgSpatialViewer.setZoomLevel(1.0 / zoom.getZoomLevel()); + } + /** * Create the Appearance menu. * @@ -794,7 +773,8 @@ public class GhgMonitorDlg extends CaveSWTDialog implements // Identify TEST Events menu item identifyTestMI = new MenuItem(appearanceMenu, SWT.CHECK); identifyTestMI.setText("Identify TEST Events"); - identifyTestMI.setSelection(GhgConfigData.getInstance().isIdentifyTestEvents()); + identifyTestMI.setSelection(GhgConfigData.getInstance() + .isIdentifyTestEvents()); identifyTestMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -822,7 +802,7 @@ public class GhgMonitorDlg extends CaveSWTDialog implements @Override public void widgetSelected(SelectionEvent event) { showFilterDialog(); - ghgMapComponent.refresh(); + ghgSpatialViewer.refresh(); } }); @@ -1035,6 +1015,10 @@ public class GhgMonitorDlg extends CaveSWTDialog implements createTextMapTabs(); createDataTable(); createStatusBar(shell); + + ghgTableComp.addSelectionListener(this); + ghgSpatialViewer.addSelectionListener(this); + GhgConfigData.getInstance().addFilterChangeListener(this); } private void createStatusBar(Shell shell) { @@ -1080,15 +1064,25 @@ public class GhgMonitorDlg extends CaveSWTDialog implements TabItem textTab = new TabItem(tabFolder, SWT.NONE); textTab.setText("Text"); - ghgTextComp = new GhgTextComp(tabFolder); // , controller); + ghgTextComp = new GhgTextComp(tabFolder); textTab.setControl(ghgTextComp); TabItem mapTab = new TabItem(tabFolder, SWT.NONE); mapTab.setText("Map"); - ghgMapComponent = new GhgMapComp(tabFolder); - mapTab.setControl(ghgMapComponent); - GhgDisplayManager.getInstance() - .addGhgMonitorZoneSelectionListener(this); + + Composite mapComp = new Composite(tabFolder, SWT.None); + gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gl = new GridLayout(1, false); + gl.marginHeight = 0; + gl.marginWidth = 0; + mapComp.setLayout(gl); + mapComp.setLayoutData(gd); + + ghgSpatialViewer = new GHGSpatialViewer(mapComp, myWFO, gridLocation, + null); + ghgSpatialViewer.setMap(DEFAULT_MAP); + ghgSpatialViewer.setZoomLevel(DEFAULT_ZOOM.getZoomLevel()); + mapTab.setControl(mapComp); tabFolder.setSelection(1); } @@ -1114,7 +1108,8 @@ public class GhgMonitorDlg extends CaveSWTDialog implements GhgConfigData configuration = GhgConfigData.getInstance(); filterDlg = new GhgFilterDlg(getShell(), - configuration.getCurrentFilter()); + configuration.getCurrentFilter(), ifpClient, discreteDef, + my4WFO); filterDlg.setCloseCallback(new ICloseCallback() { @Override @@ -1193,7 +1188,43 @@ public class GhgMonitorDlg extends CaveSWTDialog implements // Update the alert colors in the table if (changeColor == true) { ghgTableComp.updateDataColors(); - ghgMapComponent.updateMapColors(); + + Set mapZones = new HashSet<>(); + Set monitorZones = new HashSet<>(); + for (GhgData data : GhgMonitorDlg.this.dataList) { + switch (data.getSelection()) { + case MapSelection: + mapZones.add(data.getGeoId()); + break; + case MonitorSelection: + monitorZones.add(data.getGeoId()); + break; + default: + break; + + } + } + + if (!mapZones.isEmpty()) { + ghgSpatialViewer.setHighlightedZones( + GhgConfigData.getInstance() + .getMapSelectionsColors() + .getBackgroundRgb(), mapZones + .toArray(new String[mapZones + .size()])); + } + + if (!monitorZones.isEmpty()) { + ghgSpatialViewer + .setHighlightedZones( + GhgConfigData + .getInstance() + .getMonitorSelectionsColors() + .getBackgroundRgb(), + monitorZones + .toArray(new String[monitorZones + .size()])); + } } } colorDlg = null; @@ -1203,7 +1234,33 @@ public class GhgMonitorDlg extends CaveSWTDialog implements colorDlg.open(); } - public void refresh(boolean getData) { + /** + * Gets the ActiveTable records and returns them as a List. The + * list is based on the configuration selections. + * + * @return List list of GhgData objects + */ + private List getTableData() { + ServerResponse> sr = ifpClient + .getVTECActiveTable(activeTableName); + if (!sr.isOkay()) { + statusHandler.error(String.format("Error getting ActiveTable: %s", + sr.message())); + return Collections.emptyList(); + } + + List activeTableList = sr.getPayload(); + dataList.clear(); + for (ActiveTableRecord rec : activeTableList) { + GhgData data = new GhgData(rec, discreteDef.getHazardDescription( + HAZARDS_PARM_NAME, rec.getPhensig())); + dataList.add(data); + } + + return new ArrayList(dataList); + } + + private void refresh(boolean getData) { if (refreshing) { return; @@ -1211,14 +1268,16 @@ public class GhgMonitorDlg extends CaveSWTDialog implements try { refreshing = true; - GhgDisplayManager dispMan = GhgDisplayManager.getInstance(); List newList = new ArrayList(); if (getData) { - newList = dispMan.getTableData(); - // dataList.retainAll() replaces "retained" entries from - // newList, - // which messes up alert level flags, popping up extra banners. + newList = getTableData(); + /* + * dataList.retainAll() replaces "retained" entries from + * newList, which messes up alert level flags, popping up extra + * banners. + */ + // Remove dead entries from dataList. Iterator dlit = dataList.iterator(); while (dlit.hasNext()) { @@ -1249,12 +1308,7 @@ public class GhgMonitorDlg extends CaveSWTDialog implements tableData = calculateMonitorData(); // Check for alerts - try { - doAlerting(tableData); - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), - e); - } + doAlerting(tableData); filteredTable = doFiltering(tableData); @@ -1293,13 +1347,12 @@ public class GhgMonitorDlg extends CaveSWTDialog implements * * @param dataList * List list of data records - * @throws GFEServerException */ - private void doAlerting(List dataList) throws GFEServerException { + private void doAlerting(List dataList) { GhgAlertsConfigData alertsConfig = GhgConfigData.getInstance() .getAlerts(); for (GhgData data : dataList) { - GhgAlertCheckData alertCheckData = GhgFilterEngine.alertCheck(data); + GhgAlertCheckData alertCheckData = filterEngine.alertCheck(data); AlertsEnum alertType = alertCheckData.getAlertType(); GhgAlertData alertData = alertsConfig.getAlert(alertType); if (alertData.isBanner()) { @@ -1388,7 +1441,7 @@ public class GhgMonitorDlg extends CaveSWTDialog implements List tableList = new ArrayList(); for (GhgData gd : consolidatedList) { // Check if the data are filtered out - if (GhgFilterEngine.filterCheck(gd) == true) { + if (filterEngine.filterCheck(gd)) { tableList.add(gd); } } @@ -1403,12 +1456,8 @@ public class GhgMonitorDlg extends CaveSWTDialog implements */ private void addPhenSigDescription(List list) { for (GhgData rec : list) { - try { - rec.setHazard(GhgData.getHazardDescription(rec.getPhenSig())); - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), - e); - } + rec.setHazard(discreteDef.getHazardDescription(HAZARDS_PARM_NAME, + rec.getPhenSig())); } } @@ -1742,9 +1791,8 @@ public class GhgMonitorDlg extends CaveSWTDialog implements synchColumnsWithConfig(); refresh(false); ghgTableComp.packColumns(); - - identifyTestMI.setSelection( - configuration.isIdentifyTestEvents()); + + identifyTestMI.setSelection(configuration.isIdentifyTestEvents()); } /** @@ -1785,26 +1833,6 @@ public class GhgMonitorDlg extends CaveSWTDialog implements configuration.setDescending(sortDir == SWT.DOWN); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ghg.monitor.listener.GhgMonitorFilterChangeListener# - * notifyUpdate - * (com.raytheon.viz.ghg.monitor.event.GhgMonitorFilterChangeEvent) - */ - @Override - public void notifyUpdate(GhgMonitorFilterChangeEvent evt) { - boolean filterChanged = evt.isFilterChanged(); - boolean refreshData = false; - if (filterChanged == true) { - filterDisplay.updateFilter(GhgConfigData.CUSTOM_FILTER_NAME); - refreshData = true; - } - - refresh(refreshData); - } - private void calcStatusImportanceMap() { statusImportanceMap = new HashMap(); GhgConfigData config = GhgConfigData.getInstance(); @@ -1868,9 +1896,9 @@ public class GhgMonitorDlg extends CaveSWTDialog implements .setImportanceDict(statusImportanceMap); } - private void sendAlert(GhgAlertCheckData alertData, GhgData rec) - throws GFEServerException { - String headline = GhgData.getHazardDescription(rec.getPhenSig()); + private void sendAlert(GhgAlertCheckData alertData, GhgData rec) { + String headline = discreteDef.getHazardDescription(HAZARDS_PARM_NAME, + rec.getPhenSig()); String action = rec.getAction(); String[] cancelExpire = new String[] { "CAN", "EXP" }; StringBuilder buffer = new StringBuilder(); @@ -1929,7 +1957,7 @@ public class GhgMonitorDlg extends CaveSWTDialog implements // Within 30 minutes of purge/end time? boolean within30 = false; - if (later > -30 * 60) { + if (later > (-30 * 60)) { within30 = true; } @@ -1971,17 +1999,14 @@ public class GhgMonitorDlg extends CaveSWTDialog implements needRefresh = true; } else { for (VTECChange change : msg.getChanges()) { - if (filter.wfos == null - || filter.wfos.length == 0 - || Arrays.binarySearch(filter.wfos, change.getSite()) >= 0) { - if (filter.phenSigs == null - || filter.phenSigs.length == 0 - || Arrays.binarySearch(filter.phenSigs, - change.getPhensig()) >= 0) { - if (filter.pils == null - || filter.pils.length == 0 - || Arrays.binarySearch(filter.pils, - change.getPil()) >= 0) { + if (ArrayUtils.isEmpty(filter.wfos) + || (Arrays.binarySearch(filter.wfos, change.getSite()) >= 0)) { + if (ArrayUtils.isEmpty(filter.phenSigs) + || (Arrays.binarySearch(filter.phenSigs, + change.getPhensig()) >= 0)) { + if (ArrayUtils.isEmpty(filter.pils) + || (Arrays.binarySearch(filter.pils, + change.getPil()) >= 0)) { needRefresh = true; break; } @@ -1994,13 +2019,6 @@ public class GhgMonitorDlg extends CaveSWTDialog implements } } - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.common.jms.notification.INotificationObserver# - * notificationArrived - * (com.raytheon.uf.common.jms.notification.NotificationMessage[]) - */ @Override public void notificationArrived(NotificationMessage[] messages) { statusHandler.handle(Priority.VERBOSE, "Received " + messages.length @@ -2034,17 +2052,15 @@ public class GhgMonitorDlg extends CaveSWTDialog implements */ private void clearSelections() { // Clear map selections - GhgDisplayManager dMan = GhgDisplayManager.getInstance(); - GhgMonitorTableSelectionEvent evt = new GhgMonitorTableSelectionEvent( - this); - evt.setHighlightedZones(new String[0]); - dMan.fireTableSelectionEvent(evt); + List highlightedZones = Collections.emptyList(); + GhgMonitorTableSelectionEvent tableEvent = new GhgMonitorTableSelectionEvent(); + tableEvent.setHighlightedZones(highlightedZones); + notifyUpdate(tableEvent); // Clear spreadsheet selections - GhgMonitorZoneSelectionEvent evt2 = new GhgMonitorZoneSelectionEvent( - this); - evt2.setHighlightedZones(new String[0]); - dMan.fireMapChangeEvent(evt2); + GhgMonitorZoneSelectionEvent zoneEvent = new GhgMonitorZoneSelectionEvent(); + zoneEvent.setHighlightedZones(highlightedZones); + notifyUpdate(zoneEvent); } /* @@ -2079,12 +2095,7 @@ public class GhgMonitorDlg extends CaveSWTDialog implements @Override public void run() { // Check for alerts - try { - doAlerting(tableData); - } catch (GFEServerException e) { - statusHandler.handle(Priority.PROBLEM, - e.getLocalizedMessage(), e); - } + doAlerting(tableData); // Records can be added to or removed from the display // as they age. @@ -2121,34 +2132,50 @@ public class GhgMonitorDlg extends CaveSWTDialog implements } } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ghg.monitor.listener.GhgMonitorZoneSelectionListener - * #notifyUpdate - * (com.raytheon.viz.ghg.monitor.event.GhgMonitorZoneSelectionEvent) - */ @Override - public void notifyUpdate(GhgMonitorZoneSelectionEvent evt) { - String[] highlightedZones = evt.getHighlightedZones(); - // Be polite. Other handlers get the event, too. Sort a copy. - String[] sortHlZones = Arrays.copyOf(highlightedZones, - highlightedZones.length); - Arrays.sort(sortHlZones); - for (GhgData data : dataList) { - if (Arrays.binarySearch(sortHlZones, data.getGeoId()) >= 0) { - data.setSelection(SelectionEnum.MapSelection); - } else if (SelectionEnum.MapSelection == data.getSelection() - || highlightedZones.length > 0) { - // We may(?) get a zero-length map selection in response to - // selecting table records. In that case, we need to clear the - // map selections without interfering with the table (aka - // monitor) selection. However, if map zones are really being - // selected, then the table selection should be cleared, too. - data.setSelection(SelectionEnum.NoSelection); + public void notifyUpdate(AbstractGhgMonitorEvent event) { + if (event instanceof GhgMonitorTableSelectionEvent) { + GhgMonitorTableSelectionEvent tableEvent = (GhgMonitorTableSelectionEvent) event; + ghgTextComp.update(tableEvent.getGhgData()); + + Collection highlightedZones = tableEvent + .getHighlightedZones(); + ghgSpatialViewer.setHighlightedZones( + tableEvent.getSelectionColor(), highlightedZones + .toArray(new String[highlightedZones.size()])); + + } else if (event instanceof GhgMonitorZoneSelectionEvent) { + GhgMonitorZoneSelectionEvent zoneEvent = (GhgMonitorZoneSelectionEvent) event; + Collection highlightedZones = zoneEvent + .getHighlightedZones(); + for (GhgData data : dataList) { + if (highlightedZones.contains(data.getGeoId())) { + data.setSelection(SelectionEnum.MapSelection); + } else if (SelectionEnum.MapSelection.equals(data + .getSelection()) || (highlightedZones.size() > 0)) { + /* + * We may(?) get a zero-length map selection in response to + * selecting table records. In that case, we need to clear + * the map selections without interfering with the table + * (aka monitor) selection. However, if map zones are really + * being selected, then the table selection should be + * cleared, too. + */ + data.setSelection(SelectionEnum.NoSelection); + } } + refresh(false); + + ghgTableComp.update(highlightedZones); + + } else if (event instanceof GhgMonitorFilterChangeEvent) { + filterDisplay.updateFilter(GhgConfigData.CUSTOM_FILTER_NAME); + refresh(true); + + } else { + statusHandler.error("Received unexpected notification of type " + + event.getClass().getName()); } - refresh(false); + } } diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgTableComp.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgTableComp.java index 2a4ea5f0d0..7f7c2d4cdd 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgTableComp.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgTableComp.java @@ -20,6 +20,8 @@ package com.raytheon.viz.ghg.monitor; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; @@ -53,9 +55,8 @@ import com.raytheon.viz.ghg.monitor.data.GhgConfigData.DataEnum; import com.raytheon.viz.ghg.monitor.data.GhgConfigData.SelectionEnum; import com.raytheon.viz.ghg.monitor.data.GhgData; import com.raytheon.viz.ghg.monitor.data.GhgTableRowData; +import com.raytheon.viz.ghg.monitor.event.AbstractGhgMonitorEvent.GhgEventListener; import com.raytheon.viz.ghg.monitor.event.GhgMonitorTableSelectionEvent; -import com.raytheon.viz.ghg.monitor.event.GhgMonitorZoneSelectionEvent; -import com.raytheon.viz.ghg.monitor.listener.GhgMonitorZoneSelectionListener; /** * This class contains the GHG table and handle all of the table interactions. @@ -68,6 +69,8 @@ import com.raytheon.viz.ghg.monitor.listener.GhgMonitorZoneSelectionListener; * 19Jun2008 1157 MW Fegan Added banner popup for alerts. * 27Mar2009 1881 wldougher Enhance performance * 27Aug2013 2301 dgilling Fix Image loading for icons. + * Dec 16, 2015 5184 dgilling Remove viz.gfe dependencies. + * Feb 05, 2016 #5316 randerso Moved notification registration into GHGMonitorDlg * * * @@ -75,8 +78,8 @@ import com.raytheon.viz.ghg.monitor.listener.GhgMonitorZoneSelectionListener; * @version 1.0 * */ -public class GhgTableComp extends Composite implements IGhgSelectedTableColumn, - GhgMonitorZoneSelectionListener { +public class GhgTableComp extends Composite implements IGhgSelectedTableColumn { + /** * Font used for editors. */ @@ -133,6 +136,11 @@ public class GhgTableComp extends Composite implements IGhgSelectedTableColumn, */ private TableColumn lastSelectedColumn; + /** + * Table selection listener list + */ + private List tableSelectionListenerList = new ArrayList<>(); + /** * Constructor. * @@ -141,12 +149,11 @@ public class GhgTableComp extends Composite implements IGhgSelectedTableColumn, * @param columnsMap * Map of the visible/hidden table columns. */ - public GhgTableComp(Composite parent, Map columnsMap) { + public GhgTableComp(Composite parent, /* GhgDisplayManager displayMgr, */ + Map columnsMap) { super(parent, SWT.NONE); this.columnsMap = columnsMap; - GhgDisplayManager.getInstance() - .addGhgMonitorZoneSelectionListener(this); init(); } @@ -195,8 +202,6 @@ public class GhgTableComp extends Composite implements IGhgSelectedTableColumn, upImage.dispose(); downImage.dispose(); ghgTable.dispose(); - GhgDisplayManager.getInstance().removeGhgMonitorZoneSelectionListener( - this); for (GhgTableRowData row : ghgTableRowArray) { if (row != null) { @@ -573,9 +578,8 @@ public class GhgTableComp extends Composite implements IGhgSelectedTableColumn, String geoIds = row.getGhgData().getGeoId(); String[] geoIdArray = geoIds.split(","); - GhgMonitorTableSelectionEvent evt = new GhgMonitorTableSelectionEvent( - this); - evt.setHighlightedZones(geoIdArray); + GhgMonitorTableSelectionEvent evt = new GhgMonitorTableSelectionEvent(); + evt.setHighlightedZones(Arrays.asList(geoIdArray)); List dataList = new ArrayList(1); GhgData rowData = row.getGhgData(); rowData.setSelection(SelectionEnum.MonitorSelection); @@ -583,7 +587,7 @@ public class GhgTableComp extends Composite implements IGhgSelectedTableColumn, evt.setGhgData(dataList); evt.setSelectionColor(GhgConfigData.getInstance() .getMonitorSelectionsColors().getBackgroundRgb()); - GhgDisplayManager.getInstance().fireTableSelectionEvent(evt); + fireTableSelectionEvent(evt); } else { row.setSelected(false); } @@ -593,7 +597,7 @@ public class GhgTableComp extends Composite implements IGhgSelectedTableColumn, packColumns(); } - private void setSelection(String[] highlightedZones) { + private void setSelection(Collection highlightedZones) { ghgTable.deselectAll(); Set idSet = new HashSet(); List dataList = new ArrayList(); @@ -635,36 +639,18 @@ public class GhgTableComp extends Composite implements IGhgSelectedTableColumn, dataList.add(row.getGhgData()); } - Iterator iter = idSet.iterator(); - String[] zones = new String[idSet.size()]; - int index = 0; - while (iter.hasNext()) { - zones[index] = iter.next(); - index++; - } // build the event object - GhgMonitorTableSelectionEvent evt = new GhgMonitorTableSelectionEvent( - this); - evt.setHighlightedZones(zones); + GhgMonitorTableSelectionEvent evt = new GhgMonitorTableSelectionEvent(); + evt.setHighlightedZones(idSet); evt.setGhgData(dataList); evt.setSelectionColor(GhgConfigData.getInstance() - .getMonitorSelectionsColors().getBackgroundRgb()); - GhgDisplayManager.getInstance().fireTableSelectionEvent(evt); + .getMapSelectionsColors().getBackgroundRgb()); + fireTableSelectionEvent(evt); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ghg.monitor.listener.GhgMonitorZoneSelectionListener - * #notifyUpdate - * (com.raytheon.viz.ghg.monitor.event.GhgMonitorZoneSelectionEvent) - */ - @Override - public void notifyUpdate(GhgMonitorZoneSelectionEvent evt) { - String[] highlightedZones = evt.getHighlightedZones(); + public void update(Collection highlightedZones) { setSelection(highlightedZones); } @@ -676,8 +662,7 @@ public class GhgTableComp extends Composite implements IGhgSelectedTableColumn, */ public void setHighlight() { - GhgMonitorTableSelectionEvent evt = new GhgMonitorTableSelectionEvent( - this); + GhgMonitorTableSelectionEvent evt = new GhgMonitorTableSelectionEvent(); List dataList = new ArrayList(1); StringBuilder geoIdBuffer = new StringBuilder(); String sep = ""; @@ -707,9 +692,9 @@ public class GhgTableComp extends Composite implements IGhgSelectedTableColumn, // update the map to highlight this selection String geoIds = geoIdBuffer.toString(); String[] geoIdArray = geoIds.split(","); - evt.setHighlightedZones(geoIdArray); + evt.setHighlightedZones(Arrays.asList(geoIdArray)); evt.setGhgData(dataList); - GhgDisplayManager.getInstance().fireTableSelectionEvent(evt); + fireTableSelectionEvent(evt); } sortTableData(lastSelectedColumn); @@ -733,4 +718,36 @@ public class GhgTableComp extends Composite implements IGhgSelectedTableColumn, return selectionData; } + /** + * Add a listener to the list. + * + * @param listener + */ + public void addSelectionListener(GhgEventListener listener) { + if (!tableSelectionListenerList.contains(listener)) { + tableSelectionListenerList.add(listener); + } + } + + /** + * Remove a listener from the list. + * + * @param listener + */ + public void removeSelectionListener(GhgEventListener listener) { + tableSelectionListenerList.remove(listener); + } + + /** + * Fire the table change event. + * + * @param evt + * The GhgMonitorTableSelectionEvent object + */ + private void fireTableSelectionEvent(GhgMonitorTableSelectionEvent evt) { + for (GhgEventListener listener : tableSelectionListenerList) { + listener.notifyUpdate(evt); + } + } + } \ No newline at end of file diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgTextComp.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgTextComp.java index 68dff4f93e..9c9fe7b785 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgTextComp.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/GhgTextComp.java @@ -20,6 +20,7 @@ package com.raytheon.viz.ghg.monitor; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.SortedSet; @@ -37,10 +38,8 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; -import com.raytheon.viz.ghg.monitor.data.GhgData; import com.raytheon.viz.ghg.monitor.data.GhgConfigData.DataEnum; -import com.raytheon.viz.ghg.monitor.event.GhgMonitorTableSelectionEvent; -import com.raytheon.viz.ghg.monitor.listener.GhgMonitorTableSelectionListener; +import com.raytheon.viz.ghg.monitor.data.GhgData; /** * This class displays the GHG text component. @@ -50,6 +49,8 @@ import com.raytheon.viz.ghg.monitor.listener.GhgMonitorTableSelectionListener; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 25 MAR 2008 N/A lvenable Initial creation + * Dec 16, 2015 #5184 dgilling Remove viz.gfe dependencies. + * Feb 05, 2016 #5316 randerso Moved notification registration into GHGMonitorDlg * * * @@ -57,7 +58,7 @@ import com.raytheon.viz.ghg.monitor.listener.GhgMonitorTableSelectionListener; * @version 1.0 * */ -public class GhgTextComp extends Composite implements GhgMonitorTableSelectionListener { +public class GhgTextComp extends Composite { private static final int PIL_INDEX = DataEnum.PIL.ordinal(); private static final int ISSUE_INDEX = DataEnum.ISSUE_TIME.ordinal(); @@ -86,11 +87,11 @@ public class GhgTextComp extends Composite implements GhgMonitorTableSelectionLi * Editor background color in header sections */ private Color headerColor; - + /** * List of GhgData objects */ - private List dataList; + private Collection dataList; /** * Constructor. @@ -102,7 +103,6 @@ public class GhgTextComp extends Composite implements GhgMonitorTableSelectionLi super(parent, SWT.NONE); this.parent = parent; - GhgDisplayManager.getInstance().addGhgMonitorTableSelectionListener(this); init(); } @@ -127,14 +127,14 @@ public class GhgTextComp extends Composite implements GhgMonitorTableSelectionLi this.pack(); addDisposeListener(new DisposeListener() { + @Override public void widgetDisposed(DisposeEvent arg0) { disposeItems(); } }); } - + private void disposeItems() { - GhgDisplayManager.getInstance().removeGhgMonitorTableSelectionListener(this); editorFont.dispose(); editorColor.dispose(); headerColor.dispose(); @@ -175,11 +175,11 @@ public class GhgTextComp extends Composite implements GhgMonitorTableSelectionLi */ public void refresh() { styledText.setText(""); - + if (dataList != null) { // combine text where adjacent records are compatible List combined = new ArrayList(dataList); - + for (GhgData data : combined) { showGhgText(data); } @@ -203,24 +203,25 @@ public class GhgTextComp extends Composite implements GhgMonitorTableSelectionLi styledText.setStyleRange(range); styledText.append(overviewText); styledText.append("\n"); - + } - + // Segment text int start = styledText.getCharCount(); int startLine = styledText.getLineCount() - 1; String segHdr = String.format( - "Segment Text: Pil: %s IssueTime: %s\n", - dataCellNames[PIL_INDEX], dataCellNames[ISSUE_INDEX]); + "Segment Text: Pil: %s IssueTime: %s\n", + dataCellNames[PIL_INDEX], dataCellNames[ISSUE_INDEX]); styledText.append(segHdr); - + styledText.append("["); String sep = ""; // Get a sorted list of geoIds - SortedSet sortedSet= new TreeSet(data.getSegmentTextMap().keySet()); + SortedSet sortedSet = new TreeSet(data + .getSegmentTextMap().keySet()); String geoId = null; - + Iterator iter = sortedSet.iterator(); while (iter.hasNext()) { geoId = iter.next(); @@ -231,23 +232,18 @@ public class GhgTextComp extends Composite implements GhgMonitorTableSelectionLi int lineLen = styledText.getLineCount() - startLine - 1; int len = styledText.getCharCount() - start; styledText.setLineBackground(startLine, lineLen, headerColor); - StyleRange range = new StyleRange(start, len, editorColor, - headerColor); + StyleRange range = new StyleRange(start, len, editorColor, headerColor); styledText.setStyleRange(range); - + String segText = data.getSegmentText(geoId); if (segText != null) { styledText.append(segText); } - styledText.append("\n"); + styledText.append("\n"); } - /* (non-Javadoc) - * @see com.raytheon.viz.ghg.monitor.listener.GhgMonitorTableSelectionListener#notifyUpdate(com.raytheon.viz.ghg.monitor.event.GhgMonitorTableSelectionEvent) - */ - @Override - public void notifyUpdate(GhgMonitorTableSelectionEvent evt) { - dataList = evt.getGhgData(); + public void update(Collection data) { + dataList = data; refresh(); } } \ No newline at end of file diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/constants/GhgMenuConstants.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/constants/GhgMenuConstants.java deleted file mode 100644 index b1d3d2aff1..0000000000 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/constants/GhgMenuConstants.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.ghg.monitor.constants; - - -/** - * Contains constant values that describe the various menu actions. - *
- *
- * SOFTWARE HISTORY
- *
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 30May2008    1157       MW Fegan    Initial Creation
- * 
- * 
- * - * @author mfegan - * @version 1.0 - */ - -public class GhgMenuConstants { - /** - * Constructor. - */ - public GhgMenuConstants() { - // intentionally empty. - } - /** - * Enumeration defining the segments of the map menu. - */ - public enum MapMenuActions { - SHOW_MAP, - ZOOM_MAP, - SHOW_LABELS; - } - /** - * Enumeration defining the available zoom level. - */ - public enum ZoomLevel { - ZOOM_NO_ZOOM(1), - ZOOM_2(2), - ZOOM_4(4), - ZOOM_6(6), - ZOOM_8(8), - ZOOM_12(12), - ZOOM_16(16); - private int level; - - private ZoomLevel(int level) { - this.level = level; - } - - public int getZoomLevel() { - return level; - } - } - /** - * Enumeration defining the available maps. - */ - public enum ShowMap { - SHOW_FIPS("counties/counties.shp"), - SHOW_PUBLIC("zones/zones.shp"), - SHOW_FIRE("FireWx"), - SHOW_MARINE("Marine"); - - private String map; - - private ShowMap(String map) { - this.map = map; - } - - public String getMap() { - return map; - } - } -} diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/data/GhgColorData.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/data/GhgColorData.java index 53b1b5aaca..fa7ac919a5 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/data/GhgColorData.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/data/GhgColorData.java @@ -7,6 +7,8 @@ import javax.xml.bind.annotation.XmlRootElement; import org.eclipse.swt.graphics.RGB; +import com.raytheon.uf.viz.core.RGBColors; + /** * This class containing RGB foreground and background colors. * @@ -14,7 +16,9 @@ import org.eclipse.swt.graphics.RGB; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * 25 MAR 2008 1033 lvenable Initial creation + * Mar 25, 2008 1033 lvenable Initial creation + * Feb 05, 2016 5316 randerso Changed to use RGBColors to allow use of + * color names not just hex representations * * * @@ -96,27 +100,19 @@ public class GhgColorData { @XmlAttribute public String getForegroundRgbAsString() { - String result = String.format("#%02x%02x%02x", foregroundRgb.red, - foregroundRgb.green, foregroundRgb.blue); - return result; + return RGBColors.getColorName(foregroundRgb); } - public void setForegroundRgbAsString(String stringRep) { - foregroundRgb.red = Integer.parseInt(stringRep.substring(1, 3), 16); - foregroundRgb.green = Integer.parseInt(stringRep.substring(3, 5), 16); - foregroundRgb.blue = Integer.parseInt(stringRep.substring(5), 16); + public void setForegroundRgbAsString(String colorName) { + foregroundRgb = RGBColors.getRGBColor(colorName); } @XmlAttribute public String getBackgroundRgbAsString() { - String result = String.format("#%02x%02x%02x", backgroundRgb.red, - backgroundRgb.green, backgroundRgb.blue); - return result; + return RGBColors.getColorName(backgroundRgb); } - public void setBackgroundRgbAsString(String stringRep) { - backgroundRgb.red = Integer.parseInt(stringRep.substring(1, 3), 16); - backgroundRgb.green = Integer.parseInt(stringRep.substring(3, 5), 16); - backgroundRgb.blue = Integer.parseInt(stringRep.substring(5), 16); + public void setBackgroundRgbAsString(String colorName) { + backgroundRgb = RGBColors.getRGBColor(colorName); } } diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/data/GhgConfigData.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/data/GhgConfigData.java index 97102abcf5..90f7e16848 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/data/GhgConfigData.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/data/GhgConfigData.java @@ -20,6 +20,7 @@ package com.raytheon.viz.ghg.monitor.data; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -31,7 +32,6 @@ import java.util.Set; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import jep.JepException; @@ -44,25 +44,29 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; -import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; +import com.raytheon.uf.common.localization.SaveableOutputStream; +import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.python.PyUtil; import com.raytheon.uf.common.python.PythonScript; +import com.raytheon.uf.common.serialization.SerializationException; +import com.raytheon.uf.common.serialization.SingleTypeJAXBManager; 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.util.StringUtil; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.viz.gfe.constants.StatusConstants; -import com.raytheon.viz.gfe.core.DataManager; -import com.raytheon.viz.ghg.monitor.GhgDisplayManager; +import com.raytheon.uf.viz.core.localization.LocalizationManager; +import com.raytheon.viz.ghg.constants.StatusConstants; import com.raytheon.viz.ghg.monitor.config.GhgConfigXml; +import com.raytheon.viz.ghg.monitor.event.AbstractGhgMonitorEvent.GhgEventListener; +import com.raytheon.viz.ghg.monitor.event.GhgMonitorFilterChangeEvent; import com.raytheon.viz.ui.statusline.StatusMessage; import com.raytheon.viz.ui.statusline.StatusStore; @@ -84,7 +88,11 @@ import com.raytheon.viz.ui.statusline.StatusStore; * 28Nov2012 1353 rferrel Sort the list of filter names for dialog display. * 10Apr2014 15769 ryu Modified default config and GUI items to match A1. * Default config changed to hard coding instead of reading - * from config file. + * from config file. + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * Dec 16, 2015 5184 dgilling Remove viz.gfe dependencies. + * Feb 05, 2016 5316 randerso Moved notification of filter change into this class + * Feb 05, 2016 #5242 dgilling Remove calls to deprecated Localization APIs. * * * @author lvenable @@ -106,8 +114,8 @@ public final class GhgConfigData { /** * The VTEC Action Names */ - public static final String[] vtecActionNames = { "CAN", "CON", - "EXA", "EXB", "EXP", "EXT", "NEW", "UPG"}; + public static final String[] vtecActionNames = { "CAN", "CON", "EXA", + "EXB", "EXP", "EXT", "NEW", "UPG" }; /** * The VTEC Afos Product (PIL) Names @@ -203,6 +211,11 @@ public final class GhgConfigData { private boolean identifyTestEvents; + /** + * Filter change listener list + */ + private List filterChangeListenerList = new ArrayList<>(); + /** * Alerts enumeration. Contains the available alerts. {@code display} * attribute contains the text to display in the Alert Dialog. @@ -340,6 +353,7 @@ public final class GhgConfigData { // Fonts are system resources. We have to dispose of them // properly. display.addListener(SWT.Dispose, new Listener() { + @Override public void handleEvent(Event e) { Font font = fontMap.get(e.display); font.dispose(); @@ -362,17 +376,21 @@ public final class GhgConfigData { /** * Private constructor. + * + * @param displayMgr */ private GhgConfigData() { init(); } /** - * Get an instance of the GHG configuration data. + * Constructs an instance of the GHG configuration data. Used to build the + * initial instance and should only ever be called from the top-level GHG + * Monitor dialog. * * @return An instance of the GHG configuration data. */ - public static synchronized GhgConfigData getInstance() { + public static synchronized GhgConfigData buildInstance() { // If the GHG configuration data has not been created // then create a new instance. if (classInstance == null) { @@ -382,16 +400,27 @@ public final class GhgConfigData { return classInstance; } + /** + * Returns the instance of the GHG configuration data. Should be used to + * retrieve the config data instance by all other parts of the GHG Monitor + * code. + * + * @return An instance of the GHG configuration data. + */ + public static synchronized GhgConfigData getInstance() { + return classInstance; + } + /** * Initialize the configuration data. */ private void init() { loadDefault(); - + defaultFilter = currentFilter.clone(); defaultAlerts = currentAlerts.clone(); defaultColumns = new ArrayList(visibleColumns); - + // Get the VTECTable initializePython(); } @@ -600,7 +629,8 @@ public final class GhgConfigData { */ public void setCurrentFilter(GhgDataFilter filter) { currentFilter = filter; - GhgDisplayManager.getInstance().setFilterChanged(true); + GhgMonitorFilterChangeEvent evt = new GhgMonitorFilterChangeEvent(); + fireFilterChangeEvent(evt); } /** @@ -757,24 +787,19 @@ public final class GhgConfigData { IPathManager pathMgr = PathManagerFactory.getPathManager(); LocalizationContext locCtx = pathMgr.getContext( LocalizationType.CAVE_STATIC, LocalizationLevel.USER); - LocalizationFile localizationFile = pathMgr.getLocalizationFile(locCtx, - CONFIG_PATH); - File configFile = localizationFile.getFile(); + ILocalizationFile localizationFile = pathMgr.getLocalizationFile( + locCtx, CONFIG_PATH); - try { - JAXBContext ctx = JAXBContext.newInstance(GhgConfigXml.class); - Marshaller marshaller = ctx.createMarshaller(); - marshaller.marshal(config, configFile); - localizationFile.save(); - StatusStore.updateStatus(StatusConstants.SUBCATEGORY_GHG, + try (SaveableOutputStream outStream = localizationFile + .openOutputStream()) { + SingleTypeJAXBManager jaxb = SingleTypeJAXBManager + .createWithoutException(GhgConfigXml.class); + jaxb.marshalToStream(config, outStream); + outStream.save(); + StatusStore.updateStatus(StatusConstants.CATEGORY_GHG, "Saved configuration", StatusMessage.Importance.REGULAR); - - } catch (JAXBException e) { - statusHandler.handle(Priority.PROBLEM, - "Error saving GHG Monitor configuration", e); - } catch (LocalizationOpFailedException e) { - statusHandler.handle(Priority.PROBLEM, - "Error saving GHG Monitor configuration", e); + } catch (IOException | LocalizationException | SerializationException e) { + statusHandler.error("Error saving GHG Monitor configuration", e); } } @@ -798,20 +823,17 @@ public final class GhgConfigData { GhgAlertsConfigData alerts = new GhgAlertsConfigData(); alerts.setLocal(true); alerts.setTest(true); - alerts.addAlert(new GhgAlertData(true, true, 30, - AlertsEnum.AlertLvl1)); - alerts.addAlert(new GhgAlertData(true, true, 10, - AlertsEnum.AlertLvl2)); - alerts.addAlert(new GhgAlertData(true, true, 0, - AlertsEnum.ExpiredAlert)); - alerts.setActions(new String[] { "NEW", "CON", "COR", "EXT", - "EXA", "EXB" }); + alerts.addAlert(new GhgAlertData(true, true, 30, AlertsEnum.AlertLvl1)); + alerts.addAlert(new GhgAlertData(true, true, 10, AlertsEnum.AlertLvl2)); + alerts.addAlert(new GhgAlertData(true, true, 0, AlertsEnum.ExpiredAlert)); + alerts.setActions(new String[] { "NEW", "CON", "COR", "EXT", "EXA", + "EXB" }); alerts.setPhenSigs(new String[] {}); alerts.setPils(new String[] {}); currentAlerts = alerts; final String siteId = SiteMap.getInstance().getSite4LetterId( - DataManager.getCurrentInstance().getSiteID()); + LocalizationManager.getInstance().getSite()); /* generate some hardcoded default filter data */ currentFilter = new GhgDataFilter() { @@ -844,16 +866,16 @@ public final class GhgConfigData { visibleColumns = new ArrayList(DataEnum.values().length); // The initial columns visible. These need to match the ones set up by // GhgMonitorDlg. - visibleColumns.addAll(Arrays.asList(DataEnum.ACTION, DataEnum.ETN, - DataEnum.PHEN_SIG, DataEnum.START, DataEnum.END, - DataEnum.PURGE, DataEnum.ISSUE_TIME, DataEnum.PIL, - DataEnum.WFO)); + visibleColumns.addAll(Arrays + .asList(DataEnum.ACTION, DataEnum.ETN, DataEnum.PHEN_SIG, + DataEnum.START, DataEnum.END, DataEnum.PURGE, + DataEnum.ISSUE_TIME, DataEnum.PIL, DataEnum.WFO)); sortColumn = DataEnum.PURGE; - + descending = false; identifyTestEvents = true; - - //loadFrom(DEFAULT_PATH, true); + + // loadFrom(DEFAULT_PATH, true); } public void load(boolean reportMissing) { @@ -1044,4 +1066,37 @@ public final class GhgConfigData { } } } + + /** + * Add a listener to the list. + * + * @param listener + */ + public void addFilterChangeListener(GhgEventListener listener) { + filterChangeListenerList.add(listener); + } + + /** + * Remove a listener from the list. + * + * @param listener + */ + public void removeFilterChangeListener(GhgEventListener listener) { + if (filterChangeListenerList.contains(listener)) { + filterChangeListenerList.remove(listener); + } + } + + /** + * Fire event so listeners are aware of change. + * + * @param event + * The GhgMonitorFilterChangeEvent + */ + private void fireFilterChangeEvent(GhgMonitorFilterChangeEvent event) { + for (GhgEventListener listener : filterChangeListenerList) { + listener.notifyUpdate(event); + } + } + } diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/data/GhgData.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/data/GhgData.java index a991e4ecf9..06c56edc02 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/data/GhgData.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/data/GhgData.java @@ -31,11 +31,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import com.raytheon.uf.common.activetable.ActiveTableRecord; -import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteDefinition; -import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteKey; import com.raytheon.uf.common.time.SimulatedTime; -import com.raytheon.uf.viz.core.localization.LocalizationManager; -import com.raytheon.viz.gfe.GFEServerException; import com.raytheon.viz.ghg.monitor.data.GhgConfigData.AlertsEnum; import com.raytheon.viz.ghg.monitor.data.GhgConfigData.SelectionEnum; @@ -49,6 +45,8 @@ import com.raytheon.viz.ghg.monitor.data.GhgConfigData.SelectionEnum; * 25 MAR 2008 N/A lvenable Initial creation * 30 JUL 2010 6721 mpduff WFO now from officeid column. * 28 APR 2015 4027 randerso Expunged Calendar from ActiveTableRecord + * 05 JAN 2016 5184 dgilling Refactor constructor. + * 05 FEB 2016 5316 randerso Removed unnecessary exception handler * * * @@ -183,62 +181,24 @@ public class GhgData implements Comparable { */ SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm'Z' dd-MMM-yy"); - /** - * Get a hazard description for a phen.sig value. This code was essentially - * copied from MakeHazardDialog. - * - * @param phenSig - * The phensig whose description is needed. - * - * @return the description for the phensig. - * @throws GFEServerException - */ - public static String getHazardDescription(String phenSig) - throws GFEServerException { - String siteId = LocalizationManager.getInstance().getSite(); - DiscreteDefinition discreteDef = DiscreteKey.discreteDefinition(siteId); - - String sdesc = discreteDef.keyDesc("Hazards_SFC", phenSig); - - if (sdesc.isEmpty()) { - if ("CF.S".equals(phenSig)) { - sdesc = "COASTAL FLOOD STATEMENT"; - } else if ("LS.S".equals(phenSig)) { - sdesc = "LAKESHORE FLOOD STATEMENT"; - } else if ("MA.S".equals(phenSig)) { - sdesc = "MARINE WEATHER STATEMENT"; - } else if ("HU.S".equals(phenSig)) { - sdesc = "HURRICANE LOCAL STATEMENT"; - } else { - sdesc = "UNKNOWN PHENOMENON.SIGNIFICANCE"; - } - } - - return sdesc; - } - /** * Constructor. Uses the warning to create the data record. * * @param warning * the warning to convert - * @throws GFEServerException + * @param hazardDesc + * Headline-like description of the warning * */ - public GhgData(ActiveTableRecord warning) throws GFEServerException { - Date now = SimulatedTime.getSystemTime().getTime(); + public GhgData(ActiveTableRecord warning, String hazardDesc) { if (warning != null) { action = warning.getAct(); vtecString = warning.getVtecstr(); etn = warning.getEtn(); phen = warning.getPhen(); sig = warning.getSig(); - hazard = getHazardDescription(getPhenSig()); - try { - startDate = warning.getStartTime(); - } catch (Exception e) { - startDate = now; - } + hazard = hazardDesc; + startDate = warning.getStartTime(); endDate = warning.getEndTime(); purgeDate = warning.getPurgeTime(); issueTime = warning.getIssueTime(); diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/listener/GhgMonitorZoneSelectionListener.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/AbstractGhgMonitorEvent.java similarity index 64% rename from cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/listener/GhgMonitorZoneSelectionListener.java rename to cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/AbstractGhgMonitorEvent.java index cf0dbdf14b..3c78948096 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/listener/GhgMonitorZoneSelectionListener.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/AbstractGhgMonitorEvent.java @@ -17,27 +17,35 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.viz.ghg.monitor.listener; - -import com.raytheon.viz.ghg.monitor.event.GhgMonitorZoneSelectionEvent; +package com.raytheon.viz.ghg.monitor.event; /** - * Map zone selection listener interface. + * Base class for all GHG Monitor events * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Jun 2, 2010            mpduff     Initial creation
- *
+ * Feb 04, 2016  #5316     randerso     Initial creation
+ * 
  * 
- * - * @author mpduff - * @version 1.0 + * + * @author randerso + * @version 1.0 */ -public interface GhgMonitorZoneSelectionListener { - public void notifyUpdate(GhgMonitorZoneSelectionEvent evt); +public abstract class AbstractGhgMonitorEvent { + /** + * Interface for GHG Monitor event listeners + */ + public interface GhgEventListener { + /** + * Method called when evnet occurs + * + * @param event + */ + public void notifyUpdate(AbstractGhgMonitorEvent event); + } } diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/GhgMonitorFilterChangeEvent.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/GhgMonitorFilterChangeEvent.java index b3236b301e..df44ea0463 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/GhgMonitorFilterChangeEvent.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/GhgMonitorFilterChangeEvent.java @@ -19,49 +19,30 @@ **/ package com.raytheon.viz.ghg.monitor.event; -import java.util.EventObject; - /** * GHG Monitor data change event. * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * May 24, 2010            mpduff     Initial creation
- *
+ * May 24, 2010            mpduff      Initial creation
+ * Feb 05, 2016   #5316    randerso    Changed to extend AbstractGhgMonitorEvent
+ * 
  * 
- * + * * @author mpduff - * @version 1.0 + * @version 1.0 */ -public class GhgMonitorFilterChangeEvent extends EventObject { - - private static final long serialVersionUID = -4455895822255108354L; - - private boolean filterChanged = false; +public class GhgMonitorFilterChangeEvent extends AbstractGhgMonitorEvent { /** * @param source */ - public GhgMonitorFilterChangeEvent(Object source) { - super(source); + public GhgMonitorFilterChangeEvent() { + super(); } - - /** - * @return the filterChanged - */ - public boolean isFilterChanged() { - return filterChanged; - } - - /** - * @param filterChanged the filterChanged to set - */ - public void setFilterChanged(boolean filterChanged) { - this.filterChanged = filterChanged; - } } diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/GhgMonitorTableSelectionEvent.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/GhgMonitorTableSelectionEvent.java index 1cc03eb5a6..3e4deb15e1 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/GhgMonitorTableSelectionEvent.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/GhgMonitorTableSelectionEvent.java @@ -19,8 +19,8 @@ **/ package com.raytheon.viz.ghg.monitor.event; -import java.util.EventObject; -import java.util.List; +import java.util.Collection; +import java.util.Collections; import org.eclipse.swt.graphics.RGB; @@ -30,61 +30,62 @@ import com.raytheon.viz.ghg.monitor.data.GhgData; * Ghg Monitor table(spreadsheet) selection event object. * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Jun 2, 2010            mpduff     Initial creation
- *
+ * Jun 02, 2010            mpduff      Initial creation
+ * Feb 05, 2016   #5316    randerso    Changed to extend AbstractGhgMonitorEvent
+ * 
  * 
- * + * * @author mpduff - * @version 1.0 + * @version 1.0 */ -public class GhgMonitorTableSelectionEvent extends EventObject { +public class GhgMonitorTableSelectionEvent extends AbstractGhgMonitorEvent { - private static final long serialVersionUID = 3679672253157750734L; - - private List ghgData; + private Collection ghgData; + + private Collection highlightedZones = Collections.emptyList(); - private String[] highlightedZones = null; - private RGB selectionColor = null; - + /** * @param source */ - public GhgMonitorTableSelectionEvent(Object source) { - super(source); + public GhgMonitorTableSelectionEvent() { + super(); } - + /** - * @param highlightedZones the highlightedZones to set + * @param highlightedZones + * the highlightedZones to set */ - public void setHighlightedZones(String[] highlightedZones) { + public void setHighlightedZones(Collection highlightedZones) { this.highlightedZones = highlightedZones; } - + /** * @return the highlightedZones */ - public String[] getHighlightedZones() { + public Collection getHighlightedZones() { return highlightedZones; } /** * @return the ghgData */ - public List getGhgData() { + public Collection getGhgData() { return ghgData; } /** - * @param ghgData the ghgData to set + * @param ghgData + * the ghgData to set */ - public void setGhgData(List ghgData) { + public void setGhgData(Collection ghgData) { this.ghgData = ghgData; } @@ -96,7 +97,8 @@ public class GhgMonitorTableSelectionEvent extends EventObject { } /** - * @param selectionColor the selectionColor to set + * @param selectionColor + * the selectionColor to set */ public void setSelectionColor(RGB selectionColor) { this.selectionColor = selectionColor; diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/GhgMonitorZoneSelectionEvent.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/GhgMonitorZoneSelectionEvent.java index b3bcac0728..d7bd026767 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/GhgMonitorZoneSelectionEvent.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/event/GhgMonitorZoneSelectionEvent.java @@ -19,49 +19,51 @@ **/ package com.raytheon.viz.ghg.monitor.event; -import java.util.EventObject; +import java.util.Collection; +import java.util.Collections; /** * Ghg Monitor map selection event object. * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Jun 2, 2010            mpduff     Initial creation
- *
+ * Jun 02, 2010            mpduff      Initial creation
+ * Feb 05, 2016   #5316    randerso    Changed to extend AbstractGhgMonitorEvent
+ *                                     removed unnecessary field
+ * 
  * 
- * + * * @author mpduff - * @version 1.0 + * @version 1.0 */ -public class GhgMonitorZoneSelectionEvent extends EventObject { +public class GhgMonitorZoneSelectionEvent extends AbstractGhgMonitorEvent { - private static final long serialVersionUID = 7240901206407383480L; - - private String[] highlightedZones = null; + private Collection highlightedZones = Collections.emptyList(); /** * @param source */ - public GhgMonitorZoneSelectionEvent(Object source) { - super(source); + public GhgMonitorZoneSelectionEvent() { + super(); } /** * @return the highlightedZones */ - public String[] getHighlightedZones() { + public Collection getHighlightedZones() { return highlightedZones; } /** - * @param highlightedZones the highlightedZones to set + * @param highlightedZones + * the highlightedZones to set */ - public void setHighlightedZones(String[] highlightedZones) { + public void setHighlightedZones(Collection highlightedZones) { this.highlightedZones = highlightedZones; } } diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/filter/GhgFilterEngine.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/filter/GhgFilterEngine.java index 8f7ec20311..ae2fe9af2e 100644 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/filter/GhgFilterEngine.java +++ b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/filter/GhgFilterEngine.java @@ -20,12 +20,10 @@ package com.raytheon.viz.ghg.monitor.filter; import java.util.Arrays; -import java.util.Calendar; import java.util.List; -import com.raytheon.uf.common.site.SiteMap; import com.raytheon.uf.common.time.SimulatedTime; -import com.raytheon.viz.gfe.core.DataManager; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.viz.ghg.monitor.data.GhgAlertCheckData; import com.raytheon.viz.ghg.monitor.data.GhgAlertData; import com.raytheon.viz.ghg.monitor.data.GhgAlertsConfigData; @@ -41,10 +39,12 @@ import com.raytheon.viz.ghg.monitor.data.GhgDataFilter; *
  * 
  * SOFTWARE HISTORY
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * 26May2010               mpduff      Initial creation.
- * 11Apr2014    15769      ryu         Promote delta minutes if within a few seconds.
+ * May 26, 2010            mpduff      Initial creation.
+ * Apr 11, 2014  15769     ryu         Promote delta minutes if within a few seconds.
+ * Jan 05, 2016  #5184     dgilling    Re-factor to remove statics.
  * 
  * 
* @@ -53,8 +53,16 @@ import com.raytheon.viz.ghg.monitor.data.GhgDataFilter; */ public class GhgFilterEngine { - /** Milliseconds per minute */ - private static final int MILLIS_PER_MINUTE = 60 * 1000; + + private final String siteID; + + /** + * @param siteID + * 4-character site identifier. + */ + public GhgFilterEngine(String siteID) { + this.siteID = siteID; + } /** * Compare this record to the filter and see if it should be included or @@ -64,7 +72,7 @@ public class GhgFilterEngine { * The GhgData object to check * @return true if included, false if filtered out */ - public static boolean filterCheck(GhgData gd) { + public boolean filterCheck(GhgData gd) { boolean include = true; GhgConfigData config = GhgConfigData.getInstance(); @@ -75,7 +83,7 @@ public class GhgFilterEngine { // settings boolean includeAlerts = filter.includeAlerts; if (includeAlerts - && (GhgFilterEngine.alertCheck(gd).getAlertType() != AlertsEnum.NoAlerts)) { + && (alertCheck(gd).getAlertType() != AlertsEnum.NoAlerts)) { return true; } @@ -154,14 +162,12 @@ public class GhgFilterEngine { return include; } - public static GhgAlertCheckData alertCheck(GhgData gd) { - String wfo = DataManager.getCurrentInstance().getSiteID(); - wfo = SiteMap.getInstance().getSite4LetterId(wfo); + public GhgAlertCheckData alertCheck(GhgData gd) { GhgConfigData config = GhgConfigData.getInstance(); GhgAlertsConfigData alertFilter = config.getAlerts(); // Alerts for my WFO - if (alertFilter.isLocal() && !gd.getWfo().equals(wfo)) { + if (alertFilter.isLocal() && !gd.getWfo().equals(siteID)) { return new GhgAlertCheckData(AlertsEnum.NoAlerts); } @@ -216,10 +222,10 @@ public class GhgFilterEngine { // minutes until purge time int margin = 4999; // promote the deltas if within 5 seconds - int deltaP = (int) ((gd.getPurgeDate().getTime() - now + margin) / MILLIS_PER_MINUTE); + int deltaP = (int) ((gd.getPurgeDate().getTime() - now + margin) / TimeUtil.MILLIS_PER_MINUTE); // minutes until end time - int deltaE = (int) ((gd.getEndDate().getTime() - now + margin) / MILLIS_PER_MINUTE); + int deltaE = (int) ((gd.getEndDate().getTime() - now + margin) / TimeUtil.MILLIS_PER_MINUTE); long earlierT = Math.min(gd.getPurgeDate().getTime(), gd.getEndDate() .getTime()); @@ -233,7 +239,7 @@ public class GhgFilterEngine { GhgAlertData expiredAlert = config.getAlerts().getAlert( AlertsEnum.ExpiredAlert); int tval = expiredAlert.getTime(); - long triggerTime = earlierT - (tval * MILLIS_PER_MINUTE); + long triggerTime = earlierT - (tval * TimeUtil.MILLIS_PER_MINUTE); if (expiredAlert.isEnabled() && (now >= triggerTime)) { return new GhgAlertCheckData(AlertsEnum.ExpiredAlert, deltaP, @@ -243,7 +249,7 @@ public class GhgFilterEngine { // time limit for non-Expired alerts GhgAlertData alert2 = config.getAlerts().getAlert(AlertsEnum.AlertLvl2); tval = alert2.getTime(); - triggerTime = earlierT - (tval * MILLIS_PER_MINUTE); + triggerTime = earlierT - (tval * TimeUtil.MILLIS_PER_MINUTE); if (alert2.isEnabled() && (now >= triggerTime)) { return new GhgAlertCheckData(AlertsEnum.AlertLvl2, deltaP, deltaE); @@ -251,7 +257,7 @@ public class GhgFilterEngine { GhgAlertData alert1 = config.getAlerts().getAlert(AlertsEnum.AlertLvl1); tval = alert1.getTime(); - triggerTime = earlierT - (tval * MILLIS_PER_MINUTE); + triggerTime = earlierT - (tval * TimeUtil.MILLIS_PER_MINUTE); if (alert1.isEnabled() && (now >= triggerTime)) { return new GhgAlertCheckData(AlertsEnum.AlertLvl1, deltaP, deltaE); diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/listener/GhgMonitorFilterChangeListener.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/listener/GhgMonitorFilterChangeListener.java deleted file mode 100644 index ab92eec900..0000000000 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/monitor/listener/GhgMonitorFilterChangeListener.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.ghg.monitor.listener; - -import com.raytheon.viz.ghg.monitor.event.GhgMonitorFilterChangeEvent; - -/** - * GHG Monitor change listener. - * - *
- *
- * SOFTWARE HISTORY
- *
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * May 24, 2010            mpduff     Initial creation
- *
- * 
- * - * @author mpduff - * @version 1.0 - */ - -public interface GhgMonitorFilterChangeListener { - public void notifyUpdate(GhgMonitorFilterChangeEvent evt); -} diff --git a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/utilities/GhgDragDetector.java b/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/utilities/GhgDragDetector.java deleted file mode 100644 index fac5e96f22..0000000000 --- a/cave/com.raytheon.viz.ghg/src/com/raytheon/viz/ghg/utilities/GhgDragDetector.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -/** - * - */ -package com.raytheon.viz.ghg.utilities; - -import com.raytheon.viz.ui.input.InputAdapter; - -/** - * A class created to capture MB1 drags for GHGLauncher before PanHandler eats - * the event. The basic idea is that this input handler is put into the chain - * where it will receive mouseDownMove events before PanHandler. It sets an - * internal flag to remember the drag. When - * GhgLauncher.theMouseListener.handleMouseUp() is called, it checks and clears - * the flag and can skip its "click" behavior if a the action was a drag. Note - * that since this object will receive mouseUp events before - * GhgLauncher.theMouseListener, it cannot clear its own wasDrag flag. - * - * @author wdougherty - * - */ -public class GhgDragDetector extends InputAdapter { - private boolean drag; - - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDownMove(int, - * int, int) - */ - @Override - public boolean handleMouseDownMove(int x, int y, int mouseButton) { - if (mouseButton == 1) { - setDrag(true); - } - return false; - } - - /** - * @return the wasDrag - */ - public boolean isDrag() { - return drag; - } - - /** - * @param drag - * the drag to set - */ - public void setDrag(boolean drag) { - this.drag = drag; - } - -} diff --git a/cave/com.raytheon.viz.hydro/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.hydro/META-INF/MANIFEST.MF index 71cd3955a6..d74e2f699a 100644 --- a/cave/com.raytheon.viz.hydro/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.hydro/META-INF/MANIFEST.MF @@ -21,7 +21,8 @@ Require-Bundle: org.eclipse.core.runtime, com.raytheon.uf.common.dataplugin.shef;bundle-version="1.12.1174", com.raytheon.uf.viz.core.point;bundle-version="1.15.0", com.raytheon.uf.common.auth;bundle-version="1.12.1174", - com.google.guava;bundle-version="18.0.0" + com.google.guava;bundle-version="18.0.0", + org.slf4j;bundle-version="1.7.12" Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.viz.hydro, com.raytheon.viz.hydro.perspective, diff --git a/cave/com.raytheon.viz.hydro/plugin.xml b/cave/com.raytheon.viz.hydro/plugin.xml index 85be1165d6..f40110b602 100644 --- a/cave/com.raytheon.viz.hydro/plugin.xml +++ b/cave/com.raytheon.viz.hydro/plugin.xml @@ -390,7 +390,7 @@ style="radio"> + value="6"> + value="7"> + value="8"> + value="9"> + value="10"> + value="14"> * @@ -79,6 +80,17 @@ public abstract class CaveHydroSWTDialog extends CaveSWTDialog { super(parentShell, SWT.DIALOG_TRIM, caveStyle | CAVE.DO_NOT_BLOCK); } + /** + * Construct top level dialog specifying cave style and make it + * non-blocking. + * + * @param display + * @param caveStyle + */ + protected CaveHydroSWTDialog(Display display, int caveStyle) { + super(display, SWT.DIALOG_TRIM, caveStyle | CAVE.DO_NOT_BLOCK); + } + /** * Determine if there is a currently selected LID. * diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/flashfloodguidance/FlashFloodGuidanceDlg.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/flashfloodguidance/FlashFloodGuidanceDlg.java index 73deb90953..f5626aa0a0 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/flashfloodguidance/FlashFloodGuidanceDlg.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/flashfloodguidance/FlashFloodGuidanceDlg.java @@ -54,6 +54,9 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue; import com.raytheon.uf.common.ohd.AppsDefaults; +import com.raytheon.uf.common.ohd.AppsDefaultsDirKeys; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.uf.viz.core.drawables.ResourcePair; @@ -77,6 +80,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * 07 Feb 2013 1578 rferrel Changes for non-blocking dialog. * Jul 21, 2015 4500 rjpeter Use Number in blind cast. * Aug 05, 2015 4486 rjpeter Changed Timestamp to Date. + * Jan 26, 2016 5264 bkowal Eliminate use of System println. * * * @author lvenable @@ -84,6 +88,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * */ public class FlashFloodGuidanceDlg extends CaveSWTDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(getClass()); + /** Date format for the dates */ private static SimpleDateFormat sdf = null; @@ -877,20 +884,17 @@ public class FlashFloodGuidanceDlg extends CaveSWTDialog { dataList.add(sortedMap.get(s)); } } else { - // WFO Grided data, read xmrg directory - String ffgDirToken = "gaff_mosaic_dir"; - /* * Retrieve the path of the WFO ffg_product file from the * "apps defaults" file. */ - String ffgDirPath = AppsDefaults.getInstance() - .getToken(ffgDirToken); + String ffgDirPath = AppsDefaults.getInstance().getToken( + AppsDefaultsDirKeys.GAFF_MOSAIC_DIR); if (ffgDirPath == null) { - // TODO error handling - System.err - .println("Error getting WFO FFG directory from token " - + ffgDirToken); + statusHandler + .error("Error getting WFO FFG directory from token: " + + AppsDefaultsDirKeys.GAFF_MOSAIC_DIR + "."); + return; } File ffgDir = new File(ffgDirPath); diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/gagedisplay/GageColorLegendAction.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/gagedisplay/GageColorLegendAction.java index 2249820e77..54c09a1f3f 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/gagedisplay/GageColorLegendAction.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/gagedisplay/GageColorLegendAction.java @@ -20,6 +20,7 @@ package com.raytheon.viz.hydro.gagedisplay; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; import com.raytheon.viz.ui.cmenu.AbstractRightClickAction; @@ -30,11 +31,12 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Jul 2, 2008 1194 mpduff Initial creation - * Feb 07, 2013 1578 rferre Changes for non-blocking GageLegend. - * Feb 27, 2013 1790 rferrel Bug fix for non-blocking dialogs. + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Jul 02, 2008 1194 mpduff Initial creation + * Feb 07, 2013 1578 rferrel Changes for non-blocking GageLegend. + * Feb 27, 2013 1790 rferrel Bug fix for non-blocking dialogs. + * Jan 15, 2015 5054 randerso Remove unnecessary new Shell * * * @@ -68,7 +70,9 @@ public class GageColorLegendAction extends AbstractRightClickAction { @Override public void run() { if (dialog == null || dialog.isDisposed()) { - dialog = new GageLegend(new Shell()); + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(); + dialog = new GageLegend(shell); dialog.open(); } else { dialog.bringToTop(); diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/pointdatacontrol/engine/PointDataControlDerive.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/pointdatacontrol/engine/PointDataControlDerive.java old mode 100644 new mode 100755 index f63da140bc..681897b781 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/pointdatacontrol/engine/PointDataControlDerive.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/pointdatacontrol/engine/PointDataControlDerive.java @@ -51,13 +51,15 @@ import com.raytheon.viz.hydrocommon.pdc.PDCOptionData; import com.raytheon.viz.hydrocommon.pdc.PDCOptions; /** - * TODO Add Description + * PointData Control Derive. * *
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Nov 15, 2008            mpduff     Initial creation
+ * Nov 24, 2015 5142       skorolev   Fixed time window issue for precipitation.
+ * 
  * 
* * @author mpduff @@ -71,17 +73,17 @@ public class PointDataControlDerive { private static final int PRECIP_TS_BEST = 64; - private ArrayList heightList; + private List heightList; - private ArrayList qList; + private List qList; - private ArrayList riverStatusList; + private List riverStatusList; - private ArrayList obsList; + private List obsList; - private ArrayList dataList = new ArrayList(); + private final List dataList = new ArrayList(); - Map> tsRankingMap = null; + private Map> tsRankingMap = null; private double change = PDCConstants.MISSING_VALUE; @@ -99,23 +101,22 @@ public class PointDataControlDerive { * lid. It eliminates these multiple reports by using type source ranking * from the Ingest table. * - * @param isOneTime Is this being run via the runOneTime method? - * @return ArrayList The list of data with a single entry per lid, - * or null if no data + * @param isOneTime + * Is this being run via the runOneTime method? + * @param pcOptions + * */ public void deriveRiverReports(boolean isOneTime, PDCOptions pcOptions) { - PointDataControlManager pdcManager = PointDataControlManager.getInstance(); + PointDataControlManager pdcManager = PointDataControlManager + .getInstance(); HydroDisplayManager displayManager = HydroDisplayManager.getInstance(); - heightList = (ArrayList) pdcManager.getObsHeightList(); - qList = (ArrayList) pdcManager.getObsDischargeList(); - riverStatusList = (ArrayList) pdcManager - .getRiverStatusList(); + heightList = pdcManager.getObsHeightList(); + qList = pdcManager.getObsDischargeList(); + riverStatusList = pdcManager.getRiverStatusList(); List repObsPtr = null; List repFcstPtr = null; -// PDCOptionData pcOptions = pdcManager.getPCOptionData(); - String currentLid = null; int startRecord = 0; int changeWindow = 0; @@ -207,8 +208,11 @@ public class PointDataControlDerive { changeWindow /= 2; } - heightList.trimToSize(); - if ((heightList != null) && (heightList.size() > 0)) { + if ((heightList != null) && !heightList.isEmpty()) { + List tmpList = heightList; + heightList = new ArrayList<>(tmpList.size()); + heightList.addAll(tmpList); + tmpList = null; repObsPtr = processList(heightList, changeWindow); } @@ -216,16 +220,15 @@ public class PointDataControlDerive { repObsPtr = processList(qList, changeWindow); } } - + if (isOneTime) { pdcManager.setFcst2ReportList(repFcstPtr); pdcManager.setObs2ReportList(repObsPtr); } else { pdcManager.setFcstReportList(repFcstPtr); - + /* - * We don't want to trigger a draw here so set - * flag to false. + * We don't want to trigger a draw here so set flag to false. */ displayManager.setDrawStation(false); pdcManager.setObsReportList(repObsPtr); @@ -241,14 +244,14 @@ public class PointDataControlDerive { * * @return */ - public ArrayList deriveOtherReports() { - PointDataControlManager pdcManager = PointDataControlManager.getInstance(); + public List deriveOtherReports() { + PointDataControlManager pdcManager = PointDataControlManager + .getInstance(); /* This list is one of obs or latestobsvalue */ - obsList = (ArrayList) pdcManager.getObservationList(); + obsList = pdcManager.getObservationList(); int changeWindow = 0; String currentLid = null; - int startRecord = 0; if ((obsList == null) || (obsList.size() == 0)) { return null; @@ -266,11 +269,10 @@ public class PointDataControlDerive { changeWindow /= 2; } - ArrayList tempObsList = new ArrayList(); + List tempObsList = new ArrayList(); for (int i = 0; i < obsList.size(); i++) { if (!currentLid.equals(obsList.get(i).getLid())) { -// startRecord = i; processLidObs(tempObsList, changeWindow); /* @@ -294,12 +296,13 @@ public class PointDataControlDerive { return dataList; } - private List processList(ArrayList obsList, int changeWindow) { + private List processList(List obsList, + int changeWindow) { /* loop thru the list and process each lid. */ String currentLid = obsList.get(0).getLid(); int startRecord = 0; - ArrayList tempObsList = new ArrayList(); - ArrayList returnList = new ArrayList(); + List tempObsList = new ArrayList(); + List returnList = new ArrayList(); for (int i = 0; i < obsList.size(); i++) { /* @@ -318,8 +321,8 @@ public class PointDataControlDerive { * ingestfilter type source rank to determine which one to use. */ - returnList = processLidObsRiver(tempObsList, 0,//startRecord, - changeWindow, returnList); + returnList = processLidObsRiver(tempObsList, 0, changeWindow, + returnList); /* * set up data for next pass through the input linked list @@ -339,7 +342,7 @@ public class PointDataControlDerive { returnList = processLidObsRiver(tempObsList, startRecord, changeWindow, returnList); } - + return returnList; } @@ -390,15 +393,16 @@ public class PointDataControlDerive { * * @param startRecord * Starting record - * @param endRecord - * Ending record * @param lidCount * Number of lids * @param changeWindow * Number of hours + * @param obsList + * @param inputList + * @return */ - private ArrayList processLidObsRiver(ArrayList obsList, - int startRecord, int changeWindow, ArrayList inputList) { + private List processLidObsRiver(List obsList, + int startRecord, int changeWindow, List inputList) { Observation bestObs = null; GageData oneRpt = new GageData(); List outputList = new ArrayList(); @@ -413,7 +417,7 @@ public class PointDataControlDerive { bestObs = deriveReportObsRiver(obsList, startRecord, changeWindow); if (bestObs != null) { - oneRpt.setLid(bestObs.getLid());; + oneRpt.setLid(bestObs.getLid()); oneRpt.setPe(bestObs.getPe()); oneRpt.setDur(bestObs.getDur()); oneRpt.setTs(bestObs.getTs()); @@ -423,7 +427,6 @@ public class PointDataControlDerive { oneRpt.setQuality_code(PDCConstants.DEFAULT_QC_VALUE); oneRpt.setValue(bestObs.getValue()); oneRpt.setValidtime(bestObs.getObstime()); -// oneRpt.setBasistime(bestObs.getBasistime()); /* initialize the list */ if (inputList != null) { @@ -436,7 +439,7 @@ public class PointDataControlDerive { outputList = inputList; } - return (ArrayList) outputList; + return outputList; } /** @@ -450,9 +453,15 @@ public class PointDataControlDerive { * Type Source * @param rsList * Riverstatus list + * @param startRecord + * @param inputList + * GageData list + * @param pcOptions + * @return */ - private ArrayList processLidRS(String[] useTs, - List rsList, int startRecord, List inputList, PDCOptions pcOptions) { + private List processLidRS(String[] useTs, + List rsList, int startRecord, + List inputList, PDCOptions pcOptions) { Riverstatus best = null; GageData oneRpt = new GageData(); List outputList = new ArrayList(); @@ -496,11 +505,16 @@ public class PointDataControlDerive { outputList = inputList; } - return (ArrayList) outputList; + return outputList; } - private void processLidObs(ArrayList tempObsList, - int changeWindow) { + /** + * Process Lid Obs + * + * @param tempObsList + * @param changeWindow + */ + private void processLidObs(List tempObsList, int changeWindow) { GageData oneRpt = new GageData(); PDCOptionData pcOptions = PDCOptionData.getInstance(); @@ -509,7 +523,6 @@ public class PointDataControlDerive { * pointer returned is of the type Observation. */ Observation best = deriveReportObs(tempObsList, changeWindow); -// Observation best = deriveReportObs(obsList, startRecord, changeWindow); /* copy the best report into the linked list of Reports */ if (best != null) { @@ -550,7 +563,7 @@ public class PointDataControlDerive { * Number of hours * @return */ - private Observation deriveReportObs(ArrayList obsList, + private Observation deriveReportObs(List obsList, int changeWindow) { PDCOptionData pcOptions = PDCOptionData.getInstance(); PDCDataManager manager = PDCDataManager.getInstance(); @@ -558,7 +571,6 @@ public class PointDataControlDerive { Observation bestObs2 = null; String currentTS = null; String bestTS = null; - boolean recordFound = false; long currentDiff; long bestDiff; int firstObsFound = 0; @@ -576,8 +588,6 @@ public class PointDataControlDerive { * physical element. */ - recordFound = false; - tsRankingMap = manager.getIngestFilterData(); for (int i = 0; i < obsList.size(); i++) { @@ -596,7 +606,8 @@ public class PointDataControlDerive { * best ts if it has a higher rank */ int result = compareTSRank(obsList.get(i).getTs(), bestTS, - tsRankingMap.get(obsList.get(i).getLid()), obsList.get(i).getPe()); + tsRankingMap.get(obsList.get(i).getLid()), + obsList.get(i).getPe()); if (result < 0) { bestTS = obsList.get(i).getTs(); } @@ -734,11 +745,11 @@ public class PointDataControlDerive { * Number of hours * @return */ - private Observation deriveReportObsRiver(ArrayList obsList, + private Observation deriveReportObsRiver(List obsList, int startRecord, int changeWindow) { PDCOptionData pcOptions = PDCOptionData.getInstance(); PDCDataManager manager = PDCDataManager.getInstance(); - Observation obs = null; + Observation bestObs = null; Observation bestObs2 = null; String currentTS = null; @@ -749,22 +760,16 @@ public class PointDataControlDerive { int firstObsFound = 0; int lastObsFound = 0; - // if (riverStatusList.size() == 0) { - // return null; - // } - /* determine which physical element to use for this location */ if (pcOptions.getPrimary() == 1) { usePE = "HG"; if (startRecord >= obsList.size()) { return bestObs; } - + /* try and find the pe specified for this location */ - RiverStat rsInfo = manager.getRiverStatus(obsList.get( - startRecord).getLid()); -// RiverStat rsInfo = manager.getRiverStatus(riverStatusList.get( -// startRecord).getId().getLid()); + RiverStat rsInfo = manager.getRiverStatus(obsList.get(startRecord) + .getLid()); if (rsInfo != null) { usePE = rsInfo.getPe(); @@ -810,7 +815,8 @@ public class PointDataControlDerive { */ int result = compareTSRank(obsList.get(i).getTs(), bestTS, - tsRankingMap.get(obsList.get(i).getLid()), obsList.get(i).getPe()); + tsRankingMap.get(obsList.get(i).getLid()), obsList + .get(i).getPe()); if (result < 0) { bestTS = obsList.get(i).getTs(); } @@ -849,8 +855,10 @@ public class PointDataControlDerive { return obsList.get(i); } else if (pcOptions.getTimeMode() == PDCConstants.TimeModeType.SETTIME .getTimeMode()) { - currentDiff = Math.abs(pcOptions.getValidTime().getTime() - - SimulatedTime.getSystemTime().getTime().getTime()); + currentDiff = Math + .abs(pcOptions.getValidTime().getTime() + - SimulatedTime.getSystemTime().getTime() + .getTime()); /* * Is the observation the closest to the center time so far? @@ -871,7 +879,8 @@ public class PointDataControlDerive { if (firstObsFound == 0) { currentDiff = Math.abs(pcOptions.getValidTime() .getTime() - - SimulatedTime.getSystemTime().getTime().getTime()); + - SimulatedTime.getSystemTime().getTime() + .getTime()); /* Is the observation inside the window? */ if (currentDiff / (PDCConstants.MILLIS_PER_MINUTE * 60) <= changeWindow) { @@ -912,7 +921,8 @@ public class PointDataControlDerive { } else if (lastObsFound == 0) { currentDiff = Math.abs(pcOptions.getValidTime() .getTime() - - SimulatedTime.getSystemTime().getTime().getTime()); + - SimulatedTime.getSystemTime().getTime() + .getTime()); /* Find the best observation in the lower time window. */ @@ -935,12 +945,13 @@ public class PointDataControlDerive { } } } else { - /* - * Both observations necessary to compute the change - * have been found. - */ - change = bestObs.getValue() - bestObs2.getValue(); - + if (bestObs != null && bestObs2 != null) { + /* + * Both observations necessary to compute the change + * have been found. + */ + change = bestObs.getValue() - bestObs2.getValue(); + } return bestObs; } break; @@ -968,11 +979,13 @@ public class PointDataControlDerive { * Type Source * @param rsList * Riverstatus list + * @param startRecord + * @param pcOptions * @return */ private Riverstatus deriveReportRS(String[] useTs, List rsList, int startRecord, PDCOptions pcOptions) { -// PDCOptionData pcOptions = pdcManager.getPCOptionData(); + PDCDataManager manager = PDCDataManager.getInstance(); Riverstatus best = null; String usePE = null; @@ -1037,8 +1050,9 @@ public class PointDataControlDerive { */ int result = compareTSRank(rsList.get(i).getId().getTs(), - bestTs, tsRankingMap.get(rsList.get(i).getId() - .getLid()), rsList.get(i).getId().getPe()); + bestTs, + tsRankingMap.get(rsList.get(i).getId().getLid()), + rsList.get(i).getId().getPe()); if (result < 0) { bestTs = rsList.get(i).getId().getTs(); } @@ -1075,9 +1089,10 @@ public class PointDataControlDerive { return best; } - public ArrayList deriveRainReports() { + public List deriveRainReports() { PDCOptionData pcOptions = PDCOptionData.getInstance(); - PointDataControlManager pdcManager = PointDataControlManager.getInstance(); + PointDataControlManager pdcManager = PointDataControlManager + .getInstance(); ArrayList reportList = new ArrayList(); long beginTime; long endTime; @@ -1123,11 +1138,12 @@ public class PointDataControlDerive { } else { beginTime = pcOptions.getValidTime().getTime() - (pcOptions.getDurHours() * PDCConstants.MILLIS_PER_HOUR); - endTime = pcOptions.getValidTime().getTime(); + endTime = pcOptions.getValidTime().getTime() + + (pcOptions.getDurHours() * PDCConstants.MILLIS_PER_HOUR); } - List rawPcList = new ArrayList(); - List rawPpList = new ArrayList(); + ArrayList rawPcList = new ArrayList(); + ArrayList rawPpList = new ArrayList(); if (pcList != null) { for (Curpc cp : pcList) { rawPcList.add(convertCurpc2Rawpc(cp)); @@ -1146,10 +1162,8 @@ public class PointDataControlDerive { endDate.setTime(endTime); GetTotalPrecip gtp = new GetTotalPrecip(); - reportList = gtp.getTotalRawPrecip((ArrayList) rawPcList, - (ArrayList) rawPpList, - beginDate, endDate, - endingTimeMatch, minPercent, precipSettings); + reportList = gtp.getTotalRawPrecip(rawPcList, rawPpList, beginDate, + endDate, endingTimeMatch, minPercent, precipSettings); return reportList; } @@ -1220,7 +1234,7 @@ public class PointDataControlDerive { /** * @return the heightList */ - public ArrayList getHeightList() { + public List getHeightList() { return heightList; } @@ -1228,14 +1242,14 @@ public class PointDataControlDerive { * @param heightList * the heightList to set */ - public void setHeightList(ArrayList heightList) { + public void setHeightList(List heightList) { this.heightList = heightList; } /** * @return the qList */ - public ArrayList getQList() { + public List getQList() { return qList; } @@ -1243,14 +1257,14 @@ public class PointDataControlDerive { * @param list * the qList to set */ - public void setQList(ArrayList list) { + public void setQList(List list) { qList = list; } /** * @return the riverStatusList */ - public ArrayList getRiverStatusList() { + public List getRiverStatusList() { return riverStatusList; } @@ -1258,7 +1272,7 @@ public class PointDataControlDerive { * @param riverStatusList * the riverStatusList to set */ - public void setRiverStatusList(ArrayList riverStatusList) { + public void setRiverStatusList(List riverStatusList) { this.riverStatusList = riverStatusList; } } \ No newline at end of file diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/resource/DamLocationResource.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/resource/DamLocationResource.java index 6962838d38..13e6b94b9f 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/resource/DamLocationResource.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/resource/DamLocationResource.java @@ -67,9 +67,11 @@ import com.vividsolutions.jts.index.strtree.STRtree; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Apr 20, 2009 mpduff Initial creation + * Apr 20, 2009 mpduff Initial creation * Sep 23, 2009 3069 mpduff Changed the parent class to HydroPointResource. * Jan 22, 2013 15553 wkwock Correct DamCrest selection algorithm + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling + * * * * @author mpduff @@ -122,7 +124,7 @@ public class DamLocationResource extends return HydroImageMaker.getDamIcon(); } }); - fontSize = 10; + fontSize = 8; font = target.initializeFont("Dialog", fontSize, null); font.setSmoothing(false); @@ -310,24 +312,26 @@ public class DamLocationResource extends Coordinate coord = container.translateClick(x, y); Envelope env = new Envelope(coord); List elements = damStrTree.query(env); - double curDist=Double.MAX_VALUE; + double curDist = Double.MAX_VALUE; DamMaster foundDam = null; if (elements.size() > 0) { - //find the closest one - for (Object obj : elements) { + // find the closest one + for (Object obj : elements) { DamMaster dam = (DamMaster) obj; - double distance=Math.pow((dam.getLatitudeDam()-coord.y),2) + Math.pow((dam.getLongitudeDam()-coord.x), 2); - if (distance @@ -194,23 +195,30 @@ public class MultiPointResource extends */ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } HydroImageMakerCallback other = (HydroImageMakerCallback) obj; if (color == null) { - if (other.color != null) + if (other.color != null) { return false; - } else if (!color.equals(other.color)) + } + } else if (!color.equals(other.color)) { return false; + } if (dispClass == null) { - if (other.dispClass != null) + if (other.dispClass != null) { return false; - } else if (!dispClass.equals(other.dispClass)) + } + } else if (!dispClass.equals(other.dispClass)) { return false; + } return true; } @@ -225,7 +233,7 @@ public class MultiPointResource extends private final Map dataMapTimeStep = new HashMap(); private STRtree strTree = new STRtree(); - + private IFont font; private int fontSize; @@ -324,7 +332,7 @@ public class MultiPointResource extends container.registerMouseHandler(inputManager); } - fontSize = 10; + fontSize = 8; font = target.initializeFont("Dialog", fontSize, null); font.setSmoothing(false); @@ -338,10 +346,10 @@ public class MultiPointResource extends for (GageData gage : data) { /* Get the point color for this location */ if ((gage.getLid() != null) && gage.isUse()) { - if ( pcOptions.getQueryMode() == 1 ){ - addPointTimeStep(gage); - }else{ - addPoint(gage); + if (pcOptions.getQueryMode() == 1) { + addPointTimeStep(gage); + } else { + addPoint(gage); } } } @@ -353,28 +361,29 @@ public class MultiPointResource extends * * @param gage * GageData object - */ - private synchronized void addPointTimeStep(GageData gage) { + */ + private synchronized void addPointTimeStep(GageData gage) { String lid = gage.getLid(); - - if ( !dataMapTimeStep.containsKey(lid) ) { - - Coordinate xy = new Coordinate(gage.getLon(), gage.getLat()); + + if (!dataMapTimeStep.containsKey(lid)) { + + Coordinate xy = new Coordinate(gage.getLon(), gage.getLat()); gage.setCoordinate(xy); /* Create a small envelope around the point */ - PixelExtent pe = getPixelExtent( gage, getShiftWidth(gage), getShiftHeight(gage) ); - Envelope newEnv = descriptor.pixelToWorld( pe ); + PixelExtent pe = getPixelExtent(gage, getShiftWidth(gage), + getShiftHeight(gage)); + Envelope newEnv = descriptor.pixelToWorld(pe); + + GageDataTimeStep newGageTS = new GageDataTimeStep(gage); - GageDataTimeStep newGageTS = new GageDataTimeStep( gage ); - strTree.insert(newEnv, newGageTS); - dataMapTimeStep.put(lid, newGageTS); - - } else{ - dataMapTimeStep.get(lid).Update(gage); + dataMapTimeStep.put(lid, newGageTS); + + } else { + dataMapTimeStep.get(lid).Update(gage); } - + } private synchronized void addPoint(GageData gage) { @@ -455,7 +464,6 @@ public class MultiPointResource extends return new PixelExtent(coors); } - /** * Draws the plot information for TimeStep * @@ -470,89 +478,90 @@ public class MultiPointResource extends * @param target * the graphics target * @throws VizException - */ - private Collection drawPlotInfoTimeStep(GageDataTimeStep gageTimeStep, - double shiftWidth, double shiftHeight, PaintProperties paintProps, + */ + private Collection drawPlotInfoTimeStep( + GageDataTimeStep gageTimeStep, double shiftWidth, + double shiftHeight, PaintProperties paintProps, IGraphicsTarget target) throws VizException { List strings = new ArrayList(); Coordinate c = gageTimeStep.getCoordinate(); - - /* Logic for determining how the data values are displayed. */ boolean showValue1 = pdcManager.isValue(); - double[] centerpixels = descriptor .worldToPixel(new double[] { c.x, c.y }); if (showValue1) { - - String [] valueStrings; - - if ( pcOptions.getElementType() == 1 ){ - valueStrings = gageTimeStep.getRainValue( pcOptions.getPrecipPeFilter() ).split("\n"); - }else{ - valueStrings = gageTimeStep.getOtherValue().split("\n"); - } - - int strSize = valueStrings.length; - - RGB[] strColor = new RGB[strSize]; - - if ( strSize > 0){ - for (int i=0; i 0) { + for (int i = 0; i < strSize; i++) { + if (valueStrings[i] != "") { + if (valueStrings[i].equalsIgnoreCase("M")) { strColor[i] = RGBColors.getRGBColor("White"); - }else{ - strColor[i] = getValueLabelColorTimeStep( gageTimeStep.getLid(), Double.parseDouble( valueStrings[i] ) ); + } else { + strColor[i] = getValueLabelColorTimeStep( + gageTimeStep.getLid(), + Double.parseDouble(valueStrings[i])); } } } } - + Coordinate valueCoor = new Coordinate( (centerpixels[0] + shiftWidth) - getScaleWidth(), (centerpixels[1] + shiftHeight) - getScaleHeight() / 2); - + /* - * If in timestep mode and icon drawing off, draw a circle - * matching the color of the text + * If in timestep mode and icon drawing off, draw a circle matching + * the color of the text */ if (pcOptions.getIcon() == 0) { - Coordinate cd = gageTimeStep.getCoordinate(); - centerpixels = descriptor.worldToPixel(new double[] { cd.x, - cd.y }); - Coordinate[] coors = new Coordinate[4]; - coors[0] = new Coordinate((centerpixels[0] + shiftWidth) - - getScaleWidth(), (centerpixels[1] + shiftHeight) - - getScaleHeight()); - coors[1] = new Coordinate((centerpixels[0] + shiftWidth) - + getScaleWidth(), (centerpixels[1] + shiftHeight) - - getScaleHeight()); - coors[2] = new Coordinate((centerpixels[0] + shiftWidth) - + getScaleWidth(), (centerpixels[1] + shiftHeight) - + getScaleHeight()); - coors[3] = new Coordinate((centerpixels[0] + shiftWidth) - - getScaleWidth(), (centerpixels[1] + shiftHeight) - + getScaleHeight()); + Coordinate cd = gageTimeStep.getCoordinate(); + centerpixels = descriptor.worldToPixel(new double[] { cd.x, + cd.y }); + Coordinate[] coors = new Coordinate[4]; + coors[0] = new Coordinate((centerpixels[0] + shiftWidth) + - getScaleWidth(), (centerpixels[1] + shiftHeight) + - getScaleHeight()); + coors[1] = new Coordinate((centerpixels[0] + shiftWidth) + + getScaleWidth(), (centerpixels[1] + shiftHeight) + - getScaleHeight()); + coors[2] = new Coordinate((centerpixels[0] + shiftWidth) + + getScaleWidth(), (centerpixels[1] + shiftHeight) + + getScaleHeight()); + coors[3] = new Coordinate((centerpixels[0] + shiftWidth) + - getScaleWidth(), (centerpixels[1] + shiftHeight) + + getScaleHeight()); - PixelExtent pe = new PixelExtent(coors); - pe.scale(.07); + PixelExtent pe = new PixelExtent(coors); + pe.scale(.07); + + target.drawShadedRect(pe, RGBColors.getRGBColor("White"), 1, + null); + } - target.drawShadedRect(pe, RGBColors.getRGBColor("White"), 1, null); - } - DrawableString string = new DrawableString(valueStrings, strColor); - + string.font = font; string.horizontalAlignment = HorizontalAlignment.RIGHT; - string.setCoordinates(valueCoor.x, valueCoor.y); strings.add(string); - + } if (pdcManager.isTime()) { @@ -568,7 +577,6 @@ public class MultiPointResource extends string.font = font; string.setCoordinates(dateCoor1.x, dateCoor1.y); strings.add(string); - string = new DrawableString(sdf2.format(gageTimeStep.getValidtime() .getTime()), LABEL_COLOR); @@ -603,16 +611,16 @@ public class MultiPointResource extends } if (pdcManager.isPE()) { - - String pe = ""; - if ( pcOptions.getElementType() == 1 ){ - - pe = gageTimeStep.getRainParam(pcOptions.getPrecipPeFilter()); - }else{ - - pe = gageTimeStep.getOtherParam(); - } - + + String pe = ""; + if (pcOptions.getElementType() == 1) { + + pe = gageTimeStep.getRainParam(pcOptions.getPrecipPeFilter()); + } else { + + pe = gageTimeStep.getOtherParam(); + } + Coordinate peCoor = new Coordinate(centerpixels[0] + shiftWidth + getScaleWidth(), centerpixels[1] + shiftHeight - getScaleHeight() / 2); @@ -620,8 +628,7 @@ public class MultiPointResource extends string.font = font; string.setCoordinates(peCoor.x, peCoor.y); strings.add(string); - - + } if (pdcManager.isElevation()) { @@ -630,41 +637,43 @@ public class MultiPointResource extends + getScaleWidth(), centerpixels[1] + shiftHeight - getScaleHeight() / 2); - DrawableString string = new DrawableString(df.format(gageTimeStep.getElevation()), LABEL_COLOR); + DrawableString string = new DrawableString(df.format(gageTimeStep + .getElevation()), LABEL_COLOR); string.font = font; string.setCoordinates(elCoor.x, elCoor.y); strings.add(string); } return strings; } - - + /** - * Gets the color for value label in TimeStep mode + * Gets the color for value label in TimeStep mode + * + * @param plid + * lid string + * + * @param pValue + * value * - * @param plid lid string - * - * @param pValue value - * * @throws VizException - */ - private RGB getValueLabelColorTimeStep( String pLid, double pValue ){ - - RGB textColor = RGBColors.getRGBColor("White"); - + */ + private RGB getValueLabelColorTimeStep(String pLid, double pValue) { + + RGB textColor = RGBColors.getRGBColor("White"); + if ((pcOptions.getTsDataElement() == HydroConstants.TimeStepDataElement.STAGE_POOL_TSDE - .getElementType()) - || (pcOptions.getTsDataElement() == HydroConstants.TimeStepDataElement.FLOW_STORAGE_TSDE - .getElementType())) { - textColor = getRiverValueColorForTimeStepMode( pLid, pValue ); + .getElementType()) + || (pcOptions.getTsDataElement() == HydroConstants.TimeStepDataElement.FLOW_STORAGE_TSDE + .getElementType())) { + textColor = getRiverValueColorForTimeStepMode(pLid, pValue); } else { - // textColor = new RGB(255, 255, 255); - textColor = determineValueColor( pValue ); + // textColor = new RGB(255, 255, 255); + textColor = determineValueColor(pValue); } return textColor; } - + /** * Draws the plot information * @@ -689,7 +698,6 @@ public class MultiPointResource extends int floodLevel = pcOptions.getFloodLevel(); int deriveStageFlow = pcOptions.getDeriveStageFlow(); - String valueLabel = null; String formatStr = null; @@ -705,7 +713,7 @@ public class MultiPointResource extends && (pcOptions.getElementType() == HydroConstants.AdHocDataElementType.RIVER_AD_HOC_TYPE .getAdHocDataElementType())) { showValue2 = true; - + } } @@ -725,7 +733,7 @@ public class MultiPointResource extends (centerpixels[1] + shiftHeight) - getScaleHeight() / 2); textColor = RGBColors.getRGBColor("white"); - + DrawableString string = new DrawableString(valueLabel, textColor); string.font = font; string.horizontalAlignment = HorizontalAlignment.RIGHT; @@ -979,16 +987,15 @@ public class MultiPointResource extends pdcManager.setColorUseName(colorUseName); pdcManager.setMultiPointResource(this); setScaleValues(paintProps); - + resetDataMap(); - - - if ( pcOptions.getQueryMode() == 1 ){ - paintInternalHelperTimeStep( target, paintProps ); - }else{ - paintInternalHelper( target, paintProps ); - } - + + if (pcOptions.getQueryMode() == 1) { + paintInternalHelperTimeStep(target, paintProps); + } else { + paintInternalHelper(target, paintProps); + } + GageData currentData = manager.getCurrentData(); if (currentData != null) { List siteList = pdcManager.getObsReportList(); @@ -1003,7 +1010,7 @@ public class MultiPointResource extends } } - + /** * Paint method called to display this resource in TimeStep mode. * @@ -1012,69 +1019,73 @@ public class MultiPointResource extends * @param paintProps * The Paint Properties * @throws VizException - */ - private void paintInternalHelperTimeStep(IGraphicsTarget target, PaintProperties paintProps) throws VizException { - - List data = pdcManager.getObsReportList(); - - if (data == null) { - return; - } - - for (GageData gage : data) { - /* Get the point color for this location */ - if ((gage.getLid() != null) && gage.isUse()) { - - addPointTimeStep(gage); - - } - - } - - IExtent extent = paintProps.getView().getExtent(); - - List images = new ArrayList( dataMapTimeStep.size() ); - List strings = new ArrayList( dataMapTimeStep.size() * 3 ); - - Iterator> it = dataMapTimeStep.entrySet().iterator(); - Map.Entry gageTS = null; - while ( it.hasNext() ) { - gageTS = it.next(); - - Coordinate c = gageTS.getValue().getCoordinate(); - double[] pixel = descriptor.worldToPixel(new double[] { c.x, c.y }); - - if (pixel != null && extent.contains(pixel)) { - double shiftHeightValue = getShiftHeight(gageTS.getValue()); - double shiftWidthValue = getShiftWidth(gageTS.getValue()); - /* Draw the icons */ - if (pcOptions.getIcon() == 1) { - RGB color = null; - if (pcOptions.getRiverStatus() == 1) { - color = gageTS.getValue().getColor(); - } else { - color = RGBColors.getRGBColor(colorSet.get(0) - .getColorname().getColorName()); - } - PointImage image = new PointImage( - getIcon(target, gageTS.getValue(), color), pixel[0], pixel[1] - ); - - image.setSiteId(gageTS.getValue().getLid()); - images.add(image); - } - strings.addAll( drawPlotInfoTimeStep( gageTS.getValue(), shiftWidthValue, shiftHeightValue, paintProps, target ) ); - } - - } + */ + private void paintInternalHelperTimeStep(IGraphicsTarget target, + PaintProperties paintProps) throws VizException { - if (images.size() > 0) { - target.getExtension(IPointImageExtension.class) - .drawPointImages(paintProps, images); - } - if (strings.size() > 0) { - target.drawStrings(strings); - } + List data = pdcManager.getObsReportList(); + + if (data == null) { + return; + } + + for (GageData gage : data) { + /* Get the point color for this location */ + if ((gage.getLid() != null) && gage.isUse()) { + + addPointTimeStep(gage); + + } + + } + + IExtent extent = paintProps.getView().getExtent(); + + List images = new ArrayList( + dataMapTimeStep.size()); + List strings = new ArrayList( + dataMapTimeStep.size() * 3); + + Iterator> it = dataMapTimeStep + .entrySet().iterator(); + Map.Entry gageTS = null; + while (it.hasNext()) { + gageTS = it.next(); + + Coordinate c = gageTS.getValue().getCoordinate(); + double[] pixel = descriptor.worldToPixel(new double[] { c.x, c.y }); + + if (pixel != null && extent.contains(pixel)) { + double shiftHeightValue = getShiftHeight(gageTS.getValue()); + double shiftWidthValue = getShiftWidth(gageTS.getValue()); + /* Draw the icons */ + if (pcOptions.getIcon() == 1) { + RGB color = null; + if (pcOptions.getRiverStatus() == 1) { + color = gageTS.getValue().getColor(); + } else { + color = RGBColors.getRGBColor(colorSet.get(0) + .getColorname().getColorName()); + } + PointImage image = new PointImage(getIcon(target, + gageTS.getValue(), color), pixel[0], pixel[1]); + + image.setSiteId(gageTS.getValue().getLid()); + images.add(image); + } + strings.addAll(drawPlotInfoTimeStep(gageTS.getValue(), + shiftWidthValue, shiftHeightValue, paintProps, target)); + } + + } + + if (images.size() > 0) { + target.getExtension(IPointImageExtension.class).drawPointImages( + paintProps, images); + } + if (strings.size() > 0) { + target.drawStrings(strings); + } } /** @@ -1086,58 +1097,62 @@ public class MultiPointResource extends * The Paint Properties * @throws VizException */ - private void paintInternalHelper(IGraphicsTarget target, PaintProperties paintProps) throws VizException { - - List data = pdcManager.getObsReportList(); - - if (data == null) { - return; - } - - IExtent extent = paintProps.getView().getExtent(); - - List images = new ArrayList( data.size() ); - List strings = new ArrayList( data.size() * 3 ); - for (GageData gage : data) { - /* Get the point color for this location */ - if ((gage.getLid() != null) && gage.isUse()) { - - addPoint(gage); - - Coordinate c = gage.getCoordinate(); - double[] pixel = descriptor.worldToPixel(new double[] { c.x, c.y }); - - if (pixel != null && extent.contains(pixel)) { - double shiftHeightValue = getShiftHeight(gage); - double shiftWidthValue = getShiftWidth(gage); - /* Draw the icons */ - if (pcOptions.getIcon() == 1) { - RGB color = null; - if (pcOptions.getRiverStatus() == 1) { - color = gage.getColor(); - } else { - color = RGBColors.getRGBColor(colorSet.get(0) - .getColorname().getColorName()); - } - PointImage image = new PointImage(getIcon(target, - gage, color), pixel[0], pixel[1]); - image.setSiteId(gage.getLid()); - images.add(image); - } - strings.addAll( drawPlotInfo(gage, shiftWidthValue, shiftHeightValue, paintProps, target) ); - } - } - } + private void paintInternalHelper(IGraphicsTarget target, + PaintProperties paintProps) throws VizException { - if (images.size() > 0) { - target.getExtension(IPointImageExtension.class) - .drawPointImages(paintProps, images); - } - if (strings.size() > 0) { - target.drawStrings(strings); - } + List data = pdcManager.getObsReportList(); + + if (data == null) { + return; + } + + IExtent extent = paintProps.getView().getExtent(); + + List images = new ArrayList(data.size()); + List strings = new ArrayList( + data.size() * 3); + for (GageData gage : data) { + /* Get the point color for this location */ + if ((gage.getLid() != null) && gage.isUse()) { + + addPoint(gage); + + Coordinate c = gage.getCoordinate(); + double[] pixel = descriptor.worldToPixel(new double[] { c.x, + c.y }); + + if (pixel != null && extent.contains(pixel)) { + double shiftHeightValue = getShiftHeight(gage); + double shiftWidthValue = getShiftWidth(gage); + /* Draw the icons */ + if (pcOptions.getIcon() == 1) { + RGB color = null; + if (pcOptions.getRiverStatus() == 1) { + color = gage.getColor(); + } else { + color = RGBColors.getRGBColor(colorSet.get(0) + .getColorname().getColorName()); + } + PointImage image = new PointImage(getIcon(target, gage, + color), pixel[0], pixel[1]); + image.setSiteId(gage.getLid()); + images.add(image); + } + strings.addAll(drawPlotInfo(gage, shiftWidthValue, + shiftHeightValue, paintProps, target)); + } + } + } + + if (images.size() > 0) { + target.getExtension(IPointImageExtension.class).drawPointImages( + paintProps, images); + } + if (strings.size() > 0) { + target.drawStrings(strings); + } } - + /** * Set the selected coordinate * @@ -1228,9 +1243,8 @@ public class MultiPointResource extends } return null; } - - private RGB getRiverValueColorForTimeStepMode( String pLid, double pValue ) { + private RGB getRiverValueColorForTimeStepMode(String pLid, double pValue) { RGB color = null; String threatIndex = ThreatIndex.THREAT_MISSING_DATA.getThreatIndex(); @@ -1259,12 +1273,12 @@ public class MultiPointResource extends } // determine the threat level - if (( pValue ) != PDCConstants.MISSING_VALUE) { + if ((pValue) != PDCConstants.MISSING_VALUE) { threatIndex = ThreatIndex.THREAT_MISSING_STAGE.getThreatIndex(); if ((actionLevel != PDCConstants.MISSING_VALUE) && (actionLevel != 0)) { - if ( pValue >= actionLevel) { + if (pValue >= actionLevel) { threatIndex = ThreatIndex.THREAT_ACTION.getThreatIndex(); } else { threatIndex = ThreatIndex.THREAT_NONE.getThreatIndex(); @@ -1272,7 +1286,7 @@ public class MultiPointResource extends } if ((floodLevel != PDCConstants.MISSING_VALUE) && (floodLevel != 0)) { - if ( pValue >= floodLevel) { + if (pValue >= floodLevel) { threatIndex = ThreatIndex.THREAT_FLOOD.getThreatIndex(); } else if (actionLevel == PDCConstants.MISSING_VALUE) { threatIndex = ThreatIndex.THREAT_NONE.getThreatIndex(); @@ -1491,19 +1505,19 @@ public class MultiPointResource extends /** * Clear the data map. - */ + */ public void resetDataMap() { - - if (pcOptions.getQueryMode() == 1){ - - dataMapTimeStep.clear(); + + if (pcOptions.getQueryMode() == 1) { + + dataMapTimeStep.clear(); - }else{ + } else { + + dataMap.clear(); - dataMap.clear(); - - } - + } + strTree = new STRtree(); } diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDataManager.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDataManager.java index e1733db37a..d186f51b60 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDataManager.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDataManager.java @@ -30,6 +30,10 @@ import java.util.List; import java.util.Map; import java.util.TimeZone; +import org.apache.commons.lang.time.DateUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject; import com.raytheon.uf.common.dataplugin.shef.tables.Fcstheight; import com.raytheon.uf.common.dataplugin.shef.tables.FcstheightId; @@ -77,6 +81,8 @@ import com.raytheon.viz.hydrocommon.util.DbUtils; * Aug 18, 2015 4793 rjpeter Use Number in blind cast. * Nov 06, 2015 17846 lbousaidi modify edit and insertRejectedData so that quality_code. * is reset from Bad to Good after data QC. + * Feb 16, 2016 5342 bkowal Ensure two rejected records with the same key values are + * not inserted at the same second. * * * @author dhladky @@ -85,6 +91,8 @@ import com.raytheon.viz.hydrocommon.util.DbUtils; public class TimeSeriesDataManager extends HydroDataManager { + private final Logger logger = LoggerFactory.getLogger(getClass()); + private static final String TIME_SERIES_DATA_QUERY = "select lid,obstime,lid,product_id from latestobsvalue"; private final String INGEST_FILTER_QUERY = "select lid,pe,ts,extremum,dur from ingestfilter where lid=':lid' and ingest = 'T' order by pe asc,ts_rank asc,ts asc,dur asc,extremum asc"; @@ -104,9 +112,6 @@ public class TimeSeriesDataManager extends HydroDataManager { /** Quality control value for manual "Good" */ private final int QC_MANUAL_PASSED = 121; - /** Quality control value for manual "Bad". */ - private final int QC_MANUAL_FAILED = 123; - /** * Map holding the location id and display class. */ @@ -553,16 +558,21 @@ public class TimeSeriesDataManager extends HydroDataManager { boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, false); if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + /* + * Since debug is set by Apps Defaults and not via logger + * configuration, these message will be logged as info messages to + * ensure that they are output even if debug messages have been + * disabled at the logger level. + */ + logger.info(ad.getToken(HydroConstants.PGHOST) + ":" + ad.getToken(HydroConstants.PGPORT) + ":" + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql.toString()); + logger.info("Query: " + sql.toString()); } ArrayList tabularData = new ArrayList(); - ArrayList results = (ArrayList) DirectDbQuery - .executeQuery(sql.toString(), HydroConstants.IHFS, - QueryLanguage.SQL); + List results = DirectDbQuery.executeQuery(sql.toString(), + HydroConstants.IHFS, QueryLanguage.SQL); for (int i = 0; i < results.size(); i++) { Object[] oa = results.get(i); @@ -608,10 +618,10 @@ public class TimeSeriesDataManager extends HydroDataManager { false); if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + logger.info(ad.getToken(HydroConstants.PGHOST) + ":" + ad.getToken(HydroConstants.PGPORT) + ":" + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql); + logger.info("Query: " + sql); } List results = DirectDbQuery.executeQuery(sql.toString(), @@ -642,10 +652,10 @@ public class TimeSeriesDataManager extends HydroDataManager { false); if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + logger.info(ad.getToken(HydroConstants.PGHOST) + ":" + ad.getToken(HydroConstants.PGPORT) + ":" + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql); + logger.info("Query: " + sql); } DirectDbQuery.executeStatement(sql, HydroConstants.IHFS, QueryLanguage.SQL); @@ -725,10 +735,10 @@ public class TimeSeriesDataManager extends HydroDataManager { false); if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + logger.info(ad.getToken(HydroConstants.PGHOST) + ":" + ad.getToken(HydroConstants.PGPORT) + ":" + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sb.toString()); + logger.info("Query: " + sb.toString()); } return DirectDbQuery.executeStatement(sb.toString(), @@ -749,10 +759,10 @@ public class TimeSeriesDataManager extends HydroDataManager { false); if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + logger.info(ad.getToken(HydroConstants.PGHOST) + ":" + ad.getToken(HydroConstants.PGPORT) + ":" + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql); + logger.info("Query: " + sql); } return DirectDbQuery.executeStatement(sql, HydroConstants.IHFS, @@ -889,10 +899,10 @@ public class TimeSeriesDataManager extends HydroDataManager { false); if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + logger.info(ad.getToken(HydroConstants.PGHOST) + ":" + ad.getToken(HydroConstants.PGPORT) + ":" + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sb.toString()); + logger.info("Query: " + sb.toString()); } return DirectDbQuery.executeStatement(sb.toString(), @@ -924,20 +934,58 @@ public class TimeSeriesDataManager extends HydroDataManager { return sqlResult.get(0)[0]; } } catch (VizException e) { - e.printStackTrace(); - return null; + logger.error("Failed to retrieve data from table: " + tablename + + ".", e); } return null; } - public int insertRejectedData(List deleteList) - throws VizException { + public int insertRejectedData(List deleteList, + Map rejectedSecondsMap, + Date insertStartTime) throws VizException { StringBuilder sb = new StringBuilder(); - Date currentTime = Calendar.getInstance(TimeZone.getTimeZone("GMT")) - .getTime(); + /* + * part of the primary key. So, should be unique with each record + * insert. + */ for (ForecastData dr : deleteList) { + /* + * This will ensure that records that would normally have the same + * id will at least be offset by a second. This is needed because + * the dynamic time field that is part of the primary key only has a + * resolution out to the seconds field. The insert of a record does + * not take an entire second. This implementation is limited by the + * fact that only sixty of a particular record can be inserted + * without conflicting with a potential future insert less than a + * minute later. The inserts are mapped by id to reduce the amount + * of data manipulation that would occur when there is a lack of + * duplicate records. The ideal scenario would be to alter the data + * record so that it would not be necessary to offset the posting + * time by a second to ensure uniqueness; however, a changeset that + * large is far outside the scope of DR #5342. + */ + RejecteddataId id = new RejecteddataId(); + id.setLid(dr.getLid()); + id.setPe(dr.getPe()); + id.setDur((short) dr.getDur()); + id.setTs(dr.getTs()); + id.setExtremum(dr.getExtremum()); + id.setProbability((float) dr.getProbability()); + id.setValidtime(dr.getValidTime()); + id.setBasistime(dr.getBasisTime()); + id.setPostingtime(insertStartTime); + Integer offsetSeconds = rejectedSecondsMap.get(id); + if (offsetSeconds == null) { + offsetSeconds = 0; + } else { + offsetSeconds += 1; + } + rejectedSecondsMap.put(id, offsetSeconds); + + final Date postingTime = DateUtils.addSeconds(insertStartTime, + offsetSeconds); int probability = -1; int revision = 1; @@ -957,7 +1005,8 @@ public class TimeSeriesDataManager extends HydroDataManager { productID = dr.getProductID(); } - Integer qualityCode = ((Number) getDataFromDB(dr, "quality_code")).intValue(); + Integer qualityCode = ((Number) getDataFromDB(dr, "quality_code")) + .intValue(); if (qualityCode == null) { qualityCode = new Integer(dr.getQualityCode()); } @@ -996,7 +1045,7 @@ public class TimeSeriesDataManager extends HydroDataManager { + "', "); } - sb.append("'" + HydroConstants.DATE_FORMAT.format(currentTime) + sb.append("'" + HydroConstants.DATE_FORMAT.format(postingTime) + "', "); sb.append(dr.getValue() + ", "); sb.append(revision + ", "); @@ -1015,10 +1064,10 @@ public class TimeSeriesDataManager extends HydroDataManager { false); if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + logger.info(ad.getToken(HydroConstants.PGHOST) + ":" + ad.getToken(HydroConstants.PGPORT) + ":" + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sb.toString()); + logger.info("Query: " + sb.toString()); } return DirectDbQuery.executeStatement(sb.toString(), @@ -1063,10 +1112,10 @@ public class TimeSeriesDataManager extends HydroDataManager { false); if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + logger.info(ad.getToken(HydroConstants.PGHOST) + ":" + ad.getToken(HydroConstants.PGPORT) + ":" + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql); + logger.info("Query: " + sql); } status = DirectDbQuery.executeStatement(sql.toString(), @@ -1133,10 +1182,10 @@ public class TimeSeriesDataManager extends HydroDataManager { false); if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + logger.info(ad.getToken(HydroConstants.PGHOST) + ":" + ad.getToken(HydroConstants.PGPORT) + ":" + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql.toString()); + logger.info("Query: " + sql.toString()); } status = DirectDbQuery.executeStatement(sql.toString(), @@ -1161,7 +1210,7 @@ public class TimeSeriesDataManager extends HydroDataManager { for (int i = 0; i < editList.size(); i++) { ForecastData data = editList.get(i); String tablename = DbUtils.getTableName(data.getPe(), data.getTs()); - //set the QC to GOOD when you set data to missing. + // set the QC to GOOD when you set data to missing. data.setQualityCode(TimeSeriesUtil.setQcCode(QC_MANUAL_PASSED, data.getQualityCode())); SqlBuilder sql = new SqlBuilder(tablename); @@ -1201,10 +1250,10 @@ public class TimeSeriesDataManager extends HydroDataManager { false); if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + logger.info(ad.getToken(HydroConstants.PGHOST) + ":" + ad.getToken(HydroConstants.PGPORT) + ":" + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql); + logger.info("Query: " + sql); } DirectDbQuery.executeStatement(sql.toString(), HydroConstants.IHFS, @@ -1236,10 +1285,10 @@ public class TimeSeriesDataManager extends HydroDataManager { false); if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + logger.info(ad.getToken(HydroConstants.PGHOST) + ":" + ad.getToken(HydroConstants.PGPORT) + ":" + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql); + logger.info("Query: " + sql); } List rs = DirectDbQuery.executeQuery(sql.toString(), @@ -1281,10 +1330,10 @@ public class TimeSeriesDataManager extends HydroDataManager { false); if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + logger.info(ad.getToken(HydroConstants.PGHOST) + ":" + ad.getToken(HydroConstants.PGPORT) + ":" + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + query.toString()); + logger.info("Query: " + query.toString()); } List results = DirectDbQuery.executeQuery(query.toString(), @@ -1332,7 +1381,8 @@ public class TimeSeriesDataManager extends HydroDataManager { * @return The number of objects inserted/updated * @throws VizException */ - public int putForecast(PersistableDataObject dataObj) throws VizException { + public int putForecast(PersistableDataObject dataObj) + throws VizException { int rv = 0; rv = DirectDbQuery.saveOrUpdate(dataObj, HydroConstants.IHFS); diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayCanvas.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayCanvas.java index 132d3432a5..46d6368803 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayCanvas.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayCanvas.java @@ -142,6 +142,8 @@ import com.raytheon.viz.hydrocommon.util.DbUtils; * 05 Sep 2013 #2332 lvenable Fixed memory leaks. * 24 Jan 2013 15959 lbousaidi Swap the corner points of the bounding box when zooming. * 22 Oct 2015 13736 xwei Fixed missing data after zoom, edit, & reset problem + * Nov 18 2015 5073 skorolev Fixed drawing PP time series. + * * @author lvenable * @version 1.0 * @@ -842,7 +844,8 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements } /* Precipitation physical element */ - if (td.getPe().equalsIgnoreCase(HydroConstants.PP)) { + if (td.getPe().equalsIgnoreCase(HydroConstants.PP) + && td.isTraceOn()) { precipPE = true; setBackgroundColor(td, j, gc); int[] ia = new int[8]; @@ -1265,12 +1268,12 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements } Date xMin = pixel2x(gd, rubberBandX1 - GRAPHBORDER_LEFT); Date xMax = pixel2x(gd, rubberBandX2 - GRAPHBORDER_LEFT); - //Swap the corner points of the bounding box when zooming + // Swap the corner points of the bounding box when zooming if (xMin.after(xMax)) { - Date xtmp; - xtmp= xMin; - xMin=xMax; - xMax=xtmp; + Date xtmp; + xtmp = xMin; + xMin = xMax; + xMax = xtmp; } gd.setXMin(xMin); gd.setXMax(xMax); @@ -1286,12 +1289,12 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements if (ymin < gd.getYmin()) { ymin = gd.getYmin(); } - //Swap the corner points of the bounding box when zooming + // Swap the corner points of the bounding box when zooming if (ymin > ymax) { - double ytmp; - ytmp= ymin; - ymin=ymax; - ymax=ytmp; + double ytmp; + ytmp = ymin; + ymin = ymax; + ymax = ytmp; } gd.setYmin(ymin); gd.setYmax(ymax); diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayDlg.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayDlg.java index 6dc06100b8..0455cbd0dd 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayDlg.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayDlg.java @@ -21,8 +21,12 @@ package com.raytheon.viz.hydro.timeseries; import java.io.File; import java.util.ArrayList; +import java.util.Calendar; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.TimeZone; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.SWT; @@ -50,6 +54,7 @@ import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; +import com.raytheon.uf.common.dataplugin.shef.tables.RejecteddataId; import com.raytheon.uf.common.ohd.AppsDefaults; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; @@ -94,7 +99,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * 30 Jan 2012 15459 mpduff Redmine 1560 - Make graph canvases redraw on page up/down. * 06 Feb 2013 1578 rferrel Code cleanup for non-blocking dialogs. * 24 Apr 2013 1921 mpduff Fix zoom reset to only reset the "active" graph - * 14 May 2014 16388 xwei updated the insertion of rejecteddata table. + * 14 May 2014 16388 xwei updated the insertion of rejecteddata table. + * 16 Feb 2016 5342 bkowal Ensure rejected data keys are unique. * * * @@ -328,10 +334,10 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog { /** * Display Canvas List. */ - private final ArrayList canvasList = new ArrayList(); + private final List canvasList = new ArrayList(); /** List of page composites */ - private final ArrayList pageCompList = new ArrayList(); + private final List pageCompList = new ArrayList(); /** * The page currently displayed. @@ -413,11 +419,6 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog { this.parentDialog = parentDialog; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() - */ @Override protected Layout constructShellLayout() { // Create the main layout for the shell. @@ -428,24 +429,11 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog { return mainLayout; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayoutData() - */ @Override protected Object constructShellLayoutData() { return new GridData(SWT.FILL, SWT.FILL, true, true); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org - * .eclipse.swt.widgets.Shell) - */ @Override protected void initializeComponents(final Shell shell) { // Get default values from Apps Defaults @@ -476,11 +464,6 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog { shell.setMinimumSize(new Point(900, 900)); } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened() - */ @Override protected void preOpened() { super.preOpened(); @@ -857,9 +840,20 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog { setSelectTrace(false); TimeSeriesDataManager dataManager = TimeSeriesDataManager .getInstance(); + Map rejectedSecondsMap = new HashMap<>( + deleteList.size(), 1.0f); + /* + * The insertion start time is remembered prior to any + * inserts into the rejected data table. This will ensure + * that insertion times will remain unique across both + * potential inserts into the rejected data table below. + */ + Date insertStartTime = Calendar.getInstance( + TimeZone.getTimeZone("GMT")).getTime(); if (deleteList.size() > 0) { try { - dataManager.insertRejectedData(deleteList); + dataManager.insertRejectedData(deleteList, + rejectedSecondsMap, insertStartTime); dataManager.delete(deleteList); updateMaxFcst(deleteList); } catch (VizException e) { @@ -889,7 +883,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog { if (editList.size() > 0) { try { - dataManager.insertRejectedData(editList); + dataManager.insertRejectedData(editList, + rejectedSecondsMap, insertStartTime); dataManager.edit(editList); updateMaxFcst(editList); } catch (VizException e) { diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDlg.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDlg.java index 12df601a22..06bec79380 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDlg.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDlg.java @@ -53,6 +53,7 @@ import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; @@ -61,7 +62,6 @@ import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.PathManagerFactory; @@ -128,6 +128,7 @@ import com.raytheon.viz.hydrocommon.util.StnClassSyncUtil; * Oct 13, 2015 4933 rferrel Log error if unable to find group definition file * Fixed formatter resource leaks. * 30 Oct, 2015 15102 wkwock Implements preferred order for PE-D-TS-EXT list + * Jan 26, 2016 5054 randerso Allow dialog to be parented to display * * * @@ -497,9 +498,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog { public final static TimeSeriesDlg getInstance() { // Independent shell must be recreated after closing. if ((instance == null) || !instance.isOpen()) { - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(); - instance = new TimeSeriesDlg(shell); + instance = new TimeSeriesDlg(Display.getCurrent()); } return instance; } @@ -507,11 +506,10 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog { /** * Constructor. * - * @param parent - * Parent shell. + * @param display */ - private TimeSeriesDlg(Shell parent) { - super(parent, CAVE.INDEPENDENT_SHELL); + private TimeSeriesDlg(Display display) { + super(display, CAVE.INDEPENDENT_SHELL); setText("Time Series Control"); displayManager = HydroDisplayManager.getInstance(); @@ -523,14 +521,13 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog { /** * Constructor for stand alone dialog. * - * @param parent - * the Parent shell. + * @param display * * @param groupConfigFile * the user-specified file with group configuration information. */ - public TimeSeriesDlg(Shell parent, File groupConfigFile) { - this(parent); + public TimeSeriesDlg(Display display, File groupConfigFile) { + this(display); this.standaloneMode = true; // Ensure That The Group Configuration File Exists. @@ -1541,12 +1538,12 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog { si.setDur(((Number) row[4]).intValue()); boolean preferredLstFlg = false; - if (peMap!=null){ + if (peMap != null) { String[] typeSrcLst = peMap.get(si.getPe()); if (typeSrcLst != null) { for (String typesrc : typeSrcLst) { - + if (typesrc.equalsIgnoreCase(si.getTs())) { preferredLstFlg = true; break; @@ -1621,7 +1618,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog { tsSelected = false; } - populatePreferredDataInOrder(preferredMap,peMap); + populatePreferredDataInOrder(preferredMap, peMap); processDataList(hMap, tsSelected); processDataList(qMap, tsSelected); processDataList(pMap, tsSelected); @@ -1632,33 +1629,37 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog { selectedDataLbl.setText(selectedLid); bottomDataList.setSelection(0); } catch (VizException e) { - statusHandler.error("Failed to populate time series list",e); + statusHandler.error("Failed to populate time series list", e); } } /** * populate data to bottomDataList base on preferred predefined order + * * @param preferredMap * @param peMap */ - private void populatePreferredDataInOrder (LinkedHashMap>preferredMap, Map peMap) { - if (peMap!=null && preferredMap!=null ){ - for (String pe:peMap.keySet()){ + private void populatePreferredDataInOrder( + LinkedHashMap> preferredMap, + Map peMap) { + if ((peMap != null) && (preferredMap != null)) { + for (String pe : peMap.keySet()) { java.util.List siList = preferredMap.get(pe); - + if (siList == null) { continue; } - - String[] tsList = peMap.get(pe); - if (tsList==null) { //There's PE but no TS in preffered_order.txt - for(SiteInfo si : siList) { + + String[] tsList = peMap.get(pe); + if (tsList == null) { // There's PE but no TS in + // preffered_order.txt + for (SiteInfo si : siList) { bottomDataList.add(formatDataLine(si)); siteInfoList.add(si); } - } else { //There's both PE and TS in preferred_order.txt - for (String ts: tsList){ - for(SiteInfo si : siList) { + } else { // There's both PE and TS in preferred_order.txt + for (String ts : tsList) { + for (SiteInfo si : siList) { if (ts.equalsIgnoreCase(si.getTs())) { bottomDataList.add(formatDataLine(si)); siteInfoList.add(si); diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesconfigComponent.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesconfigComponent.java index 72c7766f0b..6d182f7324 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesconfigComponent.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesconfigComponent.java @@ -22,7 +22,6 @@ package com.raytheon.viz.hydro.timeseries; import java.io.File; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; import com.raytheon.viz.ui.personalities.awips.AbstractCAVEDialogComponent; @@ -35,8 +34,9 @@ import com.raytheon.viz.ui.personalities.awips.AbstractCAVEDialogComponent; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Apr 28, 2011 mschenke Initial creation + * Apr 28, 2011 mschenke Initial creation * Feb 05, 2013 1578 rferrel Changes for non-blocking singleton TimeSeriesDlg. + * Jan 26, 2016 5054 randerso Make dialog parented to display * * * @@ -59,8 +59,8 @@ public class TimeSeriesconfigComponent extends AbstractCAVEDialogComponent { */ @Override protected void startInternal(String componentName) throws Exception { - TimeSeriesDlg timeSeriesDialog = new TimeSeriesDlg(new Shell( - Display.getCurrent()), + TimeSeriesDlg timeSeriesDialog = new TimeSeriesDlg( + Display.getCurrent(), TimeSeriesconfigComponent.locateGroupDefinitionFile()); timeSeriesDialog.open(); blockUntilClosed(timeSeriesDialog); diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/graph/TimeSeriesGraphCanvas.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/graph/TimeSeriesGraphCanvas.java index 860f762da3..0ccaba3663 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/graph/TimeSeriesGraphCanvas.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/graph/TimeSeriesGraphCanvas.java @@ -70,6 +70,7 @@ import com.raytheon.viz.hydrocommon.HydroConstants; * 06 Nov 2012 15399 wkwock Fix refine the plot algorithm and sampling algorithm * May 06, 2013 1976 mpduff Code cleanup * 05Sep2013 #2332 lvenable Fixed memory leaks. + * Nov 18, 2015 5073 skorolev Fixed y2pixel. * * * @author mpduff @@ -624,8 +625,11 @@ public class TimeSeriesGraphCanvas extends Canvas { } double yDiff = gd.getYmax() - gd.getYmin(); double yValue = (graphAreaHeight / yDiff) * (y - gd.getYmin()); - - return (int) (graphAreaHeight - Math.round(yValue)); + if (yValue < 0) { + return graphAreaHeight; + } else { + return (int) (graphAreaHeight - Math.round(yValue)); + } } /** diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/util/TimeSeriesUtil.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/util/TimeSeriesUtil.java index 99eb8f091d..26b7a26092 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/util/TimeSeriesUtil.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/util/TimeSeriesUtil.java @@ -46,6 +46,8 @@ import com.raytheon.viz.hydrocommon.util.QualityCodeUtil; * June 1, 2011 9499 djingtao convertDurNameToValue() * July 12, 2011 9709 djingtao modify tsAccumToInc3() * Aug 25, 2015 4794 mpduff Added 5 min duration. + * Jan 13, 2015 5243 tgurney Fix convertDur2Short() handling of + * numeric characters * * * @author mpduff @@ -144,7 +146,7 @@ public class TimeSeriesUtil { public static final int ALL_ONES = 2147483647; private static final HashBiMap durationMap = HashBiMap - .create(21); + .create(23); static { durationMap.put(0, 'I'); durationMap.put(1, 'U'); @@ -172,6 +174,13 @@ public class TimeSeriesUtil { } public static short convertDur2Short(char dur) { + int durAsInt = Character.getNumericValue(dur); + if (durAsInt >= 0) { + if (!durationMap.containsKey(durAsInt)) { + return 0; + } + return (short) durAsInt; + } if (!durationMap.containsValue(dur)) { return 0; } diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/util/TraceData.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/util/TraceData.java index 5bf8cc1435..157a222b9d 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/util/TraceData.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/util/TraceData.java @@ -31,14 +31,16 @@ import com.raytheon.viz.hydrocommon.HydroConstants; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Jun 25, 2008 1194 mpduff Initial creation - * Mar 04, 2011 7758 Jingtao added isSelectionCheckOn flag for - * pop up menu - * Apr 05, 2011 8732 jpiatt Added product_id. - * June,1, 2011 9499 djingtao change setDur() - * 22 Oct 2015 13736 xwei Added getZoomIndexOffset() method + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Jun 25, 2008 1194 mpduff Initial creation + * Mar 04, 2011 7758 Jingtao added isSelectionCheckOn flag for + * pop up menu + * Apr 05, 2011 8732 jpiatt Added product_id. + * June,1, 2011 9499 djingtao change setDur() + * 22 Oct 2015 13736 xwei Added getZoomIndexOffset() method + * Jan 13, 2016 5243 tgurney Added duration codes E (5 min.) + * and G (10 min.) * * * @@ -47,584 +49,601 @@ import com.raytheon.viz.hydrocommon.HydroConstants; */ public class TraceData implements Serializable { - private static final long serialVersionUID = -4345330013536912094L; - private static final String CODES = "IUCJHBTFQAKLDWMYZSRPX"; - private static final int[] INT_CODE_ARRAY = { 0, 1, 15, 30, 1001, 1002, - 1003, 1004, 1006, 1008, 1012, 1018, 2001, 2007, 3001, 4001, 5000, - 5001, 5002, 5004, 5005 }; - - private int npts = 0; - private int traceColor; - - private double ymin; - private double ymax; - private double value_ymin; - private double value_ymax; - - private Date xmin; - private Date xmax; - private Date basistime; - private Date productTime; - - private TimeSeriesPoint[] tsData = new TimeSeriesPoint[HydroConstants.MAX_POINTS]; - private TimeSeriesPoint[] previousTsData; - private TimeSeriesPoint[] zoomedTsData; - - private int[] lineData; - - private String name = null; - private String lid = null; - private String pe = null; - private String dur = "0"; - private String ts = null; - private String extremum = null; - private String cdur = null; - private String product_id = null; - - private String colorName = null; - - private boolean isForecast = false; - - private String label = null; - - private boolean isSelected = false; - - private boolean traceOn = true; - - private boolean traceValid = true; - - private boolean selectionCheckOn = true; - - public TraceData() { - - } - - /** - * Copy constructor. - * - * @param data - */ - public TraceData(TraceData data) { - basistime = data.basistime; - cdur = data.cdur; - product_id = data.product_id; - colorName = data.colorName; - dur = data.dur; - extremum = data.extremum; - isForecast = data.isForecast; - isSelected = data.isSelected; - label = data.label; - lid = data.lid; - lineData = data.lineData; - name = data.name; - npts = data.npts; - pe = data.pe; - previousTsData = data.previousTsData; - productTime = data.productTime; - traceColor = data.traceColor; - traceOn = data.traceOn; - ts = data.ts; - tsData = data.tsData; - value_ymax = data.value_ymax; - value_ymin = data.value_ymin; - xmax = data.xmax; - xmin = data.xmin; - ymax = data.ymax; - ymin = data.ymin; - zoomedTsData = data.zoomedTsData; - selectionCheckOn = data.selectionCheckOn; - } - - /** - * - * @return pop up check box selection - */ - public boolean isSelectionCheckOn() { - return selectionCheckOn; - } - - /** - * - * @param selectionCheckOn - */ - public void setSelectionCheckOn(boolean selectionCheckOn) { - this.selectionCheckOn = selectionCheckOn; - } - - /** - * @return the npts - */ - public int getNpts() { - if ((npts == 0) || (npts == -9999)) { - return tsData.length; - } - return npts; - // return tsData.length; - } - - /** - * @param npts - * the npts to set - */ - public void setNpts(int npts) { - this.npts = npts; - } - - /** - * @return the traceColor - */ - public int getTraceColor() { - return traceColor; - } - - /** - * @param traceColor - * the traceColor to set - */ - public void setTraceColor(int traceColor) { - this.traceColor = traceColor; - } - - /** - * @return the ymin - */ - public double getYmin() { - return ymin; - } - - /** - * @param ymin - * the ymin to set - */ - public void setYmin(double ymin) { - this.ymin = ymin; - } - - /** - * @return the ymax - */ - public double getYmax() { - return ymax; - } - - /** - * @param ymax - * the ymax to set - */ - public void setYmax(double ymax) { - this.ymax = ymax; - } - - /** - * @return the value_ymin - */ - public double getValue_ymin() { - return value_ymin; - } - - /** - * @param value_ymin - * the value_ymin to set - */ - public void setValue_ymin(double value_ymin) { - this.value_ymin = value_ymin; - } - - /** - * @return the value_ymax - */ - public double getValue_ymax() { - return value_ymax; - } - - /** - * @param value_ymax - * the value_ymax to set - */ - public void setValue_ymax(double value_ymax) { - this.value_ymax = value_ymax; - } - - /** - * @return the xmin - */ - public Date getXmin() { - return xmin; - } - - /** - * @param xmin - * the xmin to set - */ - public void setXmin(Date xmin) { - this.xmin = xmin; - } - - /** - * @return the xmax - */ - public Date getXmax() { - return xmax; - } - - /** - * @param xmax - * the xmax to set - */ - public void setXmax(Date xmax) { - this.xmax = xmax; - } - - /** - * @return the basistime - */ - public Date getBasistime() { - return basistime; - } - - /** - * @param basistime - * the basistime to set - */ - public void setBasistime(Date basistime) { - this.basistime = basistime; - } - - /** - * @return the tsData - */ - public TimeSeriesPoint[] getTsData() { - return tsData; - } - - /** - * @param tsData - * the tsData to set - */ - public void setTsData(TimeSeriesPoint[] tsData) { - this.tsData = tsData; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the lid - */ - public String getLid() { - return lid; - } - - /** - * @param lid - * the lid to set - */ - public void setLid(String lid) { - this.lid = lid; - } - - /** - * @return the pe - */ - public String getPe() { - return pe; - } - - /** - * @param pe - * the pe to set - */ - public void setPe(String pe) { - this.pe = pe; - } - - /** - * @return the dur - */ - public String getDur() { - return dur; - } - - /** - * @param dur - * the dur to set - */ - public void setDur(String dur) { - if (dur.matches("\\d*")) { - this.dur = dur; - } else { - // 21 characters that I care about - char[] charCodeArray = CODES.toCharArray(); - - for (int i = 0; i < charCodeArray.length; i++) { - if (dur.equalsIgnoreCase(String.valueOf(charCodeArray[i]))) { - dur = String.valueOf(INT_CODE_ARRAY[i]); - this.dur = dur; - break; - } - } - } - } - - /** - * @return the ts - */ - public String getTs() { - return ts; - } - - /** - * @param ts - * the ts to set - */ - public void setTs(String ts) { - this.ts = ts; - } - - /** - * @return the product_id - */ - public String getProductId() { - return product_id; - } - - /** - * @param product_id - * the product_id to set - */ - public void setProductId(String product_id) { - this.product_id = product_id; - } - - /** - * @return the extremum - */ - public String getExtremum() { - return extremum; - } - - /** - * @param extremum - * the extremum to set - */ - public void setExtremum(String extremum) { - this.extremum = extremum; - } - - /** - * @return the cdur - */ - public String getCdur() { - return cdur; - } - - /** - * @param cdur - * the cdur to set - */ - public void setCdur(String cdur) { - this.cdur = cdur; - } - - /** - * @return the colorName - */ - public String getColorName() { - return colorName; - } - - /** - * @param colorName - * the colorName to set - */ - public void setColorName(String colorName) { - this.colorName = colorName.trim(); - } - - /** - * @return the isForecast - */ - public boolean isForecast() { - return isForecast; - } - - /** - * @param isForecast - * the isForecast to set - */ - public void setForecast(boolean isForecast) { - this.isForecast = isForecast; - } - - /** - * Set the PEDTSE values from a single string - * - * @param pc - * the PEDTSE values as a String - */ - public void setPc(String pc) { - setPe(pc.substring(0, 2)); - setDur(pc.substring(2, 3)); - setTs(pc.substring(3, 5)); - setExtremum(pc.substring(5)); - - // Set forecast if ts is F or C - this.setForecast(false); - if (getTs().startsWith("F") || getTs().startsWith("f") - || getTs().startsWith("C") || getTs().startsWith("c")) { - this.setForecast(true); - } - } - - /** - * @return the label - */ - public String getLabel() { - return label; - } - - /** - * @param label - * the label to set - */ - public void setLabel(String label) { - this.label = label; - } - - /** - * @return the isSelected - */ - public boolean isSelected() { - return isSelected; - } - - /** - * @param isSelected - * the isSelected to set - */ - public void setSelected(boolean isSelected) { - this.isSelected = isSelected; - } - - /** - * @return the lineData - */ - public int[] getLineData() { - return lineData; - } - - /** - * @param lineData - * the lineData to set - */ - public void setLineData(int[] lineData) { - this.lineData = lineData; - } - - /** - * @return the previousLineData - */ - public TimeSeriesPoint[] getPreviousTsData() { - return previousTsData; - } - - /** - * @param previousLineData - * the previousLineData to set - */ - public void setPreviousTsData(TimeSeriesPoint[] previousTsData) { - this.previousTsData = previousTsData; - } - - /** - * @return the zoomedTsData - */ - public TimeSeriesPoint[] getZoomedTsData() { - return zoomedTsData; - } - - /** - * @param zoomedTsData - * the zoomedTsData to set - */ - public void setZoomedTsData(TimeSeriesPoint[] zoomedTsData) { - this.zoomedTsData = zoomedTsData; - } - - /** - * @return the traceOn - */ - public boolean isTraceOn() { - return traceOn; - } - - /** - * @param traceOn - * the traceOn to set - */ - public void setTraceOn(boolean traceOn) { - this.traceOn = traceOn; - } - - /** - * @return the traceValid - */ - public boolean isTraceValid() { - return traceValid; - } - - /** - * @param traceValid - * the traceValid to set - */ - public void setTraceValid(boolean traceValid) { - this.traceValid = traceValid; - } - - /** - * @return the productTime - */ - public Date getProductTime() { - return productTime; - } - - /** - * @param productTime - * the productTime to set - */ - public void setProductTime(Date productTime) { - this.productTime = productTime; - } - - /** - * @return zoom index offset - */ - public int getZoomIndexOffset() { - - if (this.zoomedTsData != null && this.zoomedTsData.length > 0 ){ - for (int i = 0; i < this.tsData.length; i++) { - if ( tsData[i].getX().equals(zoomedTsData[0].getX()) && - tsData[i].getY() == zoomedTsData[0].getY() - ){ - return i; - } - } - - } - - return 0; - } - + private static final long serialVersionUID = -4345330013536912094L; + + private static final String CODES = "IUEGCJHBTFQAKLDWMYZSRPX"; + + private static final int[] INT_CODE_ARRAY = { 0, 1, 5, 10, 15, 30, 1001, + 1002, 1003, 1004, 1006, 1008, 1012, 1018, 2001, 2007, 3001, 4001, + 5000, 5001, 5002, 5004, 5005 }; + + private int npts = 0; + + private int traceColor; + + private double ymin; + + private double ymax; + + private double value_ymin; + + private double value_ymax; + + private Date xmin; + + private Date xmax; + + private Date basistime; + + private Date productTime; + + private TimeSeriesPoint[] tsData = new TimeSeriesPoint[HydroConstants.MAX_POINTS]; + + private TimeSeriesPoint[] previousTsData; + + private TimeSeriesPoint[] zoomedTsData; + + private int[] lineData; + + private String name = null; + + private String lid = null; + + private String pe = null; + + private String dur = "0"; + + private String ts = null; + + private String extremum = null; + + private String cdur = null; + + private String product_id = null; + + private String colorName = null; + + private boolean isForecast = false; + + private String label = null; + + private boolean isSelected = false; + + private boolean traceOn = true; + + private boolean traceValid = true; + + private boolean selectionCheckOn = true; + + public TraceData() { + + } + + /** + * Copy constructor. + * + * @param data + */ + public TraceData(TraceData data) { + basistime = data.basistime; + cdur = data.cdur; + product_id = data.product_id; + colorName = data.colorName; + dur = data.dur; + extremum = data.extremum; + isForecast = data.isForecast; + isSelected = data.isSelected; + label = data.label; + lid = data.lid; + lineData = data.lineData; + name = data.name; + npts = data.npts; + pe = data.pe; + previousTsData = data.previousTsData; + productTime = data.productTime; + traceColor = data.traceColor; + traceOn = data.traceOn; + ts = data.ts; + tsData = data.tsData; + value_ymax = data.value_ymax; + value_ymin = data.value_ymin; + xmax = data.xmax; + xmin = data.xmin; + ymax = data.ymax; + ymin = data.ymin; + zoomedTsData = data.zoomedTsData; + selectionCheckOn = data.selectionCheckOn; + } + + /** + * + * @return pop up check box selection + */ + public boolean isSelectionCheckOn() { + return selectionCheckOn; + } + + /** + * + * @param selectionCheckOn + */ + public void setSelectionCheckOn(boolean selectionCheckOn) { + this.selectionCheckOn = selectionCheckOn; + } + + /** + * @return the npts + */ + public int getNpts() { + if ((npts == 0) || (npts == -9999)) { + return tsData.length; + } + return npts; + // return tsData.length; + } + + /** + * @param npts + * the npts to set + */ + public void setNpts(int npts) { + this.npts = npts; + } + + /** + * @return the traceColor + */ + public int getTraceColor() { + return traceColor; + } + + /** + * @param traceColor + * the traceColor to set + */ + public void setTraceColor(int traceColor) { + this.traceColor = traceColor; + } + + /** + * @return the ymin + */ + public double getYmin() { + return ymin; + } + + /** + * @param ymin + * the ymin to set + */ + public void setYmin(double ymin) { + this.ymin = ymin; + } + + /** + * @return the ymax + */ + public double getYmax() { + return ymax; + } + + /** + * @param ymax + * the ymax to set + */ + public void setYmax(double ymax) { + this.ymax = ymax; + } + + /** + * @return the value_ymin + */ + public double getValue_ymin() { + return value_ymin; + } + + /** + * @param value_ymin + * the value_ymin to set + */ + public void setValue_ymin(double value_ymin) { + this.value_ymin = value_ymin; + } + + /** + * @return the value_ymax + */ + public double getValue_ymax() { + return value_ymax; + } + + /** + * @param value_ymax + * the value_ymax to set + */ + public void setValue_ymax(double value_ymax) { + this.value_ymax = value_ymax; + } + + /** + * @return the xmin + */ + public Date getXmin() { + return xmin; + } + + /** + * @param xmin + * the xmin to set + */ + public void setXmin(Date xmin) { + this.xmin = xmin; + } + + /** + * @return the xmax + */ + public Date getXmax() { + return xmax; + } + + /** + * @param xmax + * the xmax to set + */ + public void setXmax(Date xmax) { + this.xmax = xmax; + } + + /** + * @return the basistime + */ + public Date getBasistime() { + return basistime; + } + + /** + * @param basistime + * the basistime to set + */ + public void setBasistime(Date basistime) { + this.basistime = basistime; + } + + /** + * @return the tsData + */ + public TimeSeriesPoint[] getTsData() { + return tsData; + } + + /** + * @param tsData + * the tsData to set + */ + public void setTsData(TimeSeriesPoint[] tsData) { + this.tsData = tsData; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the lid + */ + public String getLid() { + return lid; + } + + /** + * @param lid + * the lid to set + */ + public void setLid(String lid) { + this.lid = lid; + } + + /** + * @return the pe + */ + public String getPe() { + return pe; + } + + /** + * @param pe + * the pe to set + */ + public void setPe(String pe) { + this.pe = pe; + } + + /** + * @return the dur + */ + public String getDur() { + return dur; + } + + /** + * @param dur + * the dur to set + */ + public void setDur(String dur) { + if (dur.matches("\\d*")) { + this.dur = dur; + } else { + // 21 characters that I care about + char[] charCodeArray = CODES.toCharArray(); + + for (int i = 0; i < charCodeArray.length; i++) { + if (dur.equalsIgnoreCase(String.valueOf(charCodeArray[i]))) { + dur = String.valueOf(INT_CODE_ARRAY[i]); + this.dur = dur; + break; + } + } + } + } + + /** + * @return the ts + */ + public String getTs() { + return ts; + } + + /** + * @param ts + * the ts to set + */ + public void setTs(String ts) { + this.ts = ts; + } + + /** + * @return the product_id + */ + public String getProductId() { + return product_id; + } + + /** + * @param product_id + * the product_id to set + */ + public void setProductId(String product_id) { + this.product_id = product_id; + } + + /** + * @return the extremum + */ + public String getExtremum() { + return extremum; + } + + /** + * @param extremum + * the extremum to set + */ + public void setExtremum(String extremum) { + this.extremum = extremum; + } + + /** + * @return the cdur + */ + public String getCdur() { + return cdur; + } + + /** + * @param cdur + * the cdur to set + */ + public void setCdur(String cdur) { + this.cdur = cdur; + } + + /** + * @return the colorName + */ + public String getColorName() { + return colorName; + } + + /** + * @param colorName + * the colorName to set + */ + public void setColorName(String colorName) { + this.colorName = colorName.trim(); + } + + /** + * @return the isForecast + */ + public boolean isForecast() { + return isForecast; + } + + /** + * @param isForecast + * the isForecast to set + */ + public void setForecast(boolean isForecast) { + this.isForecast = isForecast; + } + + /** + * Set the PEDTSE values from a single string + * + * @param pc + * the PEDTSE values as a String + */ + public void setPc(String pc) { + setPe(pc.substring(0, 2)); + setDur(pc.substring(2, 3)); + setTs(pc.substring(3, 5)); + setExtremum(pc.substring(5)); + + // Set forecast if ts is F or C + this.setForecast(false); + if (getTs().startsWith("F") || getTs().startsWith("f") + || getTs().startsWith("C") || getTs().startsWith("c")) { + this.setForecast(true); + } + } + + /** + * @return the label + */ + public String getLabel() { + return label; + } + + /** + * @param label + * the label to set + */ + public void setLabel(String label) { + this.label = label; + } + + /** + * @return the isSelected + */ + public boolean isSelected() { + return isSelected; + } + + /** + * @param isSelected + * the isSelected to set + */ + public void setSelected(boolean isSelected) { + this.isSelected = isSelected; + } + + /** + * @return the lineData + */ + public int[] getLineData() { + return lineData; + } + + /** + * @param lineData + * the lineData to set + */ + public void setLineData(int[] lineData) { + this.lineData = lineData; + } + + /** + * @return the previousLineData + */ + public TimeSeriesPoint[] getPreviousTsData() { + return previousTsData; + } + + /** + * @param previousLineData + * the previousLineData to set + */ + public void setPreviousTsData(TimeSeriesPoint[] previousTsData) { + this.previousTsData = previousTsData; + } + + /** + * @return the zoomedTsData + */ + public TimeSeriesPoint[] getZoomedTsData() { + return zoomedTsData; + } + + /** + * @param zoomedTsData + * the zoomedTsData to set + */ + public void setZoomedTsData(TimeSeriesPoint[] zoomedTsData) { + this.zoomedTsData = zoomedTsData; + } + + /** + * @return the traceOn + */ + public boolean isTraceOn() { + return traceOn; + } + + /** + * @param traceOn + * the traceOn to set + */ + public void setTraceOn(boolean traceOn) { + this.traceOn = traceOn; + } + + /** + * @return the traceValid + */ + public boolean isTraceValid() { + return traceValid; + } + + /** + * @param traceValid + * the traceValid to set + */ + public void setTraceValid(boolean traceValid) { + this.traceValid = traceValid; + } + + /** + * @return the productTime + */ + public Date getProductTime() { + return productTime; + } + + /** + * @param productTime + * the productTime to set + */ + public void setProductTime(Date productTime) { + this.productTime = productTime; + } + + /** + * @return zoom index offset + */ + public int getZoomIndexOffset() { + + if (this.zoomedTsData != null && this.zoomedTsData.length > 0) { + for (int i = 0; i < this.tsData.length; i++) { + if (tsData[i].getX().equals(zoomedTsData[0].getX()) + && tsData[i].getY() == zoomedTsData[0].getY()) { + return i; + } + } + + } + + return 0; + } + } diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/HydroBaseDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/HydroBaseDlg.java index d117c0b462..cc6ccd30d4 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/HydroBaseDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/HydroBaseDlg.java @@ -167,6 +167,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Changes for non-blocking LowWaterStatementDlg. * Changes for non-blocking RatingCurveDlg. * Changes for non-blocking TextReportDlg. + * 02/16/2016 5354 bkowal Prevent the closure of the password dialog from + * closing all of CAVE. * * * @@ -1494,17 +1496,6 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, } }); - /* Removed per Mr. Glaudemans at 16-17 April TIM in Omaha */ - // Cities menu item - // MenuItem citiesMI = new MenuItem(setupMenu, SWT.NONE); - // citiesMI.setText("&Cities..."); - // citiesMI.addSelectionListener(new SelectionAdapter() { - // @Override - // public void widgetSelected(SelectionEvent event) { - // CitiesDlg citiesDlg = new CitiesDlg(shell); - // citiesDlg.open(); - // } - // }); // Reference Fields menu item MenuItem referenceFieldsMI = new MenuItem(setupMenu, SWT.NONE); referenceFieldsMI.setText("R&eference Fields..."); @@ -1698,21 +1689,16 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, @Override public void mouseDoubleClick(MouseEvent e) { - // TODO Auto-generated method stub // open Modify Location window on double click openModifyDlg(); } @Override public void mouseDown(MouseEvent e) { - // TODO Auto-generated method stub - } @Override public void mouseUp(MouseEvent e) { - // TODO Auto-generated method stub - } }); @@ -1780,11 +1766,6 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, stationCountLbl.setText("( " + size + " Stations )"); } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.hydrocommon.IGetSortType#getSortType() - */ @Override public String getSortType() { return sortByCbo.getItem(sortByCbo.getSelectionIndex()); @@ -1907,12 +1888,6 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, sortAndUpdateListControl(); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.hydrobase.listeners.IPreferencesListener#notifyUpdate() - */ @Override public void notifyUpdate() { applyPreferences(); @@ -1954,24 +1929,10 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, sortAndUpdateListControl(); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events. - * KeyEvent) - */ @Override public void keyPressed(KeyEvent e) { } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events - * .KeyEvent) - */ @Override public void keyReleased(KeyEvent e) { String stationSearch = stationSearchTF.getText().toUpperCase(); @@ -1992,12 +1953,6 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, } } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.hydrobase.listeners.IStationFilterListener# - * notifyFilterChange() - */ @Override public void notifyFilterChange() { populateListControl(); @@ -2023,13 +1978,6 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, } } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.hydrobase.listeners.IStationListener#notifyStationUpdate - * (java.lang.String) - */ @Override public void notifyStationUpdate(String lid) { populateListControl(); @@ -2204,8 +2152,9 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, cancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - // Close password dialog - dialog.close(); + // Dispose the dialog instead of closing it. Otherwise, all + // of CAVE is closed. + dialog.dispose(); } }); diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/HydrobaseAction.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/HydrobaseAction.java index a2b1e78878..a36107ff8c 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/HydrobaseAction.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/HydrobaseAction.java @@ -26,7 +26,7 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.handlers.HandlerUtil; import com.raytheon.uf.common.ohd.AppsDefaults; import com.raytheon.viz.hydrocommon.HydroDisplayManager; @@ -39,14 +39,15 @@ import com.raytheon.viz.hydrocommon.HydroDisplayManager; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- * 6/27/06 lvenable Initial Creation. - * 6/21/2010 #5412 lbousaid Added database name + * 6/21/2010 #5412 lbousaid Added database name * 07/03/2010 6586 mduff Fixed problem introduced from the * CaveSWTDialog refactor and added * a pre-selected lid. * 06/27/2013 2088 rferrel Changes for non-blocking HydroBaseDlg. + * 15/01/2015 5054 randerso Remove unnecessary new Shell * * * @@ -57,17 +58,13 @@ public class HydrobaseAction extends AbstractHandler { private HydroBaseDlg hydrobaseDlg; @Override - public Object execute(ExecutionEvent arg0) throws ExecutionException { + public Object execute(ExecutionEvent event) throws ExecutionException { if (hydrobaseDlg == null || hydrobaseDlg.isDisposed()) { - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(); - + Shell shell = HandlerUtil.getActiveShell(event); String lid = HydroDisplayManager.getInstance().getCurrentLid(); String dbName = AppsDefaults.getInstance().getToken("db_name"); hydrobaseDlg = new HydroBaseDlg(shell, dbName, lid); - Shell passwdShell = new Shell(); - boolean verified = hydrobaseDlg.promptForPassword(passwdShell); - passwdShell.dispose(); + boolean verified = hydrobaseDlg.promptForPassword(shell); if (verified) { hydrobaseDlg.open(); diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AdministrationDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AdministrationDlg.java index 089c7d7def..a722833379 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AdministrationDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AdministrationDlg.java @@ -54,6 +54,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * 02 Sep 2008 lvenable Initial creation. * 14 Nov 2008 1697 askripsky Connect to DB * 16 Apr 2013 1790 rferrel Made dialog non-blocking. + * 15 Jan 2015 5054 randerso Remove unnecessary new Shell * * * @@ -322,6 +323,7 @@ public class AdministrationDlg extends CaveSWTDialog { applyBtn.setText("Apply"); applyBtn.setLayoutData(gd); applyBtn.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { saveRecord(); } @@ -333,6 +335,7 @@ public class AdministrationDlg extends CaveSWTDialog { closeBtn.setText("Close"); closeBtn.setLayoutData(gd); closeBtn.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { close(); } @@ -404,8 +407,8 @@ public class AdministrationDlg extends CaveSWTDialog { // Make sure the LID, aka Station ID, is set since it is the primary key // for the DB if (stationIdTF.getText().compareTo("") == 0) { - MessageBox messageBox = new MessageBox(new Shell(), - SWT.ICON_WARNING | SWT.OK); + MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING + | SWT.OK); messageBox.setText("Station ID Missing"); messageBox.setMessage("Please enter a Station ID"); messageBox.open(); @@ -418,7 +421,7 @@ public class AdministrationDlg extends CaveSWTDialog { .parseInt(hsaNoTF.getText()) : HydroConstants.MISSING_VALUE; if (noTF.getText().length() > 1) { - MessageBox messageBox = new MessageBox(new Shell(), + MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK); messageBox.setText("Invalid Region Number"); messageBox @@ -444,7 +447,7 @@ public class AdministrationDlg extends CaveSWTDialog { currData.setOneYearDate((oneYearTF.getText().compareTo("") == 0) ? (Date) null : adminFormat.parse(oneYearTF.getText())); } catch (ParseException e) { - MessageBox messageBox = new MessageBox(new Shell(), + MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK); messageBox.setText("Invalid One Year Date"); messageBox @@ -457,7 +460,7 @@ public class AdministrationDlg extends CaveSWTDialog { currData.setTenYearDate((tenYearTF.getText().compareTo("") == 0) ? (Date) null : adminFormat.parse(tenYearTF.getText())); } catch (ParseException e) { - MessageBox messageBox = new MessageBox(new Shell(), + MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK); messageBox.setText("Invalid Ten Year Date"); messageBox @@ -467,8 +470,8 @@ public class AdministrationDlg extends CaveSWTDialog { return currData; } } catch (NumberFormatException e) { - MessageBox messageBox = new MessageBox(new Shell(), - SWT.ICON_WARNING | SWT.OK); + MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING + | SWT.OK); messageBox.setText("Invalid HSA Number"); messageBox .setMessage("Please enter a numeric value for HSA Number"); diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CoopAgencyOfficeDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CoopAgencyOfficeDlg.java index 822eb6f5ac..f8539aa4df 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CoopAgencyOfficeDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CoopAgencyOfficeDlg.java @@ -51,6 +51,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * 02 Sep 2008 lvenable Initial creation. * 05 Dec 2008 1744 askripsky Connected data * 17 Apr 2013 1790 rferrel Make dialog non-blocking. + * 15 Jan 2015 5054 randerso Remove unnecessary new Shell * * * @@ -218,6 +219,7 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog { availList.setLayoutData(gd); availList.setFont(controlFont); availList.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { updateDisplay(); } @@ -236,6 +238,7 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog { addBtn.setText("Add -->"); addBtn.setLayoutData(gd); addBtn.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { saveData(); } @@ -246,6 +249,7 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog { deleteBtn.setText("Delete >"); deleteBtn.setLayoutData(gd); deleteBtn.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { deleteData(); } @@ -302,6 +306,7 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog { closeBtn.setText("Close"); closeBtn.setLayoutData(gd); closeBtn.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { close(); } @@ -363,16 +368,16 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog { private void saveData() { // Check to see if the values are valid if (agencyTF.getText().length() > 8) { - MessageBox messageBox = new MessageBox(new Shell(), - SWT.ICON_WARNING | SWT.OK); + MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING + | SWT.OK); messageBox.setText("Agency too long"); messageBox.setMessage("Agency cannot be longer than 8 characters"); messageBox.open(); return; } else if (officeTF.getText().length() > 20) { - MessageBox messageBox = new MessageBox(new Shell(), - SWT.ICON_WARNING | SWT.OK); + MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING + | SWT.OK); messageBox.setText("Office too long"); messageBox.setMessage("Office cannot be longer than 20 characters"); messageBox.open(); @@ -414,8 +419,8 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog { // Refresh the data populateListControl(); } else { - MessageBox messageBox = new MessageBox(new Shell(), - SWT.ICON_WARNING | SWT.OK); + MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING + | SWT.OK); messageBox.setText("No Agency/Office Selected"); messageBox .setMessage("Please select an Agency/Office from the Selected list to delete"); diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataIngestFilterDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataIngestFilterDlg.java index 12136a893b..3b378632e6 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataIngestFilterDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataIngestFilterDlg.java @@ -60,6 +60,7 @@ import com.raytheon.viz.hydrocommon.data.DataIngestFilterData; import com.raytheon.viz.hydrocommon.datamanager.DataIngestFilterDataManager; import com.raytheon.viz.hydrocommon.datamanager.DataTrashCanDataManager; import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager; +import com.raytheon.viz.hydrocommon.datamanager.LocationDataManager; import com.raytheon.viz.hydrocommon.util.StnClassSyncUtil; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; @@ -77,7 +78,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Mar 31, 2014 #2970 lvenable Put dispose checks in the runAsync calls. * May 1, 2014 17096 xwei By default the first item of the data * list is selected - * + * Feb 16, 2016 5354 bkowal Only update the stnclass table after an ingest + * filter removal if there is an associated location. + * * * * @@ -1372,8 +1375,28 @@ public class DataIngestFilterDlg extends CaveSWTDialog { try { HydroDBDataManager.getInstance().deleteRecord(selectedData); - // Synchronize StnClass table - StnClassSyncUtil.setStnClass(selectedData.getLid()); + /* + * If there is not a location associated with the lid of the + * ingest filter record that was just deleted, there is no + * reason to sync the changes to the stnclass table because + * the stnclass table defines a foreign key in which the lid + * must map to a location in the location table. The ingest + * filter table does not define a similar foreign key. So, + * if there is not a location associated with the lid, an + * associated record could never exist in the stnclass table + * and any attempt to insert a record into the stnclass + * table will fail. + */ + + if (!LocationDataManager.getInstance() + .getLocationName(selectedData.getLid()).isEmpty()) { + /* + * an associated location exists, so the stnclass table + * can be updated. + */ + // Synchronize StnClass table + StnClassSyncUtil.setStnClass(selectedData.getLid()); + } } catch (VizException e) { statusHandler.handle(Priority.PROBLEM, "Problem deleting record ", e); diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/whfslib/colorthreshold/GetColorValues.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/whfslib/colorthreshold/GetColorValues.java index f45dda2145..95edc99ecf 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/whfslib/colorthreshold/GetColorValues.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/whfslib/colorthreshold/GetColorValues.java @@ -45,6 +45,9 @@ import com.raytheon.viz.hydrocommon.whfslib.IHFSDbGenerated; * Nov 10, 2008 randerso Initial creation * May 27, 2014 3133 njensen Organized imports, fixed == to equals * Jul 21, 2015 4500 rjpeter Use Number in blind cast. + * Feb 12, 2016 5356 bsteffen Fall back to using the provided + * colorsets when no values are found. + * * * * @author randerso @@ -135,7 +138,7 @@ public class GetColorValues { if ("hydroview".equals(application_name) && "HEIGHT".equals(coloruse_name)) { cvHead = getDefaultColorSet(application_name, coloruse_name, - threshold_unit); + threshold_unit, null); } else { // Try to find a user defined color set. cvHead = getUserColorSet(user_id, application_name, coloruse_name, @@ -152,8 +155,11 @@ public class GetColorValues { // Try to find a default color set. cvHead = getDefaultColorSet(application_name, coloruse_name, - threshold_unit);// , pColorSetGroup); - + threshold_unit, null); + if ((cvHead == null) || (cvHead.size() == 0)) { + cvHead = getDefaultColorSet(application_name, + coloruse_name, threshold_unit, pColorSetGroup); + } if ((cvHead == null) || (cvHead.size() == 0)) { statusHandler.handle(Priority.PROBLEM, "ERROR in " + method + " Colors/levels not defined for application " @@ -224,13 +230,11 @@ public class GetColorValues { */ private static List getDefaultColorSet( final String application_name, final String coloruse_name, - String threshold_unit) {// , final List - // pColorSetGroup) { + String threshold_unit, List pColorSetGroup) { - List pColorSetGroup = null; if (application_name.equals("hmapmpe")) { pColorSetGroup = MPEColors.build_mpe_colors(); - } else { + } else if (pColorSetGroup == null) { pColorSetGroup = HydroDisplayManager.getInstance() .getDefaultNamedColorUseSetList(); } diff --git a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java index 7fc3009e5e..009f7edc3e 100644 --- a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java +++ b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java @@ -95,6 +95,7 @@ import com.raytheon.viz.lightning.cache.LightningFrameRetriever; * Jul 01, 2015 4597 bclement reworked resource name using DisplayType * Sep 10, 2015 4856 njensen synchronize in remove(DataTime) * Sep 25, 2015 4605 bsteffen repeat binning + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling * * * @@ -153,7 +154,7 @@ public class LightningResource extends @Override protected void initInternal(IGraphicsTarget target) throws VizException { - font = target.initializeFont(Font.MONOSPACED, 11, + font = target.initializeFont(Font.MONOSPACED, 9, new Style[] { Style.BOLD }); VizApp.runSync(new Runnable() { @@ -248,8 +249,9 @@ public class LightningResource extends int cloudCount = 0; int pulseCount = 0; - if (magnification == 0.0) + if (magnification == 0.0) { magnification = (float) 0.01; + } /* * we only want strikes that are visible so we have to filter any diff --git a/cave/com.raytheon.viz.lpi/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.lpi/META-INF/MANIFEST.MF index c3c1d0cc12..51ca6ecbcc 100644 --- a/cave/com.raytheon.viz.lpi/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.lpi/META-INF/MANIFEST.MF @@ -10,7 +10,6 @@ Require-Bundle: org.eclipse.ui, com.raytheon.viz.core, com.raytheon.viz.ui, org.geotools, - org.apache.commons.lang, com.raytheon.uf.viz.core.maps;bundle-version="1.0.0" Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.viz.lpi diff --git a/cave/com.raytheon.viz.lpi/localization/basemaps/us_county.lpi b/cave/com.raytheon.viz.lpi/localization/basemaps/us_county.lpi deleted file mode 100644 index 2a1be03f4c..0000000000 --- a/cave/com.raytheon.viz.lpi/localization/basemaps/us_county.lpi +++ /dev/null @@ -1,3142 +0,0 @@ -3141 -32.542 -86.641 70 Autauga -30.655 -87.755 70 Baldwin -31.863 -85.389 70 Barbour -32.997 -87.127 70 Bibb -33.980 -86.566 70 Blount -32.102 -85.718 70 Bullock -31.752 -86.682 70 Butler -33.775 -85.826 70 Calhoun -32.915 -85.390 70 Chambers -34.187 -85.606 70 Cherokee -32.845 -86.719 70 Chilton -32.025 -88.266 70 Choctaw -31.678 -87.836 70 Clarke -33.269 -85.860 70 Clay -33.671 -85.517 70 Cleburne -31.403 -85.989 70 Coffee -34.707 -87.797 70 Colbert -31.428 -86.993 70 Conecuh -32.936 -86.239 70 Coosa -31.248 -86.453 70 Covington -31.731 -86.312 70 Crenshaw -34.132 -86.867 70 Cullman -31.426 -85.612 70 Dale -32.330 -87.110 70 Dallas -34.460 -85.799 70 DeKalb -32.600 -86.138 70 Elmore -31.137 -87.163 70 Escambia -34.048 -86.038 70 Etowah -33.730 -87.735 70 Fayette -34.436 -87.844 70 Franklin -31.094 -85.837 70 Geneva -32.855 -87.951 70 Greene -32.756 -87.625 70 Hale -31.516 -85.240 70 Henry -31.151 -85.305 70 Houston -34.776 -86.002 70 Jackson -33.552 -86.897 70 Jefferson -33.775 -88.096 70 Lamar -34.904 -87.648 70 Lauderdale -34.520 -87.310 70 Lawrence -32.597 -85.356 70 Lee -34.810 -86.981 70 Limestone -32.158 -86.643 70 Lowndes -32.385 -85.693 70 Macon -34.760 -86.549 70 Madison -32.249 -87.790 70 Marengo -34.134 -87.887 70 Marion -34.365 -86.313 70 Marshall -30.684 -88.199 70 Mobile -31.563 -87.353 70 Monroe -32.224 -86.204 70 Montgomery -34.453 -86.857 70 Morgan -32.639 -87.294 70 Perry -33.284 -88.084 70 Pickens -31.806 -85.939 70 Pike -33.291 -85.456 70 Randolph -32.287 -85.184 70 Russell -33.713 -86.318 70 St Clair -33.267 -86.655 70 Shelby -32.593 -88.194 70 Sumter -33.384 -86.169 70 Talladega -32.861 -85.798 70 Tallapoosa -33.288 -87.524 70 Tuscaloosa -33.807 -87.296 70 Walker -31.403 -88.203 70 Washington -31.991 -87.309 70 Wilcox -34.155 -87.373 70 Winston -55.229 -161.915 70 Aleutians East -52.243 -175.130 70 Aleutians West -61.178 -149.186 70 Anchorage -60.939 -160.147 70 Bethel -58.745 -156.988 70 Bristol Bay -59.950 -158.430 70 Dillingham -64.846 -146.643 70 Fairbanks North Star -59.156 -135.444 70 Haines -58.389 -134.133 70 Juneau -60.202 -151.630 70 Kenai Peninsula -55.541 -131.408 70 Ketchikan Gateway -57.707 -153.783 70 Kodiak Island -58.401 -156.185 70 Lake and Peninsula -62.395 -149.575 70 Matanuska-Susitna -64.735 -164.187 70 Nome -69.297 -153.448 70 North Slope -67.001 -159.998 70 Northwest Arctic -55.454 -132.050 70 Prince of Wales-Outer Ketchikan -57.214 -135.447 70 Sitka -58.811 -136.622 70 Skagway-Yakutat-Angoon -63.765 -143.598 70 Southeast Fairbanks -61.400 -144.503 70 Valdez-Cordova -62.088 -163.529 70 Wade Hampton -56.518 -132.962 70 Wrangell-Petersburg -65.286 -151.647 70 Yukon-Koyukuk -35.384 -109.488 70 Apache -31.891 -109.737 70 Cochise -35.836 -111.768 70 Coconino -33.797 -110.818 70 Gila -32.937 -109.891 70 Graham -33.185 -109.233 70 Greenlee -33.728 -113.979 70 La Paz -33.343 -112.491 70 Maricopa -35.708 -113.753 70 Mohave -35.388 -110.320 70 Navajo -32.104 -111.815 70 Pima -32.909 -111.347 70 Pinal -31.524 -110.836 70 Santa Cruz -34.595 -112.554 70 Yavapai -32.765 -113.897 70 Yuma -34.289 -91.376 70 Arkansas -33.191 -91.772 70 Ashley -36.286 -92.340 70 Baxter -36.338 -94.258 70 Benton -36.314 -93.093 70 Boone -33.463 -92.168 70 Bradley -33.554 -92.497 70 Calhoun -36.337 -93.542 70 Carroll -33.266 -91.298 70 Chicot -34.054 -93.177 70 Clark -36.376 -90.421 70 Clay -35.542 -92.029 70 Cleburne -33.894 -92.188 70 Cleveland -33.215 -93.227 70 Columbia -35.263 -92.695 70 Conway -35.828 -90.632 70 Craighead -35.579 -94.246 70 Crawford -35.213 -90.314 70 Crittenden -35.300 -90.771 70 Cross -33.967 -92.657 70 Dallas -33.831 -91.259 70 Desha -33.590 -91.717 70 Drew -35.147 -92.335 70 Faulkner -35.512 -93.892 70 Franklin -36.383 -91.819 70 Fulton -34.573 -93.154 70 Garland -34.287 -92.423 70 Grant -36.119 -90.562 70 Greene -33.731 -93.665 70 Hempstead -34.320 -92.945 70 Hot Spring -34.090 -93.990 70 Howard -35.744 -91.566 70 Independence -36.095 -91.911 70 Izard -35.600 -91.214 70 Jackson -34.269 -91.929 70 Jefferson -35.569 -93.461 70 Johnson -33.236 -93.611 70 Lafayette -36.043 -91.115 70 Lawrence -34.780 -90.780 70 Lee -33.953 -91.734 70 Lincoln -33.700 -94.236 70 Little River -35.215 -93.713 70 Logan -34.755 -91.883 70 Lonoke -36.012 -93.723 70 Madison -36.263 -92.680 70 Marion -33.311 -93.881 70 Miller -35.764 -90.054 70 Mississippi -34.680 -91.203 70 Monroe -34.546 -93.660 70 Montgomery -33.667 -93.303 70 Nevada -35.918 -93.223 70 Newton -33.591 -92.879 70 Ouachita -34.947 -92.934 70 Perry -34.426 -90.852 70 Phillips -34.166 -93.655 70 Pike -35.577 -90.663 70 Poinsett -34.475 -94.224 70 Polk -35.446 -93.036 70 Pope -34.828 -91.557 70 Prairie -34.770 -92.311 70 Pulaski -36.342 -91.028 70 Randolph -35.022 -90.747 70 St Francis -34.648 -92.675 70 Saline -34.859 -94.063 70 Scott -35.918 -92.703 70 Searcy -35.199 -94.275 70 Sebastian -33.999 -94.238 70 Sevier -36.154 -91.482 70 Sharp -35.863 -92.153 70 Stone -33.170 -92.594 70 Union -35.581 -92.519 70 Van Buren -35.986 -94.214 70 Washington -35.255 -91.746 70 White -35.188 -91.241 70 Woodruff -34.998 -93.407 70 Yell -37.654 -121.914 70 Alameda -38.579 -119.804 70 Alpine -38.444 -120.655 70 Amador -39.662 -121.596 70 Butte -38.208 -120.552 70 Calaveras -39.176 -122.235 70 Colusa -37.933 -121.949 70 Contra Costa -41.737 -123.957 70 Del Norte -38.775 -120.528 70 El Dorado -36.754 -119.648 70 Fresno -39.595 -122.392 70 Glenn -40.700 -123.912 70 Humboldt -33.039 -115.353 70 Imperial -36.589 -117.483 70 Inyo -35.338 -118.725 70 Kern -36.073 -119.815 70 Kings -39.091 -122.762 70 Lake -40.652 -120.578 70 Lassen -34.185 -118.262 70 Los Angeles -37.220 -119.765 70 Madera -38.035 -122.743 70 Marin -37.578 -119.910 70 Mariposa -39.431 -123.432 70 Mendocino -37.189 -120.711 70 Merced -41.595 -120.719 70 Modoc -37.911 -118.874 70 Mono -36.239 -121.311 70 Monterey -38.503 -122.323 70 Napa -39.304 -120.766 70 Nevada -33.675 -117.777 70 Orange -39.065 -120.728 70 Placer -40.011 -120.834 70 Plumas -33.728 -115.977 70 Riverside -38.445 -121.349 70 Sacramento -36.612 -121.084 70 San Benito -34.828 -116.191 70 San Bernardino -33.021 -116.772 70 San Diego -37.793 -122.555 70 San Francisco -37.933 -121.271 70 San Joaquin -35.382 -120.446 70 San Luis Obispo -37.437 -122.356 70 San Mateo -34.537 -120.026 70 Santa Barbara -37.233 -121.686 70 Santa Clara -37.026 -122.007 70 Santa Cruz -40.760 -122.038 70 Shasta -39.591 -120.499 70 Sierra -41.589 -122.533 70 Siskiyou -38.267 -121.938 70 Solano -38.512 -122.929 70 Sonoma -37.562 -120.994 70 Stanislaus -39.040 -121.689 70 Sutter -40.129 -122.233 70 Tehama -40.657 -123.118 70 Trinity -36.228 -118.797 70 Tulare -38.019 -119.945 70 Tuolumne -34.356 -119.146 70 Ventura -38.701 -121.883 70 Yolo -39.271 -121.353 70 Yuba -39.871 -104.350 70 Adams |NE -37.572 -105.785 70 Alamosa |SC -39.644 -104.332 70 Arapahoe |NE -37.187 -107.052 70 Archuleta |SC -37.321 -102.557 70 Baca |SE -37.955 -103.077 70 Bent |SE -40.088 -105.357 70 Boulder |NE -38.737 -106.176 70 Chaffee |CC -38.820 -102.588 70 Cheyenne |EC -39.688 -105.636 70 Clear Creek |CC -37.206 -106.194 70 Conejos |SC -37.276 -105.428 70 Costilla |SC -38.327 -103.785 70 Crowley |SE -38.093 -105.361 70 Custer |SE -38.862 -107.861 70 Delta |WC -39.768 -104.873 70 Denver |NE -37.755 -108.522 70 Dolores |SW -39.346 -104.930 70 Douglas |NE -39.624 -106.704 70 Eagle |CC -39.282 -104.128 70 Elbert |EC -38.838 -104.521 70 El Paso |EC -38.476 -105.438 70 Fremont |CC -39.603 -107.897 70 Garfield |WC -39.859 -105.520 70 Gilpin |CC -40.102 -106.118 70 Grand |NC -38.669 -107.014 70 Gunnison |CC -37.821 -107.280 70 Hinsdale |SW -37.687 -104.959 70 Huerfano |SE -40.662 -106.339 70 Jackson |NC -39.587 -105.247 70 Jefferson |NE -38.434 -102.741 70 Kiowa |SE -39.305 -102.602 70 Kit Carson |EC -39.190 -106.358 70 Lake |CC -37.286 -107.846 70 La Plata |SW -40.649 -105.456 70 Larimer |NC -37.320 -104.043 70 Las Animas |SE -38.979 -103.523 70 Lincoln |EC -40.729 -103.105 70 Logan |NE -39.022 -108.468 70 Mesa |WC -37.693 -106.927 70 Mineral |SC -40.608 -108.202 70 Moffat |NW -37.336 -108.596 70 Montezuma |SW -38.406 -108.269 70 Montrose |WC -40.263 -103.807 70 Morgan |NE -37.896 -103.711 70 Otero |SE -38.157 -107.766 70 Ouray |SW -39.117 -105.714 70 Park |CC -40.594 -102.349 70 Phillips |NE -39.221 -106.921 70 Pitkin |CC -37.956 -102.395 70 Prowers |SE -38.153 -104.506 70 Pueblo |SE -39.975 -108.199 70 Rio Blanco |NW -37.606 -106.388 70 Rio Grande |SC -40.484 -106.987 70 Routt |NW -38.079 -106.299 70 Saguache |CC -37.770 -107.667 70 San Juan |SW -38.013 -108.426 70 San Miguel |WC -40.877 -102.353 70 Sedgwick |NE -39.619 -106.108 70 Summit |CC -38.881 -105.154 70 Teller |CC -39.976 -103.201 70 Washington |NE -40.545 -104.403 70 Weld |NE -40.000 -102.422 70 Yuma |NE -41.221 -73.370 70 Fairfield -41.807 -72.731 70 Hartford -41.791 -73.248 70 Litchfield -41.435 -72.526 70 Middlesex -41.364 -72.906 70 New Haven -41.477 -72.120 70 New London -41.848 -72.337 70 Tolland -41.832 -71.988 70 Windham -39.097 -75.503 70 Kent -39.581 -75.638 70 New Castle -38.683 -75.342 70 Sussex -38.905 -77.016 70 District of Columbia -29.676 -82.358 70 Alachua -30.324 -82.274 70 Baker -30.236 -85.632 70 Bay -29.950 -82.168 70 Bradford -28.299 -80.701 70 Brevard -26.146 -80.453 70 Broward -30.410 -85.197 70 Calhoun -26.898 -81.954 70 Charlotte -28.849 -82.516 70 Citrus -29.977 -81.858 70 Clay -26.083 -81.401 70 Collier -30.225 -82.625 70 Columbia -25.606 -80.502 70 Dade -27.191 -81.806 70 DeSoto -29.586 -83.194 70 Dixie -30.334 -81.649 70 Duval -30.607 -87.333 70 Escambia -29.470 -81.297 70 Flagler -29.802 -84.817 70 Franklin -30.582 -84.612 70 Gadsden -29.734 -82.803 70 Gilchrist -26.954 -81.186 70 Glades -29.900 -85.242 70 Gulf -30.492 -82.949 70 Hamilton -27.494 -81.809 70 Hardee -26.554 -81.173 70 Hendry -28.553 -82.468 70 Hernando -27.341 -81.343 70 Highlands -27.906 -82.346 70 Hillsborough -30.867 -85.812 70 Holmes -27.698 -80.579 70 Indian River -30.797 -85.213 70 Jackson -30.421 -83.896 70 Jefferson -29.988 -83.180 70 Lafayette -28.766 -81.717 70 Lake -26.578 -81.921 70 Lee -30.457 -84.279 70 Leon -29.277 -82.790 70 Levy -30.233 -84.887 70 Liberty -30.452 -83.467 70 Madison -27.481 -82.360 70 Manatee -29.212 -82.059 70 Marion -27.080 -80.397 70 Martin -25.117 -81.150 70 Monroe -30.611 -81.768 70 Nassau -30.668 -86.593 70 Okaloosa -27.385 -80.890 70 Okeechobee -28.514 -81.322 70 Orange -28.058 -81.147 70 Osceola -26.641 -80.437 70 Palm Beach -28.301 -82.439 70 Pasco -27.903 -82.739 70 Pinellas -27.960 -81.700 70 Polk -29.605 -81.740 70 Putnam -29.908 -81.407 70 St Johns -27.378 -80.444 70 St Lucie -30.696 -87.016 70 Santa Rosa -27.195 -82.369 70 Sarasota -28.709 -81.227 70 Seminole -28.708 -82.079 70 Sumter -30.187 -82.993 70 Suwannee -30.019 -83.616 70 Taylor -30.043 -82.374 70 Union -29.068 -81.138 70 Volusia -30.153 -84.381 70 Wakulla -30.615 -86.171 70 Walton -30.613 -85.671 70 Washington -31.753 -82.286 70 Appling -31.295 -82.875 70 Atkinson -31.557 -82.451 70 Bacon -31.331 -84.454 70 Baker -33.072 -83.251 70 Baldwin -34.353 -83.501 70 Banks -33.993 -83.712 70 Barrow -34.238 -84.839 70 Bartow -31.759 -83.220 70 Ben Hill -31.274 -83.232 70 Berrien -32.805 -83.699 70 Bibb -32.436 -83.331 70 Bleckley -31.197 -81.983 70 Brantley -30.847 -83.577 70 Brooks -32.020 -81.438 70 Bryan -32.391 -81.744 70 Bulloch -33.058 -81.999 70 Burke -33.288 -83.957 70 Butts -31.528 -84.619 70 Calhoun -30.919 -81.638 70 Camden -32.401 -82.075 70 Candler -33.583 -85.079 70 Carroll -34.902 -85.136 70 Catoosa -30.779 -82.140 70 Charlton -31.968 -81.085 70 Chatham -32.348 -84.788 70 Chattahoochee -34.477 -85.346 70 Chattooga -34.245 -84.474 70 Cherokee -33.952 -83.366 70 Clarke -31.621 -84.993 70 Clay -33.543 -84.357 70 Clayton -30.918 -82.703 70 Clinch -33.942 -84.577 70 Cobb -31.547 -82.851 70 Coffee -31.186 -83.768 70 Colquitt -33.549 -82.261 70 Columbia -31.155 -83.431 70 Cook -33.353 -84.763 70 Coweta -32.710 -83.980 70 Crawford -31.925 -83.772 70 Crisp -34.855 -85.505 70 Dade -34.440 -84.171 70 Dawson -30.879 -84.580 70 Decatur -33.771 -84.227 70 DeKalb -32.173 -83.166 70 Dodge -32.161 -83.798 70 Dooly -31.538 -84.216 70 Dougherty -33.700 -84.767 70 Douglas -31.330 -84.909 70 Early -30.717 -82.899 70 Echols -32.370 -81.343 70 Effingham -34.115 -82.840 70 Elbert -32.587 -82.304 70 Emanuel -32.158 -81.891 70 Evans -34.864 -84.319 70 Fannin -33.415 -84.493 70 Fayette -34.263 -85.215 70 Floyd -34.224 -84.127 70 Forsyth -34.373 -83.228 70 Franklin -33.789 -84.467 70 Fulton -34.688 -84.458 70 Gilmer -33.231 -82.607 70 Glascock -31.217 -81.494 70 Glynn -34.504 -84.872 70 Gordon -30.875 -84.233 70 Grady -33.581 -83.168 70 Greene -33.959 -84.025 70 Gwinnett -34.630 -83.529 70 Habersham -34.316 -83.821 70 Hall -33.270 -83.001 70 Hancock -33.791 -85.209 70 Haralson -32.741 -84.906 70 Harris -34.353 -82.959 70 Hart -33.300 -85.129 70 Heard -33.456 -84.155 70 Henry -32.458 -83.668 70 Houston -31.602 -83.274 70 Irwin -34.133 -83.563 70 Jackson -33.316 -83.687 70 Jasper -31.802 -82.636 70 Jeff Davis -33.054 -82.415 70 Jefferson -32.789 -81.960 70 Jenkins -32.702 -82.656 70 Johnson -33.026 -83.566 70 Jones -33.073 -84.135 70 Lamar -31.037 -83.063 70 Lanier -32.463 -82.930 70 Laurens -31.777 -84.137 70 Lee -31.800 -81.462 70 Liberty -33.793 -82.452 70 Lincoln -31.759 -81.747 70 Long -30.835 -83.268 70 Lowndes -34.574 -84.002 70 Lumpkin -33.478 -82.482 70 McDuffie -31.480 -81.372 70 McIntosh -32.354 -84.038 70 Macon -34.128 -83.210 70 Madison -32.353 -84.526 70 Marion -33.043 -84.685 70 Meriwether -31.164 -84.729 70 Miller -31.224 -84.195 70 Mitchell -33.013 -83.913 70 Monroe -32.168 -82.530 70 Montgomery -33.593 -83.493 70 Morgan -34.782 -84.748 70 Murray -32.511 -84.875 70 Muscogee -33.553 -83.844 70 Newton -33.837 -83.437 70 Oconee -33.881 -83.082 70 Oglethorpe -33.923 -84.866 70 Paulding -32.564 -83.828 70 Peach -34.465 -84.465 70 Pickens -31.356 -82.215 70 Pierce -33.091 -84.386 70 Pike -33.999 -85.182 70 Polk -32.237 -83.474 70 Pulaski -33.321 -83.373 70 Putnam -31.859 -85.012 70 Quitman -34.881 -83.401 70 Rabun -31.763 -84.758 70 Randolph -33.359 -82.074 70 Richmond -33.650 -84.027 70 Rockdale -32.263 -84.320 70 Schley -32.749 -81.614 70 Screven -30.933 -84.867 70 Seminole -33.262 -84.285 70 Spalding -34.556 -83.294 70 Stephens -32.078 -84.837 70 Stewart -32.042 -84.196 70 Sumter -32.708 -84.528 70 Talbot -33.567 -82.883 70 Taliaferro -32.043 -82.061 70 Tattnall -32.554 -84.251 70 Taylor -31.935 -82.941 70 Telfair -31.776 -84.436 70 Terrell -30.865 -83.919 70 Thomas -31.457 -83.526 70 Tift -32.123 -82.335 70 Toombs -34.919 -83.739 70 Towns -32.405 -82.565 70 Treutlen -33.033 -85.028 70 Troup -31.716 -83.627 70 Turner -32.666 -83.426 70 Twiggs -34.834 -83.991 70 Union -32.879 -84.298 70 Upson -34.731 -85.296 70 Walker -33.783 -83.738 70 Walton -31.052 -82.422 70 Ware -33.408 -82.676 70 Warren -32.968 -82.795 70 Washington -31.548 -81.913 70 Wayne -32.049 -84.550 70 Webster -32.122 -82.717 70 Wheeler -34.645 -83.753 70 White -34.805 -84.966 70 Whitfield -31.970 -83.436 70 Wilcox -33.787 -82.744 70 Wilkes -32.799 -83.168 70 Wilkinson -31.553 -83.848 70 Worth -19.597 -155.499 70 Hawaii -23.573 -164.701 70 Honolulu -21.226 -156.948 70 Kalawao -22.013 -159.705 70 Kauai -20.868 -156.622 70 Maui -43.448 -116.243 70 Ada -44.896 -116.455 70 Adams -42.668 -112.222 70 Bannock -42.290 -111.333 70 Bear Lake -47.222 -116.655 70 Benewah -43.216 -112.398 70 Bingham -43.394 -113.978 70 Blaine -44.006 -115.739 70 Boise -48.295 -116.598 70 Bonner -43.380 -111.602 70 Bonneville -48.793 -116.449 70 Boundary -43.725 -113.174 70 Butte -43.469 -114.811 70 Camas -43.626 -116.707 70 Canyon -42.759 -111.551 70 Caribou -42.272 -113.611 70 Cassia -44.285 -112.376 70 Clark -46.668 -115.658 70 Clearwater -44.232 -114.294 70 Custer -43.343 -115.465 70 Elmore -42.183 -111.810 70 Franklin -44.217 -111.484 70 Fremont -44.061 -116.405 70 Gem -42.965 -114.800 70 Gooding -45.847 -115.459 70 Idaho -43.822 -112.305 70 Jefferson -42.692 -114.263 70 Jerome -47.677 -116.697 70 Kootenai -46.816 -116.706 70 Latah -44.956 -113.949 70 Lemhi -46.239 -116.430 70 Lewis -42.978 -114.130 70 Lincoln -43.788 -111.657 70 Madison -42.848 -113.643 70 Minidoka -46.331 -116.746 70 Nez Perce -42.208 -112.522 70 Oneida -42.563 -116.168 70 Owyhee -44.010 -116.758 70 Payette -42.688 -112.838 70 Power -47.348 -115.885 70 Shoshone -43.755 -111.213 70 Teton -42.353 -114.662 70 Twin Falls -44.744 -115.560 70 Valley -44.449 -116.779 70 Washington -39.986 -91.195 70 Adams -37.194 -89.340 70 Alexander -38.881 -89.436 70 Bond -42.326 -88.813 70 Boone -39.954 -90.750 70 Brown -41.409 -89.529 70 Bureau -39.165 -90.667 70 Calhoun -42.061 -89.924 70 Carroll -39.977 -90.247 70 Cass -40.140 -88.196 70 Champaign -39.547 -89.278 70 Christian -39.333 -87.792 70 Clark -38.755 -88.488 70 Clay -38.607 -89.424 70 Clinton -39.513 -88.221 70 Coles -41.898 -87.650 70 Cook -39.003 -87.760 70 Crawford -39.274 -88.240 70 Cumberland -41.894 -88.769 70 DeKalb -40.170 -88.905 70 De Witt -39.766 -88.223 70 Douglas -41.852 -88.086 70 DuPage -39.679 -87.747 70 Edgar -38.417 -88.058 70 Edwards -39.064 -88.588 70 Effingham -39.001 -89.018 70 Fayette -40.595 -88.225 70 Ford -37.992 -88.923 70 Franklin -40.479 -90.213 70 Fulton -37.758 -88.229 70 Gallatin -39.352 -90.386 70 Greene -41.289 -88.428 70 Grundy -38.081 -88.541 70 Hamilton -40.402 -91.169 70 Hancock -37.522 -88.266 70 Hardin -40.810 -90.926 70 Henderson -41.355 -90.136 70 Henry -40.742 -87.824 70 Iroquois -37.788 -89.381 70 Jackson -39.006 -88.149 70 Jasper -38.301 -88.924 70 Jefferson -39.088 -90.358 70 Jersey -42.364 -90.210 70 Jo Daviess -37.459 -88.874 70 Johnson -41.936 -88.432 70 Kane -41.138 -87.863 70 Kankakee -41.588 -88.431 70 Kendall -40.931 -90.214 70 Knox -42.433 -87.777 70 Lake -41.341 -88.885 70 La Salle -38.720 -87.731 70 Lawrence -41.740 -89.300 70 Lee -40.888 -88.557 70 Livingston -40.127 -89.363 70 Logan -40.456 -90.678 70 McDonough -42.324 -88.452 70 McHenry -40.495 -88.845 70 McLean -39.860 -88.961 70 Macon -39.257 -89.921 70 Macoupin -38.832 -89.908 70 Madison -38.649 -88.919 70 Marion -41.031 -89.342 70 Marshall -40.238 -89.914 70 Mason -37.219 -88.710 70 Massac -40.034 -89.800 70 Menard -41.204 -90.742 70 Mercer -38.277 -90.178 70 Monroe -39.228 -89.478 70 Montgomery -39.715 -90.198 70 Morgan -39.638 -88.617 70 Moultrie -42.042 -89.320 70 Ogle -40.790 -89.759 70 Peoria -38.085 -89.368 70 Perry -40.007 -88.593 70 Piatt -39.620 -90.886 70 Pike -37.411 -88.573 70 Pope -37.228 -89.131 70 Pulaski -41.203 -89.282 70 Putnam -38.049 -89.821 70 Randolph -38.713 -88.085 70 Richland -41.469 -90.566 70 Rock Island -38.471 -89.931 70 St Clair -37.754 -88.541 70 Saline -39.758 -89.658 70 Sangamon -40.158 -90.609 70 Schuyler -39.648 -90.478 70 Scott -39.395 -88.809 70 Shelby -41.089 -89.795 70 Stark -42.350 -89.666 70 Stephenson -40.513 -89.513 70 Tazewell -37.469 -89.256 70 Union -40.182 -87.738 70 Vermilion -38.444 -87.840 70 Wabash -40.853 -90.615 70 Warren -38.351 -89.417 70 Washington -38.432 -88.423 70 Wayne -38.087 -88.178 70 White -41.751 -89.911 70 Whiteside -41.439 -87.982 70 Will -37.730 -88.930 70 Williamson -42.332 -89.161 70 Winnebago -40.786 -89.212 70 Woodford -40.745 -84.936 70 Adams -41.091 -85.064 70 Allen -39.205 -85.898 70 Bartholomew -40.606 -87.308 70 Benton -40.473 -85.323 70 Blackford -40.051 -86.469 70 Boone -39.196 -86.229 70 Brown -40.584 -86.565 70 Carroll -40.761 -86.347 70 Cass -38.477 -85.716 70 Clark -39.396 -87.115 70 Clay -40.300 -86.476 70 Clinton -38.285 -86.456 70 Crawford -38.702 -87.076 70 Daviess -39.150 -84.977 70 Dearborn -39.304 -85.502 70 Decatur -41.396 -85.000 70 De Kalb -40.226 -85.398 70 Delaware -38.364 -86.881 70 Dubois -41.596 -85.859 70 Elkhart -39.644 -85.176 70 Fayette -38.319 -85.903 70 Floyd -40.123 -87.244 70 Fountain -39.422 -85.056 70 Franklin -41.044 -86.261 70 Fulton -38.309 -87.580 70 Gibson -40.516 -85.654 70 Grant -39.037 -86.966 70 Greene -40.071 -86.052 70 Hamilton -39.823 -85.771 70 Hancock -38.199 -86.116 70 Harrison -39.769 -86.509 70 Hendricks -39.931 -85.397 70 Henry -40.481 -86.116 70 Howard -40.829 -85.494 70 Huntington -38.907 -86.043 70 Jackson -41.025 -87.120 70 Jasper -40.434 -85.009 70 Jay -38.786 -85.437 70 Jefferson -38.996 -85.628 70 Jennings -39.490 -86.096 70 Johnson -38.691 -87.419 70 Knox -41.244 -85.861 70 Kosciusko -41.642 -85.426 70 Lagrange -41.476 -87.379 70 Lake -41.549 -86.745 70 La Porte -38.840 -86.485 70 Lawrence -40.163 -85.721 70 Madison -39.782 -86.138 70 Marion -41.331 -86.263 70 Marshall -38.711 -86.802 70 Martin -40.769 -86.048 70 Miami -39.161 -86.523 70 Monroe -40.041 -86.893 70 Montgomery -39.482 -86.447 70 Morgan -40.951 -87.402 70 Newton -41.396 -85.417 70 Noble -38.954 -84.968 70 Ohio -38.535 -86.495 70 Orange -39.312 -86.839 70 Owen -39.775 -87.207 70 Parke -38.082 -86.644 70 Perry -38.398 -87.233 70 Pike -41.508 -87.071 70 Porter -38.024 -87.861 70 Posey -41.037 -86.695 70 Pulaski -39.667 -86.844 70 Putnam -40.150 -85.006 70 Randolph -39.102 -85.260 70 Ripley -39.617 -85.469 70 Rush -41.618 -86.288 70 St Joseph -38.687 -85.744 70 Scott -39.523 -85.791 70 Shelby -38.011 -87.011 70 Spencer -41.282 -86.648 70 Starke -41.644 -85.000 70 Steuben -39.089 -87.414 70 Sullivan -38.824 -85.027 70 Switzerland -40.388 -86.894 70 Tippecanoe -40.310 -86.052 70 Tipton -39.623 -84.923 70 Union -38.023 -87.584 70 Vanderburgh -39.854 -87.462 70 Vermillion -39.429 -87.390 70 Vigo -40.847 -85.790 70 Wabash -40.345 -87.356 70 Warren -38.098 -87.271 70 Warrick -38.599 -86.106 70 Washington -39.862 -85.006 70 Wayne -40.727 -85.220 70 Wells -40.748 -86.865 70 White -41.135 -85.504 70 Whitley -41.327 -94.466 70 Adair -41.033 -94.702 70 Adams -43.280 -91.373 70 Allamakee -40.741 -92.869 70 Appanoose -41.685 -94.905 70 Audubon -42.080 -92.066 70 Benton -42.473 -92.307 70 Black Hawk -42.036 -93.933 70 Boone -42.776 -92.308 70 Bremer -42.469 -91.839 70 Buchanan -42.742 -95.161 70 Buena Vista -42.728 -92.795 70 Butler -42.388 -94.637 70 Calhoun -42.035 -94.859 70 Carroll -41.330 -94.933 70 Cass -41.773 -91.132 70 Cedar -43.083 -93.261 70 Cerro Gordo -42.735 -95.623 70 Cherokee -43.060 -92.317 70 Chickasaw -41.029 -93.784 70 Clarke -43.085 -95.155 70 Clay -42.854 -91.341 70 Clayton -41.897 -90.534 70 Clinton -42.039 -95.384 70 Crawford -41.688 -94.038 70 Dallas -40.748 -92.410 70 Davis -40.738 -93.784 70 Decatur -42.470 -91.367 70 Delaware -40.921 -91.175 70 Des Moines -43.377 -95.152 70 Dickinson -42.473 -90.886 70 Dubuque -43.378 -94.669 70 Emmet -42.858 -91.845 70 Fayette -43.058 -92.790 70 Floyd -42.731 -93.260 70 Franklin -40.743 -95.600 70 Fremont -42.038 -94.391 70 Greene -42.401 -92.791 70 Grundy -41.684 -94.501 70 Guthrie -42.381 -93.709 70 Hamilton -43.086 -93.743 70 Hancock -42.380 -93.242 70 Hardin -41.687 -95.810 70 Harrison -40.989 -91.544 70 Henry -43.352 -92.315 70 Howard -42.782 -94.203 70 Humboldt -42.381 -95.513 70 Ida -41.688 -92.066 70 Iowa -42.165 -90.576 70 Jackson -41.686 -93.053 70 Jasper -41.033 -91.948 70 Jefferson -41.666 -91.590 70 Johnson -42.120 -91.131 70 Jones -41.337 -92.181 70 Keokuk -43.205 -94.197 70 Kossuth -40.645 -91.478 70 Lee -42.079 -91.595 70 Linn -41.217 -91.262 70 Louisa -41.027 -93.327 70 Lucas -43.373 -96.209 70 Lyon -41.331 -94.015 70 Madison -41.334 -92.645 70 Mahaska -41.335 -93.101 70 Marion -42.033 -93.002 70 Marshall -41.034 -95.618 70 Mills -43.359 -92.786 70 Mitchell -42.050 -95.953 70 Monona -41.029 -92.870 70 Monroe -41.031 -95.156 70 Montgomery -41.487 -91.113 70 Muscatine -43.084 -95.626 70 O'Brien -43.377 -95.619 70 Osceola -40.738 -95.150 70 Page -43.091 -94.680 70 Palo Alto -42.737 -96.216 70 Plymouth -42.733 -94.678 70 Pocahontas -41.681 -93.569 70 Polk -41.340 -95.546 70 Pottawattamie -41.694 -92.532 70 Poweshiek -40.735 -94.244 70 Ringgold -42.387 -95.104 70 Sac -41.642 -90.622 70 Scott -41.679 -95.309 70 Shelby -43.083 -96.177 70 Sioux -42.037 -93.466 70 Story -42.081 -92.532 70 Tama -40.734 -94.692 70 Taylor -41.028 -94.242 70 Union -40.755 -91.953 70 Van Buren -41.030 -92.409 70 Wapello -41.333 -93.560 70 Warren -41.337 -91.717 70 Washington -40.738 -93.326 70 Wayne -42.434 -94.179 70 Webster -43.378 -93.725 70 Winnebago -43.291 -91.843 70 Winneshiek -42.388 -96.037 70 Woodbury -43.376 -93.266 70 Worth -42.733 -93.735 70 Wright -37.888 -95.300 70 Allen -38.216 -95.292 70 Anderson -39.531 -95.314 70 Atchison -37.224 -98.684 70 Barber -38.480 -98.755 70 Barton -37.856 -94.851 70 Bourbon -39.823 -95.562 70 Brown -37.774 -96.834 70 Butler -38.302 -96.593 70 Chase -37.155 -96.245 70 Chautauqua -37.169 -94.846 70 Cherokee -39.781 -101.730 70 Cheyenne -37.236 -99.818 70 Clark -39.351 -97.164 70 Clay -39.483 -97.656 70 Cloud -38.237 -95.735 70 Coffey -37.186 -99.282 70 Comanche -37.231 -96.837 70 Cowley -37.508 -94.851 70 Crawford -39.785 -100.460 70 Decatur -38.864 -97.158 70 Dickinson -39.789 -95.148 70 Doniphan -38.884 -95.287 70 Douglas -37.883 -99.304 70 Edwards -37.457 -96.245 70 Elk -38.916 -99.315 70 Ellis -38.696 -98.205 70 Ellsworth -38.047 -100.746 70 Finney -37.692 -99.883 70 Ford -38.567 -95.288 70 Franklin -38.996 -96.749 70 Geary -38.921 -100.491 70 Gove -39.349 -99.880 70 Graham -37.563 -101.309 70 Grant -37.745 -100.424 70 Gray -38.473 -101.804 70 Greeley -37.878 -96.228 70 Greenwood -37.993 -101.793 70 Hamilton -37.198 -98.078 70 Harper -38.044 -97.425 70 Harvey -37.563 -100.873 70 Haskell -38.088 -99.898 70 Hodgeman -39.421 -95.798 70 Jackson -39.229 -95.382 70 Jefferson -39.786 -98.218 70 Jewell -38.884 -94.822 70 Johnson -37.995 -101.313 70 Kearny -37.560 -98.135 70 Kingman -37.559 -99.287 70 Kiowa -37.191 -95.298 70 Labette -38.481 -100.466 70 Lane -39.202 -95.038 70 Leavenworth -39.044 -98.211 70 Lincoln -38.207 -94.841 70 Linn -38.916 -101.147 70 Logan -38.462 -96.150 70 Lyon -38.388 -97.648 70 McPherson -38.362 -97.098 70 Marion -39.779 -96.529 70 Marshall -37.240 -100.359 70 Meade -38.565 -94.834 70 Miami -39.393 -98.207 70 Mitchell -37.189 -95.742 70 Montgomery -38.687 -96.643 70 Morris -37.198 -101.808 70 Morton -39.776 -96.019 70 Nemaha -37.557 -95.301 70 Neosho -38.475 -99.916 70 Ness -39.784 -99.899 70 Norton -38.650 -95.727 70 Osage -39.349 -98.767 70 Osborne -39.132 -97.653 70 Ottawa -38.181 -99.232 70 Pawnee -39.784 -99.347 70 Phillips -39.380 -96.334 70 Pottawatomie -37.648 -98.740 70 Pratt -39.790 -101.074 70 Rawlins -37.961 -98.090 70 Reno -39.828 -97.650 70 Republic -38.347 -98.200 70 Rice -39.293 -96.727 70 Riley -39.351 -99.326 70 Rooks -38.523 -99.309 70 Rush -38.922 -98.766 70 Russell -38.781 -97.648 70 Saline -38.482 -100.906 70 Scott -37.683 -97.462 70 Sedgwick -37.191 -100.852 70 Seward -39.043 -95.758 70 Shawnee -39.351 -100.441 70 Sheridan -39.351 -101.719 70 Sherman -39.785 -98.785 70 Smith -38.036 -98.720 70 Stafford -37.559 -101.784 70 Stanton -37.203 -101.318 70 Stevens -37.230 -97.475 70 Sumner -39.359 -101.055 70 Thomas -38.921 -99.865 70 Trego -38.955 -96.200 70 Wabaunsee -38.909 -101.754 70 Wallace -39.784 -97.086 70 Washington -38.482 -101.347 70 Wichita -37.559 -95.742 70 Wilson -37.887 -95.739 70 Woodson -39.114 -94.766 70 Wyandotte -37.105 -85.282 70 Adair -36.752 -86.190 70 Allen -38.004 -84.988 70 Anderson -37.064 -89.002 70 Ballard -36.960 -85.928 70 Barren -38.140 -83.741 70 Bath -36.736 -83.673 70 Bell -38.974 -84.730 70 Boone -38.203 -84.211 70 Bourbon -38.359 -82.689 70 Boyd -37.619 -84.866 70 Boyle -38.693 -84.083 70 Bracken -37.519 -83.322 70 Breathitt -37.773 -86.431 70 Breckinridge -37.971 -85.695 70 Bullitt -37.209 -86.681 70 Butler -37.148 -87.871 70 Caldwell -36.621 -88.274 70 Calloway -38.945 -84.379 70 Campbell -36.854 -88.977 70 Carlisle -38.670 -85.128 70 Carroll -38.326 -83.051 70 Carter -37.322 -84.928 70 Casey -36.895 -87.492 70 Christian -37.971 -84.146 70 Clark -37.157 -83.709 70 Clay -36.719 -85.135 70 Clinton -37.357 -88.090 70 Crittenden -36.782 -85.389 70 Cumberland -37.732 -87.088 70 Daviess -37.213 -86.246 70 Edmonson -38.120 -83.098 70 Elliott -37.693 -83.965 70 Estill -38.043 -84.459 70 Fayette -38.374 -83.695 70 Fleming -37.556 -82.748 70 Floyd -38.235 -84.879 70 Franklin -36.553 -89.185 70 Fulton -38.757 -84.862 70 Gallatin -37.645 -84.535 70 Garrard -38.639 -84.613 70 Grant -36.723 -88.650 70 Graves -37.460 -86.346 70 Grayson -37.259 -85.554 70 Green -38.542 -82.921 70 Greenup -37.842 -86.779 70 Hancock -37.696 -85.963 70 Hardin -36.856 -83.215 70 Harlan -38.444 -84.332 70 Harrison -37.293 -85.888 70 Hart -37.799 -87.573 70 Henderson -38.456 -85.123 70 Henry -36.678 -88.976 70 Hickman -37.307 -87.538 70 Hopkins -37.417 -84.008 70 Jackson -38.188 -85.662 70 Jefferson -37.872 -84.582 70 Jessamine -37.844 -82.830 70 Johnson -38.933 -84.536 70 Kenton -37.347 -82.954 70 Knott -36.890 -83.852 70 Knox -37.553 -85.698 70 Larue -37.111 -84.120 70 Laurel -38.061 -82.732 70 Lawrence -37.590 -83.718 70 Lee -37.094 -83.384 70 Leslie -37.117 -82.855 70 Letcher -38.531 -83.385 70 Lewis -37.456 -84.659 70 Lincoln -37.212 -88.347 70 Livingston -36.858 -86.879 70 Logan -37.015 -88.079 70 Lyon -37.056 -88.717 70 McCracken -36.739 -84.482 70 McCreary -37.528 -87.261 70 McLean -37.723 -84.277 70 Madison -37.699 -83.065 70 Magoffin -37.554 -85.270 70 Marion -36.881 -88.335 70 Marshall -37.799 -82.520 70 Martin -38.596 -83.826 70 Mason -37.979 -86.218 70 Meade -37.948 -83.604 70 Menifee -37.805 -84.876 70 Mercer -36.989 -85.630 70 Metcalfe -36.710 -85.718 70 Monroe -38.030 -83.906 70 Montgomery -37.923 -83.259 70 Morgan -37.213 -87.146 70 Muhlenberg -37.805 -85.466 70 Nelson -38.341 -84.014 70 Nicholas -37.473 -86.845 70 Ohio -38.397 -85.444 70 Oldham -38.527 -84.830 70 Owen -37.414 -83.689 70 Owsley -38.693 -84.356 70 Pendleton -37.245 -83.225 70 Perry -37.468 -82.394 70 Pike -37.830 -83.826 70 Powell -37.103 -84.576 70 Pulaski -38.508 -84.052 70 Robertson -37.362 -84.316 70 Rockcastle -38.194 -83.420 70 Rowan -36.989 -85.064 70 Russell -38.296 -84.580 70 Scott -38.218 -85.194 70 Shelby -36.740 -86.582 70 Simpson -38.030 -85.323 70 Spencer -37.366 -85.330 70 Taylor -36.840 -87.185 70 Todd -36.806 -87.875 70 Trigg -38.598 -85.339 70 Trimble -37.656 -87.954 70 Union -36.992 -86.424 70 Warren -37.753 -85.174 70 Washington -36.811 -84.831 70 Wayne -37.516 -87.682 70 Webster -36.763 -84.147 70 Whitley -37.742 -83.490 70 Wolfe -38.039 -84.741 70 Woodford -30.291 -92.411 70 Acadia -30.656 -92.828 70 Allen -30.203 -90.909 70 Ascension -29.899 -91.064 70 Assumption -31.071 -92.003 70 Avoyelles -30.653 -93.341 70 Beauregard -32.349 -93.056 70 Bienville -32.681 -93.603 70 Bossier -32.579 -93.880 70 Caddo -30.228 -93.358 70 Calcasieu -32.087 -92.120 70 Caldwell -29.847 -93.200 70 Cameron -31.666 -91.846 70 Catahoula -32.816 -92.994 70 Claiborne -31.441 -91.640 70 Concordia -32.062 -93.736 70 De Soto -30.544 -91.094 70 East Baton Rouge -32.734 -91.235 70 East Carroll -30.850 -91.049 70 East Feliciana -30.733 -92.412 70 Evangeline -32.138 -91.673 70 Franklin -31.593 -92.560 70 Grant -29.794 -91.785 70 Iberia -30.263 -91.349 70 Iberville -32.296 -92.554 70 Jackson -29.718 -90.102 70 Jefferson -30.269 -92.816 70 Jefferson Davis -30.206 -92.064 70 Lafayette -29.494 -90.399 70 Lafourche -31.676 -92.158 70 La Salle -32.604 -92.663 70 Lincoln -30.444 -90.731 70 Livingston -32.371 -91.243 70 Madison -32.818 -91.800 70 Morehouse -31.726 -93.095 70 Natchitoches -30.066 -89.931 70 Orleans -32.478 -92.156 70 Ouachita -29.391 -89.481 70 Plaquemines -30.708 -91.600 70 Pointe Coupee -31.197 -92.536 70 Rapides -32.094 -93.331 70 Red River -32.417 -91.764 70 Richland -31.560 -93.558 70 Sabine -29.895 -89.346 70 St Bernard -29.912 -90.357 70 St Charles -30.820 -90.710 70 St Helena -30.026 -90.796 70 St James -30.118 -90.502 70 St John the Baptist -30.598 -92.004 70 St Landry -30.130 -91.612 70 St Martin -29.635 -91.468 70 St Mary -30.399 -89.964 70 St Tammany -30.634 -90.402 70 Tangipahoa -32.003 -91.330 70 Tensas -29.335 -90.838 70 Terrebonne -32.827 -92.378 70 Union -29.814 -92.309 70 Vermilion -31.108 -93.186 70 Vernon -30.852 -90.042 70 Washington -32.704 -93.331 70 Webster -30.463 -91.313 70 West Baton Rouge -32.786 -91.453 70 West Carroll -30.873 -91.423 70 West Feliciana -31.945 -92.637 70 Winn -44.158 -70.217 70 Androscoggin -46.648 -68.591 70 Aroostook -43.827 -70.316 70 Cumberland -44.977 -70.444 70 Franklin -44.566 -68.368 70 Hancock -44.413 -69.766 70 Kennebec -44.032 -69.035 70 Knox -44.000 -69.526 70 Lincoln -44.486 -70.760 70 Oxford -45.399 -68.643 70 Penobscot -45.843 -69.295 70 Piscataquis -43.908 -69.838 70 Sagadahoc -45.506 -69.954 70 Somerset -44.484 -69.125 70 Waldo -44.969 -67.610 70 Washington -43.407 -70.682 70 York -39.631 -78.690 70 Allegany -38.992 -76.569 70 Anne Arundel -39.442 -76.617 70 Baltimore -38.531 -76.529 70 Calvert -38.871 -75.832 70 Caroline -39.565 -77.024 70 Carroll -39.567 -75.950 70 Cecil -38.482 -77.012 70 Charles -38.419 -76.081 70 Dorchester -39.472 -77.397 70 Frederick -39.530 -79.270 70 Garrett -39.537 -76.300 70 Harford -39.249 -76.934 70 Howard -39.231 -76.095 70 Kent -39.137 -77.205 70 Montgomery -38.830 -76.849 70 Prince George's -39.033 -76.083 70 Queen Anne's -38.215 -76.530 70 St Mary's -38.082 -75.859 70 Somerset -38.751 -76.179 70 Talbot -39.604 -77.814 70 Washington -38.369 -75.629 70 Wicomico -38.226 -75.283 70 Worcester -39.301 -76.611 70 Baltimore -41.720 -70.251 70 Barnstable -42.369 -73.205 70 Berkshire -41.787 -71.096 70 Bristol -41.374 -70.703 70 Dukes -42.626 -70.872 70 Essex -42.583 -72.591 70 Franklin -42.122 -72.670 70 Hampden -42.341 -72.662 70 Hampshire -42.484 -71.394 70 Middlesex -41.253 -70.127 70 Nantucket -42.172 -71.184 70 Norfolk -41.996 -70.730 70 Plymouth -42.357 -70.978 70 Suffolk -42.354 -71.916 70 Worcester -44.712 -83.273 70 Alcona -47.160 -86.484 70 Alger -42.565 -86.250 70 Allegan -45.037 -83.198 70 Alpena -45.006 -85.177 70 Antrim -44.045 -83.752 70 Arenac -46.715 -88.342 70 Baraga -42.598 -85.311 70 Barry -43.721 -83.943 70 Bay -44.630 -86.248 70 Benzie -41.943 -86.592 70 Berrien -41.915 -85.054 70 Branch -42.253 -85.003 70 Calhoun -41.914 -85.993 70 Cass -45.466 -85.458 70 Charlevoix -45.476 -84.496 70 Cheboygan -46.318 -84.519 70 Chippewa -43.991 -84.838 70 Clare -42.941 -84.612 70 Clinton -44.680 -84.611 70 Crawford -45.775 -86.873 70 Delta -45.997 -87.872 70 Dickinson -42.588 -84.846 70 Eaton -45.583 -84.981 70 Emmet -43.021 -83.707 70 Genesee -43.989 -84.388 70 Gladwin -46.484 -89.791 70 Gogebic -44.733 -85.552 70 Grand Traverse -43.292 -84.605 70 Gratiot -41.888 -84.594 70 Hillsdale -46.984 -88.647 70 Houghton -43.959 -82.836 70 Huron -42.604 -84.374 70 Ingham -42.944 -85.073 70 Ionia -44.276 -83.337 70 Iosco -46.205 -88.514 70 Iron -43.648 -84.838 70 Isabella -42.248 -84.425 70 Jackson -42.245 -85.530 70 Kalamazoo -44.692 -85.084 70 Kalkaska -43.033 -85.547 70 Kent -47.477 -88.155 70 Keweenaw -43.988 -85.812 70 Lake -43.091 -83.224 70 Lapeer -45.133 -86.030 70 Leelanau -41.892 -84.069 70 Lenawee -42.602 -83.912 70 Livingston -46.747 -85.590 70 Luce -46.009 -85.008 70 Mackinac -42.668 -82.910 70 Macomb -44.301 -86.312 70 Manistee -46.664 -87.604 70 Marquette -44.022 -86.500 70 Mason -43.643 -85.323 70 Mecosta -45.522 -87.525 70 Menominee -43.643 -84.386 70 Midland -44.339 -85.096 70 Missaukee -41.915 -83.500 70 Monroe -43.313 -85.149 70 Montcalm -45.027 -84.129 70 Montmorency -43.287 -86.446 70 Muskegon -43.551 -85.797 70 Newaygo -42.660 -83.384 70 Oakland -43.657 -86.531 70 Oceana -44.334 -84.131 70 Ogemaw -46.979 -89.271 70 Ontonagon -43.985 -85.330 70 Osceola -44.683 -84.125 70 Oscoda -45.017 -84.607 70 Otsego -42.922 -86.233 70 Ottawa -45.322 -83.459 70 Presque Isle -44.331 -84.611 70 Roscommon -43.335 -84.052 70 Saginaw -42.934 -82.668 70 St Clair -41.915 -85.530 70 St Joseph -43.457 -82.640 70 Sanilac -46.024 -86.187 70 Schoolcraft -42.950 -84.144 70 Shiawassee -43.488 -83.437 70 Tuscola -42.271 -86.309 70 Van Buren -42.253 -83.842 70 Washtenaw -42.285 -83.260 70 Wayne -44.338 -85.580 70 Wexford -46.607 -93.414 70 Aitkin -45.274 -93.241 70 Anoka -46.932 -95.668 70 Becker -48.018 -94.923 70 Beltrami -45.703 -94.000 70 Benton -45.427 -96.413 70 Big Stone -44.033 -94.064 70 Blue Earth -44.235 -94.721 70 Brown -46.590 -92.680 70 Carlton -44.821 -93.798 70 Carver -46.946 -94.322 70 Cass -45.029 -95.564 70 Chippewa -45.502 -92.909 70 Chisago -46.899 -96.495 70 Clay -47.573 -95.380 70 Clearwater -47.726 -90.442 70 Cook -44.009 -95.183 70 Cottonwood -46.487 -94.072 70 Crow Wing -44.685 -93.065 70 Dakota -44.027 -92.862 70 Dodge -45.936 -95.454 70 Douglas -43.677 -93.948 70 Faribault -43.675 -92.089 70 Fillmore -43.671 -93.350 70 Freeborn -44.415 -92.722 70 Goodhue -45.932 -96.011 70 Grant -45.003 -93.475 70 Hennepin -43.674 -91.491 70 Houston -47.101 -94.914 70 Hubbard -45.565 -93.293 70 Isanti -47.508 -93.626 70 Itasca -43.675 -95.157 70 Jackson -45.948 -93.298 70 Kanabec -45.152 -95.008 70 Kandiyohi -48.776 -96.780 70 Kittson -48.259 -93.769 70 Koochiching -45.001 -96.175 70 Lac qui Parle -47.526 -91.388 70 Lake -48.768 -94.904 70 Lake of the Woods -44.374 -93.732 70 Le Sueur -44.408 -96.272 70 Lincoln -44.414 -95.840 70 Lyon -44.826 -94.271 70 McLeod -47.326 -95.810 70 Mahnomen -48.354 -96.377 70 Marshall -43.677 -94.557 70 Martin -45.123 -94.527 70 Meeker -45.930 -93.633 70 Mille Lacs -46.012 -94.268 70 Morrison -43.672 -92.751 70 Mower -44.020 -95.761 70 Murray -44.342 -94.245 70 Nicollet -43.673 -95.757 70 Nobles -47.331 -96.463 70 Norman -44.002 -92.399 70 Olmsted -46.408 -95.714 70 Otter Tail -48.065 -96.036 70 Pennington -46.140 -92.736 70 Pine -44.025 -96.254 70 Pipestone -47.775 -96.400 70 Polk -45.593 -95.447 70 Pope -45.015 -93.100 70 Ramsey -47.877 -96.096 70 Red Lake -44.404 -95.254 70 Redwood -44.724 -94.955 70 Renville -44.357 -93.297 70 Rice -43.673 -96.248 70 Rock -48.770 -95.799 70 Roseau -47.578 -92.462 70 St Louis -44.655 -93.535 70 Scott -45.440 -93.768 70 Sherburne -44.579 -94.229 70 Sibley -45.555 -94.610 70 Stearns -44.023 -93.224 70 Steele -45.585 -96.001 70 Stevens -45.287 -95.682 70 Swift -46.071 -94.899 70 Todd -45.772 -96.470 70 Traverse -44.282 -92.239 70 Wabasha -46.577 -94.959 70 Wadena -44.019 -93.590 70 Waseca -45.038 -92.889 70 Washington -43.979 -94.615 70 Watonwan -46.355 -96.471 70 Wilkin -43.985 -91.775 70 Winona -45.175 -93.968 70 Wright -44.719 -95.863 70 Yellow Medicine -31.480 -91.351 70 Adams -34.877 -88.576 70 Alcorn -31.173 -90.801 70 Amite -33.089 -89.580 70 Attala -34.817 -89.187 70 Benton -33.795 -90.882 70 Bolivar -33.936 -89.337 70 Calhoun -33.450 -89.920 70 Carroll -33.922 -88.948 70 Chickasaw -33.345 -89.252 70 Choctaw -31.973 -90.914 70 Claiborne -32.040 -88.691 70 Clarke -33.652 -88.774 70 Clay -34.225 -90.597 70 Coahoma -31.865 -90.445 70 Copiah -31.632 -89.552 70 Covington -34.875 -89.992 70 DeSoto -31.187 -89.259 70 Forrest -31.478 -90.898 70 Franklin -30.866 -88.643 70 George -31.217 -88.640 70 Greene -33.771 -89.801 70 Grenada -30.389 -89.472 70 Hancock -30.419 -89.090 70 Harrison -32.263 -90.444 70 Hinds -33.121 -90.088 70 Holmes -33.132 -90.524 70 Humphreys -32.738 -90.988 70 Issaquena -34.278 -88.359 70 Itawamba -30.463 -88.622 70 Jackson -32.019 -89.120 70 Jasper -31.730 -91.035 70 Jefferson -31.564 -89.823 70 Jefferson Davis -31.624 -89.168 70 Jones -32.756 -88.645 70 Kemper -34.359 -89.485 70 Lafayette -31.210 -89.505 70 Lamar -32.404 -88.661 70 Lauderdale -31.550 -90.107 70 Lawrence -32.753 -89.523 70 Leake -34.289 -88.681 70 Lee -33.548 -90.298 70 Leflore -31.536 -90.452 70 Lincoln -33.471 -88.444 70 Lowndes -32.634 -90.034 70 Madison -31.231 -89.822 70 Marion -34.770 -89.509 70 Marshall -33.890 -88.485 70 Monroe -33.498 -89.609 70 Montgomery -32.752 -89.119 70 Neshoba -32.405 -89.118 70 Newton -33.111 -88.570 70 Noxubee -33.426 -88.880 70 Oktibbeha -34.363 -89.947 70 Panola -30.770 -89.592 70 Pearl River -31.172 -88.987 70 Perry -31.176 -90.400 70 Pike -34.228 -89.037 70 Pontotoc -34.613 -88.519 70 Prentiss -34.255 -90.287 70 Quitman -32.263 -89.946 70 Rankin -32.405 -89.545 70 Scott -32.879 -90.812 70 Sharkey -31.915 -89.921 70 Simpson -32.016 -89.501 70 Smith -30.789 -89.123 70 Stone -33.607 -90.595 70 Sunflower -33.946 -90.172 70 Tallahatchie -34.653 -89.940 70 Tate -34.770 -88.908 70 Tippah -34.741 -88.243 70 Tishomingo -34.656 -90.376 70 Tunica -34.490 -89.004 70 Union -31.145 -90.103 70 Walthall -32.357 -90.852 70 Warren -33.286 -90.948 70 Washington -31.644 -88.702 70 Wayne -33.613 -89.282 70 Webster -31.164 -91.319 70 Wilkinson -33.093 -89.035 70 Winston -34.032 -89.715 70 Yalobusha -32.781 -90.405 70 Yazoo -40.188 -92.599 70 Adair -39.988 -94.801 70 Andrew -40.425 -95.434 70 Atchison -39.214 -91.843 70 Audrain -36.713 -93.831 70 Barry -37.501 -94.344 70 Barton -38.258 -94.339 70 Bates -38.299 -93.288 70 Benton -37.321 -90.028 70 Bollinger -38.987 -92.308 70 Boone -39.666 -94.806 70 Buchanan -36.715 -90.403 70 Butler -39.659 -93.979 70 Caldwell -38.836 -91.925 70 Callaway -38.029 -92.772 70 Camden -37.383 -89.684 70 Cape Girardeau -39.428 -93.501 70 Carroll -36.942 -90.966 70 Carter -38.647 -94.354 70 Cass -37.722 -93.865 70 Cedar -39.519 -92.960 70 Chariton -36.970 -93.187 70 Christian -40.411 -91.742 70 Clark -39.313 -94.423 70 Clay -39.604 -94.402 70 Clinton -38.507 -92.282 70 Cole -38.846 -92.813 70 Cooper -37.977 -91.303 70 Crawford -37.430 -93.853 70 Dade -37.672 -93.020 70 Dallas -39.961 -93.986 70 Daviess -39.899 -94.405 70 DeKalb -37.609 -91.498 70 Dent -36.928 -92.497 70 Douglas -36.271 -90.090 70 Dunklin -38.408 -91.076 70 Franklin -38.442 -91.506 70 Gasconade -40.218 -94.411 70 Gentry -37.257 -93.337 70 Greene -40.112 -93.567 70 Grundy -40.354 -93.982 70 Harrison -38.387 -93.791 70 Henry -37.942 -93.319 70 Hickory -40.095 -95.213 70 Holt -39.144 -92.695 70 Howard -36.774 -91.887 70 Howell -37.546 -90.757 70 Iron -39.010 -94.344 70 Jackson -37.202 -94.336 70 Jasper -38.256 -90.537 70 Jefferson -38.749 -93.809 70 Johnson -40.125 -92.150 70 Knox -37.660 -92.595 70 Laclede -39.059 -93.784 70 Lafayette -37.108 -93.830 70 Lawrence -40.094 -91.726 70 Lewis -39.061 -90.962 70 Lincoln -39.868 -93.111 70 Linn -39.783 -93.547 70 Livingston -36.622 -94.354 70 McDonald -39.830 -92.560 70 Macon -37.481 -90.343 70 Madison -38.175 -91.919 70 Maries -39.813 -91.624 70 Marion -40.424 -93.566 70 Mercer -38.217 -92.432 70 Miller -36.827 -89.295 70 Mississippi -38.633 -92.584 70 Moniteau -39.495 -91.998 70 Monroe -38.942 -91.473 70 Montgomery -38.426 -92.886 70 Morgan -36.595 -89.656 70 New Madrid -36.907 -94.332 70 Newton -40.360 -94.883 70 Nodaway -36.688 -91.402 70 Oregon -38.465 -91.859 70 Osage -36.651 -92.444 70 Ozark -36.215 -89.783 70 Pemiscot -37.709 -89.829 70 Perry -38.726 -93.284 70 Pettis -37.878 -91.793 70 Phelps -39.341 -91.171 70 Pike -39.378 -94.771 70 Platte -37.617 -93.401 70 Polk -37.825 -92.209 70 Pulaski -40.479 -93.017 70 Putnam -39.525 -91.528 70 Ralls -39.433 -92.497 70 Randolph -39.350 -93.991 70 Ray -37.358 -90.971 70 Reynolds -36.659 -90.866 70 Ripley -38.779 -90.675 70 St Charles -38.040 -93.774 70 St Clair -37.894 -90.185 70 Ste. Genevieve -37.810 -90.465 70 St Francois -38.639 -90.443 70 St Louis -39.136 -93.204 70 Saline -40.471 -92.518 70 Schuyler -40.454 -92.149 70 Scotland -37.054 -89.572 70 Scott -37.160 -91.403 70 Shannon -39.791 -92.069 70 Shelby -36.856 -89.946 70 Stoddard -36.740 -93.465 70 Stone -40.212 -93.112 70 Sullivan -36.655 -93.036 70 Taney -37.317 -91.964 70 Texas -37.850 -94.342 70 Vernon -38.768 -91.164 70 Warren -37.969 -90.877 70 Washington -37.113 -90.461 70 Wayne -37.284 -92.875 70 Webster -40.481 -94.420 70 Worth -37.266 -92.462 70 Wright -38.636 -90.244 40 St Louis city -45.116 -112.896 70 Beaverhead -45.429 -107.490 70 Big Horn -48.436 -108.962 70 Blaine -46.332 -111.495 70 Broadwater -45.232 -109.022 70 Carbon -45.502 -104.538 70 Carter -47.311 -111.351 70 Cascade -47.876 -110.439 70 Chouteau -46.265 -105.580 70 Custer -48.786 -105.547 70 Daniels -47.273 -104.901 70 Dawson -46.066 -113.084 70 Deer Lodge -46.354 -104.411 70 Fallon -47.262 -109.222 70 Fergus -48.291 -114.019 70 Flathead -45.558 -111.174 70 Gallatin -47.282 -106.989 70 Garfield -48.700 -113.019 70 Glacier -46.383 -109.167 70 Golden Valley -46.420 -113.447 70 Granite -48.628 -110.106 70 Hill -46.177 -112.105 70 Jefferson -47.040 -110.265 70 Judith Basin -47.650 -114.089 70 Lake -47.114 -112.377 70 Lewis and Clark -48.549 -111.025 70 Liberty -48.536 -115.409 70 Lincoln -47.649 -105.802 70 McCone -45.296 -111.922 70 Madison -46.592 -110.864 70 Meagher -47.145 -114.981 70 Mineral -47.041 -113.925 70 Missoula -46.486 -108.400 70 Musselshell -45.498 -110.521 70 Park -47.107 -108.262 70 Petroleum -48.262 -107.923 70 Phillips -48.235 -112.219 70 Pondera -45.382 -105.636 70 Powder River -46.850 -112.941 70 Powell -46.853 -105.373 70 Prairie -46.085 -114.123 70 Ravalli -47.785 -104.561 70 Richland -48.295 -105.029 70 Roosevelt -46.226 -106.724 70 Rosebud -47.662 -115.131 70 Sanders -48.727 -104.500 70 Sheridan -45.896 -112.658 70 Silver Bow -45.674 -109.389 70 Stillwater -45.814 -109.943 70 Sweet Grass -47.848 -112.233 70 Teton -48.651 -111.689 70 Toole -46.203 -107.266 70 Treasure -48.356 -106.663 70 Valley -46.471 -109.844 70 Wheatland -46.962 -104.247 70 Wibaux -45.935 -108.272 70 Yellowstone -45.004 -110.801 70 Yellowstone National Park -40.523 -98.500 70 Adams -42.178 -98.072 70 Antelope -41.572 -101.696 70 Arthur -41.543 -103.715 70 Banner -41.926 -99.983 70 Blaine -41.705 -98.063 70 Boone -42.213 -103.082 70 Box Butte -42.896 -98.772 70 Boyd -42.445 -99.934 70 Brown -40.855 -99.074 70 Buffalo -41.854 -96.321 70 Burt -41.222 -97.133 70 Butler -40.913 -96.139 70 Cass -42.598 -97.249 70 Cedar -40.530 -101.694 70 Chase -42.543 -101.119 70 Cherry -41.219 -102.987 70 Cheyenne -40.524 -98.051 70 Clay -41.576 -97.088 70 Colfax -41.916 -96.788 70 Cuming -41.394 -99.727 70 Custer -42.387 -96.563 70 Dakota -42.709 -103.136 70 Dawes -40.866 -99.815 70 Dawson -41.113 -102.332 70 Deuel -42.499 -96.868 70 Dixon -41.576 -96.645 70 Dodge -41.299 -96.147 70 Douglas -40.182 -101.690 70 Dundy -40.525 -97.596 70 Fillmore -40.183 -98.947 70 Franklin -40.527 -100.388 70 Frontier -40.173 -99.915 70 Furnas -40.265 -96.693 70 Gage -41.622 -102.344 70 Garden -41.894 -98.982 70 Garfield -40.504 -99.823 70 Gosper -41.917 -101.743 70 Grant -41.563 -98.515 70 Greeley -40.866 -98.502 70 Hall -40.877 -98.021 70 Hamilton -40.174 -99.399 70 Harlan -40.527 -101.060 70 Hayes -40.176 -101.040 70 Hitchcock -42.460 -98.784 70 Holt -41.888 -101.141 70 Hooker -41.219 -98.518 70 Howard -40.168 -97.146 70 Jefferson -40.396 -96.266 70 Johnson -40.506 -98.946 70 Kearney -41.197 -101.662 70 Keith -42.878 -99.719 70 Keya Paha -41.199 -103.711 70 Kimball -42.634 -97.881 70 Knox -40.784 -96.689 70 Lancaster -41.052 -100.745 70 Lincoln -41.556 -100.476 70 Logan -41.933 -99.447 70 Loup -41.570 -101.060 70 McPherson -41.922 -97.600 70 Madison -41.169 -98.030 70 Merrick -41.694 -103.013 70 Morrill -41.394 -97.994 70 Nance -40.387 -95.847 70 Nemaha -40.177 -98.046 70 Nuckolls -40.652 -96.136 70 Otoe -40.130 -96.240 70 Pawnee -40.842 -101.656 70 Perkins -40.509 -99.410 70 Phelps -42.271 -97.611 70 Pierce -41.568 -97.525 70 Platte -41.188 -97.571 70 Polk -40.176 -100.479 70 Red Willow -40.124 -95.718 70 Richardson -42.418 -99.454 70 Rock -40.531 -97.142 70 Saline -41.114 -96.110 70 Sarpy -41.226 -96.634 70 Saunders -41.850 -103.709 70 Scotts Bluff -40.872 -97.140 70 Seward -42.497 -102.434 70 Sheridan -41.222 -98.973 70 Sherman -42.481 -103.771 70 Sioux -41.922 -97.190 70 Stanton -40.176 -97.594 70 Thayer -41.918 -100.582 70 Thomas -42.157 -96.550 70 Thurston -41.570 -98.977 70 Valley -41.527 -96.223 70 Washington -42.214 -97.125 70 Wayne -40.178 -98.498 70 Webster -41.918 -98.525 70 Wheeler -40.872 -97.597 70 York -39.602 -118.341 70 Churchill -36.202 -115.023 70 Clark -38.916 -119.614 70 Douglas -41.131 -115.354 70 Elko -37.786 -117.632 70 Esmeralda -39.979 -116.270 70 Eureka -41.411 -118.117 70 Humboldt -39.946 -117.026 70 Lander -37.642 -114.875 70 Lincoln -39.013 -119.192 70 Lyon -38.542 -118.428 70 Mineral -38.050 -116.451 70 Nye -40.446 -118.403 70 Pershing -39.447 -119.535 70 Storey -40.634 -119.685 70 Washoe -39.435 -114.896 70 White Pine -39.148 -119.743 70 Carson City -43.519 -71.425 70 Belknap -43.870 -71.211 70 Carroll -42.921 -72.253 70 Cheshire -44.687 -71.302 70 Coos -43.933 -71.843 70 Grafton -42.915 -71.716 70 Hillsborough -43.290 -71.677 70 Merrimack -42.984 -71.089 70 Rockingham -43.296 -71.027 70 Strafford -43.361 -72.225 70 Sullivan -39.465 -74.637 70 Atlantic -40.959 -74.074 70 Bergen -39.876 -74.669 70 Burlington -39.801 -74.960 70 Camden -39.077 -74.859 70 Cape May -39.330 -75.133 70 Cumberland -40.787 -74.246 70 Essex -39.715 -75.140 70 Gloucester -40.732 -74.075 70 Hudson -40.570 -74.917 70 Hunterdon -40.282 -74.699 70 Mercer -40.439 -74.409 70 Middlesex -40.288 -74.154 70 Monmouth -40.865 -74.547 70 Morris -39.872 -74.250 70 Ocean -41.032 -74.300 70 Passaic -39.580 -75.362 70 Salem -40.564 -74.615 70 Somerset -41.142 -74.691 70 Sussex -40.660 -74.308 70 Union -40.855 -74.994 70 Warren -35.053 -106.670 70 Bernalillo -33.924 -108.417 70 Catron -33.363 -104.469 70 Chaves -34.920 -107.989 70 Cibola -36.606 -104.638 70 Colfax -34.572 -103.346 70 Curry -34.336 -104.416 70 DeBaca -32.345 -106.832 70 Dona Ana -32.466 -104.298 70 Eddy -32.729 -108.379 70 Grant -34.862 -104.785 70 Guadalupe -35.858 -103.817 70 Harding -31.916 -108.712 70 Hidalgo -32.796 -103.415 70 Lea -33.740 -105.456 70 Lincoln -35.865 -106.309 70 Los Alamos -32.181 -107.749 70 Luna -35.583 -108.260 70 McKinley -36.018 -104.940 70 Mora -32.623 -105.726 70 Otero -35.106 -103.552 70 Quay -36.509 -106.697 70 Rio Arriba -34.019 -103.480 70 Roosevelt -35.688 -106.848 70 Sandoval -36.513 -108.323 70 San Juan -35.470 -104.827 70 San Miguel -35.508 -105.978 70 Santa Fe -33.136 -107.186 70 Sierra -34.016 -106.934 70 Socorro -36.570 -105.630 70 Taos -34.640 -105.854 70 Torrance -36.476 -103.471 70 Union -34.717 -106.805 70 Valencia -42.603 -73.972 70 Albany -42.255 -78.022 70 Allegany -40.849 -73.853 70 Bronx -42.164 -75.820 70 Broome -42.241 -78.679 70 Cattaraugus -42.945 -76.561 70 Cayuga -42.302 -79.412 70 Chautauqua -42.141 -76.760 70 Chemung -42.495 -75.615 70 Chenango -44.740 -73.679 70 Clinton -42.251 -73.630 70 Columbia -42.599 -76.073 70 Cortland -42.201 -74.965 70 Delaware -41.764 -73.747 70 Dutchess -42.755 -78.785 70 Erie -44.113 -73.768 70 Essex -44.600 -74.309 70 Franklin -43.115 -74.424 70 Fulton -43.001 -78.195 70 Genesee -42.292 -74.129 70 Greene -43.655 -74.501 70 Hamilton -43.412 -74.959 70 Herkimer -43.994 -76.054 70 Jefferson -40.636 -73.951 70 Kings -43.786 -75.449 70 Lewis -42.727 -77.770 70 Livingston -42.912 -75.668 70 Madison -43.295 -77.689 70 Monroe -42.906 -74.437 70 Montgomery -40.733 -73.588 70 Nassau -40.774 -73.972 70 New York -43.324 -78.794 70 Niagara -43.241 -75.438 70 Oneida -43.007 -76.196 70 Onondaga -42.853 -77.295 70 Ontario -41.402 -74.306 70 Orange -43.368 -78.229 70 Orleans -43.466 -76.204 70 Oswego -42.634 -75.035 70 Otsego -41.431 -73.746 70 Putnam -40.656 -73.840 70 Queens -42.710 -73.514 70 Rensselaer -40.562 -74.140 70 Richmond -41.150 -74.027 70 Rockland -44.497 -75.073 70 St Lawrence -43.106 -73.868 70 Saratoga -42.815 -74.066 70 Schenectady -42.591 -74.439 70 Schoharie -42.390 -76.877 70 Schuyler -42.786 -76.829 70 Seneca -42.264 -77.385 70 Steuben -40.941 -72.679 70 Suffolk -41.715 -74.765 70 Sullivan -42.167 -76.303 70 Tioga -42.451 -76.475 70 Tompkins -41.889 -74.258 70 Ulster -43.563 -73.844 70 Warren -43.320 -73.431 70 Washington -43.283 -77.054 70 Wayne -41.154 -73.754 70 Westchester -42.699 -78.228 70 Wyoming -42.639 -77.105 70 Yates -36.044 -79.398 70 Alamance -35.922 -81.177 70 Alexander -36.494 -81.130 70 Alleghany -34.975 -80.102 70 Anson -36.433 -81.502 70 Ashe -36.079 -81.923 70 Avery -35.483 -76.845 70 Beaufort -36.059 -76.963 70 Bertie -34.619 -78.556 70 Bladen -34.039 -78.221 70 Brunswick -35.609 -82.530 70 Buncombe -35.747 -81.706 70 Burke -35.388 -80.551 70 Cabarrus -35.954 -81.547 70 Caldwell -36.337 -76.163 70 Camden -34.876 -76.504 70 Carteret -36.396 -79.335 70 Caswell -35.663 -81.214 70 Catawba -35.702 -79.258 70 Chatham -35.137 -84.064 70 Cherokee -36.131 -76.602 70 Chowan -35.058 -83.756 70 Clay -35.336 -81.556 70 Cleveland -34.260 -78.665 70 Columbus -35.120 -77.082 70 Craven -35.046 -78.829 70 Cumberland -36.364 -75.944 70 Currituck -35.690 -75.727 70 Dare -35.794 -80.212 70 Davidson -35.930 -80.543 70 Davie -34.936 -77.935 70 Duplin -36.038 -78.875 70 Durham -35.914 -77.596 70 Edgecombe -36.130 -80.257 70 Forsyth -36.079 -78.284 70 Franklin -35.296 -81.181 70 Gaston -36.442 -76.703 70 Gates -35.349 -83.833 70 Graham -36.305 -78.656 70 Granville -35.486 -77.684 70 Greene -36.079 -79.789 70 Guilford -36.256 -77.656 70 Halifax -35.371 -78.864 70 Harnett -35.553 -82.978 70 Haywood -35.337 -82.481 70 Henderson -36.358 -76.984 70 Hertford -35.021 -79.234 70 Hoke -35.406 -76.153 70 Hyde -35.809 -80.873 70 Iredell -35.288 -83.144 70 Jackson -35.519 -78.365 70 Johnston -35.012 -77.366 70 Jones -35.476 -79.172 70 Lee -35.242 -77.643 70 Lenoir -35.484 -81.223 70 Lincoln -35.682 -82.048 70 McDowell -35.150 -83.421 70 Macon -35.858 -82.712 70 Madison -35.843 -77.103 70 Martin -35.248 -80.833 70 Mecklenburg -36.014 -82.164 70 Mitchell -35.330 -79.903 70 Montgomery -35.309 -79.485 70 Moore -35.968 -77.988 70 Nash -34.182 -77.865 70 New Hanover -36.419 -77.398 70 Northampton -34.715 -77.413 70 Onslow -36.059 -79.118 70 Orange -35.150 -76.668 70 Pamlico -36.265 -76.262 70 Pasquotank -34.510 -77.887 70 Pender -36.181 -76.414 70 Perquimans -36.392 -78.977 70 Person -35.591 -77.377 70 Pitt -35.277 -82.166 70 Polk -35.711 -79.806 70 Randolph -35.003 -79.747 70 Richmond -34.640 -79.107 70 Robeson -36.395 -79.777 70 Rockingham -35.636 -80.523 70 Rowan -35.399 -81.920 70 Rutherford -34.991 -78.369 70 Sampson -34.841 -79.480 70 Scotland -35.312 -80.253 70 Stanly -36.409 -80.230 70 Stokes -36.415 -80.687 70 Surry -35.492 -83.492 70 Swain -35.198 -82.797 70 Transylvania -35.870 -76.165 70 Tyrrell -34.988 -80.533 70 Union -36.365 -78.405 70 Vance -35.790 -78.650 70 Wake -36.398 -78.097 70 Warren -35.837 -76.565 70 Washington -36.234 -81.697 70 Watauga -35.362 -78.005 70 Wayne -36.203 -81.166 70 Wilkes -35.705 -77.919 70 Wilson -36.158 -80.665 70 Yadkin -35.903 -82.310 70 Yancey -46.093 -102.534 70 Adams -46.932 -98.070 70 Barnes -48.072 -99.362 70 Benson -47.035 -103.367 70 Billings -48.792 -100.841 70 Bottineau -46.113 -103.519 70 Bowman -48.790 -102.519 70 Burke -46.977 -100.472 70 Burleigh -46.927 -97.252 70 Cass -48.768 -98.463 70 Cavalier -46.109 -98.494 70 Dickey -48.809 -103.487 70 Divide -47.358 -102.615 70 Dunn -47.723 -98.900 70 Eddy -46.285 -100.237 70 Emmons -47.460 -98.885 70 Foster -46.939 -103.844 70 Golden Valley -47.919 -97.454 70 Grand Forks -46.358 -101.639 70 Grant -47.464 -98.232 70 Griggs -46.431 -102.456 70 Hettinger -46.977 -99.779 70 Kidder -46.466 -98.530 70 LaMoure -46.450 -99.477 70 Logan -48.232 -100.637 70 McHenry -46.119 -99.439 70 McIntosh -47.733 -103.389 70 McKenzie -47.605 -101.315 70 McLean -47.302 -101.817 70 Mercer -46.720 -101.278 70 Morton -48.202 -102.366 70 Mountrail -47.922 -98.186 70 Nelson -47.113 -101.345 70 Oliver -48.768 -97.546 70 Pembina -48.249 -99.979 70 Pierce -48.252 -98.716 70 Ramsey -46.459 -97.664 70 Ransom -48.713 -101.658 70 Renville -46.265 -96.951 70 Richland -48.772 -99.839 70 Rolette -46.107 -97.629 70 Sargent -47.581 -100.341 70 Sheridan -46.108 -101.049 70 Sioux -46.453 -103.458 70 Slope -46.813 -102.664 70 Stark -47.458 -97.719 70 Steele -46.979 -98.955 70 Stutsman -48.688 -99.247 70 Towner -47.447 -97.166 70 Traill -48.373 -97.723 70 Walsh -48.224 -101.545 70 Ward -47.581 -99.671 70 Wells -48.347 -103.477 70 Williams -38.843 -83.478 70 Adams -40.770 -84.106 70 Allen -40.843 -82.272 70 Ashland -41.890 -80.756 70 Ashtabula -39.334 -82.046 70 Athens -40.561 -84.224 70 Auglaize -40.018 -80.987 70 Belmont -38.933 -83.867 70 Brown -39.438 -84.577 70 Butler -40.580 -81.091 70 Carroll -40.141 -83.768 70 Champaign -39.917 -83.784 70 Clark -39.052 -84.150 70 Clermont -39.411 -83.808 70 Clinton -40.769 -80.777 70 Columbiana -40.302 -81.915 70 Coshocton -40.849 -82.924 70 Crawford -41.536 -81.660 70 Cuyahoga -40.134 -84.622 70 Darke -41.321 -84.488 70 Defiance -40.278 -83.007 70 Delaware -41.513 -82.614 70 Erie -39.746 -82.628 70 Fairfield -39.565 -83.451 70 Fayette -39.970 -83.010 70 Franklin -41.597 -84.125 70 Fulton -38.825 -82.320 70 Gallia -41.499 -81.173 70 Geauga -39.695 -83.886 70 Greene -40.049 -81.496 70 Guernsey -39.196 -84.542 70 Hamilton -40.998 -83.665 70 Hancock -40.661 -83.664 70 Hardin -40.293 -81.093 70 Harrison -41.333 -84.069 70 Henry -39.184 -83.604 70 Highland -39.497 -82.476 70 Hocking -40.561 -81.929 70 Holmes -41.150 -82.602 70 Huron -39.021 -82.622 70 Jackson -40.383 -80.762 70 Jefferson -40.399 -82.422 70 Knox -41.816 -81.241 70 Lake -38.594 -82.536 70 Lawrence -40.091 -82.482 70 Licking -40.387 -83.770 70 Logan -41.466 -82.154 70 Lorain -41.678 -83.497 70 Lucas -39.897 -83.401 70 Madison -41.017 -80.773 70 Mahoning -40.586 -83.161 70 Marion -41.118 -81.901 70 Medina -39.076 -82.019 70 Meigs -40.542 -84.629 70 Mercer -40.054 -84.228 70 Miami -39.729 -81.080 70 Monroe -39.752 -84.290 70 Montgomery -39.613 -81.851 70 Morgan -40.526 -82.798 70 Morrow -39.966 -81.947 70 Muskingum -39.767 -81.453 70 Noble -41.593 -83.057 70 Ottawa -41.118 -84.577 70 Paulding -39.735 -82.236 70 Perry -39.640 -83.032 70 Pickaway -39.084 -83.072 70 Pike -41.171 -81.198 70 Portage -39.742 -84.652 70 Preble -41.022 -84.128 70 Putnam -40.775 -82.536 70 Richland -39.329 -83.060 70 Ross -41.357 -83.145 70 Sandusky -38.806 -82.987 70 Scioto -41.127 -83.126 70 Seneca -40.329 -84.205 70 Shelby -40.814 -81.366 70 Stark -41.130 -81.532 70 Summit -41.315 -80.755 70 Trumbull -40.446 -81.474 70 Tuscarawas -40.305 -83.375 70 Union -40.856 -84.586 70 Van Wert -39.250 -82.486 70 Vinton -39.430 -84.167 70 Warren -39.460 -81.494 70 Washington -40.830 -81.890 70 Wayne -41.565 -84.585 70 Williams -41.361 -83.622 70 Wood -40.848 -83.303 70 Wyandot -35.878 -94.658 70 Adair -36.731 -98.323 70 Alfalfa -34.379 -96.046 70 Atoka -36.753 -100.481 70 Beaver -35.265 -99.689 70 Beckham -35.877 -98.428 70 Blaine -33.970 -96.255 70 Bryan -35.182 -98.381 70 Caddo -35.539 -97.981 70 Canadian -34.249 -97.287 70 Carter -35.906 -94.999 70 Cherokee -34.027 -95.553 70 Choctaw -36.744 -102.516 70 Cimarron -35.201 -97.328 70 Cleveland -34.596 -96.301 70 Coal -34.656 -98.464 70 Comanche -34.285 -98.374 70 Cotton -36.760 -95.218 70 Craig -35.902 -96.372 70 Creek -35.636 -99.005 70 Custer -36.415 -94.802 70 Delaware -35.993 -98.996 70 Dewey -36.215 -99.750 70 Ellis -36.379 -97.785 70 Garfield -34.709 -97.311 70 Garvin -35.020 -97.887 70 Grady -36.799 -97.789 70 Grant -34.931 -99.558 70 Greer -34.742 -99.844 70 Harmon -36.783 -99.652 70 Harper -35.225 -95.111 70 Haskell -35.036 -96.256 70 Hughes -34.587 -99.410 70 Jackson -34.099 -97.840 70 Jefferson -34.315 -96.655 70 Johnston -36.815 -97.144 70 Kay -35.942 -97.943 70 Kingfisher -34.921 -98.981 70 Kiowa -34.870 -95.242 70 Latimer -34.903 -94.701 70 Le Flore -35.703 -96.881 70 Lincoln -35.912 -97.453 70 Logan -33.953 -97.249 70 Love -35.000 -97.440 70 McClain -34.113 -94.766 70 McCurtain -35.376 -95.666 70 McIntosh -36.311 -98.542 70 Major -34.025 -96.769 70 Marshall -36.300 -95.237 70 Mayes -34.486 -97.073 70 Murray -35.609 -95.379 70 Muskogee -36.389 -97.238 70 Noble -36.793 -95.620 70 Nowata -35.471 -96.326 70 Okfuskee -35.549 -97.415 70 Oklahoma -35.644 -95.966 70 Okmulgee -36.631 -96.396 70 Osage -36.844 -94.811 70 Ottawa -36.314 -96.697 70 Pawnee -36.078 -96.974 70 Payne -34.925 -95.749 70 Pittsburg -34.724 -96.694 70 Pontotoc -35.202 -96.945 70 Pottawatomie -34.415 -95.364 70 Pushmataha -35.687 -99.703 70 Roger Mills -36.366 -95.603 70 Rogers -35.173 -96.608 70 Seminole -35.498 -94.755 70 Sequoyah -34.478 -97.856 70 Stephens -36.752 -101.484 70 Texas -34.377 -98.920 70 Tillman -36.120 -95.941 70 Tulsa -35.959 -95.523 70 Wagoner -36.722 -95.904 70 Washington -35.290 -98.992 70 Washita -36.765 -98.861 70 Woods -36.421 -99.260 70 Woodward -44.712 -117.674 70 Baker -44.497 -123.428 70 Benton -45.193 -122.210 70 Clackamas -46.006 -123.711 70 Clatsop -45.946 -123.084 70 Columbia -43.184 -124.092 70 Coos -44.132 -120.359 70 Crook -42.473 -124.230 70 Curry -43.915 -121.224 70 Deschutes -43.287 -123.181 70 Douglas -45.383 -120.208 70 Gilliam -44.498 -119.003 70 Grant -43.071 -118.971 70 Harney -45.523 -121.640 70 Hood River -42.421 -122.737 70 Jackson -44.633 -121.171 70 Jefferson -42.362 -123.561 70 Josephine -42.685 -121.647 70 Klamath -42.792 -120.386 70 Lake -43.948 -122.876 70 Lane -44.642 -123.908 70 Lincoln -44.492 -122.527 70 Linn -43.206 -117.634 70 Malheur -44.909 -122.578 70 Marion -45.422 -119.567 70 Morrow -45.544 -122.414 70 Multnomah -44.906 -123.417 70 Polk -45.409 -120.687 70 Sherman -45.456 -123.758 70 Tillamook -45.594 -118.734 70 Umatilla -45.315 -118.011 70 Union -45.577 -117.173 70 Wallowa -45.163 -121.163 70 Wasco -45.555 -123.095 70 Washington -44.726 -120.023 70 Wheeler -45.227 -123.308 70 Yamhill -39.870 -77.218 70 Adams -40.469 -79.981 70 Allegheny -40.812 -79.464 70 Armstrong -40.686 -80.352 70 Beaver -40.010 -78.490 70 Bedford -40.416 -75.928 70 Berks -40.471 -78.351 70 Blair -41.793 -76.518 70 Bradford -40.338 -75.105 70 Bucks -40.909 -79.912 70 Butler -40.494 -78.715 70 Cambria -41.442 -78.205 70 Cameron -40.923 -75.702 70 Carbon -40.914 -77.818 70 Centre -39.967 -75.752 70 Chester -41.191 -79.423 70 Clarion -41.000 -78.474 70 Clearfield -41.241 -77.637 70 Clinton -41.051 -76.403 70 Columbia -41.684 -80.108 70 Crawford -40.170 -77.265 70 Cumberland -40.413 -76.787 70 Dauphin -39.917 -75.399 70 Delaware -41.419 -78.651 70 Elk -42.103 -80.104 70 Erie -39.921 -79.649 70 Fayette -41.521 -79.236 70 Forest -39.927 -77.724 70 Franklin -39.920 -78.109 70 Fulton -39.855 -80.222 70 Greene -40.414 -77.978 70 Huntingdon -40.652 -79.087 70 Indiana -41.127 -79.000 70 Jefferson -40.531 -77.402 70 Juniata -41.440 -75.610 70 Lackawanna -40.042 -76.250 70 Lancaster -40.992 -80.335 70 Lawrence -40.367 -76.457 70 Lebanon -40.614 -75.590 70 Lehigh -41.176 -75.991 70 Luzerne -41.346 -77.060 70 Lycoming -41.801 -78.566 70 Mc Kean -41.305 -80.253 70 Mercer -40.609 -77.618 70 Mifflin -41.057 -75.336 70 Monroe -40.209 -75.370 70 Montgomery -41.025 -76.662 70 Montour -40.753 -75.308 70 Northampton -40.850 -76.708 70 Northumberland -40.398 -77.266 70 Perry -40.007 -75.135 70 Philadelphia -41.330 -75.034 70 Pike -41.744 -77.900 70 Potter -40.705 -76.214 70 Schuylkill -40.771 -77.076 70 Snyder -39.974 -79.033 70 Somerset -41.447 -76.505 70 Sullivan -41.823 -75.800 70 Susquehanna -41.774 -77.254 70 Tioga -40.962 -77.065 70 Union -41.402 -79.763 70 Venango -41.815 -79.272 70 Warren -40.189 -80.248 70 Washington -41.650 -75.306 70 Wayne -40.309 -79.465 70 Westmoreland -41.520 -76.020 70 Wyoming -39.922 -76.727 70 York -41.705 -71.284 70 Bristol -41.673 -71.578 70 Kent -41.507 -71.267 70 Newport -41.867 -71.580 70 Providence -41.381 -71.614 70 Washington -34.227 -82.453 70 Abbeville -33.546 -81.639 70 Aiken -32.991 -81.355 70 Allendale -34.520 -82.638 70 Anderson -33.219 -81.051 70 Bamberg -33.264 -81.437 70 Barnwell -32.353 -80.694 70 Beaufort -33.195 -79.950 70 Berkeley -33.675 -80.781 70 Calhoun -32.820 -79.896 70 Charleston -35.048 -81.623 70 Cherokee -34.692 -81.159 70 Chester -34.638 -80.159 70 Chesterfield -33.665 -80.218 70 Clarendon -32.844 -80.652 70 Colleton -34.332 -79.955 70 Darlington -34.390 -79.376 70 Dillon -33.081 -80.404 70 Dorchester -33.770 -81.971 70 Edgefield -34.396 -81.126 70 Fairfield -34.024 -79.707 70 Florence -33.414 -79.296 70 Georgetown -34.893 -82.371 70 Greenville -34.156 -82.129 70 Greenwood -32.779 -81.143 70 Hampton -33.910 -78.976 70 Horry -32.435 -81.024 70 Jasper -34.339 -80.588 70 Kershaw -34.687 -80.704 70 Lancaster -34.484 -82.005 70 Laurens -34.158 -80.253 70 Lee -33.899 -81.270 70 Lexington -33.899 -82.305 70 McCormick -34.081 -79.362 70 Marion -34.602 -79.678 70 Marlboro -34.289 -81.600 70 Newberry -34.754 -83.067 70 Oconee -33.442 -80.799 70 Orangeburg -34.889 -82.724 70 Pickens -34.031 -80.907 70 Richland -34.005 -81.728 70 Saluda -34.932 -81.991 70 Spartanburg -33.916 -80.382 70 Sumter -34.693 -81.617 70 Union -33.617 -79.728 70 Williamsburg -34.970 -81.183 70 York -43.717 -98.567 70 Aurora -44.412 -98.278 70 Beadle -43.184 -101.660 70 Bennett -42.993 -97.883 70 Bon Homme -44.366 -96.793 70 Brookings -45.597 -98.353 70 Brown -43.718 -99.065 70 Brule -44.084 -99.201 70 Buffalo -44.909 -103.491 70 Butte -45.761 -100.048 70 Campbell -43.206 -98.595 70 Charles Mix -44.860 -97.727 70 Clark -42.917 -96.974 70 Clay -44.976 -97.179 70 Codington -45.721 -101.184 70 Corson -43.680 -103.457 70 Custer -43.681 -98.156 70 Davison -45.369 -97.605 70 Day -44.761 -96.669 70 Deuel -45.159 -100.875 70 Dewey -43.391 -98.358 70 Douglas -45.413 -99.210 70 Edmunds -43.245 -103.516 70 Fall River -45.069 -99.150 70 Faulk -45.173 -96.772 70 Grant -43.198 -99.178 70 Gregory -44.302 -101.532 70 Haakon -44.681 -97.195 70 Hamlin -44.547 -99.004 70 Hand -43.665 -97.789 70 Hanson -45.591 -103.498 70 Harding -44.393 -99.987 70 Hughes -43.335 -97.748 70 Hutchinson -44.555 -99.482 70 Hyde -43.697 -101.636 70 Jackson -44.062 -98.622 70 Jerauld -43.952 -100.686 70 Jones -44.369 -97.490 70 Kingsbury -44.020 -97.122 70 Lake -44.364 -103.791 70 Lawrence -43.279 -96.722 70 Lincoln -43.900 -99.850 70 Lyman -43.670 -97.362 70 McCook -45.765 -99.224 70 McPherson -45.763 -97.602 70 Marshall -44.566 -102.713 70 Meade -43.580 -100.761 70 Mellette -44.023 -97.610 70 Miner -43.681 -96.786 70 Minnehaha -44.023 -96.672 70 Moody -44.007 -102.820 70 Pennington -45.496 -102.483 70 Perkins -45.064 -99.950 70 Potter -45.624 -96.948 70 Roberts -44.025 -98.090 70 Sanborn -43.332 -102.547 70 Shannon -44.940 -98.347 70 Spink -44.400 -100.748 70 Stanley -44.715 -100.131 70 Sully -43.180 -100.729 70 Todd -43.342 -99.884 70 Tripp -43.310 -97.151 70 Turner -42.832 -96.652 70 Union -45.428 -100.027 70 Walworth -43.009 -97.387 70 Yankton -44.982 -101.669 70 Ziebach -36.113 -84.197 70 Anderson -35.514 -86.458 70 Bedford -36.069 -88.072 70 Benton -35.599 -85.207 70 Bledsoe -35.687 -83.926 70 Blount -35.154 -84.860 70 Bradley -36.406 -84.146 70 Campbell -35.810 -86.063 70 Cannon -35.976 -88.452 70 Carroll -36.296 -82.129 70 Carter -36.267 -87.080 70 Cheatham -35.425 -88.609 70 Chester -36.484 -83.662 70 Claiborne -36.554 -85.543 70 Clay -35.926 -83.120 70 Cocke -35.492 -86.075 70 Coffee -35.810 -89.133 70 Crockett -35.951 -84.997 70 Cumberland -36.169 -86.785 70 Davidson -35.605 -88.106 70 Decatur -35.979 -85.833 70 DeKalb -36.154 -87.362 70 Dickson -36.057 -89.412 70 Dyer -35.189 -89.413 70 Fayette -36.384 -84.928 70 Fentress -35.152 -86.097 70 Franklin -35.999 -88.930 70 Gibson -35.202 -87.036 70 Giles -36.277 -83.511 70 Grainger -36.173 -82.846 70 Greene -35.392 -85.720 70 Grundy -36.218 -83.266 70 Hamblen -35.182 -85.168 70 Hamilton -36.526 -83.220 70 Hancock -35.203 -88.997 70 Hardeman -35.195 -88.186 70 Hardin -36.436 -82.949 70 Hawkins -35.580 -89.286 70 Haywood -35.655 -88.386 70 Henderson -36.327 -88.299 70 Henry -35.800 -87.474 70 Hickman -36.283 -87.714 70 Houston -36.033 -87.773 70 Humphreys -36.355 -85.670 70 Jackson -36.050 -83.447 70 Jefferson -36.458 -81.859 70 Johnson -35.993 -83.937 70 Knox -36.341 -89.492 70 Lake -35.757 -89.635 70 Lauderdale -35.224 -87.393 70 Lawrence -35.522 -87.495 70 Lewis -35.141 -86.588 70 Lincoln -35.734 -84.312 70 Loudon -35.425 -84.618 70 McMinn -35.175 -88.564 70 McNairy -36.529 -86.005 70 Macon -35.608 -88.839 70 Madison -35.128 -85.610 70 Marion -35.467 -86.767 70 Marshall -35.616 -87.076 70 Maury -35.515 -84.810 70 Meigs -35.448 -84.251 70 Monroe -36.495 -87.382 70 Montgomery -35.284 -86.357 70 Moore -36.131 -84.642 70 Morgan -36.361 -89.147 70 Obion -36.344 -85.285 70 Overton -35.636 -87.868 70 Perry -36.558 -85.079 70 Pickett -35.126 -84.516 70 Polk -36.140 -85.496 70 Putnam -35.609 -84.918 70 Rhea -35.847 -84.523 70 Roane -36.525 -86.870 70 Robertson -35.843 -86.417 70 Rutherford -36.433 -84.514 70 Scott -35.370 -85.412 70 Sequatchie -35.783 -83.521 70 Sevier -35.184 -89.892 70 Shelby -36.249 -85.957 70 Smith -36.500 -87.838 70 Stewart -36.515 -82.300 70 Sullivan -36.468 -86.456 70 Sumner -35.492 -89.757 70 Tipton -36.393 -86.156 70 Trousdale -36.103 -82.428 70 Unicoi -36.282 -83.839 70 Union -35.693 -85.462 70 Van Buren -35.678 -85.777 70 Warren -36.294 -82.497 70 Washington -35.236 -87.787 70 Wayne -36.295 -88.717 70 Weakley -35.927 -85.455 70 White -35.894 -86.899 70 Williamson -36.158 -86.299 70 Wilson -31.812 -95.647 70 Anderson -32.299 -102.639 70 Andrews -31.256 -94.607 70 Angelina -28.096 -96.988 70 Aransas -33.614 -98.691 70 Archer -34.966 -101.353 70 Armstrong -28.890 -98.528 70 Atascosa -29.883 -96.277 70 Austin -34.067 -102.830 70 Bailey -29.736 -99.231 70 Bandera -30.104 -97.312 70 Bastrop -33.627 -99.216 70 Baylor -28.417 -97.740 70 Bee -31.037 -97.476 70 Bell -29.449 -98.520 70 Bexar -30.267 -98.399 70 Blanco -32.739 -101.426 70 Borden -31.902 -97.629 70 Bosque -33.446 -94.423 70 Bowie -29.169 -95.435 70 Brazoria -30.662 -96.301 70 Brazos -29.807 -103.246 70 Brewster -34.526 -101.207 70 Briscoe -27.042 -98.212 70 Brooks -31.772 -98.998 70 Brown -30.493 -96.621 70 Burleson -30.784 -98.185 70 Burnet -29.837 -97.614 70 Caldwell -28.436 -96.605 70 Calhoun -32.292 -99.371 70 Callahan -26.149 -97.449 70 Cameron -32.973 -94.979 70 Camp -35.405 -101.355 70 Carson -33.071 -94.346 70 Cass -34.534 -102.257 70 Castro -29.704 -94.679 70 Chambers -31.835 -95.167 70 Cherokee -34.536 -100.202 70 Childress -33.790 -98.205 70 Clay -33.604 -102.831 70 Cochran -31.884 -100.531 70 Coke -31.773 -99.454 70 Coleman -33.185 -96.578 70 Collin -34.967 -100.270 70 Collingsworth -29.622 -96.519 70 Colorado -29.811 -98.284 70 Comal -31.951 -98.558 70 Comanche -31.332 -99.864 70 Concho -33.638 -97.213 70 Cooke -31.391 -97.798 70 Coryell -34.081 -100.275 70 Cottle -31.411 -102.521 70 Crane -30.732 -101.409 70 Crockett -33.613 -101.298 70 Crosby -31.445 -104.524 70 Culberson -36.287 -102.594 70 Dallam -32.767 -96.778 70 Dallas -32.742 -101.947 70 Dawson -34.973 -102.602 70 Deaf Smith -33.387 -95.674 70 Delta -33.204 -97.118 70 Denton -29.081 -97.355 70 DeWitt -33.620 -100.779 70 Dickens -28.424 -99.749 70 Dimmit -34.962 -100.811 70 Donley -27.683 -98.524 70 Duval -32.331 -98.828 70 Eastland -31.865 -102.542 70 Ector -29.971 -100.300 70 Edwards -32.350 -96.793 70 Ellis -31.769 -106.241 70 El Paso -32.234 -98.216 70 Erath -31.258 -96.932 70 Falls -33.588 -96.105 70 Fannin -29.865 -96.926 70 Fayette -32.741 -100.399 70 Fisher -34.074 -101.303 70 Floyd -33.981 -99.778 70 Foard -29.533 -95.774 70 Fort Bend -33.176 -95.219 70 Franklin -31.702 -96.148 70 Freestone -28.865 -99.108 70 Frio -32.740 -102.640 70 Gaines -29.380 -94.858 70 Galveston -33.181 -101.300 70 Garza -30.313 -98.950 70 Gillespie -31.867 -101.532 70 Glasscock -28.652 -97.425 70 Goliad -29.451 -97.494 70 Gonzales -35.409 -100.815 70 Gray -33.624 -96.676 70 Grayson -32.485 -94.811 70 Gregg -30.549 -95.979 70 Grimes -29.583 -97.948 70 Guadalupe -34.074 -101.826 70 Hale -34.521 -100.693 70 Hall -31.703 -98.110 70 Hamilton -36.279 -101.352 70 Hansford -34.290 -99.745 70 Hardeman -30.336 -94.393 70 Hardin -29.857 -95.393 70 Harris -32.548 -94.371 70 Harrison -35.841 -102.608 70 Hartley -33.179 -99.730 70 Haskell -30.058 -98.030 70 Hays -35.834 -100.280 70 Hemphill -32.210 -95.852 70 Henderson -26.396 -98.185 70 Hidalgo -31.993 -97.132 70 Hill -33.606 -102.343 70 Hockley -32.434 -97.835 70 Hood -33.149 -95.562 70 Hopkins -31.318 -95.429 70 Houston -32.309 -101.439 70 Howard -31.452 -105.374 70 Hudspeth -33.123 -96.085 70 Hunt -35.837 -101.361 70 Hutchinson -31.303 -100.980 70 Irion -33.236 -98.176 70 Jack -28.944 -96.576 70 Jackson -30.741 -94.027 70 Jasper -30.716 -104.135 70 Jeff Davis -29.860 -94.140 70 Jefferson -27.049 -98.678 70 Jim Hogg -27.733 -98.090 70 Jim Wells -32.378 -97.365 70 Johnson -32.739 -99.882 70 Jones -28.905 -97.864 70 Karnes -32.597 -96.284 70 Kaufman -29.950 -98.704 70 Kendall -26.926 -97.616 70 Kenedy -33.186 -100.771 70 Kent -30.062 -99.349 70 Kerr -30.491 -99.750 70 Kimble -33.614 -100.252 70 King -29.352 -100.418 70 Kinney -27.427 -97.662 70 Kleberg -33.609 -99.743 70 Knox -33.667 -95.570 70 Lamar -34.069 -102.348 70 Lamb -31.194 -98.240 70 Lampasas -28.344 -99.100 70 La Salle -29.384 -96.938 70 Lavaca -30.307 -96.956 70 Lee -31.300 -96.000 70 Leon -30.149 -94.812 70 Liberty -31.545 -96.583 70 Limestone -36.276 -100.272 70 Lipscomb -28.351 -98.127 70 Live Oak -30.705 -98.685 70 Llano -31.845 -103.567 70 Loving -33.612 -101.820 70 Lubbock -33.178 -101.816 70 Lynn -31.197 -99.347 70 McCulloch -31.551 -97.201 70 McLennan -28.346 -98.567 70 McMullen -30.967 -95.930 70 Madison -32.798 -94.357 70 Marion -32.303 -101.961 70 Martin -30.718 -99.220 70 Mason -28.784 -95.998 70 Matagorda -28.747 -100.321 70 Maverick -29.354 -99.110 70 Medina -30.898 -99.823 70 Menard -31.889 -102.020 70 Midland -30.789 -96.975 70 Milam -31.496 -98.594 70 Mills -32.302 -100.923 70 Mitchell -33.672 -97.725 70 Montague -30.300 -95.502 70 Montgomery -35.836 -101.890 70 Moore -33.118 -94.731 70 Morris -34.085 -100.789 70 Motley -31.612 -94.614 70 Nacogdoches -32.049 -96.474 70 Navarro -30.782 -93.747 70 Newton -32.308 -100.399 70 Nolan -27.737 -97.521 70 Nueces -36.279 -100.815 70 Ochiltree -35.399 -102.596 70 Oldham -30.126 -93.894 70 Orange -32.748 -98.306 70 Palo Pinto -32.163 -94.307 70 Panola -32.778 -97.806 70 Parker -34.528 -102.779 70 Parmer -30.781 -102.723 70 Pecos -30.798 -94.830 70 Polk -35.397 -101.895 70 Potter -29.998 -104.229 70 Presidio -32.870 -95.796 70 Rains -34.968 -101.900 70 Randall -31.359 -101.524 70 Reagan -29.841 -99.807 70 Real -33.618 -95.051 70 Red River -31.321 -103.683 70 Reeves -28.321 -97.169 70 Refugio -35.833 -100.806 70 Roberts -31.027 -96.514 70 Robertson -32.893 -96.409 70 Rockwall -31.833 -99.968 70 Runnels -32.105 -94.757 70 Rusk -31.343 -93.850 70 Sabine -31.397 -94.180 70 San Augustine -30.575 -95.163 70 San Jacinto -28.005 -97.522 70 San Patricio -31.155 -98.815 70 San Saba -30.900 -100.539 70 Schleicher -32.746 -100.917 70 Scurry -32.730 -99.355 70 Shackelford -31.792 -94.142 70 Shelby -36.280 -101.893 70 Sherman -32.375 -95.271 70 Smith -32.222 -97.771 70 Somervell -26.575 -98.733 70 Starr -32.738 -98.839 70 Stephens -31.824 -101.045 70 Sterling -33.178 -100.252 70 Stonewall -30.496 -100.541 70 Sutton -34.530 -101.732 70 Swisher -32.770 -97.293 70 Tarrant -32.311 -99.881 70 Taylor -30.226 -102.067 70 Terrell -33.171 -102.339 70 Terry -33.184 -99.215 70 Throckmorton -33.218 -94.968 70 Titus -31.410 -100.457 70 Tom Green -30.333 -97.779 70 Travis -31.093 -95.125 70 Trinity -30.769 -94.379 70 Tyler -32.735 -94.941 70 Upshur -31.364 -102.042 70 Upton -29.350 -99.761 70 Uvalde -29.894 -101.151 70 Val Verde -32.558 -95.835 70 Van Zandt -28.796 -96.971 70 Victoria -30.738 -95.574 70 Walker -30.013 -95.982 70 Waller -31.511 -103.102 70 Ward -30.214 -96.405 70 Washington -27.770 -99.327 70 Webb -29.277 -96.217 70 Wharton -35.397 -100.267 70 Wheeler -33.990 -98.708 70 Wichita -34.084 -99.242 70 Wilbarger -26.494 -97.598 70 Willacy -30.644 -97.598 70 Williamson -29.174 -98.086 70 Wilson -31.860 -103.047 70 Winkler -33.215 -97.653 70 Wise -32.782 -95.382 70 Wood -33.175 -102.824 70 Yoakum -33.177 -98.698 70 Young -27.000 -99.183 70 Zapata -28.864 -99.760 70 Zavala -38.341 -113.229 70 Beaver -41.515 -113.097 70 Box Elder -41.691 -111.749 70 Cache -39.644 -110.583 70 Carbon -40.890 -109.505 70 Daggett -41.015 -112.123 70 Davis -40.282 -110.435 70 Duchesne -38.990 -110.690 70 Emery -37.874 -111.439 70 Garfield -38.994 -109.559 70 Grand -37.857 -113.277 70 Iron -39.711 -112.796 70 Juab -37.293 -111.894 70 Kane -39.047 -113.105 70 Millard -41.081 -111.579 70 Morgan -38.336 -112.130 70 Piute -41.619 -111.239 70 Rich -40.671 -111.925 70 Salt Lake -37.631 -109.805 70 San Juan -39.373 -111.575 70 Sanpete -38.747 -111.797 70 Sevier -40.884 -110.966 70 Summit -40.445 -113.182 70 Tooele -40.126 -109.518 70 Uintah -40.117 -111.670 70 Utah -40.333 -111.159 70 Wasatch -37.278 -113.517 70 Washington -38.364 -110.897 70 Wayne -41.296 -111.917 70 Weber -44.031 -73.143 70 Addison -43.029 -73.108 70 Bennington -44.460 -72.099 70 Caledonia -44.467 -73.078 70 Chittenden -44.732 -71.721 70 Essex -44.856 -72.923 70 Franklin -44.797 -73.291 70 Grand Isle -44.607 -72.646 70 Lamoille -44.008 -72.382 70 Orange -44.829 -72.251 70 Orleans -43.574 -73.035 70 Rutland -44.270 -72.621 70 Washington -42.986 -72.718 70 Windham -43.571 -72.570 70 Windsor -37.762 -75.764 70 Accomack -38.026 -78.556 70 Albemarle -37.784 -80.013 70 Alleghany -37.337 -77.977 70 Amelia -37.611 -79.142 70 Amherst -37.370 -78.810 70 Appomattox -38.879 -77.102 70 Arlington -38.172 -79.133 70 Augusta -38.059 -79.736 70 Bath -37.312 -79.529 70 Bedford -37.132 -81.127 70 Bland -37.552 -79.805 70 Botetourt -36.764 -77.859 70 Brunswick -37.267 -82.036 70 Buchanan -37.569 -78.525 70 Buckingham -37.212 -79.091 70 Campbell -38.026 -77.348 70 Caroline -36.735 -80.734 70 Carroll -37.352 -77.061 40 Charles City -37.008 -78.662 70 Charlotte -37.378 -77.588 70 Chesterfield -39.116 -77.997 70 Clarke -37.487 -80.216 70 Craig -38.486 -77.957 70 Culpeper -37.515 -78.239 70 Cumberland -37.117 -82.351 70 Dickenson -37.076 -77.630 70 Dinwiddie -37.944 -76.951 70 Essex -38.834 -77.276 70 Fairfax -38.741 -77.809 70 Fauquier -36.936 -80.363 70 Floyd -37.844 -78.279 70 Fluvanna -36.993 -79.881 70 Franklin -39.206 -78.263 70 Frederick -37.319 -80.698 70 Giles -37.403 -76.523 70 Gloucester -37.718 -77.926 70 Goochland -36.653 -81.229 70 Grayson -38.298 -78.471 70 Greene -36.675 -77.562 70 Greensville -36.767 -78.938 70 Halifax -37.760 -77.491 70 Hanover -37.551 -77.404 70 Henrico -36.671 -79.884 70 Henry -38.350 -79.556 70 Highland -36.907 -76.711 70 Isle of Wight -37.312 -76.771 40 James City -37.720 -76.902 70 King and Queen -38.265 -77.155 70 King George -37.703 -77.097 70 King William -37.708 -76.411 70 Lancaster -36.707 -83.129 70 Lee -39.093 -77.637 70 Loudoun -37.987 -77.957 70 Louisa -36.947 -78.241 70 Lunenburg -38.409 -78.281 70 Madison -37.419 -76.279 70 Mathews -36.684 -78.365 70 Mecklenburg -37.611 -76.507 70 Middlesex -37.171 -80.394 70 Montgomery -37.792 -78.884 70 Nelson -37.506 -76.998 70 New Kent -37.301 -75.926 70 Northampton -37.858 -76.379 70 Northumberland -37.141 -78.055 70 Nottoway -38.240 -78.012 70 Orange -38.614 -78.482 70 Page -36.682 -80.285 70 Patrick -36.820 -79.397 70 Pittsylvania -37.546 -77.916 70 Powhatan -37.218 -78.443 70 Prince Edward -37.187 -77.221 70 Prince George -38.704 -77.478 70 Prince William -37.063 -80.714 70 Pulaski -38.687 -78.169 70 Rappahannock -37.939 -76.724 70 Richmond -37.269 -80.079 70 Roanoke -37.815 -79.446 70 Rockbridge -38.515 -78.876 70 Rockingham -36.938 -82.095 70 Russell -36.719 -82.601 70 Scott -38.862 -78.568 70 Shenandoah -36.845 -81.534 70 Smyth -36.724 -77.107 70 Southampton -38.180 -77.651 70 Spotsylvania -38.413 -77.453 70 Stafford -37.120 -76.891 70 Surry -36.926 -77.259 70 Sussex -37.126 -81.563 70 Tazewell -38.908 -78.207 70 Warren -36.724 -81.961 70 Washington -38.114 -76.804 70 Westmoreland -36.975 -82.622 70 Wise -36.921 -81.085 70 Wythe -37.224 -76.439 70 York -38.821 -77.086 40 Alexandria city -37.338 -79.521 40 Bedford city -36.613 -82.168 40 Bristol city -37.732 -79.357 40 Buena Vista city -38.037 -78.486 40 Charlottesville city -36.679 -76.309 40 Chesapeake city -37.823 -79.826 40 Clifton Forge city -37.264 -77.399 40 Colonial Heights city -37.778 -79.990 40 Covington city -36.583 -79.408 40 Danville city -36.695 -77.537 40 Emporia city -38.854 -77.298 40 Fairfax city -38.885 -77.175 40 Falls Church city -36.681 -76.936 40 Franklin city -38.299 -77.487 40 Fredericksburg city -36.665 -80.918 40 Galax city -37.050 -76.295 40 Hampton city -38.437 -78.874 40 Harrisonburg city -37.291 -77.298 40 Hopewell city -37.782 -79.445 40 Lexington city -37.401 -79.191 40 Lynchburg city -38.747 -77.485 40 Manassas city -38.773 -77.452 40 Manassas Park city -36.683 -79.864 40 Martinsville city -37.076 -76.514 40 Newport News city -36.923 -76.245 40 Norfolk city -36.931 -82.626 40 Norton city -37.204 -77.393 40 Petersburg city -37.153 -76.290 40 Poquoson city -36.856 -76.356 40 Portsmouth city -37.124 -80.559 40 Radford city -37.531 -77.475 40 Richmond city -37.278 -79.958 40 Roanoke city -37.287 -80.056 40 Salem city -36.708 -78.906 40 South Boston city -38.159 -79.062 40 Staunton city -36.703 -76.638 40 Suffolk city -36.770 -76.015 40 Virginia Beach city -38.070 -78.903 40 Waynesboro city -37.270 -76.707 40 Williamsburg city -39.174 -78.175 40 Winchester city -46.989 -118.557 70 Adams -46.182 -117.185 70 Asotin -46.248 -119.502 70 Benton -47.877 -120.641 70 Chelan -48.110 -123.931 70 Clallam -45.774 -122.484 70 Clark -46.302 -117.915 70 Columbia -46.191 -122.682 70 Cowlitz -47.740 -119.695 70 Douglas -48.470 -118.509 70 Ferry -46.537 -118.905 70 Franklin -46.434 -117.535 70 Garfield -47.208 -119.466 70 Grant -47.147 -123.829 70 Grays Harbor -48.154 -122.576 70 Island -47.844 -123.576 70 Jefferson -47.475 -121.844 70 King -47.640 -122.647 70 Kitsap -47.124 -120.676 70 Kittitas -45.874 -120.789 70 Klickitat -46.578 -122.398 70 Lewis -47.572 -118.414 70 Lincoln -47.351 -123.185 70 Mason -48.550 -119.746 70 Okanogan -46.561 -123.781 70 Pacific -48.535 -117.282 70 Pend Oreille -47.048 -122.113 70 Pierce -48.570 -122.973 70 San Juan -48.477 -121.782 70 Skagit -46.026 -121.914 70 Skamania -48.044 -121.714 70 Snohomish -47.620 -117.403 70 Spokane -48.397 -117.853 70 Stevens -46.925 -122.828 70 Thurston -46.293 -123.428 70 Wahkiakum -46.226 -118.478 70 Walla Walla -48.834 -121.900 70 Whatcom -46.887 -117.519 70 Whitman -46.456 -120.739 70 Yakima -39.130 -79.998 70 Barbour -39.467 -78.026 70 Berkeley -38.021 -81.720 70 Boone -38.703 -80.731 70 Braxton -40.270 -80.584 70 Brooke -38.418 -82.242 70 Cabell -38.844 -81.118 70 Calhoun -38.460 -81.075 70 Clay -39.260 -80.701 70 Doddridge -38.031 -81.087 70 Fayette -38.918 -80.854 70 Gilmer -39.102 -79.197 70 Grant -37.950 -80.450 70 Greenbrier -39.314 -78.613 70 Hampshire -40.521 -80.581 70 Hancock -39.005 -78.863 70 Hardy -39.287 -80.383 70 Harrison -38.833 -81.672 70 Jackson -39.307 -77.864 70 Jefferson -38.342 -81.526 70 Kanawha -38.996 -80.506 70 Lewis -38.178 -82.071 70 Lincoln -37.826 -81.939 70 Logan -37.372 -81.648 70 McDowell -39.512 -80.243 70 Marion -39.872 -80.672 70 Marshall -38.773 -82.022 70 Mason -37.406 -81.114 70 Mercer -39.415 -78.942 70 Mineral -37.728 -82.136 70 Mingo -39.626 -80.051 70 Monongalia -37.561 -80.544 70 Monroe -39.562 -78.261 70 Morgan -38.290 -80.796 70 Nicholas -40.097 -80.617 70 Ohio -38.684 -79.356 70 Pendleton -39.371 -81.163 70 Pleasants -38.322 -80.008 70 Pocahontas -39.469 -79.668 70 Preston -38.509 -81.906 70 Putnam -37.776 -81.256 70 Raleigh -38.780 -79.868 70 Randolph -39.178 -81.066 70 Ritchie -38.715 -81.358 70 Roane -37.657 -80.857 70 Summers -39.340 -80.048 70 Taylor -39.104 -79.567 70 Tucker -39.465 -80.879 70 Tyler -38.901 -80.232 70 Upshur -38.150 -82.433 70 Wayne -38.495 -80.435 70 Webster -39.610 -80.641 70 Wetzel -39.019 -81.385 70 Wirt -39.213 -81.514 70 Wood -37.610 -81.541 70 Wyoming -43.967 -89.773 70 Adams -46.708 -90.558 70 Ashland -45.418 -91.853 70 Barron -46.631 -91.183 70 Bayfield -44.475 -87.994 70 Brown -44.379 -91.752 70 Buffalo -45.866 -92.368 70 Burnett -44.078 -88.222 70 Calumet -45.068 -91.282 70 Chippewa -44.731 -90.610 70 Clark -43.471 -89.330 70 Columbia -43.233 -90.931 70 Crawford -43.067 -89.418 70 Dane -43.416 -88.708 70 Dodge -45.021 -87.010 70 Door -46.451 -91.906 70 Douglas -44.948 -91.898 70 Dunn -44.727 -91.287 70 Eau Claire -45.851 -88.399 70 Florence -43.755 -88.491 70 Fond du Lac -45.668 -88.777 70 Forest -42.863 -90.708 70 Grant -42.682 -89.602 70 Green -43.808 -89.044 70 Green Lake -42.998 -90.134 70 Iowa -46.326 -90.262 70 Iron -44.315 -90.808 70 Jackson -43.020 -88.780 70 Jefferson -43.923 -90.112 70 Juneau -42.582 -87.806 70 Kenosha -44.589 -87.440 70 Kewaunee -43.908 -91.110 70 La Crosse -42.659 -90.135 70 Lafayette -45.256 -89.071 70 Langlade -45.330 -89.732 70 Lincoln -44.145 -87.553 70 Manitowoc -44.898 -89.758 70 Marathon -45.343 -88.001 70 Marinette -43.818 -89.394 70 Marquette -45.019 -88.700 70 Menominee -42.976 -87.671 70 Milwaukee -43.945 -90.620 70 Monroe -44.994 -88.229 70 Oconto -45.705 -89.524 70 Oneida -44.412 -88.462 70 Outagamie -43.250 -87.502 70 Ozaukee -44.597 -92.001 70 Pepin -44.716 -92.423 70 Pierce -45.460 -92.443 70 Polk -44.476 -89.498 70 Portage -45.680 -90.361 70 Price -42.785 -87.755 70 Racine -43.377 -90.427 70 Richland -42.672 -89.068 70 Rock -45.475 -91.135 70 Rusk -45.039 -92.447 70 St Croix -43.427 -89.944 70 Sauk -45.899 -91.142 70 Sawyer -44.790 -88.756 70 Shawano -43.716 -87.663 70 Sheboygan -45.211 -90.505 70 Taylor -44.305 -91.352 70 Trempealeau -43.593 -90.833 70 Vernon -46.053 -89.513 70 Vilas -42.668 -88.542 70 Walworth -45.900 -91.791 70 Washburn -43.367 -88.231 70 Washington -43.018 -88.306 70 Waukesha -44.479 -88.966 70 Waupaca -44.113 -89.238 70 Waushara -44.062 -88.643 70 Winnebago -44.451 -90.042 70 Wood -41.649 -105.744 70 Albany -44.526 -107.987 70 Big Horn -44.240 -105.549 70 Campbell -41.691 -106.930 70 Carbon -42.975 -105.504 70 Converse -44.590 -104.564 70 Crook -43.028 -108.629 70 Fremont -42.089 -104.355 70 Goshen -43.714 -108.444 70 Hot Springs -44.040 -106.587 70 Johnson -41.315 -104.686 70 Laramie -42.260 -110.703 70 Lincoln -42.965 -106.805 70 Natrona -43.051 -104.473 70 Niobrara -44.493 -109.563 70 Park -42.129 -104.961 70 Platte -44.794 -106.882 70 Sheridan -42.761 -109.920 70 Sublette -41.658 -108.894 70 Sweetwater -43.923 -110.574 70 Teton -41.286 -110.547 70 Uinta -43.907 -107.684 70 Washakie -43.836 -104.563 70 Weston diff --git a/cave/com.raytheon.viz.lpi/localization/bundles/maps/county_names.xml b/cave/com.raytheon.viz.lpi/localization/bundles/maps/county_names.xml deleted file mode 100644 index 8d78ebd578..0000000000 --- a/cave/com.raytheon.viz.lpi/localization/bundles/maps/county_names.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - PLAN_VIEW - - - - - - us_county.lpi - County Names - - - - - - diff --git a/cave/com.raytheon.viz.lpi/src/com/raytheon/viz/lpi/LPIResource.java b/cave/com.raytheon.viz.lpi/src/com/raytheon/viz/lpi/LPIResource.java index 3c82b791ce..03e986590a 100644 --- a/cave/com.raytheon.viz.lpi/src/com/raytheon/viz/lpi/LPIResource.java +++ b/cave/com.raytheon.viz.lpi/src/com/raytheon/viz/lpi/LPIResource.java @@ -41,12 +41,10 @@ import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; import com.raytheon.uf.viz.core.IGraphicsTarget.PointStyle; import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment; import com.raytheon.uf.viz.core.VizApp; -import com.raytheon.uf.viz.core.drawables.IFont; import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.map.IMapDescriptor; import com.raytheon.uf.viz.core.maps.rsc.StyledMapResource; -import com.raytheon.uf.viz.core.rsc.IResourceDataChanged; import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; import com.raytheon.uf.viz.core.rsc.capabilities.DensityCapability; @@ -68,6 +66,7 @@ import com.vividsolutions.jts.geom.Coordinate; * May 16, 2014 3163 bsteffen Remove WORD_WRAP TextStyle and handle * wrapping locally. * Aug 21, 2014 #3459 randerso Restructured Map resource class hierarchy + * Nov 05, 2015 #5070 randerso Moved label font management up to AbstractMapResource * * * @@ -75,8 +74,7 @@ import com.vividsolutions.jts.geom.Coordinate; * */ public class LPIResource extends - StyledMapResource implements - IResourceDataChanged { + StyledMapResource { /** Whether the resource is ready to be drawn */ private boolean ready = false; @@ -87,8 +85,6 @@ public class LPIResource extends private int pixelSizeHint = 90; - private IFont font; - private class LPIPoint { public Coordinate latLon; @@ -106,20 +102,6 @@ public class LPIResource extends protected LPIResource(LPIResourceData resourceData, LoadProperties loadProperties) { super(resourceData, loadProperties); - resourceData.addChangeListener(this); - } - - @Override - public void resourceChanged(ChangeType type, Object object) { - if (type == ChangeType.CAPABILITY) { - if (object instanceof MagnificationCapability) { - if (font != null) { - font.dispose(); - font = null; - } - } - } - this.issueRefresh(); } /* @@ -215,6 +197,7 @@ public class LPIResource extends @Override protected void paintInternal(IGraphicsTarget target, PaintProperties paintProps) throws VizException { + if (ready) { int displayWidth = (int) (this.descriptor.getMapWidth() * paintProps .getZoomLevel()); @@ -225,17 +208,12 @@ public class LPIResource extends double magnification = getCapability(MagnificationCapability.class) .getMagnification(); - if (this.font == null) { - font = target.initializeFont(target.getDefaultFont() - .getFontName(), (float) (10 * magnification), null); - } - double displayHintSize = this.pixelSizeHint * magnification; double minSepDist = (displayHintSize * (metersPerPixel / 1000.0)) / getCapability(DensityCapability.class).getDensity(); DrawableString test = new DrawableString("N", null); - test.font = font; + test.font = getFont(target); Rectangle2D charSize = target.getStringsBounds(test); double charWidth = charSize.getWidth(); double charHeight = charSize.getHeight(); @@ -279,7 +257,7 @@ public class LPIResource extends String label = p.label; label = label.replaceAll("([^\n]{3}\\S*)\\s+", "$1\n"); DrawableString string = new DrawableString(label, color); - string.font = font; + string.font = getFont(target); string.setCoordinates(p.pixel[0] + offsetX, p.pixel[1] + offsetY); string.horizontalAlignment = align; @@ -294,20 +272,6 @@ public class LPIResource extends } } - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.viz.core.rsc.AbstractVizResource#dispose() - */ - @Override - protected void disposeInternal() { - resourceData.removeChangeListener(this); - if (font != null) { - font.dispose(); - font = null; - } - } - /* * (non-Javadoc) * diff --git a/cave/com.raytheon.viz.mpe.ui/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.mpe.ui/META-INF/MANIFEST.MF index 690867eccb..cd70fd8f8d 100644 --- a/cave/com.raytheon.viz.mpe.ui/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.mpe.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: MPE Ui Plug-in Bundle-SymbolicName: com.raytheon.viz.mpe.ui;singleton:=true -Bundle-Version: 1.15.0.qualifier +Bundle-Version: 1.15.1.qualifier Bundle-Activator: com.raytheon.viz.mpe.ui.Activator Bundle-Vendor: Raytheon Require-Bundle: org.eclipse.core.runtime, @@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime, com.raytheon.viz.mpe, com.raytheon.viz.core.contours, javax.measure, - org.apache.commons.lang, + org.apache.commons.lang3;bundle-version="3.4.0", com.raytheon.uf.viz.app.launcher, com.raytheon.uf.common.mpe, com.raytheon.uf.common.hydro, diff --git a/cave/com.raytheon.viz.mpe.ui/plugin.xml b/cave/com.raytheon.viz.mpe.ui/plugin.xml index e28a5c64c8..671ee96da4 100644 --- a/cave/com.raytheon.viz.mpe.ui/plugin.xml +++ b/cave/com.raytheon.viz.mpe.ui/plugin.xml @@ -1890,7 +1890,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.legend" id="com.raytheon.viz.mpe.ui.rsc.MPELegendResource.miniscule" label="Miniscule" - value="Monospace-bold-10"> + value="Monospace-bold-8"> This is the definition for the "Miniscule" font for the MPE Legend. This font definition will be used when the "Miniscule" option is selected. @@ -1900,7 +1900,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.legend" id="com.raytheon.viz.mpe.ui.rsc.MPELegendResource.verysmall" label="Very Small" - value="Monospace-bold-11"> + value="Monospace-bold-9"> This is the definition for the "Very Small" font for the MPE Legend. This font definition will be used when the "Very Small" option is selected. @@ -1910,7 +1910,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.legend" id="com.raytheon.viz.mpe.ui.rsc.MPELegendResource.small" label="Small" - value="Monospace-bold-12"> + value="Monospace-bold-10"> This is the definition for the "Small" font for the MPE Legend. This font definition will be used when the "Small" option is selected. @@ -1920,7 +1920,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.legend" id="com.raytheon.viz.mpe.ui.rsc.MPELegendResource.normal" label="Normal" - value="Monospace-bold-14"> + value="Monospace-bold-12"> This is the definition for the "Normal" font for the MPE Legend. This font definition will be used when the "Normal" option is selected. @@ -1930,7 +1930,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.legend" id="com.raytheon.viz.mpe.ui.rsc.MPELegendResource.large" label="Large" - value="Monospace-bold-17"> + value="Monospace-bold-14"> This is the definition for the "Large" font for the MPE Legend. This font definition will be used when the "Large" option is selected. @@ -1940,7 +1940,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.legend" id="com.raytheon.viz.mpe.ui.rsc.MPELegendResource.verylarge" label="Very Large" - value="Monospace-bold-22"> + value="Monospace-bold-18"> This is the definition for the "Very Large" font for the MPE Legend. This font definition will be used when the "Very Large" option is selected. @@ -1952,7 +1952,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.gage" id="com.raytheon.viz.mpe.ui.rsc.MPEGageResource.miniscule" label="Miniscule" - value="Dialog-bold-7"> + value="Dialog-bold-6"> This is the definition for the "Miniscule" font for the Gage Plots. This font definition will be used when the "Miniscule" option is selected. @@ -1962,7 +1962,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.gage" id="com.raytheon.viz.mpe.ui.rsc.MPEGageResource.verysmall" label="Very Small" - value="Dialog-bold-8"> + value="Dialog-bold-7"> This is the definition for the "Very Small" font for the Gage Plots. This font definition will be used when the "Very Small" option is selected. @@ -1972,7 +1972,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.gage" id="com.raytheon.viz.mpe.ui.rsc.MPEGageResource.small" label="Small" - value="Dialog-bold-9"> + value="Dialog-bold-8"> This is the definition for the "Small" font for the Gage Plots. This font definition will be used when the "Small" option is selected. @@ -1982,7 +1982,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.gage" id="com.raytheon.viz.mpe.ui.rsc.MPEGageResource.normal" label="Normal" - value="Dialog-bold-10"> + value="Dialog-bold-9"> This is the definition for the "Normal" font for the Gage Plots. This font definition will be used when the "Normal" option is selected. @@ -1992,7 +1992,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.gage" id="com.raytheon.viz.mpe.ui.rsc.MPEGageResource.large" label="Large" - value="Dialog-bold-12"> + value="Dialog-bold-10"> This is the definition for the "Large" font for the Gage Plots. This font definition will be used when the "Large" option is selected. @@ -2002,7 +2002,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.gage" id="com.raytheon.viz.mpe.ui.rsc.MPEGageResource.verylarge" label="Very Large" - value="Dialog-bold-16"> + value="Dialog-bold-14"> This is the definition for the "Very Large" font for the Gage Plots. This font definition will be used when the "Very Large" option is selected. @@ -2014,7 +2014,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.default" id="com.raytheon.viz.mpe.ui.defaultFont.miniscule" label="Miniscule" - value="Monospace-regular-7"> + value="Monospace-regular-6"> This is the default definition for the "Miniscule" font. This font definition will be used when the "Miniscule" option is selected. @@ -2024,7 +2024,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.default" id="com.raytheon.viz.mpe.ui.defaultFont.verysmall" label="Very Small" - value="Monospace-regular-8"> + value="Monospace-regular-7"> This is the default definition for the "Very Small" font. This font definition will be used when the "Very Small" option is selected. @@ -2034,7 +2034,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.default" id="com.raytheon.viz.mpe.ui.defaultFont.small" label="Small" - value="Monospace-regular-9"> + value="Monospace-regular-8"> This is the default definition for the "Small" font. This font definition will be used when the "Small" option is selected. @@ -2044,7 +2044,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.default" id="com.raytheon.viz.mpe.ui.defaultFont.normal" label="Normal" - value="Monospace-regular-10"> + value="Monospace-regular-9"> This is the default definition for the "Normal" font. This font definition will be used when the "Normal" option is selected. @@ -2054,7 +2054,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.default" id="com.raytheon.viz.mpe.ui.defaultFont.large" label="Large" - value="Monospace-regular-12"> + value="Monospace-regular-10"> This is the default definition for the "Large" font. This font definition will be used when the "Large" option is selected. @@ -2064,7 +2064,7 @@ categoryId="com.raytheon.viz.mpe.ui.theme.default" id="com.raytheon.viz.mpe.ui.defaultFont.verylarge" label="Very Large" - value="Monospace-regular-16"> + value="Monospace-regular-14"> This is the default definition for the "Very Large" font. This font definition will be used when the "Very Large" option is selected. diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SaveLevel2DQCData.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SaveLevel2DQCData.java index 8ca6d85701..7f8c5297e9 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SaveLevel2DQCData.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SaveLevel2DQCData.java @@ -22,6 +22,9 @@ package com.raytheon.viz.mpe.ui.actions; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.handlers.HandlerUtil; /** * TODO Add Description @@ -31,6 +34,7 @@ import org.eclipse.core.commands.ExecutionException; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 27, 2009 snaples Initial creation + * Jan 15, 2016 5054 randerso Use proper parent shell * * * @author randerso @@ -47,8 +51,9 @@ public class SaveLevel2DQCData extends AbstractHandler { * .ExecutionEvent) */ @Override - public Object execute(ExecutionEvent arg0) throws ExecutionException { - SaveLevel2Data s2 = new SaveLevel2Data(); + public Object execute(ExecutionEvent event) throws ExecutionException { + Shell shell = HandlerUtil.getActiveShell(event); + SaveLevel2Data s2 = new SaveLevel2Data(shell); s2.send_dbase_new_area(); return null; } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SaveLevel2Data.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SaveLevel2Data.java index c0a065619e..d7869b1ddc 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SaveLevel2Data.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SaveLevel2Data.java @@ -80,6 +80,7 @@ import com.raytheon.viz.mpe.util.WriteQPFGrids; * Mar 10, 2015 14575 snaples Added status check to make sure that we close everything before exiting. * Jun 25, 2015 17462 snaples Fixed loop of basins for temp and freezing. * Dec 07, 2015 5172 bkowal Prevent NPE on close. Cleanup all warnings and e print stack trace usage. + * Jan 15, 2016 5054 randerso Added proper constructor with parent shell parameter * * * @@ -110,17 +111,25 @@ public class SaveLevel2Data { public static int[] qctype_flag = new int[NUM_QCTYPE]; - private Shell shell = new Shell(); + private final Shell shell; DailyQcUtils dqc = DailyQcUtils.getInstance(); + /** + * @param shell + * parent shell for dialogs + */ + public SaveLevel2Data(Shell shell) { + this.shell = shell; + } + public int check_new_area(Date curDate, String area, int days) { int j, m; currntDate = curDate; qarea = area; qdays = days; - if (DailyQcUtils.pdata == null || DailyQcUtils.pdata.length < 10) { + if ((DailyQcUtils.pdata == null) || (DailyQcUtils.pdata.length < 10)) { return 0; } /* Check if any of the GageQC datasets have not been QC'd. */ @@ -132,8 +141,8 @@ public class SaveLevel2Data { if (DailyQcUtils.pdata[j] == null) { return 0; } - if (DailyQcUtils.pdata[j].used[m] != 1 - || DailyQcUtils.pdata[j].level != 1) { + if ((DailyQcUtils.pdata[j].used[m] != 1) + || (DailyQcUtils.pdata[j].level != 1)) { continue; } @@ -152,8 +161,8 @@ public class SaveLevel2Data { for (j = 0; j < MAX_GAGEQC_DAYS; j++) { for (m = 0; m < 5; m++) { /* not databased */ - if (DailyQcUtils.zdata[j].used[m] != 1 - || DailyQcUtils.zdata[j].level[m] != 1) { + if ((DailyQcUtils.zdata[j].used[m] != 1) + || (DailyQcUtils.zdata[j].level[m] != 1)) { continue; } @@ -167,8 +176,8 @@ public class SaveLevel2Data { for (j = 0; j < MAX_GAGEQC_DAYS; j++) { for (m = 0; m < 5; m++) { /* not databased */ - if (DailyQcUtils.tdata[j].used[m] != 1 - || DailyQcUtils.tdata[j].level[m] != 1) { + if ((DailyQcUtils.tdata[j].used[m] != 1) + || (DailyQcUtils.tdata[j].level[m] != 1)) { continue; } @@ -201,8 +210,8 @@ public class SaveLevel2Data { for (m = 0; m < 5; m++) { - if (DailyQcUtils.pdata[j].used[m] != 1 - || DailyQcUtils.pdata[j].level != 1) { + if ((DailyQcUtils.pdata[j].used[m] != 1) + || (DailyQcUtils.pdata[j].level != 1)) { continue; } @@ -231,8 +240,8 @@ public class SaveLevel2Data { for (m = 0; m < 5; m++) { - if (DailyQcUtils.zdata[j].used[m] != 1 - || DailyQcUtils.zdata[j].level[m] != 1) { + if ((DailyQcUtils.zdata[j].used[m] != 1) + || (DailyQcUtils.zdata[j].level[m] != 1)) { continue; } @@ -260,8 +269,8 @@ public class SaveLevel2Data { for (m = 0; m < 6; m++) { - if (DailyQcUtils.tdata[j].used[m] != 1 - || DailyQcUtils.tdata[j].level[m] != 1) { + if ((DailyQcUtils.tdata[j].used[m] != 1) + || (DailyQcUtils.tdata[j].level[m] != 1)) { continue; } @@ -289,8 +298,8 @@ public class SaveLevel2Data { for (m = 0; m < 5; m++) { /* not databased */ - if (DailyQcUtils.pdata[j].used[m] != 3 - && DailyQcUtils.pdata[j].used[m] != 2) { + if ((DailyQcUtils.pdata[j].used[m] != 3) + && (DailyQcUtils.pdata[j].used[m] != 2)) { continue; } @@ -337,8 +346,9 @@ public class SaveLevel2Data { if (DailyQcUtils.pdata == null) { return; } - if (DailyQcUtils.pdata.length == 0 && DailyQcUtils.tdata.length == 0 - && DailyQcUtils.zdata.length == 0) { + if ((DailyQcUtils.pdata.length == 0) + && (DailyQcUtils.tdata.length == 0) + && (DailyQcUtils.zdata.length == 0)) { return; } for (j = 0; j < MAX_GAGEQC_DAYS; j++) { @@ -350,14 +360,14 @@ public class SaveLevel2Data { for (m = 0; m < 5; m++) { - if (DailyQcUtils.pdata[j].used[m] != 3 - && DailyQcUtils.pdata[j].used[m] != 2) { + if ((DailyQcUtils.pdata[j].used[m] != 3) + && (DailyQcUtils.pdata[j].used[m] != 2)) { - if (DailyQcUtils.zdata[j].used[m] != 3 - && DailyQcUtils.zdata[j].used[m] != 2) { + if ((DailyQcUtils.zdata[j].used[m] != 3) + && (DailyQcUtils.zdata[j].used[m] != 2)) { - if (DailyQcUtils.tdata[j].used[m] != 3 - && DailyQcUtils.tdata[j].used[m] != 2) { + if ((DailyQcUtils.tdata[j].used[m] != 3) + && (DailyQcUtils.tdata[j].used[m] != 2)) { continue; } @@ -405,7 +415,7 @@ public class SaveLevel2Data { String tokenName = "mpe_map_one_zone"; String tokenValue = apps_defaults.getToken(tokenName); - if (tokenValue != null && tokenValue.length() > 0) { + if ((tokenValue != null) && (tokenValue.length() > 0)) { /* we use the token ON and OFF */ if (tokenValue.equalsIgnoreCase(ON)) { token_of_mpe_map_one_zone = 1; @@ -451,7 +461,8 @@ public class SaveLevel2Data { int num_period_qc = 0; String fname_nc = ""; float[][] datavals = new float[hrap_grid.maxi][hrap_grid.maxj]; - if (dqc.mpe_dqc_save_grib == true || dqc.mpe_dqc_save_netcdf == true) { + if ((dqc.mpe_dqc_save_grib == true) + || (dqc.mpe_dqc_save_netcdf == true)) { for (int h = 0; h < hrap_grid.maxj; h++) { for (int i = 0; i < hrap_grid.maxi; i++) { datavals[i][h] = (DailyQcUtils.pcp.value[i][h] / 100.f); @@ -468,7 +479,7 @@ public class SaveLevel2Data { if (first == 0) { String l2Type = apps_defaults.getToken("mpe_level2_type_value"); - if (l2Type != null && l2Type.length() > 0) { + if ((l2Type != null) && (l2Type.length() > 0)) { type = l2Type.trim(); } else { type = "2"; @@ -482,9 +493,10 @@ public class SaveLevel2Data { } save_isom = DailyQcUtils.isom; - if ((DailyQcUtils.qpf_flag == true || DailyQcUtils.maxmin_flag == true || DailyQcUtils.z_flag == true) - && DailyQcUtils.pcpn_day == 0 - && (dqc.curHr18_00 == 1 || dqc.curHr00_06 == 1 || dqc.curHr06_12 == 1)) { + if (((DailyQcUtils.qpf_flag == true) + || (DailyQcUtils.maxmin_flag == true) || (DailyQcUtils.z_flag == true)) + && (DailyQcUtils.pcpn_day == 0) + && ((dqc.curHr18_00 == 1) || (dqc.curHr00_06 == 1) || (dqc.curHr06_12 == 1))) { /* * if run DQC at the time frames such as curHr18_00 or curHr00_06 or * curHr06_12, for precipitation, do not display the 24 hr @@ -555,7 +567,8 @@ public class SaveLevel2Data { */ // Sanity check - if (DailyQcUtils.pdata == null || DailyQcUtils.pdata.length <= 0) { + if ((DailyQcUtils.pdata == null) + || (DailyQcUtils.pdata.length <= 0)) { return; } @@ -570,8 +583,8 @@ public class SaveLevel2Data { * saved. */ - if ((DailyQcUtils.pdata[j].used[m] == 3 || DailyQcUtils.pdata[j].used[m] == 2) - && qctype_flag[0] == 1) { + if (((DailyQcUtils.pdata[j].used[m] == 3) || (DailyQcUtils.pdata[j].used[m] == 2)) + && (qctype_flag[0] == 1)) { break; } } @@ -588,8 +601,8 @@ public class SaveLevel2Data { * other if run DQC on partial time frame and j=0 */ - if (j == 0 - && (dqc.curHr00_06 == 1 || dqc.curHr06_12 == 1 || dqc.curHr18_00 == 1)) { + if ((j == 0) + && ((dqc.curHr00_06 == 1) || (dqc.curHr06_12 == 1) || (dqc.curHr18_00 == 1))) { } else { EstDailyStations eds = new EstDailyStations(); eds.estimate_daily_stations(j, DailyQcUtils.precip_stations, @@ -637,7 +650,8 @@ public class SaveLevel2Data { // save for each 6 hour periods for (l = 0; l < 5; l++) { - if (DailyQcUtils.pdata[j].used[l] == 0 || qctype_flag[0] == -1) { + if ((DailyQcUtils.pdata[j].used[l] == 0) + || (qctype_flag[0] == -1)) { continue; } @@ -704,7 +718,7 @@ public class SaveLevel2Data { } if (l < 4) { - num = j * 4 + 3 - l; + num = ((j * 4) + 3) - l; } else { num = 40 + j; } @@ -718,7 +732,8 @@ public class SaveLevel2Data { // save the whole days for (l = 0; l < 5; l++) { - if (DailyQcUtils.pdata[j].used[l] == 0 || qctype_flag[0] == -1) { + if ((DailyQcUtils.pdata[j].used[l] == 0) + || (qctype_flag[0] == -1)) { continue; } @@ -773,7 +788,7 @@ public class SaveLevel2Data { } if (l < 4) { - num = j * 4 + 3 - l; + num = ((j * 4) + 3) - l; } else { num = 40 + j; } @@ -994,7 +1009,7 @@ public class SaveLevel2Data { /* write_qc_file(type); */ for (l = 0; l < 4; l++) { - int jj = j * 4 + 3 - l; + int jj = ((j * 4) + 3) - l; if (pcp_in_use[jj] != 1) { continue; @@ -1016,7 +1031,7 @@ public class SaveLevel2Data { found: for (m = 0; mean_areal_precip_global[m] != null; m++) { for (k = 0; k < 4; k++) { - num = j * 4 + 3 - k; + num = ((j * 4) + 3) - k; if (mean_areal_precip_global[m].maps_done != null) { if (mean_areal_precip_global[m].maps_done[num] == 1) { @@ -1091,7 +1106,7 @@ public class SaveLevel2Data { /* fix for polygon basins */ if (dqc.mpe_rfc_name.equalsIgnoreCase("cbrfc") - && mean_areal_precip_global[m].hb5.length() == 7) { + && (mean_areal_precip_global[m].hb5.length() == 7)) { xbuf.append(mean_areal_precip_global[m].bchar .charAt(0)); @@ -1100,15 +1115,16 @@ public class SaveLevel2Data { else { - if (l == 0 && numzones != 1 && one_zone_flag != 1) { + if ((l == 0) && (numzones != 1) + && (one_zone_flag != 1)) { xbuf.append("L"); xbuf.append(mean_areal_precip_global[m].bchar .charAt(0)); } - else if (l == 0 && numzones == 1 - && one_zone_flag != 1) { + else if ((l == 0) && (numzones == 1) + && (one_zone_flag != 1)) { xbuf.append("O"); xbuf.append(mean_areal_precip_global[m].bchar .charAt(0)); @@ -1146,12 +1162,13 @@ public class SaveLevel2Data { for (k = 0; k < 4; k++) { - int h = j * 4 + (3 - k); + int h = (j * 4) + (3 - k); /* fix for polygon basins */ if (dqc.mpe_rfc_name.equalsIgnoreCase("cbrfc") - && mean_areal_precip_global[m].hb5.length() == 7) { + && (mean_areal_precip_global[m].hb5 + .length() == 7)) { temp = mean_areal_precip_global[m].lz[h]; } else if (l == 0) { temp = mean_areal_precip_global[m].lz[h]; @@ -1181,7 +1198,7 @@ public class SaveLevel2Data { if (one_zone_flag == 0) { fp.write(xbuf.toString()); fp.newLine(); - } else if (one_zone_flag == 1 && l == 0) { + } else if ((one_zone_flag == 1) && (l == 0)) { fp.write(xbuf.toString()); statusHandler .info("Writing out record to One Zone MAP file: " @@ -1337,9 +1354,9 @@ public class SaveLevel2Data { * level 1 pass through here to the save data question */ - if ((DailyQcUtils.zdata[j].used[m] == 3 - || DailyQcUtils.zdata[j].used[m] == 2 || DailyQcUtils.zdata[j].used[m] == 1) - && qctype_flag[2] == 1) { + if (((DailyQcUtils.zdata[j].used[m] == 3) + || (DailyQcUtils.zdata[j].used[m] == 2) || (DailyQcUtils.zdata[j].used[m] == 1)) + && (qctype_flag[2] == 1)) { break; } @@ -1372,7 +1389,8 @@ public class SaveLevel2Data { for (l = 0; l < 4; l++) { - if (DailyQcUtils.zdata[j].used[l] == 0 || qctype_flag[2] == -1) { + if ((DailyQcUtils.zdata[j].used[l] == 0) + || (qctype_flag[2] == -1)) { continue; } /* @@ -1420,7 +1438,7 @@ public class SaveLevel2Data { wqg.write_qpf_grids(dbuf); /* output grid to file in netCDF format */ - if (l + 1 <= num_period_qc) { + if ((l + 1) <= num_period_qc) { if (dqc.mpe_dqc_save_netcdf == true) { WriteDQCNetCDFGrids wng = new WriteDQCNetCDFGrids(); wng.write_dqc_netcdf_grids(fname_nc, l, num_period_qc, @@ -1446,7 +1464,7 @@ public class SaveLevel2Data { } } - num = 100 + j * 4 + 3 - l; + num = (100 + (j * 4) + 3) - l; MakeRsel mr = new MakeRsel(); mr.make_rsel(num, num - 100); @@ -1566,7 +1584,7 @@ public class SaveLevel2Data { for (k = 0; k < 4; k++) { - num = j * 4 + 3 - k; + num = ((j * 4) + 3) - k; if (mean_areal_precip_global[m].zmaps_done[num] == 1) { break foundz; @@ -1630,7 +1648,7 @@ public class SaveLevel2Data { /* fix for polygon basins */ if (dqc.mpe_rfc_name.equalsIgnoreCase("cbrfc") - && mean_areal_precip_global[m].hb5.length() == 7) { + && (mean_areal_precip_global[m].hb5.length() == 7)) { // logMessage ("polygon write\n"); xbuf.append(mean_areal_precip_global[m].bchar @@ -1640,7 +1658,7 @@ public class SaveLevel2Data { else { - if (l == 0 && numzones != 1) { + if ((l == 0) && (numzones != 1)) { xbuf.append("L"); xbuf.append(mean_areal_precip_global[m].bchar @@ -1648,7 +1666,7 @@ public class SaveLevel2Data { } - else if (l == 0 && numzones == 1) { + else if ((l == 0) && (numzones == 1)) { xbuf.append("O"); xbuf.append(mean_areal_precip_global[m].bchar @@ -1701,10 +1719,11 @@ public class SaveLevel2Data { for (k = 0; k < 4; k++) { - int h = j * 4 + (3 - k); + int h = (j * 4) + (3 - k); if (dqc.mpe_rfc_name.equalsIgnoreCase("cbrfc") - && mean_areal_precip_global[m].hb5.length() == 7) { + && (mean_areal_precip_global[m].hb5 + .length() == 7)) { temp = mean_areal_precip_global[m].zlz[h]; } else if (l == 0) { @@ -1787,8 +1806,8 @@ public class SaveLevel2Data { for (m = 0; m < 6; m++) { - if ((DailyQcUtils.tdata[j].used[m] == 3 || DailyQcUtils.tdata[j].used[m] == 2) - && qctype_flag[1] == 1) { + if (((DailyQcUtils.tdata[j].used[m] == 3) || (DailyQcUtils.tdata[j].used[m] == 2)) + && (qctype_flag[1] == 1)) { break; } @@ -1800,8 +1819,8 @@ public class SaveLevel2Data { /* re-create all pcpn and maps if necessary */ - if (j == 0 - && (dqc.curHr00_06 == 1 || dqc.curHr06_12 == 1 || dqc.curHr18_00 == 1)) { + if ((j == 0) + && ((dqc.curHr00_06 == 1) || (dqc.curHr06_12 == 1) || (dqc.curHr18_00 == 1))) { // do not estimate } else { @@ -1842,7 +1861,8 @@ public class SaveLevel2Data { for (l = 5; l >= 0; l--) { - if (DailyQcUtils.tdata[j].used[l] == 0 || qctype_flag[1] == -1) { + if ((DailyQcUtils.tdata[j].used[l] == 0) + || (qctype_flag[1] == -1)) { continue; } @@ -1905,7 +1925,7 @@ public class SaveLevel2Data { wqg.write_qpf_grids(dbuf); /* output grid to file in netCDF format */ - if (l + 1 <= num_period_qc) { + if ((l + 1) <= num_period_qc) { if (dqc.mpe_dqc_save_netcdf == true) { WriteDQCNetCDFGrids wng = new WriteDQCNetCDFGrids(); wng.write_dqc_netcdf_grids(fname_nc, l, num_period_qc, @@ -1933,7 +1953,7 @@ public class SaveLevel2Data { } } - num = 150 + j * 4 + 3 - l; + num = (150 + (j * 4) + 3) - l; if (l < 4) { MakeMat mmt = new MakeMat(); @@ -2179,7 +2199,7 @@ public class SaveLevel2Data { for (k = 0; k < 4; k++) { - num = j * 4 + 3 - k; + num = ((j * 4) + 3) - k; if (mean_areal_precip_global[m].tmaps_done[num] == 1) { break foundt; @@ -2245,7 +2265,7 @@ public class SaveLevel2Data { /* fix for polygon basins */ if (dqc.mpe_rfc_name.equalsIgnoreCase("cbrfc") - && mean_areal_precip_global[m].hb5.length() == 7) { + && (mean_areal_precip_global[m].hb5.length() == 7)) { // logMessage ("polygon write\n"); xbuf.append(mean_areal_precip_global[m].bchar .charAt(0)); @@ -2253,12 +2273,12 @@ public class SaveLevel2Data { } else { - if (l == 0 && numzones != 1) { + if ((l == 0) && (numzones != 1)) { xbuf.append("L"); xbuf.append(mean_areal_precip_global[m].bchar .charAt(0)); - } else if (l == 0 && numzones == 1) { + } else if ((l == 0) && (numzones == 1)) { xbuf.append("O"); xbuf.append(mean_areal_precip_global[m].bchar .charAt(0)); @@ -2304,10 +2324,11 @@ public class SaveLevel2Data { for (k = 0; k < 4; k++) { - int h = j * 4 + (3 - k); + int h = (j * 4) + (3 - k); if (dqc.mpe_rfc_name.equalsIgnoreCase("cbrfc") - && mean_areal_precip_global[m].hb5.length() == 7) { + && (mean_areal_precip_global[m].hb5 + .length() == 7)) { temp = mean_areal_precip_global[m].tlz[h]; @@ -2392,8 +2413,8 @@ public class SaveLevel2Data { int pcpn_day = DailyQcUtils.pcpn_day; - if (DailyQcUtils.qpf_flag == true || DailyQcUtils.z_flag == true - || DailyQcUtils.maxmin_flag == true) { + if ((DailyQcUtils.qpf_flag == true) || (DailyQcUtils.z_flag == true) + || (DailyQcUtils.maxmin_flag == true)) { if (DailyQcUtils.qpf_flag == true) { QcPrecipOptionsDialog.dataSet.clear(); @@ -2437,36 +2458,42 @@ public class SaveLevel2Data { int grids_flag = DailyQcUtils.grids_flag; int map_flag = DailyQcUtils.map_flag; - if (points_flag == 1 && pcp_in_use[time_pos] == -1) { + if ((points_flag == 1) && (pcp_in_use[time_pos] == -1)) { k = 0; } - else if (points_flag == 1 && grids_flag == -1 && map_flag == -1) { + else if ((points_flag == 1) && (grids_flag == -1) + && (map_flag == -1)) { k = 0; } - else if (points_flag == -1 && grids_flag == 1 && map_flag == -1) { + else if ((points_flag == -1) && (grids_flag == 1) + && (map_flag == -1)) { k = 1; } - else if (points_flag == -1 && grids_flag == -1 && map_flag == 1) { + else if ((points_flag == -1) && (grids_flag == -1) + && (map_flag == 1)) { k = 2; } - else if (points_flag == 1 && grids_flag == 1 && map_flag == -1) { + else if ((points_flag == 1) && (grids_flag == 1) + && (map_flag == -1)) { k = 3; } - else if (points_flag == 1 && grids_flag == -1 && map_flag == 1) { + else if ((points_flag == 1) && (grids_flag == -1) + && (map_flag == 1)) { k = 4; } - else if (points_flag == -1 && grids_flag == -1 && map_flag == -1) { + else if ((points_flag == -1) && (grids_flag == -1) + && (map_flag == -1)) { k = 5; } - if (DailyQcUtils.qpf_flag == true - && QcPrecipOptionsDialog.isOpen == true) { + if ((DailyQcUtils.qpf_flag == true) + && (QcPrecipOptionsDialog.isOpen == true)) { QcPrecipOptionsDialog.selectDataSetVal(k); } } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcFreezeOptionsDialog.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcFreezeOptionsDialog.java index 22e8e2875d..ed7171e5b6 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcFreezeOptionsDialog.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcFreezeOptionsDialog.java @@ -66,6 +66,7 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener; * Jul, 7 2009 snaples Initial creation * Sep 11, 2013 #2353 lvenable Fixed cursor memory leak. * Mar 10, 2015 14575 snaples Added addtional status flag. + * Jan 15, 2016 5054 randerso Use proper parent shell * * * @@ -113,7 +114,7 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog { private int dqc_good = 0; public static DrawDQCStations ddq; - + private DailyQcUtils dqc; public static ArrayList dataType = new ArrayList(); @@ -124,9 +125,9 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog { OtherFreezeOptions ozo = new OtherFreezeOptions(); -// Zdata[] zdata = new Zdata[0]; + // Zdata[] zdata = new Zdata[0]; -// Ts[] ts; + // Ts[] ts; private int time_pos; @@ -156,33 +157,29 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog { private int getOpts() { int ik = 0; - if (dqc.points_flag == 1 - && dqc.pcp_in_use[time_pos] == -1) { + if (dqc.points_flag == 1 && dqc.pcp_in_use[time_pos] == -1) { ik = 0; - } else if (dqc.points_flag == 1 - && dqc.grids_flag == -1 && dqc.map_flag == -1 - && dqc.contour_flag == -1) { + } else if (dqc.points_flag == 1 && dqc.grids_flag == -1 + && dqc.map_flag == -1 && dqc.contour_flag == -1) { ik = 0; - } else if (dqc.points_flag == -1 - && dqc.grids_flag == 1 && dqc.map_flag == -1) { + } else if (dqc.points_flag == -1 && dqc.grids_flag == 1 + && dqc.map_flag == -1) { ik = 1; - } else if (dqc.points_flag == -1 - && dqc.grids_flag == -1 && dqc.map_flag == 1) { + } else if (dqc.points_flag == -1 && dqc.grids_flag == -1 + && dqc.map_flag == 1) { ik = 2; - } else if (dqc.points_flag == 1 - && dqc.grids_flag == 1 && dqc.map_flag == -1) { + } else if (dqc.points_flag == 1 && dqc.grids_flag == 1 + && dqc.map_flag == -1) { ik = 3; - } else if (dqc.points_flag == 1 - && dqc.grids_flag == -1 && dqc.map_flag == 1) { + } else if (dqc.points_flag == 1 && dqc.grids_flag == -1 + && dqc.map_flag == 1) { ik = 4; - } else if (dqc.points_flag == -1 - && dqc.contour_flag == 1) { + } else if (dqc.points_flag == -1 && dqc.contour_flag == 1) { ik = 5; - } else if (dqc.points_flag == 1 - && dqc.contour_flag == 1) { + } else if (dqc.points_flag == 1 && dqc.contour_flag == 1) { ik = 6; - } else if (dqc.points_flag == -1 - && dqc.grids_flag == -1 && dqc.map_flag == -1) { + } else if (dqc.points_flag == -1 && dqc.grids_flag == -1 + && dqc.map_flag == -1) { ik = 7; } return ik; @@ -216,7 +213,7 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog { dqc_good = dqc.qcDataHasChanged(prevDate, currDate, QcArea, qcDays, false); if (dqc_good == 1) { - SaveLevel2Data s2 = new SaveLevel2Data(); + SaveLevel2Data s2 = new SaveLevel2Data(getShell()); dqc_good = s2.check_new_area(currDate, QcArea, qcDays); if (dqc_good == 0) { dqc_good = dqc.qcDataReload(currDate, QcArea, qcDays, false); @@ -308,13 +305,14 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog { isfinished = true; isOpen = false; font.dispose(); - SaveLevel2Data s2 = new SaveLevel2Data(); + SaveLevel2Data s2 = new SaveLevel2Data(getShell()); s2.send_dbase_new_area(); dqc.clearData(); displayMgr.displayFieldData(df); removePerspectiveListener(); if (MPEDisplayManager.getCurrent() != null) { display.asyncExec(new Runnable() { + @Override public void run() { ChooseDataPeriodDialog dialog = new ChooseDataPeriodDialog( getParent().getShell()); @@ -330,7 +328,7 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog { * Initialize the dialog components. */ private void initializeComponents() { -// zdata = DailyQcUtils.zdata; + // zdata = DailyQcUtils.zdata; dqc.points_flag = 1; dqc.grids_flag = -1; dqc.map_flag = -1; @@ -342,7 +340,7 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog { // checks to see if area or date has changed since last data load DailyQcUtils dqcu = new DailyQcUtils(); dqc_good = dqcu.qcDataReload(currDate, QcArea, qcDays, false); -// dqc.zdata = DailyQcUtils.zdata; + // dqc.zdata = DailyQcUtils.zdata; if (MPEDisplayManager.pcpn_time_step != 0) { MPEDisplayManager.pcpn_time_step = 0; dqc.pcpn_time = 0; @@ -366,7 +364,7 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog { } } -// ts = DailyQcUtils.ts; + // ts = DailyQcUtils.ts; this.createDataOptionsGroup(); this.createPointSetComp(); this.createPointControlComp(); diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcPrecipOptionsDialog.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcPrecipOptionsDialog.java index 34d9047d91..acbf229362 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcPrecipOptionsDialog.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcPrecipOptionsDialog.java @@ -70,6 +70,8 @@ import com.raytheon.viz.mpe.util.DailyQcUtils; * Sep 11, 2015 17988 snaples Fixed issue with wait cursor not showing when Rendering Grids. * Nov 18, 2015 18093 snaples Fixed problem with arrows being disabled when new * day rollover >18Z occurs. + * Jan 15, 2016 5054 randerso Use proper parent shell + * * * * @author snaples @@ -132,9 +134,9 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog { private static boolean isfinished = true; private static int dqc_good = 0; - + public static DrawDQCStations ddq; - + private DailyQcUtils dqc; public static ArrayList dataType = new ArrayList(); @@ -143,11 +145,11 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog { OtherPrecipOptions opo = new OtherPrecipOptions(); -// int[] pcp_in_use; + // int[] pcp_in_use; -// Pdata[] pdata = new Pdata[0]; + // Pdata[] pdata = new Pdata[0]; -// Ts[] ts; + // Ts[] ts; private int time_pos; @@ -158,7 +160,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog { final GageQcSelect gq = new GageQcSelect(); int i = 0; - + /** * Constructor. * @@ -169,12 +171,13 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog { super(parent); MPEDisplayManager.getCurrent().setQpf(true); dqc = DailyQcUtils.getInstance(); - + } private int getOpts() { int ik = 0; - if (DailyQcUtils.points_flag == 1 && DailyQcUtils.pcp_in_use[time_pos] == -1) { + if (DailyQcUtils.points_flag == 1 + && DailyQcUtils.pcp_in_use[time_pos] == -1) { ik = 0; } else if (DailyQcUtils.points_flag == 1 && DailyQcUtils.grids_flag == -1 && DailyQcUtils.map_flag == -1 @@ -220,7 +223,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog { String QcArea = ChooseDataPeriodDialog.prevArea; AppsDefaults appDefaults = AppsDefaults.getInstance(); DisplayFieldData df = displayMgr.getDisplayFieldType(); - + if (currDate == null) { currDate = prevDate; } @@ -234,7 +237,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog { dqc_good = dqc.qcDataHasChanged(prevDate, currDate, QcArea, qcDays, false); if (dqc_good == 1) { - SaveLevel2Data s2 = new SaveLevel2Data(); + SaveLevel2Data s2 = new SaveLevel2Data(getShell()); dqc_good = s2.check_new_area(currDate, QcArea, qcDays); if (dqc_good == 0) { dqc_good = dqc.qcDataReload(currDate, QcArea, qcDays, false); @@ -312,14 +315,15 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog { isfinished = true; isOpen = false; font.dispose(); - SaveLevel2Data s2 = new SaveLevel2Data(); + SaveLevel2Data s2 = new SaveLevel2Data(getShell()); s2.send_dbase_new_area(); -// DailyQcUtils dc = new DailyQcUtils(); + // DailyQcUtils dc = new DailyQcUtils(); dqc.clearData(); displayMgr.displayFieldData(df); removePerspectiveListener(); if (MPEDisplayManager.getCurrent() != null) { display.asyncExec(new Runnable() { + @Override public void run() { ChooseDataPeriodDialog dialog = new ChooseDataPeriodDialog( getParent().getShell()); @@ -365,7 +369,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog { } } -// ts = DailyQcUtils.ts; + // ts = DailyQcUtils.ts; this.createDataOptionsGroup(); this.createPointTypeGroup(); this.createPointQualityGroup(); @@ -418,8 +422,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog { } }); if (DailyQcUtils.qcDays == 1 - && (dqc.curHr18_00 == 1 - || dqc.curHr00_06 == 1 || dqc.curHr06_12 == 1)) { + && (dqc.curHr18_00 == 1 || dqc.curHr00_06 == 1 || dqc.curHr06_12 == 1)) { selsix24Cbo.setEnabled(false); } else { selsix24Cbo.setEnabled(true); @@ -499,7 +502,8 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog { renderGridsBtn = new Button(renderComp, SWT.PUSH); renderGridsBtn.setText("Render Grids+MAPs"); renderGridsBtn.setLayoutData(gd); - if (DailyQcUtils.pcp_in_use[time_pos] == -1 && DailyQcUtils.pdata[i].used[4] != 0) { + if (DailyQcUtils.pcp_in_use[time_pos] == -1 + && DailyQcUtils.pdata[i].used[4] != 0) { renderGridsBtn.setEnabled(true); } else { renderGridsBtn.setEnabled(false); @@ -669,8 +673,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog { boolean mpe_show_missing_gage_set = false; if (dqc.mpe_show_missing_gage.length() > 0) { if ((dqc.mpe_show_missing_gage.equalsIgnoreCase("All")) - || (dqc.mpe_show_missing_gage - .equalsIgnoreCase("Reported"))) { + || (dqc.mpe_show_missing_gage.equalsIgnoreCase("Reported"))) { mpe_show_missing_gage_set = true; } else { mpe_show_missing_gage_set = false; diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcTempOptionsDialog.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcTempOptionsDialog.java index c93c64d75c..9d52cec446 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcTempOptionsDialog.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcTempOptionsDialog.java @@ -63,6 +63,7 @@ import com.raytheon.viz.mpe.util.DailyQcUtils; * Nov 12, 2008 snaples Initial creation * Sep 11, 2013 #2353 lvenable Fixed cursor memory leak. * Mar 10, 2015 14575 snaples Added status flag. + * Jan 15, 2016 5054 randerso Use proper parent shell * * * @@ -118,7 +119,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog { private int dqc_good = 0; public static DrawDQCStations ddq; - + private DailyQcUtils dqc; public static ArrayList dataType = new ArrayList(); @@ -129,9 +130,9 @@ public class QcTempOptionsDialog extends AbstractMPEDialog { OtherTempOptions oto = new OtherTempOptions(); -// Tdata[] tdata = new Tdata[0]; + // Tdata[] tdata = new Tdata[0]; -// Ts[] ts; + // Ts[] ts; private int time_pos; @@ -157,33 +158,29 @@ public class QcTempOptionsDialog extends AbstractMPEDialog { private int getOpts() { int ik = 0; - if (dqc.points_flag == 1 - && dqc.pcp_in_use[time_pos] == -1) { + if (dqc.points_flag == 1 && dqc.pcp_in_use[time_pos] == -1) { ik = 0; - } else if (dqc.points_flag == 1 - && dqc.grids_flag == -1 && dqc.map_flag == -1 - && dqc.contour_flag == -1) { + } else if (dqc.points_flag == 1 && dqc.grids_flag == -1 + && dqc.map_flag == -1 && dqc.contour_flag == -1) { ik = 0; - } else if (dqc.points_flag == -1 - && dqc.grids_flag == 1 && dqc.map_flag == -1) { + } else if (dqc.points_flag == -1 && dqc.grids_flag == 1 + && dqc.map_flag == -1) { ik = 1; - } else if (dqc.points_flag == -1 - && dqc.grids_flag == -1 && dqc.map_flag == 1) { + } else if (dqc.points_flag == -1 && dqc.grids_flag == -1 + && dqc.map_flag == 1) { ik = 2; - } else if (dqc.points_flag == 1 - && dqc.grids_flag == 1 && dqc.map_flag == -1) { + } else if (dqc.points_flag == 1 && dqc.grids_flag == 1 + && dqc.map_flag == -1) { ik = 3; - } else if (dqc.points_flag == 1 - && dqc.grids_flag == -1 && dqc.map_flag == 1) { + } else if (dqc.points_flag == 1 && dqc.grids_flag == -1 + && dqc.map_flag == 1) { ik = 4; - } else if (dqc.points_flag == -1 - && dqc.contour_flag == 1) { + } else if (dqc.points_flag == -1 && dqc.contour_flag == 1) { ik = 5; - } else if (dqc.points_flag == 1 - && dqc.contour_flag == 1) { + } else if (dqc.points_flag == 1 && dqc.contour_flag == 1) { ik = 6; - } else if (dqc.points_flag == -1 - && dqc.grids_flag == -1 && dqc.map_flag == -1) { + } else if (dqc.points_flag == -1 && dqc.grids_flag == -1 + && dqc.map_flag == -1) { ik = 7; } return ik; @@ -217,7 +214,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog { dqc_good = dqc.qcDataHasChanged(prevDate, currDate, QcArea, qcDays, false); if (dqc_good == 1) { - SaveLevel2Data s2 = new SaveLevel2Data(); + SaveLevel2Data s2 = new SaveLevel2Data(getShell()); dqc_good = s2.check_new_area(currDate, QcArea, qcDays); if (dqc_good == 0) { dqc_good = dqc.qcDataReload(currDate, QcArea, qcDays, false); @@ -295,7 +292,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog { isfinished = true; isOpen = false; font.dispose(); - SaveLevel2Data s2 = new SaveLevel2Data(); + SaveLevel2Data s2 = new SaveLevel2Data(getShell()); s2.send_dbase_new_area(); DailyQcUtils dc = new DailyQcUtils(); dc.clearData(); @@ -303,6 +300,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog { removePerspectiveListener(); if (MPEDisplayManager.getCurrent() != null) { display.asyncExec(new Runnable() { + @Override public void run() { ChooseDataPeriodDialog dialog = new ChooseDataPeriodDialog( getParent().getShell()); @@ -318,7 +316,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog { * Initialize the dialog components. */ private void initializeComponents() { -// tdata = DailyQcUtils.tdata; + // tdata = DailyQcUtils.tdata; dqc.points_flag = 1; dqc.grids_flag = -1; dqc.map_flag = -1; @@ -332,7 +330,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog { int qcDays = MPEDisplayManager.getCurrent().getDqcDays(); // checks to see if area or date has changed since last data load dqc_good = dqc.qcDataReload(currDate, QcArea, qcDays, false); -// tdata = DailyQcUtils.tdata; + // tdata = DailyQcUtils.tdata; } dataSet.clear(); @@ -357,7 +355,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog { } } -// ts = DailyQcUtils.ts; + // ts = DailyQcUtils.ts; this.createDataOptionsGroup(); this.createPointTypeGroup(); this.createPointQualityGroup(); @@ -407,8 +405,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog { } }); if (dqc.qcDays == 1 - && (dqc.curHr18_00 == 1 - || dqc.curHr00_06 == 1 || dqc.curHr06_12 == 1)) { + && (dqc.curHr18_00 == 1 || dqc.curHr00_06 == 1 || dqc.curHr06_12 == 1)) { maxminTimeCbo.setEnabled(false); } else { maxminTimeCbo.setEnabled(true); @@ -471,8 +468,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog { renderGridsBtn = new Button(renderComp, SWT.PUSH); renderGridsBtn.setText("Render Grids+MATs"); renderGridsBtn.setLayoutData(gd); - if (dqc.pcp_in_use[time_pos] == -1 - && dqc.tdata[i].used[4] != 0) { + if (dqc.pcp_in_use[time_pos] == -1 && dqc.tdata[i].used[4] != 0) { renderGridsBtn.setEnabled(true); } else { renderGridsBtn.setEnabled(false); @@ -607,10 +603,10 @@ public class QcTempOptionsDialog extends AbstractMPEDialog { pointQualGroup.setLayoutData(gd); int i; -// int qflag[] = dqc.qflag; + // int qflag[] = dqc.qflag; for (i = 0; i < 10; i++) { - dqc.qflag[i] = 1; + dqc.qflag[i] = 1; } // qflag[5] = -1; @@ -618,8 +614,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog { boolean mpe_show_missing_gage_set = false; if (dqc.mpe_show_missing_gage.length() > 0) { if ((dqc.mpe_show_missing_gage.equalsIgnoreCase("All")) - || (dqc.mpe_show_missing_gage - .equalsIgnoreCase("Reported"))) { + || (dqc.mpe_show_missing_gage.equalsIgnoreCase("Reported"))) { mpe_show_missing_gage_set = true; } else { mpe_show_missing_gage_set = false; diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DeletePolygonDlg.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DeletePolygonDlg.java index 7df54c8c8b..a0d9e62d9c 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DeletePolygonDlg.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DeletePolygonDlg.java @@ -57,6 +57,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * displayed for polygons with * the "sub" action. * Jan 7, 2015 16954 cgobs Fix for cv_use issue - using getFieldName() in certain parts. + * Feb 15, 2016 5338 bkowal Keep track of any persistent polygons that are deleted. * * * @author mpduff @@ -287,7 +288,7 @@ public class DeletePolygonDlg extends CaveSWTDialog { polygonListBox.removeAll(); String type = displayManager.getDisplayFieldType().getFieldName(); - + productTF.setText(type); polygonList = PolygonEditManager.getPolygonEdits(fieldData, editDate); recreatePolygonListBox(); @@ -348,8 +349,9 @@ public class DeletePolygonDlg extends CaveSWTDialog { return; } // Remove selected from list and apply - polygonList.remove(polygonListBox.getSelectionIndex()); - applyPolygonList(); + RubberPolyData polygon = polygonList.remove(polygonListBox + .getSelectionIndex()); + applyPolygonList(polygon.isPersistent()); } /** @@ -357,8 +359,15 @@ public class DeletePolygonDlg extends CaveSWTDialog { */ private void deleteAll() { // Clear the list and apply + boolean persistentRemoved = false; + for (RubberPolyData polygon : polygonList) { + if (polygon.isPersistent()) { + persistentRemoved = true; + break; + } + } polygonList.clear(); - applyPolygonList(); + applyPolygonList(persistentRemoved); } /** @@ -374,15 +383,16 @@ public class DeletePolygonDlg extends CaveSWTDialog { if (polygon >= 0 && polygon < polygonList.size()) { RubberPolyData data = polygonList.get(polygon); data.setVisible(display); - applyPolygonList(); + applyPolygonList(false); } } - private void applyPolygonList() { + private void applyPolygonList(boolean persistentRemoved) { MPEDisplayManager displayManager = MPEDisplayManager.getCurrent(); DisplayFieldData fieldData = displayManager.getDisplayFieldType(); Date editDate = displayManager.getCurrentEditDate(); - PolygonEditManager.writePolygonEdits(fieldData, editDate, polygonList); + PolygonEditManager.writePolygonEdits(fieldData, editDate, polygonList, + persistentRemoved); recreatePolygonListBox(); } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DrawPolygonDlg.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DrawPolygonDlg.java index 094dcb01f1..5865a67e36 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DrawPolygonDlg.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DrawPolygonDlg.java @@ -66,6 +66,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Apr 28, 2014 16707 snaples Added code to save and set location of dialog box when moved. * Jan 12, 2015 16993 snaples Restored code for Substitute Field Combo box. * Feb 26, 2015 17209 cgobs Ensured that there is an initial selection of Substitution field, prevents empty selection. + * Feb 15, 2016 5338 bkowal Remove commented code. Cleanup. * * * @@ -80,9 +81,10 @@ public class DrawPolygonDlg extends CaveSWTDialog { private static final String MAKE_PERSISTENT = "Make Persistent"; - private DisplayFieldData[] displayFieldDataArray; + private DisplayFieldData[] displayFieldDataArray; + private String[] displayTypeNameArray; - + /** * Bold Font. */ @@ -96,8 +98,8 @@ public class DrawPolygonDlg extends CaveSWTDialog { /** * The field type selection Combo control. */ - private Combo fieldTypeCombo = null; - + private Combo fieldTypeCombo = null; + /** * The precip value spinner control. */ @@ -126,12 +128,12 @@ public class DrawPolygonDlg extends CaveSWTDialog { /** The polygon resource */ private final MPEPolygonResource resource; - + /** Point to hold location of dialog */ - private static org.eclipse.swt.graphics.Point dlgLoc = null; + private static org.eclipse.swt.graphics.Point dlgLoc = null; /** Status of dialog opened or not */ - private boolean dialogOpened = false; + private boolean dialogOpened = false; /** * Constructor. @@ -170,21 +172,21 @@ public class DrawPolygonDlg extends CaveSWTDialog { font = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); // Initialize all of the controls and layoutsendCal initializeComponents(); - shell.addControlListener(new ControlAdapter() { - @Override - public void controlMoved(ControlEvent e) { - if (!dialogOpened) { - return; - } + shell.addControlListener(new ControlAdapter() { + @Override + public void controlMoved(ControlEvent e) { + if (!dialogOpened) { + return; + } - if (dlgLoc == null) { - return; - } + if (dlgLoc == null) { + return; + } - dlgLoc.x = shell.getBounds().x; - dlgLoc.y = shell.getBounds().y; - } - }); + dlgLoc.x = shell.getBounds().x; + dlgLoc.y = shell.getBounds().y; + } + }); } /** @@ -196,17 +198,16 @@ public class DrawPolygonDlg extends CaveSWTDialog { createCloseBtn(); } - @Override - protected void opened() { - if (dlgLoc == null) { - dlgLoc = new org.eclipse.swt.graphics.Point(shell.getBounds().x, shell.getBounds().y); - } - else { - shell.setLocation(dlgLoc); - } - dialogOpened = true; - } - + @Override + protected void opened() { + if (dlgLoc == null) { + dlgLoc = new org.eclipse.swt.graphics.Point(shell.getBounds().x, + shell.getBounds().y); + } else { + shell.setLocation(dlgLoc); + } + dialogOpened = true; + } /** * Create the persistent group. @@ -361,7 +362,7 @@ public class DrawPolygonDlg extends CaveSWTDialog { */ private void createFieldCombo(Group groupComp) { // Spacer - + // Create a container to hold the label and the combo box. GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); Composite prodListComp = new Composite(shell, SWT.NONE); @@ -377,83 +378,58 @@ public class DrawPolygonDlg extends CaveSWTDialog { gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); fieldTypeCombo = new Combo(groupComp, SWT.LEFT | SWT.DROP_DOWN | SWT.READ_ONLY); - - if (displayFieldDataArray == null) - { - displayFieldDataArray = MPEDisplayManager.mpe_qpe_fields; + + if (displayFieldDataArray == null) { + displayFieldDataArray = MPEDisplayManager.mpe_qpe_fields; } - - // Label spaceLabel = new Label(groupComp, SWT.NONE); - // spaceLabel.setText("***** "); - + int selectedFieldIndex = 0; boolean found = false; - //find the index of the selected field - for (selectedFieldIndex = 0; selectedFieldIndex < displayFieldDataArray.length; selectedFieldIndex++) - { - if (displayFieldDataArray[selectedFieldIndex] == subType) - { + // find the index of the selected field + for (selectedFieldIndex = 0; selectedFieldIndex < displayFieldDataArray.length; selectedFieldIndex++) { + if (displayFieldDataArray[selectedFieldIndex] == subType) { found = true; break; } } - - if (!found) - { + + if (!found) { selectedFieldIndex = 0; } - - //create and initialize the display field type name array + + // create and initialize the display field type name array displayTypeNameArray = new String[displayFieldDataArray.length]; - + for (int i = 0; i < displayFieldDataArray.length; i++) { - - String fieldName = displayFieldDataArray[i].toString(); - // System.out.println("DrawPolygon.createFieldCombo(): FieldName = :" + fieldName + ":"); + + String fieldName = displayFieldDataArray[i].toString(); displayTypeNameArray[i] = fieldName; } - - //select the field + + // select the field fieldTypeCombo.setTextLimit(35); fieldTypeCombo.setLayoutData(gd); fieldTypeCombo.setItems(displayTypeNameArray); - // fieldTypeCombo.select(selectedFieldIndex); - + fieldTypeCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - setSubstitutionField(); - -// String selectedFieldString = fieldTypeCombo.getText(); - - // System.out.println("DrawPolygon.createFieldCombo(): selectedFieldString = " + - // selectedFieldString); - - // subType = DisplayFieldData.fromDisplayNameString(selectedFieldString); - - // if (subType != null) - // { - // System.out.println("DrawPolygon.createFieldCombo(): subType = " + - // subType.toString()); - // } - } + } }); - - //select the substitution field - + + // select the substitution field + fieldTypeCombo.select(selectedFieldIndex); setSubstitutionField(); - + } - - private void setSubstitutionField() - { + + private void setSubstitutionField() { String selectedFieldString = fieldTypeCombo.getText(); subType = DisplayFieldData.fromDisplayNameString(selectedFieldString); - + } - /** * Process the selection. @@ -490,7 +466,7 @@ public class DrawPolygonDlg extends CaveSWTDialog { .getPolygonEdits(displayedField, editDate); polygonEdits.add(newEdit); PolygonEditManager.writePolygonEdits(displayedField, editDate, - polygonEdits); + polygonEdits, false); resource.clearPolygons(); dispMgr.setSavedData(false); } finally { diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/IPolygonEditsChangedListener.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/IPolygonEditsChangedListener.java index e96855ae42..533c2af6e7 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/IPolygonEditsChangedListener.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/IPolygonEditsChangedListener.java @@ -34,6 +34,8 @@ import com.raytheon.viz.mpe.ui.DisplayFieldData; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jan 2, 2013 mschenke Initial creation + * Feb 15, 2016 5338 bkowal Updated to provide information about which + * persistent polygons remain after the edit. * * * @@ -44,6 +46,7 @@ import com.raytheon.viz.mpe.ui.DisplayFieldData; public interface IPolygonEditsChangedListener { public void polygonEditsChanged(DisplayFieldData field, Date date, - List polygonEdits); + List polygonEdits, + List persistentRemaining); } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/PolygonEditManager.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/PolygonEditManager.java index e755ddf582..b5dc835027 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/PolygonEditManager.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/PolygonEditManager.java @@ -69,6 +69,8 @@ import com.raytheon.viz.mpe.ui.dialogs.polygon.RubberPolyData.PolygonEditAction; * files are written. * Jul 15, 2013 15963 snaples Removed polygon edit flag, and * removed unneeded Constant for Backward compatibility. + * Feb 15, 2016 5338 bkowal Keep track of the remaining persistent polygons just + * in case a refresh is required. * * * @@ -209,11 +211,12 @@ public class PolygonEditManager { } public static void writePolygonEdits(DisplayFieldData fieldData, Date date, - List polygonEdits) { + List polygonEdits, boolean persistentRemoved) { orderPolygonEdits(polygonEdits); File hourlyFile = getHourlyEditFile(fieldData, date); StringBuilder hourlyBuffer = new StringBuilder(); + List persistentRemaining = new ArrayList<>(); File persistentFile = getPersistentEditFile(fieldData, date); StringBuilder persistentBuffer = new StringBuilder(); @@ -225,6 +228,7 @@ public class PolygonEditManager { StringBuilder toUse = null; int idx = 0; if (polyEdit.isPersistent()) { + persistentRemaining.add(polyEdit); persistOrder++; toUse = persistentBuffer; idx = persistOrder; @@ -290,9 +294,13 @@ public class PolygonEditManager { toNotify = new LinkedHashSet( listeners); } + if (!persistentRemoved) { + persistentRemaining = null; + } for (IPolygonEditsChangedListener listener : toNotify) { listener.polygonEditsChanged(fieldData, date, - new ArrayList(polygonEdits)); + new ArrayList(polygonEdits), + persistentRemaining); } } @@ -354,8 +362,8 @@ public class PolygonEditManager { DisplayFieldData subData = null; for (DisplayFieldData fieldData : DisplayFieldData .values()) { - if (fieldData.getFieldName() - .equalsIgnoreCase(subCvUse)) { + if (fieldData.getFieldName().equalsIgnoreCase( + subCvUse)) { subData = fieldData; break; } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/DPAResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/DPAResource.java index d122737526..da647e4936 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/DPAResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/DPAResource.java @@ -78,8 +78,9 @@ import com.vividsolutions.jts.geom.Coordinate; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jul 28, 2009 2675 mpduff Initial creation - * Aug 13, 2009 2675 mpduff TIM Changes added + * Jul 28, 2009 2675 mpduff Initial creation + * Aug 13, 2009 2675 mpduff TIM Changes added + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling * * * @@ -96,13 +97,12 @@ public class DPAResource extends private static final String RADAR_IGNORED = "Radar Data Ignored"; private static final String ALL_ZERO = "Radar Data All Zero"; - + /** Radar types */ public static enum SingleSiteRadarType { - RAW_SP_RADAR("Raw SP Radar"), - RAW_DP_RADAR("Raw DP Radar"), - MEAN_FIELD_BIAS_CORRECTED_SP_RADAR("Mean Field Bias Corrected SP Radar"), - RADAR_COVERAGE_MAP("Radar Coverage Map"); + RAW_SP_RADAR("Raw SP Radar"), RAW_DP_RADAR("Raw DP Radar"), MEAN_FIELD_BIAS_CORRECTED_SP_RADAR( + "Mean Field Bias Corrected SP Radar"), RADAR_COVERAGE_MAP( + "Radar Coverage Map"); private String text; @@ -112,7 +112,7 @@ public class DPAResource extends } private DPAFile dpaFile; - + /** The HRAP subgrid */ private HRAPSubGrid subGrid; @@ -150,15 +150,15 @@ public class DPAResource extends private DrawableString mainString; private DrawableString ignoredStr; - + private DrawableString allZeroStr; - + private int available = 0; - //private SingleSiteRadarType radarType = SingleSiteRadarType.RAW_SP_RADAR; - + // private SingleSiteRadarType radarType = SingleSiteRadarType.RAW_SP_RADAR; + private SingleSiteRadarType radarType; - + private boolean ignored = false; private Date lastDate = null; @@ -190,7 +190,7 @@ public class DPAResource extends getCapability(ColorableCapability.class).setColor( RGBColors.getRGBColor("Yellow")); } - + /* * (non-Javadoc) * @@ -226,9 +226,9 @@ public class DPAResource extends return dpaFile.getFile().getAbsolutePath(); } - -//------------------------------------------------------------------- - + + // ------------------------------------------------------------------- + /* * (non-Javadoc) * @@ -284,146 +284,131 @@ public class DPAResource extends parameters.setDataMin(0); UnitConverter cvt = parameters.getDataToImageConverter(); - - try - { - buf = FloatBuffer.allocate(17161); - Date dtg = MPEDisplayManager.getCurrent().getCurrentEditDate(); - // available = radar availability flag read from - // RWRadarResult or DAARadarResult table - // = 0 -- field available (some values > 0.0) - // = 1 -- field not available - // = 2 -- field available (all values = 0.0) + try { + buf = FloatBuffer.allocate(17161); + Date dtg = MPEDisplayManager.getCurrent().getCurrentEditDate(); - available = 0; - if (radarType == SingleSiteRadarType.RAW_DP_RADAR) - { - available = RadarDataManager.getInstance() - .getAvailableRadarDP(radId, dtg); - } - else - { - available = RadarDataManager.getInstance() - .getAvailableRadarSP(radId, dtg); + // available = radar availability flag read from + // RWRadarResult or DAARadarResult table + // = 0 -- field available (some values > 0.0) + // = 1 -- field not available + // = 2 -- field available (all values = 0.0) - // check for special case of ignored radar - // this behavior is different than A1 - ignored = RadarDataManager.getInstance() - .getIgnoreRadarSP(radId, dtg); - if(ignored) available = 0; - } + available = 0; + if (radarType == SingleSiteRadarType.RAW_DP_RADAR) { + available = RadarDataManager.getInstance().getAvailableRadarDP( + radId, dtg); + } else { + available = RadarDataManager.getInstance().getAvailableRadarSP( + radId, dtg); - if (available == 0) - { - - dpaFile.load(); - if (radarType == SingleSiteRadarType.RAW_SP_RADAR) - { - System.out.println("DPAResource: Reading SP Radar Data "); + // check for special case of ignored radar + // this behavior is different than A1 + ignored = RadarDataManager.getInstance().getIgnoreRadarSP( + radId, dtg); + if (ignored) { + available = 0; + } + } + + if (available == 0) { + + dpaFile.load(); + if (radarType == SingleSiteRadarType.RAW_SP_RADAR) { + System.out.println("DPAResource: Reading SP Radar Data "); data = dpaFile.getStage1i(); - } - else if (radarType == SingleSiteRadarType.RAW_DP_RADAR) - { - System.out.println("DPAResource: Reading DP Radar Data "); - data = dpaFile.getStage1i(); - } - else if (radarType == SingleSiteRadarType.MEAN_FIELD_BIAS_CORRECTED_SP_RADAR) - { - System.out.println("DPAResource: Reading MFB Corrected SP Radar Data "); + } else if (radarType == SingleSiteRadarType.RAW_DP_RADAR) { + System.out.println("DPAResource: Reading DP Radar Data "); + data = dpaFile.getStage1i(); + } else if (radarType == SingleSiteRadarType.MEAN_FIELD_BIAS_CORRECTED_SP_RADAR) { + System.out + .println("DPAResource: Reading MFB Corrected SP Radar Data "); data = dpaFile.getStage1u(); - } - else - { + } else { data = dpaFile.getZeroData(); } - - for (int i = 0; i < 131; i++) { - for (int j = 0; j < 131; j++) { - float f = -9999; - if (data[i][j] != -9999) { - f = (float) Math.floor(cvt.convert(data[i][j])); - } - int dx = i - 66; - int dy = j - 66; - double dist = Math.sqrt(dx * dx + dy * dy); + for (int i = 0; i < 131; i++) { + for (int j = 0; j < 131; j++) { + float f = -9999; + if (data[i][j] != -9999) { + f = (float) Math.floor(cvt.convert(data[i][j])); + } - // If grid cell outside radius then set missing - if (dist > ngrd) { - f = -9999; - } - buf.put(f); - } - } - buf.rewind(); - missingData = false; - } - else if (available == 2) - { - for (int i = 0; i < 131; i++) { - for (int j = 0; j < 131; j++) { - buf.put(0.0f); - } - } - buf.rewind(); - missingData = false; - } - else - { - for (int i = 0; i < 131; i++) { - for (int j = 0; j < 131; j++) { - buf.put(-1f); - } - } - buf.rewind(); - missingData = true; - } + int dx = i - 66; + int dy = j - 66; + double dist = Math.sqrt(dx * dx + dy * dy); - /* Retrieve the Latitude/Longitude of the radars */ - Coordinate latLon; - List radarList = MPEDataManager.getInstance() - .getRadars(); - for (MPERadarLoc radarLoc : radarList) { - if (radarLoc.getId().equalsIgnoreCase(radId)) { - latLon = radarLoc.getLatLon(); - if (latLon == null) { - continue; - } - if ((latLon.x == 0.) || (latLon.y == 0.)) { - continue; - } + // If grid cell outside radius then set missing + if (dist > ngrd) { + f = -9999; + } + buf.put(f); + } + } + buf.rewind(); + missingData = false; + } else if (available == 2) { + for (int i = 0; i < 131; i++) { + for (int j = 0; j < 131; j++) { + buf.put(0.0f); + } + } + buf.rewind(); + missingData = false; + } else { + for (int i = 0; i < 131; i++) { + for (int j = 0; j < 131; j++) { + buf.put(-1f); + } + } + buf.rewind(); + missingData = true; + } - /* calculate HRAP coordinates from lat,lon */ - Coordinate hp = new Coordinate(0, 0); - hp = HRAP.getInstance().latLonToGridCoordinate(latLon, - PixelOrientation.UPPER_LEFT); - int minx = (int) hp.x - 65; - int miny = (int) hp.y - 65; + /* Retrieve the Latitude/Longitude of the radars */ + Coordinate latLon; + List radarList = MPEDataManager.getInstance() + .getRadars(); + for (MPERadarLoc radarLoc : radarList) { + if (radarLoc.getId().equalsIgnoreCase(radId)) { + latLon = radarLoc.getLatLon(); + if (latLon == null) { + continue; + } + if ((latLon.x == 0.) || (latLon.y == 0.)) { + continue; + } - extent = new Rectangle(minx, miny, 131, 131); - break; - } - } + /* calculate HRAP coordinates from lat,lon */ + Coordinate hp = new Coordinate(0, 0); + hp = HRAP.getInstance().latLonToGridCoordinate(latLon, + PixelOrientation.UPPER_LEFT); + int minx = (int) hp.x - 65; + int miny = (int) hp.y - 65; - if ((extent.x == 0) && (extent.y == 0)) { - Rectangle coord = HRAPCoordinates.getHRAPCoordinates(); - if ((extent.width == coord.width) - && (extent.height == coord.height)) { - extent = coord; - } else { - dpaFile = null; - return; - } - } - subGrid = new HRAPSubGrid(extent); + extent = new Rectangle(minx, miny, 131, 131); + break; + } + } - gridGeometry = MapUtil.getGridGeometry(subGrid); + if ((extent.x == 0) && (extent.y == 0)) { + Rectangle coord = HRAPCoordinates.getHRAPCoordinates(); + if ((extent.width == coord.width) + && (extent.height == coord.height)) { + extent = coord; + } else { + dpaFile = null; + return; + } + } + subGrid = new HRAPSubGrid(extent); - project(gridGeometry.getCoordinateReferenceSystem()); - } - catch (Exception e) - { + gridGeometry = MapUtil.getGridGeometry(subGrid); + + project(gridGeometry.getCoordinateReferenceSystem()); + } catch (Exception e) { dpaFile = null; e.printStackTrace(); } @@ -433,26 +418,25 @@ public class DPAResource extends ignoredStr = new DrawableString(RADAR_IGNORED, RGBColors.getRGBColor("Red")); allZeroStr = new DrawableString(ALL_ZERO, - RGBColors.getRGBColor("Green")); + RGBColors.getRGBColor("Green")); if (missingData && (radarType == SingleSiteRadarType.MEAN_FIELD_BIAS_CORRECTED_SP_RADAR - || radarType == SingleSiteRadarType.RAW_SP_RADAR - || radarType == SingleSiteRadarType.RAW_DP_RADAR)) - { + || radarType == SingleSiteRadarType.RAW_SP_RADAR || radarType == SingleSiteRadarType.RAW_DP_RADAR)) { missingString = new DrawableString(MISSING_DATA, getCapability( ColorableCapability.class).getColor()); } - ignoredStr.font = allZeroStr.font = mainString.font = target.initializeFont("Dialog", 12, null); + ignoredStr.font = allZeroStr.font = mainString.font = target + .initializeFont("Dialog", 10, null); if (missingString != null) { missingString.font = mainString.font; } - + } -//--------------------------------------------------------------- + // --------------------------------------------------------------- /* * (non-Javadoc) * @@ -503,19 +487,17 @@ public class DPAResource extends Date date = MPEDisplayManager.getCurrent().getCurrentEditDate(); if (date.equals(lastDate) == false) { // Check for ignored Radar - if (radarType.equals(SingleSiteRadarType.RAW_SP_RADAR) || - radarType.equals(SingleSiteRadarType.MEAN_FIELD_BIAS_CORRECTED_SP_RADAR)) - { - ignored = RadarDataManager.getInstance() - .getIgnoreRadarSP(radId, date); - lastDate = date; - } - else if (radarType.equals(SingleSiteRadarType.RAW_DP_RADAR)) - { - ignored = RadarDataManager.getInstance() - .getIgnoreRadarDP(radId, date); - lastDate = date; - } + if (radarType.equals(SingleSiteRadarType.RAW_SP_RADAR) + || radarType + .equals(SingleSiteRadarType.MEAN_FIELD_BIAS_CORRECTED_SP_RADAR)) { + ignored = RadarDataManager.getInstance().getIgnoreRadarSP( + radId, date); + lastDate = date; + } else if (radarType.equals(SingleSiteRadarType.RAW_DP_RADAR)) { + ignored = RadarDataManager.getInstance().getIgnoreRadarDP( + radId, date); + lastDate = date; + } } if (missingString != null) { @@ -530,18 +512,17 @@ public class DPAResource extends screenExtent.getMaxY() - 25, 0.0); target.drawStrings(ignoredStr); } - - else if (ignored && (radarType == SingleSiteRadarType.RAW_DP_RADAR)) - { - ignoredStr.setCoordinates(screenExtent.getMinX() + 50, - screenExtent.getMaxY() - 25, 0.0); - target.drawStrings(ignoredStr); + + else if (ignored && (radarType == SingleSiteRadarType.RAW_DP_RADAR)) { + ignoredStr.setCoordinates(screenExtent.getMinX() + 50, + screenExtent.getMaxY() - 25, 0.0); + target.drawStrings(ignoredStr); } - if (available == 2 && (radarType == SingleSiteRadarType.RAW_DP_RADAR || radarType == SingleSiteRadarType.RAW_SP_RADAR)) - { - allZeroStr.setCoordinates(screenExtent.getMinX() + 600, - screenExtent.getMaxY() - 25, 0.0); - target.drawStrings(allZeroStr); + if (available == 2 + && (radarType == SingleSiteRadarType.RAW_DP_RADAR || radarType == SingleSiteRadarType.RAW_SP_RADAR)) { + allZeroStr.setCoordinates(screenExtent.getMinX() + 600, + screenExtent.getMaxY() - 25, 0.0); + target.drawStrings(allZeroStr); } } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEFieldResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEFieldResource.java index 56f7128954..83cc7e7619 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEFieldResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEFieldResource.java @@ -30,11 +30,13 @@ import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import javax.measure.converter.UnitConverter; +import org.apache.commons.collections.CollectionUtils; import org.eclipse.swt.graphics.RGB; import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; @@ -86,6 +88,8 @@ import com.raytheon.viz.mpe.ui.rsc.MPEFieldResourceData.MPEFieldFrame; * Nov 05, 2015 18095 lbousaidi Fixed hour substitued for satellite field precip when drawing polygon. * Dec 04, 2015 5165/14513 mduff Set this resource on the display manager if not set in the display manager. * Dec 08, 2015 5180 bkowal Made the hour substitution special case precise. + * Feb 15, 2016 5338 bkowal Update the persistent set of polygons for an existing frame after one or + * all are deleted. * * * @@ -455,8 +459,6 @@ public class MPEFieldResource extends timeToLoad.getTime()); try { long fileLength = file.getFile().length(); - // System.out.printf("FileName = %s, length = %d\n", - // file.getFile().getPath(), fileLength); if (fileLength > 0) { file.load(); } else // can't read the file since it is empty @@ -557,13 +559,6 @@ public class MPEFieldResource extends } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.mpe.ui.rsc.AbstractGriddedMPEResource#createFrameContour - * (com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData.Frame) - */ @Override protected GriddedContourDisplay createFrameContour(MPEFieldFrame frame) throws VizException { @@ -582,13 +577,6 @@ public class MPEFieldResource extends return display; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.mpe.ui.rsc.AbstractGriddedMPEResource#createFrameImage - * (com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData.Frame) - */ @Override protected GriddedImageDisplay2 createFrameImage(MPEFieldFrame frame) throws VizException { @@ -680,23 +668,59 @@ public class MPEFieldResource extends return preferences; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.mpe.ui.dialogs.polygon.IPolygonEditsChangedListener# - * polygonEditsChanged(com.raytheon.viz.mpe.ui.DisplayFieldData, - * java.util.Date, java.util.List) - */ @Override public void polygonEditsChanged(DisplayFieldData field, Date date, - List polygonEdits) { + List polygonEdits, + List persistentRemaining) { if (field == resourceData.getFieldData()) { MPEFieldFrame frame = frames.get(new DataTime(date)); if (frame != null) { frame.setPolygonEdits(polygonEdits); issueRefresh(); } + + if (persistentRemaining == null) { + /* + * A persistent polygon has been removed. So, the lists of + * polygons for any existing frames will need to be rebuilt. The + * polygons are stored in a text file without any unique + * identifier and polygons with duplicate fields are allowed to + * exist. The polygons must currently remain stored in this + * format to maintain compatibility with legacy C++ mpe code. + * So, the only option (with the current implementation) is to + * remove any persistent polygons from the existing list and + * re-add the remaining set of persistent polygons. The lists of + * polygons cannot be replaced across all frames because the + * list of polygon edits passed to this method also contains + * frame/time specific polygons. + */ + return; + } + for (MPEFieldFrame otherFrame : frames.values()) { + if (otherFrame.getDate().equals(date)) { + // already updated this frame. + continue; + } + List currentPolygonEdits = otherFrame + .getPolygonEdits(); + if (CollectionUtils.isEmpty(currentPolygonEdits)) { + continue; + } + boolean persistentRemoved = false; + Iterator persistentIter = currentPolygonEdits + .iterator(); + while (persistentIter.hasNext()) { + if (persistentIter.next().isPersistent()) { + persistentIter.remove(); + persistentRemoved = true; + } + } + if (!persistentRemoved) { + continue; + } + currentPolygonEdits.addAll(persistentRemaining); + otherFrame.setPolygonEdits(currentPolygonEdits); + } } } } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedFreezeResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedFreezeResource.java index 850e2adff9..109b671f1a 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedFreezeResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedFreezeResource.java @@ -32,7 +32,7 @@ import javax.measure.converter.UnitConverter; import javax.measure.unit.NonSI; import javax.measure.unit.Unit; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.eclipse.swt.graphics.RGB; import org.geotools.coverage.grid.GridGeometry2D; import org.opengis.referencing.crs.CoordinateReferenceSystem; @@ -97,9 +97,9 @@ public class PlotGriddedFreezeResource extends IMpeResource { MPEDisplayManager displayMgr = null; - + private DailyQcUtils dqc = DailyQcUtils.getInstance(); - + private DrawDQCStations ddq = DrawDQCStations.getInstance(); private GriddedImageDisplay gridDisplay; @@ -130,9 +130,9 @@ public class PlotGriddedFreezeResource extends private List colorSet; -// Hrap_Grid hrap_grid = DailyQcUtils.getHrap_grid(); + // Hrap_Grid hrap_grid = DailyQcUtils.getHrap_grid(); -// Pcp pcp = DailyQcUtils.pcp; + // Pcp pcp = DailyQcUtils.pcp; public PlotGriddedFreezeResource(MPEDisplayManager displayMgr, LoadProperties loadProperties, List colorSet) { @@ -213,7 +213,8 @@ public class PlotGriddedFreezeResource extends cm.read_file(file, num, dqc.pcp); - buf = FloatBuffer.allocate(dqc.getHrap_grid().maxi * dqc.getHrap_grid().maxj); + buf = FloatBuffer.allocate(dqc.getHrap_grid().maxi + * dqc.getHrap_grid().maxj); /* Get value in the HRAP grid bins. */ for (j = dqc.getHrap_grid().maxj - 1; j >= 0; j--) { @@ -264,7 +265,8 @@ public class PlotGriddedFreezeResource extends buf.rewind(); Rectangle extent = new Rectangle(dqc.getHrap_grid().hrap_minx, - dqc.getHrap_grid().hrap_miny, dqc.getHrap_grid().maxi, dqc.getHrap_grid().maxj); + dqc.getHrap_grid().hrap_miny, dqc.getHrap_grid().maxi, + dqc.getHrap_grid().maxj); if (extent.x == 0 && extent.y == 0) { Rectangle coord = null; @@ -433,8 +435,7 @@ public class PlotGriddedFreezeResource extends @Override protected void paintInternal(IGraphicsTarget target, PaintProperties paintProps) throws VizException { - if (buf == null || dqc.grids_flag != 1 - || displayMgr.isZflag() != true) { + if (buf == null || dqc.grids_flag != 1 || displayMgr.isZflag() != true) { return; } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedPrecipResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedPrecipResource.java index 22bc92509e..76a5bc6f24 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedPrecipResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedPrecipResource.java @@ -32,7 +32,7 @@ import javax.measure.converter.UnitConverter; import javax.measure.unit.NonSI; import javax.measure.unit.Unit; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.eclipse.swt.graphics.RGB; import org.geotools.coverage.grid.GridGeometry2D; import org.opengis.referencing.crs.CoordinateReferenceSystem; @@ -470,13 +470,14 @@ public class PlotGriddedPrecipResource extends @Override protected void paintInternal(IGraphicsTarget target, PaintProperties paintProps) throws VizException { - if (buf == null || (DailyQcUtils.grids_flag != 1 && DailyQcUtils.contour_flag != 1) + if (buf == null + || (DailyQcUtils.grids_flag != 1 && DailyQcUtils.contour_flag != 1) || displayMgr.isQpf() != true) { return; } Set mode = displayMgr.getDisplayMode(); - System.out.println("Mode is: "+mode.toString()); + System.out.println("Mode is: " + mode.toString()); if (mode.contains(DisplayMode.Image)) { if (gridDisplay == null) { diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedTempResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedTempResource.java index 62a37e7c7e..09fcaf5e49 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedTempResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedTempResource.java @@ -32,7 +32,7 @@ import javax.measure.converter.UnitConverter; import javax.measure.unit.NonSI; import javax.measure.unit.Unit; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.eclipse.swt.graphics.RGB; import org.geotools.coverage.grid.GridGeometry2D; import org.opengis.referencing.crs.CoordinateReferenceSystem; @@ -100,9 +100,9 @@ public class PlotGriddedTempResource extends IMpeResource { private DailyQcUtils dqc = DailyQcUtils.getInstance(); - + private DrawDQCStations ddq = DrawDQCStations.getInstance(); - + MPEDisplayManager displayMgr = null; private GriddedImageDisplay2 gridDisplay; @@ -133,9 +133,9 @@ public class PlotGriddedTempResource extends private final List colorSet; -// Hrap_Grid hrap_grid = DailyQcUtils.getHrap_grid(); + // Hrap_Grid hrap_grid = DailyQcUtils.getHrap_grid(); -// Pcp pcp = DailyQcUtils.pcp; + // Pcp pcp = DailyQcUtils.pcp; public PlotGriddedTempResource(MPEDisplayManager displayMgr, LoadProperties loadProperties, List colorSet) { @@ -223,7 +223,8 @@ public class PlotGriddedTempResource extends cm.read_file(file, num, dqc.pcp); - buf = FloatBuffer.allocate(dqc.getHrap_grid().maxi * dqc.getHrap_grid().maxj); + buf = FloatBuffer.allocate(dqc.getHrap_grid().maxi + * dqc.getHrap_grid().maxj); /* Get value in the HRAP grid bins. */ for (j = dqc.getHrap_grid().maxj - 1; j >= 0; j--) { @@ -276,7 +277,8 @@ public class PlotGriddedTempResource extends buf.rewind(); Rectangle extent = new Rectangle(dqc.getHrap_grid().hrap_minx, - dqc.getHrap_grid().hrap_miny, dqc.getHrap_grid().maxi, dqc.getHrap_grid().maxj); + dqc.getHrap_grid().hrap_miny, dqc.getHrap_grid().maxi, + dqc.getHrap_grid().maxj); if (extent.x == 0 && extent.y == 0) { Rectangle coord = null; @@ -446,8 +448,7 @@ public class PlotGriddedTempResource extends protected void paintInternal(IGraphicsTarget target, PaintProperties paintProps) throws VizException { - if (buf == null || dqc.grids_flag != 1 - || displayMgr.isMaxmin() != true) { + if (buf == null || dqc.grids_flag != 1 || displayMgr.isMaxmin() != true) { return; } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/RadarCoverageResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/RadarCoverageResource.java index 6b8ac55757..612053557f 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/RadarCoverageResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/RadarCoverageResource.java @@ -77,7 +77,8 @@ import com.vividsolutions.jts.geom.Coordinate; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Aug 10, 2009 2675 mpduff Initial creation + * Aug 10, 2009 2675 mpduff Initial creation + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling * * * @@ -282,8 +283,8 @@ public class RadarCoverageResource extends for (int i = 0; i < 131; i++) { for (int j = 0; j < 131; j++) { float f = -9999; - if (data[130-i][j] != -9999) { - f = (float) Math.floor(cvt.convert(data[130-i][j])); + if (data[130 - i][j] != -9999) { + f = (float) Math.floor(cvt.convert(data[130 - i][j])); } int dx = i - 66; @@ -390,7 +391,7 @@ public class RadarCoverageResource extends // Draw label if (iFont == null) { - iFont = target.initializeFont("Dialog", 12, null); + iFont = target.initializeFont("Dialog", 10, null); } String text = RADAR_COVERAGE; @@ -403,8 +404,7 @@ public class RadarCoverageResource extends string.verticallAlignment = VerticalAlignment.TOP; target.drawStrings(string); - if (missingData) - { + if (missingData) { string.setText(MISSING_DATA, textColor); string.setCoordinates(screenExtent.getMinX() + 350, screenExtent.getMinY() + 550); diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/RadarGageOverlayRsc.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/RadarGageOverlayRsc.java index 80a609f679..0c92b79d2a 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/RadarGageOverlayRsc.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/RadarGageOverlayRsc.java @@ -49,7 +49,8 @@ import com.vividsolutions.jts.geom.Coordinate; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Nov 8, 2009 3232 mpduff Initial creation. + * Nov 08, 2009 3232 mpduff Initial creation. + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling * * * @@ -133,7 +134,7 @@ public class RadarGageOverlayRsc extends if (getProperties().isVisible()) { if (shape == null) { IFont font = target.initializeFont(target.getDefaultFont() - .getFontName(), 9, null); + .getFontName(), 8, null); DrawableString string = new DrawableString("+", null); string.font = font; diff --git a/cave/com.raytheon.viz.mpe/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.mpe/META-INF/MANIFEST.MF index d602f27a96..3d2b73a78a 100644 --- a/cave/com.raytheon.viz.mpe/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.mpe/META-INF/MANIFEST.MF @@ -2,14 +2,14 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Mpe Plug-in Bundle-SymbolicName: com.raytheon.viz.mpe -Bundle-Version: 1.12.1174.qualifier +Bundle-Version: 1.15.0.qualifier Bundle-Activator: com.raytheon.viz.mpe.Activator Bundle-Vendor: RAYTHEON Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.geotools, com.raytheon.viz.core, - org.apache.commons.lang, + org.apache.commons.lang3;bundle-version="3.4.0", com.raytheon.viz.hydrocommon, javax.persistence;bundle-version="1.0.0", javax.measure;bundle-version="1.0.0", diff --git a/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/MPEDataManager.java b/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/MPEDataManager.java index c2c09fbfcb..aa4fca4eec 100644 --- a/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/MPEDataManager.java +++ b/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/MPEDataManager.java @@ -40,7 +40,7 @@ import java.util.TimeZone; import javax.persistence.Table; -import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; import org.opengis.metadata.spatial.PixelOrientation; import com.raytheon.uf.common.dataplugin.shef.tables.Hourlypc; @@ -154,9 +154,9 @@ public class MPEDataManager { private short[] unbiasedRadarData; private double rwBiasValUsed; -// private double daaBiasValUsed; - - + + // private double daaBiasValUsed; + private double memSpanUsed; private String editBias; @@ -209,21 +209,18 @@ public class MPEDataManager { } /* - public double getDAABiasValUsed() { - return daaBiasValUsed; - } - */ - + * public double getDAABiasValUsed() { return daaBiasValUsed; } + */ + public void setRwBiasValUsed(double rwBiasValUsed) { this.rwBiasValUsed = rwBiasValUsed; } /* - public void setDAABiasValUsed(double daaBiasValUsed) { - this.daaBiasValUsed = daaBiasValUsed; - } - */ - + * public void setDAABiasValUsed(double daaBiasValUsed) { + * this.daaBiasValUsed = daaBiasValUsed; } + */ + /** * @return the memSpanUsed */ @@ -766,8 +763,8 @@ public class MPEDataManager { } public Map getDateMap(boolean update) { - - getDates(update); + + getDates(update); return dateMap; } @@ -781,7 +778,8 @@ public class MPEDataManager { for (Object[] item : results) { // note db stores west longitude as positive so must negate MPERadarLoc radarLoc = new MPERadarLoc((String) item[0], - ((Number) item[1]).doubleValue(), -((Number) item[2]).doubleValue()); + ((Number) item[1]).doubleValue(), + -((Number) item[2]).doubleValue()); radarList.add(radarLoc); } } catch (VizException e) { @@ -833,7 +831,8 @@ public class MPEDataManager { } radarData.setRadAvail(radAvail); - radarData.setRwBiasValUsed(((Number) item[3]).doubleValue()); + radarData + .setRwBiasValUsed(((Number) item[3]).doubleValue()); radarData.setMemSpanUsed(((Number) item[4]).doubleValue()); radarData.setEditBias((String) item[5]); radarData.setIgnoreRadar(!"n".equals(item[6])); @@ -868,26 +867,28 @@ public class MPEDataManager { return radarResultList; } - public Map readSPRadarData(Date date) - { - //reads DPA radar data - return readRadarData(date, "rwradarresult"); - + public Map readSPRadarData(Date date) { + // reads DPA radar data + return readRadarData(date, "rwradarresult"); + } - - public Map readDPRadarData(Date date) - { - //reads DAA radar data - return readRadarData(date, "daaradarresult"); + + public Map readDPRadarData(Date date) { + // reads DAA radar data + return readRadarData(date, "daaradarresult"); } - - + public Map readRadarData(Date date, String tableName) { getRadars(); StringBuffer sqlQuery = new StringBuffer(); - sqlQuery.append("select radid,num_gages, rad_avail, rw_bias_val_used, mem_span_used, edit_bias, ignore_radar from " + - tableName + " where obstime='" + sdf.format(date) + "' and radid in("); - System.out.println("Datestring actually passed in query to radar table: " + sdf.format(date)); + sqlQuery.append("select radid,num_gages, rad_avail, rw_bias_val_used, mem_span_used, edit_bias, ignore_radar from " + + tableName + + " where obstime='" + + sdf.format(date) + + "' and radid in("); + System.out + .println("Datestring actually passed in query to radar table: " + + sdf.format(date)); for (int i = 0; i < radarList.size(); i++) { sqlQuery.append("'"); sqlQuery.append(radarList.get(i).getId()); @@ -926,7 +927,8 @@ public class MPEDataManager { } radarData.setRadAvail(radAvail); - radarData.setRwBiasValUsed(((Number) item[3]).doubleValue()); + radarData + .setRwBiasValUsed(((Number) item[3]).doubleValue()); radarData.setMemSpanUsed(((Number) item[4]).doubleValue()); radarData.setEditBias((String) item[5]); radarData.setIgnoreRadar(!"n".equals(item[6])); diff --git a/cave/com.raytheon.viz.pointdata/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.pointdata/META-INF/MANIFEST.MF index fbd19db39b..48a909f512 100644 --- a/cave/com.raytheon.viz.pointdata/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.pointdata/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Pointdata Plug-in Bundle-SymbolicName: com.raytheon.viz.pointdata;singleton:=true -Bundle-Version: 1.15.0.qualifier +Bundle-Version: 1.15.1.qualifier Bundle-Vendor: Raytheon Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.7 @@ -11,7 +11,7 @@ Require-Bundle: org.apache.batik;bundle-version="1.6", org.eclipse.core.runtime;bundle-version="3.8", com.raytheon.uf.viz.core;bundle-version="1.14.3", com.raytheon.viz.ui;bundle-version="1.14.0", - org.apache.commons.lang;bundle-version="2.3.0", + org.apache.commons.lang3;bundle-version="3.4.0", javax.measure, com.raytheon.uf.viz.localization, org.jep;bundle-version="2.3.0", diff --git a/cave/com.raytheon.viz.pointdata/localization/bundles/Scatterometer.xml b/cave/com.raytheon.viz.pointdata/localization/bundles/Scatterometer.xml deleted file mode 100644 index d31a24daf6..0000000000 --- a/cave/com.raytheon.viz.pointdata/localization/bundles/Scatterometer.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/cave/com.raytheon.viz.pointdata/localization/bundles/Scatterometer_quikscat.xml b/cave/com.raytheon.viz.pointdata/localization/bundles/Scatterometer_quikscat.xml deleted file mode 100644 index e499bcac9b..0000000000 --- a/cave/com.raytheon.viz.pointdata/localization/bundles/Scatterometer_quikscat.xml +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/cave/com.raytheon.viz.pointdata/localization/menus/obs/baseMaritime.xml b/cave/com.raytheon.viz.pointdata/localization/menus/obs/baseMaritime.xml index 29451efc45..022080e94a 100644 --- a/cave/com.raytheon.viz.pointdata/localization/menus/obs/baseMaritime.xml +++ b/cave/com.raytheon.viz.pointdata/localization/menus/obs/baseMaritime.xml @@ -57,16 +57,6 @@ - diff --git a/cave/com.raytheon.viz.pointdata/localization/plotModels/quikScatPlotDesign.svg b/cave/com.raytheon.viz.pointdata/localization/plotModels/quikScatPlotDesign.svg deleted file mode 100644 index 2787b591e9..0000000000 --- a/cave/com.raytheon.viz.pointdata/localization/plotModels/quikScatPlotDesign.svg +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - 0 - 0 - 0 - 0 - 0 - - - 75 - - - - - - diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/LocalizationParsedURLHandler.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/LocalizationParsedURLHandler.java deleted file mode 100644 index b52b961547..0000000000 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/LocalizationParsedURLHandler.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.pointdata; - -import java.io.File; - -import org.apache.batik.util.ParsedURL; -import org.apache.batik.util.ParsedURLData; -import org.apache.batik.util.ParsedURLDefaultProtocolHandler; - -import com.raytheon.uf.common.localization.IPathManager; -import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.viz.pointdata.rsc.PlotResourceData; - -/** - * parse file URLs to go through localization - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Oct 26, 2010            mschenke     Initial creation
- * 
- * 
- * - * @author mschenke - * @version 1.0 - */ - -public class LocalizationParsedURLHandler extends - ParsedURLDefaultProtocolHandler { - - private IPathManager pathManager; - - public LocalizationParsedURLHandler() { - super("file"); - pathManager = PathManagerFactory.getPathManager(); - } - - @Override - public ParsedURLData parseURL(String urlStr) { - ParsedURLData data = null; - if (urlStr != null && urlStr.startsWith("file:") == false - && urlStr.startsWith("#") == false - && urlStr.startsWith(IPathManager.SEPARATOR) == false) { // Win32 - String name = urlStr; - String endName = ""; - int idx = name.indexOf("#"); - if (idx > -1) { - endName = name.substring(idx); - name = name.substring(0, idx); - } - File file = pathManager.getStaticFile(PlotResourceData.PLOT_DIR - + name); - if (file != null) { - // Win32: Change to convert both Linux and Win32 paths - // Win32 path -> URL needs separator changed and "/" pre-pended - String absPath = file.getAbsolutePath(); - absPath = absPath.replace(File.separator, - IPathManager.SEPARATOR); - if (absPath.startsWith(IPathManager.SEPARATOR) == false) - absPath = IPathManager.SEPARATOR + absPath; - data = super.parseURL("file:" + absPath + endName); - } - } - - if (data == null) { - data = super.parseURL(urlStr); - } - return data; - } - - @Override - public ParsedURLData parseURL(ParsedURL baseURL, String urlStr) { - ParsedURLData data = null; - if (urlStr != null && urlStr.startsWith("file:") == false - && urlStr.startsWith("#") == false - && urlStr.startsWith(IPathManager.SEPARATOR) == false) { // Win32 - String name = urlStr; - String endName = ""; - int idx = name.indexOf("#"); - if (idx > -1) { - endName = name.substring(idx); - name = name.substring(0, idx); - } - File file = pathManager.getStaticFile(PlotResourceData.PLOT_DIR - + name); - if (file != null) { - // Win32: Change to convert both Linux and Win32 paths - // Win32 path -> URL needs separator changed and "/" pre-pended - String absPath = file.getAbsolutePath(); - absPath = absPath.replace(File.separator, - IPathManager.SEPARATOR); - if (absPath.startsWith(IPathManager.SEPARATOR) == false) - absPath = IPathManager.SEPARATOR + absPath; - data = super.parseURL("file:" + absPath + endName); - } - } - if (data == null) { - data = super.parseURL(baseURL, urlStr); - } - return data; - } -} diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelFactory.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelFactory.java index 066bcb15e7..acf332b154 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelFactory.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelFactory.java @@ -20,9 +20,7 @@ package com.raytheon.viz.pointdata; -import java.awt.Graphics2D; import java.awt.image.BufferedImage; -import java.awt.image.IndexColorModel; import java.io.File; import java.text.ParseException; import java.text.ParsePosition; @@ -35,21 +33,13 @@ import java.util.Formatter; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.TimeZone; import javax.measure.converter.UnitConverter; import javax.measure.unit.Unit; import javax.measure.unit.UnitFormat; -import org.apache.batik.bridge.BridgeContext; -import org.apache.batik.bridge.GVTBuilder; -import org.apache.batik.bridge.UserAgentAdapter; -import org.apache.batik.dom.svg.SAXSVGDocumentFactory; -import org.apache.batik.gvt.GraphicsNode; -import org.apache.batik.util.XMLResourceDescriptor; import org.eclipse.swt.graphics.RGB; import org.geotools.referencing.GeodeticCalculator; -import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -61,9 +51,11 @@ import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator; 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.IGraphicsTarget.LineStyle; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.map.IMapDescriptor; +import com.raytheon.uf.viz.core.point.svg.SVGImageFactory; import com.raytheon.viz.pointdata.lookup.IAbstractLookupTable; import com.raytheon.viz.pointdata.lookup.LookupUtils; import com.raytheon.viz.pointdata.python.CheckPlotValidityExecutor; @@ -71,7 +63,6 @@ import com.raytheon.viz.pointdata.python.PlotPythonScript; import com.raytheon.viz.pointdata.python.PlotPythonScriptFactory; import com.raytheon.viz.pointdata.python.SampleTextExecutor; import com.raytheon.viz.pointdata.rsc.PlotResource; -import com.raytheon.viz.pointdata.rsc.PlotResourceData; /** * A factory for generating plot images and sample messages by parsing the @@ -94,13 +85,16 @@ import com.raytheon.viz.pointdata.rsc.PlotResourceData; * Jun 06, 2014 2061 bsteffen Rename and add support for data formats in sampling. * Aug 07, 2014 3478 bclement removed PointDataDescription.Type.Double * Dec 16, 2014 16193 kshrestha Updated range limits + * Oct 27, 2015 4798 bsteffen Extend SVGImageFactory + * Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API. * * * * @author BRock97 * @version 1.0 */ -public class PlotModelFactory { +public class PlotModelFactory extends SVGImageFactory { + private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(PlotModelFactory.class); @@ -128,9 +122,7 @@ public class PlotModelFactory { private final SimpleDateFormat SAMPLE_DATE = new SimpleDateFormat("HHmm"); - // Need to include attribute and code to allow for String2String lookups and - // String2Number lookups - // to support clouds and present weather + private static final int NUM_POOL_THREADS = 1; private int width = 1; @@ -138,12 +130,6 @@ public class PlotModelFactory { private String currentStyleStr; - private Document document; - - private final GVTBuilder builder; - - private final BridgeContext bridgeContext; - private int plotModelWidth; private int plotModelHeight; @@ -158,7 +144,7 @@ public class PlotModelFactory { private final IMapDescriptor mapDescriptor; - private IndexColorModel tm; + private RGB color; private final List plotFields; @@ -180,7 +166,7 @@ public class PlotModelFactory { TEXT, BARB, TABLE, AVAIL, RANGE, NULL, SAMPLE, ARROW } - public class PlotModelElement { + public static class PlotModelElement { DisplayMode mode = DisplayMode.TEXT; String format = null; @@ -218,7 +204,7 @@ public class PlotModelFactory { } } - public class PlotWindElement { + public static class PlotWindElement { Node barbNode = null; Element barbElement = null; @@ -236,29 +222,18 @@ public class PlotModelFactory { String gustY = null; } - public PlotModelFactory(IMapDescriptor mapDescriptor, String plotModelFile) { - byte full = (byte) 255; - byte zero = (byte) 0; - byte[] red = { 0, zero }; - byte[] blue = { 0, full }; - byte[] green = { 0, zero }; + public PlotModelFactory(IMapDescriptor mapDescriptor, String plotModelFile) + throws VizException { + super(plotModelFile(plotModelFile)); regenerateStyle(); this.plotModelFile = plotModelFile; this.plotFields = new ArrayList(); this.sampleFields = new ArrayList(); - tm = new IndexColorModel(8, 2, red, blue, green, 0); + setColor(new RGB(0, 0, 255)); this.gc = new GeodeticCalculator(mapDescriptor.getCRS()); this.mapDescriptor = mapDescriptor; - String parser = XMLResourceDescriptor.getXMLParserClassName(); - SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); - try { - document = f.createDocument(PathManagerFactory.getPathManager() - .getStaticFile(PlotResourceData.PLOT_DIR + plotModelFile) - .toURI().toString()); - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, "Error parsing svg file", e); - } + this.svgRoot = document.getDocumentElement(); this.originalPlotModelWidth = Integer.parseInt(svgRoot.getAttributeNS( null, "width")); @@ -276,171 +251,12 @@ public class PlotModelFactory { if (Node.ELEMENT_NODE == plotElements.item(i).getNodeType()) { Element plotElement = (Element) plotElements.item(i); if (plotElement.hasAttribute(DM_ATTRIBUTE)) { - PlotModelElement thisElement = new PlotModelElement(); - thisElement.plotElement = plotElement; - thisElement.plotNode = plotElement.getChildNodes().item(0); - if (plotElement.getAttribute(DM_ATTRIBUTE).equals("text")) { - thisElement.mode = DisplayMode.TEXT; - plotElement.setAttribute("class", "text"); - displayedElementCount++; - } else if (plotElement.getAttribute(DM_ATTRIBUTE).equals( - "barb")) { - thisElement.mode = DisplayMode.BARB; - thisElement.winds = new PlotWindElement(); - NodeList windElements = plotElement.getChildNodes(); - for (int j = 0; j < windElements.getLength(); j++) { - if (Node.ELEMENT_NODE == windElements.item(j) - .getNodeType()) { - Element windElement = (Element) windElements - .item(j); - if (windElement.getAttribute("class").matches( - "arrow")) { - thisElement.winds.arrowElement = windElement; - thisElement.winds.arrowNode = windElement - .getChildNodes().item(0); - } else if (windElement.getAttribute("class") - .matches("barb")) { - thisElement.winds.barbElement = windElement; - thisElement.winds.barbNode = windElement - .getChildNodes().item(0); - } else if (windElement.getAttribute("class") - .matches("text")) { - thisElement.winds.gustElement = windElement; - thisElement.winds.gustNode = windElement - .getChildNodes().item(0); - thisElement.winds.gustX = windElement - .getAttribute("x"); - thisElement.winds.gustY = windElement - .getAttribute("y"); - } - } - } - displayedElementCount++; - } else if (plotElement.getAttribute(DM_ATTRIBUTE).equals( - "arrowuv")) { - thisElement.mode = DisplayMode.ARROW; - thisElement.winds = new PlotWindElement(); - NodeList windElements = plotElement.getChildNodes(); - for (int j = 0; j < windElements.getLength(); j++) { - if (Node.ELEMENT_NODE == windElements.item(j) - .getNodeType()) { - Element windElement = (Element) windElements - .item(j); - String attrClass = windElement - .getAttribute("class"); - if ("arrow".matches(attrClass)) { - thisElement.winds.arrowElement = windElement; - thisElement.winds.arrowNode = windElement - .getChildNodes().item(0); - } else if ("arrow1".matches(attrClass)) { - thisElement.winds.arrowElement = windElement; - thisElement.winds.arrowNode = windElement - .getChildNodes().item(0); - thisElement.winds.arrowElement - .setAttribute("arrowtype", - attrClass); - } else if ("arrow2".matches(attrClass)) { - thisElement.winds.arrowElement = windElement; - thisElement.winds.arrowNode = windElement - .getChildNodes().item(0); - thisElement.winds.arrowElement - .setAttribute("arrowtype", - attrClass); - } else if ("text".matches(attrClass)) { - thisElement.winds.gustElement = windElement; - thisElement.winds.gustNode = windElement - .getChildNodes().item(0); - thisElement.winds.gustX = windElement - .getAttribute("x"); - thisElement.winds.gustY = windElement - .getAttribute("y"); - } - } - } - displayedElementCount++; - } else if (plotElement.getAttribute(DM_ATTRIBUTE).equals( - "table") - || plotElement.getAttribute(DM_ATTRIBUTE).equals( - "recursive_translation")) { - thisElement.mode = DisplayMode.TABLE; - if (plotElement.hasAttribute(PFT_ATTRIBUTE)) { - thisElement.ranking = S2N.readS2NFile(plotElement - .getAttribute(PFT_ATTRIBUTE)); - } - if (plotElement.hasAttribute(PLT_ATTRIBUTE)) { - File table = getTableFile(plotElement - .getAttribute(PLT_ATTRIBUTE)); - thisElement.lookup = LookupUtils - .buildLookupTable(table); - thisElement.lookup.setMode(plotElement - .getAttribute(DM_ATTRIBUTE)); - } - displayedElementCount++; - } else if (plotElement.getAttribute(DM_ATTRIBUTE).equals( - "arrow")) { - plotElement.setAttribute("class", "text"); - thisElement.mode = DisplayMode.BARB; - displayedElementCount++; - } else if (plotElement.getAttribute(DM_ATTRIBUTE).equals( - "available")) { - thisElement.mode = DisplayMode.AVAIL; - plotElement.setAttribute("class", "text"); - displayedElementCount++; - } else if (plotElement.getAttribute(DM_ATTRIBUTE).equals( - "range")) { - thisElement.mode = DisplayMode.RANGE; - if (plotElement.hasAttribute(PLT_ATTRIBUTE)) { - File table = getTableFile(plotElement - .getAttribute(PLT_ATTRIBUTE)); - thisElement.lookup = LookupUtils - .buildLookupTable(table); - thisElement.lookup.setMode(plotElement - .getAttribute(DM_ATTRIBUTE)); - } - displayedElementCount++; - } else if (plotElement.getAttribute(DM_ATTRIBUTE).equals( - "null")) { - thisElement.mode = DisplayMode.NULL; - } else if (plotElement.getAttribute(DM_ATTRIBUTE).equals( - "sample")) { - thisElement.mode = DisplayMode.SAMPLE; - if (plotElement.hasAttribute(PLT_ATTRIBUTE)) { - File table = getTableFile(plotElement - .getAttribute(PLT_ATTRIBUTE)); - thisElement.lookup = LookupUtils - .buildLookupTable(table); - thisElement.lookup.setMode(plotElement - .getAttribute(DM_ATTRIBUTE)); - } - } - thisElement.parameter = plotElement - .getAttribute(P_ATTRIBUTE); - if (plotElement.hasAttribute(FMT_ATTRIBUTE)) { - thisElement.format = plotElement - .getAttribute(FMT_ATTRIBUTE); - } - if (plotElement.hasAttribute(UNIT_ATTRIBUTE)) { - thisElement.unit = plotElement - .getAttribute(UNIT_ATTRIBUTE); - } - if (plotElement.hasAttribute(SYMBOL_ATTRIBUTE)) { - thisElement.symbol = plotElement - .getAttribute(SYMBOL_ATTRIBUTE); - } - if (plotElement.hasAttribute(TRIM_ATTRIBUTE)) { - thisElement.trim = Integer.parseInt(plotElement - .getAttribute(TRIM_ATTRIBUTE)); - } - if (plotElement.hasAttribute(PLT_INDEX)) { - thisElement.index = Integer.parseInt(plotElement - .getAttribute(PLT_INDEX)); - } - if (plotElement.hasAttribute(REQUIRED)) { - thisElement.required = Boolean.parseBoolean(plotElement - .getAttribute(REQUIRED)); - } + PlotModelElement thisElement = parseElement(plotElement); if (thisElement.mode != DisplayMode.SAMPLE) { this.plotFields.add(thisElement); + if (thisElement.mode != DisplayMode.NULL) { + displayedElementCount += 1; + } } else { this.sampleFields.add(thisElement); thisElement.plotNode.setNodeValue(""); @@ -450,11 +266,13 @@ public class PlotModelFactory { } if (displayedElementCount <= 3) { - // Dont use image caching if more then 3 elements are used, with - // very few elements the hit rate is good enought to risk keeping - // the images in memory, but with more elements the hit rate drops - // and the cache size increases. 3 elements might not be the optimal - // way of detecting complexity but it is better than nothing. + /* + * Don't use image caching if more then 3 elements are used, with + * very few elements the hit rate is good enough to risk keeping the + * images in memory, but with more elements the hit rate drops and + * the cache size increases. 3 elements might not be the optimal way + * of detecting complexity but it is better than nothing. + */ imageCache = new HashMap(); } NodeList scriptNodes = document.getElementsByTagName("script"); @@ -480,54 +298,168 @@ public class PlotModelFactory { if (scriptText.length() > 0) { PlotPythonScriptFactory pythonFactory = new PlotPythonScriptFactory( plotModelFile, scriptText, plotDelegateName); - python = PythonJobCoordinator.newInstance(pythonFactory); + python = new PythonJobCoordinator<>(NUM_POOL_THREADS, + plotModelFile, pythonFactory); } - // remove the scriptNode in memory so time isn't wasted - // later attempting to render it + /* + * Remove the scriptNode in memory so time isn't wasted later + * attempting to render it + */ scriptNode.getParentNode().removeChild(scriptNode); } + } - UserAgentAdapter userAgentAdapter = new UserAgentAdapter(); - this.bridgeContext = new BridgeContext(userAgentAdapter); - this.builder = new GVTBuilder(); + private static PlotModelElement parseElement(Element plotElement) { + String dmAttribute = plotElement.getAttribute(DM_ATTRIBUTE); + PlotModelElement thisElement = new PlotModelElement(); + thisElement.plotElement = plotElement; + thisElement.plotNode = plotElement.getChildNodes().item(0); + if (dmAttribute.equals("text")) { + thisElement.mode = DisplayMode.TEXT; + plotElement.setAttribute("class", "text"); + } else if (dmAttribute.equals("barb")) { + thisElement.mode = DisplayMode.BARB; + thisElement.winds = new PlotWindElement(); + NodeList windElements = plotElement.getChildNodes(); + for (int j = 0; j < windElements.getLength(); j++) { + if (Node.ELEMENT_NODE == windElements.item(j).getNodeType()) { + Element windElement = (Element) windElements.item(j); + String elementClass = windElement.getAttribute("class"); + if (elementClass.matches("arrow")) { + thisElement.winds.arrowElement = windElement; + thisElement.winds.arrowNode = windElement + .getChildNodes().item(0); + } else if (elementClass.matches("barb")) { + thisElement.winds.barbElement = windElement; + thisElement.winds.barbNode = windElement + .getChildNodes().item(0); + } else if (elementClass.matches("text")) { + thisElement.winds.gustElement = windElement; + thisElement.winds.gustNode = windElement + .getChildNodes().item(0); + thisElement.winds.gustX = windElement.getAttribute("x"); + thisElement.winds.gustY = windElement.getAttribute("y"); + } + } + } + } else if (dmAttribute.equals("arrowuv")) { + thisElement.mode = DisplayMode.ARROW; + thisElement.winds = new PlotWindElement(); + NodeList windElements = plotElement.getChildNodes(); + for (int j = 0; j < windElements.getLength(); j++) { + if (Node.ELEMENT_NODE == windElements.item(j).getNodeType()) { + Element windElement = (Element) windElements.item(j); + String attrClass = windElement.getAttribute("class"); + if ("arrow".matches(attrClass)) { + thisElement.winds.arrowElement = windElement; + thisElement.winds.arrowNode = windElement + .getChildNodes().item(0); + } else if ("arrow1".matches(attrClass)) { + thisElement.winds.arrowElement = windElement; + thisElement.winds.arrowNode = windElement + .getChildNodes().item(0); + thisElement.winds.arrowElement.setAttribute( + "arrowtype", attrClass); + } else if ("arrow2".matches(attrClass)) { + thisElement.winds.arrowElement = windElement; + thisElement.winds.arrowNode = windElement + .getChildNodes().item(0); + thisElement.winds.arrowElement.setAttribute( + "arrowtype", attrClass); + } else if ("text".matches(attrClass)) { + thisElement.winds.gustElement = windElement; + thisElement.winds.gustNode = windElement + .getChildNodes().item(0); + thisElement.winds.gustX = windElement.getAttribute("x"); + thisElement.winds.gustY = windElement.getAttribute("y"); + } + } + } + } else if (dmAttribute.equals("table") + || dmAttribute.equals("recursive_translation")) { + thisElement.mode = DisplayMode.TABLE; + if (plotElement.hasAttribute(PFT_ATTRIBUTE)) { + thisElement.ranking = S2N.readS2NFile(plotElement + .getAttribute(PFT_ATTRIBUTE)); + } + if (plotElement.hasAttribute(PLT_ATTRIBUTE)) { + File table = getTableFile(plotElement + .getAttribute(PLT_ATTRIBUTE)); + thisElement.lookup = LookupUtils.buildLookupTable(table); + thisElement.lookup.setMode(dmAttribute); + } + } else if (dmAttribute.equals("arrow")) { + plotElement.setAttribute("class", "text"); + thisElement.mode = DisplayMode.BARB; + } else if (dmAttribute.equals("available")) { + thisElement.mode = DisplayMode.AVAIL; + plotElement.setAttribute("class", "text"); + } else if (dmAttribute.equals("range")) { + thisElement.mode = DisplayMode.RANGE; + if (plotElement.hasAttribute(PLT_ATTRIBUTE)) { + File table = getTableFile(plotElement + .getAttribute(PLT_ATTRIBUTE)); + thisElement.lookup = LookupUtils.buildLookupTable(table); + thisElement.lookup.setMode(dmAttribute); + } + } else if (dmAttribute.equals("null")) { + thisElement.mode = DisplayMode.NULL; + } else if (dmAttribute.equals("sample")) { + thisElement.mode = DisplayMode.SAMPLE; + if (plotElement.hasAttribute(PLT_ATTRIBUTE)) { + File table = getTableFile(plotElement + .getAttribute(PLT_ATTRIBUTE)); + thisElement.lookup = LookupUtils.buildLookupTable(table); + thisElement.lookup.setMode(dmAttribute); + } + } + thisElement.parameter = plotElement.getAttribute(P_ATTRIBUTE); + if (plotElement.hasAttribute(FMT_ATTRIBUTE)) { + thisElement.format = plotElement.getAttribute(FMT_ATTRIBUTE); + } + if (plotElement.hasAttribute(UNIT_ATTRIBUTE)) { + thisElement.unit = plotElement.getAttribute(UNIT_ATTRIBUTE); + } + if (plotElement.hasAttribute(SYMBOL_ATTRIBUTE)) { + thisElement.symbol = plotElement.getAttribute(SYMBOL_ATTRIBUTE); + } + if (plotElement.hasAttribute(TRIM_ATTRIBUTE)) { + thisElement.trim = Integer.parseInt(plotElement + .getAttribute(TRIM_ATTRIBUTE)); + } + if (plotElement.hasAttribute(PLT_INDEX)) { + thisElement.index = Integer.parseInt(plotElement + .getAttribute(PLT_INDEX)); + } + if (plotElement.hasAttribute(REQUIRED)) { + thisElement.required = Boolean.parseBoolean(plotElement + .getAttribute(REQUIRED)); + } + return thisElement; } public void setColor(RGB color) { if (imageCache != null) { imageCache.clear(); } - byte fullr = (byte) color.red; - byte fullg = (byte) color.green; - byte fullb = (byte) color.blue; - // String style = "stroke: rgb(" + color.red + "," + color.green + "," - // + color.blue + ");"; - // this.svgRoot.setAttribute("style", style); - // System.out.println(style); - byte[] red = { 0, fullr }; - byte[] blue = { 0, fullb }; - byte[] green = { 0, fullg }; - tm = new IndexColorModel(8, 2, red, green, blue, 0); - // System.out.println(style); + this.color = color; } public void setLineWidth(int width) { - if (imageCache != null) { - imageCache.clear(); - } this.width = width; regenerateStyle(); } public void setLineStyle(LineStyle style) { - if (imageCache != null) { - imageCache.clear(); - } this.lineStyle = style; regenerateStyle(); } private void regenerateStyle() { + if (imageCache != null) { + imageCache.clear(); + } String strokeStart = "stroke-dasharray: "; switch (lineStyle) { case DASH_DOTTED: { @@ -576,12 +508,14 @@ public class PlotModelFactory { } /** - * Takes the station data object and produces a buffered image. + * Takes the plot data object and produces a buffered image. * - * @param station - * The station name * @param stationData - * A metar record for that station + * The data + * @param latitude + * the longitude the data will be displayed + * @param longitude + * the latitude the data will be displayed * @return A buffered image representing the station data */ public synchronized BufferedImage getStationPlot(PlotData stationData, @@ -607,7 +541,7 @@ public class PlotModelFactory { CheckPlotValidityExecutor task = new CheckPlotValidityExecutor( stationData); try { - result = python.submitSyncJob(task); + result = python.submitJob(task).get(); } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, "Error checking if plot is valid for plot model " @@ -685,24 +619,9 @@ public class PlotModelFactory { return imageCache.get(imageId.toString()); } - BufferedImage bufferedImage = new BufferedImage( - this.plotModelWidth, this.plotModelHeight, - BufferedImage.TYPE_BYTE_INDEXED, tm); + BufferedImage bufferedImage = createSingleColorImage(color, + plotModelHeight, plotModelWidth); - // long t0 = System.currentTimeMillis(); - GraphicsNode graphicsNode = builder.build(this.bridgeContext, - this.document); - Graphics2D g2d = null; - try { - g2d = bufferedImage.createGraphics(); - graphicsNode.primitivePaint(g2d); - } finally { - if (g2d != null) { - g2d.dispose(); - } - } - // System.out.println("Time building and creating graphics: " - // + (System.currentTimeMillis() - t0)); if (imageCache != null) { imageCache.put(imageId.toString(), bufferedImage); } @@ -724,7 +643,7 @@ public class PlotModelFactory { String result = null; SampleTextExecutor task = new SampleTextExecutor(stationData); try { - result = python.submitSyncJob(task); + result = python.submitJob(task).get(); } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, "Error getting sample text for plot model " @@ -865,8 +784,6 @@ public class PlotModelFactory { } if (isValidValue(cWindSpeed)) { - // Element eWindSpeed = - // (Element)element.plotElement.getChildNodes().item(0) if (element.winds.barbElement != null) { if (cWindSpeed == -9999.0 && plotMissingData) { element.winds.barbElement.removeAttribute("transform"); @@ -1067,13 +984,15 @@ public class PlotModelFactory { if (element.format != null) { if (element.format.equals("time")) { Date d = new Date(new Double(displayValue).longValue()); - SAMPLE_DATE.setTimeZone(TimeZone.getTimeZone("UTC")); - sValue = SAMPLE_DATE.format(d); + synchronized (SAMPLE_DATE) { + SAMPLE_DATE.setTimeZone(TimeUtil.GMT_TIME_ZONE); + sValue = SAMPLE_DATE.format(d); + } } else if (element.format.startsWith("time:")) { Date d = new Date(new Double(displayValue).longValue()); SimpleDateFormat sampleData = new SimpleDateFormat( element.format.substring(5)); - sampleData.setTimeZone(TimeZone.getTimeZone("UTC")); + sampleData.setTimeZone(TimeUtil.GMT_TIME_ZONE); sValue = sampleData.format(d); } else { StringBuilder sb = new StringBuilder(); @@ -1097,8 +1016,8 @@ public class PlotModelFactory { if (element.lookup != null && sValue != null) { String lu = null; - if (!sValue.equals("?")){ - lu = element.lookup.lookup(sValue); + if (!sValue.equals("?")) { + lu = element.lookup.lookup(sValue); } if (lu != null) { sValue = lu.trim(); @@ -1122,36 +1041,36 @@ public class PlotModelFactory { case LONG: Number value = ob.getNumber(element.parameter); if (value != null && value.doubleValue() != -9999.0) { - double displayValue = 0.0; - if (element.unit != null) { - if (element.converter == null) { - try { - Unit unit = UnitFormat.getUCUMInstance() - .parseProductUnit(element.unit, - new ParsePosition(0)); - element.converter = ob.getUnit( - element.parameter).getConverterTo(unit); - } catch (ParseException e) { - throw new VizException("Unable parse units ", e); - } + double displayValue = 0.0; + if (element.unit != null) { + if (element.converter == null) { + try { + Unit unit = UnitFormat.getUCUMInstance() + .parseProductUnit(element.unit, + new ParsePosition(0)); + element.converter = ob.getUnit(element.parameter) + .getConverterTo(unit); + } catch (ParseException e) { + throw new VizException("Unable parse units ", e); } - displayValue = element.converter.convert(value - .doubleValue()); + } + displayValue = element.converter.convert(value + .doubleValue()); + } else { + displayValue = value.doubleValue(); + } + + if (isValidValue(displayValue)) { + if (element.format != null) { + StringBuilder sb = new StringBuilder(); + Formatter testing = new Formatter(sb); + testing.format(element.format, displayValue); + sValue = sb.toString(); + testing.close(); } else { - displayValue = value.doubleValue(); - } - - if (isValidValue(displayValue)){ - if (element.format != null) { - StringBuilder sb = new StringBuilder(); - Formatter testing = new Formatter(sb); - testing.format(element.format, displayValue); - sValue = sb.toString(); - testing.close(); - } else { - sValue = Double.toString(displayValue); - } + sValue = Double.toString(displayValue); } + } } break; case STRING: @@ -1163,8 +1082,9 @@ public class PlotModelFactory { if (element.lookup != null && sValue != null) { String lu = null; lu = element.lookup.lookup(sValue); - if (!lu.equals("")) + if (!lu.equals("")) { sValue = lu; + } } if (sValue != null) { element.plotNode.setNodeValue(sValue.substring(element.trim)); @@ -1258,7 +1178,7 @@ public class PlotModelFactory { this.plotMissingData = b; } - private File getTableFile(String fileName) { + private static File getTableFile(String fileName) { File rval = PathManagerFactory.getPathManager().getStaticFile( PLOT_MODEL_DIR + IPathManager.SEPARATOR + fileName); return rval; diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModels.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModels.java index c6592a0d5d..7ec77eca87 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModels.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModels.java @@ -34,9 +34,9 @@ import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.LevelFactory; import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping; import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; +import com.raytheon.uf.common.localization.ILocalizationFile; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; -import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.map.MapDescriptor; @@ -57,6 +57,7 @@ import com.raytheon.viz.pointdata.util.PointDataInventory; * Jun 06, 2014 2061 bsteffen Remove old PlotResource * Sep 09, 2014 3356 njensen Remove CommunicationException * Aug 17, 2015 4717 mapeters Added null check in getLevels() + * Feb 12, 2016 5242 dgilling Remove calls to deprecated Localization APIs. * * * @@ -117,7 +118,7 @@ public class PlotModels { if (models == null) { models = new HashMap>(); IPathManager pm = PathManagerFactory.getPathManager(); - LocalizationFile[] files = pm.listFiles( + ILocalizationFile[] files = pm.listFiles( pm.getLocalSearchHierarchy(LocalizationType.CAVE_STATIC), PLOTLOCATION, new String[] { ".svg" }, true, true); @@ -128,8 +129,8 @@ public class PlotModels { throw new RuntimeException(e); } - for (LocalizationFile file : files) { - String fileName = file.getName(); + for (ILocalizationFile file : files) { + String fileName = file.getPath(); fileName = fileName.substring(PLOTLOCATION.length() + 1); try { if (!models.containsKey(fileName)) { diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PointDataRequest.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PointDataRequest.java index 3320a1e4cf..21b9402aa5 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PointDataRequest.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PointDataRequest.java @@ -22,7 +22,7 @@ package com.raytheon.viz.pointdata; import java.util.HashMap; import java.util.Map; -import org.apache.commons.lang.Validate; +import org.apache.commons.lang3.Validate; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; @@ -242,7 +242,6 @@ public class PointDataRequest { new RequestConstraint( PointDataServerRequest.REQUEST_MODE_2D)); - PointDataServerRequest request = new PointDataServerRequest(rcMap); Object result = ThriftClient.sendRequest(request); diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/python/PlotPythonScriptFactory.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/python/PlotPythonScriptFactory.java index 36262a7f96..50b4bd3907 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/python/PlotPythonScriptFactory.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/python/PlotPythonScriptFactory.java @@ -27,7 +27,7 @@ import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory; +import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory; import com.raytheon.viz.pointdata.PlotModelFactory; /** @@ -44,6 +44,7 @@ import com.raytheon.viz.pointdata.PlotModelFactory; * ------------- -------- ----------- -------------------------- * Mar 14, 2014 2868 njensen Initial creation * Jun 06, 2014 2061 bsteffen Remove old PlotResource + * Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API. * * * @@ -51,13 +52,15 @@ import com.raytheon.viz.pointdata.PlotModelFactory; * @version 1.0 */ -public class PlotPythonScriptFactory extends - AbstractPythonScriptFactory { +public class PlotPythonScriptFactory implements + PythonInterpreterFactory { private static String includePath; private static String baseFilePath; + protected String plotSvgName; + protected String scriptText; protected String plotDelegateName; @@ -76,7 +79,7 @@ public class PlotPythonScriptFactory extends */ public PlotPythonScriptFactory(String plotSvgName, String scriptText, String plotDelegateName) { - super(plotSvgName, 1); + this.plotSvgName = plotSvgName; this.scriptText = scriptText; this.plotDelegateName = plotDelegateName; } @@ -112,6 +115,6 @@ public class PlotPythonScriptFactory extends } return new PlotPythonScript(baseFilePath, includePath, scriptText, - plotDelegateName, this.getName()); + plotDelegateName, plotSvgName); } } diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java index 2f22180ef4..14ebbabdc4 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java @@ -21,6 +21,7 @@ package com.raytheon.viz.pointdata.rsc; import java.awt.Font; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -75,6 +76,8 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; import com.raytheon.uf.viz.core.rsc.capabilities.DensityCapability; import com.raytheon.uf.viz.core.rsc.capabilities.MagnificationCapability; +import com.raytheon.viz.pointdata.rsc.progdisc.GenericProgressiveDisclosure; +import com.raytheon.viz.pointdata.rsc.progdisc.GenericProgressiveDisclosure.PlotItem; import com.raytheon.viz.pointdata.util.MetarPrecipDataContainer; import com.raytheon.viz.pointdata.util.MetarPrecipDataContainer.PrecipData; import com.vividsolutions.jts.geom.Coordinate; @@ -90,12 +93,14 @@ import com.vividsolutions.jts.geom.Coordinate; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Aug 19, 2011 bsteffen Initial creation - * Jun 07, 2013 2070 bsteffen Add geospatial constraints to metar - * precip requests. - * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 + * Date Ticket# Engineer Description + * ------------- -------- --------- -------------------------------------------- + * Aug 19, 2011 7725 bsteffen Initial creation + * Jun 07, 2013 2070 bsteffen Add geospatial constraints to metar precip + * requests. + * Mar 11, 2014 2718 randerso Changes for GeoTools 10.5 + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling + * Nov 13, 2015 4903 bsteffen Extract progressive disclosure * * * @@ -109,15 +114,19 @@ public class MetarPrecipResource extends private static final int PLOT_PIXEL_SIZE = 30; - private class RenderablePrecipData extends PrecipData { + private class RenderablePrecipData extends PrecipData implements PlotItem { - Double distValue = 0.0; + public final DrawableString string; - DrawableString string = null; - - public RenderablePrecipData(PrecipData data) { + public RenderablePrecipData(PrecipData data, DrawableString string) { super(data.getTimeObs(), data.getStationName(), data.getPrecipAmt(), data.getLatLon().x, data.getLatLon().y); + this.string = string; + } + + @Override + public Coordinate getLocation() { + return new Coordinate(string.basics.x, string.basics.y); } } @@ -149,7 +158,7 @@ public class MetarPrecipResource extends private boolean reproject = false; - private Map> data = new HashMap>(); + private Map> data = new HashMap<>(); private IFont font = null; @@ -175,59 +184,53 @@ public class MetarPrecipResource extends if (time == null) { return; } - List precips = getPrecipData(time); - if (precips == null) { + GenericProgressiveDisclosure disclosure = null; + synchronized (data) { + disclosure = data.get(time); + } + if (disclosure == null) { dataProcessJob.schedule(); return; } - if (precips.isEmpty()) { - return; - } - - RGB color = getCapability(ColorableCapability.class).getColor(); + IExtent extent = paintProps.getView().getExtent(); Double magnification = getCapability(MagnificationCapability.class) .getMagnification(); Double density = getCapability(DensityCapability.class).getDensity(); + double threshold = (PLOT_PIXEL_SIZE * magnification) / density; + threshold = (threshold * extent.getWidth()) + / paintProps.getCanvasBounds().width; + Collection precips = disclosure.runDisclosure( + extent, threshold); + if (precips.isEmpty()) { + return; + } + RGB color = getCapability(ColorableCapability.class).getColor(); if (font == null) { - font = target.initializeFont(Font.DIALOG, 10, + font = target.initializeFont(Font.DIALOG, 8, new Style[] { Style.BOLD }); font.setMagnification(magnification.floatValue()); } List strings = new ArrayList(); - IExtent extent = paintProps.getView().getExtent(); - - double threshold = (PLOT_PIXEL_SIZE * magnification) / density; - threshold = (threshold * extent.getWidth()) - / paintProps.getCanvasBounds().width; - for (RenderablePrecipData data : precips) { - if (!extent.contains(new double[] { data.string.basics.x, - data.string.basics.y })) { - continue; - } - if (data.distValue >= threshold) { - // This is easier then changing it when the capability changes. - data.string.font = this.font; - data.string.setText(data.string.getText(), color); - strings.add(data.string); - } + // This is easier then changing it when the capability changes. + data.string.font = this.font; + data.string.setText(data.string.getText(), color); + strings.add(data.string); } target.drawStrings(strings); } private List getPrecipData(DataTime time) { - List currData = null; + GenericProgressiveDisclosure currData = null; synchronized (data) { currData = data.get(time); } if (currData != null) { - synchronized (currData) { - return new ArrayList(currData); - } + return currData.getAll(); } return null; } @@ -335,7 +338,9 @@ public class MetarPrecipResource extends GridEnvelope2D envelope = GridGeometry2D.wrap( descriptor.getGridGeometry()).getGridRange2D(); synchronized (data) { - for (List dataList : data.values()) { + for (GenericProgressiveDisclosure disclosure : data + .values()) { + List dataList = disclosure.getAll(); Iterator it = dataList.iterator(); while (it.hasNext()) { RenderablePrecipData precip = it.next(); @@ -424,22 +429,20 @@ public class MetarPrecipResource extends rcMap.put("location.stationId", rc); MetarPrecipDataContainer container = new MetarPrecipDataContainer( resourceData.getDuration(), rcMap); - for (Entry> entry : data + for (Entry> entry : data .entrySet()) { DataTime time = entry.getKey(); if (time.getMatchValid() < earliestTime) { // No need to reprocess times after the earliest update. continue; } - synchronized (entry.getValue()) { - Iterator iter = entry.getValue() - .iterator(); - while (iter.hasNext()) { - if (newStations.contains(iter.next().getStationName())) { - iter.remove(); - } + GenericProgressiveDisclosure newValue = new GenericProgressiveDisclosure<>(); + for (RenderablePrecipData data : entry.getValue().getAll()) { + if (!newStations.contains(data.getStationName())) { + newValue.add(data); } } + entry.setValue(newValue); addData(time, container.getBasePrecipData(time)); addData(time, container.getDerivedPrecipData(time)); if (monitor.isCanceled()) { @@ -522,10 +525,9 @@ public class MetarPrecipResource extends private void addData(DataTime time, List precips) { if (precips.isEmpty()) { if (!dataTimes.contains(time)) { + GenericProgressiveDisclosure disclosure = new GenericProgressiveDisclosure(); synchronized (data) { - List newPrecips = Collections - .emptyList(); - data.put(time, newPrecips); + data.put(time, disclosure); } dataTimes.add(time); } @@ -543,8 +545,7 @@ public class MetarPrecipResource extends }); - List newPrecips = new ArrayList( - precips.size()); + GenericProgressiveDisclosure newPrecips = new GenericProgressiveDisclosure(); RGB color = getCapability(ColorableCapability.class).getColor(); @@ -557,32 +558,19 @@ public class MetarPrecipResource extends if (precip instanceof RenderablePrecipData) { data = (RenderablePrecipData) precip; } else { - data = new RenderablePrecipData(precip); double[] px = descriptor.worldToPixel(new double[] { precip.getLatLon().x, precip.getLatLon().y }); if (!envelope.contains(px[0], px[1])) { continue; } - data.string = new DrawableString(formatPrecip(precips.get(i) - .getPrecipAmt()), color); - data.string.setCoordinates(px[0], px[1], px[2]); - data.string.verticallAlignment = VerticalAlignment.MIDDLE; - data.string.horizontalAlignment = HorizontalAlignment.CENTER; - } - double bestDist = Double.MAX_VALUE; - for (RenderablePrecipData exist : newPrecips) { - double xDist = exist.string.basics.x - data.string.basics.x; - double yDist = exist.string.basics.y - data.string.basics.y; - double dist = Math.hypot(xDist, yDist); - if (dist < bestDist) { - bestDist = dist; - } - } - data.distValue = bestDist; - // this checks removes duplicates - if (bestDist > 0) { - newPrecips.add(data); + DrawableString string = new DrawableString(formatPrecip(precips + .get(i).getPrecipAmt()), color); + string.setCoordinates(px[0], px[1], px[2]); + string.verticallAlignment = VerticalAlignment.MIDDLE; + string.horizontalAlignment = HorizontalAlignment.CENTER; + data = new RenderablePrecipData(precip, string); } + newPrecips.add(data); } synchronized (data) { data.put(time, newPrecips); diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource.java index 99c6750547..69adfb8a93 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource.java @@ -30,7 +30,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; -import org.apache.commons.lang.Validate; +import org.apache.commons.lang3.Validate; import org.eclipse.swt.graphics.RGB; import org.opengis.coverage.grid.GridEnvelope; import org.opengis.referencing.crs.CoordinateReferenceSystem; diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResourceData.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResourceData.java index da7f124027..931329d718 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResourceData.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResourceData.java @@ -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 * 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. **/ @@ -28,8 +28,6 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import org.apache.batik.util.ParsedURL; - import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; @@ -41,29 +39,35 @@ import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.LoadProperties; -import com.raytheon.viz.pointdata.LocalizationParsedURLHandler; import com.raytheon.viz.pointdata.rsc.retrieve.AbstractPlotInfoRetriever; import com.raytheon.viz.pointdata.rsc.retrieve.PointDataPlotInfoRetriever; /** * Resource data for plots - * + * *
- * 
+ *
  * SOFTWARE HISTORY
- * Date          Ticket#  Engineer    Description
- * ------------- -------- ----------- --------------------------
- * Feb 17, 2009           njensen     Initial creation
- * Jun 29, 2009  2538     jsanchez    Implemented Metars.
- * May 14, 2013  1869     bsteffen    Get plots working without dataURI
- * Aug 09, 2013  2033     mschenke    Switched File.separator to 
- *                                    IPathManager.SEPARATOR
- * Sep 05, 2013  2316     bsteffen    Unify pirep and ncpirep.
- * Jun 06, 2014  2061     bsteffen    Remove old PlotResource
- * Sep 16, 2014  2707     bclement    lsr no longer uses dataURI
- * 
+ *
+ * Date          Ticket#  Engineer  Description
+ * ------------- -------- --------- --------------------------------------------
+ * Feb 17, 2009  1960     njensen   Initial creation
+ * Jun 29, 2009  2538     jsanchez  Implemented Metars.
+ * May 14, 2013  1869     bsteffen  Get plots working without dataURI
+ * Aug 09, 2013  2033     mschenke  Switched File.separator to
+ *                                  IPathManager.SEPARATOR
+ * Sep 05, 2013  2316     bsteffen  Unify pirep and ncpirep.
+ * Jun 06, 2014  2061     bsteffen  Remove old PlotResource
+ * Sep 16, 2014  2707     bclement  lsr no longer uses dataURI
+ * Oct 27, 2015  4798     bsteffen  Move SVG localization url handler
+ *                                  registration.
+ * Nov 16, 2015  5119     bsteffen  Remove bufquikscat
+ * Jan 19, 2016  5253     tgurney   Remove svrwx dependency on dataURI
+ * Jan 28, 2016  5286     tgurney   Remove tcg dependency on dataURI
+ * Feb 09, 2016  5283     nabowle   Remove NGM MOS support.
+ *
  * 
- * + * * @author njensen * @version 1.0 */ @@ -143,10 +147,7 @@ public class PlotResourceData extends AbstractRequestableResourceData { * In the future if stationId can be set to anything that is even a * little unique we can get rid of this */ - pluginProps.put("bufrquikscat", new PluginPlotProperties(false)); pluginProps.put("radar", new PluginPlotProperties(false)); - pluginProps.put("tcg", new PluginPlotProperties(false)); - pluginProps.put("svrwx", new PluginPlotProperties(false)); pluginProps.put("ldadhydro", new PluginPlotProperties(false)); pluginProps.put("textPoints", new PluginPlotProperties(false)); @@ -155,6 +156,9 @@ public class PlotResourceData extends AbstractRequestableResourceData { * default behavior, but for now they are included so we have a * comprehensive list of which plugins use certain behaviors. */ + + pluginProps.put("tcg", new PluginPlotProperties()); + pluginProps.put("svrwx", new PluginPlotProperties()); pluginProps.put("obs", new PluginPlotProperties()); pluginProps.put("goessounding", new PluginPlotProperties()); pluginProps.put("poessounding", new PluginPlotProperties()); @@ -169,7 +173,6 @@ public class PlotResourceData extends AbstractRequestableResourceData { pluginProps.put("bufrmosHPC", new PluginPlotProperties()); pluginProps.put("bufrmosLAMP", new PluginPlotProperties()); pluginProps.put("bufrmosMRF", new PluginPlotProperties()); - pluginProps.put("bufrmosNGM", new PluginPlotProperties()); pluginProps.put("ldadmesonet", new PluginPlotProperties()); pluginProps.put("qc", new PluginPlotProperties()); pluginProps.put("bufrascat", new PluginPlotProperties()); @@ -181,8 +184,6 @@ public class PlotResourceData extends AbstractRequestableResourceData { pluginProps.put("airep", new PluginPlotProperties()); pluginProps.put("acars", new PluginPlotProperties()); pluginProps.put("lsr", new PluginPlotProperties()); - - ParsedURL.registerHandler(new LocalizationParsedURLHandler()); } public PlotResourceData() { @@ -192,13 +193,6 @@ public class PlotResourceData extends AbstractRequestableResourceData { } } - /* - * (non-Javadoc) - * - * @seecom.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData# - * constructResource(com.raytheon.uf.viz.core.comm.LoadProperties, - * com.raytheon.edex.db.objects.PluginDataObject[]) - */ @Override protected AbstractVizResource constructResource( LoadProperties loadProperties, PluginDataObject[] objects) { @@ -342,12 +336,6 @@ public class PlotResourceData extends AbstractRequestableResourceData { this.defaultPeriod = defaultPeriod; } - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData# - * getAvailableTimes() - */ @Override public DataTime[] getAvailableTimes() throws VizException { Map map = null; diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/progdisc/GenericProgressiveDisclosure.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/progdisc/GenericProgressiveDisclosure.java new file mode 100644 index 0000000000..2dd4a36507 --- /dev/null +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/progdisc/GenericProgressiveDisclosure.java @@ -0,0 +1,362 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.viz.pointdata.rsc.progdisc; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +import com.raytheon.uf.viz.core.IExtent; +import com.raytheon.viz.pointdata.rsc.progdisc.GenericProgressiveDisclosure.PlotItem; +import com.vividsolutions.jts.geom.Coordinate; + +/** + * A generic progressive disclosure algorithm that will determine a subset of + * {@link PlotItem}s that should be displayed given a particular {@link IExtent} + * and the desired distance between plot items. The exact disclosure for a set + * of items can be weighted by adding the items in a specific order. In general + * the items that are added first will displayed sooner than those added later. + * For example if you were displaying cities, then sorting the cities by + * population before adding would result in large cities being displayed before + * small cities. + *

+ * This class was designed to scale well for any number of points. To achieve + * this it uses a combination of two distinct algorithms with different + * performance characteristics: + *

    + *
  1. The static algorithm: When a new item is inserted using this + * algorithm then the position is compared to all the existing items to + * determine the distance from the closest item. When disclosure is run it is + * simply a loop over the items to find any with a large enough distance value. + * This has Θ(n²) insertion time, Θ(n) disclosure time. + *
  2. The dynamic algorithm: When a new item is inserted using this + * algorithm it is simply appended to the list of items. When disclosure is run + * then each item is compared to any other displayed items to see if it fits + * into the display without getting to close. This has Θ(1) insertion time, + * Θ(n*m) disclosure time(m is the number of items actually displayed). + *

    + * The static algorithm is much better for performance if the disclosure is + * going to be reused since it has a much faster disclosure time. However the + * longer insertion time can be a problem for more than 5000-10000 items. + *

    + * Besides raw performance, a major consideration between the two algorithms is + * that the dynamic algorithm suffers from inconsistent disclosure that can + * cause a flickering artifact as the extent changes. For example if you zoom in + * on a display then sometimes there is enough room to replace a single item + * with two items that are spread further apart, however if those items are too + * close to other items then they may be removed and replaced with items + * slightly further away. A very small change to the extent leads to a very big + * change in the set of items displayed which is generally unpleasant for users. + *

    + * There are two tweaks to the dynamic algorithm that help mitigate the flicker. + *

      + *
    1. First, when the dynamic algorithm is used it caches the disclosed items + * and tries to disclose the same items across multiple calls, before + * considering new items. This helps immensely because as the extent changes + * only minimal changes are made to the set of disclosed items. There can still + * be a problem if you zoom in on an area and zoom back out, the extra items + * introduced by zooming in can significantly change the result when zooming + * out. Although this effect is much more gradual than a flicker, it is still + * annoying when there is a specific item of interest that disappears + * unexpectedly. + *
    2. Secondly, pure dynamic disclosure is never used, instead a hybrid of + * dynamic/static is always used. For the first few thousand items the insertion + * cost for the static algorithm is very low so using a static algorithm for a + * certain number of points is beneficial. The static items can be quickly + * disclosed before adding in the dynamic points and they act like anchor points + * that help keep the dynamic algorithm more consistent. + *

      + * The hybrid approach provides a balance between getting something to display + * quickly and keeping the disclosure consistent. If the disclosure is going to + * be used for awhile it may be worthwhile to use the static disclosure more. It + * is possible to asynchronously calculate the static values so that as soon as + * possible the disclosure will be completely consistent( + * {@link #calculateStaticDistances()}. + *

      + * This class uses internal synchronization to make it safe to use from multiple + * threads. When properly configured all function calls will be very fast so + * there should not be significant waiting. + * + *

      + * 
      + * SOFTWARE HISTORY
      + * 
      + * Date          Ticket#  Engineer  Description
      + * ------------- -------- --------- -----------------
      + * Nov 12, 2015  4903     bsteffen  Initial creation
      + * 
      + * 
      + * + * @author bsteffen + * @version 1.0 + * @param + */ +public class GenericProgressiveDisclosure { + + private final int staticToDynamicThreshold; + + private AtomicInteger waitingTasks = new AtomicInteger(0); + + private int staticCount = 0; + + private List> items = new ArrayList<>(); + + private List> prevItems = Collections.emptyList(); + + public GenericProgressiveDisclosure() { + this(5000); + } + + /** + * Construct a new instance with a specific threshold for switching between + * the two disclosure algorithms. Its usually best to keep the number + * relatively small and use {@link #calculateStaticDistances()} + * asynchronously to ensure that that + * {@link #runDisclosure(IExtent, double)} does not have to wait for slow + * calls to {@link #add(PlotItem)}. + * + * @param staticToDynamicThreshold + * the number of items that should calculate static distance + * values before switching to dynamic calculations. + */ + public GenericProgressiveDisclosure(int staticToDynamicThreshold) { + this.staticToDynamicThreshold = staticToDynamicThreshold; + } + + /** + * @return all the {@link PlotItem}s contained in this disclosure. + */ + public List getAll() { + ArrayList all = new ArrayList<>(); + waitingTasks.incrementAndGet(); + synchronized (items) { + all.ensureCapacity(items.size()); + for (ItemInfo info : items) { + all.add(info.getItem()); + } + } + waitingTasks.decrementAndGet(); + return all; + } + + /** + * Get a set of items that are all within extent and are not closer together + * than minDistance. + * + * @param extent + * area whcich will contain all items returned + * @param minDistance + * the minimum distance between any two disclosed items, no two + * items returned will be closer than this. + * @return items + */ + public Collection runDisclosure(IExtent extent, double minDistance) { + List> items = new ArrayList<>(); + Set result = new HashSet<>(100); + waitingTasks.incrementAndGet(); + synchronized (this.items) { + for (ItemInfo item : getStaticItems()) { + if (item.getDistance() > minDistance && item.within(extent)) { + result.add(item.getItem()); + items.add(item); + } + } + if (staticCount < this.items.size()) { + for (ItemInfo item : this.prevItems) { + if (!item.hasDistance() && item.within(extent) + && getMinDistance(items, item) > minDistance) { + if (result.add(item.getItem())) { + items.add(item); + } + } + } + for (ItemInfo item : getDynamicItems()) { + if (item.within(extent) + && getMinDistance(items, item) > minDistance) { + if (result.add(item.getItem())) { + items.add(item); + } + } + } + this.prevItems = items; + } + } + waitingTasks.decrementAndGet(); + return result; + } + + /** + * Add a new item that can be disclosed. This will not do any aggressive + * duplicate checking. + */ + public double add(T item) { + return add(item, false); + } + + /** + * Add a new item that can be disclosed. + * + * @param item + * the item to add + * @param checkDuplicate + * when this is true then the item will be checked against all + * existing items and ignored if it is in a location that is + * already used. This slows down the method so if you are + * reasonably certain there are no duplicates its better to use + * false. + * @return The static distance between the new item and the next closest + * item, or NaN if there are too many items for static calculations. + */ + public double add(T item, boolean checkDuplicate) { + ItemInfo info = new ItemInfo<>(item); + waitingTasks.incrementAndGet(); + synchronized (items) { + if (items.size() < staticToDynamicThreshold) { + double distance = getMinDistance(items, info); + info.setDistance(distance); + } else if (checkDuplicate) { + for (ItemInfo itemToCheck : items) { + if (itemToCheck.getItem().getLocation() + .equals(item.getLocation())) { + info.setDistance(0); + break; + } + } + } + if (!info.hasDistance()) { + items.add(info); + } else if (info.getDistance() > 0) { + staticCount += 1; + items.add(info); + } + } + waitingTasks.decrementAndGet(); + return info.getDistance(); + } + + /** + * Convert any items within the disclosure that are using the dynamic + * algorithm to be able to use the static algorithm. This will result in + * more consistent disclosure and faster execution of + * {@link #runDisclosure(IExtent, double)}. If there are alot of items this + * method can be slow and should not be run on a thread that is sensitive to + * delays. + *

      + * Running the calculation requires an exclusive lock that can block other + * methods. to avoid causing problems this method will return early if there + * is another thread using this object. The early return will often occur + * after some items have been converted so future calls will have less work + * to do. If the return value indicates an early return then the calling + * code should generally {@link Thread#sleep(long)}, {@link Thread#yield()}, + * or do other tasks before calling this method again. Calling this method + * again before other threads have a chance to run will return immediately + * after doing no work. + * + * @return false if the calculation was interrupted and there are more + * dynamic items, true if this disclosure is now 100% static. + */ + public boolean calculateStaticDistances() { + if (waitingTasks.get() > 0) { + return false; + } + synchronized (items) { + while (staticCount < items.size()) { + ItemInfo item = items.get(staticCount); + double distance = getMinDistance(getStaticItems(), item); + if (distance > 0) { + item.setDistance(distance); + staticCount += 1; + } else { + items.remove(staticCount); + } + if (waitingTasks.get() > 0) { + return false; + } + } + return true; + } + } + + protected List> getStaticItems() { + return items.subList(0, staticCount); + } + + protected List> getDynamicItems() { + return items.subList(staticCount, items.size()); + } + + private double getMinDistance(List> list, ItemInfo item) { + double min_dist = Double.MAX_VALUE; + for (ItemInfo existing : list) { + double dist = existing.getItem().getLocation() + .distance(item.getItem().getLocation()); + if (dist < min_dist + && (Double.isNaN(existing.getDistance()) || dist < existing + .getDistance())) { + min_dist = dist; + } + } + return min_dist; + + } + + public static interface PlotItem { + + public Coordinate getLocation(); + } + + private static class ItemInfo { + + private final T item; + + private double distance; + + public ItemInfo(T item) { + this.item = item; + this.distance = Double.NaN; + } + + public T getItem() { + return item; + } + + public boolean within(IExtent extent) { + Coordinate location = item.getLocation(); + return extent.contains(new double[] { location.x, location.y }); + } + + public boolean hasDistance() { + return !Double.isNaN(distance); + } + + public double getDistance() { + return distance; + } + + public void setDistance(double distance) { + this.distance = distance; + } + + } +} diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotConfig.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotConfig.java new file mode 100644 index 0000000000..ee9174b1da --- /dev/null +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotConfig.java @@ -0,0 +1,152 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.viz.pointdata.rsc.wind; + +import java.util.HashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; + +/** + * + * JAXB compatible representation of all the configuration options needed to + * request data and sampling information for wind vectors. + * + *

      + * 
      + * SOFTWARE HISTORY
      + * 
      + * Date          Ticket#  Engineer  Description
      + * ------------- -------- --------- -----------------
      + * Nov 13, 2015  4903     bsteffen  Initial creation
      + * 
      + * 
      + * + * @author bsteffen + * @version 1.0 + */ +@XmlAccessorType(XmlAccessType.NONE) +public class WindPlotConfig { + + @XmlElement + private WindPlotParameter longitude = new WindPlotParameter("longitude"); + + @XmlElement + private WindPlotParameter latitude = new WindPlotParameter("latitude"); + + @XmlElement + private WindPlotParameter speed = new WindPlotParameter("windSpd", "kn"); + + @XmlElement + private WindPlotParameter direction = new WindPlotParameter("windDir"); + + @XmlElement + private SampleFormat sample; + + public WindPlotParameter getLongitude() { + return longitude; + } + + public void setLongitude(WindPlotParameter longitude) { + this.longitude = longitude; + } + + public WindPlotParameter getLatitude() { + return latitude; + } + + public void setLatitude(WindPlotParameter latitude) { + this.latitude = latitude; + } + + public WindPlotParameter getSpeed() { + return speed; + } + + public void setSpeed(WindPlotParameter speed) { + this.speed = speed; + } + + public WindPlotParameter getDirection() { + return direction; + } + + public void setDirection(WindPlotParameter direction) { + this.direction = direction; + } + + public SampleFormat getSample() { + return sample; + } + + public void setSample(SampleFormat sample) { + this.sample = sample; + } + + public Set getUniqueParameters() { + Set result = new HashSet<>(5); + result.add(longitude.getParameter()); + result.add(latitude.getParameter()); + result.add(speed.getParameter()); + result.add(direction.getParameter()); + if (sample != null) { + result.addAll(sample.getUniqueParameters()); + } + return result; + } + + @XmlAccessorType(XmlAccessType.NONE) + public static class SampleFormat { + + @XmlAttribute + private String text; + + @XmlElement(name = "field") + private WindPlotParameter[] fields; + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public WindPlotParameter[] getFields() { + return fields; + } + + public void setFields(WindPlotParameter[] fields) { + this.fields = fields; + } + + public Set getUniqueParameters() { + Set result = new HashSet<>(); + for (WindPlotParameter p : fields) { + result.add(p.getParameter()); + } + return result; + } + + } +} diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotParameter.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotParameter.java new file mode 100644 index 0000000000..273eb2d726 --- /dev/null +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotParameter.java @@ -0,0 +1,236 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.viz.pointdata.rsc.wind; + +import java.text.ParseException; +import java.text.ParsePosition; +import java.util.Date; + +import javax.measure.unit.Unit; +import javax.measure.unit.UnitFormat; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlTransient; + +import com.raytheon.uf.common.pointdata.PointDataDescription.Type; +import com.raytheon.uf.common.pointdata.PointDataView; +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; + +/** + * + * Configuration information for a single parameter that is part of a + * {@link WindPlotConfig}. + * + *
      + * 
      + * SOFTWARE HISTORY
      + * 
      + * Date          Ticket#  Engineer  Description
      + * ------------- -------- --------- -----------------
      + * Nov 13, 2015  4903     bsteffen  Initial creation
      + * 
      + * 
      + * + * @author bsteffen + * @version 1.0 + */ +@XmlAccessorType(XmlAccessType.NONE) +public class WindPlotParameter { + + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(WindPlotParameter.class); + + @XmlAttribute + private String parameter; + + @XmlAttribute + private String unit; + + @XmlAttribute + private Boolean time; + + @XmlElement(name = "format") + private FormatValue[] formats; + + @XmlTransient + private Unit parsedUnit; + + /* Avoid spamming logs. */ + @XmlTransient + private boolean unitParseFailed = false; + + public WindPlotParameter() { + + } + + public WindPlotParameter(String parameter) { + this.parameter = parameter; + } + + public WindPlotParameter(String parameter, String unit) { + this.parameter = parameter; + this.unit = unit; + } + + public String getParameter() { + return parameter; + } + + public void setParameter(String parameter) { + this.parameter = parameter; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public Boolean getTime() { + return time; + } + + public void setTime(Boolean time) { + this.time = time; + } + + public FormatValue[] getFormats() { + return formats; + } + + public void setFormats(FormatValue[] formats) { + this.formats = formats; + } + + public Unit getParsedUnit() { + if (!unitParseFailed && parsedUnit == null) { + try { + parsedUnit = UnitFormat.getUCUMInstance().parseProductUnit( + unit, new ParsePosition(0)); + } catch (ParseException e) { + statusHandler.handle(Priority.WARN, + "Error retrieving wind data.", e); + unitParseFailed = true; + } + } + return parsedUnit; + } + + public double getNumericValue(PointDataView view) { + double value = view.getNumber(parameter).doubleValue(); + if (unit != null) { + Unit desired = getParsedUnit(); + Unit current = view.getUnit(parameter); + if (desired != null && current.isCompatible(desired)) { + value = current.getConverterTo(desired).convert(value); + } + } + return value; + } + + public Object getValue(PointDataView view) { + if (view.getType(parameter) == Type.STRING) { + return view.getString(parameter); + } else if (Boolean.TRUE.equals(time)) { + return TimeUtil.newGmtCalendar(new Date(view.getNumber(parameter) + .longValue())); + } else if (formats != null) { + Number value = view.getNumber(parameter); + for (FormatValue format : formats) { + if (format.matches(value)) { + return format.getText(); + } + } + return value.toString(); + } else if (unit != null) { + return getNumericValue(view); + } + return view.getNumber(parameter); + } + + @XmlAccessorType(XmlAccessType.NONE) + public static class FormatValue { + + @XmlAttribute + private Double high; + + @XmlAttribute + private Double low; + + @XmlAttribute + private Double value; + + @XmlAttribute + private String text; + + public boolean matches(Number value) { + if (this.value != null + && value.doubleValue() == this.value.doubleValue()) { + return true; + } else if (high != null && low != null + && high.doubleValue() >= value.doubleValue() + && low.doubleValue() < value.doubleValue()) { + return true; + } + return false; + } + + public Double getHigh() { + return high; + } + + public void setHigh(Double high) { + this.high = high; + } + + public Double getLow() { + return low; + } + + public void setLow(Double low) { + this.low = low; + } + + public Double getValue() { + return value; + } + + public void setValue(Double value) { + this.value = value; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + } + +} \ No newline at end of file diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotRenderable.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotRenderable.java new file mode 100644 index 0000000000..c797b42865 --- /dev/null +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotRenderable.java @@ -0,0 +1,268 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.viz.pointdata.rsc.wind; + +import java.util.Collection; + +import org.eclipse.swt.graphics.RGB; +import org.geotools.referencing.GeodeticCalculator; + +import com.raytheon.uf.viz.core.IExtent; +import com.raytheon.uf.viz.core.IGraphicsTarget; +import com.raytheon.uf.viz.core.drawables.IDescriptor; +import com.raytheon.uf.viz.core.drawables.PaintProperties; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.point.display.VectorGraphicsConfig; +import com.raytheon.uf.viz.core.point.display.VectorGraphicsRenderable; +import com.raytheon.uf.viz.core.rsc.AbstractVizResource; +import com.raytheon.uf.viz.core.rsc.IResourceDataChanged; +import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; +import com.raytheon.uf.viz.core.rsc.capabilities.DensityCapability; +import com.raytheon.uf.viz.core.rsc.capabilities.MagnificationCapability; +import com.raytheon.viz.pointdata.rsc.progdisc.GenericProgressiveDisclosure; +import com.raytheon.viz.pointdata.rsc.progdisc.GenericProgressiveDisclosure.PlotItem; +import com.vividsolutions.jts.geom.Coordinate; + +/** + * + * Combines a {@link VectorGraphicsRenderable} with a + * {@link GenericProgressiveDisclosure} to generate progressively disclosed wind + * displays. + * + *
      + * 
      + * SOFTWARE HISTORY
      + * 
      + * Date          Ticket#  Engineer  Description
      + * ------------- -------- --------- -----------------
      + * Nov 13, 2015  4903     bsteffen  Initial creation
      + * 
      + * 
      + * + * @author bsteffen + * @version 1.0 + */ +public class WindPlotRenderable { + + protected final AbstractVizResource resource; + + private final IResourceDataChanged changeListener = new IResourceDataChanged() { + + @Override + public void resourceChanged(ChangeType type, Object object) { + if (type == ChangeType.CAPABILITY) { + lastPaintedExtent = null; + } + } + }; + + protected VectorGraphicsConfig config = new VectorGraphicsConfig(); + + protected double baseDensity = 1.0; + + protected GenericProgressiveDisclosure barbs = new GenericProgressiveDisclosure<>(); + + private VectorGraphicsRenderable renderable; + + private double lastPaintedDistance = Double.POSITIVE_INFINITY; + + private IExtent lastPaintedExtent; + + public WindPlotRenderable(AbstractVizResource resource) { + this.resource = resource; + resource.getResourceData().addChangeListener(changeListener); + } + + public VectorGraphicsConfig getConfig() { + return config; + } + + public void reconfigure() { + if (lastPaintedExtent != null) { + lastPaintedExtent = null; + resource.issueRefresh(); + } + } + + public void dispose() { + if (renderable != null) { + renderable.dispose(); + renderable = null; + } + resource.getResourceData().removeChangeListener(changeListener); + } + + public void paint(IGraphicsTarget target, PaintProperties paintProps) + throws VizException { + IExtent extent = paintProps.getView().getExtent(); + if (renderable != null + && (lastPaintedExtent == null || !lastPaintedExtent + .equals(extent))) { + renderable.dispose(); + renderable = null; + } + if (renderable == null) { + + double magnification = resource.getCapability( + MagnificationCapability.class).getMagnification(); + double ratio = magnification * extent.getWidth() + / paintProps.getCanvasBounds().width; + config.setSizeScaler(ratio); + renderable = new VectorGraphicsRenderable(getDescriptor(), target, + config); + lastPaintedExtent = extent.clone(); + double density = resource.getCapability(DensityCapability.class) + .getDensity(); + double minDist = config.getScaledSize() / baseDensity / density; + lastPaintedDistance = minDist; + Collection barbs = this.barbs.runDisclosure(extent, minDist); + GeodeticCalculator gc = new GeodeticCalculator(); + for (Barb barb : barbs) { + double dir = barb.getDirection(); + Coordinate lonLat = barb.getLonLat(); + Coordinate plotLoc = barb.getLocation(); + gc.setStartingGeographicPoint(lonLat.x, lonLat.y); + double[] world = getDescriptor().pixelToWorld( + new double[] { plotLoc.x, plotLoc.y - 1 }); + gc.setDestinationGeographicPoint(world[0], world[1]); + dir -= gc.getAzimuth(); + dir = Math.toRadians(dir); + renderable.paintBarb(plotLoc, barb.getMagnitude(), dir); + } + } + renderable.setColor(getColor()); + renderable.paint(target); + } + + public String getText(Coordinate pixelLoc) { + String text = null; + double bestDist = 100; + if (renderable != null) { + bestDist = renderable.getConfig().getScaledSize() * 2; + } + for (Barb barb : barbs.getAll()) { + double dist = barb.getLocation().distance(pixelLoc); + if (dist < bestDist) { + bestDist = dist; + text = barb.getText(); + } + } + return text; + } + + protected RGB getColor() { + return resource.getCapability(ColorableCapability.class).getColor(); + } + + public synchronized boolean optimizeDisclosure() { + return barbs.calculateStaticDistances(); + } + + public void addBarb(Coordinate lonLat, double magnitude, double direction) { + addBarb(lonLat, magnitude, direction, null, false); + } + + public void addBarb(Coordinate lonLat, double magnitude, double direction, + boolean checkDuplicate) { + addBarb(lonLat, magnitude, direction, null, checkDuplicate); + } + + public void addBarb(Coordinate lonLat, double magnitude, double direction, + String text) { + addBarb(lonLat, magnitude, direction, text, false); + } + + public synchronized void addBarb(Coordinate lonLat, double magnitude, + double direction, String text, boolean checkDuplicate) { + double[] pixel = getDescriptor().worldToPixel( + new double[] { lonLat.x, lonLat.y }); + Coordinate plotLoc = new Coordinate(pixel[0], pixel[1]); + double distance = barbs.add(new Barb(lonLat, plotLoc, magnitude, + direction, text), checkDuplicate); + if (Double.isNaN(distance) || distance > lastPaintedDistance) { + IExtent extent = lastPaintedExtent; + if (extent != null && extent.contains(pixel)) { + resource.issueRefresh(); + lastPaintedExtent = null; + } + } + } + + public synchronized void reproject() { + GenericProgressiveDisclosure barbs = this.barbs; + this.barbs = new GenericProgressiveDisclosure<>(); + for (Barb barb : barbs.getAll()) { + addBarb(barb.getLonLat(), barb.getMagnitude(), barb.getDirection()); + } + } + + protected IDescriptor getDescriptor() { + return resource.getDescriptor(); + } + + private class Barb implements PlotItem { + + public final Coordinate lonLat; + + public final Coordinate plotLoc; + + public final double magnitude; + + public final double direction; + + public final String text; + + public Barb(Coordinate lonLat, Coordinate plotLoc, double magnitude, + double direction, String text) { + this.lonLat = lonLat; + this.plotLoc = plotLoc; + this.magnitude = magnitude; + this.direction = direction; + this.text = text; + } + + public Coordinate getLonLat() { + return lonLat; + } + + @Override + public Coordinate getLocation() { + return plotLoc; + } + + public double getMagnitude() { + return magnitude; + } + + public double getDirection() { + return direction; + } + + public String getText() { + return text; + } + + } + + public void setBaseDensity(double baseDensity) { + this.baseDensity = baseDensity; + } + +} diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotResource.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotResource.java new file mode 100644 index 0000000000..4bada49793 --- /dev/null +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotResource.java @@ -0,0 +1,404 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.viz.pointdata.rsc.wind; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.opengis.referencing.FactoryException; +import org.opengis.referencing.crs.CoordinateReferenceSystem; +import org.opengis.referencing.operation.TransformException; + +import com.raytheon.uf.common.dataplugin.PluginDataObject; +import com.raytheon.uf.common.dataquery.requests.RequestConstraint; +import com.raytheon.uf.common.geospatial.ReferencedCoordinate; +import com.raytheon.uf.common.pointdata.PointDataContainer; +import com.raytheon.uf.common.pointdata.PointDataServerRequest; +import com.raytheon.uf.common.pointdata.PointDataView; +import com.raytheon.uf.common.time.BinOffset; +import com.raytheon.uf.common.time.DataTime; +import com.raytheon.uf.common.time.TimeRange; +import com.raytheon.uf.viz.core.IGraphicsTarget; +import com.raytheon.uf.viz.core.drawables.PaintProperties; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.jobs.JobPool; +import com.raytheon.uf.viz.core.map.IMapDescriptor; +import com.raytheon.uf.viz.core.point.display.VectorGraphicsConfig; +import com.raytheon.uf.viz.core.requests.ThriftClient; +import com.raytheon.uf.viz.core.rsc.AbstractVizResource; +import com.raytheon.uf.viz.core.rsc.IResourceDataChanged.ChangeType; +import com.raytheon.uf.viz.core.rsc.LoadProperties; +import com.raytheon.viz.pointdata.rsc.wind.WindPlotConfig.SampleFormat; +import com.vividsolutions.jts.geom.Coordinate; + +/** + * + * Resource for displaying wind barbs of point data. + * + *
      + * 
      + * SOFTWARE HISTORY
      + * 
      + * Date          Ticket#  Engineer  Description
      + * ------------- -------- --------- -----------------
      + * Nov 13, 2015  4903     bsteffen  Initial creation
      + * 
      + * 
      + * + * @author bsteffen + * @version 1.0 + */ +public class WindPlotResource extends + AbstractVizResource { + + private JobPool primaryLoadPool; + + private Job secondaryLoadJob; + + private final Object framesLock = new Object(); + + private Map frames; + + protected WindPlotResource(WindPlotResourceData resourceData, + LoadProperties loadProperties) { + super(resourceData, loadProperties); + } + + @Override + protected void initInternal(IGraphicsTarget target) throws VizException { + synchronized (framesLock) { + dataTimes = new CopyOnWriteArrayList<>(); + frames = new HashMap(); + primaryLoadPool = new JobPool("Loading Wind Data", 4, false); + secondaryLoadJob = new SecondaryUpdateJob(); + secondaryLoadJob.setSystem(true); + secondaryLoadJob.schedule(); + } + } + + @Override + protected void disposeInternal() { + secondaryLoadJob.cancel(); + secondaryLoadJob = null; + primaryLoadPool.cancel(); + primaryLoadPool = null; + synchronized (framesLock) { + for (DataFrame frame : frames.values()) { + frame.getRenderable().dispose(); + } + this.frames = null; + } + + } + + @Override + protected void paintInternal(IGraphicsTarget target, + PaintProperties paintProps) throws VizException { + DataTime time = paintProps.getDataTime(); + if (time == null) { + return; + } + DataFrame frame; + synchronized (framesLock) { + frame = frames.get(time); + if (frame == null) { + frame = addFrame(time); + } + } + primaryLoadPool.schedule(frame); + frame.getRenderable().paint(target, paintProps); + } + + protected DataFrame addFrame(DataTime dataTime) { + synchronized (framesLock) { + DataFrame frame = frames.get(dataTime); + if (frame == null) { + frame = new DataFrame(dataTime); + int index = Collections.binarySearch(dataTimes, dataTime); + if (index < 0) { + /* Keep the list sorted. */ + dataTimes.add(-1 * index - 1, dataTime); + } + frames.put(dataTime, frame); + } + return frame; + } + } + + @Override + public void remove(DataTime dataTime) { + synchronized (framesLock) { + frames.remove(dataTime); + super.remove(dataTime); + } + } + + @Override + public String inspect(ReferencedCoordinate coord) throws VizException { + if (resourceData.getConfig().getSample() == null) { + return null; + } + DataTime time = descriptor.getTimeForResource(this); + if (time == null) { + return null; + } + DataFrame frame; + synchronized (framesLock) { + frame = frames.get(time); + } + if (frame == null) { + return null; + } + try { + String text = frame.getRenderable().getText( + coord.asPixel(descriptor.getGridGeometry())); + if (text == null) { + text = "NO DATA"; + } + return text; + } catch (TransformException | FactoryException e) { + throw new VizException("Unable to transform point for inspect.", e); + } + } + + @Override + public void project(CoordinateReferenceSystem crs) throws VizException { + synchronized (framesLock) { + for (DataFrame frame : frames.values()) { + frame.reproject(); + } + } + } + + @Override + public String getName() { + String name = resourceData.getLegend(); + if (name == null) { + name = "Wind"; + } + return name; + } + + protected void loadData(DataTime dataTime, WindPlotRenderable renderable, + boolean initialLoad) { + WindPlotConfig config = resourceData.getConfig(); + SampleFormat sample = config.getSample(); + Map constraints = new HashMap<>( + resourceData.getFullDataMetadataMap()); + constraints.put(PointDataServerRequest.REQUEST_MODE_KEY, + new RequestConstraint(PointDataServerRequest.REQUEST_MODE_2D)); + constraints.put(PointDataServerRequest.REQUEST_PARAMETERS_KEY, + new RequestConstraint(config.getUniqueParameters())); + + BinOffset binOffset = resourceData.getBinOffset(); + if (binOffset == null) { + constraints.put(PluginDataObject.DATATIME_ID, + new RequestConstraint(dataTime.toString())); + } else { + TimeRange range = binOffset.getTimeRange(dataTime); + constraints.put(PluginDataObject.REFTIME_ID, new RequestConstraint( + new DataTime(range.getStart()).toString(), new DataTime( + range.getEnd()).toString())); + } + PointDataServerRequest request = new PointDataServerRequest(); + request.setRcMap(constraints); + try { + PointDataContainer container = (PointDataContainer) ThriftClient + .sendRequest(request); + if (container == null) { + return; + } + for (int i = 0; i < container.getAllocatedSz(); i += 1) { + PointDataView view = container.readRandom(i); + double longitude = config.getLongitude().getNumericValue(view); + double latitude = config.getLatitude().getNumericValue(view); + double magnitude = config.getSpeed().getNumericValue(view); + double direction = config.getDirection().getNumericValue(view); + Coordinate lonLat = new Coordinate(longitude, latitude); + if (sample == null) { + renderable.addBarb(lonLat, magnitude, direction, + !initialLoad); + } else { + WindPlotParameter[] fields = sample.getFields(); + Object[] args = new Object[fields.length]; + for (int c = 0; c < args.length; c += 1) { + args[c] = fields[c].getValue(view); + } + String text = String.format(sample.getText(), args) + .toString(); + renderable.addBarb(lonLat, magnitude, direction, text, + !initialLoad); + } + + } + } catch (VizException e) { + statusHandler.error("Error retrieving wind data.", e); + } + } + + @Override + protected void resourceDataChanged(ChangeType type, Object updateObject) { + if (type == ChangeType.DATA_UPDATE + && updateObject instanceof PluginDataObject[]) { + synchronized (framesLock) { + BinOffset binOffset = resourceData.getBinOffset(); + for (PluginDataObject pdo : (PluginDataObject[]) updateObject) { + DataTime time = pdo.getDataTime(); + if (binOffset != null) { + time = binOffset.getNormalizedTime(time); + } + DataFrame frame = frames.get(time); + if (frame != null) { + frame.update(); + } + } + secondaryLoadJob.schedule(); + } + } + } + + + private class DataFrame implements Runnable { + + private final DataTime time; + + private final WindPlotRenderable renderable; + + private boolean needsReproject = false; + + private boolean needsData = true; + + private boolean initialLoad = true; + + public DataFrame(DataTime time) { + this.time = time; + this.renderable = new WindPlotRenderable(WindPlotResource.this); + renderable.setBaseDensity(resourceData.getBaseDensity()); + VectorGraphicsConfig config = renderable.getConfig(); + config.setBaseSize(20); + config.setCalmCircleSizeRatio(0.3); + } + + public WindPlotRenderable getRenderable() { + return renderable; + } + + public void update() { + needsData = true; + } + + public void reproject() { + needsReproject = true; + } + + @Override + public void run() { + asyncUpdate(); + } + + public synchronized boolean asyncUpdate() { + boolean result = needsReproject | needsData; + if (needsReproject) { + needsReproject = false; + renderable.reproject(); + } + if (needsData) { + needsData = false; + loadData(time, renderable, initialLoad); + initialLoad = false; + } + return result; + } + + } + + private class SecondaryUpdateJob extends Job { + + public SecondaryUpdateJob() { + super("Updating wind data."); + setSystem(true); + } + + @Override + protected IStatus run(IProgressMonitor monitor) { + List frameList; + synchronized (framesLock) { + if (frames == null) { + return Status.OK_STATUS; + } + frameList = new ArrayList<>(frames.values()); + } + for (DataFrame frame : frameList) { + if (frame.asyncUpdate()) { + /* + * Restart after every frame to make sure frames haven't + * been added or removed while it was updating. + */ + schedule(); + return Status.OK_STATUS; + } + } + DataTime[] times = descriptor.getFramesInfo().getTimeMap() + .get(WindPlotResource.this); + if (times == null) { + return Status.OK_STATUS; + } + boolean added = false; + for (DataTime time : times) { + if (time == null) { + continue; + } + synchronized (framesLock) { + if (!frames.containsKey(time)) { + addFrame(time); + added = true; + } + } + } + if (added) { + /* + * Restart to ensure data is requested before optimization. + */ + schedule(); + return Status.OK_STATUS; + } + boolean finished = true; + for (DataFrame frame : frameList) { + if (!frame.getRenderable().optimizeDisclosure()) { + finished = false; + } + } + if (!finished) { + schedule(); + } + return Status.OK_STATUS; + } + + } + +} diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotResourceData.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotResourceData.java new file mode 100644 index 0000000000..d451e1bf2c --- /dev/null +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/wind/WindPlotResourceData.java @@ -0,0 +1,199 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.viz.pointdata.rsc.wind; + +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.JAXB; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlTransient; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.raytheon.uf.common.dataplugin.PluginDataObject; +import com.raytheon.uf.common.dataquery.requests.RequestConstraint; +import com.raytheon.uf.common.dataquery.requests.RequestableMetadataMarshaller; +import com.raytheon.uf.common.localization.IPathManager; +import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; +import com.raytheon.uf.viz.core.rsc.AbstractVizResource; +import com.raytheon.uf.viz.core.rsc.LoadProperties; + +/** + * + * Resource data for displaying wind barbs of point data. + * + *
      + * 
      + * SOFTWARE HISTORY
      + * 
      + * Date          Ticket#  Engineer  Description
      + * ------------- -------- --------- -----------------
      + * Nov 13, 2015  4903     bsteffen  Initial creation
      + * 
      + * 
      + * + * @author bsteffen + * @version 1.0 + */ +@XmlAccessorType(XmlAccessType.NONE) +public class WindPlotResourceData extends AbstractRequestableResourceData { + + @XmlAttribute + private String legend; + + @XmlAttribute + private String windFile; + + @XmlAttribute + private double baseDensity = 1.0; + + @XmlJavaTypeAdapter(value = RequestableMetadataMarshaller.class) + protected HashMap dataMetadataMap; + + @XmlTransient + protected WindPlotConfig config; + + public WindPlotResourceData() { + /* + * Resource data should never instigate a trip to the DB, the resource + * is responsible for requesting its own stuff. + */ + setRetrieveData(false); + setUpdatingOnMetadataOnly(true); + } + + @Override + protected AbstractVizResource constructResource( + LoadProperties loadProperties, PluginDataObject[] objects) + throws VizException { + if (config == null) { + IPathManager pathManager = PathManagerFactory.getPathManager(); + String path = "plotWind" + IPathManager.SEPARATOR + windFile; + LocalizationFile localizedFile = pathManager + .getStaticLocalizationFile(path); + try (InputStream is = localizedFile.openInputStream()) { + config = JAXB.unmarshal(is, WindPlotConfig.class); + } catch (Exception e) { + throw new VizException("Error loading " + path, e); + } + } + return new WindPlotResource(this, loadProperties); + } + + public String getLegend() { + return legend; + } + + public void setLegend(String legend) { + this.legend = legend; + } + + public String getWindFile() { + return windFile; + } + + public void setWindFile(String windFile) { + this.windFile = windFile; + } + + public double getBaseDensity() { + return baseDensity; + } + + public void setBaseDensity(double baseDensity) { + this.baseDensity = baseDensity; + } + + public HashMap getDataMetadataMap() { + return dataMetadataMap; + } + + public void setDataMetadataMap( + HashMap dataMetadataMap) { + this.dataMetadataMap = dataMetadataMap; + } + + public Map getFullDataMetadataMap() { + Map result = new HashMap<>(getMetadataMap()); + if (dataMetadataMap != null) { + result.putAll(dataMetadataMap); + } + return result; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + + ((dataMetadataMap == null) ? 0 : dataMetadataMap.hashCode()); + result = prime * result + ((legend == null) ? 0 : legend.hashCode()); + result = prime * result + + ((windFile == null) ? 0 : windFile.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + WindPlotResourceData other = (WindPlotResourceData) obj; + if (dataMetadataMap == null) { + if (other.dataMetadataMap != null) { + return false; + } + } else if (!dataMetadataMap.equals(other.dataMetadataMap)) { + return false; + } + if (legend == null) { + if (other.legend != null) { + return false; + } + } else if (!legend.equals(other.legend)) { + return false; + } + if (windFile == null) { + if (other.windFile != null) { + return false; + } + } else if (!windFile.equals(other.windFile)) { + return false; + } + return true; + } + + public WindPlotConfig getConfig() { + return config; + } + +} diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/PointDataCubeAdapter.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/PointDataCubeAdapter.java index bb5a9d2ade..b6498b366a 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/PointDataCubeAdapter.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/PointDataCubeAdapter.java @@ -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 * 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. **/ @@ -49,20 +49,24 @@ import com.raytheon.viz.pointdata.PointDataRequest; * sets. It is important to note that derived parameters for point data is much * different than grid. The primary difference is that while grid is combining * multiple records that represent different parameters, point data is combining - * multiple paramters within a single record. As a result point data does not + * multiple parameters within a single record. As a result point data does not * use the time and space matching functions of derived parameters since they * are guaranteed to match for all parameters within a record. - * + * *
      - * 
      + *
        * SOFTWARE HISTORY
      - * Date         Ticket#    Engineer    Description
      - * ------------ ---------- ----------- --------------------------
      - * Jun 1, 2009             brockwoo    Initial creation
      - * Nov 21, 2009 #3576      rjpeter     Refactored use of DerivParamDesc.
      - * Sep 09, 2014  3356      njensen     Remove CommunicationException
      + *
      + * Date          Ticket#  Engineer  Description
      + * ------------- -------- --------- ----------------------------------
      + * Jun 01, 2009  2149     brockwoo  Initial creation
      + * Nov 21, 2009  3576     rjpeter   Refactored use of DerivParamDesc.
      + * Sep 09, 2014  3356     njensen   Remove CommunicationException
      + * Nov 16, 2015  5119     bsteffen  Remove bufquikscat
      + * Feb 09, 2016  5283     nabowle   Remove NGM MOS support.
      + *
        * 
      - * + * * @author brockwoo * @version 1.0 */ @@ -74,11 +78,11 @@ public class PointDataCubeAdapter extends DefaultDataCubeAdapter { public static String PLUGIN_NAME = PointDataInventory.PLUGIN_NAME; private static String[] supportedPlugins = { "obs", "madis", - "modelsounding", "bufrssmi", "bufrquikscat", "lsr", "sfcobs", - "goessounding", "bufrascat", "poessounding", "profiler", "bufrua", - "ldadmesonet", "ldadhydro", "qc", "fssobs", "bufrmosAVN", - "bufrmosETA", "bufrmosGFS", "bufrmosHPC", "bufrmosLAMP", - "bufrmosMRF", "bufrmosNGM", "airep", "pirep", "nctaf" }; + "modelsounding", "bufrssmi", "lsr", "sfcobs", "goessounding", + "bufrascat", "poessounding", "profiler", "bufrua", "ldadmesonet", + "ldadhydro", "qc", "fssobs", "bufrmosAVN", "bufrmosETA", + "bufrmosGFS", "bufrmosHPC", "bufrmosLAMP", "bufrmosMRF", "airep", + "pirep", "nctaf" }; protected AbstractPointDataInventory inventory; @@ -86,12 +90,6 @@ public class PointDataCubeAdapter extends DefaultDataCubeAdapter { super(PLUGIN_NAME); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getInventory() - */ @Override public Object getInventory() { if (inventory == null) { @@ -100,13 +98,6 @@ public class PointDataCubeAdapter extends DefaultDataCubeAdapter { return this.inventory; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getPoints(java - * .lang.String[], java.util.Map) - */ @Override public PointDataContainer getPoints(String plugin, String[] parameters, Map queryParams) @@ -231,25 +222,11 @@ public class PointDataCubeAdapter extends DefaultDataCubeAdapter { } } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getSupportedPlugin - * () - */ @Override public String[] getSupportedPlugins() { return supportedPlugins; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#initInventory - * (java.util.Map) - */ @Override public void initInventory() { if (inventory == null) { diff --git a/cave/com.raytheon.viz.radar/localization/menus/tools/radar-tools-index.xml b/cave/com.raytheon.viz.radar/localization/menus/tools/radar-tools-index.xml new file mode 100644 index 0000000000..a2c3b0edde --- /dev/null +++ b/cave/com.raytheon.viz.radar/localization/menus/tools/radar-tools-index.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/cave/com.raytheon.viz.radar/localization/menus/tools/radar-tools-menu.xml b/cave/com.raytheon.viz.radar/localization/menus/tools/radar-tools-menu.xml new file mode 100644 index 0000000000..78d5994da6 --- /dev/null +++ b/cave/com.raytheon.viz.radar/localization/menus/tools/radar-tools-menu.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.viz.radar/plugin.xml b/cave/com.raytheon.viz.radar/plugin.xml index d3f3bb4e7c..ee3b1cdf04 100644 --- a/cave/com.raytheon.viz.radar/plugin.xml +++ b/cave/com.raytheon.viz.radar/plugin.xml @@ -172,14 +172,6 @@ - - - - * @@ -142,7 +143,7 @@ public class RadarTextResource extends @Override protected void initInternal(IGraphicsTarget target) throws VizException { // initialize the font - textFont = target.initializeFont(java.awt.Font.DIALOG, 11.0f, + textFont = target.initializeFont(java.awt.Font.DIALOG, 9, new IFont.Style[] {}); } diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicFunctions.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicFunctions.java index 41ecc48dde..c11e1c3990 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicFunctions.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicFunctions.java @@ -20,23 +20,13 @@ package com.raytheon.viz.radar.rsc.graphic; -import java.awt.Graphics2D; import java.awt.image.BufferedImage; -import java.awt.image.IndexColorModel; import java.awt.image.RenderedImage; -import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.UUID; -import org.apache.batik.bridge.BridgeContext; -import org.apache.batik.bridge.GVTBuilder; -import org.apache.batik.bridge.UserAgentAdapter; -import org.apache.batik.dom.svg.SAXSVGDocumentFactory; -import org.apache.batik.gvt.GraphicsNode; -import org.apache.batik.util.XMLResourceDescriptor; import org.eclipse.swt.graphics.RGB; import org.geotools.coverage.grid.GeneralGridGeometry; import org.opengis.referencing.FactoryException; @@ -47,25 +37,21 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import com.raytheon.uf.common.dataplugin.radar.level3.HdaHailPacket.HdaHailPoint; -import com.raytheon.uf.common.dataplugin.radar.level3.MesocyclonePacket.MesocyclonePoint; import com.raytheon.uf.common.dataplugin.radar.level3.SCITDataPacket; import com.raytheon.uf.common.dataplugin.radar.level3.SCITDataPacket.SCITDataCell; -import com.raytheon.uf.common.dataplugin.radar.level3.STICirclePacket.STICirclePoint; import com.raytheon.uf.common.dataplugin.radar.level3.SpecialGraphicSymbolPacket.SpecialGraphicPoint; import com.raytheon.uf.common.dataplugin.radar.level3.SymbologyPacket; import com.raytheon.uf.common.dataplugin.radar.level3.TVSPacket.TVSPoint; import com.raytheon.uf.common.dataplugin.radar.level3.TextSymbolPacket; -import com.raytheon.uf.common.dataplugin.radar.level3.WindBarbPacket.WindBarbPoint; import com.raytheon.uf.common.geospatial.ReferencedCoordinate; import com.raytheon.uf.common.geospatial.ReferencedObject.Type; -import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.data.IRenderedImageCallback; import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.point.display.PointWindDisplay; -import com.raytheon.uf.viz.core.point.display.PointWindDisplay.DisplayType; +import com.raytheon.uf.viz.core.point.svg.SVGImageFactory; import com.raytheon.viz.radar.RadarHelper; import com.raytheon.viz.radar.ui.RadarDisplayControls; import com.raytheon.viz.radar.ui.RadarDisplayManager; @@ -79,13 +65,14 @@ import com.vividsolutions.jts.geom.Coordinate; *
        * 
        * SOFTWARE HISTORY
      - * Date         Ticket#    Engineer    Description
      - * ------------ ---------- ----------- --------------------------
      - * Jan 13, 2009            chammack     Initial creation
      - * Jan 20, 2010 DR 4059    Zihou Wang   Display more GSM status and
      - *                                      correct display features.
      - * Aug 11, 2014  3504      mapeters     Replaced deprecated IODataPreparer
      - *                                      instances with IRenderedImageCallback.
      + * Date          Ticket#  Engineer    Description
      + * ------------- -------- ----------- --------------------------
      + * Jan 13, 2009            chammack   Initial creation
      + * Jan 20, 2010  4059      Zihou Wang Display more GSM status and
      + *                                    correct display features.
      + * Aug 11, 2014  3504      mapeters   Replaced deprecated IODataPreparer
      + *                                    instances with IRenderedImageCallback.
      + * Oct 37, 2015  4798      bsteffen   Use SVGImageFactory
        * 
        * 
      * @@ -105,9 +92,6 @@ public class RadarGraphicFunctions { /** ID in the svg for sti forecast symbols */ private static final String STI_FORE_SYMBOL = "STIForecastSymbol"; - /** ID in the svg for sti hexagon symbols */ - private static final String STI_HEX_SYMBOL = "STIHexagonSymbol"; - /** Index of the font for the past symbol */ private static final String PAST_SYM = "056"; @@ -152,16 +136,7 @@ public class RadarGraphicFunctions { /** ID in the svg for tvs */ private static final String TVS_ATTRIB = "tvs"; - static BufferedImage colorMapImage = null; - - private static UserAgentAdapter userAgentAdapter = new UserAgentAdapter(); - - private static BridgeContext bridgeContext = new BridgeContext( - userAgentAdapter); - - private static GVTBuilder builder = new GVTBuilder(); - - private static Map docMap = new HashMap(); + private static Map imageFactoryMap = new HashMap<>(); public static enum MesocycloneType { CORRELATED_SHEAR, CORRELATED_SHEAR_EXTRAPOLATED, MESOCYCLONE, MESOCYCLONE_WITH_SPIKES @@ -272,8 +247,7 @@ public class RadarGraphicFunctions { objArr.put(HAIL_SIZE, size); BufferedImage img = createImage(objArr, "HailIndex.svg", color); - IImage image = convertBufferedImage(target, img, UUID.randomUUID() - .toString()); + IImage image = convertBufferedImage(target, img); PlotObject po = new PlotObject(); po.image = image; ReferencedCoordinate rc = new ReferencedCoordinate( @@ -294,31 +268,6 @@ public class RadarGraphicFunctions { return null; } - /** - * Create a set of plot objects from the TVSPacket and ETVSPacket - * - * @param packet - * @param target - * @param gridGeometry - * @param descriptor - * @return - * @throws VizException - */ - public static List createTVS(SymbologyPacket packet, - IGraphicsTarget target, GeneralGridGeometry gridGeometry, - IDescriptor descriptor, RGB color) throws VizException { - List images = new ArrayList(); - TVSPoint[] points = (TVSPoint[]) RadarHelper.getItems(packet).toArray(); - if (points == null) - return images; - - for (TVSPoint point : points) { - images.add(createTVS(point, target, gridGeometry, descriptor, color)); - } - - return images; - } - public static List createTVS(SpecialGraphicPoint currPt, boolean isElevated, IGraphicsTarget target, GeneralGridGeometry gridGeometry, IDescriptor descriptor, @@ -338,7 +287,7 @@ public class RadarGraphicFunctions { target, gridGeometry, descriptor, color); } - public static PlotObject createTVS(int i, int j, boolean isElevated, + protected static PlotObject createTVS(int i, int j, boolean isElevated, boolean isExtrapolated, IGraphicsTarget target, GeneralGridGeometry gridGeometry, IDescriptor descriptor, RGB color) throws VizException { @@ -355,8 +304,7 @@ public class RadarGraphicFunctions { } BufferedImage img = createImage(objArr, "TVS.svg", color); - IImage image = convertBufferedImage(target, img, UUID.randomUUID() - .toString()); + IImage image = convertBufferedImage(target, img); PlotObject po = new PlotObject(); po.image = image; ReferencedCoordinate rc = new ReferencedCoordinate( @@ -436,7 +384,8 @@ public class RadarGraphicFunctions { } // Get the SVG - Document document = loadSVG(svgToGet); + RadarSVGImageFactory imageFactory = getImageFactory(svgToGet); + Document document = imageFactory.getDocument(); // Load the values into the SVG // Set radius @@ -494,11 +443,10 @@ public class RadarGraphicFunctions { } // Get the buffered image from SVG - BufferedImage img = getBufferedImage(document, color); + BufferedImage img = imageFactory.createSingleColorImage(color); // Plot - IImage image = convertBufferedImage(target, img, UUID.randomUUID() - .toString()); + IImage image = convertBufferedImage(target, img); PlotObject po = new PlotObject(); po.image = image; @@ -532,146 +480,6 @@ public class RadarGraphicFunctions { return images; } - public static List createMesocycloneImage( - SymbologyPacket packet, IGraphicsTarget target, - GeneralGridGeometry gridGeometry, IDescriptor descriptor, - MesocycloneType type, RGB color) throws VizException, - TransformException, FactoryException { - List images = new ArrayList(); - MesocyclonePoint[] points = (MesocyclonePoint[]) RadarHelper.getItems( - packet).toArray(); - - if (points == null) - return images; - - for (MesocyclonePoint point : points) { - PlotObject po = createMesocycloneImage(point.getI(), point.getJ(), - point.getMesoCycloneRadius(), target, gridGeometry, - descriptor, type, color); - - images.add(po); - } - - return images; - } - - public static List createMesocycloneImage( - SymbologyPacket packet, IGraphicsTarget target, - GeneralGridGeometry gridGeometry, IDescriptor descriptor, RGB color) - throws VizException, TransformException, FactoryException { - return createMesocycloneImage(packet, target, gridGeometry, descriptor, - MesocycloneType.MESOCYCLONE, color); - } - - /** - * Create a set of plot objects from a WindBarbPacket, making a table - * - * @param packet - * @param target - * @param gridGeometry - * @param descriptor - * @return - * @throws VizException - */ - public static List createWindBarb(SymbologyPacket packet, - IGraphicsTarget target, IDescriptor descriptor) throws VizException { - - List images = new ArrayList(); - WindBarbPoint[] points = (WindBarbPoint[]) RadarHelper.getItems(packet) - .toArray(); - if (points == null) - return images; - - int imgSize = 64; - for (WindBarbPoint point : points) { - PointWindDisplay barb = new PointWindDisplay(imgSize * 0.4, 1, 0, 0); - RGB color; - barb.setImageParameters(imgSize, imgSize, 255, 255, 255, 1); - - switch (point.getColorValue()) { - case 1: - color = RadarHelper.GREEN; - break; - case 2: - color = RadarHelper.YELLOW; - break; - case 3: - color = RadarHelper.BRIGHT_RED; - break; - case 4: - color = RadarHelper.LIGHT_BLUE; - break; - case 5: - color = RadarHelper.MED_PURPLE; - break; - default: - color = RadarHelper.WHITE; - break; - } - barb.setColor(color); - barb.setWind(point.getWindBarbDir(), point.getWindBarbSpd(), true); - BufferedImage img = barb.getWindImage(false, DisplayType.BARB, 1); - IImage image = convertBufferedImage(target, img, UUID.randomUUID() - .toString()); - PlotObject po = new PlotObject(); - po.image = image; - ReferencedCoordinate rc = new ReferencedCoordinate( - RadarGraphicsPage.rectifyCoordinate(new Coordinate(point - .getI(), point.getJ())), - descriptor.getGridGeometry(), Type.GRID_CENTER); - try { - // po.coord = rc.asPixel(descriptor); - po.coord = new Coordinate(point.i, point.j); - // adjust y coord per original code - // po.pixelOffset = new int[] { 0, 8 }; - po.pixelOffset = new int[] { 0, 0 }; - } catch (Exception e) { - throw new VizException("Unable to transform coordinates", e); - } - images.add(po); - } - - return images; - } - - public static List createStormTrackIndexCircle( - SymbologyPacket packet, IGraphicsTarget target, - GeneralGridGeometry gridGeometry, IDescriptor descriptor, - int hexOrCircle, RGB color) throws VizException { - List images = new ArrayList(); - STICirclePoint[] points = (STICirclePoint[]) RadarHelper.getItems( - packet).toArray(); - if (points == null) - return images; - - for (STICirclePoint point : points) { - Map objArr = new HashMap(); - - // TODO no type of product used as of 2/17/09 - BufferedImage img = createImage(objArr, "TVS.svg", color); - IImage image = convertBufferedImage(target, img, UUID.randomUUID() - .toString()); - PlotObject po = new PlotObject(); - po.image = image; - ReferencedCoordinate rc = new ReferencedCoordinate( - RadarGraphicsPage.rectifyCoordinate(new Coordinate(point - .getI(), point.getJ())), gridGeometry, - Type.GRID_CENTER); - try { - po.coord = rc.asPixel(descriptor.getGridGeometry()); - // adjust y coord per original code - po.pixelOffset = new int[] { 0, 8 }; - } catch (Exception e) { - throw new VizException("Unable to transform coordinates", e); - } - - images.add(po); - - } - - return images; - } - /** * * @param packet @@ -718,8 +526,7 @@ public class RadarGraphicFunctions { break; } BufferedImage img = createImage(objArr, "STI.svg", color); - IImage image = convertBufferedImage(target, img, UUID.randomUUID() - .toString()); + IImage image = convertBufferedImage(target, img); PlotObject po = new PlotObject(); po.image = image; ReferencedCoordinate rc = new ReferencedCoordinate( @@ -740,7 +547,7 @@ public class RadarGraphicFunctions { return images; } - public static PlotObject createDMDSTIImage(ReferencedCoordinate rc, + protected static PlotObject createDMDSTIImage(ReferencedCoordinate rc, String type, IGraphicsTarget target, GeneralGridGeometry gridGeometry, IDescriptor descriptor, RGB color) throws VizException { @@ -762,8 +569,7 @@ public class RadarGraphicFunctions { } BufferedImage img = createImage(objArr, "STI.svg", color); - IImage image = convertBufferedImage(target, img, UUID.randomUUID() - .toString()); + IImage image = convertBufferedImage(target, img); po.image = image; @@ -793,115 +599,70 @@ public class RadarGraphicFunctions { private static synchronized BufferedImage createImage( Map objs, String plotModelFile, RGB rgb) throws VizException { - // Get the SVG - Document document = loadSVG(plotModelFile); - // Load the values into the SVG - setSVGValues(objs, document); - - // Get the buffered image from SVG - BufferedImage bufferedImage = getBufferedImage(document, rgb); - - return bufferedImage; + RadarSVGImageFactory imageFactory = getImageFactory(plotModelFile); + imageFactory.setSVGValues(objs); + return imageFactory.createSingleColorImage(rgb); } - private static BufferedImage getBufferedImage(Document document, RGB rgb) { - Element svgRoot = document.getDocumentElement(); - int originalPlotModelWidth = Integer.parseInt(svgRoot.getAttributeNS( - null, "width")); - int originalPlotModelHeight = Integer.parseInt(svgRoot.getAttributeNS( - null, "height")); - - byte[] red = new byte[] { 0, (byte) rgb.red }; - byte[] green = new byte[] { 0, (byte) rgb.green }; - byte[] blue = new byte[] { 0, (byte) rgb.blue }; - - IndexColorModel tm = new IndexColorModel(8, 2, red, green, blue, 0); - - BufferedImage bufferedImage = new BufferedImage(originalPlotModelWidth, - originalPlotModelHeight, BufferedImage.TYPE_BYTE_INDEXED, tm); - Graphics2D g2d = bufferedImage.createGraphics(); - - GraphicsNode theGraphicsNode = builder.build(bridgeContext, document); - theGraphicsNode.primitivePaint(g2d); - theGraphicsNode.paint(g2d); - // Cleanup and return image - g2d.dispose(); - - return bufferedImage; + private static RadarSVGImageFactory getImageFactory(String plotModelFile) + throws VizException { + RadarSVGImageFactory imageFactory = imageFactoryMap.get(plotModelFile); + if(imageFactory == null){ + imageFactory = new RadarSVGImageFactory(plotModelFile); + } + return imageFactory; } - private static void setSVGValues(Map objs, Document document) { - Element plot = document.getElementById("plotData"); - NodeList plotElements = plot.getChildNodes(); - for (int i = 0; i < plotElements.getLength(); i++) { - if (Node.ELEMENT_NODE == plotElements.item(i).getNodeType()) { - Element plotElement = (Element) plotElements.item(i); - String id = plotElement.getAttribute("id"); + /** + * Converting the buffered image to a IGraphicsTarget API. + */ + protected static IImage convertBufferedImage(IGraphicsTarget target, + final BufferedImage img) { + return target.initializeRaster(new IRenderedImageCallback() { + @Override + public RenderedImage getImage() throws VizException { + return img; + } + }); + } - if (id != null && objs.containsKey(id)) { - Object value = objs.get(id); - plotElement.getChildNodes().item(0) - .setNodeValue(value.toString()); + private static class RadarSVGImageFactory extends SVGImageFactory { + + public RadarSVGImageFactory(String localizationPath) + throws VizException { + super(RADAR_PLOTMODEL_DIR + IPathManager.SEPARATOR + + localizationPath); + } + + public BufferedImage createSingleColorImage(RGB color) { + Element svgRoot = document.getDocumentElement(); + int width = Integer.parseInt(svgRoot.getAttributeNS(null, "width")); + int height = Integer.parseInt(svgRoot + .getAttributeNS(null, "height")); + return super.createSingleColorImage(color, width, height); + } + + public Document getDocument() { + return document; + } + + public void setSVGValues(Map objs) { + Element plot = document.getElementById("plotData"); + NodeList plotElements = plot.getChildNodes(); + for (int i = 0; i < plotElements.getLength(); i++) { + if (Node.ELEMENT_NODE == plotElements.item(i).getNodeType()) { + Element plotElement = (Element) plotElements.item(i); + String id = plotElement.getAttribute("id"); + + if (id != null && objs.containsKey(id)) { + Object value = objs.get(id); + plotElement.getChildNodes().item(0) + .setNodeValue(value.toString()); + } } } } } - private static Document loadSVG(String plotModelFile) throws VizException { - Document document = docMap.get(plotModelFile); - if (document == null) { - - String parser = XMLResourceDescriptor.getXMLParserClassName(); - SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); - - try { - document = f.createDocument(PathManagerFactory - .getPathManager() - .getStaticFile( - RADAR_PLOTMODEL_DIR + File.separator - + plotModelFile).toURI().toString()); - } catch (Exception e1) { - throw new VizException("Unable to set up radar graphics model", - e1); - } - docMap.put(plotModelFile, document); - } - - return document; - } - - /** - * Converting the buffered image to a graphics card image - * - * @param target - * @param img - * @param name - * @return - */ - public static IImage convertBufferedImage(IGraphicsTarget target, - BufferedImage img, String name) throws VizException { - final BufferedImage image = img; - return target.initializeRaster(new IRenderedImageCallback() { - @Override - public RenderedImage getImage() throws VizException { - return image; - } - }); - } - - /** - * Drawing the legend for the color bars on the top left - * - * @param colors - * @return - */ - public static BufferedImage drawColorLegend(IGraphicsTarget target, - IDescriptor descriptor, RGB[] colors, int startNum, int endNum, - int offset) { - BufferedImage img = new BufferedImage(15, 15, - BufferedImage.TYPE_BYTE_INDEXED); - - return img; - } } diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicsPage.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicsPage.java index c52ea25e1f..53f977487a 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicsPage.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicsPage.java @@ -107,8 +107,10 @@ import com.vividsolutions.jts.geom.LineString; * Jun 04, 2014 3232 bsteffen Cleanup. * Aug 11, 2014 3504 mapeters Replaced deprecated IODataPreparer * instances with IRenderedImageCallback. - * Sep 03, 2014 3574 njensen Properly dispose objects - * Nov 06, 2014 16776 zwang Handle AMDA product MBA + * Sep 03, 2014 3574 njensen Properly dispose objects + * Nov 06, 2014 16776 zwang Handle AMDA product MBA + * Feb 08, 2016 5318 randerso Font should not be preference based because the + * size must match the table outline * * * @@ -230,8 +232,8 @@ public class RadarGraphicsPage implements IRenderable { public void addSymbologyPacket(SymbologyPacket sp, CoordinateSystem cs) throws VizException { List localGeometries = new ArrayList(); - if (sp instanceof UnlinkedVectorPacket - || sp instanceof UnlinkedContourVectorPacket) { + if ((sp instanceof UnlinkedVectorPacket) + || (sp instanceof UnlinkedContourVectorPacket)) { List vectors = (List) RadarHelper .getItems(sp); @@ -699,8 +701,8 @@ public class RadarGraphicsPage implements IRenderable { if ((!onLowestElev.equals("") && onLowestElev .equalsIgnoreCase("Y")) - || (!baseHeight.equals("") && Double - .parseDouble(baseHeight) <= 1)) { + || (!baseHeight.equals("") && (Double + .parseDouble(baseHeight) <= 1))) { iconType = MesocycloneType.MESOCYCLONE_WITH_SPIKES; } else { iconType = MesocycloneType.MESOCYCLONE; @@ -731,7 +733,7 @@ public class RadarGraphicsPage implements IRenderable { float prevLat; float prevLon; // Forecast Positions - if (numFcstPos > 0 + if ((numFcstPos > 0) && (currentSettings.getDmdTrackType().equals( TrackTypes.FORECAST) || currentSettings .getDmdTrackType().equals( @@ -777,7 +779,7 @@ public class RadarGraphicsPage implements IRenderable { } // Past Positions - if (numPastPos > 0 + if ((numPastPos > 0) && (currentSettings.getDmdTrackType().equals( TrackTypes.PAST) || currentSettings .getDmdTrackType().equals( @@ -926,7 +928,7 @@ public class RadarGraphicsPage implements IRenderable { barb.setColor(this.color); // plot the wind arrow in the same length as 50 kts - double spd = Math.sqrt(pU * pU + pV * pV); + double spd = Math.sqrt((pU * pU) + (pV * pV)); if (spd > 0) { pU *= 50.0 / spd; pV *= 50.0 / spd; @@ -934,15 +936,14 @@ public class RadarGraphicsPage implements IRenderable { barb.setWind(pU, pV, false); final BufferedImage imgBuf = barb.getWindImage(false, - DisplayType.ARROW, - 0.2); + DisplayType.ARROW, 0.2); poWind.image = target .initializeRaster(new IRenderedImageCallback() { - @Override - public RenderedImage getImage() throws VizException { - return imgBuf; - } - }); + @Override + public RenderedImage getImage() throws VizException { + return imgBuf; + } + }); ReferencedCoordinate rc = referencedGfmCoord(wX, wY); try { @@ -985,28 +986,27 @@ public class RadarGraphicsPage implements IRenderable { } // Handle MBA product - private void drawMbaImage(GenericDataComponent currPt) - throws VizException { - + private void drawMbaImage(GenericDataComponent currPt) throws VizException { + double x, y; Coordinate point; // Determine if the feature should be rendered RadarDisplayControls currentSettings = RadarDisplayManager .getInstance().getCurrentSettings(); - + AreaComponent currFeature = (AreaComponent) currPt; - String cat = currFeature.getValue(MBAAttributeIDs.CATEGORY - .getName()); + String cat = currFeature.getValue(MBAAttributeIDs.CATEGORY.getName()); int catValue = cat.equals("") ? 0 : Integer.parseInt(cat); // By default, do not show MBA Wind Shear int minCat = 1; - if (currentSettings.isMbaShowWindShear()) + if (currentSettings.isMbaShowWindShear()) { minCat = 0; - + } + if (catValue >= minCat) { - + int numPoints = currFeature.getPoints().size(); Coordinate[] points = new Coordinate[numPoints]; @@ -1027,7 +1027,7 @@ public class RadarGraphicsPage implements IRenderable { } } } - + private PlotObject getImage(HdaHailPoint currPt) throws VizException { PlotObject image = null; @@ -1184,7 +1184,7 @@ public class RadarGraphicsPage implements IRenderable { * the magnification to set */ public void setMagnification(double magnification) { - if (this.magnification != magnification && this.font != null) { + if ((this.magnification != magnification) && (this.font != null)) { font.setMagnification((float) magnification, false); } @@ -1217,7 +1217,7 @@ public class RadarGraphicsPage implements IRenderable { public void paint(IGraphicsTarget target, PaintProperties paintProps) throws VizException { if (font == null) { - this.font = target.initializeFont(getClass().getName()); + this.font = target.initializeFont("Monospace", 10, null); this.font.setMagnification((float) magnification, false); this.font.setSmoothing(true); } @@ -1253,7 +1253,7 @@ public class RadarGraphicsPage implements IRenderable { double yOffset = 24.0; double xOffset = 24.0; double magnification = this.magnification; - if (this.screenGeometries != null && !this.screenGeometries.isEmpty()) { + if ((this.screenGeometries != null) && !this.screenGeometries.isEmpty()) { double minx = Double.MAX_VALUE; double maxx = Double.MIN_VALUE; for (Geometry g : this.screenGeometries) { @@ -1271,9 +1271,8 @@ public class RadarGraphicsPage implements IRenderable { double width = (maxx - minx) * magnification; // If the table wider than our canvas then shrink it if (width > paintProps.getCanvasBounds().width) { - magnification = this.magnification - * paintProps.getCanvasBounds().width - / (width + xOffset * 2); + magnification = (this.magnification * paintProps + .getCanvasBounds().width) / (width + (xOffset * 2)); font.setMagnification((float) magnification, false); magnification = target.getStringsBounds(testString).getHeight() / 14; width = (maxx - minx) * magnification; @@ -1284,11 +1283,11 @@ public class RadarGraphicsPage implements IRenderable { Coordinate[] coords = g.getCoordinates(); // offsets to make the table fit the screen - double x1 = coords[0].x * magnification + xOffset; - double y1 = (coords[0].y + 0.25) * magnification * 1.3 + double x1 = (coords[0].x * magnification) + xOffset; + double y1 = ((coords[0].y + 0.25) * magnification * 1.3) + yOffset; - double x2 = coords[1].x * magnification + xOffset; - double y2 = (coords[1].y + 0.25) * magnification * 1.3 + double x2 = (coords[1].x * magnification) + xOffset; + double y2 = ((coords[1].y + 0.25) * magnification * 1.3) + yOffset; DrawableLine line = new DrawableLine(); line.addPoint(x1, y1); @@ -1302,15 +1301,16 @@ public class RadarGraphicsPage implements IRenderable { // Only paint data table text if no configuration is specified or // if configuration says to show table. - if (tableModifier == null - || (tableModifier != null && tableModifier.isShowTable())) { + if ((tableModifier == null) + || ((tableModifier != null) && tableModifier.isShowTable())) { // Paint the table data text. - if (this.screenStringMap != null && !this.screenStringMap.isEmpty()) { + if ((this.screenStringMap != null) + && !this.screenStringMap.isEmpty()) { for (Coordinate c : this.screenStringMap.keySet()) { String str = this.screenStringMap.get(c); - double x = c.x * magnification + xOffset; - double y = c.y * magnification * 1.3 + yOffset; + double x = (c.x * magnification) + xOffset; + double y = (c.y * magnification * 1.3) + yOffset; // if (x < 0.1) { // x = 0; // } @@ -1386,7 +1386,7 @@ public class RadarGraphicsPage implements IRenderable { tableRight += width; } - int tableBottom = rowHeight * numberOfRows + tableTop; + int tableBottom = (rowHeight * numberOfRows) + tableTop; // Rows for (int i = tableTop; i <= tableBottom; i += rowHeight) { @@ -1551,7 +1551,7 @@ public class RadarGraphicsPage implements IRenderable { for (int k = 0; k < numPoints; k++) { x2 = currFeature.getPoints().get(k).getCoordinate1(); y2 = currFeature.getPoints().get(k).getCoordinate2(); - dist = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); + dist = ((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)); if (dist < minDist) { point.x = x2; point.y = y2; diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarMLResource.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarMLResource.java index 982c9af5f3..317d3301b5 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarMLResource.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarMLResource.java @@ -84,6 +84,8 @@ import com.vividsolutions.jts.geom.Coordinate; * around for better logical separation * Aug 14, 2014 3523 mapeters Updated deprecated {@link DrawableString#textStyle} * assignments. + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling + * * * * @author mnash @@ -138,7 +140,7 @@ public class RadarMLResource extends RadarGraphicsResource { @Override protected void initInternal(IGraphicsTarget target) throws VizException { // initialize the font - textFont = target.initializeFont(java.awt.Font.DIALOG, 11.0f, + textFont = target.initializeFont(java.awt.Font.DIALOG, 9, new IFont.Style[] {}); } diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/RadarDisplayControlDlg.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/RadarDisplayControlDlg.java index 2149f4cb16..303b4a6893 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/RadarDisplayControlDlg.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/RadarDisplayControlDlg.java @@ -54,6 +54,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * 04 DEC 2007 373 lvenable Initial creation * 06 Nov 2014 DCS 16776 zwang Add control for MBA * May 13, 2015 4461 bsteffen Add option for sails. + * Jan 14, 2016 5054 randerso Made independent shell to keep same + * behavior as when parented by dummy shell * * * @@ -205,7 +207,7 @@ public class RadarDisplayControlDlg extends CaveSWTDialog { * Parent shell. */ public RadarDisplayControlDlg(Shell parent) { - super(parent); + super(parent, SWT.DIALOG_TRIM, CAVE.INDEPENDENT_SHELL); setText("Radar Display Controls"); this.values = RadarDisplayManager.getInstance().getCurrentSettings(); diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/RadarDisplayControlsHandler.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/RadarDisplayControlsHandler.java index 4156bc333a..b378c79384 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/RadarDisplayControlsHandler.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/RadarDisplayControlsHandler.java @@ -23,12 +23,31 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.handlers.HandlerUtil; +/** + * Opens RadarDisplayControlDlg + * + *
      + * 
      + * SOFTWARE HISTORY
      + * 
      + * Date         Ticket#    Engineer    Description
      + * ------------ ---------- ----------- --------------------------
      + * Jan 14, 2016   5054     randerso    Set parent to active workbench window
      + *                                     instead of dummy shell
      + * 
      + * 
      + * + * @author randerso + * @version 1.0 + */ public class RadarDisplayControlsHandler extends AbstractHandler { @Override - public Object execute(ExecutionEvent arg0) throws ExecutionException { - RadarDisplayControlDlg dlg = new RadarDisplayControlDlg(new Shell()); + public Object execute(ExecutionEvent event) throws ExecutionException { + Shell shell = HandlerUtil.getActiveShell(event); + RadarDisplayControlDlg dlg = new RadarDisplayControlDlg(shell); dlg.open(); return null; diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/CellTrendGraph.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/CellTrendGraph.java index 241caf89d3..7c20832911 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/CellTrendGraph.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/CellTrendGraph.java @@ -61,6 +61,8 @@ import com.raytheon.viz.radar.ui.xy.RadarGraphResource.GraphPosition; * 07-21-14 #3412 mapeters Updated deprecated drawCircle call. * 07-24-14 #3429 mapeters Updated deprecated drawLine() calls. * 07-29-14 #3465 mapeters Updated deprecated drawString() calls. + * 11-05-2015 #5070 randerso Adjust font sizes for dpi scaling + * * * * @author askripsk @@ -122,7 +124,7 @@ public class CellTrendGraph extends XYGraph { for (XYDataList currSeries : dataSeries) { currLineStyle = dataSeriesLineTypes.get(i); currPointType = dataSeriesPointTypes.get(i++); - + DrawableLine line = new DrawableLine(); line.basics.color = colorCap.getColor(); line.width = outlineCap.getOutlineWidth(); @@ -161,10 +163,9 @@ public class CellTrendGraph extends XYGraph { } } } - + private AbstractDrawableObject createPoint(IGraphicsTarget target, - double x, double y, - PointType currPointType) throws VizException { + double x, double y, PointType currPointType) throws VizException { if (currPointType.equals(PointType.CIRCLE)) { DrawableCircle circle = new DrawableCircle(); circle = new DrawableCircle(); @@ -235,7 +236,7 @@ public class CellTrendGraph extends XYGraph { PointType pt = dataSeriesPointTypes.get(i); AbstractDrawableObject object = createPoint(target, labelx[i], labely[i], pt); - //Add the point to its corresponding list + // Add the point to its corresponding list if (object instanceof DrawableCircle) { circles.add((DrawableCircle) object); } else if (object instanceof DrawableLine) { @@ -256,7 +257,7 @@ public class CellTrendGraph extends XYGraph { strings[i].setCoordinates(labelx[i] + offset, labely[i]); strings[i].verticallAlignment = VerticalAlignment.MIDDLE; } - + target.drawLine(lines.toArray(new DrawableLine[0])); target.drawCircle(circles.toArray(new DrawableCircle[0])); target.drawStrings(strings); @@ -307,7 +308,7 @@ public class CellTrendGraph extends XYGraph { yAxis.setLabeling(axisLabels); yAxis.setDrawLinesAtLabels(true); yAxis.setLabelLineStyle(IGraphicsTarget.LineStyle.DASHED_LARGE); - yAxis.setFontSize(10); + yAxis.setFontSize(8); ArrayList label = new ArrayList(); label.add(this.yLabel); @@ -378,8 +379,8 @@ public class CellTrendGraph extends XYGraph { max = time; } - labelVals.put(Double.valueOf(time), String.format("%02d%02d", - time / 60, time % 60)); + labelVals.put(Double.valueOf(time), + String.format("%02d%02d", time / 60, time % 60)); } NumberAxis xAxis = AxisFactory.buildNumberAxis( @@ -387,7 +388,7 @@ public class CellTrendGraph extends XYGraph { xAxis.setDrawLinesAtLabels(false); xAxis.setDrawTickmarksAtLabels(true); xAxis.setLabelLineStyle(IGraphicsTarget.LineStyle.SOLID); - xAxis.setFontSize(10); + xAxis.setFontSize(8); AxisLabeling axisLabels = new AxisLabeling(); axisLabels.setLabels(labelVals); @@ -414,7 +415,7 @@ public class CellTrendGraph extends XYGraph { NumberAxis yAxis = AxisFactory.buildNumberAxis( IAxis.Orientation.HORIZONTAL, 0, 100, "Percent"); - yAxis.setFontSize(10); + yAxis.setFontSize(8); yAxis.setDrawLinesAtLabels(true); // axis.addTitle(getName(), new RGB(100, 100, 100)); yAxis.setLabelLineStyle(IGraphicsTarget.LineStyle.DASHED); diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/RadarXYResource.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/RadarXYResource.java index 6c1c09c31a..d48d1e25e2 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/RadarXYResource.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/RadarXYResource.java @@ -85,6 +85,8 @@ import com.vividsolutions.jts.geom.Coordinate; * hdf5. * Sep 23, 2013 2363 bsteffen Add more vector configuration options. * Jul 23, 2014 3429 mapeters Updated deprecated drawLine() calls. + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling + * * * * @author askripsk @@ -145,7 +147,7 @@ public class RadarXYResource extends RadarImageResource { if (this.font == null) { // Anything larger than 10 leads to text overlap, to go larger we // will need to place the text smarter - this.font = target.initializeFont(Font.MONOSPACED, 10, + this.font = target.initializeFont(Font.MONOSPACED, 8, new Style[] { Style.BOLD }); } if (paintProps.getDataTime() == null) { @@ -221,7 +223,8 @@ public class RadarXYResource extends RadarImageResource { .getMagnification().floatValue(); // Paint unlinked lines - DrawableLine[] lines = new DrawableLine[this.unlinkedLines.size() + this.linkedLines.size()]; + DrawableLine[] lines = new DrawableLine[this.unlinkedLines.size() + + this.linkedLines.size()]; int i = 0; for (UnlinkedVector currVec : this.unlinkedLines) { lines[i] = new DrawableLine(); @@ -280,8 +283,7 @@ public class RadarXYResource extends RadarImageResource { plotLoc.y -= 2; plotLoc.x *= SCALAR; plotLoc.y *= SCALAR; - renderables[index].paintBarb(plotLoc, - point.getWindBarbSpd(), + renderables[index].paintBarb(plotLoc, point.getWindBarbSpd(), Math.toRadians(point.getWindBarbDir())); } for (VectorGraphicsRenderable renderable : renderables) { diff --git a/cave/com.raytheon.viz.redbook/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.redbook/META-INF/MANIFEST.MF index e8838a5ea5..77ee69f5eb 100644 --- a/cave/com.raytheon.viz.redbook/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.redbook/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Redbook Plug-in Bundle-SymbolicName: com.raytheon.viz.redbook;singleton:=true -Bundle-Version: 1.14.0.qualifier +Bundle-Version: 1.15.0.qualifier Bundle-Activator: com.raytheon.viz.redbook.Activator Bundle-Vendor: Raytheon Require-Bundle: org.apache.batik, @@ -11,12 +11,13 @@ Require-Bundle: org.apache.batik, com.raytheon.viz.core, org.geotools, com.raytheon.viz.ui, - org.apache.commons.lang, + org.apache.commons.lang3;bundle-version="3.4.0", com.raytheon.uf.common.serialization, com.raytheon.uf.common.pointdata;bundle-version="1.11.26", com.raytheon.viz.pointdata, com.raytheon.uf.viz.productbrowser;bundle-version="1.11.31", - com.raytheon.uf.common.dataplugin.redbook;bundle-version="1.14.0" + com.raytheon.uf.common.dataplugin.redbook;bundle-version="1.14.0", + com.raytheon.uf.viz.core.point;bundle-version="1.15.1" Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.viz.redbook, com.raytheon.viz.redbook.blocks, diff --git a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/RedbookResource.java b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/RedbookResource.java index d9d3913095..21f2d0081d 100644 --- a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/RedbookResource.java +++ b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/RedbookResource.java @@ -25,7 +25,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import org.apache.commons.lang.Validate; +import org.apache.commons.lang3.Validate; import org.opengis.referencing.crs.CoordinateReferenceSystem; import com.raytheon.uf.common.dataplugin.HDF5Util; @@ -69,6 +69,8 @@ import com.raytheon.viz.redbook.rsc.RedbookFrame.RedbookStatus; * Mar 13, 2014 2907 njensen split edex.redbook plugin into common * and edex redbook plugins * Jun 26, 2015 4512 mapeters Updated for RedbookWMOMap API changes + * Oct 27, 2015 4798 bsteffen Throw VizException for missing svg. + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling * * * @@ -87,7 +89,7 @@ public class RedbookResource extends private IFont font; - private WxSymbols wxSymbols = new WxSymbols(); + private WxSymbols wxSymbols; private String humanReadableName; @@ -96,11 +98,12 @@ public class RedbookResource extends private boolean magnificationChanged = false; protected RedbookResource(RedbookResourceData resourceData, - LoadProperties loadProperties) { + LoadProperties loadProperties) throws VizException { super(resourceData, loadProperties); this.dataTimes = new ArrayList(); resourceData.addChangeListener(this); this.redbookFrames = new HashMap(); + wxSymbols = new WxSymbols(); } /* @@ -114,8 +117,9 @@ public class RedbookResource extends font.dispose(); font = null; } - for (RedbookFrame frame : this.redbookFrames.values()) + for (RedbookFrame frame : this.redbookFrames.values()) { frame.dispose(); + } } /* @@ -205,8 +209,9 @@ public class RedbookResource extends @Override public void remove(DataTime dataTime) { RedbookFrame frame = this.redbookFrames.remove(dataTime); - if (frame != null) + if (frame != null) { frame.dispose(); + } } /* @@ -219,8 +224,9 @@ public class RedbookResource extends @Override protected void initInternal(IGraphicsTarget target) throws VizException { for (RedbookFrame frame : this.redbookFrames.values()) { - if (!frame.hasInited()) + if (!frame.hasInited()) { frame.init(target); + } } } @@ -249,7 +255,7 @@ public class RedbookResource extends font = null; } font = target.initializeFont(target.getDefaultFont() - .getFontName(), (float) (10 * magnification), null); + .getFontName(), (float) (8 * magnification), null); magnificationChanged = false; } diff --git a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/RedbookResourceData.java b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/RedbookResourceData.java index bc24021ae6..ac89112ff5 100644 --- a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/RedbookResourceData.java +++ b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/RedbookResourceData.java @@ -23,10 +23,11 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; -import org.apache.commons.lang.Validate; +import org.apache.commons.lang3.Validate; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.redbook.RedbookRecord; +import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.LoadProperties; @@ -42,6 +43,7 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties; * Feb 18, 2009 chammack Initial creation * Mar 13, 2014 2907 njensen split edex.redbook plugin into common and * edex redbook plugins + * Oct 27, 2015 4798 bsteffen Throw VizException for missing svg. * * * @@ -63,7 +65,8 @@ public class RedbookResourceData extends AbstractRequestableResourceData { */ @Override protected AbstractVizResource constructResource( - LoadProperties loadProperties, PluginDataObject[] objects) { + LoadProperties loadProperties, PluginDataObject[] objects) + throws VizException { RedbookResource rsc = new RedbookResource(this, loadProperties); for (PluginDataObject pdo : objects) { Validate.isTrue( diff --git a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/WxSymbols.java b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/WxSymbols.java index fb7f9bf9e2..c349c14aa6 100644 --- a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/WxSymbols.java +++ b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/WxSymbols.java @@ -19,31 +19,21 @@ **/ package com.raytheon.viz.redbook.rsc; -import java.awt.Graphics2D; import java.awt.image.BufferedImage; -import java.awt.image.IndexColorModel; import java.awt.image.RenderedImage; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; import java.util.HashMap; +import java.util.Map; -import org.apache.batik.bridge.BridgeContext; -import org.apache.batik.bridge.GVTBuilder; -import org.apache.batik.bridge.UserAgentAdapter; -import org.apache.batik.dom.svg.SAXSVGDocumentFactory; -import org.apache.batik.gvt.GraphicsNode; -import org.apache.batik.util.XMLResourceDescriptor; import org.eclipse.swt.graphics.RGB; -import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; -import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.data.IRenderedImageCallback; import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.point.svg.SVGImageFactory; /** * Create weather symbol images to be drawn on the target. @@ -51,68 +41,35 @@ import com.raytheon.uf.viz.core.exception.VizException; *
        * 
        * SOFTWARE HISTORY
      - * Date         Ticket#    Engineer    Description
      - * ------------ ---------- ----------- --------------------------
      - *                                     Initial creation.
      - * Aug 11, 2014 3504       mapeters    Replaced deprecated IODataPreparer
      - *                                     instances with IRenderedImageCallback.
      + * Date          Ticket#  Engineer  Description
      + * ------------- -------- --------- --------------------------
      + * Aug 11, 2014  3504     mapeters  Replaced deprecated IODataPreparer
      + *                                  instances with IRenderedImageCallback.
      + * Oct 27, 2015  4798     bsteffen  Extend SVGImageFactory
        * 
        * 
      */ -public class WxSymbols { +public class WxSymbols extends SVGImageFactory { + + private final Map images = new HashMap<>(); + private IGraphicsTarget target; private RGB color; - private HashMap images = new HashMap(); - - private Document document; - - private Element textNode; - - private Text textText; - - private final GVTBuilder builder; - - private final BridgeContext bridgeContext; - - public WxSymbols() { - String parser = XMLResourceDescriptor.getXMLParserClassName(); - SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); - try { - document = f.createDocument(PathManagerFactory.getPathManager() - .getStaticFile( - "redbook" + File.separator - + "RedbookSymbolText.svg").toURI() - .toString()); - } catch (MalformedURLException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - textNode = document.getElementById("theText"); - textText = (Text) textNode.getFirstChild(); - - UserAgentAdapter userAgentAdapter = new UserAgentAdapter(); - this.bridgeContext = new BridgeContext(userAgentAdapter); - this.builder = new GVTBuilder(); + public WxSymbols() throws VizException { + super("redbook" + + IPathManager.SEPARATOR + "RedbookSymbolText.svg"); } - private IndexColorModel tm; public IImage getImage(IGraphicsTarget target, RGB color, char c) { if (this.target != target || this.color == null || !this.color.equals(color)) { - byte[] red = { 0, (byte) color.red }; - byte[] green = { 0, (byte) color.green }; - byte[] blue = { 0, (byte) color.blue }; this.target = target; this.color = new RGB(color.red, color.green, color.blue); - tm = new IndexColorModel(8, 2, red, green, blue, 0); images.clear(); /* @@ -132,14 +89,6 @@ public class WxSymbols { IImage image = images.get(c); if (image == null) { - // Is this code going to convert the font every time? - // should use the bridge context to get the TextNode and change - // that instead of the origonal DOM and rebuild.. - - final BufferedImage bufferedImage = new BufferedImage(12, 12, - BufferedImage.TYPE_BYTE_INDEXED, tm); - Graphics2D g2d = bufferedImage.createGraphics(); - // textText.setTextContent(Character.toString(c)); /* @@ -147,14 +96,12 @@ public class WxSymbols { * font to support low ASCII characters in an SVG file. Use the * Unicode PUA at U+E000 instead. */ + Element textNode = document.getElementById("theText"); + Text textText = (Text) textNode.getFirstChild(); textText.setNodeValue(Character.toString((char) (c + 0xe000))); - GraphicsNode gn = builder.build(this.bridgeContext, this.document); - gn.paint(g2d); - /* - * g2d.setColor(new Color(color.red,color.green,color.blue)); - * g2d.drawRect(0, 0, 13, 13); - */ + final BufferedImage bufferedImage = createSingleColorImage(color, + 12, 12); image = target.initializeRaster(new IRenderedImageCallback() { @Override @@ -163,8 +110,6 @@ public class WxSymbols { } }); images.put(c, image); - - g2d.dispose(); } return image; } diff --git a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbookua/rsc/RedbookUpperAirResource.java b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbookua/rsc/RedbookUpperAirResource.java index d4aa9b209d..2154e3c104 100644 --- a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbookua/rsc/RedbookUpperAirResource.java +++ b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbookua/rsc/RedbookUpperAirResource.java @@ -27,7 +27,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import org.apache.commons.lang.Validate; +import org.apache.commons.lang3.Validate; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -91,6 +91,12 @@ import com.vividsolutions.jts.geom.Coordinate; * Aug 11, 2014 3504 mapeters Replaced deprecated IODataPreparer * instances with IRenderedImageCallback. * Jun 26, 2015 4512 mapeters Updated for RedbookWMOMap API changes. + * Oct 27, 2015 4798 bsteffen Handle VizException for missing svg. + * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling + * Dec 03, 2015 5143 kbisanz Remove unneeded setting of DataTime + * utility flag in getName() to prevent + * NPE in case of no data. + * * * * @@ -135,8 +141,9 @@ public class RedbookUpperAirResource extends */ @Override protected void disposeInternal() { - for (UAFrame frame : this.frames.values()) + for (UAFrame frame : this.frames.values()) { frame.dispose(); + } if (font != null) { font.dispose(); @@ -150,13 +157,6 @@ public class RedbookUpperAirResource extends */ @Override public String getName() { - DataTime[] times = descriptor.getTimeMatchingMap().get(this); - for (int i = 0; i < times.length; i++) { - if (times[i] != null) { - times[i] = times[i].clone(); - times[i].getUtilityFlags().remove(DataTime.FLAG.FCST_USED); - } - } if (this.humanReadableName == null) { buildHumanReadableName(); } @@ -181,8 +181,9 @@ public class RedbookUpperAirResource extends return; } RedbookWMOMap.Info info = map.getValue(wmo.getConstraintValue()); - if (info != null && info.name != null) + if (info != null && info.name != null) { this.humanReadableName = info.name; + } } } @@ -230,8 +231,9 @@ public class RedbookUpperAirResource extends public void remove(DataTime dataTime) { dataTimes.remove(dataTime); UAFrame frame = frames.remove(dataTime); - if (frame != null) + if (frame != null) { frame.dispose(); + } } /* @@ -243,11 +245,11 @@ public class RedbookUpperAirResource extends */ @Override protected void initInternal(IGraphicsTarget target) throws VizException { - this.font = target.initializeFont("Monospace", 10, null); + this.font = target.initializeFont("Monospace", 8, null); this.graphicsTarget = target; } - protected PlotModelFactory getPlotModelFactory() { + protected PlotModelFactory getPlotModelFactory() throws VizException { if (plotModelFactory == null) { plotModelFactory = new PlotModelFactory(getDescriptor(), "redbookuaDesign.svg"); @@ -274,17 +276,19 @@ public class RedbookUpperAirResource extends UAFrame frame = frames.get(displayedDataTime); if (frame != null) { - if (frame.isReadyToPaint()) + if (frame.isReadyToPaint()) { frame.paint(target, paintProps); - else + } else { job.upadte(); + } } } private void invalidateAll() { synchronized (job) { - for (UAFrame frame : frames.values()) + for (UAFrame frame : frames.values()) { frame.invalidate(); + } } } @@ -378,14 +382,21 @@ public class RedbookUpperAirResource extends } public void init(IGraphicsTarget target) { - if (pointData == null) + if (pointData == null) { retrieveAndDecodeData(); + } PlotModelFactory pmf; synchronized (job) { plotSettingsChanged = false; - pmf = getPlotModelFactory(); + try { + pmf = getPlotModelFactory(); + } catch (VizException e) { + statusHandler.handle(Priority.PROBLEM, + e.getLocalizedMessage(), e); + return; + } int actualPlotWidth = pmf.getDefinedPlotModelWidth(); Double magnification = getCapability( MagnificationCapability.class).getMagnification(); @@ -426,20 +437,22 @@ public class RedbookUpperAirResource extends } synchronized (job) { - if (!plotSettingsChanged) + if (!plotSettingsChanged) { valid = true; + } } } public void dispose() { synchronized (this) { - if (images != null) + if (images != null) { for (int i = 0; i < images.length; ++i) { if (images[i] != null) { images[i].dispose(); images[i] = null; } } + } valid = false; redbookRecord = null; pointData = null; @@ -448,8 +461,9 @@ public class RedbookUpperAirResource extends public void paint(IGraphicsTarget target, PaintProperties paintProps) throws VizException { - if (pointData == null || images == null) + if (pointData == null || images == null) { return; + } IExtent pe = paintProps.getView().getExtent(); @@ -470,24 +484,27 @@ public class RedbookUpperAirResource extends int threshold; - if (netZoom <= 0.8) + if (netZoom <= 0.8) { threshold = 0; - else if (netZoom <= 1.5) + } else if (netZoom <= 1.5) { threshold = 1; - else if (netZoom <= 2.5) + } else if (netZoom <= 2.5) { threshold = 2; - else + } else { threshold = 3; + } for (int i = 0; i < pointData.getCurrentSz(); ++i) { - if (images[i] == null) + if (images[i] == null) { continue; + } PointDataView pdv = pointData.readRandom(i); int zoomLevel = pdv.getInt(RedbookUpperAirDecoder.P_ZOOM_LEVEL); - if (zoomLevel > threshold) + if (zoomLevel > threshold) { continue; + } double[] worldCoord = new double[] { pdv.getFloat(RedbookUpperAirDecoder.P_LONGITUDE), @@ -512,8 +529,9 @@ public class RedbookUpperAirResource extends stationPixelLocation[1] + scaleValue, 0 }; if (ul[0] > pe.getMaxX() || ul[1] > pe.getMaxY() - || lr[0] < pe.getMinX() || lr[1] < pe.getMinY()) + || lr[0] < pe.getMinX() || lr[1] < pe.getMinY()) { continue; + } PixelCoverage pc = new PixelCoverage(new Coordinate(ul[0], ul[1], ul[2]), new Coordinate(ur[0], ur[1], ur[2]), diff --git a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbookua/rsc/RedbookUpperAirResourceData.java b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbookua/rsc/RedbookUpperAirResourceData.java index 37a36c2399..78547f34c4 100644 --- a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbookua/rsc/RedbookUpperAirResourceData.java +++ b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbookua/rsc/RedbookUpperAirResourceData.java @@ -22,7 +22,7 @@ package com.raytheon.viz.redbookua.rsc; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; -import org.apache.commons.lang.Validate; +import org.apache.commons.lang3.Validate; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.redbook.RedbookRecord; diff --git a/cave/com.raytheon.viz.satellite/localization/bundles/Satellite3_9WindPlots.xml b/cave/com.raytheon.viz.satellite/localization/bundles/Satellite3_9WindPlots.xml index 53153e3770..5f91331f3d 100644 --- a/cave/com.raytheon.viz.satellite/localization/bundles/Satellite3_9WindPlots.xml +++ b/cave/com.raytheon.viz.satellite/localization/bundles/Satellite3_9WindPlots.xml @@ -1,52 +1,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteLayerPlot.xml b/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteLayerPlot.xml index c669e5d6be..3da444bea2 100644 --- a/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteLayerPlot.xml +++ b/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteLayerPlot.xml @@ -1,52 +1,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteWV7_0WindPlots.xml b/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteWV7_0WindPlots.xml index 70094eeb22..248ff3bc22 100644 --- a/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteWV7_0WindPlots.xml +++ b/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteWV7_0WindPlots.xml @@ -1,185 +1,136 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteWV7_4WindPlots.xml b/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteWV7_4WindPlots.xml index 6978c1b829..8a7fa984bd 100644 --- a/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteWV7_4WindPlots.xml +++ b/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteWV7_4WindPlots.xml @@ -1,211 +1,154 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteWindPlots.xml b/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteWindPlots.xml index 17060a0485..45bb8eeeb5 100644 --- a/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteWindPlots.xml +++ b/cave/com.raytheon.viz.satellite/localization/bundles/SatelliteWindPlots.xml @@ -1,237 +1,172 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.viz.satellite/localization/bundles/Scatterometer.xml b/cave/com.raytheon.viz.satellite/localization/bundles/Scatterometer.xml new file mode 100644 index 0000000000..a284d1373d --- /dev/null +++ b/cave/com.raytheon.viz.satellite/localization/bundles/Scatterometer.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.viz.satellite/localization/menus/satellite/baseDerivedProductPlots.xml b/cave/com.raytheon.viz.satellite/localization/menus/satellite/baseDerivedProductPlots.xml index 36e5a55bce..4fd460a578 100644 --- a/cave/com.raytheon.viz.satellite/localization/menus/satellite/baseDerivedProductPlots.xml +++ b/cave/com.raytheon.viz.satellite/localization/menus/satellite/baseDerivedProductPlots.xml @@ -208,16 +208,6 @@ - @@ -231,23 +221,23 @@ + menuText="SSM/I Wind Speeds" id="SSMIWindSpeeds"> + menuText="SSM/I Precip. Water" id="SSMIPrecipWater"> + menuText="SSM/I Sea Temperature" id="SSMISeaTemp"> + menuText="SSM/I VIL" id="SSMIVIL"> diff --git a/cave/com.raytheon.viz.satellite/localization/menus/satellite/baseDerivedProductsImagery.xml b/cave/com.raytheon.viz.satellite/localization/menus/satellite/baseDerivedProductsImagery.xml index 3cc60cd8c3..57f2ea9604 100644 --- a/cave/com.raytheon.viz.satellite/localization/menus/satellite/baseDerivedProductsImagery.xml +++ b/cave/com.raytheon.viz.satellite/localization/menus/satellite/baseDerivedProductsImagery.xml @@ -40,7 +40,7 @@ + menuText="Cloud Amount" id="cloudAmount"> diff --git a/cave/com.raytheon.viz.pointdata/localization/plotModels/ascatPlotDesign.svg b/cave/com.raytheon.viz.satellite/localization/plotModels/ascatPlotDesign.svg similarity index 100% rename from cave/com.raytheon.viz.pointdata/localization/plotModels/ascatPlotDesign.svg rename to cave/com.raytheon.viz.satellite/localization/plotModels/ascatPlotDesign.svg diff --git a/cave/com.raytheon.viz.pointdata/localization/plotModels/hdwTypePlotDesign.svg b/cave/com.raytheon.viz.satellite/localization/plotModels/hdwTypePlotDesign.svg similarity index 100% rename from cave/com.raytheon.viz.pointdata/localization/plotModels/hdwTypePlotDesign.svg rename to cave/com.raytheon.viz.satellite/localization/plotModels/hdwTypePlotDesign.svg diff --git a/cave/com.raytheon.viz.pointdata/localization/plotModels/hdw_sat_lookup.txt b/cave/com.raytheon.viz.satellite/localization/plotModels/hdw_sat_lookup.txt similarity index 100% rename from cave/com.raytheon.viz.pointdata/localization/plotModels/hdw_sat_lookup.txt rename to cave/com.raytheon.viz.satellite/localization/plotModels/hdw_sat_lookup.txt diff --git a/cave/com.raytheon.viz.pointdata/localization/plotModels/sat_name_lookup.txt b/cave/com.raytheon.viz.satellite/localization/plotModels/sat_name_lookup.txt similarity index 100% rename from cave/com.raytheon.viz.pointdata/localization/plotModels/sat_name_lookup.txt rename to cave/com.raytheon.viz.satellite/localization/plotModels/sat_name_lookup.txt diff --git a/cave/com.raytheon.viz.pointdata/localization/plotModels/sat_type_lookup.txt b/cave/com.raytheon.viz.satellite/localization/plotModels/sat_type_lookup.txt similarity index 100% rename from cave/com.raytheon.viz.pointdata/localization/plotModels/sat_type_lookup.txt rename to cave/com.raytheon.viz.satellite/localization/plotModels/sat_type_lookup.txt diff --git a/cave/com.raytheon.viz.pointdata/localization/plotModels/sat_type_lookup_ascat.txt b/cave/com.raytheon.viz.satellite/localization/plotModels/sat_type_lookup_ascat.txt similarity index 100% rename from cave/com.raytheon.viz.pointdata/localization/plotModels/sat_type_lookup_ascat.txt rename to cave/com.raytheon.viz.satellite/localization/plotModels/sat_type_lookup_ascat.txt diff --git a/cave/com.raytheon.viz.pointdata/localization/plotModels/ssmiPWPlotDesign.svg b/cave/com.raytheon.viz.satellite/localization/plotModels/ssmiPWPlotDesign.svg similarity index 100% rename from cave/com.raytheon.viz.pointdata/localization/plotModels/ssmiPWPlotDesign.svg rename to cave/com.raytheon.viz.satellite/localization/plotModels/ssmiPWPlotDesign.svg diff --git a/cave/com.raytheon.viz.pointdata/localization/plotModels/ssmiSTPlotDesign.svg b/cave/com.raytheon.viz.satellite/localization/plotModels/ssmiSTPlotDesign.svg similarity index 100% rename from cave/com.raytheon.viz.pointdata/localization/plotModels/ssmiSTPlotDesign.svg rename to cave/com.raytheon.viz.satellite/localization/plotModels/ssmiSTPlotDesign.svg diff --git a/cave/com.raytheon.viz.pointdata/localization/plotModels/ssmiVILPlotDesign.svg b/cave/com.raytheon.viz.satellite/localization/plotModels/ssmiVILPlotDesign.svg similarity index 100% rename from cave/com.raytheon.viz.pointdata/localization/plotModels/ssmiVILPlotDesign.svg rename to cave/com.raytheon.viz.satellite/localization/plotModels/ssmiVILPlotDesign.svg diff --git a/cave/com.raytheon.viz.pointdata/localization/plotModels/ssmiVILPlotDesign.txt b/cave/com.raytheon.viz.satellite/localization/plotModels/ssmiVILPlotDesign.txt similarity index 100% rename from cave/com.raytheon.viz.pointdata/localization/plotModels/ssmiVILPlotDesign.txt rename to cave/com.raytheon.viz.satellite/localization/plotModels/ssmiVILPlotDesign.txt diff --git a/cave/com.raytheon.viz.pointdata/localization/plotModels/ssmiWindPlotDesign.svg b/cave/com.raytheon.viz.satellite/localization/plotModels/ssmiWindPlotDesign.svg similarity index 100% rename from cave/com.raytheon.viz.pointdata/localization/plotModels/ssmiWindPlotDesign.svg rename to cave/com.raytheon.viz.satellite/localization/plotModels/ssmiWindPlotDesign.svg diff --git a/cave/com.raytheon.viz.satellite/localization/plotWind/ascat_wind.xml b/cave/com.raytheon.viz.satellite/localization/plotWind/ascat_wind.xml new file mode 100644 index 0000000000..7ece70ea3a --- /dev/null +++ b/cave/com.raytheon.viz.satellite/localization/plotWind/ascat_wind.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.viz.satellite/localization/plotWind/hdw_wind.xml b/cave/com.raytheon.viz.satellite/localization/plotWind/hdw_wind.xml new file mode 100644 index 0000000000..2dd21d8b0d --- /dev/null +++ b/cave/com.raytheon.viz.satellite/localization/plotWind/hdw_wind.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.viz.spi/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.spi/META-INF/MANIFEST.MF index e4b3fac88f..921cbe2fdd 100644 --- a/cave/com.raytheon.viz.spi/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.spi/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: SPI Plug-in Bundle-SymbolicName: com.raytheon.viz.spi;singleton:=true -Bundle-Version: 1.14.0.qualifier +Bundle-Version: 1.15.0.qualifier Bundle-Activator: com.raytheon.viz.spi.Activator Bundle-Vendor: Raytheon Require-Bundle: org.eclipse.ui, @@ -11,7 +11,6 @@ Require-Bundle: org.eclipse.ui, com.raytheon.viz.ui, org.geotools, com.raytheon.viz.pointdata, - org.apache.commons.lang, com.raytheon.uf.viz.core.maps;bundle-version="1.0.0" Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.viz.spi diff --git a/cave/com.raytheon.viz.spi/src/com/raytheon/viz/spi/SPIResource.java b/cave/com.raytheon.viz.spi/src/com/raytheon/viz/spi/SPIResource.java index 91e2d8e6f0..e8b8ef7cfa 100644 --- a/cave/com.raytheon.viz.spi/src/com/raytheon/viz/spi/SPIResource.java +++ b/cave/com.raytheon.viz.spi/src/com/raytheon/viz/spi/SPIResource.java @@ -36,12 +36,10 @@ import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; import com.raytheon.uf.viz.core.IGraphicsTarget.PointStyle; -import com.raytheon.uf.viz.core.drawables.IFont; import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.map.MapDescriptor; import com.raytheon.uf.viz.core.maps.rsc.StyledMapResource; -import com.raytheon.uf.viz.core.rsc.IResourceDataChanged; import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; import com.raytheon.uf.viz.core.rsc.capabilities.DensityCapability; @@ -56,13 +54,14 @@ import com.raytheon.viz.pointdata.StaticPlotInfoPV.SPIEntry; * *
        * 
      - *    SOFTWARE HISTORY
      - *   
      - *    Date          Ticket#     Engineer    Description
      - *    ------------  ----------  ----------- --------------------------
      - *    1/10/08       562         bphillip    Initial Creation.
      - *    8/04/14       3489        mapeters    Updated deprecated getStringBounds() calls.
      - *    08/21/2014   #3459        randerso    Restructured Map resource class hierarchy
      + * SOFTWARE HISTORY
      + * 
      + * Date          Ticket#     Engineer    Description
      + * ------------  ----------  ----------- --------------------------
      + * 1/10/08       562         bphillip    Initial Creation.
      + * 8/04/14       3489        mapeters    Updated deprecated getStringBounds() calls.
      + * 08/21/2014   #3459        randerso    Restructured Map resource class hierarchy
      + * Nov 05, 2015 #5070        randerso    Moved label font management up to AbstractMapResource
        * 
        * 
      * @@ -70,8 +69,7 @@ import com.raytheon.viz.pointdata.StaticPlotInfoPV.SPIEntry; * */ public class SPIResource extends - StyledMapResource implements - IResourceDataChanged { + StyledMapResource { /** The line color */ private static final RGB DEFAULT_COLOR = new RGB(155, 155, 155); @@ -82,8 +80,6 @@ public class SPIResource extends private int pixelSizeHint = 90; - private IFont font; - public int getPixelSizeHint() { return pixelSizeHint; } @@ -102,7 +98,6 @@ public class SPIResource extends @Override protected void initInternal(IGraphicsTarget target) throws VizException { super.initInternal(target); - resourceData.addChangeListener(this); getCapability(LabelableCapability.class).setAvailableLabelFields( "Label"); getCapability(LabelableCapability.class).setLabelField("Label"); @@ -129,17 +124,12 @@ public class SPIResource extends } project(this.descriptor.getCRS()); - - font = target.initializeFont(target.getDefaultFont().getFontName(), 10, - null); - float magnification = getCapability(MagnificationCapability.class) - .getMagnification().floatValue(); - font.setMagnification(magnification); } @Override protected void paintInternal(IGraphicsTarget target, PaintProperties paintProps) throws VizException { + int displayWidth = (int) (this.descriptor.getMapWidth() * paintProps .getZoomLevel()); @@ -150,7 +140,7 @@ public class SPIResource extends / paintProps.getView().getExtent().getWidth(); DrawableString n = new DrawableString("N"); - n.font = font; + n.font = getFont(target); Rectangle2D charSize = target.getStringsBounds(n); double charWidth = charSize.getWidth(); double charHeight = charSize.getHeight(); @@ -196,7 +186,7 @@ public class SPIResource extends points.add(entry.pixel); if (isLabeled && (magnification > 0.0)) { DrawableString string = new DrawableString(key, color); - string.font = font; + string.font = getFont(target); string.setCoordinates(entry.pixel[0] + offsetX, entry.pixel[1] + offsetY, 0.0); string.horizontalAlignment = align; @@ -219,30 +209,4 @@ public class SPIResource extends } } - @Override - protected void disposeInternal() { - resourceData.removeChangeListener(this); - font.dispose(); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.core.rsc.IResourceDataChanged#resourceChanged(com - * .raytheon.uf.viz.core.rsc.IResourceDataChanged.ChangeType, - * java.lang.Object) - */ - @Override - public void resourceChanged(ChangeType type, Object object) { - if (type == ChangeType.CAPABILITY) { - if (object instanceof MagnificationCapability) { - if (font != null) { - font.setMagnification(((MagnificationCapability) object) - .getMagnification().floatValue()); - } - } - } - this.issueRefresh(); - } } diff --git a/cave/com.raytheon.viz.texteditor/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.texteditor/META-INF/MANIFEST.MF index 876d18affd..6bfe5709d5 100644 --- a/cave/com.raytheon.viz.texteditor/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.texteditor/META-INF/MANIFEST.MF @@ -2,13 +2,14 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Texteditor Plug-in Bundle-SymbolicName: com.raytheon.viz.texteditor;singleton:=true -Bundle-Version: 1.14.0.qualifier +Bundle-Version: 1.16.0.qualifier Bundle-Activator: com.raytheon.viz.texteditor.Activator Bundle-Vendor: Raytheon Require-Bundle: com.raytheon.uf.common.activetable, com.raytheon.uf.common.auth;bundle-version="1.12.1174", com.raytheon.uf.common.dataplugin.radar;bundle-version="1.0.0", com.raytheon.uf.common.dataplugin.text;bundle-version="1.11.30", + com.raytheon.uf.common.dataplugin.text.subscription, com.raytheon.uf.common.dataplugin.warning;bundle-version="1.12.1174", com.raytheon.uf.common.python, com.raytheon.uf.common.serialization.comm, diff --git a/cave/com.raytheon.viz.texteditor/localization/menus/textws/baseToolsMenus.xml b/cave/com.raytheon.viz.texteditor/localization/menus/textws/baseToolsMenus.xml index bfaa9313aa..c82c2de71b 100644 --- a/cave/com.raytheon.viz.texteditor/localization/menus/textws/baseToolsMenus.xml +++ b/cave/com.raytheon.viz.texteditor/localization/menus/textws/baseToolsMenus.xml @@ -19,12 +19,6 @@ further_licensing_information. --> - - - - - - \ No newline at end of file diff --git a/cave/com.raytheon.viz.texteditor/localization/menus/tools/texteditor-index.xml b/cave/com.raytheon.viz.texteditor/localization/menus/tools/texteditor-index.xml new file mode 100644 index 0000000000..6aea541ae8 --- /dev/null +++ b/cave/com.raytheon.viz.texteditor/localization/menus/tools/texteditor-index.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/cave/com.raytheon.viz.texteditor/localization/menus/tools/texteditor-menu.xml b/cave/com.raytheon.viz.texteditor/localization/menus/tools/texteditor-menu.xml new file mode 100644 index 0000000000..33ea9faa9b --- /dev/null +++ b/cave/com.raytheon.viz.texteditor/localization/menus/tools/texteditor-menu.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextEditorAction.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextEditorAction.java index 50608f3539..4ef1e0c16c 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextEditorAction.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextEditorAction.java @@ -27,20 +27,20 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; import com.raytheon.viz.texteditor.dialogs.TextEditorDialog; -import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase.CAVE; +import com.raytheon.viz.ui.dialogs.CaveSWTDialog.CAVE; /** - * Action for unimplemented features. To be used temporarily until final - * behavior is implemented. + * Text Editor Action: opens a new Text Editor Dialog * *
        * 
        * SOFTWARE HISTORY
        * 
      - * Date       	Ticket#		Engineer	Description
      - * ------------	----------	-----------	--------------------------
      - * 6/27/06                  randerso    Initial creation.
      - * 10/11/2007   482         grichard    Reformatted file.
      + * Date         Ticket#    Engineer    Description
      + * ------------ ---------- ----------- --------------------------
      + * 6/27/06                  randerso   Initial creation.
      + * 10/11/2007   482         grichard   Reformatted file.
      + * 01/18/2016   5045        randerso   Merged CaveSWTDialog and CaveSWTDialogBase
        * 
        * 
      * diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWorkstationConstants.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWorkstationConstants.java index 27afb4c536..d7670b5a4b 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWorkstationConstants.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWorkstationConstants.java @@ -35,21 +35,22 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; +import com.raytheon.uf.common.localization.exception.LocalizationException; 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.viz.core.mode.CAVEMode; /** - * TODO Add Description + * Constants for the text workstation * *
        * 
        * SOFTWARE HISTORY
        * Date         Ticket#    Engineer    Description
        * ------------ ---------- ----------- --------------------------
      - * Nov 11, 2009            mschenke     Initial creation
      + * Nov 11, 2009            mschenke    Initial creation
      + * Nov 12, 2015 4834       njensen     Changed LocalizationOpFailedException to LocalizationException
        * 
        * 
      * @@ -158,7 +159,7 @@ public class TextWorkstationConstants { super.save(); try { file.save(); - } catch (LocalizationOpFailedException e) { + } catch (LocalizationException e) { statusHandler.handle(Priority.PROBLEM, "Error saving text workstation preferences", e); } diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertSaveLoadDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertSaveLoadDlg.java index 88c84712f2..718c390686 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertSaveLoadDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertSaveLoadDlg.java @@ -38,7 +38,7 @@ import org.eclipse.swt.widgets.Text; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; +import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -53,13 +53,13 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 17, 2009 mnash Initial creation - * ====================================== - * AWIPS2 DR Work - * 07/25/2012 953 jkorman Modified file "search" to return LocalizationFile - * instead of File so references are deleted in all locations. - * 09/20/2012 1196 rferrel Setup fileName now in return value for - * use with close callback. + * Sep 17, 2009 mnash Initial creation + * 07/25/2012 953 jkorman Modified file "search" to return LocalizationFile + * instead of File so references are deleted in all locations. + * 09/20/2012 1196 rferrel Setup fileName now in return value for + * use with close callback. + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * Dec 09, 2015 4834 njensen updates for API changes to LocalizationFile * * * @@ -189,6 +189,7 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog { // loads the loadButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { // Set the filename to be returned through getFileName() if (lists.getSelectionCount() > 0) { @@ -203,20 +204,15 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog { // delete the file from the display list and from the file system deleteButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { int num = lists.getSelectionIndex(); LocalizationFile f = fileList.get(num); try { - if (!f.delete()) { - String msg = String.format( - "ALARM/ALERT:Failed deleting file %s", f - .getFile().getPath()); - statusHandler.handle(Priority.PROBLEM, msg); - } - } catch (LocalizationOpFailedException e) { + f.delete(); + } catch (LocalizationException e) { String msg = String.format( - "ALARM/ALERT:Failed deleting file %s", f.getFile() - .getPath()); + "ALARM/ALERT: Failed deleting file %s", f.getPath()); statusHandler.handle(Priority.PROBLEM, msg, e); } lists.remove(num); @@ -225,6 +221,7 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog { // close the display without doing anything else cancelButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { shell.close(); } @@ -287,6 +284,7 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog { // get the file name saveButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { // Set the filename to be returned through getFileName() fileName = textBox.getText(); @@ -297,12 +295,14 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog { // close the display without doing anything else cancelButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { shell.close(); } }); lists.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { textBox.setText(lists.getSelection()[0]); } diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/util/AlarmAlertFunctions.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/util/AlarmAlertFunctions.java index d40803126e..54a96959a5 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/util/AlarmAlertFunctions.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/util/AlarmAlertFunctions.java @@ -37,6 +37,7 @@ import java.util.regex.Pattern; import javax.xml.bind.JAXB; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; import com.raytheon.uf.common.dataplugin.text.alarms.AlarmAlertProduct; import com.raytheon.uf.common.dataplugin.text.alarms.AlarmAlertProduct.ProductType; @@ -52,7 +53,7 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; +import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -77,28 +78,22 @@ import com.vividsolutions.jts.geom.GeometryFactory; * ------------ ---------- ----------- -------------------------- * Sep 18, 2009 mnash Initial creation * 03/19/2012 D. Friedman Fix determination of "Alarm" entries. - * 12/07/2012 15555 m.gamazaychikov Added methods and constants for - * the implementation of proximity alarm - * 07/24/2014 3423 randerso Ensure ringBell is called on UI thread - * 09/09/2014 3580 mapeters Removed IQueryTransport usage (no longer exists). - * 12/03/2014 ASM #16829 D. Friedman Lazy initialization of alarmAlertBell - * 11/29/2015 ASM #14995 m.gamazaychikov Made sure that non-standard latlons in - * LAT...LON string did not result in error. + * 12/07/2012 15555 m.gamazaychikov Added methods and constants for + * the implementation of proximity alarm + * 07/24/2014 3423 randerso Ensure ringBell is called on UI thread + * 09/09/2014 3580 mapeters Removed IQueryTransport usage (no longer exists). + * 12/03/2014 16829 D. Friedman Lazy initialization of alarmAlertBell + * Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException + * 11/29/2015 14995 m.gamazaychikov Made sure that non-standard latlons in + * LAT...LON string did not result in error. + * 15/01/2016 5054 randerso Use proper parent shell + * * * * * @author mnash * @version 1.0 */ - -/** - * @author michaelg - * - */ -/** - * @author michaelg - * - */ public class AlarmAlertFunctions { private static final AlarmAlertProduct.ProductType AA = AlarmAlertProduct.ProductType.Alarm_Alert; @@ -135,10 +130,6 @@ public class AlarmAlertFunctions { private static final double ONE_DEGREE_KM = 111.20; - protected void getGIS() { - - } - /** * Create the string for distance in the dialog * @@ -155,13 +146,14 @@ public class AlarmAlertFunctions { * DR15555 - check the text content, if it is not a valid number set * the text to default 3000 mi */ - Scanner scn = new Scanner(prod.getAorDistance()); - while (scn.hasNext()) { - if (!scn.hasNextInt()) { - prod.setAorDistance(DEFAULT_DISTANCE); - break; - } else { - scn.next(); + try (Scanner scn = new Scanner(prod.getAorDistance())) { + while (scn.hasNext()) { + if (!scn.hasNextInt()) { + prod.setAorDistance(DEFAULT_DISTANCE); + break; + } else { + scn.next(); + } } } string.append("AOR+" + prod.getAorDistance() + prod.getAorLabel()); @@ -171,10 +163,6 @@ public class AlarmAlertFunctions { return string.toString(); } - protected void print(String textToPrint) { - - } - protected static void ringBell(boolean sound) { getAlarmalertbell().open(sound); } @@ -524,7 +512,6 @@ public class AlarmAlertFunctions { double lonE = coords[i].x; if (coords[i].x < centerLon) { lonE = coords[i].x - deltaX; - ; } else if (coords[i].x > centerLon) { lonE = coords[i].x + deltaX; } else if (coords[i].x == centerLon) { @@ -762,7 +749,7 @@ public class AlarmAlertFunctions { JAXB.marshal(alarms, file.getFile()); try { file.save(); - } catch (LocalizationOpFailedException e) { + } catch (LocalizationException e) { statusHandler.handle(Priority.SIGNIFICANT, e.getLocalizedMessage(), e); } @@ -812,7 +799,7 @@ public class AlarmAlertFunctions { lFile.getFile().createNewFile(); try { lFile.save(); - } catch (LocalizationOpFailedException e) { + } catch (LocalizationException e) { statusHandler.handle(Priority.SIGNIFICANT, e.getLocalizedMessage(), e); } @@ -852,7 +839,7 @@ public class AlarmAlertFunctions { w.close(); try { lFile.save(); - } catch (LocalizationOpFailedException e) { + } catch (LocalizationException e) { statusHandler.handle(Priority.SIGNIFICANT, e.getLocalizedMessage(), e); } @@ -876,8 +863,11 @@ public class AlarmAlertFunctions { */ public static AlarmAlertBell getAlarmalertbell() { if (alarmAlertBell == null) { - // No synchronize because this must be called on the UI thread anyway. - alarmAlertBell = new AlarmAlertBell(new Shell()); + // No synchronize because this must be called on the UI thread + // anyway. + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(); + alarmAlertBell = new AlarmAlertBell(shell); } return alarmAlertBell; } diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java index d22b3052d8..b24504d1a3 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java @@ -49,6 +49,7 @@ import java.util.regex.Pattern; import javax.xml.bind.JAXB; import javax.xml.bind.JAXBException; +import org.apache.commons.lang.StringUtils; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -106,6 +107,7 @@ import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; +import org.eclipse.swt.widgets.Monitor; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; @@ -356,14 +358,20 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeOperations; * simulated time. * Sep 30, 2015 4860 skorolev Corrected misspelling. * 07Oct2015 RM 18132 D. Friedman Exclude certain phensigs from automatic ETN incrementing. + * Oct 28, 2015 5054 randerso Make Text Editor windows appear on same monitor as the parent. + * Removed hard coded offset for window placement. * Nov 05, 2015 5039 rferrel Prevent wrapping text to a component name line and clean up of streams. * 19Nov2015 5141 randerso Replace commas with ellipses if product not enabled for * mixed case transmission * 10Dec2015 5206 randerso Replace commas with ellipses only in WarnGen products * 11Dec2015 RM14752 mgamazaychikov Fix problems with wrapping in the impact section. - * 6Jan2016    RM18452   mgamazaychikov Fix NPE for null product in enterEditor + * 06Jan2016    RM18452  mgamazaychikov Fix NPE for null product in enterEditor * 06Jan2016 5225 randerso Fix problem with mixed case not getting converted to upper case * when multiple text editors are open on the same product. + * 27Jan2016 5054 randerso Removed ignored second ICON from Cancel confirmation + * 04Feb2016 5076 dgilling Prevent text editor from adding multiple + * copies of header to edited product after + * save/cancel cycling. * * * @@ -894,16 +902,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, */ private MenuItem productsMenuItem; - /** - * Help on a window item menu item. - */ - private MenuItem onTextWindowItem; - - /** - * About menu item. - */ - private MenuItem aboutItem; - /** * Composite for the script runner controls */ @@ -1600,7 +1598,17 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, createMenus(); // Initialize all of the controls and layouts - initializeComponents(); + createTopButtonRow(); + + Label sepLbl = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); + sepLbl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + createTextRow(); + createHeaderTextField(); + createEditorControlButtons(); + createTextAreaEditor(); + createScriptRunnerControlBar(); + createStatusBar(); // initialize scripting controls setScriptControls(false); @@ -1627,7 +1635,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, createToolsMenus(menuBar); createScriptsMenus(menuBar); createProductsMenus(menuBar); - createHelpMenus(menuBar); shell.setMenuBar(menuBar); } @@ -2356,47 +2363,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, productsMenuItem = productsMenu.getParentItem(); } - /** - * Create the Help menu (top menu bar) and all of the menu items under the - * Help menu. - * - * @param menuBar - * The main menu bar. - */ - private void createHelpMenus(Menu menuBar) { - // ----------------------------------------- - // Create all the items in the Help menu - // ----------------------------------------- - MenuItem helpMenuItem = new MenuItem(menuBar, SWT.CASCADE); - helpMenuItem.setText("Help"); - - // Create the Products menu item with a Products "dropdown" menu - Menu helpMenu = new Menu(menuBar); - helpMenuItem.setMenu(helpMenu); - - onTextWindowItem = new MenuItem(helpMenu, SWT.NONE); - onTextWindowItem.setText("On Text Window...\tF1"); - onTextWindowItem.setAccelerator(SWT.F1); - onTextWindowItem.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - notImplementedYet("On text window"); - } - }); - - // Add a menu separator. - new MenuItem(helpMenu, SWT.SEPARATOR); - - aboutItem = new MenuItem(helpMenu, SWT.NONE); - aboutItem.setText("About..."); - aboutItem.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - notImplementedYet("About"); - } - }); - } - /** * Method to determine the target position for page up or page down. * @@ -3053,23 +3019,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, dftFont = new Font(getDisplay(), fontName, fontSize, SWT.NORMAL); } - /** - * Initialize the components and put them on the display. - */ - private void initializeComponents() { - createTopButtonRow(); - - Label sepLbl = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - createTextRow(); - createHeaderTextField(); - createEditorControlButtons(); - createTextAreaEditor(); - createScriptRunnerControlBar(); - createStatusBar(); - } - /** * Create the top row of buttons on the display. */ @@ -4310,7 +4259,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, // Notify the user that any unsaved changes will be lost. SWTMessageBox mb = new SWTMessageBox(shell, "Cancel Editor", "Any unsaved changes will be lost. Cancel anyway?", - SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.ICON_WARNING); + SWT.ICON_QUESTION | SWT.YES | SWT.NO); mb.setCloseCallback(new ICloseCallback() { @Override @@ -4388,15 +4337,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, searchReplaceDlg.setEditMode(inEditMode); } - // Restore the contents of the text editor if needed - // Note: this block conpensates for the unusual behavior of the AWIPS-I - // cancel editor functionality. Basically, once a product has been saved - // cancelling DOES NOT roll back changes in AWIPS-I! - if (saved) { - replaceWorkProductId(); - originalText = combineOriginalMessage(); - } - if (originalText != null) { textEditor.setText(originalText); } @@ -5107,7 +5047,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, try { updateTextEditor(body); if ((inEditMode || resend) - && saveEditedProduct(prod, false, resend, true)) { + && !saveEditedProduct(prod, false, resend, true) + .isEmpty()) { inEditMode = false; } if (!resend) { @@ -5189,7 +5130,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, } updateTextEditor(body); if ((inEditMode || resend) - && saveEditedProduct(prod, false, resend, false)) { + && !saveEditedProduct(prod, false, resend, false) + .isEmpty()) { inEditMode = false; } SendPracticeProductRequest req = new SendPracticeProductRequest(); @@ -5353,12 +5295,12 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, userInformation("This product MUST be edited in GFE! \n Please exit and return to GFE. \n Action Aborted!"); return; } - boolean successful = saveEditedProduct(product, false, false, false); - if (successful) { + String savedProduct = saveEditedProduct(product, false, false, false); + if (!savedProduct.isEmpty()) { // reset the editor status flags saved = true; replaceWorkProductId(); - originalText = combineOriginalMessage(); + originalText = savedProduct; if (warnGenFlag == true) { originalText = removeSoftReturns(originalText); } @@ -5377,16 +5319,16 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, * @param isOperationalSend * true if operational send * - * @return true is the save was successful + * @return The text of the saved product if successful. Empty string if not. */ - synchronized private boolean saveEditedProduct(StdTextProduct product, + synchronized private String saveEditedProduct(StdTextProduct product, boolean isAutoSave, boolean resend, boolean isOperationalSend) { if ((product != null) && gfeForbidden(product.getCccid(), product.getNnnid())) { // Pop up forbidden window. inEditMode = false; userInformation("This product MUST be edited in GFE! \n Please exit and return to GFE. \n Action Aborted!"); - return false; + return StringUtils.EMPTY; } boolean successful = false; @@ -5401,7 +5343,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, // Convert the text in the text editor to uppercase if (!isAutoSave) { if (!verifyRequiredFields()) { - return false; + return StringUtils.EMPTY; } replaceWorkProductId(); @@ -5486,7 +5428,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, successful = true; } else { if (!saveStoredTextProduct(storedProduct)) { - return false; + return StringUtils.EMPTY; } // Update the TextProductInfo table within the Text Database when a @@ -5498,7 +5440,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, successful = saveTextProductInfo(); } - return successful; + return (successful) ? productText.trim() : StringUtils.EMPTY; } /** @@ -7752,20 +7694,35 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, protected void preOpened() { // Shell shell = ted.getShell(); if (textWorkstationFlag) { - Rectangle rect = getShell().getDisplay().getClientArea(); - int x = rect.width / 4; - // account for dual monitor - if (rect.width > (rect.height * 2)) { - x /= 2; + // get bounds of monitor containing parent shell + Point parentLoc = getParent().getShell().getLocation(); + Rectangle rect = null; + for (Monitor monitor : getShell().getDisplay().getMonitors()) { + rect = monitor.getBounds(); + if (rect.contains(parentLoc)) { + break; + } } + int x = rect.x + (rect.width / 4); + int y = rect.y; int index = getText().indexOf(" "); int editorIndex = new Integer(getText().substring(index + 1)) .intValue(); - int offset = (editorIndex - 1) * 25; - getShell().setLocation(x + offset, (rect.height / 4) + offset); + Rectangle bounds = getShell().getBounds(); + Rectangle clientArea = getShell().getClientArea(); + + /* + * NOTE: this offset includes the height of the title bar and the + * menu. There appears to be no way to get just the title bar in + * Eclipse 3.8 We may be able to do this in Eclipse 4 + */ + int xOffset = (editorIndex - 1) * (bounds.width - clientArea.width); + int yOffset = (editorIndex - 1) + * (bounds.height - clientArea.height); + getShell().setLocation(x + xOffset, y + yOffset); } inEditMode = false; @@ -8048,9 +8005,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, } // is this the impact paragraph? - if (paragraphStart.startsWith(" IMPACT...") || - paragraphStart.startsWith(" HAZARD...") || - paragraphStart.startsWith(" SOURCE...") ) { + if (paragraphStart.startsWith(" IMPACT...") + || paragraphStart.startsWith(" HAZARD...") + || paragraphStart.startsWith(" SOURCE...")) { padding = " "; } @@ -8134,8 +8091,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, // if the next line does not start a new paragraph if (!isParagraphStart(lineNumber + 1)) { // if the next line is not empty - if (!textEditor.getLine(lineNumber + 1).trim().isEmpty() || - (textEditor.getLine(lineNumber + 1).length() == padding.length()+1) ) { + if (!textEditor.getLine(lineNumber + 1).trim().isEmpty() + || (textEditor.getLine(lineNumber + 1).length() == (padding + .length() + 1))) { // Determine what kind of end of line marker line has. int deleteLen = 0; diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxMessageDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxMessageDlg.java index d6429bdb0d..93b274ba95 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxMessageDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxMessageDlg.java @@ -34,7 +34,7 @@ import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import com.raytheon.uf.common.dataplugin.text.request.SendFaxRequest; +import com.raytheon.uf.common.dataplugin.text.subscription.request.SendFaxRequest; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxSiteEditorDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxSiteEditorDlg.java index c9abef0a84..3489fb8b6b 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxSiteEditorDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxSiteEditorDlg.java @@ -34,7 +34,7 @@ import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import com.raytheon.uf.common.dataplugin.text.db.AutoFaxRecord; +import com.raytheon.uf.common.dataplugin.text.subscription.db.AutoFaxRecord; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; /** diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/LdadFaxSitesDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/LdadFaxSitesDlg.java index 73df1595d8..05ff5b0266 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/LdadFaxSitesDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/LdadFaxSitesDlg.java @@ -38,10 +38,10 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; -import com.raytheon.uf.common.dataplugin.text.AutoFaxContainer; -import com.raytheon.uf.common.dataplugin.text.db.AutoFaxRecord; -import com.raytheon.uf.common.dataplugin.text.request.AutoFaxRequest; -import com.raytheon.uf.common.dataplugin.text.request.GetAutoFaxRecordsRequest; +import com.raytheon.uf.common.dataplugin.text.subscription.AutoFaxContainer; +import com.raytheon.uf.common.dataplugin.text.subscription.db.AutoFaxRecord; +import com.raytheon.uf.common.dataplugin.text.subscription.request.AutoFaxRequest; +import com.raytheon.uf.common.dataplugin.text.subscription.request.GetAutoFaxRecordsRequest; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/notify/NotifyExpiration.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/notify/NotifyExpiration.java index 6e4f9055ea..10e1f2133b 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/notify/NotifyExpiration.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/notify/NotifyExpiration.java @@ -25,6 +25,7 @@ import java.util.Timer; import java.util.TimerTask; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import com.raytheon.viz.texteditor.TextDisplayModel; @@ -41,8 +42,9 @@ import com.raytheon.viz.texteditor.util.VtecUtil; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * May 24, 2010 jsanchez Initial creation + * May 24, 2010 jsanchez Initial creation * Apr 25, 2014 DR 16668 D. Friedman Only notify on NEW products. + * Jan 26, 2016 5054 randerso Changed to use display as parent * * * @@ -60,7 +62,7 @@ public class NotifyExpiration { private static ArrayList ALLOWED_TYPES = new ArrayList(5); - private Shell parent; + private Display display; static { ALLOWED_TYPES.add("SMW"); @@ -70,8 +72,8 @@ public class NotifyExpiration { ALLOWED_TYPES.add("FLW"); } - public NotifyExpiration(Shell parent) { - this.parent = parent; + public NotifyExpiration(Display display) { + this.display = display; } public void add(String warning) { @@ -84,11 +86,11 @@ public class NotifyExpiration { } VtecObject vtecObject = VtecUtil.parseMessage(warning); - if (vtecObject == null || !"NEW".equals(vtecObject.getAction())) { + if ((vtecObject == null) || !"NEW".equals(vtecObject.getAction())) { return; } Calendar expire = vtecObject.getEndTime(); - TimerTask notify = new NotifyExpirationTask(parent, productId, + TimerTask notify = new NotifyExpirationTask(display, productId, vtecObject); Timer timer = new Timer(); expire.add(Calendar.MINUTE, -10); @@ -97,7 +99,7 @@ public class NotifyExpiration { } public void checkExpirationNotices(Shell shell) { - if (shell != null && !tasks.isEmpty()) { + if ((shell != null) && !tasks.isEmpty()) { if (MessageDialog.openQuestion(shell, EXIT_TITLE, EXIT_MSG)) { for (TimerTask t : tasks) { t.cancel(); diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/notify/NotifyExpirationTask.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/notify/NotifyExpirationTask.java index 0164ef57f0..5003c86a36 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/notify/NotifyExpirationTask.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/notify/NotifyExpirationTask.java @@ -24,7 +24,7 @@ import java.text.SimpleDateFormat; import java.util.TimerTask; import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Display; import com.raytheon.uf.common.activetable.ActiveTableMode; import com.raytheon.uf.common.activetable.ActiveTableRecord; @@ -57,6 +57,9 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox; * Apr 25, 2014 DR 16668 D. Friedman Handle partial cancellations * Apr 28, 2015 4027 randerso Expunged Calendar from ActiveTableRecord * Nov 03, 2015 5086 rferrel Generate sound while displaying warning expire message. + * Jan 26, 2016 5054 randerso Changed to use display as parent, + * code cleanup + * * * * @author jsanchez @@ -80,11 +83,16 @@ public class NotifyExpirationTask extends TimerTask { private String message; - private Shell parentShell; + private Display display; - public NotifyExpirationTask(Shell parent, String productId, + /** + * @param display + * @param productId + * @param vtecObject + */ + public NotifyExpirationTask(Display display, String productId, VtecObject vtecObject) { - this.parentShell = parent; + this.display = display; office = vtecObject.getOffice(); phenSig = vtecObject.getPhenomena() + "." + vtecObject.getSignificance(); @@ -100,13 +108,13 @@ public class NotifyExpirationTask extends TimerTask { if (!isCanceled()) { final AlarmBeepJob abj = new AlarmBeepJob("expire", 0); abj.schedule(); - parentShell.getDisplay().asyncExec(new Runnable() { + display.asyncExec(new Runnable() { @Override public void run() { SWTMessageBox mb = new SWTMessageBox( - NotifyExpirationTask.this.parentShell, - "Watch/Warning Expires Soon", message, SWT.OK, - SWT.MODELESS, true); + NotifyExpirationTask.this.display, + "Watch/Warning Expires Soon", message, + SWT.ICON_WARNING | SWT.OK); mb.setCloseCallback(new ICloseCallback() { @Override diff --git a/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/SelectUserIdDlg.java b/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/SelectUserIdDlg.java deleted file mode 100644 index 692bb927b7..0000000000 --- a/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/SelectUserIdDlg.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ - -package com.raytheon.viz.textworkstation; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Font; -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.List; -import org.eclipse.swt.widgets.Shell; - -import com.raytheon.viz.ui.dialogs.CaveSWTDialog; - -/** - * SelectUserIdDlg class. - * - *
      - * 
      - * SOFTWARE HISTORY
      - * 
      - * Date       	Ticket#		Engineer	Description
      - * ------------	----------	-----------	--------------------------
      - * 9/27/2007    368         lvenable    Initial creation.
      - * 10/11/2007   482         grichard    Reformatted file.
      - * 26Sep2012    1196        lvenable    Dialog refactor to not block.
      - * 
      - * 
      - * - * @author lvenable - */ -public class SelectUserIdDlg extends CaveSWTDialog { - - private Font font; - - private List userIdList; - - public SelectUserIdDlg(Shell parent) { - super(parent, SWT.DIALOG_TRIM, CAVE.PERSPECTIVE_INDEPENDENT - | CAVE.DO_NOT_BLOCK); - setText("Select User ID"); - } - - @Override - protected void disposed() { - font.dispose(); - } - - @Override - protected void initializeComponents(Shell shell) { - setReturnValue(false); - - font = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); - - // Initialize all of the controls and layouts - createUserIdList(); - createBottomButtons(); - - // TODO : remove this method call... - createDummyData(); - } - - private void createUserIdList() { - GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false); - gd.widthHint = 200; - gd.heightHint = 350; - userIdList = new List(shell, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL); - userIdList.setLayoutData(gd); - - userIdList.setFont(font); - } - - private void createBottomButtons() { - Composite centeredComp = new Composite(shell, SWT.NONE); - GridLayout gl = new GridLayout(2, false); - centeredComp.setLayout(gl); - GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); - centeredComp.setLayoutData(gd); - - gd = new GridData(70, SWT.DEFAULT); - Button okBtn = new Button(centeredComp, SWT.NONE); - okBtn.setText("OK"); - okBtn.setLayoutData(gd); - okBtn.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - } - }); - - gd = new GridData(70, SWT.DEFAULT); - Button cancelBtn = new Button(centeredComp, SWT.NONE); - cancelBtn.setText("Cancel"); - cancelBtn.setLayoutData(gd); - cancelBtn.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - shell.dispose(); - } - }); - } - - // TODO : remove this method... - private void createDummyData() { - String tmp; - - for (int i = 0; i < 30; i++) { - tmp = "User ID " + i; - userIdList.add(tmp); - } - } -} diff --git a/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationAction.java b/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationAction.java index 93b9160bc9..70705df833 100644 --- a/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationAction.java +++ b/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationAction.java @@ -23,8 +23,7 @@ package com.raytheon.viz.textworkstation; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; +import org.eclipse.swt.widgets.Display; import com.raytheon.viz.ui.dialogs.ICloseCallback; @@ -42,6 +41,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * 10/11/2007 482 grichard Reformatted file. * 08/03/2011 9572 rferrel Allow single instance of the dialog. * 26Sep2012 1196 lvenable Update for the dialog refactor. + * Jan 26, 2016 5054 randerso Changed to use display as parent * * * @@ -54,10 +54,8 @@ public class TextWorkstationAction extends AbstractHandler { @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(); - if (textWorkstationDlg == null || textWorkstationDlg.isDisposed()) { - textWorkstationDlg = new TextWorkstationDlg(shell); + if ((textWorkstationDlg == null) || textWorkstationDlg.isDisposed()) { + textWorkstationDlg = new TextWorkstationDlg(Display.getCurrent()); textWorkstationDlg.setCloseCallback(new ICloseCallback() { @Override diff --git a/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationComponent.java b/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationComponent.java index a7f9c380bf..56444f18b6 100644 --- a/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationComponent.java +++ b/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationComponent.java @@ -1,7 +1,6 @@ package com.raytheon.viz.textworkstation; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.viz.ui.personalities.awips.AbstractCAVEDialogComponent; @@ -36,11 +35,12 @@ import com.raytheon.viz.ui.personalities.awips.AbstractCAVEDialogComponent; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Apr 28, 2011 mschenke Initial creation + * Apr 28, 2011 mschenke Initial creation * Oct 02, 2012 1229 rferrel Make a blocking dialog. - * Oct 17, 2012 1229 rferrel Changes for non-blocking - * TextWorkstationDlg. + * Oct 17, 2012 1229 rferrel Changes for non-blocking TextWorkstationDlg. * Sep 09, 2014 3580 mapeters Removed {@link SerializationUtil} usage. + * Oct 28, 2015 5054 randerso Make TextWorkstationDlg appear on current monitor. + * Jan 26, 2016 5054 randerso Changed to use display as parent * * * @@ -60,7 +60,7 @@ public class TextWorkstationComponent extends AbstractCAVEDialogComponent { @Override protected void startInternal(String componentName) throws Exception { TextWorkstationDlg textWorkstationDlg = new TextWorkstationDlg( - new Shell(Display.getCurrent())); + Display.getCurrent()); textWorkstationDlg.open(); blockUntilClosed(textWorkstationDlg); } diff --git a/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java b/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java index 48eeadb361..f6fb4d794c 100644 --- a/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java +++ b/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java @@ -32,12 +32,15 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.swt.widgets.Monitor; import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.jms.notification.INotificationObserver; @@ -90,8 +93,12 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * 02Oct2012 1229 rferrel Option to allow blocking when top dialog. * 13Dec2012 1353 rferrel Fix bug introduced in the Show all dialogs. * 30Jan2013 DR 14736 D. Friedman Display local time. - * 24Jun2013 DR 15733 XHuang Display MAX_BUTTON_CNT (8 button). + * 24Jun2013 DR 15733 XHuang Display MAX_BUTTON_CNT (8 button). * 25July2013 DR 15733 Greg Hull Make dflt and max number of Text Buttons configurable. + * 28Oct2015 5054 randerso Make TextWorkstationDlg appear in upper left corner of + * monitor where parent shell is located + * Dec 14, 2015 4834 njensen Remove dead menu items + * Jan 26, 2016 5054 randerso Changed to use display as parent * Feb 15, 2016 4860 njensen Removed references to IAviationObserver * * @@ -146,20 +153,15 @@ public class TextWorkstationDlg extends CaveSWTDialog implements private long initStartTime; - /** Select user ID dialog */ - private SelectUserIdDlg userIdDlg; - /** - * Create dialog specifying NONE for blocking and DO_NOT_BLOCK for - * non-blocking dialog. + * Create top level Text Workstation Dialog + * + * @param display * - * @param parent - * - CAVE.DO_NOT_BLOCK or CAVE.NONE */ - public TextWorkstationDlg(Shell parent) { - super(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.RESIZE, - CAVE.PERSPECTIVE_INDEPENDENT | CAVE.INDEPENDENT_SHELL - | CAVE.DO_NOT_BLOCK); + public TextWorkstationDlg(Display display) { + super(display, SWT.DIALOG_TRIM | SWT.MIN, CAVE.PERSPECTIVE_INDEPENDENT + | CAVE.INDEPENDENT_SHELL | CAVE.DO_NOT_BLOCK); setText("Text Workstation"); TextDisplayModel.getInstance().setTextRadar(new RadarTextUtility()); @@ -193,34 +195,21 @@ public class TextWorkstationDlg extends CaveSWTDialog implements protected void initializeComponents(final Shell shell) { setReturnValue(false); - notify = new NotifyExpiration(getParent()); + notify = new NotifyExpiration(getDisplay()); font = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); fontAwipsLabel = new Font(shell.getDisplay(), "Helvetica", 24, SWT.ITALIC); - INIT_BUTTON_CNT = TextEditorCfg.getTextEditorCfg().getDefaultNumEditors(); + INIT_BUTTON_CNT = TextEditorCfg.getTextEditorCfg() + .getDefaultNumEditors(); MAX_BUTTON_CNT = TextEditorCfg.getTextEditorCfg().getMaxNumEditors(); - + // Initialize all of the controls and layouts - initializeComponents(); - } - - @Override - protected void opened() { - if (productToDisplay != null) { - wgDlg.showWarngenProduct(productToDisplay, notify); - } - - // Display the first Text Editor - showTextEditor(0); - } - - private void initializeComponents() { sdfUTC.setTimeZone(TimeZone.getTimeZone("UTC")); String localTZName = System.getenv("FXA_LOCAL_TZ"); - sdfLocal.setTimeZone(localTZName != null ? - TimeZone.getTimeZone(localTZName) : TimeZone.getDefault()); + sdfLocal.setTimeZone(localTZName != null ? TimeZone + .getTimeZone(localTZName) : TimeZone.getDefault()); createMenus(); new Label(shell, SWT.NONE).setText("host: " @@ -237,6 +226,49 @@ public class TextWorkstationDlg extends CaveSWTDialog implements alarmDlg.openInvisible(); } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened() + */ + @Override + protected void preOpened() { + super.preOpened(); + + Monitor monitor = null; + if (getParent() != null) { + monitor = getParent().getShell().getMonitor(); + + } else { + Point cursor = getDisplay().getCursorLocation(); + for (Monitor m : getDisplay().getMonitors()) { + Rectangle bounds = m.getBounds(); + if (bounds.contains(cursor)) { + monitor = m; + break; + } + } + } + + Point loc = new Point(0, 0); + if (monitor != null) { + Rectangle bounds = monitor.getBounds(); + loc.x = bounds.x; + loc.y = bounds.y; + } + shell.setLocation(loc); + } + + @Override + protected void opened() { + if (productToDisplay != null) { + wgDlg.showWarngenProduct(productToDisplay, notify); + } + + // Display the first Text Editor + showTextEditor(0); + } + private void createMenus() { Menu menuBar = new Menu(shell, SWT.BAR); @@ -258,43 +290,12 @@ public class TextWorkstationDlg extends CaveSWTDialog implements fileMenuItem.setMenu(fileMenu); // -------------------------------------------------- - // Create Select User ID menu item - // -------------------------------------------------- - MenuItem selectUserIdMenuItem = new MenuItem(fileMenu, SWT.NONE); - selectUserIdMenuItem.setText("Select User ID..."); - selectUserIdMenuItem.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - if (userIdDlg == null || userIdDlg.isDisposed()) { - userIdDlg = new SelectUserIdDlg(shell); - userIdDlg.open(); - } else { - userIdDlg.bringToTop(); - } - } - }); - - // -------------------------------------------------- - // Create Evaluation sub menu item - // -------------------------------------------------- - MenuItem evaluationMenuItem = new MenuItem(fileMenu, SWT.CASCADE); - evaluationMenuItem.setText("Select"); - - Menu selectSubMenu = new Menu(shell, SWT.DROP_DOWN); - evaluationMenuItem.setMenu(selectSubMenu); - - createEvaluationSubMenu(selectSubMenu); - - // ------------------------------- - // Add a menu separator. - // ------------------------------- - new MenuItem(fileMenu, SWT.SEPARATOR); - - // -------------------------------------------------- - // Create Select User ID menu item + // Create Exit menu item // -------------------------------------------------- MenuItem exitMenuItem = new MenuItem(fileMenu, SWT.NONE); exitMenuItem.setText("Exit"); exitMenuItem.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { getShell().close(); } @@ -318,6 +319,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements MenuItem hideAllMenuItem = new MenuItem(windowsMenu, SWT.NONE); hideAllMenuItem.setText("Hide All"); hideAllMenuItem.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { hideAllTextEditors(); } @@ -329,6 +331,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements MenuItem showAllMenuItem = new MenuItem(windowsMenu, SWT.NONE); showAllMenuItem.setText("Show All"); showAllMenuItem.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { showAllTextEditors(); } @@ -345,38 +348,13 @@ public class TextWorkstationDlg extends CaveSWTDialog implements newWindowMenuItem = new MenuItem(windowsMenu, SWT.NONE); newWindowMenuItem.setText("New Window"); newWindowMenuItem.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { addNewWindowButton(); } }); } - private void createEvaluationSubMenu(Menu evalSubMenu) { - MenuItem evaluationLogItem = new MenuItem(evalSubMenu, SWT.NONE); - evaluationLogItem.setText("Evaluation Log"); - evaluationLogItem.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - notImplementedYet("Evaluation Log"); - } - }); - - MenuItem endOfShiftItem = new MenuItem(evalSubMenu, SWT.NONE); - endOfShiftItem.setText("End of Shift"); - endOfShiftItem.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - notImplementedYet("End of Shift"); - } - }); - - MenuItem questionnaireItem = new MenuItem(evalSubMenu, SWT.NONE); - questionnaireItem.setText("Questionnaire"); - questionnaireItem.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - notImplementedYet("Questionnaire"); - } - }); - } - private void createAwipsLabel() { GridData gd = new GridData(300, 20); Label awipsBlankLabel = new Label(shell, SWT.NONE); @@ -414,6 +392,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements AlarmAlertNotificationObserver.getInstance(); alertAlarmBtn.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { if (alarmDlg == null) { AlarmAlertNotificationObserver.getInstance(); @@ -436,7 +415,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements textBtnArray = new ArrayList