From 60abf0affc7d67bf2646a60bd9713d8fe04c9da5 Mon Sep 17 00:00:00 2001 From: mjames-upc Date: Mon, 12 Jan 2015 16:11:06 -0700 Subject: [PATCH] various cleanup merge remotes/origin/ncep_14.4.1 to upc dev Former-commit-id: 965f752233390e0ffe7e9ef214e0e850869b048a --- cave/build/static/linux/cave/run.sh | 63 +- .../.classpath | 2 +- .../localization/perspective/PydevSetup.java | 2 +- .../.classpath | 2 +- .../TPCSurgeProbPostProcessor.java | 8 +- .../.cproject.BACKUP.30635.cproject | 904 ------------- .../.cproject.LOCAL.30635.cproject | 894 ------------- .../.cproject.REMOTE.30635.cproject | 728 ----------- .../src/libjasper/jp2/jp2_cod.c.orig | 921 -------------- .../src/libjasper/jp2/jp2_enc.c.orig | 436 ------- .../gov.noaa.nws.ncep.edex.uengine/.classpath | 2 +- .../ui/createRbd/CreateRbdControl.java | 17 +- .../createRbd/ResourceSelectionControl.java | 14 +- .../manageResources/EditResourceTypeComp.java | 1114 ----------------- 14 files changed, 64 insertions(+), 5043 deletions(-) delete mode 100644 nativeLib/ncep_grib2module/.cproject.BACKUP.30635.cproject delete mode 100644 nativeLib/ncep_grib2module/.cproject.LOCAL.30635.cproject delete mode 100644 nativeLib/ncep_grib2module/.cproject.REMOTE.30635.cproject delete mode 100644 nativeLib/rary.cots.jasper/jasper-1.900.1/src/libjasper/jp2/jp2_cod.c.orig delete mode 100644 nativeLib/rary.cots.jasper/jasper-1.900.1/src/libjasper/jp2/jp2_enc.c.orig diff --git a/cave/build/static/linux/cave/run.sh b/cave/build/static/linux/cave/run.sh index d950bfaad6..326839a0c3 100644 --- a/cave/build/static/linux/cave/run.sh +++ b/cave/build/static/linux/cave/run.sh @@ -30,6 +30,9 @@ # around this script. # Jan 24, 2014 #2739 bsteffen Log exit status # Jan 30, 2014 #2593 bclement warns based on memory usage, fixed for INI files with spaces +# Jul 10, 2014 #3363 bclement logs command used to launch application to console logs +# Oct 10, 2014 #3675 njensen Logback now does console logging to ensure correct pid +# Oct 13, 2014 #3675 bclement startup shutdown log includes both launching pid and placeholder # # @@ -47,7 +50,7 @@ JAVA_INSTALL="/awips2/java" PYTHON_INSTALL="/awips2/python" export AWIPS_INSTALL_DIR="${CAVE_INSTALL}" -MAX_MEM_PROPORTION="0.9" +MAX_MEM_PROPORTION="0.85" source ${CAVE_INSTALL}/caveUtil.sh RC=$? @@ -88,8 +91,29 @@ if [ $? -ne 0 ]; then fi export apps_dir=${HYDRO_APPS_DIR} -MODE="OPERATIONAL (no response)" -SWITCHES="${SWITCHES} " +TESTCHECK="$TMCP_HOME/bin/getTestMode" +if [ -x ${TESTCHECK} ]; then + echo "Calling getTestMode()" + ${TESTCHECK} + status=${?} + if [ $status -eq 11 ]; then + MODE="TEST" + SWITCHES="${SWITCHES} -mode TEST " + elif [ $status -eq 12 ];then + MODE="PRACTICE" + SWITCHES="${SWITCHES} -mode PRACTICE " + elif [ $status -eq 15 ];then + MODE="OPERATIONAL" + SWITCHES="${SWITCHES} -mode OPERATIONAL" + else + MODE="OPERATIONAL (no response)" + SWITCHES="${SWITCHES} " + fi + echo "getTestMode() returned ${MODE}" +else + MODE="UNKNOWN" + echo "getTestMode() not found - going to use defaults" +fi export TEXTWS=`hostname | sed -e 's/lx/xt/g'` @@ -173,7 +197,6 @@ fi BASE_LOGDIR=$HOME/caveData/logs/consoleLogs LOGDIR=$BASE_LOGDIR/$hostName/ - # make sure directory exists if [ ! -d $LOGDIR ]; then mkdir -p $LOGDIR @@ -189,13 +212,16 @@ curTime=`date +%Y%m%d_%H%M%S` ( export pid=`/bin/bash -c 'echo $PPID'` - LOGFILE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_console.log" - export LOGFILE_CAVE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_alertviz.log" - export LOGFILE_PERFORMANCE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_perf.log" + # we include the PID of the launching process along with + # a %PID% placeholder to be replaced with the "real" PID + LOGFILE_STARTUP_SHUTDOWN="${LOGDIR}/${PROGRAM_NAME}_${pid}_${curTime}_pid_%PID%_startup-shutdown.log" + export LOGFILE_CAVE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_logs.log" + export LOGFILE_CONSOLE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_console.log" + export LOGFILE_PERFORMANCE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_perf.log" # can we write to log directory if [ -w ${LOGDIR} ]; then - touch ${LOGFILE} + touch ${LOGFILE_STARTUP_SHUTDOWN} fi # remove "-noredirect" flag from command-line if set so it doesn't confuse any @@ -213,12 +239,6 @@ curTime=`date +%Y%m%d_%H%M%S` shift done - # Special instructions for the 64-bit jvm. - ARCH_ARGS="" - if [ -f /awips2/java/jre/lib/amd64/server/libjvm.so ]; then - ARCH_ARGS="-vm /awips2/java/jre/lib/amd64/server/libjvm.so" - fi - lookupINI "${USER_ARGS[@]}" if [[ "${runMonitorThreads}" == "true" ]] ; then @@ -226,15 +246,20 @@ curTime=`date +%Y%m%d_%H%M%S` nohup ${CAVE_INSTALL}/monitorThreads.sh $pid >> /dev/null 2>&1 & fi - if [[ "${redirect}" == "true" ]] ; then - exec ${CAVE_INSTALL}/cave ${ARCH_ARGS} ${SWITCHES} "${CAVE_INI_ARG}" "${USER_ARGS[@]}" > ${LOGFILE} 2>&1 + echo "Launching cave application using the following command: " >> ${LOGFILE_STARTUP_SHUTDOWN} + echo "${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES} ${USER_ARGS[@]}" >> ${LOGFILE_STARTUP_SHUTDOWN} + + if [[ "${redirect}" == "true" ]] ; then + # send output to /dev/null because the logback CaveConsoleAppender will capture that output + exec ${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES} "${USER_ARGS[@]}" >> /dev/null 2>&1 else - exec ${CAVE_INSTALL}/cave ${ARCH_ARGS} ${SWITCHES} "${CAVE_INI_ARG}" "${USER_ARGS[@]}" 2>&1 | tee ${LOGFILE} + # allow output to print to the console/terminal that launched CAVE + exec ${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES} "${USER_ARGS[@]}" 2>&1 fi ) & pid=$! -LOGFILE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_console.log" -logExitStatus $pid $LOGFILE +LOGFILE_STARTUP_SHUTDOWN="${LOGDIR}/${PROGRAM_NAME}_${pid}_${curTime}_pid_%PID%_startup-shutdown.log" +logExitStatus $pid $LOGFILE_STARTUP_SHUTDOWN diff --git a/cave/com.raytheon.uf.viz.localization.perspective/.classpath b/cave/com.raytheon.uf.viz.localization.perspective/.classpath index ad32c83a78..1fa3e6803d 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/.classpath +++ b/cave/com.raytheon.uf.viz.localization.perspective/.classpath @@ -1,6 +1,6 @@ - + diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/PydevSetup.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/PydevSetup.java index 06240aec59..d34bb6287b 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/PydevSetup.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/PydevSetup.java @@ -245,7 +245,7 @@ public class PydevSetup { * popup. */ public static void preventPydevEclipsePopup() { - PydevRootPrefs.setCheckPreferredPydevSettings(false); + //PydevRootPrefs.setCheckPreferredPydevSettings(false); IEclipsePreferences debug = InstanceScope.INSTANCE .getNode("org.eclipse.debug.ui"); debug.put("org.eclipse.debug.ui.wait_for_build", "never"); diff --git a/cave/com.raytheon.uf.viz.ui.popupskewt/.classpath b/cave/com.raytheon.uf.viz.ui.popupskewt/.classpath index ad32c83a78..16d067f284 100644 --- a/cave/com.raytheon.uf.viz.ui.popupskewt/.classpath +++ b/cave/com.raytheon.uf.viz.ui.popupskewt/.classpath @@ -1,7 +1,7 @@ - + diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/TPCSurgeProbPostProcessor.java b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/TPCSurgeProbPostProcessor.java index 8801567bed..357546dad6 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/TPCSurgeProbPostProcessor.java +++ b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/TPCSurgeProbPostProcessor.java @@ -134,12 +134,8 @@ public class TPCSurgeProbPostProcessor implements IDecoderPostProcessor { Level level = record.getLevel(); if (level.getMasterLevel().getName().equals("FHAG")) { record.getInfo().setDatasetId("PHISH"); - try { - level = LevelFactory.getInstance().getLevel("SFC", - level.getLevelonevalue(), level.getLeveltwovalue()); - } catch (CommunicationException e) { - throw new GribException("Error retrieving level information", e); - } + level = LevelFactory.getInstance().getLevel("SFC", + level.getLevelonevalue(), level.getLeveltwovalue()); record.setLevel(level); } diff --git a/nativeLib/ncep_grib2module/.cproject.BACKUP.30635.cproject b/nativeLib/ncep_grib2module/.cproject.BACKUP.30635.cproject deleted file mode 100644 index 166168ac1a..0000000000 --- a/nativeLib/ncep_grib2module/.cproject.BACKUP.30635.cproject +++ /dev/null @@ -1,904 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<<<<<<< HEAD - - - -======= ->>>>>>> master_14.1.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<<<<<<< HEAD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -======= ->>>>>>> master_14.1.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<<<<<<< HEAD -======= - ->>>>>>> master_14.1.1 - diff --git a/nativeLib/ncep_grib2module/.cproject.LOCAL.30635.cproject b/nativeLib/ncep_grib2module/.cproject.LOCAL.30635.cproject deleted file mode 100644 index be76fd5e52..0000000000 --- a/nativeLib/ncep_grib2module/.cproject.LOCAL.30635.cproject +++ /dev/null @@ -1,894 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nativeLib/ncep_grib2module/.cproject.REMOTE.30635.cproject b/nativeLib/ncep_grib2module/.cproject.REMOTE.30635.cproject deleted file mode 100644 index 3459feebf0..0000000000 --- a/nativeLib/ncep_grib2module/.cproject.REMOTE.30635.cproject +++ /dev/null @@ -1,728 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nativeLib/rary.cots.jasper/jasper-1.900.1/src/libjasper/jp2/jp2_cod.c.orig b/nativeLib/rary.cots.jasper/jasper-1.900.1/src/libjasper/jp2/jp2_cod.c.orig deleted file mode 100644 index 83cecb1f91..0000000000 --- a/nativeLib/rary.cots.jasper/jasper-1.900.1/src/libjasper/jp2/jp2_cod.c.orig +++ /dev/null @@ -1,921 +0,0 @@ -/* - * Copyright (c) 1999-2000 Image Power, Inc. and the University of - * British Columbia. - * Copyright (c) 2001-2002 Michael David Adams. - * All rights reserved. - */ - -/* __START_OF_JASPER_LICENSE__ - * - * JasPer License Version 2.0 - * - * Copyright (c) 2001-2006 Michael David Adams - * Copyright (c) 1999-2000 Image Power, Inc. - * Copyright (c) 1999-2000 The University of British Columbia - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person (the - * "User") obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, and/or sell copies of the Software, and to permit - * persons to whom the Software is furnished to do so, subject to the - * following conditions: - * - * 1. The above copyright notices and this permission notice (which - * includes the disclaimer below) shall be included in all copies or - * substantial portions of the Software. - * - * 2. The name of a copyright holder shall not be used to endorse or - * promote products derived from the Software without specific prior - * written permission. - * - * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS - * LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER - * THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS - * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING - * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL - * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING - * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE - * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE - * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY. - * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS - * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL - * PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS - * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE - * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE - * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL - * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES, - * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL - * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH - * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH, - * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH - * RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY - * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES. - * - * __END_OF_JASPER_LICENSE__ - */ - -/* - * JP2 Library - * - * $Id$ - */ - -/******************************************************************************\ -* Includes. -\******************************************************************************/ - -#include -#include - -#include "jasper/jas_stream.h" -#include "jasper/jas_malloc.h" -#include "jasper/jas_debug.h" - -#include "jp2_cod.h" - -/******************************************************************************\ -* Function prototypes. -\******************************************************************************/ - -#define ONES(n) ((1 << (n)) - 1) - -jp2_boxinfo_t *jp2_boxinfolookup(int type); - -static int jp2_getuint8(jas_stream_t *in, uint_fast8_t *val); -static int jp2_getuint16(jas_stream_t *in, uint_fast16_t *val); -static int jp2_getuint32(jas_stream_t *in, uint_fast32_t *val); -static int jp2_getuint64(jas_stream_t *in, uint_fast64_t *val); -static int jp2_putuint8(jas_stream_t *out, uint_fast8_t val); -static int jp2_putuint16(jas_stream_t *out, uint_fast16_t val); -static int jp2_putuint32(jas_stream_t *out, uint_fast32_t val); -static int jp2_putuint64(jas_stream_t *out, uint_fast64_t val); - -static int jp2_getint(jas_stream_t *in, int s, int n, int_fast32_t *val); - -jp2_box_t *jp2_box_get(jas_stream_t *in); -void jp2_box_dump(jp2_box_t *box, FILE *out); - -static int jp2_jp_getdata(jp2_box_t *box, jas_stream_t *in); -static int jp2_jp_putdata(jp2_box_t *box, jas_stream_t *out); -static int jp2_ftyp_getdata(jp2_box_t *box, jas_stream_t *in); -static int jp2_ftyp_putdata(jp2_box_t *box, jas_stream_t *out); -static int jp2_ihdr_getdata(jp2_box_t *box, jas_stream_t *in); -static int jp2_ihdr_putdata(jp2_box_t *box, jas_stream_t *out); -static void jp2_bpcc_destroy(jp2_box_t *box); -static int jp2_bpcc_getdata(jp2_box_t *box, jas_stream_t *in); -static int jp2_bpcc_putdata(jp2_box_t *box, jas_stream_t *out); -static int jp2_colr_getdata(jp2_box_t *box, jas_stream_t *in); -static int jp2_colr_putdata(jp2_box_t *box, jas_stream_t *out); -static void jp2_colr_dumpdata(jp2_box_t *box, FILE *out); -static void jp2_colr_destroy(jp2_box_t *box); -static void jp2_cdef_destroy(jp2_box_t *box); -static int jp2_cdef_getdata(jp2_box_t *box, jas_stream_t *in); -static int jp2_cdef_putdata(jp2_box_t *box, jas_stream_t *out); -static void jp2_cdef_dumpdata(jp2_box_t *box, FILE *out); -static void jp2_cmap_destroy(jp2_box_t *box); -static int jp2_cmap_getdata(jp2_box_t *box, jas_stream_t *in); -static int jp2_cmap_putdata(jp2_box_t *box, jas_stream_t *out); -static void jp2_cmap_dumpdata(jp2_box_t *box, FILE *out); -static void jp2_pclr_destroy(jp2_box_t *box); -static int jp2_pclr_getdata(jp2_box_t *box, jas_stream_t *in); -static int jp2_pclr_putdata(jp2_box_t *box, jas_stream_t *out); -static void jp2_pclr_dumpdata(jp2_box_t *box, FILE *out); - -/******************************************************************************\ -* Local data. -\******************************************************************************/ - -jp2_boxinfo_t jp2_boxinfos[] = { - {JP2_BOX_JP, "JP", 0, - {0, 0, jp2_jp_getdata, jp2_jp_putdata, 0}}, - {JP2_BOX_FTYP, "FTYP", 0, - {0, 0, jp2_ftyp_getdata, jp2_ftyp_putdata, 0}}, - {JP2_BOX_JP2H, "JP2H", JP2_BOX_SUPER, - {0, 0, 0, 0, 0}}, - {JP2_BOX_IHDR, "IHDR", 0, - {0, 0, jp2_ihdr_getdata, jp2_ihdr_putdata, 0}}, - {JP2_BOX_BPCC, "BPCC", 0, - {0, jp2_bpcc_destroy, jp2_bpcc_getdata, jp2_bpcc_putdata, 0}}, - {JP2_BOX_COLR, "COLR", 0, - {0, jp2_colr_destroy, jp2_colr_getdata, jp2_colr_putdata, jp2_colr_dumpdata}}, - {JP2_BOX_PCLR, "PCLR", 0, - {0, jp2_pclr_destroy, jp2_pclr_getdata, jp2_pclr_putdata, jp2_pclr_dumpdata}}, - {JP2_BOX_CMAP, "CMAP", 0, - {0, jp2_cmap_destroy, jp2_cmap_getdata, jp2_cmap_putdata, jp2_cmap_dumpdata}}, - {JP2_BOX_CDEF, "CDEF", 0, - {0, jp2_cdef_destroy, jp2_cdef_getdata, jp2_cdef_putdata, jp2_cdef_dumpdata}}, - {JP2_BOX_RES, "RES", JP2_BOX_SUPER, - {0, 0, 0, 0, 0}}, - {JP2_BOX_RESC, "RESC", 0, - {0, 0, 0, 0, 0}}, - {JP2_BOX_RESD, "RESD", 0, - {0, 0, 0, 0, 0}}, - {JP2_BOX_JP2C, "JP2C", JP2_BOX_NODATA, - {0, 0, 0, 0, 0}}, - {JP2_BOX_JP2I, "JP2I", 0, - {0, 0, 0, 0, 0}}, - {JP2_BOX_XML, "XML", 0, - {0, 0, 0, 0, 0}}, - {JP2_BOX_UUID, "UUID", 0, - {0, 0, 0, 0, 0}}, - {JP2_BOX_UINF, "UINF", JP2_BOX_SUPER, - {0, 0, 0, 0, 0}}, - {JP2_BOX_ULST, "ULST", 0, - {0, 0, 0, 0, 0}}, - {JP2_BOX_URL, "URL", 0, - {0, 0, 0, 0, 0}}, - {0, 0, 0, {0, 0, 0, 0, 0}}, -}; - -jp2_boxinfo_t jp2_boxinfo_unk = { - 0, "Unknown", 0, {0, 0, 0, 0, 0} -}; - -/******************************************************************************\ -* Box constructor. -\******************************************************************************/ - -jp2_box_t *jp2_box_create(int type) -{ - jp2_box_t *box; - jp2_boxinfo_t *boxinfo; - - if (!(box = jas_malloc(sizeof(jp2_box_t)))) { - return 0; - } - memset(box, 0, sizeof(jp2_box_t)); - box->type = type; - box->len = 0; - if (!(boxinfo = jp2_boxinfolookup(type))) { - return 0; - } - box->info = boxinfo; - box->ops = &boxinfo->ops; - return box; -} - -/******************************************************************************\ -* Box destructor. -\******************************************************************************/ - -void jp2_box_destroy(jp2_box_t *box) -{ - if (box->ops->destroy) { - (*box->ops->destroy)(box); - } - jas_free(box); -} - -static void jp2_bpcc_destroy(jp2_box_t *box) -{ - jp2_bpcc_t *bpcc = &box->data.bpcc; - if (bpcc->bpcs) { - jas_free(bpcc->bpcs); - bpcc->bpcs = 0; - } -} - -static void jp2_cdef_destroy(jp2_box_t *box) -{ - jp2_cdef_t *cdef = &box->data.cdef; - if (cdef->ents) { - jas_free(cdef->ents); - cdef->ents = 0; - } -} - -/******************************************************************************\ -* Box input. -\******************************************************************************/ - -jp2_box_t *jp2_box_get(jas_stream_t *in) -{ - jp2_box_t *box; - jp2_boxinfo_t *boxinfo; - jas_stream_t *tmpstream; - uint_fast32_t len; - uint_fast64_t extlen; - bool dataflag; - - box = 0; - tmpstream = 0; - - if (!(box = jas_malloc(sizeof(jp2_box_t)))) { - goto error; - } - box->ops = &jp2_boxinfo_unk.ops; - if (jp2_getuint32(in, &len) || jp2_getuint32(in, &box->type)) { - goto error; - } - boxinfo = jp2_boxinfolookup(box->type); - box->info = boxinfo; - box->ops = &boxinfo->ops; - box->len = len; - if (box->len == 1) { - if (jp2_getuint64(in, &extlen)) { - goto error; - } - if (extlen > 0xffffffffUL) { - jas_eprintf("warning: cannot handle large 64-bit box length\n"); - extlen = 0xffffffffUL; - } - box->len = extlen; - box->datalen = extlen - JP2_BOX_HDRLEN(true); - } else { - box->datalen = box->len - JP2_BOX_HDRLEN(false); - } - if (box->len != 0 && box->len < 8) { - goto error; - } - - dataflag = !(box->info->flags & (JP2_BOX_SUPER | JP2_BOX_NODATA)); - - if (dataflag) { - if (!(tmpstream = jas_stream_memopen(0, 0))) { - goto error; - } - if (jas_stream_copy(tmpstream, in, box->datalen)) { - jas_eprintf("cannot copy box data\n"); - goto error; - } - jas_stream_rewind(tmpstream); - - if (box->ops->getdata) { - if ((*box->ops->getdata)(box, tmpstream)) { - jas_eprintf("cannot parse box data\n"); - goto error; - } - } - jas_stream_close(tmpstream); - } - - if (jas_getdbglevel() >= 1) { - jp2_box_dump(box, stderr); - } - - return box; - abort(); - -error: - if (box) { - jp2_box_destroy(box); - } - if (tmpstream) { - jas_stream_close(tmpstream); - } - return 0; -} - -void jp2_box_dump(jp2_box_t *box, FILE *out) -{ - jp2_boxinfo_t *boxinfo; - boxinfo = jp2_boxinfolookup(box->type); - assert(boxinfo); - - fprintf(out, "JP2 box: "); - fprintf(out, "type=%c%s%c (0x%08x); length=%d\n", '"', boxinfo->name, - '"', box->type, box->len); - if (box->ops->dumpdata) { - (*box->ops->dumpdata)(box, out); - } -} - -static int jp2_jp_getdata(jp2_box_t *box, jas_stream_t *in) -{ - jp2_jp_t *jp = &box->data.jp; - if (jp2_getuint32(in, &jp->magic)) { - return -1; - } - return 0; -} - -static int jp2_ftyp_getdata(jp2_box_t *box, jas_stream_t *in) -{ - jp2_ftyp_t *ftyp = &box->data.ftyp; - unsigned int i; - if (jp2_getuint32(in, &ftyp->majver) || jp2_getuint32(in, &ftyp->minver)) { - return -1; - } - ftyp->numcompatcodes = (box->datalen - 8) / 4; - if (ftyp->numcompatcodes > JP2_FTYP_MAXCOMPATCODES) { - return -1; - } - for (i = 0; i < ftyp->numcompatcodes; ++i) { - if (jp2_getuint32(in, &ftyp->compatcodes[i])) { - return -1; - } - } - return 0; -} - -static int jp2_ihdr_getdata(jp2_box_t *box, jas_stream_t *in) -{ - jp2_ihdr_t *ihdr = &box->data.ihdr; - if (jp2_getuint32(in, &ihdr->height) || jp2_getuint32(in, &ihdr->width) || - jp2_getuint16(in, &ihdr->numcmpts) || jp2_getuint8(in, &ihdr->bpc) || - jp2_getuint8(in, &ihdr->comptype) || jp2_getuint8(in, &ihdr->csunk) || - jp2_getuint8(in, &ihdr->ipr)) { - return -1; - } - return 0; -} - -static int jp2_bpcc_getdata(jp2_box_t *box, jas_stream_t *in) -{ - jp2_bpcc_t *bpcc = &box->data.bpcc; - unsigned int i; - bpcc->numcmpts = box->datalen; - if (!(bpcc->bpcs = jas_malloc(bpcc->numcmpts * sizeof(uint_fast8_t)))) { - return -1; - } - for (i = 0; i < bpcc->numcmpts; ++i) { - if (jp2_getuint8(in, &bpcc->bpcs[i])) { - return -1; - } - } - return 0; -} - -static void jp2_colr_dumpdata(jp2_box_t *box, FILE *out) -{ - jp2_colr_t *colr = &box->data.colr; - fprintf(out, "method=%d; pri=%d; approx=%d\n", (int)colr->method, (int)colr->pri, (int)colr->approx); - switch (colr->method) { - case JP2_COLR_ENUM: - fprintf(out, "csid=%d\n", (int)colr->csid); - break; - case JP2_COLR_ICC: - jas_memdump(out, colr->iccp, colr->iccplen); - break; - } -} - -static int jp2_colr_getdata(jp2_box_t *box, jas_stream_t *in) -{ - jp2_colr_t *colr = &box->data.colr; - colr->csid = 0; - colr->iccp = 0; - colr->iccplen = 0; - - if (jp2_getuint8(in, &colr->method) || jp2_getuint8(in, &colr->pri) || - jp2_getuint8(in, &colr->approx)) { - return -1; - } - switch (colr->method) { - case JP2_COLR_ENUM: - if (jp2_getuint32(in, &colr->csid)) { - return -1; - } - break; - case JP2_COLR_ICC: - colr->iccplen = box->datalen - 3; - if (!(colr->iccp = jas_malloc(colr->iccplen * sizeof(uint_fast8_t)))) { - return -1; - } - if (jas_stream_read(in, colr->iccp, colr->iccplen) != colr->iccplen) { - return -1; - } - break; - } - return 0; -} - -static void jp2_cdef_dumpdata(jp2_box_t *box, FILE *out) -{ - jp2_cdef_t *cdef = &box->data.cdef; - unsigned int i; - for (i = 0; i < cdef->numchans; ++i) { - fprintf(out, "channo=%d; type=%d; assoc=%d\n", - cdef->ents[i].channo, cdef->ents[i].type, cdef->ents[i].assoc); - } -} - -static void jp2_colr_destroy(jp2_box_t *box) -{ - jp2_colr_t *colr = &box->data.colr; - if (colr->iccp) { - jas_free(colr->iccp); - } -} - -static int jp2_cdef_getdata(jp2_box_t *box, jas_stream_t *in) -{ - jp2_cdef_t *cdef = &box->data.cdef; - jp2_cdefchan_t *chan; - unsigned int channo; - if (jp2_getuint16(in, &cdef->numchans)) { - return -1; - } - if (!(cdef->ents = jas_malloc(cdef->numchans * sizeof(jp2_cdefchan_t)))) { - return -1; - } - for (channo = 0; channo < cdef->numchans; ++channo) { - chan = &cdef->ents[channo]; - if (jp2_getuint16(in, &chan->channo) || jp2_getuint16(in, &chan->type) || - jp2_getuint16(in, &chan->assoc)) { - return -1; - } - } - return 0; -} - -/******************************************************************************\ -* Box output. -\******************************************************************************/ - -int jp2_box_put(jp2_box_t *box, jas_stream_t *out) -{ - jas_stream_t *tmpstream; - bool extlen; - bool dataflag; - - tmpstream = 0; - - dataflag = !(box->info->flags & (JP2_BOX_SUPER | JP2_BOX_NODATA)); - - if (dataflag) { - tmpstream = jas_stream_memopen(0, 0); - if (box->ops->putdata) { - if ((*box->ops->putdata)(box, tmpstream)) { - goto error; - } - } - box->len = jas_stream_tell(tmpstream) + JP2_BOX_HDRLEN(false); - jas_stream_rewind(tmpstream); - } - extlen = (box->len >= (((uint_fast64_t)1) << 32)) != 0; - if (jp2_putuint32(out, extlen ? 1 : box->len)) { - goto error; - } - if (jp2_putuint32(out, box->type)) { - goto error; - } - if (extlen) { - if (jp2_putuint64(out, box->len)) { - goto error; - } - } - - if (dataflag) { - if (jas_stream_copy(out, tmpstream, box->len - JP2_BOX_HDRLEN(false))) { - goto error; - } - jas_stream_close(tmpstream); - } - - return 0; - abort(); - -error: - - if (tmpstream) { - jas_stream_close(tmpstream); - } - return -1; -} - -static int jp2_jp_putdata(jp2_box_t *box, jas_stream_t *out) -{ - jp2_jp_t *jp = &box->data.jp; - if (jp2_putuint32(out, jp->magic)) { - return -1; - } - return 0; -} - -static int jp2_ftyp_putdata(jp2_box_t *box, jas_stream_t *out) -{ - jp2_ftyp_t *ftyp = &box->data.ftyp; - unsigned int i; - if (jp2_putuint32(out, ftyp->majver) || jp2_putuint32(out, ftyp->minver)) { - return -1; - } - for (i = 0; i < ftyp->numcompatcodes; ++i) { - if (jp2_putuint32(out, ftyp->compatcodes[i])) { - return -1; - } - } - return 0; -} - -static int jp2_ihdr_putdata(jp2_box_t *box, jas_stream_t *out) -{ - jp2_ihdr_t *ihdr = &box->data.ihdr; - if (jp2_putuint32(out, ihdr->height) || jp2_putuint32(out, ihdr->width) || - jp2_putuint16(out, ihdr->numcmpts) || jp2_putuint8(out, ihdr->bpc) || - jp2_putuint8(out, ihdr->comptype) || jp2_putuint8(out, ihdr->csunk) || - jp2_putuint8(out, ihdr->ipr)) { - return -1; - } - return 0; -} - -static int jp2_bpcc_putdata(jp2_box_t *box, jas_stream_t *out) -{ - jp2_bpcc_t *bpcc = &box->data.bpcc; - unsigned int i; - for (i = 0; i < bpcc->numcmpts; ++i) { - if (jp2_putuint8(out, bpcc->bpcs[i])) { - return -1; - } - } - return 0; -} - -static int jp2_colr_putdata(jp2_box_t *box, jas_stream_t *out) -{ - jp2_colr_t *colr = &box->data.colr; - if (jp2_putuint8(out, colr->method) || jp2_putuint8(out, colr->pri) || - jp2_putuint8(out, colr->approx)) { - return -1; - } - switch (colr->method) { - case JP2_COLR_ENUM: - if (jp2_putuint32(out, colr->csid)) { - return -1; - } - break; - case JP2_COLR_ICC: - if (jas_stream_write(out, colr->iccp, - JAS_CAST(int, colr->iccplen)) != JAS_CAST(int, colr->iccplen)) - return -1; - break; - } - return 0; -} - -static int jp2_cdef_putdata(jp2_box_t *box, jas_stream_t *out) -{ - jp2_cdef_t *cdef = &box->data.cdef; - unsigned int i; - jp2_cdefchan_t *ent; - - if (jp2_putuint16(out, cdef->numchans)) { - return -1; - } - - for (i = 0; i < cdef->numchans; ++i) { - ent = &cdef->ents[i]; - if (jp2_putuint16(out, ent->channo) || - jp2_putuint16(out, ent->type) || - jp2_putuint16(out, ent->assoc)) { - return -1; - } - } - return 0; -} - -/******************************************************************************\ -* Input operations for primitive types. -\******************************************************************************/ - -static int jp2_getuint8(jas_stream_t *in, uint_fast8_t *val) -{ - int c; - if ((c = jas_stream_getc(in)) == EOF) { - return -1; - } - if (val) { - *val = c; - } - return 0; -} - -static int jp2_getuint16(jas_stream_t *in, uint_fast16_t *val) -{ - uint_fast16_t v; - int c; - if ((c = jas_stream_getc(in)) == EOF) { - return -1; - } - v = c; - if ((c = jas_stream_getc(in)) == EOF) { - return -1; - } - v = (v << 8) | c; - if (val) { - *val = v; - } - return 0; -} - -static int jp2_getuint32(jas_stream_t *in, uint_fast32_t *val) -{ - uint_fast32_t v; - int c; - if ((c = jas_stream_getc(in)) == EOF) { - return -1; - } - v = c; - if ((c = jas_stream_getc(in)) == EOF) { - return -1; - } - v = (v << 8) | c; - if ((c = jas_stream_getc(in)) == EOF) { - return -1; - } - v = (v << 8) | c; - if ((c = jas_stream_getc(in)) == EOF) { - return -1; - } - v = (v << 8) | c; - if (val) { - *val = v; - } - return 0; -} - -static int jp2_getuint64(jas_stream_t *in, uint_fast64_t *val) -{ - uint_fast64_t tmpval; - int i; - int c; - - tmpval = 0; - for (i = 0; i < 8; ++i) { - tmpval <<= 8; - if ((c = jas_stream_getc(in)) == EOF) { - return -1; - } - tmpval |= (c & 0xff); - } - *val = tmpval; - - return 0; -} - -/******************************************************************************\ -* Output operations for primitive types. -\******************************************************************************/ - -static int jp2_putuint8(jas_stream_t *out, uint_fast8_t val) -{ - if (jas_stream_putc(out, val & 0xff) == EOF) { - return -1; - } - return 0; -} - -static int jp2_putuint16(jas_stream_t *out, uint_fast16_t val) -{ - if (jas_stream_putc(out, (val >> 8) & 0xff) == EOF || - jas_stream_putc(out, val & 0xff) == EOF) { - return -1; - } - return 0; -} - -static int jp2_putuint32(jas_stream_t *out, uint_fast32_t val) -{ - if (jas_stream_putc(out, (val >> 24) & 0xff) == EOF || - jas_stream_putc(out, (val >> 16) & 0xff) == EOF || - jas_stream_putc(out, (val >> 8) & 0xff) == EOF || - jas_stream_putc(out, val & 0xff) == EOF) { - return -1; - } - return 0; -} - -static int jp2_putuint64(jas_stream_t *out, uint_fast64_t val) -{ - if (jp2_putuint32(out, (val >> 32) & 0xffffffffUL) || - jp2_putuint32(out, val & 0xffffffffUL)) { - return -1; - } - return 0; -} - -/******************************************************************************\ -* Miscellaneous code. -\******************************************************************************/ - -jp2_boxinfo_t *jp2_boxinfolookup(int type) -{ - jp2_boxinfo_t *boxinfo; - for (boxinfo = jp2_boxinfos; boxinfo->name; ++boxinfo) { - if (boxinfo->type == type) { - return boxinfo; - } - } - return &jp2_boxinfo_unk; -} - - - - - -static void jp2_cmap_destroy(jp2_box_t *box) -{ - jp2_cmap_t *cmap = &box->data.cmap; - if (cmap->ents) { - jas_free(cmap->ents); - } -} - -static int jp2_cmap_getdata(jp2_box_t *box, jas_stream_t *in) -{ - jp2_cmap_t *cmap = &box->data.cmap; - jp2_cmapent_t *ent; - unsigned int i; - - cmap->numchans = (box->datalen) / 4; - if (!(cmap->ents = jas_malloc(cmap->numchans * sizeof(jp2_cmapent_t)))) { - return -1; - } - for (i = 0; i < cmap->numchans; ++i) { - ent = &cmap->ents[i]; - if (jp2_getuint16(in, &ent->cmptno) || - jp2_getuint8(in, &ent->map) || - jp2_getuint8(in, &ent->pcol)) { - return -1; - } - } - - return 0; -} - -static int jp2_cmap_putdata(jp2_box_t *box, jas_stream_t *out) -{ - /* Eliminate compiler warning about unused variables. */ - box = 0; - out = 0; - - return -1; -} - -static void jp2_cmap_dumpdata(jp2_box_t *box, FILE *out) -{ - jp2_cmap_t *cmap = &box->data.cmap; - unsigned int i; - jp2_cmapent_t *ent; - fprintf(out, "numchans = %d\n", (int) cmap->numchans); - for (i = 0; i < cmap->numchans; ++i) { - ent = &cmap->ents[i]; - fprintf(out, "cmptno=%d; map=%d; pcol=%d\n", - (int) ent->cmptno, (int) ent->map, (int) ent->pcol); - } -} - -static void jp2_pclr_destroy(jp2_box_t *box) -{ - jp2_pclr_t *pclr = &box->data.pclr; - if (pclr->lutdata) { - jas_free(pclr->lutdata); - } - if (pclr->bpc) - jas_free(pclr->bpc); -} - -static int jp2_pclr_getdata(jp2_box_t *box, jas_stream_t *in) -{ - jp2_pclr_t *pclr = &box->data.pclr; - int lutsize; - unsigned int i; - unsigned int j; - int_fast32_t x; - - pclr->lutdata = 0; - - if (jp2_getuint16(in, &pclr->numlutents) || - jp2_getuint8(in, &pclr->numchans)) { - return -1; - } - lutsize = pclr->numlutents * pclr->numchans; - if (!(pclr->lutdata = jas_malloc(lutsize * sizeof(int_fast32_t)))) { - return -1; - } - if (!(pclr->bpc = jas_malloc(pclr->numchans * sizeof(uint_fast8_t)))) { - return -1; - } - for (i = 0; i < pclr->numchans; ++i) { - if (jp2_getuint8(in, &pclr->bpc[i])) { - return -1; - } - } - for (i = 0; i < pclr->numlutents; ++i) { - for (j = 0; j < pclr->numchans; ++j) { - if (jp2_getint(in, (pclr->bpc[j] & 0x80) != 0, - (pclr->bpc[j] & 0x7f) + 1, &x)) { - return -1; - } - pclr->lutdata[i * pclr->numchans + j] = x; - } - } - return 0; -} - -static int jp2_pclr_putdata(jp2_box_t *box, jas_stream_t *out) -{ -#if 0 - jp2_pclr_t *pclr = &box->data.pclr; -#endif -/* Eliminate warning about unused variable. */ -box = 0; -out = 0; - return -1; -} - -static void jp2_pclr_dumpdata(jp2_box_t *box, FILE *out) -{ - jp2_pclr_t *pclr = &box->data.pclr; - unsigned int i; - int j; - fprintf(out, "numents=%d; numchans=%d\n", (int) pclr->numlutents, - (int) pclr->numchans); - for (i = 0; i < pclr->numlutents; ++i) { - for (j = 0; j < pclr->numchans; ++j) { - fprintf(out, "LUT[%d][%d]=%d\n", i, j, pclr->lutdata[i * pclr->numchans + j]); - } - } -} - -static int jp2_getint(jas_stream_t *in, int s, int n, int_fast32_t *val) -{ - int c; - int i; - uint_fast32_t v; - int m; - - m = (n + 7) / 8; - - v = 0; - for (i = 0; i < m; ++i) { - if ((c = jas_stream_getc(in)) == EOF) { - return -1; - } - v = (v << 8) | c; - } - v &= ONES(n); - if (s) { - int sb; - sb = v & (1 << (8 * m - 1)); - *val = ((~v) + 1) & ONES(8 * m); - if (sb) { - *val = -*val; - } - } else { - *val = v; - } - - return 0; -} - -jp2_cdefchan_t *jp2_cdef_lookup(jp2_cdef_t *cdef, int channo) -{ - unsigned int i; - jp2_cdefchan_t *cdefent; - for (i = 0; i < cdef->numchans; ++i) { - cdefent = &cdef->ents[i]; - if (cdefent->channo == JAS_CAST(unsigned int, channo)) { - return cdefent; - } - } - return 0; -} diff --git a/nativeLib/rary.cots.jasper/jasper-1.900.1/src/libjasper/jp2/jp2_enc.c.orig b/nativeLib/rary.cots.jasper/jasper-1.900.1/src/libjasper/jp2/jp2_enc.c.orig deleted file mode 100644 index 9e1e1fc47d..0000000000 --- a/nativeLib/rary.cots.jasper/jasper-1.900.1/src/libjasper/jp2/jp2_enc.c.orig +++ /dev/null @@ -1,436 +0,0 @@ -/* - * Copyright (c) 1999-2000 Image Power, Inc. and the University of - * British Columbia. - * Copyright (c) 2001-2003 Michael David Adams. - * All rights reserved. - */ - -/* __START_OF_JASPER_LICENSE__ - * - * JasPer License Version 2.0 - * - * Copyright (c) 2001-2006 Michael David Adams - * Copyright (c) 1999-2000 Image Power, Inc. - * Copyright (c) 1999-2000 The University of British Columbia - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person (the - * "User") obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, and/or sell copies of the Software, and to permit - * persons to whom the Software is furnished to do so, subject to the - * following conditions: - * - * 1. The above copyright notices and this permission notice (which - * includes the disclaimer below) shall be included in all copies or - * substantial portions of the Software. - * - * 2. The name of a copyright holder shall not be used to endorse or - * promote products derived from the Software without specific prior - * written permission. - * - * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS - * LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER - * THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS - * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING - * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL - * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING - * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE - * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE - * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY. - * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS - * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL - * PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS - * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE - * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE - * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL - * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES, - * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL - * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH - * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH, - * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH - * RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY - * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES. - * - * __END_OF_JASPER_LICENSE__ - */ - -/* - * JP2 Library - * - * $Id$ - */ - -/******************************************************************************\ -* Includes. -\******************************************************************************/ - -#include -#include "jasper/jas_malloc.h" -#include "jasper/jas_image.h" -#include "jasper/jas_stream.h" -#include "jasper/jas_cm.h" -#include "jasper/jas_icc.h" -#include "jp2_cod.h" - -static uint_fast32_t jp2_gettypeasoc(int colorspace, int ctype); -static int clrspctojp2(jas_clrspc_t clrspc); - -/******************************************************************************\ -* Functions. -\******************************************************************************/ - -int jp2_encode(jas_image_t *image, jas_stream_t *out, char *optstr) -{ - jp2_box_t *box; - jp2_ftyp_t *ftyp; - jp2_ihdr_t *ihdr; - jas_stream_t *tmpstream; - int allcmptssame; - jp2_bpcc_t *bpcc; - long len; - uint_fast16_t cmptno; - jp2_colr_t *colr; - char buf[4096]; - uint_fast32_t overhead; - jp2_cdefchan_t *cdefchanent; - jp2_cdef_t *cdef; - int i; - uint_fast32_t typeasoc; -jas_iccprof_t *iccprof; -jas_stream_t *iccstream; -int pos; -int needcdef; -int prec; -int sgnd; - - box = 0; - tmpstream = 0; - - allcmptssame = 1; - sgnd = jas_image_cmptsgnd(image, 0); - prec = jas_image_cmptprec(image, 0); - for (i = 1; i < jas_image_numcmpts(image); ++i) { - if (jas_image_cmptsgnd(image, i) != sgnd || - jas_image_cmptprec(image, i) != prec) { - allcmptssame = 0; - break; - } - } - - /* Output the signature box. */ - - if (!(box = jp2_box_create(JP2_BOX_JP))) { - goto error; - } - box->data.jp.magic = JP2_JP_MAGIC; - if (jp2_box_put(box, out)) { - goto error; - } - jp2_box_destroy(box); - box = 0; - - /* Output the file type box. */ - - if (!(box = jp2_box_create(JP2_BOX_FTYP))) { - goto error; - } - ftyp = &box->data.ftyp; - ftyp->majver = JP2_FTYP_MAJVER; - ftyp->minver = JP2_FTYP_MINVER; - ftyp->numcompatcodes = 1; - ftyp->compatcodes[0] = JP2_FTYP_COMPATCODE; - if (jp2_box_put(box, out)) { - goto error; - } - jp2_box_destroy(box); - box = 0; - - /* - * Generate the data portion of the JP2 header box. - * We cannot simply output the header for this box - * since we do not yet know the correct value for the length - * field. - */ - - if (!(tmpstream = jas_stream_memopen(0, 0))) { - goto error; - } - - /* Generate image header box. */ - - if (!(box = jp2_box_create(JP2_BOX_IHDR))) { - goto error; - } - ihdr = &box->data.ihdr; - ihdr->width = jas_image_width(image); - ihdr->height = jas_image_height(image); - ihdr->numcmpts = jas_image_numcmpts(image); - ihdr->bpc = allcmptssame ? JP2_SPTOBPC(jas_image_cmptsgnd(image, 0), - jas_image_cmptprec(image, 0)) : JP2_IHDR_BPCNULL; - ihdr->comptype = JP2_IHDR_COMPTYPE; - ihdr->csunk = 0; - ihdr->ipr = 0; - if (jp2_box_put(box, tmpstream)) { - goto error; - } - jp2_box_destroy(box); - box = 0; - - /* Generate bits per component box. */ - - if (!allcmptssame) { - if (!(box = jp2_box_create(JP2_BOX_BPCC))) { - goto error; - } - bpcc = &box->data.bpcc; - bpcc->numcmpts = jas_image_numcmpts(image); - if (!(bpcc->bpcs = jas_malloc(bpcc->numcmpts * - sizeof(uint_fast8_t)))) { - goto error; - } - for (cmptno = 0; cmptno < bpcc->numcmpts; ++cmptno) { - bpcc->bpcs[cmptno] = JP2_SPTOBPC(jas_image_cmptsgnd(image, - cmptno), jas_image_cmptprec(image, cmptno)); - } - if (jp2_box_put(box, tmpstream)) { - goto error; - } - jp2_box_destroy(box); - box = 0; - } - - /* Generate color specification box. */ - - if (!(box = jp2_box_create(JP2_BOX_COLR))) { - goto error; - } - colr = &box->data.colr; - switch (jas_image_clrspc(image)) { - case JAS_CLRSPC_SRGB: - case JAS_CLRSPC_SYCBCR: - case JAS_CLRSPC_SGRAY: - colr->method = JP2_COLR_ENUM; - colr->csid = clrspctojp2(jas_image_clrspc(image)); - colr->pri = JP2_COLR_PRI; - colr->approx = 0; - break; - default: - colr->method = JP2_COLR_ICC; - colr->pri = JP2_COLR_PRI; - colr->approx = 0; - iccprof = jas_iccprof_createfromcmprof(jas_image_cmprof(image)); - assert(iccprof); - iccstream = jas_stream_memopen(0, 0); - assert(iccstream); - if (jas_iccprof_save(iccprof, iccstream)) - abort(); - if ((pos = jas_stream_tell(iccstream)) < 0) - abort(); - colr->iccplen = pos; - colr->iccp = jas_malloc(pos); - assert(colr->iccp); - jas_stream_rewind(iccstream); - if (jas_stream_read(iccstream, colr->iccp, colr->iccplen) != colr->iccplen) - abort(); - jas_stream_close(iccstream); - jas_iccprof_destroy(iccprof); - break; - } - if (jp2_box_put(box, tmpstream)) { - goto error; - } - jp2_box_destroy(box); - box = 0; - - needcdef = 1; - switch (jas_clrspc_fam(jas_image_clrspc(image))) { - case JAS_CLRSPC_FAM_RGB: - if (jas_image_cmpttype(image, 0) == - JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_R) && - jas_image_cmpttype(image, 1) == - JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_G) && - jas_image_cmpttype(image, 2) == - JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_B)) - needcdef = 0; - break; - case JAS_CLRSPC_FAM_YCBCR: - if (jas_image_cmpttype(image, 0) == - JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_YCBCR_Y) && - jas_image_cmpttype(image, 1) == - JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_YCBCR_CB) && - jas_image_cmpttype(image, 2) == - JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_YCBCR_CR)) - needcdef = 0; - break; - case JAS_CLRSPC_FAM_GRAY: - if (jas_image_cmpttype(image, 0) == - JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_GRAY_Y)) - needcdef = 0; - break; - default: - abort(); - break; - } - - if (needcdef) { - if (!(box = jp2_box_create(JP2_BOX_CDEF))) { - goto error; - } - cdef = &box->data.cdef; - cdef->numchans = jas_image_numcmpts(image); - cdef->ents = jas_malloc(cdef->numchans * sizeof(jp2_cdefchan_t)); - for (i = 0; i < jas_image_numcmpts(image); ++i) { - cdefchanent = &cdef->ents[i]; - cdefchanent->channo = i; - typeasoc = jp2_gettypeasoc(jas_image_clrspc(image), jas_image_cmpttype(image, i)); - cdefchanent->type = typeasoc >> 16; - cdefchanent->assoc = typeasoc & 0x7fff; - } - if (jp2_box_put(box, tmpstream)) { - goto error; - } - jp2_box_destroy(box); - box = 0; - } - - /* Determine the total length of the JP2 header box. */ - - len = jas_stream_tell(tmpstream); - jas_stream_rewind(tmpstream); - - /* - * Output the JP2 header box and all of the boxes which it contains. - */ - - if (!(box = jp2_box_create(JP2_BOX_JP2H))) { - goto error; - } - box->len = len + JP2_BOX_HDRLEN(false); - if (jp2_box_put(box, out)) { - goto error; - } - jp2_box_destroy(box); - box = 0; - - if (jas_stream_copy(out, tmpstream, len)) { - goto error; - } - - jas_stream_close(tmpstream); - tmpstream = 0; - - /* - * Output the contiguous code stream box. - */ - - if (!(box = jp2_box_create(JP2_BOX_JP2C))) { - goto error; - } - box->len = 0; - if (jp2_box_put(box, out)) { - goto error; - } - jp2_box_destroy(box); - box = 0; - - /* Output the JPEG-2000 code stream. */ - - overhead = jas_stream_getrwcount(out); - sprintf(buf, "%s\n_jp2overhead=%lu\n", (optstr ? optstr : ""), - (unsigned long) overhead); - - if (jpc_encode(image, out, buf)) { - goto error; - } - - return 0; - abort(); - -error: - - if (box) { - jp2_box_destroy(box); - } - if (tmpstream) { - jas_stream_close(tmpstream); - } - return -1; -} - -static uint_fast32_t jp2_gettypeasoc(int colorspace, int ctype) -{ - int type; - int asoc; - - if (ctype & JAS_IMAGE_CT_OPACITY) { - type = JP2_CDEF_TYPE_OPACITY; - asoc = JP2_CDEF_ASOC_ALL; - goto done; - } - - type = JP2_CDEF_TYPE_UNSPEC; - asoc = JP2_CDEF_ASOC_NONE; - switch (jas_clrspc_fam(colorspace)) { - case JAS_CLRSPC_FAM_RGB: - switch (JAS_IMAGE_CT_COLOR(ctype)) { - case JAS_IMAGE_CT_RGB_R: - type = JP2_CDEF_TYPE_COLOR; - asoc = JP2_CDEF_RGB_R; - break; - case JAS_IMAGE_CT_RGB_G: - type = JP2_CDEF_TYPE_COLOR; - asoc = JP2_CDEF_RGB_G; - break; - case JAS_IMAGE_CT_RGB_B: - type = JP2_CDEF_TYPE_COLOR; - asoc = JP2_CDEF_RGB_B; - break; - } - break; - case JAS_CLRSPC_FAM_YCBCR: - switch (JAS_IMAGE_CT_COLOR(ctype)) { - case JAS_IMAGE_CT_YCBCR_Y: - type = JP2_CDEF_TYPE_COLOR; - asoc = JP2_CDEF_YCBCR_Y; - break; - case JAS_IMAGE_CT_YCBCR_CB: - type = JP2_CDEF_TYPE_COLOR; - asoc = JP2_CDEF_YCBCR_CB; - break; - case JAS_IMAGE_CT_YCBCR_CR: - type = JP2_CDEF_TYPE_COLOR; - asoc = JP2_CDEF_YCBCR_CR; - break; - } - break; - case JAS_CLRSPC_FAM_GRAY: - type = JP2_CDEF_TYPE_COLOR; - asoc = JP2_CDEF_GRAY_Y; - break; - } - -done: - return (type << 16) | asoc; -} - -static int clrspctojp2(jas_clrspc_t clrspc) -{ - switch (clrspc) { - case JAS_CLRSPC_SRGB: - return JP2_COLR_SRGB; - case JAS_CLRSPC_SYCBCR: - return JP2_COLR_SYCC; - case JAS_CLRSPC_SGRAY: - return JP2_COLR_SGRAY; - default: - abort(); - break; - } -} diff --git a/ncep/gov.noaa.nws.ncep.edex.uengine/.classpath b/ncep/gov.noaa.nws.ncep.edex.uengine/.classpath index 1fa3e6803d..16d067f284 100644 --- a/ncep/gov.noaa.nws.ncep.edex.uengine/.classpath +++ b/ncep/gov.noaa.nws.ncep.edex.uengine/.classpath @@ -1,7 +1,7 @@ - + diff --git a/ncep/gov.noaa.nws.ncep.viz.resourceManager/src/gov/noaa/nws/ncep/viz/resourceManager/ui/createRbd/CreateRbdControl.java b/ncep/gov.noaa.nws.ncep.viz.resourceManager/src/gov/noaa/nws/ncep/viz/resourceManager/ui/createRbd/CreateRbdControl.java index 0d69d3b7ca..b3c56a75e8 100644 --- a/ncep/gov.noaa.nws.ncep.viz.resourceManager/src/gov/noaa/nws/ncep/viz/resourceManager/ui/createRbd/CreateRbdControl.java +++ b/ncep/gov.noaa.nws.ncep.viz.resourceManager/src/gov/noaa/nws/ncep/viz/resourceManager/ui/createRbd/CreateRbdControl.java @@ -516,7 +516,7 @@ public class CreateRbdControl extends Composite implements IPartListener2 { import_lbl.setLayoutData(form_data); */ - rbd_name_txt = ""; + rbd_name_txt = new Text(rbd_grp, SWT.SINGLE | SWT.BORDER); /* rbd_name_txt = new Text(rbd_grp, SWT.SINGLE | SWT.BORDER); form_data = new FormData(200, 20); @@ -534,7 +534,7 @@ public class CreateRbdControl extends Composite implements IPartListener2 { */ // Import - import_rbd_btn = new Button( rbd_grp, SWT.PUSH ); + Button import_rbd_btn = new Button( rbd_grp, SWT.PUSH ); import_rbd_btn.setText(ImportFromSPF); FormData form_data = new FormData(); form_data.width = 120; @@ -854,7 +854,7 @@ public class CreateRbdControl extends Composite implements IPartListener2 { sel_rsc_btn.setLayoutData(form_data); // Edit - edit_rsc_btn = new Button( seld_rscs_group, SWT.PUSH ); + edit_rsc_btn = new Button( seld_rscs_grp, SWT.PUSH ); edit_rsc_btn.setText("Edit"); form_data = new FormData(); form_data.width = 75; @@ -864,7 +864,7 @@ public class CreateRbdControl extends Composite implements IPartListener2 { edit_rsc_btn.setEnabled(false); // Remove - del_rsc_btn = new Button( seld_rscs_group, SWT.PUSH ); + del_rsc_btn = new Button( seld_rscs_grp, SWT.PUSH ); del_rsc_btn.setText("Remove"); form_data = new FormData(); form_data.width = 75; @@ -874,7 +874,7 @@ public class CreateRbdControl extends Composite implements IPartListener2 { del_rsc_btn.setEnabled(false); // Turn Off - disable_rsc_btn = new Button( seld_rscs_group, SWT.TOGGLE ); + disable_rsc_btn = new Button( seld_rscs_grp, SWT.TOGGLE ); disable_rsc_btn.setText("Turn Off"); form_data = new FormData(); form_data.width = 75; @@ -883,7 +883,7 @@ public class CreateRbdControl extends Composite implements IPartListener2 { disable_rsc_btn.setLayoutData(form_data); // Move Down - Button move_down_btn = new Button( seld_rscs_group, SWT.ARROW | SWT.DOWN ); + Button move_down_btn = new Button( seld_rscs_grp, SWT.ARROW | SWT.DOWN ); move_down_btn.setToolTipText("Move Down"); form_data = new FormData(); form_data.width = 35; @@ -893,7 +893,7 @@ public class CreateRbdControl extends Composite implements IPartListener2 { move_down_btn.setEnabled(false); // Move Up - Button move_up_btn = new Button( seld_rscs_group, SWT.ARROW | SWT.UP ); + Button move_up_btn = new Button( seld_rscs_grp, SWT.ARROW | SWT.UP ); move_up_btn.setToolTipText("Move Up"); form_data = new FormData(); form_data.width = 35; @@ -902,7 +902,7 @@ public class CreateRbdControl extends Composite implements IPartListener2 { move_up_btn.setLayoutData(form_data); move_up_btn.setEnabled(false); - Button edit_span_btn = new Button( seld_rscs_group, SWT.PUSH ); + Button edit_span_btn = new Button( seld_rscs_grp, SWT.PUSH ); edit_span_btn.setText("Bin"); form_data = new FormData(); form_data.width = 75; @@ -1947,6 +1947,7 @@ public class CreateRbdControl extends Composite implements IPartListener2 { } }); + */ // only 1 should be selected or this button should be greyed out edit_rsc_btn.addSelectionListener(new SelectionAdapter() { diff --git a/ncep/gov.noaa.nws.ncep.viz.resourceManager/src/gov/noaa/nws/ncep/viz/resourceManager/ui/createRbd/ResourceSelectionControl.java b/ncep/gov.noaa.nws.ncep.viz.resourceManager/src/gov/noaa/nws/ncep/viz/resourceManager/ui/createRbd/ResourceSelectionControl.java index 2603fa70a0..f3079c0622 100644 --- a/ncep/gov.noaa.nws.ncep.viz.resourceManager/src/gov/noaa/nws/ncep/viz/resourceManager/ui/createRbd/ResourceSelectionControl.java +++ b/ncep/gov.noaa.nws.ncep.viz.resourceManager/src/gov/noaa/nws/ncep/viz/resourceManager/ui/createRbd/ResourceSelectionControl.java @@ -123,6 +123,7 @@ public class ResourceSelectionControl extends Composite { protected Button addResourceBtn = null; + protected Button replaceResourceBtn = null; protected Boolean replaceBtnVisible; @@ -361,13 +362,14 @@ public class ResourceSelectionControl extends Composite { addResourceBtn.setText( " Add " ); // Add To RBD + /* can_btn = new Button( sel_rsc_comp, SWT.PUSH ); can_btn.setText(" Cancel "); fd = new FormData(); fd.top = new FormAttachment( seldRscNameTxt, 0, SWT.TOP ); fd.right = new FormAttachment( addResourceBtn, -10, SWT.LEFT ); can_btn.setLayoutData( fd ); - + */ /* replaceResourceBtn = new Button(sel_rsc_comp, SWT.None); fd = new FormData(); @@ -395,10 +397,10 @@ public class ResourceSelectionControl extends Composite { fd = new FormData(); // fd.left = new FormAttachment( addResourceBtn, 30, SWT.RIGHT ); //fd.left = new FormAttachment( 55, 0 ); - fd.right = new FormAttachment( can_btn, -10, SWT.LEFT ); + //fd.right = new FormAttachment( can_btn, -10, SWT.LEFT ); fd.width = 130; fd.top = new FormAttachment( seldRscNameTxt, 0, SWT.TOP ); - //fd.right = new FormAttachment( 100, -20 ); + fd.right = new FormAttachment( 100, -20 ); // fd.bottom = new FormAttachment( 100, -10 ); cycleTimeCombo.setLayoutData(fd); @@ -832,12 +834,6 @@ public class ResourceSelectionControl extends Composite { selectResource( false, true ); } }); - - can_btn.addSelectionListener(new SelectionAdapter() { - public void widgetSelected( SelectionEvent ev ) { - selShell.dispose(); - } - }); // TODO : do we want replace to pop down the dialog? /* diff --git a/ncep/gov.noaa.nws.ncep.viz.resourceManager/src/gov/noaa/nws/ncep/viz/resourceManager/ui/manageResources/EditResourceTypeComp.java b/ncep/gov.noaa.nws.ncep.viz.resourceManager/src/gov/noaa/nws/ncep/viz/resourceManager/ui/manageResources/EditResourceTypeComp.java index ba43a65165..32b559aa27 100644 --- a/ncep/gov.noaa.nws.ncep.viz.resourceManager/src/gov/noaa/nws/ncep/viz/resourceManager/ui/manageResources/EditResourceTypeComp.java +++ b/ncep/gov.noaa.nws.ncep.viz.resourceManager/src/gov/noaa/nws/ncep/viz/resourceManager/ui/manageResources/EditResourceTypeComp.java @@ -1,10 +1,6 @@ package gov.noaa.nws.ncep.viz.resourceManager.ui.manageResources; import gov.noaa.nws.ncep.viz.common.StringListAdapter; -<<<<<<< HEAD -import gov.noaa.nws.ncep.viz.localization.NcPathManager; -======= ->>>>>>> remotes/origin/ncep_14.4.1 import gov.noaa.nws.ncep.viz.localization.NcPathManager.NcPathConstants; import gov.noaa.nws.ncep.viz.resourceManager.ui.manageResources.ManageResourceControl.IEditResourceComposite; import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsRequestableResourceData.TimeMatchMethod; @@ -43,20 +39,10 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Spinner; import org.eclipse.swt.widgets.Text; -<<<<<<< HEAD -import com.raytheon.uf.common.localization.LocalizationContext; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; -import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.time.BinOffset; -import com.raytheon.uf.viz.core.exception.VizException; - - -======= import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.viz.core.exception.VizException; ->>>>>>> remotes/origin/ncep_14.4.1 /** * * @@ -79,1105 +65,6 @@ import com.raytheon.uf.viz.core.exception.VizException; * 04/11/13 #864 Greg Hull new TimelineGenMethods and EVENT TimeMatchMthd * 06/10/13 #997 Greg Hull Copy AttrSets with RDs * 07/18/13 #1011 Greg Hull Add ALL_DATA as a frameSpan option. -<<<<<<< HEAD - * - * - * - * @author - * @version 1 - */ -class EditResourceTypeComp extends Composite implements IEditResourceComposite { - ResourceDefnsMngr rscDefnMngr; - ManageResourceControl mngrControl; // the parent composite - - ResourceName seldRscName=null; - ResourceDefinition seldRscDefn; - - Text rscTypeTxt; - Spinner dfltNumFramesSpnr; - Spinner dfltTimeRangeDaysSpnr; - Spinner dfltTimeRangeHrsSpnr; -// Spinner timeIntervalSpnr; - Label frameIntLbl; // either 'Frame Span' or 'Default Frame Interval' - Combo frameSpanCombo; - Label minsLbl2, minsLbl3; - Group timelineGenMthdGrp; - Button useFrameIntrvlBtn; - Button useDataTimesBtn; - Button useFcstDataTimesBtn; - Button useManualTimelineBtn; - Button useFcstFrameIntrvlBtn; -// Combo timelineGenMethodCombo; - Combo timeMatchMethodCombo; - Button binDataBtn; - Spinner binStartIntrvlSpnr; - Spinner binEndIntrvlSpnr; - Label startLbl, endLbl; - Text editParamsTxt; - Label editParamsLbl; - - Text filterLabelsTxt; - Label filterLabelsLbl; - - Text subTypeGenTxt; - Label subTypeGenLbl; - - Text rscImplTxt; - - Button newTypeBtn; - Button saveTypeBtn; - Button cancelBtn; - - String availFrameSpanStrings[] = { //"N/A", - "1 min", "2 mins", "5 mins", "10 mins", "15 mins", "20 mins", "30 mins", - "1 hr", "90 mins", "2 hrs", "3 hrs", "6 hrs", "12 hrs", "24 hrs", "All Data" }; - - int availFrameSpanMins[] = { //0, - 1, 2, 5, 10, 15, 20, 30, 60, 90, 120, 180, 360, 720, 1440, Integer.MAX_VALUE }; - - public EditResourceTypeComp( Composite parent, int style, - ManageResourceControl mgrCtl) { - super( parent, style ); - Composite top_form = this; - - FormData fd = new FormData(); - fd.top = new FormAttachment( 0, 12 ); // offset from sash so the title shows up - fd.left = new FormAttachment( 0, 0 ); - fd.right = new FormAttachment( 100, 0 ); - fd.bottom = new FormAttachment( 100, 0 ); - top_form.setLayoutData(fd); - - setLayoutData( fd ); - - top_form.setLayout( new FormLayout() ); - - mngrControl = mgrCtl; - rscDefnMngr = mngrControl.getRscDefnMngr(); - - rscTypeTxt = new Text( top_form, SWT.SINGLE | SWT.BORDER ); - rscTypeTxt.setText( "" ); - - fd = new FormData(); - fd.width = 150; - fd.top = new FormAttachment( 0, 30 ); - fd.left = new FormAttachment( 0, 15 ); - rscTypeTxt.setLayoutData( fd ); - - Label rscTypeLbl = new Label( top_form, SWT.NONE ); - rscTypeLbl.setText("Resource Type"); - fd = new FormData(); - fd.bottom = new FormAttachment( rscTypeTxt, -3, SWT.TOP ); - fd.left = new FormAttachment( rscTypeTxt, 0, SWT.LEFT ); - rscTypeLbl.setLayoutData( fd ); - - dfltNumFramesSpnr = new Spinner( top_form, SWT.BORDER ); - fd = new FormData(); - fd.top = new FormAttachment( rscTypeTxt, 0, SWT.TOP ); - fd.left = new FormAttachment( rscTypeTxt, 35, SWT.RIGHT ); - dfltNumFramesSpnr.setLayoutData( fd ); - - Label dfltNumFramesLbl = new Label( top_form, SWT.NONE ); - dfltNumFramesLbl.setText("Num Frames");//Default Num\nFrames"); - fd = new FormData(); - fd.bottom = new FormAttachment( dfltNumFramesSpnr, -3, SWT.TOP ); - fd.left = new FormAttachment( dfltNumFramesSpnr, 0, SWT.LEFT ); //rscTypeTxt, 20, SWT.RIGHT ); - dfltNumFramesLbl.setLayoutData( fd ); - - dfltNumFramesSpnr.setMinimum(1); - dfltNumFramesSpnr.setMaximum(999); - dfltNumFramesSpnr.setDigits(0); - dfltNumFramesSpnr.setIncrement(1); - dfltNumFramesSpnr.setTextLimit(4); - - editParamsTxt = new Text( top_form, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL ); - fd = new FormData(); - fd.height = 120; - fd.left = new FormAttachment( 45, 0); - fd.top = new FormAttachment( dfltNumFramesSpnr, 0, SWT.TOP ); - fd.right = new FormAttachment( 100, -10 ); -// fd.bottom = new FormAttachment( 65, 0 ); - editParamsTxt.setLayoutData( fd ); - - editParamsLbl = new Label( top_form, SWT.NONE ); - editParamsLbl.setText("Edit Parameters"); // add the implementaion later - fd = new FormData(); - fd.bottom = new FormAttachment( editParamsTxt, -3, SWT.TOP ); - fd.left = new FormAttachment( editParamsTxt, 0, SWT.LEFT ); - fd.right = new FormAttachment( editParamsTxt, 0, SWT.RIGHT ); - editParamsLbl.setLayoutData( fd ); - - - filterLabelsTxt = new Text( top_form, SWT.SINGLE | SWT.BORDER ); //| SWT.V_SCROLL | SWT.H_SCROLL ); - fd = new FormData(); - fd.height = 20; - fd.left = new FormAttachment( editParamsTxt, 0, SWT.LEFT ); - fd.right = new FormAttachment( editParamsTxt, 0, SWT.RIGHT ); - fd.top = new FormAttachment( editParamsTxt, 40, SWT.BOTTOM ); - filterLabelsTxt.setLayoutData( fd ); - filterLabelsTxt.setToolTipText( "comma-separated labels." ); - - - filterLabelsLbl = new Label( top_form, SWT.NONE ); - filterLabelsLbl.setText("Filterable Labels"); - fd = new FormData(); - fd.bottom = new FormAttachment( filterLabelsTxt, -3, SWT.TOP ); - fd.left = new FormAttachment( filterLabelsTxt, 0, SWT.LEFT ); - // the text will be changed for the localization level so make it wider - fd.right = new FormAttachment( filterLabelsTxt, 0, SWT.RIGHT ); - filterLabelsLbl.setLayoutData( fd ); - - rscImplTxt = new Text( top_form, SWT.SINGLE | SWT.BORDER ); - fd = new FormData(); - fd.width = 150; - fd.left = new FormAttachment( filterLabelsTxt, 0, SWT.LEFT ); - fd.top = new FormAttachment( filterLabelsTxt, 40, SWT.BOTTOM ); - rscImplTxt.setLayoutData( fd ); - rscImplTxt.setToolTipText( rscImplToolTipText ); - rscImplTxt.setBackground( top_form.getBackground() ); - rscImplTxt.setEditable(false); - - Label rscImplLbl = new Label( top_form, SWT.NONE ); - rscImplLbl.setText("Resource Implementation"); - fd = new FormData(); - fd.bottom = new FormAttachment( rscImplTxt, -3, SWT.TOP ); - fd.left = new FormAttachment( rscImplTxt, 0, SWT.LEFT ); - rscImplLbl.setLayoutData( fd ); - - - subTypeGenTxt = new Text( top_form, SWT.SINGLE | SWT.BORDER ); - fd = new FormData(); - fd.width = 140; - fd.left = new FormAttachment( rscImplTxt, 15, SWT.RIGHT ); - fd.top = new FormAttachment( rscImplTxt, 0, SWT.TOP ); - subTypeGenTxt.setLayoutData( fd ); - subTypeGenTxt.setToolTipText( subTypeGenToolTipText ); - subTypeGenTxt.setVisible( false ); - subTypeGenTxt.setBackground( top_form.getBackground() ); - subTypeGenTxt.setEditable(false); - - subTypeGenLbl = new Label( top_form, SWT.NONE ); - subTypeGenLbl.setText("Sub-Type Generator(s)"); - fd = new FormData(); - fd.bottom = new FormAttachment( subTypeGenTxt, -3, SWT.TOP ); - fd.left = new FormAttachment( subTypeGenTxt, 0, SWT.LEFT ); - subTypeGenLbl.setLayoutData( fd ); - - - frameSpanCombo = new Combo( top_form, SWT.DROP_DOWN | SWT.READ_ONLY ); - fd = new FormData(); - fd.top = new FormAttachment( rscTypeTxt, 40, SWT.BOTTOM ); - fd.left = new FormAttachment( rscTypeTxt, 0, SWT.LEFT ); - frameSpanCombo.setLayoutData( fd ); - //frameIntervalCombo.setToolTipText( frameIntervalToolTipText ); - frameSpanCombo.setItems( availFrameSpanStrings ); - - frameIntLbl = new Label( top_form, SWT.NONE ); - frameIntLbl.setText("Frame Span"); - fd = new FormData(); - fd.bottom = new FormAttachment( frameSpanCombo, -3, SWT.TOP ); - fd.left = new FormAttachment( frameSpanCombo, 0, SWT.LEFT ); - frameIntLbl.setLayoutData( fd ); - - - dfltTimeRangeDaysSpnr = new Spinner( top_form, SWT.BORDER ); - fd = new FormData(); - fd.top = new FormAttachment( frameSpanCombo, 0, SWT.TOP ); - fd.left = new FormAttachment( frameSpanCombo, 70, SWT.RIGHT ); - dfltTimeRangeDaysSpnr.setLayoutData( fd ); - - Label dfltTimeRangeLbl = new Label( top_form, SWT.NONE ); - dfltTimeRangeLbl.setText("Range (Days/Hrs)"); - fd = new FormData(); - fd.bottom = new FormAttachment( dfltTimeRangeDaysSpnr, -3, SWT.TOP ); - fd.left = new FormAttachment( dfltTimeRangeDaysSpnr, 0, SWT.LEFT ); - dfltTimeRangeLbl.setLayoutData( fd ); - - dfltTimeRangeDaysSpnr.setMinimum(0); - dfltTimeRangeDaysSpnr.setMaximum(999); - dfltTimeRangeDaysSpnr.setDigits(0); - dfltTimeRangeDaysSpnr.setIncrement(1); - dfltTimeRangeDaysSpnr.setTextLimit(4); - dfltTimeRangeDaysSpnr.setPageIncrement(30); - -// Label timeRangeDaysLbl = new Label( top_form, SWT.NONE ); -// timeRangeDaysLbl.setText("Days"); -// fd = new FormData(); -// fd.top = new FormAttachment( dfltTimeRangeDaysSpnr, 3, SWT.TOP ); -// fd.left = new FormAttachment( dfltTimeRangeDaysSpnr, 3, SWT.RIGHT ); -// timeRangeDaysLbl.setLayoutData( fd ); - - dfltTimeRangeHrsSpnr = new Spinner( top_form, SWT.BORDER ); - fd = new FormData(); - fd.top = new FormAttachment( dfltTimeRangeDaysSpnr, 0, SWT.TOP ); - fd.left = new FormAttachment( dfltTimeRangeDaysSpnr, 8, SWT.RIGHT ); - dfltTimeRangeHrsSpnr.setLayoutData( fd ); - - dfltTimeRangeHrsSpnr.setMinimum(0); - dfltTimeRangeHrsSpnr.setMaximum(23); - dfltTimeRangeHrsSpnr.setDigits(0); - dfltTimeRangeHrsSpnr.setIncrement(1); - dfltTimeRangeHrsSpnr.setTextLimit(2); - - // a group composite to force the radio behaviour - timelineGenMthdGrp = new Group( top_form, SWT.SHADOW_NONE ); - timelineGenMthdGrp.setText("Generate Timeline from:"); - fd = new FormData(); - fd.top = new FormAttachment( frameSpanCombo, 20, SWT.BOTTOM ); - fd.left = new FormAttachment( frameSpanCombo, 0, SWT.LEFT ); - timelineGenMthdGrp.setLayoutData( fd ); - - GridLayout gl = new GridLayout(2, false); - gl.horizontalSpacing = 10; - gl.marginWidth = 15; - gl.marginHeight = 10; - timelineGenMthdGrp.setLayout( gl); - - useFcstDataTimesBtn = new Button(timelineGenMthdGrp, SWT.RADIO ); - useFcstDataTimesBtn.setText( "Forecast Hrs From Cycle Time" ); - fd = new FormData(); - GridData gd = new GridData(); - gd.horizontalSpan = 2; - useFcstDataTimesBtn.setLayoutData( gd ); - - useDataTimesBtn = new Button(timelineGenMthdGrp, SWT.RADIO ); - useDataTimesBtn.setText( "Data Times" ); - fd = new FormData(); - useDataTimesBtn.setLayoutData( new GridData() ); - - useFrameIntrvlBtn = new Button(timelineGenMthdGrp, SWT.RADIO ); - useFrameIntrvlBtn.setText( "Frame Interval" );//Time Interval of" ); - useFrameIntrvlBtn.setLayoutData( new GridData() ); - - useManualTimelineBtn = new Button(timelineGenMthdGrp, SWT.RADIO ); - useManualTimelineBtn.setText( "Manual Timeline" ); - fd = new FormData(); - useManualTimelineBtn.setLayoutData( new GridData() ); - - useFcstFrameIntrvlBtn = new Button(timelineGenMthdGrp, SWT.RADIO ); - useFcstFrameIntrvlBtn.setText( "Fcst Frame Interval From Ref. Time" ); - fd = new FormData(); - gd = new GridData(); - gd.horizontalSpan = 2; - useFcstFrameIntrvlBtn.setLayoutData( gd ); - - timeMatchMethodCombo = new Combo( top_form, SWT.DROP_DOWN | SWT.READ_ONLY ); - fd = new FormData(); - fd.top = new FormAttachment( timelineGenMthdGrp, 40, SWT.BOTTOM ); - fd.left = new FormAttachment( timelineGenMthdGrp, 0, SWT.LEFT ); - timeMatchMethodCombo.setLayoutData( fd ); - - Label timeMatchMthdLbl = new Label( top_form, SWT.NONE ); - timeMatchMthdLbl.setText("Time Matching Method"); - fd = new FormData(); - fd.bottom = new FormAttachment( timeMatchMethodCombo, -2, SWT.TOP ); - fd.left = new FormAttachment( timeMatchMethodCombo, 0, SWT.LEFT ); - timeMatchMthdLbl.setLayoutData( fd ); - - - binDataBtn = new Button(top_form, SWT.CHECK ); - binDataBtn.setText( "Enable Binning" ); - fd = new FormData(); - fd.top = new FormAttachment( subTypeGenTxt, 25, SWT.BOTTOM ); - fd.left = new FormAttachment( subTypeGenTxt, 0, SWT.LEFT ); - binDataBtn.setLayoutData( fd ); - binDataBtn.setEnabled( false ); // not implemented yet - - // TODO: Remove the bin offset widgets if the frame Span is sufficient to replace it - binDataBtn.setVisible( false ); - - binStartIntrvlSpnr = new Spinner( top_form, SWT.BORDER ); - fd = new FormData(); - fd.top = new FormAttachment( binDataBtn, 30, SWT.BOTTOM ); - fd.left = new FormAttachment( binDataBtn, 20, SWT.LEFT ); - binStartIntrvlSpnr.setLayoutData( fd ); - - binStartIntrvlSpnr.setMinimum(0); - binStartIntrvlSpnr.setMaximum(60*3); // 3hrs : Is this reasonable? - binStartIntrvlSpnr.setDigits(0); - binStartIntrvlSpnr.setIncrement(1); - binStartIntrvlSpnr.setTextLimit(2); - - startLbl = new Label( top_form, SWT.NONE ); - startLbl.setText("Before"); - fd = new FormData(); - fd.bottom = new FormAttachment( binStartIntrvlSpnr, -2, SWT.TOP ); - fd.left = new FormAttachment( binStartIntrvlSpnr, 0, SWT.LEFT ); - startLbl.setLayoutData( fd ); - - minsLbl2 = new Label( top_form, SWT.NONE ); - minsLbl2.setText("mins"); - fd = new FormData(); - fd.top = new FormAttachment( binStartIntrvlSpnr, 3, SWT.TOP ); - fd.left = new FormAttachment( binStartIntrvlSpnr, 5, SWT.RIGHT ); - minsLbl2.setLayoutData( fd ); - - binEndIntrvlSpnr = new Spinner( top_form, SWT.BORDER ); - fd = new FormData(); - fd.top = new FormAttachment( binStartIntrvlSpnr, 0, SWT.TOP ); - fd.left = new FormAttachment( binStartIntrvlSpnr, 50, SWT.RIGHT ); - binEndIntrvlSpnr.setLayoutData( fd ); - - binEndIntrvlSpnr.setMinimum(0); - binEndIntrvlSpnr.setMaximum(60*3); // 3hrs : Is this reasonable? - binEndIntrvlSpnr.setDigits(0); - binEndIntrvlSpnr.setIncrement(1); - binEndIntrvlSpnr.setTextLimit(2); - - endLbl = new Label( top_form, SWT.NONE ); - endLbl.setText("After"); - fd = new FormData(); - fd.bottom = new FormAttachment( binEndIntrvlSpnr, -2, SWT.TOP ); - fd.left = new FormAttachment( binEndIntrvlSpnr, 0, SWT.LEFT ); - endLbl.setLayoutData( fd ); - - minsLbl3 = new Label( top_form, SWT.NONE ); - minsLbl3.setText("mins"); - fd = new FormData(); - fd.top = new FormAttachment( binEndIntrvlSpnr, 3, SWT.TOP ); - fd.left = new FormAttachment( binEndIntrvlSpnr, 5, SWT.RIGHT ); - minsLbl3.setLayoutData( fd ); - - // Only one of these will be visible at a time - saveTypeBtn = new Button( top_form, SWT.PUSH ); - saveTypeBtn.setText("Save"); - fd = new FormData(); - fd.width = 100; - fd.bottom = new FormAttachment( 100, -10 ); - fd.right = new FormAttachment( 100, -30 ); - saveTypeBtn.setLayoutData( fd ); - - newTypeBtn = new Button( top_form, SWT.PUSH ); - newTypeBtn.setText("Create"); - fd = new FormData(); - fd.width = 100; - fd.bottom = new FormAttachment( 100, -10 ); - fd.right = new FormAttachment( 100, -30 ); - newTypeBtn.setLayoutData( fd ); - - cancelBtn = new Button( top_form, SWT.PUSH ); - cancelBtn.setText( "Cancel"); - fd = new FormData(); - fd.width = 100; - fd.bottom = new FormAttachment( 100, -10 ); - fd.right = new FormAttachment( saveTypeBtn, -20, SWT.LEFT ); - cancelBtn.setLayoutData( fd ); - - - // initialize the combo boxes with selectable items. - // - for( TimeMatchMethod tmm : TimeMatchMethod.values() ) { - timeMatchMethodCombo.add( tmm.toString() ); - } - - ArrayList availRscImplementations = - ResourceExtPointMngr.getInstance().getAvailResources(); - - - rscTypeTxt.addModifyListener(new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - - String newTextStr = rscTypeTxt.getText().trim(); - - int indx = newTextStr.indexOf( "${" ); - - if( indx != -1 ) { - newTextStr = newTextStr.substring(0,indx-1); - } - - if( newTextStr.isEmpty() ) { - saveTypeBtn.setEnabled( false ); - newTypeBtn.setEnabled( false ); - } - else { - saveTypeBtn.setEnabled( true ); - - // if the name has been changed, the 'save' button acts as a 'Rename' or Save As - // - // disable the New button if the name hasn't been changed. - // - if( seldRscDefn.getResourceDefnName().equals( newTextStr ) ) { - saveTypeBtn.setText("Save" ); - - newTypeBtn.setEnabled( false ); - } - else { - saveTypeBtn.setText("Save As" ); - newTypeBtn.setEnabled( true ); - - // disable the Save button if the new name already exists - String rscType = newTextStr; - - //ResourceDefinition.getResourceType( rscTypeTxt.getText().trim() ); - - if( rscDefnMngr.findResourceDefinition( rscType ) ) { - saveTypeBtn.setEnabled( false ); - } - } - } - } - }); - - useFrameIntrvlBtn.addSelectionListener( new SelectionAdapter() { - public void widgetSelected( SelectionEvent ev ) { -// frameIntervalCombo.setEnabled( useTimeIntrvlBtn.getSelection() ); -// timeIntervalCombo.setVisible( useTimeIntrvlBtn.getSelection() ); -// minsLbl1.setVisible( useTimeIntrvlBtn.getSelection() ); - } - }); - - binDataBtn.addSelectionListener( new SelectionAdapter() { - public void widgetSelected( SelectionEvent ev ) { - binStartIntrvlSpnr.setVisible( binDataBtn.getSelection() ); - binEndIntrvlSpnr.setVisible( binDataBtn.getSelection() ); - startLbl.setVisible( binDataBtn.getSelection() ); - endLbl.setVisible( binDataBtn.getSelection() ); - minsLbl2.setVisible( binDataBtn.getSelection() ); - minsLbl3.setVisible( binDataBtn.getSelection() ); } - }); - - editParamsTxt.addModifyListener(new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - } - }); - -// subTypeGenTxt.addVerifyListener( new VerifyListener() { -// @Override -// public void verifyText(VerifyEvent event) { -// String text = ((Text) event.widget).getText(); -// String newText = event.text; -// -// if( !text.startsWith("${") || -// !text.endsWith("}" ) ) { -// event.doit = false; -// return; -// } -// } -// }); - - saveTypeBtn.addSelectionListener( new SelectionAdapter() { - public void widgetSelected( SelectionEvent ev ) { - saveResourceDefinition(); - } - }); - - newTypeBtn.addSelectionListener( new SelectionAdapter() { - public void widgetSelected( SelectionEvent ev ) { - createResourceDefinition(); - } - }); - - cancelBtn.addSelectionListener( new SelectionAdapter() { - public void widgetSelected( SelectionEvent ev ) { - mngrControl.editActionCanceled(); - } - }); - } - - @Override - public ResourceName getSelectedResourceName( ) { - return seldRscName; - } - - // TODO : not implemented - @Override - public boolean isModified( ) { - return false; - } - - @Override - public void activate() { - setVisible( true ); - if( getParent() instanceof Group ) { - ((Group)getParent()).setText( getTitle() ); - } - } - - public void copySelectedResource( ResourceName rscName ) { - setSelectedResource( rscName ); - newTypeBtn.setVisible( true ); - saveTypeBtn.setVisible( false ); - rscTypeTxt.setEditable( true ); - rscTypeTxt.setBackground( editParamsTxt.getBackground() ); // set white to indicate editable - - rscTypeTxt.setText( "CopyOf"+rscTypeTxt.getText() ); - rscTypeTxt.setSelection(0, rscTypeTxt.getText().length() ); - rscTypeTxt.setFocus(); - } - - public void editSelectedResource( ResourceName rscName ) { - setSelectedResource( rscName ); - newTypeBtn.setVisible( false ); - saveTypeBtn.setVisible( true ); - - rscTypeTxt.setEditable( false ); - rscTypeTxt.setBackground( getParent().getBackground() ); - } - - public void setSelectedResource( ResourceName rscName ) { - - seldRscName = rscName; - - if( seldRscName.getRscType().isEmpty() ) { - rscTypeTxt.setText(""); - saveTypeBtn.setEnabled( false ); - } - else { - saveTypeBtn.setEnabled( false ); - - seldRscDefn = new ResourceDefinition( rscDefnMngr.getResourceDefinition( seldRscName ) ); - - if( seldRscDefn == null ) { // ???? - System.out.println("Unable to get Resource Defn for:"+seldRscName ); - return; - } - - String rscTypeGen = seldRscDefn.getRscTypeGenerator(); - - if( rscTypeGen != null && !rscTypeGen.isEmpty() ) { - rscTypeTxt.setText( seldRscName.getRscType() + - ":${"+ rscTypeGen + "}"); - } - else { - rscTypeTxt.setText( seldRscName.getRscType() ); - } - - // set the frame count - int numFrames = seldRscDefn.getDfltFrameCount(); - dfltNumFramesSpnr.setSelection( numFrames ); - - // if we let any resource select Manual timeline then we need another way to - // specify 'Event-type' resources .... - TimelineGenMethod timelineMthd = seldRscDefn.getTimelineGenMethod(); - - useDataTimesBtn.setEnabled( true ); - useFrameIntrvlBtn.setEnabled( true ); - useFcstDataTimesBtn.setEnabled( true ); - useManualTimelineBtn.setEnabled( true ); - useFcstFrameIntrvlBtn.setEnabled( false ); - - useDataTimesBtn.setSelection( false ); - useFcstDataTimesBtn.setSelection( false ); - useFrameIntrvlBtn.setSelection( false ); - useManualTimelineBtn.setSelection( false ); - useFcstFrameIntrvlBtn.setSelection( false ); - - if( timelineMthd == TimelineGenMethod.USE_DATA_TIMES ) { - useDataTimesBtn.setSelection( true ); - } - else if( timelineMthd == TimelineGenMethod.USE_CYCLE_TIME_FCST_HOURS ) { - useFcstDataTimesBtn.setSelection( true ); - } - else if( timelineMthd == TimelineGenMethod.USE_FRAME_INTERVAL ) { - useFrameIntrvlBtn.setSelection( true ); - } - else if( timelineMthd == TimelineGenMethod.USE_MANUAL_TIMELINE ) { - useManualTimelineBtn.setSelection( true ); - } - // just for TAF for now. So don't let the user change it and just show - else if( timelineMthd == TimelineGenMethod.USE_FCST_FRAME_INTERVAL_FROM_REF_TIME ) { - useFcstFrameIntrvlBtn.setEnabled( true ); - useFcstFrameIntrvlBtn.setSelection( true ); - - useFrameIntrvlBtn.setEnabled( false ); - useDataTimesBtn.setEnabled( false ); - useFcstDataTimesBtn.setEnabled( false ); - useManualTimelineBtn.setEnabled( false ); - } - - // if this is an event type resource; modify the - // timeMatchMthd, frameInterval and timelineGeneration selections - timeMatchMethodCombo.removeAll(); - frameSpanCombo.removeAll(); - - if( seldRscDefn.getTimeMatchMethod() == TimeMatchMethod.EVENT ) { - - useDataTimesBtn.setSelection( false ); // sanity check since - useFrameIntrvlBtn.setSelection( false ); // all event resources should - useManualTimelineBtn.setSelection( true ); // be set to MANUAL anyway - - useDataTimesBtn.setEnabled( false ); - useFcstDataTimesBtn.setEnabled( false ); - useFrameIntrvlBtn.setEnabled( false ); - - // For event resources, only EXACT is meaningful - timeMatchMethodCombo.add( TimeMatchMethod.EVENT.toString() ); - timeMatchMethodCombo.select(0); - - // for Event resources the frameSpan is the default Frame Interval - frameIntLbl.setText("Dflt Frame Interval"); -// frameSpanCombo.add( "N/A" ); -// frameSpanCombo.select(0); - frameSpanCombo.setItems( availFrameSpanStrings ); - frameSpanCombo.setToolTipText("For this Event-Type resource the Default Frame Interval is \n"+ - "used to set the initial Frame Interval for a Manual timeline." ); - - int frameSpan = seldRscDefn.getFrameSpan(); - frameSpanCombo.deselectAll(); - - for( int i=0; i filtersList=null; - try { - filtersList = strListAdptr.unmarshal( filterLabelsTxt.getText().trim() ); - } - catch (Exception e1) { - MessageDialog warnDlg = new MessageDialog( getShell(), - "Resource", null, - "Unable to parse the filters string.\n"+ - "This should be a list of comma separated strings.", - MessageDialog.WARNING, new String[]{"OK"}, 0); - warnDlg.open(); - } - - ResourceDefinitionFilter rdFilt = - rscDefnMngr.getResourceDefnFilter( seldRscDefn.getResourceDefnName() ); - - rdFilt = new ResourceDefinitionFilter( - newRscDefn.getResourceDefnName(), rdFilt.getIsEnabled(), filtersList, - LocalizationLevel.USER ); - - rscDefnMngr.setResourceDefnFilters( rdFilt ); - - try { - rscDefnMngr.saveResourceDefnFiltersFile(); - } - catch (VizException e1) { - MessageDialog errDlg = new MessageDialog( getShell(), - "Resource", null, "Error saving a new Resource Filters File:\n"+ - e1.getMessage(), MessageDialog.ERROR, new String[]{"OK"}, 0); - errDlg.open(); - } - - // if attrSetGroups apply then we will just create 1 standard attrSetGroup with nothing in - // it. The user will need to edit this later. - // TODO : allow the user to copy all (or some?) of the attributeSetGroups from the - // original rscDefn. - - String newLocFilename = seldRscDefn.getLocalizationFile().getName(); - - // peal off the filename and last directory of the same name - // and replace with a path and filename based on the new name - newLocFilename = newLocFilename.substring( 0, - newLocFilename.lastIndexOf(File.separator) ); - newLocFilename = newLocFilename.substring( 0, - newLocFilename.lastIndexOf(File.separator)+1 ) + - rscTypeName + File.separator + rscTypeName + ".xml"; - - newRscDefn.setLocalizationFile( null ); - newRscDefn.setLocalizationName( newLocFilename ); - - //seldRscDefn.setResourceDefnName( rscTypeName ); -// String origRscType = seldRscDefn.getResourceDefnName(); - - try { - rscDefnMngr.saveResourceDefn( newRscDefn ); - -// create a new attrSetGroup - if( newRscDefn.applyAttrSetGroups() ) { - if( !newRscDefn.isPgenResource() ) { - AttrSetGroup asg = new AttrSetGroup(); - asg.setResource( newRscDefn.getResourceDefnName() ); - asg.setAttrSetGroupName("standard"); - - rscDefnMngr.saveAttrSetGroup( asg ); - } - } - // Copy all of the attr sets - else { - List availAttrSets = rscDefnMngr.getAttrSetsForResource(seldRscName, false ); - - for( AttributeSet attrSet : availAttrSets ) { - try { - FileReader fr = new FileReader( attrSet.getFile().getFile() ); - char[] attrsSetStr = new char[(int) attrSet.getFile().getFile().length()]; - fr.read(attrsSetStr); - fr.close(); - - rscDefnMngr.saveAttrSet(newRscDefn, attrSet.getName(), new String( attrsSetStr ) ); - - } - catch (FileNotFoundException fnf ) { - throw new VizException( "file not found for default attr set."); - } - catch (IOException ioe ) { - throw new VizException( "i/o error copying default attr set file."); - } - } - } - seldRscDefn = newRscDefn; - - ResourceName newSeldRscName = new ResourceName(); - newSeldRscName.setRscCategory( seldRscDefn.getResourceCategory() ); - newSeldRscName.setRscType( seldRscDefn.getResourceDefnName() ); - - mngrControl.updateResourceSelections( newSeldRscName ); - - } catch (VizException e) { - MessageDialog errDlg = new MessageDialog(getShell(), - "New Resource Type", null, - "Error Creating new Type " +rscTypeName + "\n\n"+ - e.getMessage(), - MessageDialog.ERROR, new String[]{"OK"}, 0); - errDlg.open(); - return; - } - } - - // The name of the resource type hasn't changed - // - protected void saveResourceDefinition( ) { - - ResourceDefinition saveRD = new ResourceDefinition( seldRscDefn ); - - setSelectedRscDefnFromGUI( seldRscDefn ); - - Boolean filtersChanged = false; - - String newFiltsStr = filterLabelsTxt.getText().trim(); - StringListAdapter listAdpr = new StringListAdapter(); - - try { - String curFiltsStr = listAdpr.marshal( - rscDefnMngr.getResourceDefnFilter( seldRscDefn.getResourceDefnName() ).getFilters() ).trim(); - - if( !curFiltsStr.equals( newFiltsStr ) ) { - filtersChanged = true; - -// save the new filters to the map and the File - ResourceDefinitionFilter rdFilt = - rscDefnMngr.getResourceDefnFilter( seldRscDefn.getResourceDefnName() ); - rdFilt.setFilters( listAdpr.unmarshal( newFiltsStr ) ); - rscDefnMngr.setResourceDefnFilters( rdFilt ); - - rscDefnMngr.saveResourceDefnFiltersFile(); - } - } catch (Exception e) { - MessageDialog errDlg = new MessageDialog( getShell(), - "Save Resource Filters", null, - "Error Saving Filters for Rsc Defn:\n\n"+ - e.getMessage(), MessageDialog.ERROR, new String[]{"OK"}, 0); - errDlg.open(); - } - - // check to see if the user has made any changes to the RD and if - // not we don't need to save it. - if( saveRD.equals( seldRscDefn ) ) { - if( filtersChanged ) { - MessageDialog msgDlg = new MessageDialog( getShell(), - "Saved", null, - "The Filters for " + seldRscDefn.getResourceDefnName() + " have been saved to :.\n"+ - NcPathConstants.RESOURCE_FILTERS + ". No changes were made to the Rsc Defn File.", - MessageDialog.INFORMATION, new String[]{"OK"}, 0); - msgDlg.open(); - return; - } - } - - String rscTypeName = rscTypeTxt.getText().trim(); - String rscTypeGen = ""; - - int indx = rscTypeName.indexOf(":${"); - - // if there is a type generator then parse the rscType name and the name of the appending generator parameter - if( indx != -1 ) { - rscTypeGen = rscTypeName.substring(indx+2); - rscTypeName = rscTypeName.substring(0,indx); - indx = rscTypeGen.indexOf("}"); - if( indx != -1 ) { - rscTypeGen = rscTypeGen.substring(0,indx); - } - } - - LocalizationFile lFile = seldRscDefn.getLocalizationFile(); - - if( lFile.getContext().getLocalizationLevel() == LocalizationLevel.USER ) { - MessageDialog confirmDlg = new MessageDialog( getShell(), - "Confirm", null, - "This will overwrite the current User-Level Resource Type\n"+ - "Are you sure you want to do this?", - MessageDialog.CONFIRM, new String[]{"Yes", "No"}, 0); - confirmDlg.open(); - - if( confirmDlg.getReturnCode() == MessageDialog.CANCEL ) { - return; - } - } -// else { // create a new user-level lFile -// LocalizationContext newContext = NcPathManager.getInstance().getContext( -// lFile.getContext().getLocalizationType(), -// LocalizationLevel.USER ); -// lFile = NcPathManager.getInstance().getLocalizationFile( newContext, -// lFile.getName() ); -// seldRscDefn.setLocalizationFile(lFile); -// } - - try { - rscDefnMngr.saveResourceDefn( seldRscDefn ); - - if( filtersChanged ) { - MessageDialog msgDlg = new MessageDialog( getShell(), - "Saved", null, - "The Resource " + rscTypeName + " has been saved to a USER-level file.\n"+ - "and the Filters in the "+NcPathConstants.RESOURCE_FILTERS+" file have been updated.", - MessageDialog.INFORMATION, new String[]{"OK"}, 0); - msgDlg.open(); - } - else { - MessageDialog msgDlg = new MessageDialog( getShell(), - "Saved", null, - "The Resource " + rscTypeName + " has been saved.\n", - MessageDialog.INFORMATION, new String[]{"OK"}, 0); - msgDlg.open(); - } - - } catch (VizException e) { - MessageDialog confirmDlg = new MessageDialog( getShell(), - "Save Resource Type", null, - "Error Writing new Resource Definitions Table\n\n"+ - e.getMessage(), - MessageDialog.ERROR, new String[]{"OK"}, 0); - confirmDlg.open(); - } - - mngrControl.updateResourceSelections( null ); - - return; - } - - // update the seldRscDefn with the GUI selections - // - private void setSelectedRscDefnFromGUI( ResourceDefinition rscDefn ) { - - rscDefn.setDfltFrameCount( dfltNumFramesSpnr.getSelection() ); - - for( TimeMatchMethod tmm : TimeMatchMethod.values() ) { - if( timeMatchMethodCombo.getText().equals( tmm.toString() ) ) { - rscDefn.setTimeMatchMethod( tmm ); - break; - } - } - - if( frameSpanCombo.getText().equals("N/A") ) { - rscDefn.setFrameSpan( 0 ); - } - else { - for( int i=0; i * @@ -2343,5 +1230,4 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite { private String rscImplToolTipText = "This is the name of the NCP Resource implemenation for this " + "resource type. The implementation specifies the java class that displays the data and defines " + "what parameters are expected by the java code"; ->>>>>>> remotes/origin/ncep_14.4.1 } \ No newline at end of file