Merge tag 'OB_16.2.1-lx-29' into omaha_16.2.2

16.2.1-lx-29

 Conflicts:
	cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/SimpleLogViewer.java
	cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/Tool.java
	cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/CombinationsFileUtil.java
	cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/HydroBaseDlg.java
	cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcFreezeOptionsDialog.java
	cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcPrecipOptionsDialog.java
	cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/QcTempOptionsDialog.java
	cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DeletePolygonDlg.java
	cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DrawPolygonDlg.java
	cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java
	edexOsgi/com.raytheon.edex.plugin.binlightning/src/com/raytheon/edex/plugin/binlightning/total/TotalLightningDecoder.java
	edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/SaveCombinationsFileHandler.java
	edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/watch/TPCWatchSrv.java
	edexOsgi/com.raytheon.uf.common.dataplugin.warning/utility/common_static/base/warngen/impactSevereWeatherStatement.vm


Former-commit-id: 17c68986a20e9a589d40407800dd52678fcda68b
This commit is contained in:
Steve Harris 2016-05-12 09:28:49 -05:00
commit ec8b83dd67
68 changed files with 3041 additions and 2947 deletions

View file

@ -21,61 +21,84 @@ package com.raytheon.rcm.message;
import java.nio.ByteBuffer;
/**
* Represents the contents of an ORPG General Status Message.
*
* <pre>
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 2009 dfriedman Initial version
* 2016-04-22 DR 18909 dfriedman Read fields of expanded GSM.
* </pre>
*/
public class GSM extends Message {
public static final int OP_MODE_MAINTENANCE = 0;
public static final int OP_MODE_CLEAR_AIR = 1;
public static final int OP_MODE_STORM = 2;
public int opMode;
public int rdaOpStatus;
public int vcp;
public int[] cuts; // in tenths of degrees
public int rdaStatus;
public int rdaAlarms;
public int dataAvailability; // "DTE"
public int rpgOpStatus;
public int rpgAlarms;
public int rpgStatus;
public int rpgNarrowbandStatus;
public int rcc;
public int productAvailability;
public int superResCuts;
public int rdaVersion;
public int rdaChannel;
public int rpgVersion;
public static GSM decode(byte[] msg) {
return (GSM) MD.decode(msg);
}
public static final int OP_MODE_MAINTENANCE = 0;
public static final int OP_MODE_CLEAR_AIR = 1;
public static final int OP_MODE_STORM = 2;
protected void decodeBlock(int index, ByteBuffer buf) {
if (index != 1)
return;
opMode = buf.getShort();
rdaOpStatus = buf.getShort();
vcp = buf.getShort();
int nCuts = buf.getShort();
cuts = new int[nCuts];
for (int i = 0; i < 20; ++i) {
if (i < cuts.length)
cuts[i] = buf.getShort();
else
buf.getShort();
}
rdaStatus = buf.getShort();
rdaAlarms = buf.getShort();
dataAvailability = buf.getShort();
rpgOpStatus = buf.getShort();
rpgAlarms = buf.getShort();
rpgStatus = buf.getShort();
rpgNarrowbandStatus = buf.getShort();
rcc = buf.getShort();
productAvailability = buf.getShort();
superResCuts = buf.getShort();
buf.position(buf.position() + 4);
rdaVersion = buf.getShort();
rdaChannel = buf.getShort();
buf.position(buf.position() + 4);
rpgVersion = buf.getShort();
}
public int opMode;
public int rdaOpStatus;
public int vcp;
public int[] cuts; // in tenths of degrees
public int rdaStatus;
public int rdaAlarms;
public int dataAvailability; // "DTE"
public int rpgOpStatus;
public int rpgAlarms;
public int rpgStatus;
public int rpgNarrowbandStatus;
public int rcc;
public int productAvailability;
public int superResCuts;
public int rdaVersion;
public int rdaChannel;
public int rpgVersion;
public int vcpSupplemental;
public static GSM decode(byte[] msg) {
return (GSM) MD.decode(msg);
}
protected void decodeBlock(int index, ByteBuffer buf) {
if (index != 1)
return;
opMode = buf.getShort();
rdaOpStatus = buf.getShort();
vcp = buf.getShort();
int nCuts = buf.getShort();
cuts = new int[nCuts];
for (int i = 0; i < 20; ++i) {
short cut = buf.getShort();
if (i < cuts.length) {
cuts[i] = cut;
}
}
rdaStatus = buf.getShort();
rdaAlarms = buf.getShort();
dataAvailability = buf.getShort();
rpgOpStatus = buf.getShort();
rpgAlarms = buf.getShort();
rpgStatus = buf.getShort();
rpgNarrowbandStatus = buf.getShort();
rcc = buf.getShort();
productAvailability = buf.getShort();
superResCuts = buf.getShort();
buf.position(buf.position() + 4);
rdaVersion = buf.getShort();
rdaChannel = buf.getShort();
buf.position(buf.position() + 4);
rpgVersion = buf.getShort();
if (buf.remaining() < 12) {
return;
}
for (int i = 20; i < 25; ++i) {
short cut = buf.getShort();
if (i < cuts.length) {
cuts[i] = cut;
}
}
vcpSupplemental = buf.getShort();
}
}

View file

@ -22,10 +22,12 @@ package com.raytheon.rcm.otrmgr;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import com.raytheon.rcm.config.RadarConfig;
import com.raytheon.rcm.config.RadarType;
import com.raytheon.rcm.config.RcmUtil;
import com.raytheon.rcm.event.OtrEvent;
import com.raytheon.rcm.event.RadarEvent;
@ -39,6 +41,7 @@ import com.raytheon.rcm.message.MessageFormatException;
import com.raytheon.rcm.message.MessageInfo;
import com.raytheon.rcm.message.ProductRequest;
import com.raytheon.rcm.message.RequestResponse;
import com.raytheon.rcm.products.ElevationInfo;
import com.raytheon.rcm.request.Filter;
import com.raytheon.rcm.request.Request;
import com.raytheon.rcm.request.Sequence;
@ -55,9 +58,18 @@ import com.raytheon.rcm.server.RadarServer;
/**
* Manages One Time Requests for the RPGs.
* <p>
* Does not actually do much except provide a place to queue up requests while
* waiting to connect to the RPG. Does do some coalescing of duplicate
* requests.
* Implements a queue for pending requests to the RPGs. Performs some coalescing
* of duplicate requests.
*
* <pre>
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 2009 dfriedman Initial version
* 2016-04-22 DR 18909 dfriedman Accurately calculate the number of expected
* responses for multiple-elevation requests.
* </pre>
*/
public class OTRManager extends RadarEventAdapter {
@ -69,7 +81,7 @@ public class OTRManager extends RadarEventAdapter {
*/
protected boolean isReady;
protected List<Req> requests = new ArrayList<Req>();
protected List<Req> requests = new ArrayList<>();
protected GSM lastGSM;
@ -226,7 +238,7 @@ public class OTRManager extends RadarEventAdapter {
private void trySendingRequests() {
if (isReady()) {
ArrayList<Request> requestsToSend = new ArrayList<Request>();
ArrayList<Request> requestsToSend = new ArrayList<>();
long now = System.currentTimeMillis();
synchronized (this.requests) {
for (Req r : requests) {
@ -319,31 +331,55 @@ public class OTRManager extends RadarEventAdapter {
&& request.getElevationSelection() != Request.SPECIFIC_ELEVATION) {
if (lastGSM != null) {
if (request.getElevationSelection() == Request.ALL_ELEVATIONS) {
/*
* We do not get information about duplicate
* elevations. Could put in TDWR-specific knowledge.
* If vcp==80 && is-low-elevation...
*
* But probably needs something like.
* nExpectedUnknown = true and (if nExpectedUnknown
* then connMgr.idleDisconnectRadar(...)
*/
// if is tdwr and vcp80...
exactCountUnknown = true;
RadarType radarType = RcmUtil.getRadarType(getRadarConfig());
int[] completeElevationList;
nElevations = request.getElevationAngle() == 0 ? lastGSM.cuts.length
: 1;
if (radarType == RadarType.WSR
|| (radarType == RadarType.TDWR && lastGSM.rpgVersion >= 80)) {
/*
* When MESO-SAILS was added to WSR-88D, the
* expanded GSM was already available and it
* contained the complete list of elevations
* including extra SAILS elevations. Therefore,
* we can always rely on a WSR-88D's GSM for the
* list of elevation angles.
*
* Later version of the SPG contain the complete
* list of angles in an expected GSM.
*/
completeElevationList = lastGSM.cuts;
} else if (radarType == RadarType.TDWR && lastGSM.rpgVersion < 80) {
/*
* Earlier versions of the SPG do not list the
* extra low angle elevations scans. We can use
* the static elevation list instead.
*/
completeElevationList = ElevationInfo
.getInstance().getScanElevations(
radarID, lastGSM.vcp);
} else {
/*
* No choice but to guess based on the list of
* elevations from the GSM.
*/
completeElevationList = lastGSM.cuts;
exactCountUnknown = true;
}
int elevationAngle = request.getElevationAngle();
nElevations = elevationAngle == 0 ? uniqueCount(completeElevationList)
: matchCount(elevationAngle, completeElevationList);
} else if (request.getElevationSelection() == Request.N_ELEVATIONS) {
nElevations = Math.min(lastGSM.cuts.length,
nElevations = Math.min(uniqueCount(lastGSM.cuts),
request.getElevationAngle());
} else if (request.getElevationSelection() == Request.LOWER_ELEVATIONS) {
HashSet<Integer> seenAngles = new HashSet<>();
nElevations = 0;
int reqEA = request.getElevationAngle();
for (int ea : lastGSM.cuts) {
if (ea <= reqEA)
if (ea <= reqEA && !seenAngles.contains(ea)) {
++nElevations;
else
break;
seenAngles.add(ea);
}
}
} else
exactCountUnknown = true;
@ -356,9 +392,41 @@ public class OTRManager extends RadarEventAdapter {
nExpected = request.count * nElevations;
}
private int uniqueCount(int[] angles) {
HashSet<Integer> uniqueAngles = new HashSet<>();
for (int a : angles) {
uniqueAngles.add(a);
}
return uniqueAngles.size();
}
private int matchCount(int angle, int[] angles) {
int matchedAngle = findClosestAngle(angle, angles);
int count = 0;
for (int a : angles) {
if (a == matchedAngle) {
++count;
}
}
return count;
}
private int findClosestAngle(int angle, int[] angles) {
int result = Integer.MIN_VALUE;
int bestDiff = Integer.MAX_VALUE;
for (int a : angles) {
int diff = Math.abs(a - angle);
if (result == -1 || diff < bestDiff) {
result = a;
bestDiff = diff;
}
}
return result;
}
public void addHandler(OTRHandler handler) {
if (handlers == null)
handlers = new ArrayList<OTRHandler>();
handlers = new ArrayList<>();
handlers.add(handler);
}
@ -387,7 +455,7 @@ public class OTRManager extends RadarEventAdapter {
RadarServer radarServer;
// ArrayList<Req> requests = new ArrayList<Req>();
HashMap<String, RadarStatus> state = new HashMap<String, RadarStatus>();
HashMap<String, RadarStatus> state = new HashMap<>();
public OTRManager(RadarServer radarServer) {
this.radarServer = radarServer;

View file

@ -31,184 +31,198 @@ import com.raytheon.rcm.message.GraphicProduct.PDB;
/**
* A radar server component that logs various radar events.
*
* <pre>
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 2009 dfriedma Initial version
* 2016-04-22 DR 18909 dfriedma Log fields of expanded GSM.
* </pre>
*/
public class EventLogger extends RadarEventAdapter {
public EventLogger() {
}
@Override
public void handleRadarEvent(RadarEvent event) {
switch (event.getType()) {
case RadarEvent.CONNECTION_UP:
Log.eventf("%s: connected", event.getRadarID());
break;
case RadarEvent.CONNECTION_DOWN:
Log.eventf("%s: disconnected", event.getRadarID());
break;
case RadarEvent.MESSAGE_RECEIVED:
{
StringBuilder s = new StringBuilder();
byte[] msg = event.getMessageData();
int messageCode = Message.messageCodeOf(msg);
s.append("code=" + messageCode);
s.append(" size=" + msg.length);
if (messageCode == Message.GSM) {
s.append(' ');
GSM gsm = null;
try {
gsm = GSM.decode(msg);
} catch (Exception e) {
s.append("(Message decoding failed)");
}
if (gsm != null)
s.append(formatGSM(gsm));
} else if (messageCode == Message.REQUEST_RESPONSE) {
s.append(' ');
RequestResponse rr = null;
try {
rr = RequestResponse.decode(msg);
} catch (Exception e) {
s.append("(Message decoding failed)");
}
if (rr != null)
s.append(formatPRR(rr));
} else if (messageCode >= 16) {
PDB pdb = null;
s.append(' ');
try {
pdb = GraphicProduct.pdbOfMessage(msg);
} catch (Exception e) {
s.append("(Message decoding failed)");
}
if (pdb != null)
s.append(String.format("elev=%.1f sequence=%d"+
" vs=%3$tY-%3$tm-%3$td %3$tH:%3$tM:%3$tS #%4$d",
pdb.getElevationAngle() / 10.0, pdb.sequence,
pdb.volumeScanTime, pdb.volumeScan));
}
Log.eventf("%s: message %s", event.getRadarID(), s.toString());
break;
}
}
}
public EventLogger() {
protected final String[] rdaOpStatusStr = {
"auto-calib-disab", "online", "maint-req", "maint-mand", "cmd-shutdown",
"inoperable", null, "wideband-disconn"
};
protected final String[] rdaStatusStr = {
null, "startup", "standby", "restart", "operate", null, "offline-op"
};
protected final String[] rdaAlarmStr = {
"indeterminate", "tower", "pedestal", "transmitter", "receiver", "control", "comms"
};
protected final String[] dteStr = {
null, "none", "refl", "vel", "sw", "dual-pol"
};
protected final String[] rpgOpStr = {
"load-shed", "online", "maint-req", "maint-mand", "cmd-shutdown"
};
protected final String[] rpgAlarmStr = {
"none", "node-conn", null, "ctl-task-fail", "db-fail", null, "input-load-shed",
null, "store-load-shed", null, null, null, "link-fail", "redundant-channel-error",
"task-fail", "media-fail"
};
protected final String[] rpgStatusStr = {
"restart", "operate", "standby", null, "test-mode"
};
protected final String[] productAvailStr = {
"avail", "degraded", "not-avail"
};
protected final String[] prrStr = {
"no-such-msg", "no-such-prod", "not-gen", "proc-fault",
"narrowband-loadshed", "illegal-req", "mem-loadshed", "cpu-loadshed",
"slot-unavail", "task-failed", "task-unavail", "avail-next-scan",
"moment-disabled", "invalid-password", null, "aborted-scan",
"inval-prod-param", "data-seq-error", "task-term"
};
protected String formatBits(short bits, String[] strings) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < 16; i++) {
if ((bits & (1 << i)) != 0) {
if (result.length() > 0)
result.append(',');
String s = null;
if (i < strings.length)
s = strings[i];
if (s == null)
s = "unk" + Integer.toString(15 - i);
result.append(s);
}
}
return result.toString();
}
protected String formatPrrBits(int bits, String[] strings) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < 32; i++) {
// PRR bits are defined from the MSB on down, so
// note the (31-i)
if ((bits & (1 << (31-i))) != 0) {
if (result.length() > 0)
result.append(',');
String s = null;
if (i < strings.length)
s = strings[i];
if (s == null)
s = "unk" + Integer.toString(31 - i);
result.append(s);
}
}
return result.toString();
}
protected String formatGSM(GSM gsm) {
StringBuilder o = new StringBuilder();
String s;
}
switch (gsm.opMode) {
case GSM.OP_MODE_CLEAR_AIR: s = "clear-air"; break;
case GSM.OP_MODE_STORM: s = "storm"; break;
case GSM.OP_MODE_MAINTENANCE: s = "maintenance"; break;
default: s = "(" +Integer.toString(gsm.opMode) + ")";
}
o.append("opMode=" + s);
o.append(" vcp=" + gsm.vcp);
o.append(" cuts=" + Arrays.toString(gsm.cuts));
o.append(String.format(" rdaOp=%s rdaStat=%s rdaAlarm=%s dte=%s rpgOp=%s rpgStat=%s rpgAlarm=%s",
formatBits((short) gsm.rdaOpStatus, rdaOpStatusStr),
formatBits((short) gsm.rdaStatus, rdaStatusStr),
formatBits((short) gsm.rdaAlarms, rdaAlarmStr),
formatBits((short) gsm.dataAvailability, dteStr),
formatBits((short) gsm.rpgOpStatus, rpgOpStr),
formatBits((short) gsm.rpgStatus, rpgStatusStr),
formatBits((short) gsm.rpgAlarms, rpgAlarmStr)));
o.append(String.format(" avail=%s",
formatBits((short) gsm.productAvailability, productAvailStr)));
o.append(String.format(" rdaVer=%.1f rpgVer=%.1f", gsm.rdaVersion/10.0, gsm.rpgVersion/10.));
return o.toString();
}
protected String formatPRR(RequestResponse rr) {
StringBuilder o = new StringBuilder();
o.append(String.format("productCode=%d sequence=%d elev=%d flags=%s",
rr.productCode,
rr.sequence,
rr.elevationAngle,
formatPrrBits(rr.errorCode, prrStr)));
return o.toString();
}
@Override
public void handleRadarEvent(RadarEvent event) {
switch (event.getType()) {
case RadarEvent.CONNECTION_UP:
Log.eventf("%s: connected", event.getRadarID());
break;
case RadarEvent.CONNECTION_DOWN:
Log.eventf("%s: disconnected", event.getRadarID());
break;
case RadarEvent.MESSAGE_RECEIVED:
{
StringBuilder s = new StringBuilder();
byte[] msg = event.getMessageData();
int messageCode = Message.messageCodeOf(msg);
s.append("code=" + messageCode);
s.append(" size=" + msg.length);
if (messageCode == Message.GSM) {
s.append(' ');
GSM gsm = null;
try {
gsm = GSM.decode(msg);
} catch (Exception e) {
s.append("(Message decoding failed)");
}
if (gsm != null)
s.append(formatGSM(gsm));
} else if (messageCode == Message.REQUEST_RESPONSE) {
s.append(' ');
RequestResponse rr = null;
try {
rr = RequestResponse.decode(msg);
} catch (Exception e) {
s.append("(Message decoding failed)");
}
if (rr != null)
s.append(formatPRR(rr));
} else if (messageCode >= 16) {
PDB pdb = null;
s.append(' ');
try {
pdb = GraphicProduct.pdbOfMessage(msg);
} catch (Exception e) {
s.append("(Message decoding failed)");
}
if (pdb != null)
s.append(String.format("elev=%.1f sequence=%d"+
" vs=%3$tY-%3$tm-%3$td %3$tH:%3$tM:%3$tS #%4$d",
pdb.getElevationAngle() / 10.0, pdb.sequence,
pdb.volumeScanTime, pdb.volumeScan));
}
Log.eventf("%s: message %s", event.getRadarID(), s.toString());
break;
}
}
}
protected final String[] rdaOpStatusStr = {
"auto-calib-disab", "online", "maint-req", "maint-mand", "cmd-shutdown",
"inoperable", null, "wideband-disconn"
};
protected final String[] rdaStatusStr = {
null, "startup", "standby", "restart", "operate", null, "offline-op"
};
protected final String[] rdaAlarmStr = {
"indeterminate", "tower", "pedestal", "transmitter", "receiver", "control", "comms"
};
protected final String[] dteStr = {
null, "none", "refl", "vel", "sw", "dual-pol"
};
protected final String[] rpgOpStr = {
"load-shed", "online", "maint-req", "maint-mand", "cmd-shutdown"
};
protected final String[] rpgAlarmStr = {
"none", "node-conn", null, "ctl-task-fail", "db-fail", null, "input-load-shed",
null, "store-load-shed", null, null, null, "link-fail", "redundant-channel-error",
"task-fail", "media-fail"
};
protected final String[] rpgStatusStr = {
"restart", "operate", "standby", null, "test-mode"
};
protected final String[] productAvailStr = {
"avail", "degraded", "not-avail"
};
protected final String[] prrStr = {
"no-such-msg", "no-such-prod", "not-gen", "proc-fault",
"narrowband-loadshed", "illegal-req", "mem-loadshed", "cpu-loadshed",
"slot-unavail", "task-failed", "task-unavail", "avail-next-scan",
"moment-disabled", "invalid-password", null, "aborted-scan",
"inval-prod-param", "data-seq-error", "task-term"
};
protected final String[] vcpSupplementalStr = {
"AVSET", "SAILS", "site-specific-vcp", "RxRN", "CBT"
};
protected String formatBits(short bits, String[] strings) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < 16; i++) {
if ((bits & (1 << i)) != 0) {
if (result.length() > 0)
result.append(',');
String s = null;
if (i < strings.length)
s = strings[i];
if (s == null)
s = "unk" + Integer.toString(15 - i);
result.append(s);
}
}
return result.toString();
}
protected String formatPrrBits(int bits, String[] strings) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < 32; i++) {
// PRR bits are defined from the MSB on down, so
// note the (31-i)
if ((bits & (1 << (31-i))) != 0) {
if (result.length() > 0)
result.append(',');
String s = null;
if (i < strings.length)
s = strings[i];
if (s == null)
s = "unk" + Integer.toString(31 - i);
result.append(s);
}
}
return result.toString();
}
protected String formatGSM(GSM gsm) {
StringBuilder o = new StringBuilder();
String s;
switch (gsm.opMode) {
case GSM.OP_MODE_CLEAR_AIR: s = "clear-air"; break;
case GSM.OP_MODE_STORM: s = "storm"; break;
case GSM.OP_MODE_MAINTENANCE: s = "maintenance"; break;
default: s = "(" +Integer.toString(gsm.opMode) + ")";
}
o.append("opMode=" + s);
o.append(" vcp=" + gsm.vcp);
o.append(" cuts=" + Arrays.toString(gsm.cuts));
o.append(String.format(" rdaOp=%s rdaStat=%s rdaAlarm=%s dte=%s rpgOp=%s rpgStat=%s rpgAlarm=%s",
formatBits((short) gsm.rdaOpStatus, rdaOpStatusStr),
formatBits((short) gsm.rdaStatus, rdaStatusStr),
formatBits((short) gsm.rdaAlarms, rdaAlarmStr),
formatBits((short) gsm.dataAvailability, dteStr),
formatBits((short) gsm.rpgOpStatus, rpgOpStr),
formatBits((short) gsm.rpgStatus, rpgStatusStr),
formatBits((short) gsm.rpgAlarms, rpgAlarmStr)));
o.append(String.format(" avail=%s",
formatBits((short) gsm.productAvailability, productAvailStr)));
o.append(String.format(" suppl=%s",
formatBits((short) gsm.vcpSupplemental, vcpSupplementalStr)));
o.append(String.format(" rdaVer=%.1f rpgVer=%.1f", gsm.rdaVersion/10.0, gsm.rpgVersion/10.));
return o.toString();
}
protected String formatPRR(RequestResponse rr) {
StringBuilder o = new StringBuilder();
o.append(String.format("productCode=%d sequence=%d elev=%d flags=%s",
rr.productCode,
rr.sequence,
rr.elevationAngle,
formatPrrBits(rr.errorCode, prrStr)));
return o.toString();
}
}

View file

@ -40,6 +40,9 @@
# Jul 23, 2015 ASM#13849 D. Friedman Use a unique Eclipse configuration directory
# Aug 03, 2015 #4694 dlovely Fixed path for log file cleanup
# Sep 16, 2015 #18041 lshi Purge CAVE logs after 30 days instead of 7
# Apr 20, 2016 #18910 lshi Change CAVE log purging to add check for find commands
# already running
########################
source /awips2/cave/iniLookup.sh
RC=$?
@ -383,11 +386,12 @@ function deleteOldCaveLogs()
local curDir=$(pwd)
local mybox=$(hostname)
echo -e "Cleaning consoleLogs: "
echo -e "find $HOME/$BASE_LOGDIR -type f -name "*.log" -mtime +30 -exec rm {} \;"
find "$HOME/$BASE_LOGDIR" -type f -name "*.log" -mtime +30 -exec rm {} \;
pidof /bin/find > /dev/null
if [[ $? -ne 0 ]] ; then
echo -e "Cleaning consoleLogs: "
echo -e "find $HOME/$BASE_LOGDIR -type f -name "*.log" -mtime +30 | xargs rm "
find "$HOME/$BASE_LOGDIR" -type f -name "*.log" -mtime +30 | xargs rm
fi
exit 0

View file

@ -104,6 +104,7 @@ import com.raytheon.uf.viz.alertviz.ui.audio.IAudioAction;
* 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
* 19 Apr 2016 5517 randerso Fixed saving/restoring location of AlertViz bar
*
* </pre>
*
@ -271,7 +272,6 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener,
*/
public Object open() {
shell = new Shell(display, SWT.ON_TOP | SWT.NO_TRIM);
shell.setBounds(restoreDialogPosition());
shell.addDisposeListener(new DisposeListener() {
@Override
@ -292,11 +292,17 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener,
// Initialize all of the controls and layouts
initializeComponents();
shell.pack();
shell.open();
// Restore the previous dialog position
Rectangle rect = restoreDialogPosition();
Point shellLoc = new Point(rect.x, rect.y);
if (rect.width > 0 && rect.height > 0) {
shell.setSize(rect.width, rect.height);
}
Point shellSize = shell.getSize();
// force bar location to be within the display.
Point shellLoc = shell.getLocation();
Point shellSize = shell.getSize();
Display d = shell.getDisplay();
Rectangle dBounds = d.getBounds();
if (shellLoc.x < dBounds.x) {
@ -310,6 +316,7 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener,
shellLoc.y = (dBounds.y + dBounds.height) - shellSize.y;
}
shell.setLocation(shellLoc);
shell.open();
if (Boolean.getBoolean("SystemTray")
&& !Boolean.getBoolean("ShowAlertVizBar")) {
@ -1224,7 +1231,7 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener,
return alertAudioMgr;
}
public static Rectangle restoreDialogPosition() {
private static Rectangle restoreDialogPosition() {
return new Rectangle(
dialogPrefs.getInt(P_ALERT_MSG_DLG_POSITION + ".x"),
dialogPrefs.getInt(P_ALERT_MSG_DLG_POSITION + ".y"),
@ -1232,7 +1239,7 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener,
dialogPrefs.getInt(P_ALERT_MSG_DLG_POSITION + ".height"));
}
public static void saveDialogPosition(Rectangle r) {
private 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);

View file

@ -101,6 +101,7 @@ import com.raytheon.uf.viz.alertviz.ui.dialogs.ConfigurationFileDlg.Function;
* 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
* 19 Apr 2016 5517 randerso Fix GUI sizing issues
*
* </pre>
*
@ -855,23 +856,46 @@ public class AlertVisConfigDlg implements IConfigurationChangedListener,
// Filler
new Label(prioritiesComp, SWT.NONE);
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.horizontalSpan = 6;
Label priorityLbl = new Label(prioritiesComp, SWT.CENTER);
priorityLbl.setText(getPriorityLabelText());
priorityLbl.setFont(labelFont);
priorityLbl.setLayoutData(gd);
priorityLbl.setData(MonitorToolTip.tooltipTextKey,
getPrioritiesToolTipText());
Label label = new Label(prioritiesComp, SWT.CENTER);
label.setFont(labelFont);
label.setText("HIGH");
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
label.setLayoutData(gd);
mttPriorities = new MonitorToolTip(priorityLbl, false);
label = new Label(prioritiesComp, SWT.CENTER);
label.setFont(labelFont);
label.setText("<---");
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
label.setLayoutData(gd);
priorityLbl.addMouseTrackListener(new MouseTrackAdapter() {
label = new Label(prioritiesComp, SWT.CENTER);
label.setFont(labelFont);
label.setText("PRIORITIES");
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.horizontalSpan = 2;
label.setLayoutData(gd);
label.setData(MonitorToolTip.tooltipTextKey, getPrioritiesToolTipText());
mttPriorities = new MonitorToolTip(label, false);
MouseTrackAdapter hoverListener = new MouseTrackAdapter() {
@Override
public void mouseHover(MouseEvent e) {
mttPriorities.open();
}
});
};
label.addMouseTrackListener(hoverListener);
label = new Label(prioritiesComp, SWT.CENTER);
label.setFont(labelFont);
label.setText("--->");
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
label.setLayoutData(gd);
label = new Label(prioritiesComp, SWT.CENTER);
label.setFont(labelFont);
label.setText("LOW");
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
label.setLayoutData(gd);
// ---------------------------------------------------------
// Put the priority canvases on the display
@ -1098,21 +1122,6 @@ public class AlertVisConfigDlg implements IConfigurationChangedListener,
saveNeeded(false);
}
/**
* Get the text for the priorities label.
*
* @return Label text.
*/
private String getPriorityLabelText() {
String format = "%S";
String text = "High <--- PRIORITIES --> Low";
String labelStr = String.format(format, text);
return labelStr;
}
/**
* Add a separator to the display.
*
@ -1520,14 +1529,14 @@ public class AlertVisConfigDlg implements IConfigurationChangedListener,
private String getCommonSettingToolTipText() {
StringBuilder sb = new StringBuilder();
sb.append("This are general settings. The left\n");
sb.append("These are general settings. The left\n");
sb.append("side describes how the text message\n");
sb.append("representations will be affected\n");
sb.append("in the main GUI (if text is turned\n");
sb.append(" on for thekey/priority) and the Pop-ups\n");
sb.append("and how long thetext blinking and system\n");
sb.append("audio execution willlast (again, if turned\n");
sb.append("on). The right side definesother, general\n");
sb.append("on for the key/priority) and the Pop-ups\n");
sb.append("and how long the text blinking and system\n");
sb.append("audio execution will last (again, if turned\n");
sb.append("on). The right side defines other, general\n");
sb.append("behavior.");
sb.append("NOTE: to make blinking or audio \n");
sb.append("responses perpetual, set the duration to 0.");

View file

@ -74,7 +74,8 @@ import com.raytheon.uf.viz.alertviz.config.TrayConfiguration;
* 24 Mar 2011 5853 cjeanbap Add createLayoutControls() to reloadConfig().
* 02 May 2011 9067 cjeanbap Remove createLayoutControls() from reloadConfig().
* 07 Feb 2013 15490 Xiaochuan Add configDialog to handle the updated setting
* on Category layers.
* on Category layers.
* 19 Apr 2016 5517 randerso Fix GUI sizing issues
*
* </pre>
*
@ -204,7 +205,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
private MenuItem menuItem;
private INeedsSaveListener needsSaveListener;
private AlertVisConfigDlg configDialog;
/**
@ -240,6 +241,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
initControls();
this.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent arg0) {
controlFont.dispose();
}
@ -290,7 +292,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
*/
private void createCategoryListControls() {
Composite listComp = new Composite(this, SWT.NONE);
listComp.setLayout(new GridLayout(2, false));
listComp.setLayout(new GridLayout(2, true));
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.horizontalIndent = 4;
@ -300,15 +302,22 @@ public class LayoutControlsComp extends Composite implements MouseListener {
listLbl.setFont(controlFont);
listLbl.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 200;
gd.heightHint = 205;
gd.horizontalSpan = 2;
categoryList = new List(listComp, SWT.BORDER | SWT.SINGLE
| SWT.V_SCROLL);
categoryList.setLayoutData(gd);
categoryList.setFont(controlFont);
GC gc = new GC(categoryList);
int textWidth = gc.getFontMetrics().getAverageCharWidth() * 30;
gc.dispose();
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = textWidth;
gd.heightHint = categoryList.getItemHeight() * 10;
gd.horizontalSpan = 2;
categoryList.setLayoutData(gd);
categoryList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
handleSourceSelection();
}
@ -316,23 +325,27 @@ public class LayoutControlsComp extends Composite implements MouseListener {
populateCategoryList();
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.widthHint = 80;
int buttonWidth = listComp.getDisplay().getDPI().x;
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.minimumWidth = buttonWidth;
Button newBtn = new Button(listComp, SWT.PUSH);
newBtn.setText("New...");
newBtn.setLayoutData(gd);
newBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
createNewCategory();
}
});
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.widthHint = 80;
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.minimumWidth = buttonWidth;
deleteBtn = new Button(listComp, SWT.PUSH);
deleteBtn.setText("Delete");
deleteBtn.setLayoutData(gd);
deleteBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
deleteCategory();
}
@ -344,6 +357,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
clearAllBtn.setText("Clear All Layouts");
clearAllBtn.setLayoutData(gd);
clearAllBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
clearAllCategoryTextBoxes();
}
@ -353,6 +367,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
popupMenuCList = new Menu(categoryList);
categoryList.setMenu(popupMenuCList);
popupMenuCList.addListener(SWT.Show, new Listener() {
@Override
public void handleEvent(Event event) {
MenuItem[] menuItems = popupMenuCList.getItems();
@ -363,6 +378,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
if (categoryMap.get(getListIndexToKey()).isLocked() != true) {
menuItem = new MenuItem(popupMenuCList, SWT.PUSH);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
deleteCategory();
}
@ -386,6 +402,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
layoutCombo = new Combo(controlComp, SWT.DROP_DOWN | SWT.READ_ONLY);
populateLayoutCombo();
layoutCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
int index = layoutCombo.getSelectionIndex();
selectedMode = TrayConfiguration.TrayMode.valueOf(layoutCombo
@ -393,7 +410,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
selectedModeRecs = layoutRecs.getRectangles(selectedMode);
canvas.redraw();
updateCellNumbers();
configDialog.setNewConfig();
configDialog.setNewConfig();
needsSaveListener.saveNeeded(true);
}
});
@ -414,6 +431,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
removeSelectionBtn.setEnabled(false);
removeSelectionBtn.setLayoutData(gd);
removeSelectionBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
int index = categoryList.getSelectionIndex();
@ -451,6 +469,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
canvas.setLayoutData(gd);
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
drawCanvas(e.gc);
}
@ -467,7 +486,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
*/
private void drawCanvas(GC gc) {
gc.setFont(controlFont);
aveFontWidth = (int) gc.getFontMetrics().getAverageCharWidth();
aveFontWidth = gc.getFontMetrics().getAverageCharWidth();
gc.setLineWidth(3);
@ -885,8 +904,9 @@ public class LayoutControlsComp extends Composite implements MouseListener {
selectedCell = 0;
}
if (removeSelectionBtn == null || canvas == null)
if (removeSelectionBtn == null || canvas == null) {
return;
}
if (selectedCell == 0) {
removeSelectionBtn.setEnabled(false);

View file

@ -37,6 +37,7 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
@ -82,6 +83,7 @@ import com.raytheon.uf.viz.core.VizApp;
* 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.
* Mar 31, 2016 5517 randerso Fix GUI sizing issues
*
* </pre>
*
@ -92,6 +94,9 @@ import com.raytheon.uf.viz.core.VizApp;
public class SimpleLogViewer implements IAlertArrivedCallback,
IAlertVizLogPurgedNotifier {
private static final String[] columnLabels = new String[] { "Time",
"Priority", "Source", "Category", "Message" };
private Display display;
private Shell shell;
@ -120,13 +125,6 @@ public class SimpleLogViewer implements IAlertArrivedCallback,
first = true;
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
| SWT.RESIZE);
shell.setText("System Log");
initializeComponents();
}
/**
@ -157,29 +155,22 @@ public class SimpleLogViewer implements IAlertArrivedCallback,
shell.setLayoutData(gd);
table = new Table(shell, SWT.BORDER | SWT.VIRTUAL);
final TableColumn[] columns = new TableColumn[] {
new TableColumn(table, SWT.NONE),
new TableColumn(table, SWT.NONE),
new TableColumn(table, SWT.NONE),
new TableColumn(table, SWT.NONE),
new TableColumn(table, SWT.NONE) };
table.setHeaderVisible(true);
for (String label : columnLabels) {
TableColumn column = new TableColumn(table, SWT.NONE);
column.setText(label);
}
GC gc = new GC(table);
int textWidth = gc.getFontMetrics().getAverageCharWidth() * 130;
gc.dispose();
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 800;
gd.heightHint = 400;
gd.widthHint = textWidth;
gd.heightHint = table.getItemHeight() * 20;
table.setLayoutData(gd);
table.setHeaderVisible(true);
columns[0].setText("Time");
columns[0].setWidth(200);
columns[1].setText("Priority");
columns[1].setWidth(60);
columns[2].setText("Source");
columns[2].setWidth(100);
columns[3].setText("Category");
columns[3].setWidth(100);
columns[4].setText("Message");
columns[4].setWidth(100);
int sz = 0;
try {
@ -192,7 +183,7 @@ public class SimpleLogViewer implements IAlertArrivedCallback,
e2);
}
table.setSortColumn(columns[0]);
table.setSortColumn(table.getColumn(0));
table.setSortDirection(SWT.UP);
red = new Color(display, new RGB(255, 0, 0));
@ -279,12 +270,19 @@ public class SimpleLogViewer implements IAlertArrivedCallback,
Composite buttons = new Composite(shell, SWT.NONE);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
buttons.setLayoutData(gd);
buttons.setLayout(new GridLayout(3, false));
buttons.setLayout(new GridLayout(2, false));
int buttonWidth = buttons.getDisplay().getDPI().x;
Composite buttonsLeft = new Composite(buttons, SWT.NONE);
gd = new GridData(SWT.LEFT, SWT.DEFAULT, true, false);
buttonsLeft.setLayoutData(gd);
buttonsLeft.setLayout(new GridLayout(2, false));
// Open the shell to display the dialog.
Button button = new Button(buttons, SWT.NONE);
gd = new GridData(SWT.LEFT, SWT.DEFAULT, false, false);
gd.widthHint = 100;
Button button = new Button(buttonsLeft, SWT.NONE);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = buttonWidth;
button.setText("Export Log...");
button.setLayoutData(gd);
button.addSelectionListener(new SelectionAdapter() {
@ -309,9 +307,9 @@ public class SimpleLogViewer implements IAlertArrivedCallback,
});
Button close = new Button(buttons, SWT.NONE);
gd = new GridData(SWT.LEFT, SWT.DEFAULT, false, false);
gd.widthHint = 100;
Button close = new Button(buttonsLeft, SWT.NONE);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = buttonWidth;
close.setText("Close");
close.setLayoutData(gd);
close.addSelectionListener(new SelectionListener() {
@ -328,9 +326,14 @@ public class SimpleLogViewer implements IAlertArrivedCallback,
});
Composite buttonsRight = new Composite(buttons, SWT.NONE);
gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false);
gd.widthHint = 100;
showLog = new Button(buttons, SWT.NONE);
buttonsRight.setLayoutData(gd);
buttonsRight.setLayout(new GridLayout(1, false));
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = buttonWidth;
showLog = new Button(buttonsRight, SWT.NONE);
showLog.setText("Show Log...");
showLog.setLayoutData(gd);
showLog.addSelectionListener(new SelectionAdapter() {
@ -363,24 +366,32 @@ public class SimpleLogViewer implements IAlertArrivedCallback,
* @return null
*/
public Object open() {
// Create a new shell object and set the text for the dialog.
shell = new Shell(display, SWT.DIALOG_TRIM | SWT.MIN | SWT.TITLE
| SWT.RESIZE);
shell.setText("System Log");
initializeComponents();
Point minSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
shell.setMinimumSize(minSize);
Point size = minSize;
shell.setSize(size);
shell.pack();
showHideLog();
AlertvizJob.getInstance().addAlertArrivedCallback(this);
PurgeLogJob.getInstance().addLogPurgeListener(this);
shell.open();
if (table.getItemCount() > 0) {
table.showItem(table.getItem(table.getItemCount() - 1));
table.select(table.getItemCount() - 1);
table.select(table.getItemCount() - 1);
table.showSelection();
for (TableColumn column : table.getColumns()) {
column.pack();
}
shell.open();
// Wait until the shell is disposed.
Display display = shell.getDisplay();
while (!shell.isDisposed()) {

View file

@ -21,7 +21,6 @@ package com.raytheon.uf.viz.alertviz.ui.dialogs;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@ -40,6 +39,8 @@ import org.eclipse.swt.widgets.Combo;
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.Listener;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
@ -52,16 +53,17 @@ import org.eclipse.swt.widgets.TabFolder;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 2008 Max S. Initially create by Max Schenkelberg
* Apr 2, 2009 lvenable TTR fixes.
* Dec 1, 2010 5632 cjeanbap Added sort based on category.
* Mar 2, 2011 5632 cjeanbap Added sort based on category.
* 06 Feb 2013 14501 Xiaochuan Using getCategoriesFromConfig() to
* set categoryList[] in clearOptionCbo.
* 2008 mschenke Initial creation
* Apr 02, 2009 lvenable TTR fixes.
* Dec 01, 2010 5632 cjeanbap Added sort based on category.
* Mar 02, 2011 5632 cjeanbap Added sort based on category.
* Feb 06, 2013 14501 Xiaochuan Using getCategoriesFromConfig() to
* set categoryList[] in clearOptionCbo.
* Apr 01, 2016 5517 randerso Fix GUI sizing issues
*
* </pre>
*
* @author lvenable
* @author mschenke
* @version 1.0
*/
public class TabControlDlg extends Dialog {
@ -113,7 +115,7 @@ public class TabControlDlg extends Dialog {
private static Rectangle bounds;
private static int[] weights = { 50, 50 };
private static int[] weights = { 500, 500 };
private static boolean visible = false;
@ -155,10 +157,6 @@ public class TabControlDlg extends Dialog {
shell = new Shell(parent, SWT.TITLE | SWT.RESIZE);
if (bounds != null) {
shell.setBounds(bounds);
shell.setFocus();
}
GridLayout mainLayout = new GridLayout(1, false);
shell.setLayout(mainLayout);
@ -172,34 +170,28 @@ public class TabControlDlg extends Dialog {
mainComp = new Composite(shell, SWT.NONE);
mainComp.setLayout(new GridLayout(1, false));
shell.addDisposeListener(new DisposeListener() {
shell.addListener(SWT.Close, new Listener() {
@Override
public void widgetDisposed(DisposeEvent e) {
cacheDimensions();
public void handleEvent(Event event) {
if (visible) {
int[] currentWeights = topComp.getWeights();
weights[0] = currentWeights[0];
weights[1] = currentWeights[1];
}
bounds = shell.getBounds();
}
});
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
if (bounds == null) {
gd.widthHint = 800;
gd.heightHint = 285;
} else {
gd.widthHint = bounds.width;
gd.heightHint = bounds.height;
}
// TODO: clean this up
gd.widthHint = 800;
gd.heightHint = 285;
mainComp.setLayoutData(gd);
topComp = new SashForm(mainComp, SWT.HORIZONTAL);
topComp.setLayout(new GridLayout(2, false));
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
if (bounds == null) {
gd.widthHint = 400;
gd.heightHint = 285;
} else {
gd.widthHint = bounds.width;
gd.heightHint = bounds.height;
}
topComp.setLayoutData(gd);
tabFolder = new TabFolder(topComp, SWT.BORDER);
@ -207,6 +199,7 @@ public class TabControlDlg extends Dialog {
tabFolder.setLayoutData(gd);
tabFolder.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
logs.clear();
}
@ -216,8 +209,9 @@ public class TabControlDlg extends Dialog {
@Override
public void widgetSelected(SelectionEvent e) {
int index = tabFolder.getSelectionIndex();
if (index < 0 || logs.size() == 0)
if (index < 0 || logs.size() == 0) {
return;
}
TextMsgLog log = logs.get(index);
shell.setText("Log list for: " + log.getFullText());
populateClearOptionsCombo(log);
@ -235,27 +229,24 @@ public class TabControlDlg extends Dialog {
detailsText.setLayoutData(gd);
detailsText.setEditable(false);
detailsText.setVisible(visible);
((GridData) detailsText.getLayoutData()).exclude = true;
if (visible) {
topComp.setWeights(weights);
}
createBottomButtons();
topComp.setWeights(weights);
handleShowHide(visible);
}
/**
* Creates the bottom buttons of the dialog.
*/
private void createBottomButtons() {
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
GridData gd = new GridData(SWT.LEFT, SWT.DEFAULT, true, false);
Composite buttonComp = new Composite(mainComp, SWT.NONE);
buttonComp.setLayoutData(gd);
buttonComp.setLayout(new GridLayout(4, false));
buttonComp.setLayout(new GridLayout(4, true));
clearOptionCbo = new Combo(buttonComp, SWT.DROP_DOWN | SWT.READ_ONLY);
gd = new GridData(100, SWT.DEFAULT);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
clearOptionCbo.setLayoutData(gd);
clearOptionCbo.addSelectionListener(new SelectionListener() {
@ -270,7 +261,7 @@ public class TabControlDlg extends Dialog {
String category = clearOptionCbo.getItem(position);
logs.get(index).displayCategoryMessages(category);
if (index == 0) {
clearOptionCbo.select(position);
clearOptionCbo.select(position);
}
logs.get(index).setClearOptionCboSelectedIndex(position);
}
@ -281,7 +272,7 @@ public class TabControlDlg extends Dialog {
}
});
gd = new GridData(100, SWT.DEFAULT);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
Button clearBtn = new Button(buttonComp, SWT.PUSH);
clearBtn.setText("Clear");
clearBtn.setLayoutData(gd);
@ -297,7 +288,7 @@ public class TabControlDlg extends Dialog {
}
});
gd = new GridData(100, SWT.DEFAULT);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
Button closeBtn = new Button(buttonComp, SWT.PUSH);
closeBtn.setText("Close");
closeBtn.setLayoutData(gd);
@ -308,60 +299,53 @@ public class TabControlDlg extends Dialog {
}
});
gd = new GridData(SWT.END, SWT.DEFAULT, false, false);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
showHide = new Button(buttonComp, SWT.PUSH);
showHide.setText("Show Details...");
showHide.setLayoutData(gd);
// TODO: Make this work, right now not working
showHide.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// if now visible then use cache weights
// if NOT visible, save weights, set to hidden
visible = !visible;
detailsText.setVisible(visible);
SashForm sf = (SashForm) topComp;
if (visible == true) {
showHide.setText("Hide Details...");
sf.setWeights(weights);
} else {
showHide.setText("Show Details");
cacheDimensions();
sf.setWeights(new int[] { 100, 0 });
}
topComp.layout();
mainComp.layout();
handleShowHide(!visible);
}
});
}
private void cacheDimensions() {
int[] currentWeights = topComp.getWeights();
weights[0] = currentWeights[0];
weights[1] = currentWeights[1];
bounds = topComp.getParent().getBounds();
bounds.x = shell.getParent().getBounds().x;
bounds.y = shell.getParent().getBounds().y;
private void handleShowHide(boolean show) {
visible = show;
detailsText.setVisible(visible);
SashForm sf = topComp;
if (visible) {
showHide.setText("Hide Details...");
sf.setWeights(weights);
} else {
showHide.setText("Show Details");
int[] currentWeights = topComp.getWeights();
weights[0] = currentWeights[0];
weights[1] = currentWeights[1];
sf.setWeights(new int[] { 1000, 0 });
}
topComp.layout();
mainComp.layout();
}
/**
* Populates the clear options combo box with values of current LogDlg tab
* being displayed, called when tabitem has changed
*
* @param dlg
* LogDlg that is in current tab.
* @param log
* TextMsgLog that is in current tab.
*/
public void populateClearOptionsCombo(TextMsgLog log) {
clearOptionCbo.removeAll();
clearOptionCbo.add("All");
Set<String> keySet = log.getCatKeySet();
String[] categoryList = log.getCategoriesFromConfig();
for (int i = 0; i < categoryList.length; i++) {
clearOptionCbo.add(categoryList[i]);
clearOptionCbo.add(categoryList[i]);
}
clearOptionCbo.select(0);
@ -372,15 +356,19 @@ public class TabControlDlg extends Dialog {
* Open the dialog.
*/
public void open() {
Display display = shell.getDisplay();
shell.layout();
shell.pack();
setInitialDialogLocation();
if (bounds != null) {
shell.setBounds(bounds);
shell.setFocus();
} else {
setInitialDialogLocation();
}
shell.open();
Display display = shell.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
@ -439,8 +427,9 @@ public class TabControlDlg extends Dialog {
}
/**
* Notify the TabControlDlg when a new tab has been added. TODO: Replace
* with event handler?
* Notify the TabControlDlg when a new tab has been added.
*
* TODO: Replace with event handler?
*
* @param log
* The log that is the new tab.

View file

@ -30,6 +30,7 @@ import com.raytheon.uf.viz.npp.sounding.rsc.NPPSoundingMapResourceData;
* ------------ ---------- ----------- --------------------------
* Dec 16, 2015 18191 pwang Initial version.
* Feb 03, 2016 18588 wkwock Fix update nucaps data issue.
* Apr 14, 2016 18588 wkwock Improve the performance.
*
* </pre>
*
@ -71,6 +72,10 @@ public class NucapsSoundingMapResource extends NPPSoundingMapResource {
}
}
public synchronized void addRecordsNoUpdate (PluginDataObject... records){
super.addRecords(records);
}
/**
* Color code dots base on QC value
*

View file

@ -3,8 +3,10 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@ -35,6 +37,7 @@ import com.raytheon.viz.pointdata.PointDataRequest;
* ------------ ------- ---------- --------------------------
* Dec 16, 2015 18191 pwang Initial creation. Color code dots base on QC value
* Feb 03, 2016 18588 wkwock Fix update nucaps data issue.
* Apr 14, 2016 18588 wkwock Improve the performance.
*
* </pre>
*
@ -59,7 +62,7 @@ public class NucapsSoundingMapResourceData extends NPPSoundingMapResourceData {
NucapsSoundingMapResource resource = new NucapsSoundingMapResource(this,
loadProperties);
if (objects instanceof PluginDataObject[]) {
resource.addRecords((PluginDataObject[]) objects);
resource.addRecordsNoUpdate((PluginDataObject[]) objects);
}
return resource;
}
@ -72,7 +75,7 @@ public class NucapsSoundingMapResourceData extends NPPSoundingMapResourceData {
* @throws VizException
*/
public PluginDataObject[] updatePluginDataObjects(PluginDataObject[] records) throws VizException {
List<DataTime> timesToLoad = new ArrayList<DataTime>();
Set<DataTime> timesToLoad = new HashSet<DataTime>();
for (PluginDataObject record : records){
timesToLoad.add(record.getDataTime());
}

View file

@ -84,6 +84,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* plugin.
* Oct 02, 2015 4914 bsteffen Create custom style type for rules that
* apply only to cross section.
* Apr 12, 2016 5567 bsteffen Fix conversion in inspect
*
* </pre>
*
@ -312,7 +313,7 @@ public class CrossSectionImageResource extends AbstractCrossSectionResource {
ColorMapParameters colorMapParams = getCapability(
ColorMapCapability.class).getColorMapParameters();
if (colorMapParams != null) {
Unit<?> dataUnit = adapter.getUnit();
Unit<?> dataUnit = getUnit();
Unit<?> displayUnit = colorMapParams.getDisplayUnit();
if (displayUnit != null && dataUnit != null
&& dataUnit.isCompatible(displayUnit)) {

View file

@ -34,6 +34,8 @@
# RollbackMasterInterface.
# 07/23/15 4263 dgilling Support refactored Java
# SmartToolControllers.
# 04/13/16 5568 dgilling More lenient handling of
# ScreenList.
#
#
#
@ -76,7 +78,18 @@ class SmartToolInterface(RollbackMasterInterface.RollbackMasterInterface):
return getattr(sys.modules[name], "WeatherElementEdited", "None")
def getScreenList(self, name):
return getattr(sys.modules[name], "ScreenList", None)
screenList = getattr(sys.modules[name], "ScreenList", None)
if screenList is not None:
try:
iter(screenList)
except TypeError:
screenList = [str(screenList)]
else:
if isinstance(screenList, basestring):
screenList = [str(screenList)]
else:
screenList = [str(i) for i in screenList]
return screenList
def getVariableList(self, name):
return getattr(sys.modules[name], "VariableList", [])

View file

@ -63,12 +63,14 @@ 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.dataplugin.gfe.server.notify.CombinationsFileChangedNotification;
import com.raytheon.uf.common.localization.FileUpdatedMessage;
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.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
@ -80,7 +82,6 @@ import com.raytheon.uf.viz.core.exception.VizException;
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.internal.NotificationRouter.AbstractGFENotificationObserver;
import com.raytheon.viz.gfe.textformatter.CombinationsFileUtil;
import com.raytheon.viz.gfe.textformatter.TextProductManager;
import com.raytheon.viz.gfe.ui.zoneselector.ZoneSelector;
@ -112,6 +113,7 @@ import com.raytheon.viz.gfe.ui.zoneselector.ZoneSelector;
* FileUpdatedMessage so we can ignore our own changes
* Moved retrieval of combinations file to CombinationsFileUtil.init
* Oct 07, 2015 #4695 dgilling Move loading of combinations file off UI thread.
* Apr 25, 2016 #5605 randerso Switched back to writing combinations file using Localization
*
* </pre>
*
@ -208,7 +210,7 @@ public class ZoneCombinerComp extends Composite implements IZoneCombiner {
protected boolean mapRequired;
private List<RGB> colorMap = new ArrayList<RGB>();
private List<RGB> colorMap = new ArrayList<>();
private final String COLOR_MAP_FILE = FileUtil.join("gfe", "combinations",
"Combinations_ColorMap");
@ -229,15 +231,13 @@ public class ZoneCombinerComp extends Composite implements IZoneCombiner {
protected Object initialZoom = null;
private String currentComboFile = null;
private final LocalizationFile comboDir;
private final LocalizationFile combinationsFile;
private boolean includeAllZones = false;
private List<String> mapNames;
private AbstractGFENotificationObserver<CombinationsFileChangedNotification> comboChangeListener;
private ILocalizationFileObserver combinationsChangeListener;
private final ExecutorService asyncExecutor;
@ -289,41 +289,43 @@ public class ZoneCombinerComp extends Composite implements IZoneCombiner {
initPreferences();
init();
String combinationsName = textProductMgr
.getCombinationsFileName(productName);
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext baseCtx = pathMgr.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.BASE);
comboDir = pathMgr.getLocalizationFile(baseCtx,
CombinationsFileUtil.COMBO_DIR_PATH);
combinationsFile = pathMgr.getLocalizationFile(baseCtx,
LocalizationUtil.join(
CombinationsFileUtil.COMBINATIONS_DIR_PATH,
combinationsName + ".py"));
this.comboChangeListener = new AbstractGFENotificationObserver<CombinationsFileChangedNotification>(
CombinationsFileChangedNotification.class) {
this.combinationsChangeListener = new ILocalizationFileObserver() {
@Override
public void notify(
CombinationsFileChangedNotification notificationMessage) {
comboFileChanged(notificationMessage);
}
public void fileUpdated(FileUpdatedMessage message) {
comboFileChanged(message);
}
};
this.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
ZoneCombinerComp.this.dataManager.getNotificationRouter()
.removeObserver(
ZoneCombinerComp.this.comboChangeListener);
combinationsFile
.removeFileUpdatedObserver(combinationsChangeListener);
ZoneCombinerComp.this.asyncExecutor.shutdown();
}
});
dataManager.getNotificationRouter().addObserver(
this.comboChangeListener);
combinationsFile
.addFileUpdatedObserver(this.combinationsChangeListener);
}
private List<String> getMapNames(String productName) {
Object obj = this.textProductMgr.getMapNameForCombinations(productName);
List<String> mapNames = new ArrayList<String>();
List<String> mapNames = new ArrayList<>();
if (obj instanceof String) {
String s = (String) obj;
if (!s.isEmpty()) {
@ -554,7 +556,7 @@ public class ZoneCombinerComp extends Composite implements IZoneCombiner {
if (zoneSelector != null) {
return zoneSelector.getZoneGroupings();
} else {
return new ArrayList<List<String>>();
return new ArrayList<>();
}
}
@ -717,7 +719,7 @@ public class ZoneCombinerComp extends Composite implements IZoneCombiner {
}
LocalizationFile[] lfs = CombinationsFileUtil.getSavedCombos();
List<String> names = new ArrayList<String>();
List<String> names = new ArrayList<>();
for (LocalizationFile lf : lfs) {
String id = CombinationsFileUtil.fileToId(lf);
String name = CombinationsFileUtil.fnToName(this.mapNames, id);
@ -943,8 +945,8 @@ public class ZoneCombinerComp extends Composite implements IZoneCombiner {
LocalizationContext localization = pm.getContext(
LocalizationType.CAVE_STATIC, level);
File localFile = pm.getFile(localization,
FileUtil.join(CombinationsFileUtil.COMBO_DIR_PATH, local));
File localFile = pm.getFile(localization, FileUtil.join(
CombinationsFileUtil.COMBINATIONS_DIR_PATH, local));
return localFile;
}
@ -960,7 +962,7 @@ public class ZoneCombinerComp extends Composite implements IZoneCombiner {
} catch (Exception e) {
statusHandler.handle(Priority.SIGNIFICANT,
"Error loading combo file", e);
comboDict = new HashMap<String, Integer>();
comboDict = new HashMap<>();
}
zoneSelector.updateCombos(comboDict);
}
@ -992,7 +994,7 @@ public class ZoneCombinerComp extends Composite implements IZoneCombiner {
return Collections.emptyMap();
}
Map<String, Integer> dict = new HashMap<String, Integer>();
Map<String, Integer> dict = new HashMap<>();
// reformat combinations into combo dictionary
int group = 1;
for (List<String> zonelist : combolist) {
@ -1002,8 +1004,6 @@ public class ZoneCombinerComp extends Composite implements IZoneCombiner {
group += 1;
}
currentComboFile = comboName;
return dict;
}
@ -1011,7 +1011,7 @@ public class ZoneCombinerComp extends Composite implements IZoneCombiner {
* load the color map file
*/
private List<RGB> getColorsFromFile() {
List<RGB> colors = new ArrayList<RGB>();
List<RGB> colors = new ArrayList<>();
IPathManager pm = PathManagerFactory.getPathManager();
File file = pm.getStaticFile(COLOR_MAP_FILE);
@ -1037,19 +1037,16 @@ public class ZoneCombinerComp extends Composite implements IZoneCombiner {
return colors;
}
private void comboFileChanged(CombinationsFileChangedNotification notif) {
String comboName = notif.getCombinationsFileName();
private void comboFileChanged(FileUpdatedMessage message) {
String comboName = LocalizationUtil.extractName(message.getFileName())
.replace(".py", "");
statusHandler
.info("Received CombinationsFileChangedNotification for combinations file: "
+ comboName);
// if it's the same file and not changed by me update the combos
if (comboName.equalsIgnoreCase(currentComboFile)
&& !VizApp.getWsId().equals(notif.getWhoChanged())) {
statusHandler
.info("Received CombinationsFileChangedNotification for combinations file: "
+ comboName);
Map<String, Integer> comboDict = loadCombinationsFile(comboName);
this.zoneSelector.updateCombos(comboDict);
applyButtonState(false);
}
Map<String, Integer> comboDict = loadCombinationsFile(comboName);
this.zoneSelector.updateCombos(comboDict);
applyButtonState(false);
}
@Override

View file

@ -74,8 +74,9 @@ import com.raytheon.viz.gfe.smarttool.script.SmartToolRunnerController;
* Jul 23, 2015 4263 dgilling Support SmartToolMetadataManager.
* 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
* Oct 08, 2015 18125 bhunder Modified CANCEL_MSG_START to work with Jep updates
* Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API.
* Apr 20, 2016 5593 randerso Fixed issue with running tool with no grids left parm immutable
*
* </pre>
*
@ -433,37 +434,41 @@ public class Tool {
startedParmEdit = false;
// Determine the pre, execute, and post methods to call
// If present, instantiate Tool class
// Check the tool modes to make sure they make sense
boolean saveParams = false;
int numberOfGrids = 0;
try {
/*
* Make sure parm is mutable.
*
* This should be done first so saveMutableFlag is set before
* cleanUp is run
*/
if (parmToEdit != null) {
saveMutableFlag = this.inputParm.isMutable();
this.inputParm.setMutable(true);
}
/*
* varDict must be set before returning from execute to prevent
* errors attempting to retrieve the updated contents
*/
tool.setVarDict(varDict);
// Get the gridInventory for the timeRange
IGridData[] grids = this.inputParm.getGridInventory(timeRange);
if (grids.length == 0) {
numberOfGrids = grids.length;
if (numberOfGrids == 0) {
String message = "Smart Tool " + toolName
+ ": No Grids To Edit for "
+ inputParm.expressionName();
statusHandler.handle(Priority.EVENTA, message);
return;
}
numberOfGrids = grids.length;
// Make sure parm is mutable
if (parmToEdit != null) {
saveMutableFlag = this.inputParm.isMutable();
this.inputParm.setMutable(true);
}
// Clear missing grids
GridCycler.getInstance().clearMissingData();
// # PreProcess Tool
// PreProcess Tool
handlePreAndPostProcess("preProcessTool", null, timeRange,
editArea, dataMode);
statusHandler.handle(Priority.DEBUG, "Running smartTool: "
@ -477,11 +482,6 @@ public class Tool {
return;
}
// # Show progress on a grid basis for numeric and parm-based
// if toolType == "numeric" or toolType == "parm-based":
// percent = (index+1)/numberOfGrids * 100.0
// AFPS.ProgressBarMsg_send_mh(self.__msgHand, "SmartTool",
// percent)
if (!grid.isOkToEdit() && (parmToEdit != null)) {
String message = "Smart Tool " + toolName
+ ": Encountered locked grid. ";
@ -556,7 +556,7 @@ public class Tool {
}
} // end of grids for loop
// # PostProcess Tool
// PostProcess Tool
handlePreAndPostProcess("postProcessTool", null, timeRange,
trueEditArea, dataMode);
saveParams = true;

View file

@ -22,6 +22,10 @@ package com.raytheon.viz.gfe.textformatter;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -38,7 +42,6 @@ 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;
@ -59,8 +62,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.util.FileUtil;
import com.raytheon.viz.gfe.GFEException;
import com.raytheon.viz.gfe.core.DataManagerUIFactory;
import com.raytheon.uf.common.util.StringUtil;
import com.raytheon.viz.gfe.textformatter.CombinationsFileUtil.ComboData.Entry;
/**
@ -84,6 +86,7 @@ import com.raytheon.viz.gfe.textformatter.CombinationsFileUtil.ComboData.Entry;
* 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.
* Apr 25, 2016 #5605 randerso Switched back to writing combinations file using Localization
*
* </pre>
*
@ -97,7 +100,8 @@ public class CombinationsFileUtil {
private static final int MAX_TRIES = 2;
public static String COMBO_DIR_PATH = FileUtil.join("gfe", "combinations");
public static String COMBINATIONS_DIR_PATH = FileUtil.join("gfe",
"combinations");
public static String SAVED_COMBO_DIR = FileUtil.join("gfe", "comboData");
@ -133,8 +137,7 @@ public class CombinationsFileUtil {
}
public ComboData(Map<String, Integer> comboDict) {
this.combos = new ArrayList<CombinationsFileUtil.ComboData.Entry>(
comboDict.size());
this.combos = new ArrayList<>(comboDict.size());
for (java.util.Map.Entry<String, Integer> entry : comboDict
.entrySet()) {
this.combos.add(new Entry(entry.getKey(), entry.getValue()));
@ -219,7 +222,7 @@ public class CombinationsFileUtil {
try (InputStream in = lf.openInputStream()) {
ComboData comboData = jaxb.unmarshalFromInputStream(in);
Map<String, Integer> comboDict = new HashMap<String, Integer>(
Map<String, Integer> comboDict = new HashMap<>(
comboData.combos.size());
for (Entry entry : comboData.combos) {
comboDict.put(entry.zone, entry.group);
@ -237,18 +240,18 @@ public class CombinationsFileUtil {
// retrieve combinations file if it's changed
LocalizationFile lf = pm.getStaticLocalizationFile(
LocalizationType.CAVE_STATIC,
FileUtil.join(COMBO_DIR_PATH, comboName + ".py"));
FileUtil.join(COMBINATIONS_DIR_PATH, comboName + ".py"));
File pyFile = null;
if (lf != null) {
try {
// get the local .py file
pyFile = lf.getFile(false);
// delete both the local .py and .pyo files to force retrieval
// delete both the local .py and .pyc files to force retrieval
// and regeneration
pyFile.delete();
File pyoFile = new File(pyFile.getPath() + "o");
pyoFile.delete();
File pycFile = new File(pyFile.getPath() + "c");
pycFile.delete();
// retrieve the .py file
pyFile = lf.getFile(true);
@ -270,14 +273,14 @@ public class CombinationsFileUtil {
.getPath(), "CombinationsInterface.py");
List<List<String>> combos = null;
HashMap<String, Object> map = new HashMap<String, Object>();
HashMap<String, Object> map = new HashMap<>();
map.put("comboName", comboName);
for (int retryCount = 0; retryCount < MAX_TRIES; retryCount++) {
try (PythonScript python = new PythonScript(
scriptPath,
PyUtil.buildJepIncludePath(
GfePyIncludeUtil.getCombinationsIncludePath(),
PythonIncludePathUtil.getCommonPythonIncludePath()),
GfePyIncludeUtil.getCommonPythonIncludePath()),
CombinationsFileUtil.class.getClassLoader())) {
Object com = python.execute("getCombinations", map);
combos = (List<List<String>>) com;
@ -285,8 +288,8 @@ public class CombinationsFileUtil {
// if successfully retrieved break out of the loop
break;
} catch (JepException e) {
// remove the .pyo file
new File(pyFile.getAbsolutePath() + "o").delete();
// remove the .pyc file
new File(pyFile.getAbsolutePath() + "c").delete();
// if not last try, log and try again
if (retryCount < (MAX_TRIES - 1)) {
@ -309,27 +312,53 @@ public class CombinationsFileUtil {
* Generates combinations files based on just running the formatter
*
* @param zoneGroupList
* @param filename
* @throws GFEException
* @param comboName
* @throws Exception
* @throws IOException
*/
public static void generateAutoCombinationsFile(
List<List<String>> zoneGroupList, String filename)
throws GFEException {
IFPClient ifpc = DataManagerUIFactory.getCurrentInstance().getClient();
SaveCombinationsFileRequest req = new SaveCombinationsFileRequest();
req.setFileName(filename);
req.setCombos(zoneGroupList);
List<List<String>> zoneGroupList, String comboName)
throws Exception {
statusHandler.info("Saving combinations file: " + filename);
ServerResponse<?> sr = ifpc.makeRequest(req);
if (sr.isOkay()) {
statusHandler.info("Successfully saved combinations file: "
+ filename);
} else {
String message = String.format(
"Error saving combinations file %s: %s", filename,
sr.message());
throw new GFEException(message);
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext localization = pm.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.SITE);
String fileName = FileUtil.join(COMBINATIONS_DIR_PATH, comboName)
+ ".py";
LocalizationFile lf = pm.getLocalizationFile(localization, fileName);
try (SaveableOutputStream stream = lf.openOutputStream();
Writer outWriter = new OutputStreamWriter(stream)) {
String zoneComments = "\n# Automatically generated combinations file\n# "
+ comboName + "\n\nCombinations = [\n";
outWriter.write(zoneComments);
NumberFormat df = new DecimalFormat("00");
for (int i = 0; i < zoneGroupList.size(); i++) {
StringBuilder nextLineToWrite = new StringBuilder();
List<String> modZGL = new ArrayList<>(zoneGroupList.get(i)
.size());
for (String zone : zoneGroupList.get(i)) {
modZGL.add("'" + zone + "'");
}
nextLineToWrite.append("\t([");
nextLineToWrite.append(StringUtil.join(modZGL, ','));
nextLineToWrite.append("], ");
nextLineToWrite.append("'Region");
nextLineToWrite.append(df.format(i + 1));
nextLineToWrite.append("' ),\n");
outWriter.write(nextLineToWrite.toString());
}
outWriter.write("]");
outWriter.close();
stream.save();
} catch (Exception e) {
statusHandler.error("Error saving combinations file: " + fileName,
e);
}
}
}

View file

@ -25,6 +25,8 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import com.raytheon.viz.ui.dialogs.ICloseCallback;
/**
* Action to display the Get Apps Defaults or SHEF Apps Defaults dialog.
*
@ -38,6 +40,7 @@ import org.eclipse.ui.PlatformUI;
* Dec 06, 2012 1353 rferrel Changes for non blocking GetAppsDefaults.
* Changes for non blocking SHEFAppsDefaultsDlg.
* Mar 27, 2013 1790 rferrel Bug fix for non-blocking dialogs.
* Apr 08, 2016 5483 dgilling Bug fixes for SHEFAppsDefaultsDlg.
*
* </pre>
*
@ -50,13 +53,6 @@ public class AppsDefaultsAction extends AbstractHandler {
private SHEFAppsDefaultsDlg dlg;
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
* ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
@ -70,8 +66,15 @@ public class AppsDefaultsAction extends AbstractHandler {
gad.bringToTop();
}
} else {
if (dlg == null || dlg.isDisposed()) {
if ((dlg == null) || (dlg.isDisposed())) {
dlg = new SHEFAppsDefaultsDlg(shell);
dlg.addCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
dlg = null;
}
});
dlg.open();
} else {
dlg.bringToTop();

View file

@ -19,32 +19,39 @@
**/
package com.raytheon.viz.hydro.appsdefaults;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Collection;
import java.util.Collections;
import javax.xml.bind.JAXB;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import com.raytheon.uf.common.localization.ILocalizationFile;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.ohd.AppsDefaults;
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.ui.dialogs.CaveSWTDialog;
import com.raytheon.uf.common.util.Pair;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
/**
* Dialog displaying the current Apps_defaults settings for the SHEF Decoder.
@ -59,6 +66,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Dec 07, 2012 1353 rferrel Make non-blocking dialog.
* Aug 09, 2013 2033 mschenke Switched File.separator to IPathManager.SEPARATOR
* Nov 04, 2013 2361 njensen Use JAXB instead of SerializationUtil
* Apr 08, 2016 5483 dgilling Refactor based on CaveJFACEDialog, fix
* hi-dpi issues.
*
* </pre>
*
@ -66,24 +75,13 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0
*/
public class SHEFAppsDefaultsDlg extends CaveSWTDialog {
public final class SHEFAppsDefaultsDlg extends CaveJFACEDialog {
private static final String CONFIG_FILE_NAME = "hydro"
+ IPathManager.SEPARATOR + "shefGadTokens.xml";
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(SHEFAppsDefaultsDlg.class);
private final String CONFIG_FILE_NAME = "hydro" + IPathManager.SEPARATOR
+ "shefGadTokens.xml";
/**
* Font used in the dialog.
*/
private Font font;
/**
* The text area.
*/
private StyledText textArea;
private List<String> tokenList = new ArrayList<String>();
.getHandler(getClass());
/**
* Constructor.
@ -92,110 +90,138 @@ public class SHEFAppsDefaultsDlg extends CaveSWTDialog {
* Parent shell.
*/
public SHEFAppsDefaultsDlg(Shell parent) {
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
setText("SHEF Apps_defaults Settings");
populateTokenList();
super(parent);
setBlockOnOpen(false);
setShellStyle(SWT.DIALOG_TRIM);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
@Override
protected void initializeComponents(final Shell shell) {
setReturnValue(false);
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
font = new Font(shell.getDisplay(), "Monospace", 11, SWT.NORMAL);
final Table table = new Table(composite, SWT.BORDER | SWT.MULTI
| SWT.FULL_SELECTION | SWT.V_SCROLL);
table.setLinesVisible(false);
table.setHeaderVisible(true);
table.addKeyListener(new KeyAdapter() {
// Initialize the labels
Composite labelComp = new Composite(shell, SWT.NONE);
GridLayout gl = new GridLayout(2, false);
labelComp.setLayout(gl);
GridData gd = new GridData(245, SWT.DEFAULT);
Label idLbl = new Label(labelComp, SWT.NONE);
idLbl.setLayoutData(gd);
idLbl.setText("Token");
Label nameLbl = new Label(labelComp, SWT.NONE);
nameLbl.setText("Value");
nameLbl.setLayoutData(gd);
// Initialize text area
GridData gd2 = new GridData(SWT.FILL, SWT.FILL, true, true);
gd2.widthHint = 650;
gd2.heightHint = 500;
textArea = new StyledText(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL
| SWT.H_SCROLL);
textArea.setFont(font);
textArea.setEditable(false);
textArea.setLayoutData(gd2);
// Add a close button
Composite centeredComp = new Composite(shell, SWT.NONE);
GridLayout gl2 = new GridLayout(1, false);
centeredComp.setLayout(gl2);
GridData gd3 = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
centeredComp.setLayoutData(gd3);
Button closeBtn = new Button(centeredComp, SWT.NONE);
closeBtn.setText("Close");
closeBtn.setLayoutData(gd);
closeBtn.setLayoutData(gd3);
closeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
shell.dispose();
public void keyPressed(KeyEvent e) {
if ((e.keyCode == 'c') && (e.stateMask == SWT.CTRL)) {
StringBuilder sb = new StringBuilder();
for (TableItem item : table.getSelection()) {
sb.append(String.format("%-26s %s", item.getText(0),
item.getText(1)));
sb.append('\n');
}
sb.deleteCharAt(sb.length() - 1);
Clipboard clipboard = new Clipboard(e.display);
clipboard.setContents(new Object[] { sb.toString() },
new Transfer[] { TextTransfer.getInstance() });
}
}
});
populateDlg();
}
private void populateDlg() {
AppsDefaults ad = AppsDefaults.getInstance();
String format = "%-26s %s";
StringBuilder sb = new StringBuilder();
for (String s : tokenList) {
sb.append(String.format(format, s, ad.getToken(s) + "\n"));
String[] titles = { "Token", "Value" };
for (String title : titles) {
TableColumn column = new TableColumn(table, SWT.LEFT);
column.setText(title);
}
this.textArea.setText(sb.toString());
int maxTokenLen = -Integer.MAX_VALUE;
int maxValueLen = -Integer.MAX_VALUE;
for (Pair<String, String> entry : getTableEntries()) {
TableItem item = new TableItem(table, SWT.NONE);
item.setFont(JFaceResources.getTextFont());
String token = String.valueOf(entry.getFirst());
maxTokenLen = Math.max(maxTokenLen, token.length());
item.setText(0, token);
String value = String.valueOf(entry.getSecond());
maxValueLen = Math.max(maxValueLen, value.length());
item.setText(1, value);
}
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = table.getHeaderHeight()
+ (table.getItemHeight() * table.getItemCount());
GC gc = new GC(table);
gc.setFont(JFaceResources.getTextFont());
gd.widthHint = (maxTokenLen + maxValueLen + 4)
* gc.getFontMetrics().getAverageCharWidth();
gc.dispose();
table.setLayoutData(gd);
for (int i = 0; i < table.getColumnCount(); i++) {
table.getColumn(i).pack();
}
return composite;
}
private void populateTokenList() {
@Override
protected void buttonPressed(int buttonId) {
switch (buttonId) {
case IDialogConstants.CLOSE_ID:
close();
break;
default:
statusHandler.warn(String.format(
"Unrecognized button [%d] pressed.", buttonId));
break;
}
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.CLOSE_ID,
IDialogConstants.CLOSE_LABEL, true);
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("SHEF Apps_defaults Settings");
}
private Collection<Pair<String, String>> getTableEntries() {
Collection<String> tokenList = getTokenList();
Collection<Pair<String, String>> entries = new ArrayList<>(
tokenList.size());
AppsDefaults ad = AppsDefaults.getInstance();
for (String s : tokenList) {
entries.add(new Pair<String, String>(s, ad.getToken(s)));
}
return entries;
}
private Collection<String> getTokenList() {
Collection<String> tokenList = Collections.emptyList();
// Read in the xml
statusHandler.debug("Searching for " + CONFIG_FILE_NAME);
IPathManager pm = PathManagerFactory.getPathManager();
System.out.println("Searching for " + CONFIG_FILE_NAME);
File file = pm.getStaticFile(this.CONFIG_FILE_NAME);
ILocalizationFile file = pm.getStaticLocalizationFile(CONFIG_FILE_NAME);
if (file != null) {
try {
SHEFAppsDefaultsXML xml = JAXB.unmarshal(file,
try (InputStream inStream = file.openInputStream()) {
SHEFAppsDefaultsXML xml = JAXB.unmarshal(inStream,
SHEFAppsDefaultsXML.class);
tokenList = new ArrayList<>();
for (String token : xml.getTokenList()) {
tokenList.add(token);
}
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getMessage(), e);
statusHandler.error(String.format("Error reading file [%s]",
CONFIG_FILE_NAME), e);
}
} else {
MessageBox messageBox = new MessageBox(this.getParent(), SWT.ERROR);
messageBox.setText("File Not Found");
messageBox.setMessage("shefGadTokens.xml file not found.");
messageBox.open();
MessageDialog.openError(getShell(), "File Not Found",
"shefGadTokens.xml file not found.");
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
protected void disposed() {
font.dispose();
return tokenList;
}
}

View file

@ -26,7 +26,9 @@ 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.viz.ui.dialogs.ICloseCallback;
/**
* Action for unimplemented features. To be used temporarily until final
@ -41,6 +43,7 @@ import org.eclipse.ui.PlatformUI;
* 6/27/06 lvenable Initial Creation.
* 2/06/2013 1578 rferrel Change for non-blocking DataTrashCanDlg.
* 2/27/2013 1790 rferrel Bug fix for non-blocking dialogs.
* 4/15/2016 5483 dgilling Support changes to DataTrashCanDlg.
*
* </pre>
*
@ -52,19 +55,18 @@ public class DataTrashCanAction extends AbstractHandler {
/** The dialog to display */
private DataTrashCanDlg dataTrashCanDlg;
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
* .ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
if (dataTrashCanDlg == null || dataTrashCanDlg.isDisposed()) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
Shell shell = HandlerUtil.getActiveShellChecked(arg0);
dataTrashCanDlg = new DataTrashCanDlg(shell);
dataTrashCanDlg.addCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
dataTrashCanDlg = null;
}
});
dataTrashCanDlg.open();
} else {
dataTrashCanDlg.bringToTop();

View file

@ -24,9 +24,10 @@ 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.viz.hydrocommon.HydroDisplayManager;
import com.raytheon.viz.ui.dialogs.ICloseCallback;
/**
* Action for Product Viewer Dialog.
@ -41,6 +42,7 @@ import com.raytheon.viz.hydrocommon.HydroDisplayManager;
* 02/07/2013 1578 rferrel Changes for non-blocking ProductViewerDlg.
* 03/27/2013 1790 rferrel Bug fix for non-blocking dialogs.
* 06/19/2013 2119 rferrel Changed check for no selected lid.
* 04/12/2016 5483 dgilling Fixes to support changes to ProductViewerDlg.
*
* </pre>
*
@ -51,22 +53,21 @@ public class ProductViewerAction extends AbstractHandler {
/** Instance of the dialog. */
ProductViewerDlg dialog;
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
* .ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
HydroDisplayManager manager = HydroDisplayManager.getInstance();
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
Shell shell = HandlerUtil.getActiveShellChecked(arg0);
if (manager.isCurrentLidSelected(shell)) {
if (dialog == null || dialog.isDisposed()) {
dialog = new ProductViewerDlg(shell);
dialog.addCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
dialog = null;
}
});
dialog.open();
} else {
dialog.setLid(manager.getCurrentLid());
@ -75,5 +76,4 @@ public class ProductViewerAction extends AbstractHandler {
}
return null;
}
}

View file

@ -20,36 +20,38 @@
package com.raytheon.viz.hydro.productviewer;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.GC;
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.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.viz.hydro.productviewer.ProductViewerConstants.ProdListType;
import com.raytheon.viz.hydro.productviewer.ProductViewerConstants.SortType;
import com.raytheon.viz.hydrocommon.HydroDisplayManager;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
/**
* This class displays the Product Viewer dialog for HydroView.
@ -66,6 +68,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* in AWIPS 1
* 02/07/2013 1578 rferrel Make dialog non-blocking.
* 06/19/2013 2119 rferrel Remove no longer needed shouldOpen.
* 04/12/2016 5483 dgilling Refactor based on CaveJFACEDialog,
* cleanup hi-dpi issues.
*
* </pre>
*
@ -73,26 +77,15 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0
*
*/
public class ProductViewerDlg extends CaveSWTDialog {
/**
* Dialog's location and size.
*/
private static Rectangle bounds;
public class ProductViewerDlg extends CaveJFACEDialog {
/**
* Font used for the list and text controls.
*/
private Font font;
/**
* Sash form used to allow resizing parts of the dialog.
*/
private SashForm sashForm;
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(getClass());
/**
* List displaying product information.
*/
private List prodInfoListWidget;
private Table prodInfoTable;
/**
* List combo box.
@ -119,11 +112,6 @@ public class ProductViewerDlg extends CaveSWTDialog {
*/
private StyledText textViewer;
/**
* ProductInfo data structure list.
*/
private java.util.List<ProductInfo> productInfoList = null;
/**
* Constructor.
*
@ -131,184 +119,123 @@ public class ProductViewerDlg extends CaveSWTDialog {
* Parent shell.
*/
public ProductViewerDlg(Shell parent) {
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
setText("Product Viewer");
super(parent);
setShellStyle(SWT.DIALOG_TRIM);
setBlockOnOpen(false);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
@Override
protected Layout constructShellLayout() {
// Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, false);
mainLayout.marginHeight = 3;
mainLayout.marginWidth = 3;
return mainLayout;
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("Product Viewer");
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
protected void disposed() {
font.dispose();
}
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
*/
@Override
protected void preOpened() {
super.preOpened();
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent e) {
bounds = shell.getBounds();
}
});
if (bounds != null) {
shell.setBounds(bounds);
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
@Override
protected void initializeComponents(Shell shell) {
font = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
sashForm = new SashForm(shell, SWT.VERTICAL);
SashForm sashForm = new SashForm(composite, SWT.VERTICAL);
sashForm.setLayout(new FillLayout());
sashForm.SASH_WIDTH = 10;
createProductInformationGroup();
createProductInformationGroup(sashForm);
createTextViewerControl();
createCloseButton();
createTextViewerControl(sashForm);
sashForm.setWeights(new int[] { 1, 2 });
String lid = HydroDisplayManager.getInstance().getCurrentLid();
if ((lid != null) && (lid.length() > 0)) {
setReturnValue(lid);
selectedLocTF.setText(lid);
}
loadProductList();
return composite;
}
/**
* Create the Product Information group container.
*
* @param parent
*/
private void createProductInformationGroup() {
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
Group productInfoGroup = new Group(sashForm, SWT.NONE);
GridLayout gl = new GridLayout(2, false);
productInfoGroup.setLayout(gl);
productInfoGroup.setLayoutData(gd);
private void createProductInformationGroup(Composite parent) {
Group productInfoGroup = new Group(parent, SWT.NONE);
productInfoGroup.setText("Product Information");
productInfoGroup.setLayout(new GridLayout(2, false));
productInfoGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
true));
// -----------------------------------------------
// Create the LEFT side (list box and labels)
// Create the LEFT side (TABLE)
// -----------------------------------------------
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
Composite leftComp = new Composite(productInfoGroup, SWT.NONE);
gl = new GridLayout(3, false);
leftComp.setLayout(gl);
leftComp.setLayoutData(gd);
prodInfoTable = new Table(productInfoGroup, SWT.SINGLE
| SWT.FULL_SELECTION | SWT.V_SCROLL);
prodInfoTable.setLinesVisible(false);
prodInfoTable.setHeaderVisible(true);
String[] headerTitles = new String[] { "Product Id", "Product Time",
"Posting Time" };
for (String title : headerTitles) {
TableColumn column = new TableColumn(prodInfoTable, SWT.LEFT);
column.setText(title);
}
prodInfoTable.addSelectionListener(new SelectionAdapter() {
gd = new GridData(120, SWT.DEFAULT);
Label prodIdLbl = new Label(leftComp, SWT.NONE);
prodIdLbl.setText("Product Id");
prodIdLbl.setLayoutData(gd);
gd = new GridData(150, SWT.DEFAULT);
Label prodTimeLbl = new Label(leftComp, SWT.NONE);
prodTimeLbl.setText("Product Time");
prodTimeLbl.setLayoutData(gd);
gd = new GridData(100, SWT.DEFAULT);
Label postTimeLbl = new Label(leftComp, SWT.NONE);
postTimeLbl.setText("Posting Time");
postTimeLbl.setLayoutData(gd);
gd = new GridData(SWT.DEFAULT, SWT.FILL, false, true);
gd.heightHint = 150;
gd.widthHint = 450;
gd.horizontalSpan = 3;
prodInfoListWidget = new List(leftComp, SWT.BORDER | SWT.SINGLE
| SWT.V_SCROLL);
prodInfoListWidget.setLayoutData(gd);
prodInfoListWidget.setFont(font);
prodInfoListWidget.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
displaySelectedItem();
public void widgetSelected(SelectionEvent e) {
// Get the data from the list.
ProductInfo prodInfo = (ProductInfo) e.widget.getData();
if (prodInfo == null) {
prodInfo = (ProductInfo) prodInfoTable.getItem(
prodInfoTable.getSelectionIndex()).getData();
}
// Get the text product
ProductViewerDataManager dataManager = ProductViewerDataManager
.getInstance();
String product = dataManager.getTextProduct(prodInfo);
textViewer.setText(product);
}
});
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = prodInfoTable.getHeaderHeight()
+ (prodInfoTable.getItemHeight() * 7);
GC gc = new GC(prodInfoTable);
gc.setFont(JFaceResources.getTextFont());
gd.widthHint = gc.getFontMetrics().getAverageCharWidth() * 55;
gc.dispose();
prodInfoTable.setLayoutData(gd);
// -----------------------------------------------
// Create the RIGHT side (list box and labels)
// -----------------------------------------------
gd = new GridData(SWT.FILL, SWT.TOP, true, true);
Composite rightComp = new Composite(productInfoGroup, SWT.NONE);
gl = new GridLayout(2, false);
gl.verticalSpacing = 10;
rightComp.setLayout(gl);
rightComp.setLayoutData(gd);
rightComp.setLayout(new GridLayout(2, false));
rightComp.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
int labelWidth = 130;
gd = new GridData(labelWidth, SWT.DEFAULT);
Label listLbl = new Label(rightComp, SWT.RIGHT);
Label listLbl = new Label(rightComp, SWT.NONE);
listLbl.setText("List:");
listLbl.setLayoutData(gd);
listLbl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, true));
gd = new GridData(275, SWT.DEFAULT);
listCbo = new Combo(rightComp, SWT.DROP_DOWN | SWT.READ_ONLY);
listCbo.add(ProdListType.LOCATION.getStringValue());
listCbo.add(ProdListType.LATEST.getStringValue());
listCbo.add(ProdListType.ALL.getStringValue());
for (ProdListType prodType : ProdListType.values()) {
listCbo.add(prodType.getStringValue());
}
listCbo.select(0);
listCbo.setLayoutData(gd);
listCbo.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
loadProductList();
}
});
gd = new GridData(labelWidth, SWT.DEFAULT);
Label selectedLocLbl = new Label(rightComp, SWT.RIGHT);
Label selectedLocLbl = new Label(rightComp, SWT.NONE);
selectedLocLbl.setText("Selected Location:");
selectedLocLbl.setLayoutData(gd);
selectedLocLbl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
true));
gd = new GridData(110, SWT.DEFAULT);
selectedLocTF = new Text(rightComp, SWT.BORDER);
selectedLocTF.setLayoutData(gd);
String lid = HydroDisplayManager.getInstance().getCurrentLid();
if ((lid != null) && (!lid.isEmpty())) {
selectedLocTF.setText(lid);
}
selectedLocTF.addVerifyListener(new VerifyListener() {
@Override
@ -316,21 +243,24 @@ public class ProductViewerDlg extends CaveSWTDialog {
e.text = e.text.toUpperCase();
}
});
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gc = new GC(selectedLocTF);
gd.widthHint = gc.getFontMetrics().getAverageCharWidth() * 8;
gc.dispose();
selectedLocTF.setLayoutData(gd);
// Add a separator line
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 4;
Label sepLbl = new Label(rightComp, SWT.SEPARATOR | SWT.HORIZONTAL);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gd.horizontalSpan = 2;
sepLbl.setLayoutData(gd);
gd = new GridData(labelWidth, SWT.DEFAULT);
Label prodIdFilterLbl = new Label(rightComp, SWT.RIGHT);
Label prodIdFilterLbl = new Label(rightComp, SWT.NONE);
prodIdFilterLbl.setText("Product Id Filter:");
prodIdFilterLbl.setLayoutData(gd);
prodIdFilterLbl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
false, true));
gd = new GridData(110, SWT.DEFAULT);
prodIdFilterTF = new Text(rightComp, SWT.BORDER);
prodIdFilterTF.setLayoutData(gd);
prodIdFilterTF.addVerifyListener(new VerifyListener() {
@Override
@ -338,22 +268,26 @@ public class ProductViewerDlg extends CaveSWTDialog {
e.text = e.text.toUpperCase();
}
});
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gc = new GC(prodIdFilterTF);
gd.widthHint = gc.getFontMetrics().getAverageCharWidth() * 15;
gc.dispose();
prodIdFilterTF.setLayoutData(gd);
gd = new GridData(labelWidth, SWT.DEFAULT);
Label sortByLbl = new Label(rightComp, SWT.RIGHT);
Label sortByLbl = new Label(rightComp, SWT.NONE);
sortByLbl.setText("Sort By:");
sortByLbl.setLayoutData(gd);
sortByLbl
.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, true));
gd = new GridData(150, SWT.DEFAULT);
sortByCbo = new Combo(rightComp, SWT.DROP_DOWN | SWT.READ_ONLY);
sortByCbo.add(SortType.PROD_ID.getStringValue());
sortByCbo.add(SortType.PROD_TIME.getStringValue());
sortByCbo.add(SortType.POST_TIME.getStringValue());
for (SortType sortType : SortType.values()) {
sortByCbo.add(sortType.getStringValue());
}
sortByCbo.select(0);
sortByCbo.setLayoutData(gd);
sortByCbo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
public void widgetSelected(SelectionEvent e) {
loadProductList();
}
});
@ -361,21 +295,21 @@ public class ProductViewerDlg extends CaveSWTDialog {
/**
* Create the text viewer control.
*
* @param parent
*/
private void createTextViewerControl() {
GridData gd = new GridData(GridData.FILL_BOTH);
Composite textViewerComp = new Composite(sashForm, SWT.NONE);
GridLayout gridLayout = new GridLayout(1, false);
textViewerComp.setLayout(gridLayout);
textViewerComp.setLayoutData(gd);
private void createTextViewerControl(Composite parent) {
Composite textViewerComp = new Composite(parent, SWT.NONE);
textViewerComp.setLayout(new GridLayout(1, false));
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 400;
textViewer = new StyledText(textViewerComp, SWT.BORDER | SWT.MULTI
| SWT.V_SCROLL | SWT.H_SCROLL);
| SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
textViewer.setFont(JFaceResources.getTextFont());
textViewer.setWordWrap(true);
textViewer.setFont(font);
textViewer.setEditable(false);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
GC gc = new GC(textViewer);
gd.heightHint = gc.getFontMetrics().getHeight() * 25;
gc.dispose();
textViewer.setLayoutData(gd);
}
@ -391,28 +325,23 @@ public class ProductViewerDlg extends CaveSWTDialog {
}
}
/**
* Create the Close button.
*/
private void createCloseButton() {
Composite centeredComp = new Composite(shell, SWT.NONE);
GridLayout gl = new GridLayout(1, false);
centeredComp.setLayout(gl);
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.horizontalSpan = 2;
centeredComp.setLayoutData(gd);
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.CLOSE_ID,
IDialogConstants.CLOSE_LABEL, false);
}
gd = new GridData(90, SWT.DEFAULT);
Button closeBtn = new Button(centeredComp, SWT.NONE);
closeBtn.setText("Close");
closeBtn.setLayoutData(gd);
closeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
bounds = shell.getBounds();
close();
}
});
@Override
protected void buttonPressed(int buttonId) {
switch (buttonId) {
case IDialogConstants.CLOSE_ID:
close();
break;
default:
statusHandler.warn(String.format(
"Unrecognized button ID [%d] pressed.", buttonId));
break;
}
}
/**
@ -421,7 +350,6 @@ public class ProductViewerDlg extends CaveSWTDialog {
private void loadProductList() {
ProductViewerDataManager dataManager = ProductViewerDataManager
.getInstance();
SortType sortType = SortType.PROD_TIME;
/*
* load the list of products based on the user settings. load from the
@ -431,27 +359,26 @@ public class ProductViewerDlg extends CaveSWTDialog {
String prodFilter = prodIdFilterTF.getText();
if (sortByCbo.getItem(sortByCbo.getSelectionIndex()).equals(
SortType.PROD_TIME.getStringValue())) {
sortType = SortType.PROD_TIME;
} else if (sortByCbo.getItem(sortByCbo.getSelectionIndex()).equals(
SortType.POST_TIME.getStringValue())) {
sortType = SortType.POST_TIME;
} else if (sortByCbo.getItem(sortByCbo.getSelectionIndex()).equals(
SortType.PROD_ID.getStringValue())) {
sortType = SortType.PROD_ID;
SortType sortType = SortType.PROD_TIME;
String selectedSort = sortByCbo.getItem(sortByCbo.getSelectionIndex());
for (SortType sort : SortType.values()) {
if (sort.getStringValue().equals(selectedSort)) {
sortType = sort;
break;
}
}
/*
* if loading products for a given location, load from the ProductLink
* table
*/
List<ProductInfo> productInfoList;
if (listCbo.getItem(listCbo.getSelectionIndex()).equals(
ProdListType.LOCATION.getStringValue())) {
productInfoList = (ArrayList<ProductInfo>) dataManager
.getProductsByLocation(ProdListType.LOCATION, sortType,
prodFilter, selectedLocTF.getText());
productInfoList = dataManager.getProductsByLocation(
ProdListType.LOCATION, sortType, prodFilter,
selectedLocTF.getText());
} else if (listCbo.getItem(listCbo.getSelectionIndex()).equals(
ProdListType.LATEST.getStringValue())) {
@ -459,9 +386,9 @@ public class ProductViewerDlg extends CaveSWTDialog {
* if loading the latest of the products, load from the PurgeProduct
* table.
*/
productInfoList = (ArrayList<ProductInfo>) dataManager
.getLatestProducts(ProdListType.LATEST, sortType,
prodFilter, selectedLocTF.getText());
productInfoList = dataManager.getLatestProducts(
ProdListType.LATEST, sortType, prodFilter,
selectedLocTF.getText());
} else {
/*
* if loading all products, then load from the TextProduct table.
@ -474,43 +401,22 @@ public class ProductViewerDlg extends CaveSWTDialog {
* later
*/
productInfoList = (ArrayList<ProductInfo>) dataManager
.getAllProducts(ProdListType.ALL, sortType, prodFilter,
selectedLocTF.getText());
productInfoList = dataManager.getAllProducts(ProdListType.ALL,
sortType, prodFilter, selectedLocTF.getText());
}
// Populate the list
loadProductListInfo(productInfoList);
}
/**
* Load the product information into the widget.
*
* @param productInfoList
* List of ProductInfo objects to load into the list widget
*/
private void loadProductListInfo(java.util.List<ProductInfo> productInfoList) {
String[] listItems = new String[productInfoList.size()];
for (int i = 0; i < productInfoList.size(); i++) {
listItems[i] = productInfoList.get(i).toString();
prodInfoTable.removeAll();
for (ProductInfo info : productInfoList) {
TableItem item = new TableItem(prodInfoTable, SWT.NONE);
item.setFont(JFaceResources.getTextFont());
item.setText(0, info.getProductId());
item.setText(1, info.getProductTimeString());
item.setText(2, info.getPostingTimeString());
item.setData(info);
}
prodInfoListWidget.setItems(listItems);
}
/**
* Display the selected item.
*/
private void displaySelectedItem() {
// Get the data from the list.
ProductInfo prodInfo = productInfoList.get(prodInfoListWidget
.getSelectionIndex());
// Get the text product
ProductViewerDataManager dataManager = ProductViewerDataManager
.getInstance();
String product = dataManager.getTextProduct(prodInfo);
textViewer.setText(product);
for (int i = 0; i < prodInfoTable.getColumnCount(); i++) {
prodInfoTable.getColumn(i).pack();
}
}
}

View file

@ -26,7 +26,9 @@ 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.viz.ui.dialogs.CaveJFACEDialog;
/**
* Action for unimplemented features. To be used temporarily until final
@ -40,6 +42,7 @@ import org.eclipse.ui.PlatformUI;
* ------------ ---------- ----------- --------------------------
* 6/27/06 lvenable Initial Creation.
* 03/15/2013 1790 rferrel Changes for non-blocking RiverSummaryDlg.
* 04/08/2016 5483 dgilling Code cleanup.
*
* </pre>
*
@ -47,20 +50,12 @@ import org.eclipse.ui.PlatformUI;
*
*/
public class RiverSummaryAction extends AbstractHandler {
private RiverSummaryDlg riverSummaryDlg;
private CaveJFACEDialog riverSummaryDlg;
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
* .ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
if (riverSummaryDlg == null || riverSummaryDlg.isDisposed()) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
if ((riverSummaryDlg == null) || (!riverSummaryDlg.isOpen())) {
Shell shell = HandlerUtil.getActiveShellChecked(arg0);
riverSummaryDlg = new RiverSummaryDlg(shell);
riverSummaryDlg.open();
} else {
@ -69,5 +64,4 @@ public class RiverSummaryAction extends AbstractHandler {
return null;
}
}

View file

@ -19,40 +19,44 @@
**/
package com.raytheon.viz.hydro.riversummary;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
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;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
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;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.viz.hydrocommon.HydroConstants;
import com.raytheon.viz.hydrocommon.HydroDisplayManager;
import com.raytheon.viz.hydrocommon.data.RiverDataPoint;
import com.raytheon.viz.hydrocommon.datamanager.RiverDataManager;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
/**
* This class displays the River Summary dialog for Hydroview.
@ -67,6 +71,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 08 Mar 2010 2486 mpduff Changed to open with the river for the
* selected site automatically selected.
* 15 Mar 2013 1790 rferrel Make dialog non-blocking.
* 08 Apr 2016 5483 dgilling Re-factor to fix hi-dpi issues.
*
* </pre>
*
@ -74,17 +79,30 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0
*
*/
public class RiverSummaryDlg extends CaveSWTDialog {
public class RiverSummaryDlg extends CaveJFACEDialog {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(getClass());
private static final String[] STAGE_BASIS_OPTIONS = { "Max Obs/Fcst",
"Observed", "Forecast" };
private static final int CANVAS_HEIGHT = 620;
private static final String STAGE_LABEL_TEXT = "Stage (if no graph)";
/**
* Y coordinate of the dashed flood line.
*/
private static final int FLOOD_LINE_YCOORD = (CANVAS_HEIGHT / 2) - 100;
private static final int INITIAL_X_POS = 30;
/**
* Maximum stage difference.
*/
private static final int MAX_STAGE_DIFF = 100;
/**
* Font used for SWT controls.
*/
private Font font;
/**
* Font used on the canvas display.
*/
@ -95,70 +113,37 @@ public class RiverSummaryDlg extends CaveSWTDialog {
*/
private List streamList;
/**
* List of stream names that coincide with the streamList widget.
*/
private java.util.List<String> streamNameList = new ArrayList<String>();
/**
* Stage basis combo box.
*/
private Combo stageBasisCbo;
/**
* Canvas displaying the labels for the river summaries.
*/
private Canvas labelCanvas;
/**
* Canvas displaying the river summaries.
*/
private Canvas riverSumCanvas;
/**
* Canvas height.
*/
private final int CANVAS_HEIGHT = 620;
/**
* Y coordinate of the dashed flood line.
*/
private final int FLOOD_LINE_YCOORD = (CANVAS_HEIGHT / 2) - 100;
/**
* Width of the label canvas.
*/
private final int LABEL_CANVAS_WIDTH = 120;
private int labelCanvasWidth;
/**
* Width of the river summary canvas.
*/
private final int RIVER_SUM_CANVAS_WIDTH = 2000;
private int riverSumCanvasWidth;
/**
* Width of the scrolled composite.
*/
private final int SCROLLED_COMP_WIDTH = 800;
/**
* Height of the scrolled composite.
*/
private final int SCROLLED_COMP_HEIGHT = CANVAS_HEIGHT;
private int itemWidth;
/**
* First time flag indicating if the canvases have been drawn on.
*/
private boolean firstTime = true;
private boolean firstTime;
/**
* Decimal Formatter
*/
private DecimalFormat df = new DecimalFormat();
/**
* Height of the canvas font.
*/
private int canvasFontHeight;
private NumberFormat df;
/**
* Y coordinate of the flood stage.
@ -188,22 +173,17 @@ public class RiverSummaryDlg extends CaveSWTDialog {
/**
* All rivers Data structure
*/
private Map<String, LinkedHashMap<String, RiverDataPoint>> riversData = null;
private Map<String, LinkedHashMap<String, RiverDataPoint>> riversData;
/**
* River Summary Data structure
*/
private Map<String, RiverDataPoint> riverData = null;
private Map<String, RiverDataPoint> riverData;
/**
* River datamanager instance
*/
private RiverDataManager rsdm = null;
/**
* Location and size of the dialog.
*/
Rectangle bounds;
private RiverDataManager rsdm;
/**
* Constructor.
@ -212,228 +192,156 @@ public class RiverSummaryDlg extends CaveSWTDialog {
* Parent shell.
*/
public RiverSummaryDlg(Shell parent) {
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
setText("River Summary");
super(parent);
setBlockOnOpen(false);
setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE);
this.rsdm = RiverDataManager.getInstance();
this.riverData = null;
this.firstTime = true;
this.df = NumberFormat.getNumberInstance();
this.df.setMinimumIntegerDigits(1);
this.df.setMaximumFractionDigits(2);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
protected void disposed() {
font.dispose();
canvasFont.dispose();
private void disposed(DisposeEvent e) {
if (canvasFont != null) {
canvasFont.dispose();
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
@Override
protected void initializeComponents(Shell shell) {
setReturnValue(false);
font = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
canvasFont = new Font(shell.getDisplay(), "Monospace", 8, SWT.NORMAL);
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
composite.setLayout(new GridLayout(2, false));
// Initialize all of the controls and layouts
createStreamListLabel();
createStreamListAndOptions();
fillStreamList();
createCanvasLabel();
createCanvasComposite();
createCloseButton();
createStreamListAndOptions(composite);
createCanvasComposite(composite);
setSelection();
}
/**
* Create label for the the stream list control.
*/
private void createStreamListLabel() {
Composite labelComp = new Composite(shell, SWT.NONE);
GridLayout gl = new GridLayout(1, false);
labelComp.setLayout(gl);
Label streamListLbl = new Label(labelComp, SWT.NONE);
streamListLbl.setText("Stream List");
return composite;
}
/**
* Create the stream list control and the options group and control.
*
* @param composite
*/
private void createStreamListAndOptions() {
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
Composite listOptionsComp = new Composite(shell, SWT.NONE);
GridLayout gl = new GridLayout(2, false);
gl.horizontalSpacing = 10;
listOptionsComp.setLayout(gl);
listOptionsComp.setLayoutData(gd);
private void createStreamListAndOptions(Composite parent) {
Label listLabel = new Label(parent, SWT.NONE);
listLabel.setText("Stream List");
listLabel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false,
2, 1));
gd = new GridData(475, 100);
streamList = new List(listOptionsComp, SWT.BORDER | SWT.SINGLE
| SWT.V_SCROLL);
streamList = new List(parent, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
streamList.setFont(JFaceResources.getTextFont());
streamList.setItems(getStreamList());
GC gc = new GC(streamList);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = streamList.getItemHeight() * 5;
gd.widthHint = gc.getFontMetrics().getAverageCharWidth() * 55;
gc.dispose();
streamList.setLayoutData(gd);
streamList.setFont(font);
streamList.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
int index = ((List) e.getSource()).getSelectionIndex();
int i = 0;
String riverKey = null;
for (String key : riversData.keySet()) {
if (i == index) {
riverKey = key;
break;
}
i++;
}
setRiverData(rsdm.populateRiverData(riverKey,
riversData.get(riverKey)));
// issue a paint event
riverSumCanvas.redraw();
}
streamList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = ((List) e.getSource()).getSelectionIndex();
int i = 0;
String riverKey = null;
for (String key : riversData.keySet()) {
if (i == index) {
riverKey = key;
break;
}
i++;
}
setRiverData(rsdm.populateRiverData(riverKey,
riversData.get(riverKey)));
// issue a paint event
updateRiverDataFromSelection(((List) e.getSource())
.getSelectionIndex());
riverSumCanvas.redraw();
}
});
// -------------------------------------------
// Create the Options group
// -------------------------------------------
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
Group productInfoGroup = new Group(listOptionsComp, SWT.NONE);
gl = new GridLayout(2, false);
productInfoGroup.setLayout(gl);
productInfoGroup.setLayoutData(gd);
productInfoGroup.setText(" Options ");
Group optionsGroup = new Group(parent, SWT.NONE);
optionsGroup.setText("Options");
optionsGroup.setLayout(new GridLayout(2, false));
optionsGroup.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false,
true));
Label stageLbl = new Label(productInfoGroup, SWT.NONE);
stageLbl.setText("Stage Basis:");
Label stageBasisLabel = new Label(optionsGroup, SWT.NONE);
stageBasisLabel.setText("Stage Basis:");
stageBasisLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
false));
gd = new GridData(150, SWT.DEFAULT);
stageBasisCbo = new Combo(productInfoGroup, SWT.DROP_DOWN
| SWT.READ_ONLY);
stageBasisCbo.add("Max Obs/Fcst");
stageBasisCbo.add("Observed");
stageBasisCbo.add("Forecast");
stageBasisCbo = new Combo(optionsGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
stageBasisCbo.setItems(STAGE_BASIS_OPTIONS);
stageBasisCbo.select(0);
stageBasisCbo.setLayoutData(gd);
stageBasisCbo.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// issue a paint event
riverSumCanvas.redraw();
}
stageBasisCbo.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT,
false, false));
stageBasisCbo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// issue a paint event
riverSumCanvas.redraw();
}
});
}
/**
* Create label above the label & river summary canvases.
*/
private void createCanvasLabel() {
Composite labelComp = new Composite(shell, SWT.NONE);
GridLayout gl = new GridLayout(1, false);
labelComp.setLayout(gl);
Label canvasLbl = new Label(labelComp, SWT.NONE);
canvasLbl.setText("Stations ordered by river mile");
}
/**
* Create the composite for the label & river summary canvases.
*
* @param composite
*/
private void createCanvasComposite() {
Composite canvasComp = new Composite(shell, SWT.NONE);
private void createCanvasComposite(Composite parent) {
Composite plotComposite = new Composite(parent, SWT.NONE);
GridLayout gl = new GridLayout(2, false);
gl.horizontalSpacing = 0;
canvasComp.setLayout(gl);
plotComposite.setLayout(gl);
plotComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
true, 2, 1));
addLabelCanvas(canvasComp);
addProfileCanvas(canvasComp);
}
Label stationsLabel = new Label(plotComposite, SWT.NONE);
stationsLabel.setText("Stations ordered by river mile");
stationsLabel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true,
false, 2, 1));
/**
* Add the label canvas to the canvas composite.
*
* @param canvasComp
* Canvas composite.
*/
private void addLabelCanvas(Composite canvasComp) {
labelCanvas = new Canvas(canvasComp, SWT.DOUBLE_BUFFERED);
GridData gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true);
canvasFont = new Font(plotComposite.getDisplay(), "Monospace", 8,
SWT.NORMAL);
Canvas labelCanvas = new Canvas(plotComposite, SWT.DOUBLE_BUFFERED);
labelCanvas.setFont(canvasFont);
GridData gd = new GridData(SWT.CENTER, SWT.FILL, false, true);
gd.heightHint = CANVAS_HEIGHT;
gd.widthHint = LABEL_CANVAS_WIDTH;
labelCanvas.setSize(LABEL_CANVAS_WIDTH, CANVAS_HEIGHT);
GC gc = new GC(labelCanvas);
labelCanvasWidth = gc.textExtent(STAGE_LABEL_TEXT + " ").x;
gd.widthHint = labelCanvasWidth;
gc.dispose();
labelCanvas.setLayoutData(gd);
labelCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
drawLabelCanvas(e);
}
});
}
/**
* Add the river summary profile canvas to the canvas composite.
*
* @param canvasComp
* Canvas composite.
*/
private void addProfileCanvas(Composite canvasComp) {
ScrolledComposite scrolledComp = new ScrolledComposite(canvasComp,
SWT.H_SCROLL | SWT.V_SCROLL);
GridLayout gl = new GridLayout(1, false);
scrolledComp.setLayout(gl);
GridData gd = new GridData(SCROLLED_COMP_WIDTH, SCROLLED_COMP_HEIGHT);
scrolledComp.setLayoutData(gd);
ScrolledComposite scrolledComp = new ScrolledComposite(plotComposite,
SWT.H_SCROLL);
scrolledComp.setLayout(new FillLayout());
riverSumCanvas = new Canvas(scrolledComp, SWT.DOUBLE_BUFFERED);
gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true);
gd.heightHint = CANVAS_HEIGHT;
gd.widthHint = RIVER_SUM_CANVAS_WIDTH;
riverSumCanvas.setSize(RIVER_SUM_CANVAS_WIDTH, CANVAS_HEIGHT);
riverSumCanvas.setFont(canvasFont);
gd = new GridData(SWT.LEFT, SWT.FILL, false, true);
gc = new GC(riverSumCanvas);
itemWidth = gc.textExtent(HydroConstants.DATE_FORMAT.toPattern()
+ " ").x;
gc.dispose();
riverSumCanvasWidth = (itemWidth * 15) + INITIAL_X_POS;
riverSumCanvas.setSize(riverSumCanvasWidth, CANVAS_HEIGHT);
riverSumCanvas.setLayoutData(gd);
riverSumCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
drawRiverSummaryCanvas(e);
}
});
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = CANVAS_HEIGHT;
gd.widthHint = (itemWidth * 6) + INITIAL_X_POS;
scrolledComp.setLayoutData(gd);
scrolledComp.setContent(riverSumCanvas);
}
@ -444,23 +352,19 @@ public class RiverSummaryDlg extends CaveSWTDialog {
* Paint event.
*/
private void drawLabelCanvas(PaintEvent e) {
e.gc.setFont(canvasFont);
if (firstTime == true) {
if (firstTime) {
calculateCoordinates(e.gc);
}
e.gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
e.gc.fillRectangle(0, 0, LABEL_CANVAS_WIDTH, CANVAS_HEIGHT);
e.gc.setBackground(e.display.getSystemColor(SWT.COLOR_BLACK));
e.gc.fillRectangle(0, 0, labelCanvasWidth, CANVAS_HEIGHT);
// -------------------------------------
// Draw dashed flood line
// -------------------------------------
e.gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_WHITE));
e.gc.setLineStyle(SWT.LINE_DOT);
e.gc.drawLine(0, FLOOD_LINE_YCOORD, RIVER_SUM_CANVAS_WIDTH,
FLOOD_LINE_YCOORD);
e.gc.drawLine(0, FLOOD_LINE_YCOORD, labelCanvasWidth, FLOOD_LINE_YCOORD);
e.gc.drawString("Flood Stage", 2, floodStgYCoord, true);
@ -480,36 +384,29 @@ public class RiverSummaryDlg extends CaveSWTDialog {
* Paint event.
*/
private void drawRiverSummaryCanvas(PaintEvent e) {
e.gc.setFont(canvasFont);
// ticInterval is used to determine max and min stages to be
// displayed by a particular station.
/*
* ticInterval is used to determine max and min stages to be displayed
* by a particular station.
*/
int ticInterval = 5;
if (firstTime == true) {
if (firstTime) {
calculateCoordinates(e.gc);
}
e.gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
e.gc.fillRectangle(0, 0, RIVER_SUM_CANVAS_WIDTH, CANVAS_HEIGHT);
e.gc.setBackground(e.display.getSystemColor(SWT.COLOR_BLACK));
e.gc.fillRectangle(0, 0, riverSumCanvasWidth, CANVAS_HEIGHT);
// -------------------------------------
// Draw dashed flood line
// -------------------------------------
e.gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_WHITE));
e.gc.setLineStyle(SWT.LINE_DOT);
e.gc.drawLine(0, FLOOD_LINE_YCOORD, RIVER_SUM_CANVAS_WIDTH,
e.gc.drawLine(0, FLOOD_LINE_YCOORD, riverSumCanvasWidth,
FLOOD_LINE_YCOORD);
if (getRiverData() != null) {
// must deal with x coordinate
// hardcoding an x offset of 175 to bring stations
// closer together, but this leaves empty space to the right
int xoffset = 135;
int x = 30; // starting point
df.setMinimumIntegerDigits(1);
df.setMaximumFractionDigits(2);
int x = INITIAL_X_POS; // starting point
for (String key : getRiverData().keySet()) {
if (getRiverData().containsKey(key)) {
@ -620,7 +517,7 @@ public class RiverSummaryDlg extends CaveSWTDialog {
e.gc.drawString(errorText, x, stageYCoord - 15, true);
}
x += xoffset;
x += itemWidth;
}
}
}
@ -633,65 +530,52 @@ public class RiverSummaryDlg extends CaveSWTDialog {
* Graphic component.
*/
private void calculateCoordinates(GC gc) {
canvasFontHeight = (gc.getFontMetrics().getHeight());
int fontHeight = gc.getFontMetrics().getHeight();
floodStgYCoord = FLOOD_LINE_YCOORD - canvasFontHeight - 2;
nameYCoord = CANVAS_HEIGHT - canvasFontHeight - 2;
idYCoord = nameYCoord - canvasFontHeight - 2;
dateYCoord = idYCoord - canvasFontHeight - 2;
stageYCoord = dateYCoord - canvasFontHeight - 2;
floodStgYCoord = FLOOD_LINE_YCOORD - fontHeight - 2;
nameYCoord = CANVAS_HEIGHT - fontHeight - 2;
idYCoord = nameYCoord - fontHeight - 2;
dateYCoord = idYCoord - fontHeight - 2;
stageYCoord = dateYCoord - fontHeight - 2;
firstTime = false;
}
/**
* Create the Close button.
*/
private void createCloseButton() {
Composite centeredComp = new Composite(shell, SWT.NONE);
GridLayout gl = new GridLayout(1, false);
centeredComp.setLayout(gl);
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.horizontalSpan = 2;
centeredComp.setLayoutData(gd);
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.CLOSE_ID,
IDialogConstants.CLOSE_LABEL, true);
}
gd = new GridData(90, SWT.DEFAULT);
Button closeBtn = new Button(centeredComp, SWT.NONE);
closeBtn.setText("Close");
closeBtn.setLayoutData(gd);
closeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
bounds = shell.getBounds();
close();
}
});
@Override
protected void buttonPressed(int buttonId) {
switch (buttonId) {
case IDialogConstants.CLOSE_ID:
close();
break;
default:
statusHandler.warn(String.format(
"Unrecognized button ID [%d] pressed.", buttonId));
break;
}
}
/**
* Populate teh stream list.
* Populate the stream list.
*/
private void fillStreamList() {
rsdm = RiverDataManager.getInstance();
private String[] getStreamList() {
riversData = rsdm.getRiverSummaryData();
String tmpStr;
String tmpStr2;
streamNameList.clear();
Collection<String> streamList = new ArrayList<>(riversData.size());
for (String id : riversData.keySet()) {
tmpStr2 = String.format("(%d stations)", riversData.get(id)
.keySet().size());
String name = null;
// extract the river name for display
for (String key : riversData.get(id).keySet()) {
name = riversData.get(id).get(key).getRiverName();
break;
}
tmpStr = String.format("%-40s %-13s", name, tmpStr2);
streamList.add(tmpStr);
streamNameList.add(name);
String first = riversData.get(id).keySet().iterator().next();
String name = riversData.get(id).get(first).getRiverName();
int numRecords = riversData.get(id).keySet().size();
String tmp = String.format("(%d stations)", numRecords);
streamList.add(String.format("%-40s %-13s", name, tmp));
}
return streamList.toArray(new String[0]);
}
/**
@ -702,16 +586,28 @@ public class RiverSummaryDlg extends CaveSWTDialog {
RiverDataPoint riverPoint = RiverDataManager.getInstance()
.getRiverDataPoint(lid);
for (int i = 0; i < streamNameList.size(); i++) {
if (streamNameList.get(i).equalsIgnoreCase(
riverPoint.getStreamName())) {
streamList.select(i);
streamList.showSelection();
break;
if ((riverPoint != null) && (riverPoint.getStreamName() != null)) {
for (int i = 0; i < streamList.getItemCount(); i++) {
if (streamList.getItem(i)
.startsWith(riverPoint.getStreamName())) {
streamList.select(i);
streamList.showSelection();
break;
}
}
}
int index = streamList.getSelectionIndex();
updateRiverDataFromSelection(streamList.getSelectionIndex());
// issue a paint event
riverSumCanvas.redraw();
}
private void updateRiverDataFromSelection(int index) {
if (index < 0) {
return;
}
int i = 0;
String riverKey = null;
for (String key : riversData.keySet()) {
@ -721,19 +617,7 @@ public class RiverSummaryDlg extends CaveSWTDialog {
}
i++;
}
setRiverData(rsdm.populateRiverData(riverKey, riversData.get(riverKey)));
// issue a paint event
riverSumCanvas.redraw();
}
/**
* Sets the data structure for this river.
*
* @param riverData
*/
private void setRiverData(Map<String, RiverDataPoint> riverData) {
this.riverData = riverData;
riverData = rsdm.populateRiverData(riverKey, riversData.get(riverKey));
}
/**
@ -745,24 +629,16 @@ public class RiverSummaryDlg extends CaveSWTDialog {
return riverData;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
*/
@Override
protected void preOpened() {
super.preOpened();
shell.addShellListener(new ShellAdapter() {
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("River Summary");
newShell.addDisposeListener(new DisposeListener() {
@Override
public void shellClosed(ShellEvent e) {
bounds = shell.getBounds();
public void widgetDisposed(DisposeEvent e) {
disposed(e);
}
});
if (bounds != null) {
shell.setBounds(bounds);
}
}
}

View file

@ -23,6 +23,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
@ -30,18 +32,14 @@ import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.GridData;
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.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.List;
@ -56,7 +54,6 @@ 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.viz.core.exception.VizException;
import com.raytheon.uf.viz.localization.LocalizationPerspectiveUtils;
import com.raytheon.uf.viz.localization.service.ILocalizationService;
@ -104,6 +101,7 @@ import com.raytheon.viz.hydrocommon.lowwaterstatment.LowWaterStatementDlg;
import com.raytheon.viz.hydrocommon.ratingcurve.RatingCurveDlg;
import com.raytheon.viz.hydrocommon.textreport.TextReportDataManager;
import com.raytheon.viz.hydrocommon.textreport.TextReportDlg;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.dialogs.ICloseCallback;
@ -167,6 +165,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Changes for non-blocking LowWaterStatementDlg.
* Changes for non-blocking RatingCurveDlg.
* Changes for non-blocking TextReportDlg.
* 04/11/2016 5483 dgilling Fix hard-coded layouts in HBPasswordDlg.
* 02/16/2016 5354 bkowal Prevent the closure of the password dialog from
* closing all of CAVE.
*
@ -2093,145 +2092,101 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
* Prompt for the password dialog box.
*/
protected boolean promptForPassword(Shell shell) {
HBPasswordDlg pwDlg = new HBPasswordDlg();
return pwDlg.open(shell);
HBPasswordDlg dialog = new HBPasswordDlg(shell);
int returnCode = dialog.open();
return ((returnCode == Window.OK) && (dialog.isVerified()));
}
/**
* Inner class for the password dialog.
*/
private class HBPasswordDlg {
private class HBPasswordDlg extends CaveJFACEDialog {
private final String password;
private Text text;
private Shell dialog;
private int numTries;
private int numTries = 0;
private boolean verified;
private boolean verified = false;
protected HBPasswordDlg(Shell parentShell) {
super(parentShell);
setShellStyle(SWT.DIALOG_TRIM);
setBlockOnOpen(true);
private String password = null;
public HBPasswordDlg() {
numTries = 0;
this.numTries = 0;
this.verified = false;
this.password = getPassword();
}
public boolean open(final Shell shell) {
Display display = shell.getDisplay();
password = getPassword();
verified = false;
if ((password == null) || (password.length() == 0)) {
// Show message
MessageBox messageBox = new MessageBox(shell, SWT.OK);
messageBox.setText("Password");
messageBox.setMessage("Please set a password for HydroBase\n"
+ "in the Setup/Administration dialog.");
messageBox.open();
@Override
public int open() {
if ((password == null) || (password.isEmpty())) {
MessageDialog.openInformation(getShell(), "Password",
"Please set a password for HydroBase\n"
+ "in the Setup/Administration dialog.");
}
return super.open();
}
dialog = new Shell(shell, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
dialog.setText("Enter Password");
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
composite.setLayout(new GridLayout(2, false));
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = 10;
formLayout.marginHeight = 10;
formLayout.spacing = 10;
dialog.setLayout(formLayout);
Label label = new Label(dialog, SWT.NONE);
Label label = new Label(composite, SWT.NONE);
label.setText("Enter Password:");
FormData data = new FormData();
label.setLayoutData(data);
label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true));
Button cancel = new Button(dialog, SWT.PUSH);
cancel.setText("Cancel");
data = new FormData();
data.width = 60;
data.right = new FormAttachment(100, 0);
data.bottom = new FormAttachment(100, 0);
cancel.setLayoutData(data);
cancel.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// Dispose the dialog instead of closing it. Otherwise, all
// of CAVE is closed.
dialog.dispose();
}
});
text = new Text(dialog, SWT.BORDER);
text = new Text(composite, SWT.SINGLE | SWT.PASSWORD | SWT.BORDER);
text.setFocus();
data = new FormData();
data.width = 200;
data.left = new FormAttachment(label, 0, SWT.DEFAULT);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(label, 0, SWT.CENTER);
data.bottom = new FormAttachment(cancel, 0, SWT.DEFAULT);
text.setLayoutData(data);
text.setEchoChar('*');
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
GC gc = new GC(text);
gd.widthHint = gc.getFontMetrics().getAverageCharWidth() * 20;
gc.dispose();
text.setLayoutData(gd);
Button ok = new Button(dialog, SWT.PUSH);
ok.setText("OK");
data = new FormData();
data.width = 60;
data.right = new FormAttachment(cancel, 0, SWT.DEFAULT);
data.bottom = new FormAttachment(100, 0);
ok.setLayoutData(data);
ok.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
numTries++;
dialog.setVisible(false);
if (!(text.getText().equals(password))) {
// password invalid, try again
if (numTries == 3) {
// after the 3rd failed attempt, exit
dialog.dispose();
MessageBox messageBox = new MessageBox(shell,
SWT.OK);
messageBox.setText("ABORTING HydroBase");
messageBox
.setMessage("Three failed password attempts - exiting HydroBase.");
messageBox.open();
return composite;
}
return;
}
@Override
protected void okPressed() {
numTries++;
getShell().setVisible(false);
MessageBox messageBox = new MessageBox(shell, SWT.OK);
messageBox.setText("Invalid Password");
messageBox.setMessage("Invalid password entered.\n"
+ " Please try again.");
messageBox.open();
// Show the password dialog again
dialog.setVisible(true);
} else {
// Close the password dialog so HydroBase is accessible
dialog.dispose();
verified = true;
}
if (text.getText().equals(password)) {
verified = true;
} else {
String dialogTitle;
String message;
if (numTries < 3) {
dialogTitle = "Invalid Password";
message = "Invalid password entered.\n"
+ "\tPlease try again.";
} else {
dialogTitle = "ABORTING HydroBase";
message = "Three failed password attempts - exiting HydroBase.";
}
});
dialog.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent event) {
shell.dispose();
}
});
dialog.setDefaultButton(ok);
dialog.pack();
dialog.open();
while (!dialog.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
MessageDialog.openError(getShell(), dialogTitle, message);
getShell().setVisible(true);
text.setFocus();
}
if (dialog.isDisposed() == false) {
dialog.dispose();
if (verified) {
super.okPressed();
} else if (numTries == 3) {
super.cancelPressed();
}
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("Enter Password");
}
public boolean isVerified() {
return verified;
}
@ -2240,14 +2195,12 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
try {
java.util.List<AdministrationData> data = HydroDBDataManager
.getInstance().getData(AdministrationData.class);
// if no data is returned, clear the current display data
AdministrationData adminData = (data.size() > 0) ? data.get(0)
: null;
pw = adminData.getHbPassword();
if (!data.isEmpty()) {
pw = data.get(0).getHbPassword();
}
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, "Data Query:"
+ " Error retrirving HB Password.");
statusHandler.error("Data Query:"
+ " Error retrirving HB Password.", e);
}
return pw;

View file

@ -20,8 +20,16 @@
package com.raytheon.viz.hydrobase.data;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.geometry.jts.JTS;
import org.geotools.referencing.CRS;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.hydro.spatial.HRAP;
import com.raytheon.viz.hydrocommon.util.HrapUtil;
@ -41,6 +49,8 @@ import com.vividsolutions.jts.geom.Polygon;
* Dec 18, 2015 5217 mpduff Initial creation
* Mar 08, 2016 5217 mpduff Fixed column values to be full hrap columns rather
* than relative to the subgrid.
* Apr 07, 2016 5217 mpduff Fixed an issue calculating hrap column.
* Apr 15, 2016 5217 mpduff Need to reproject the basin polygon into HRAP CRS.
*
* </pre>
*
@ -76,18 +86,28 @@ public class HydroGeoProcessor {
*/
public HrapBinList getHrapBinList(GeoAreaData geoData) throws Exception {
List<Coordinate> coords = getPointsFromArea(geoData);
Coordinate[] minMaxXY = getMinMaxXY(coords);
Polygon poly = MapUtil.getPolygon(coords.toArray(new Coordinate[0]));
Coordinate minC = minMaxXY[0];
Coordinate maxC = minMaxXY[1];
/*
* Reproject the polygon to the same map space as the HRAP grid.
*/
HRAP hrap = HRAP.getInstance();
GridGeometry2D hrapGridGeometry = hrap.getGridGeometry();
CoordinateReferenceSystem latLonCRS = DefaultGeographicCRS.WGS84;
CoordinateReferenceSystem hrapCRS = hrap.getGridGeometry()
.getCoordinateReferenceSystem();
MathTransform transform = CRS.findMathTransform(latLonCRS, hrapCRS);
Geometry crsGeometry = JTS.transform(poly, transform);
Geometry gridSpaceGeometry = JTS.transform(crsGeometry,
hrapGridGeometry.getCRSToGrid2D());
Coordinate[] gridSpaceCoords = gridSpaceGeometry.getCoordinates();
Coordinate[] minMaxXY = getMinMaxXY(Arrays.asList(gridSpaceCoords));
Coordinate hrapMin = minMaxXY[0];
Coordinate hrapMax = minMaxXY[1];
Coordinate hrapMin = HrapUtil.latLonToHrap(minC);
Coordinate hrapMax = HrapUtil.latLonToHrap(maxC);
int maxRow = (int) Math.floor(hrapMax.y);
int maxCol = (int) Math.floor(hrapMax.x);
int maxRow = (int) Math.ceil(hrapMax.y);
int maxCol = (int) Math.ceil(hrapMax.x);
int minRow = (int) Math.floor(hrapMin.y);
int minCol = (int) Math.floor(hrapMin.x);
@ -109,7 +129,6 @@ public class HydroGeoProcessor {
double area = 0;
HrapBinList binList = new HrapBinList();
for (int r = 0; r < rows; r++) {
rowNum = r + minRow;
startCol = -1;
@ -122,11 +141,11 @@ public class HydroGeoProcessor {
.getGridCellPolygon(coord);
}
if (poly.intersects(hrapGeometries[rowNum][colNum])) {
endCol = c + cols;
endCol = c;
binCtr++;
if (startCol == -1) {
// First cell in the row
startCol = c + cols;
startCol = c;
rowCtr++;
}
area += HrapUtil.getHrapBinArea(coord);
@ -208,13 +227,13 @@ public class HydroGeoProcessor {
* for each input point from the database, starting with the second
* point
*/
// Add the first point every time.
points.add(new Coordinate(lon[0], lat[0]));
for (int i = 1; i < data.getNumberPoints(); i++) {
/* if input points are different */
if ((lat[i] != lat[i - 1]) || (lon[i] != lon[i - 1])) {
coord = new Coordinate(lon[i], lat[i]);
points.add(coord);
}
coord = new Coordinate(lon[i], lat[i]);
points.add(coord);
}
/*

View file

@ -80,7 +80,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* 04 Sep 2014 14448 cgobs Make MPE redisplay after save of color settings in ColorScaleMgr
* 26 Feb 2015 16848 cgobs Fix merging of color sets by deleting existing set before saving new set.
* Updated to include fix of error when saving a new source.
* </pre>
* 08 Apr 2016 5512 bkowal Minimal updates to fix GUI sizing issues.
* </pre>
*
* @author lvenable
* @version 1.0
@ -104,17 +105,16 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
private ColorChooserDlg colorDlg;
/**
* callback to be execute upon saving of a color set
* generally used to update the display with the newly-saved color set
* callback to be execute upon saving of a color set generally used to
* update the display with the newly-saved color set
*/
private ISaveCallback saveCallback;
public interface ISaveCallback {
public void execute();
}
}
/**
* User's name.
@ -139,17 +139,17 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
/**
* Updated Color/Value array of color and value labels.
*/
private java.util.List<ColorValueLabels> colorValLblArray;
private List<ColorValueLabels> colorValLblArray;
/**
* Used Color/Value array of color and value labels.
*/
private java.util.List<ColorValueLabels> usedColorValLblArray;
private List<ColorValueLabels> usedColorValLblArray;
/**
* Browse Color/Value array of color and value labels.
*/
private java.util.List<ColorValueLabels> browseColorValLblArray;
private List<ColorValueLabels> browseColorValLblArray;
/**
* Source combo box.
@ -460,14 +460,17 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
// Create the navigation arrow buttons container
// -----------------------------------------------
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
Composite arraowBtnComp = new Composite(topControlComp, SWT.BOTTOM);
gl = new GridLayout(2, false);
gl.verticalSpacing = 100;
arraowBtnComp.setLayout(gl);
arraowBtnComp.setLayoutData(gd);
Composite arrowBtnComp = new Composite(topControlComp, SWT.BOTTOM);
gl = new GridLayout(2, true);
arrowBtnComp.setLayout(gl);
arrowBtnComp.setLayoutData(gd);
gd = new GridData(50, SWT.DEFAULT);
Button leftArrowBtn = new Button(arraowBtnComp, SWT.ARROW | SWT.LEFT);
final int buttonMinimumWidth = (int) (arrowBtnComp.getDisplay()
.getDPI().x * 0.5);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = buttonMinimumWidth;
Button leftArrowBtn = new Button(arrowBtnComp, SWT.ARROW | SWT.LEFT);
leftArrowBtn.setLayoutData(gd);
leftArrowBtn.addSelectionListener(new SelectionAdapter() {
@Override
@ -485,8 +488,9 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
}
});
gd = new GridData(50, SWT.DEFAULT);
Button rightArrowBtn = new Button(arraowBtnComp, SWT.ARROW | SWT.RIGHT);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = buttonMinimumWidth;
Button rightArrowBtn = new Button(arrowBtnComp, SWT.ARROW | SWT.RIGHT);
rightArrowBtn.setLayoutData(gd);
rightArrowBtn.addSelectionListener(new SelectionAdapter() {
@Override
@ -695,13 +699,17 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
// Create the navigation arrow buttons container
// -----------------------------------------------
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
Composite arraowBtnComp = new Composite(topControlComp, SWT.NONE);
Composite arrowBtnComp = new Composite(topControlComp, SWT.NONE);
gl = new GridLayout(2, false);
arraowBtnComp.setLayout(gl);
arraowBtnComp.setLayoutData(gd);
arrowBtnComp.setLayout(gl);
arrowBtnComp.setLayoutData(gd);
gd = new GridData(50, SWT.DEFAULT);
leftArrowBtn = new Button(arraowBtnComp, SWT.ARROW | SWT.LEFT);
final int buttonMinimumWidth = (int) (arrowBtnComp.getDisplay()
.getDPI().x * 0.5);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = buttonMinimumWidth;
leftArrowBtn = new Button(arrowBtnComp, SWT.ARROW | SWT.LEFT);
leftArrowBtn.setLayoutData(gd);
leftArrowBtn.addSelectionListener(new SelectionAdapter() {
@Override
@ -719,8 +727,9 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
}
});
gd = new GridData(50, SWT.DEFAULT);
rightArrowBtn = new Button(arraowBtnComp, SWT.ARROW | SWT.RIGHT);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = buttonMinimumWidth;
rightArrowBtn = new Button(arrowBtnComp, SWT.ARROW | SWT.RIGHT);
rightArrowBtn.setLayoutData(gd);
rightArrowBtn.addSelectionListener(new SelectionAdapter() {
@Override
@ -827,13 +836,14 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
// -------------------------------------
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
Composite btnComp = new Composite(editControlsComp, SWT.NONE);
gl = new GridLayout(4, false);
gl = new GridLayout(3, true);
btnComp.setLayout(gl);
btnComp.setLayoutData(gd);
int buttonWidth = 100;
final int buttonMinimumWidth = btnComp.getDisplay().getDPI().x;
gd = new GridData(buttonWidth, SWT.DEFAULT);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = buttonMinimumWidth;
Button addBtn = new Button(btnComp, SWT.PUSH);
addBtn.setText("Add/Update");
addBtn.setToolTipText("Add/Update Color-Value Pair");
@ -849,7 +859,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
}
});
gd = new GridData(buttonWidth, SWT.DEFAULT);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = buttonMinimumWidth;
Button undoBtn = new Button(btnComp, SWT.PUSH);
undoBtn.setText("Undo");
undoBtn.setToolTipText("Undo unsaved changes");
@ -862,7 +873,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
}
});
gd = new GridData(buttonWidth, SWT.DEFAULT);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = buttonMinimumWidth;
Button deleteBtn = new Button(btnComp, SWT.PUSH);
deleteBtn.setText("Delete");
deleteBtn.setToolTipText("Delete Color-Value Pair");
@ -935,7 +947,6 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
}
};
/**
* Update the color label on the display
*
@ -1029,11 +1040,14 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
Composite buttonComp = new Composite(dbControlGroup, SWT.NONE);
gl = new GridLayout(4, false);
gl = new GridLayout(4, true);
buttonComp.setLayout(gl);
buttonComp.setLayoutData(gd);
gd = new GridData(120, SWT.DEFAULT);
final int minimumButtonWidth = buttonComp.getDisplay().getDPI().x;
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = minimumButtonWidth;
saveAsUserBtn = new Button(buttonComp, SWT.PUSH);
saveAsUserBtn.setText("Save as:\n" + userName);
saveAsUserBtn.setLayoutData(gd);
@ -1059,7 +1073,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
});
gd = new GridData(120, SWT.DEFAULT);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = minimumButtonWidth;
saveAsOfficeBtn = new Button(buttonComp, SWT.PUSH);
saveAsOfficeBtn.setText("Save as:\nOffice");
saveAsOfficeBtn.setLayoutData(gd);
@ -1084,7 +1099,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
});
gd = new GridData(120, SWT.DEFAULT);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = minimumButtonWidth;
deleteAsUserBtn = new Button(buttonComp, SWT.PUSH);
deleteAsUserBtn.setText("Delete as:\n" + userName);
deleteAsUserBtn.setLayoutData(gd);
@ -1109,7 +1125,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
});
gd = new GridData(120, SWT.DEFAULT);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = minimumButtonWidth;
deleteAsOfficeBtn = new Button(buttonComp, SWT.PUSH);
deleteAsOfficeBtn.setText("Delete as:\nOffice");
deleteAsOfficeBtn.setLayoutData(gd);
@ -1458,8 +1475,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
*/
private void updateBrowseDurationCombo() {
String source = getSource();
java.util.List<String> durations;
if (source.equals(DEFAULT)) {
List<String> durations;
if (DEFAULT.equals(source)) {
durations = new ArrayList<String>();
durations.add("0");
} else {
@ -1484,12 +1501,9 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
String source = getSource();
java.util.List<ColorScaleData> updatedColorSet = editColorData
List<ColorScaleData> updatedColorSet = editColorData
.getColorScaleDataArray(source, selectedDurationInSeconds + "_"
+ dataTypeCbo.getText());
// java.util.List<ColorScaleData> updatedColorSet = editColorData
// .getColorScaleDataArray(source, durationCbo.getText() + "_"
// + dataTypeCbo.getText());
if (updatedColorSet.size() == 0) {
updatedColorSet = editColorData.getColorScaleDataArray(source, 0
@ -1530,7 +1544,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
String source = getSource();
java.util.List<ColorScaleData> updatedColorSet = editColorData
List<ColorScaleData> updatedColorSet = editColorData
.getColorScaleDataArray(source, selectedBrowseDurationInSeconds
+ "_" + browseDataTypeCbo.getText());
if (updatedColorSet == null) {
@ -1572,10 +1586,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
String source = getSource();
// java.util.List<ColorScaleData> updatedColorSet = editColorData
// .getUsedColorScaleDataArray(source, durationCbo.getText() + "_"
// + dataTypeCbo.getText());
java.util.List<ColorScaleData> updatedColorSet = editColorData
List<ColorScaleData> updatedColorSet = editColorData
.getUsedColorScaleDataArray(source, selectedDurationInSeconds
+ "_" + dataTypeCbo.getText());
@ -1643,7 +1654,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
* @param array
* Array of color value labels.
*/
private void disposeLabelsInArray(java.util.List<ColorValueLabels> array) {
private void disposeLabelsInArray(List<ColorValueLabels> array) {
if (array != null) {
for (ColorValueLabels cvl : array) {
cvl.disposeLabels();
@ -1691,12 +1702,6 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
* Populate the source combo box.
*/
private void populateSourceCombo() {
// Set<String> keys = editColorData.getSourceKeys();
//
// for (Iterator<String> iterator = keys.iterator();
// iterator.hasNext();) {
// sourceCbo.add(iterator.next());
// }
sourceCbo.add(DEFAULT);
sourceCbo.add(USER);
sourceCbo.add(OFFICE);
@ -1802,8 +1807,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
// for each datatype in database...
for (String dataType : userDataTypes) {
// get all durations for this datatype and this user
java.util.List<String> durations = colorManager.getDurations(
userId, dataType);
List<String> durations = colorManager
.getDurations(userId, dataType);
// for each duration for datatype
for (String duration : durations) {
@ -1816,13 +1821,13 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
try {
// actually get the data from database
java.util.List<ColorValueData> data = manager.getData(cvd);
List<ColorValueData> data = manager.getData(cvd);
// sort data by double value because data is stored as
// String
// see ColorValueData class for compareTo function
Collections.sort(data);
ColorScaleSets colorScaleSets = new ColorScaleSets();
java.util.List<ColorScaleData> origList = new ArrayList<ColorScaleData>();
List<ColorScaleData> origList = new ArrayList<ColorScaleData>();
for (ColorValueData colorValue : data) {
ColorScaleData csd = new ColorScaleData();
@ -1841,7 +1846,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
}
origList.add(csd);
}
java.util.List<ColorScaleData> usedList = new ArrayList<ColorScaleData>();
List<ColorScaleData> usedList = new ArrayList<ColorScaleData>();
usedList.addAll(origList);
colorScaleSets.setOriginalArray(origList);
@ -1875,8 +1880,9 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
gd.horizontalSpan = 2;
centeredComp.setLayoutData(gd);
gd = new GridData(90, SWT.DEFAULT);
Button closeBtn = new Button(centeredComp, SWT.NONE);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = closeBtn.getDisplay().getDPI().x;
closeBtn.setText("Close");
closeBtn.setLayoutData(gd);
closeBtn.addSelectionListener(new SelectionAdapter() {
@ -1891,8 +1897,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
* Creates the default color data
*/
private void createDefaultData() {
java.util.List<String> defaultDataTypes = colorManager
.getDefaultDataTypes();
List<String> defaultDataTypes = colorManager.getDefaultDataTypes();
editColorData = new EditColorData();
@ -1900,7 +1905,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
for (int i = 0; i < defaultDataTypes.size(); i++) {
ColorScaleSets colorScaleSets = new ColorScaleSets();
java.util.List<ColorScaleData> origList = colorManager
List<ColorScaleData> origList = colorManager
.getDefaultColorScaleData(defaultDataTypes.get(i));
colorScaleSets.setOriginalArray(origList);
@ -1961,41 +1966,39 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
return true;
}
private void deleteDataFromDb(String applicationName, String colorUseName, String userId, String durationString) {
private void deleteDataFromDb(String applicationName, String colorUseName,
String userId, String durationString) {
HydroDBDataManager manager = HydroDBDataManager.getInstance();
String whereClause = " WHERE application_name = '" + applicationName + "' AND " +
"color_use_name = '" + colorUseName + "' AND " +
"userId = '" + userId + "' AND " +
"duration = '" + durationString + "' AND " +
"threshold_unit = 'E' ";
String whereClause = " WHERE application_name = '" + applicationName
+ "' AND " + "color_use_name = '" + colorUseName + "' AND "
+ "userId = '" + userId + "' AND " + "duration = '"
+ durationString + "' AND " + "threshold_unit = 'E' ";
String statement = "delete from colorValue " + whereClause;
try {
DirectDbQuery.executeStatement(statement,HydroConstants.IHFS, QueryLanguage.SQL);
try {
DirectDbQuery.executeStatement(statement, HydroConstants.IHFS,
QueryLanguage.SQL);
}
catch (VizException e) {
statusHandler.handle(Priority.ERROR,
"Error deleting Color Value Data: ", e);
}
// 0. Collect data to delete (user, dataType, duration
java.util.List<ColorScaleData> usedColorData = null;
try
{
usedColorData = editColorData
.getUsedColorScaleDataArray(userId, durationString + "_" + colorUseName);
List<ColorScaleData> usedColorData = null;
try {
usedColorData = editColorData.getUsedColorScaleDataArray(userId,
durationString + "_" + colorUseName);
} catch (Exception e) {
statusHandler
.handle(Priority.DEBUG,
"No problem. Color set doesn't exist yet, can't delete it. ",
e);
}
catch (Exception e)
{
statusHandler.handle(Priority.DEBUG,
"No problem. Color set doesn't exist yet, can't delete it. ", e);
}
if (usedColorData != null) {
ColorValueData cvd = new ColorValueData();
cvd.setApplicationName(applicationName);
@ -2003,8 +2006,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
cvd.setUserId(userId);
cvd.setDuration(durationString);
System.out.println("Attempting to delete data from cvd = " +
getStringFromColorValueData(cvd) );
statusHandler.debug("Attempting to delete data from cvd = "
+ getStringFromColorValueData(cvd));
// 1. Delete each record from database
for (ColorScaleData csd : usedColorData) {
@ -2015,23 +2018,19 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
statusHandler.handle(Priority.ERROR,
"Error deleting Color Value Data: ", e);
}
} //end for
} // end for
}
}
private String getStringFromColorValueData(ColorValueData cvd)
{
private String getStringFromColorValueData(ColorValueData cvd) {
StringBuilder builder = new StringBuilder();
builder.append("appName: " + cvd.getApplicationName() +
" colorUseName: " + cvd.getColorUseName() +
" userId: " + cvd.getUserId() +
" duration: " + cvd.getDuration());
builder.append("appName: " + cvd.getApplicationName()
+ " colorUseName: " + cvd.getColorUseName() + " userId: "
+ cvd.getUserId() + " duration: " + cvd.getDuration());
return builder.toString();
}
/**
* save the data to the database
*
@ -2048,69 +2047,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
String colorUseName = colorManager.getDataTypeName(saveDataTypeCbo
.getText());
String duration = selectedDurationInSeconds.toString();
deleteDataFromDb(applicationName, colorUseName, userId, duration);
ColorValueData cvd = new ColorValueData();
for (ColorValueLabels cvls : colorValLblArray) {
String threshold = cvls.getValueText();
String colorName = cvls.getColorName();
String thresholdUnit = "E";
if (ColorScaleData.MISSING.equals(threshold)) {
threshold = "-9999";
} else if (ColorScaleData.LESS_THAN_MIN.equals(threshold)) {
threshold = "-8888";
}
cvd.setApplicationName(applicationName);
cvd.setUserId(userId);
cvd.setColorName(colorName);
cvd.setColorUseName(colorUseName);
cvd.setDuration(duration);
cvd.setThresholdUnit(thresholdUnit);
cvd.setThresholdValue(threshold);
try {
manager.putData(cvd);
} catch (VizException e1) {
statusHandler.handle(Priority.ERROR,
"Error saving Color Value Data: ", e1);
}
}
if (sourceCbo.getText().equals(DEFAULT)) {
createDefaultData();
} else {
createColorData(user);
}
updateDurationCombo();
updateColorValueLabelBar();
if (this.saveCallback != null) {
this.saveCallback.execute();
}
setReturnValue(true);
}
/**
* save the data to the database
*
* @param user
* user to save current data as
*/
private void saveDataOrig(String user) {
setSelectedDuration(durationCbo.getText());
HydroDBDataManager manager = HydroDBDataManager.getInstance();
String userId = user;
String applicationName = colorManager.getApplicationName();
String colorUseName = colorManager.getDataTypeName(saveDataTypeCbo
.getText());
String duration = selectedDurationInSeconds.toString();
ColorValueData cvd = new ColorValueData();
for (ColorValueLabels cvls : colorValLblArray) {
@ -2122,6 +2060,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
} else if (ColorScaleData.LESS_THAN_MIN.equals(threshold)) {
threshold = "-8888";
}
cvd.setApplicationName(applicationName);
cvd.setUserId(userId);
cvd.setColorName(colorName);
@ -2131,6 +2070,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
cvd.setThresholdValue(threshold);
try {
manager.putData(cvd);
} catch (VizException e1) {
statusHandler.handle(Priority.ERROR,
@ -2138,41 +2078,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
}
}
//delete all old records
for (ColorValueLabels cvls : usedColorValLblArray) {
System.out.printf(" value = %s, colorName = %s\n", cvls.getValueText(), cvls.getColorName() );
boolean found = false;
for (int i = 0; (i < colorValLblArray.size()) && !found; ++i) {
String val = colorValLblArray.get(i).getValueText();
if (val.equals(cvls.getValueText())) {
found = true;
}
}
System.out.printf("found = %b\n", found);
if (!found) {
cvd.setApplicationName(applicationName);
cvd.setUserId(userId);
cvd.setColorName(cvls.getColorName());
cvd.setColorUseName(colorUseName);
cvd.setDuration(duration);
cvd.setThresholdUnit("E");
cvd.setThresholdValue(cvls.getValueText());
try {
manager.deleteRecord(cvd);
} catch (VizException e1) {
statusHandler.handle(Priority.ERROR,
"Error deleting Color Value Data: ", e1);
}
}
}
if (sourceCbo.getText().equals(DEFAULT)) {
if (DEFAULT.equals(sourceCbo.getText())) {
createDefaultData();
} else {
createColorData(user);
@ -2180,15 +2086,14 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
updateDurationCombo();
updateColorValueLabelBar();
if (this.saveCallback != null) {
this.saveCallback.execute();
}
setReturnValue(true);
}
public void setSaveCallback(ISaveCallback iSaveCallback)
{
public void setSaveCallback(ISaveCallback iSaveCallback) {
this.saveCallback = iSaveCallback;
}
@ -2230,10 +2135,10 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
* update delete buttons based on source/user
*/
private void updateButtons() {
if (sourceCbo.getText().equals(OFFICE)) {
if (OFFICE.equals(sourceCbo.getText())) {
deleteAsOfficeBtn.setEnabled(true);
deleteAsUserBtn.setEnabled(false);
} else if (sourceCbo.getText().equals(USER)) {
} else if (USER.equals(sourceCbo.getText())) {
deleteAsOfficeBtn.setEnabled(false);
if (userIdCbo.getText().equals(userName)) {
deleteAsUserBtn.setEnabled(true);
@ -2253,8 +2158,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
// 0. Collect data to delete (user, dataType, duration
String dataType = dataTypeCbo.getText();
String duration = selectedDurationInSeconds.toString();
java.util.List<ColorScaleData> data = editColorData
.getUsedColorScaleDataArray(source, duration + "_" + dataType);
List<ColorScaleData> data = editColorData.getUsedColorScaleDataArray(
source, duration + "_" + dataType);
ColorValueData cvd = new ColorValueData();
cvd.setApplicationName(colorManager.getApplicationName());
cvd.setColorUseName(colorManager.getDataTypeName(dataType));
@ -2274,7 +2179,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
// 2. Update editColorData
boolean dataLeft = true;
if (source.equals(DEFAULT)) {
if (DEFAULT.equals(source)) {
createDefaultData();
} else {
dataLeft = createColorData(source);
@ -2315,9 +2220,9 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
public String getSource() {
sourceColor = sourceCbo.getText();
if (sourceColor.equals(OFFICE)) {
if (OFFICE.equals(sourceColor)) {
sourceColor = OFFICE_DEFAULT;
} else if (sourceColor.equals(USER)) {
} else if (USER.equals(sourceColor)) {
sourceColor = userIdCbo.getItem(userIdCbo.getSelectionIndex());
}

View file

@ -1,51 +1,48 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
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.
-->
<!--
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.
-->
<bundle>
<displayList>
<displays xsi:type="d2DMapRenderableDisplay" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<descriptor xsi:type="mapDescriptor">
<resource>
<loadProperties xsi:type="gridLoadProperties" displayType="IMAGE" loadWithoutData="true">
</loadProperties>
<properties isSystemResource="false"
isBlinking="false" isMapLayer="false" isHoverOn="false"
isVisible="true" />
<resourceData xsi:type="gridLightningResourceData"
isUpdatingOnMetadataOnly="false" isRequeryNecessaryOnTimeMatch="true"
handlingPositiveStrikes="true" handlingNegativeStrikes="true"
handlingPulses="false" handlingCloudFlashes="false"
kmResolution="${resolution}">
<binOffset posOffset="0" negOffset="${negOffset}" virtualOffset="0"/>
<binRepeatCount>${binRepeatCount;1}</binRepeatCount>
<metadataMap>
<mapping key="pluginName">
<constraint constraintValue="binlightning" constraintType="EQUALS" />
</mapping>
<mapping key="source">
<constraint constraintValue="${source}" constraintType="EQUALS" />
</mapping>
</metadataMap>
</resourceData>
</resource>
</descriptor>
</displays>
</displayList>
<displayList>
<displays xsi:type="d2DMapRenderableDisplay" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<descriptor xsi:type="mapDescriptor">
<resource>
<loadProperties xsi:type="gridLoadProperties" displayType="IMAGE" loadWithoutData="true">
</loadProperties>
<properties isSystemResource="false" isBlinking="false" isMapLayer="false" isHoverOn="false"
isVisible="true" />
<resourceData xsi:type="gridLightningResourceData" isUpdatingOnMetadataOnly="false"
isRequeryNecessaryOnTimeMatch="true" handlingPositiveStrikes="true" handlingNegativeStrikes="true"
handlingPulses="false" handlingCloudFlashes="false" kmResolution="${resolution}">
<binOffset posOffset="0" negOffset="${negOffset}" virtualOffset="0" />
<binRepeatCount>${binRepeatCount;1}</binRepeatCount>
<metadataMap>
<mapping key="pluginName">
<constraint constraintValue="binlightning" constraintType="EQUALS" />
</mapping>
<mapping key="source">
<constraint constraintValue="${source}" constraintType="EQUALS" />
</mapping>
</metadataMap>
</resourceData>
</resource>
</descriptor>
</displays>
</displayList>
</bundle>

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
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.
-->
<bundle>
<displayList>
<displays xsi:type="d2DMapRenderableDisplay" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<descriptor xsi:type="mapDescriptor">
<resource>
<loadProperties loadWithoutData="true">
</loadProperties>
<properties isSystemResource="false" isBlinking="false" isMapLayer="false" isHoverOn="false"
isVisible="true" />
<resourceData xsi:type="lightningResourceData" isUpdatingOnMetadataOnly="false"
isRequeryNecessaryOnTimeMatch="true" handlingPositiveStrikes="true" handlingNegativeStrikes="true">
<binOffset posOffset="0" negOffset="${negOffset;60}" virtualOffset="0" />
<binRepeatCount>${binRepeatCount;1}</binRepeatCount>
<metadataMap>
<mapping key="pluginName">
<constraint constraintValue="binlightning" constraintType="EQUALS" />
</mapping>
<mapping key="source">
<constraint constraintValue="${source}" constraintType="EQUALS" />
</mapping>
</metadataMap>
</resourceData>
</resource>
</descriptor>
</displays>
</displayList>
</bundle>

View file

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
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.
-->
<bundle>
<displayList>
<displays xsi:type="d2DMapRenderableDisplay" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<descriptor xsi:type="mapDescriptor">
<resource>
<loadProperties loadWithoutData="true">
</loadProperties>
<properties isSystemResource="false" isBlinking="false" isMapLayer="false" isHoverOn="false"
isVisible="false" />
<resourceData xsi:type="lightningResourceData" isUpdatingOnMetadataOnly="false"
isRequeryNecessaryOnTimeMatch="true" handlingPositiveStrikes="false" handlingNegativeStrikes="false"
handlingPulses="true">
<binOffset posOffset="0" negOffset="${negOffset;60}" virtualOffset="0" />
<binRepeatCount>${binRepeatCount;1}</binRepeatCount>
<metadataMap>
<mapping key="pluginName">
<constraint constraintValue="binlightning" constraintType="EQUALS" />
</mapping>
<mapping key="source">
<constraint constraintValue="${source}" constraintType="EQUALS" />
</mapping>
</metadataMap>
</resourceData>
</resource>
<resource>
<loadProperties loadWithoutData="true">
</loadProperties>
<properties isSystemResource="false" isBlinking="false" isMapLayer="false" isHoverOn="false"
isVisible="true" />
<resourceData xsi:type="lightningResourceData" isUpdatingOnMetadataOnly="false"
isRequeryNecessaryOnTimeMatch="true" handlingPositiveStrikes="false" handlingNegativeStrikes="false"
handlingCloudFlashes="true">
<binOffset posOffset="0" negOffset="${negOffset;60}" virtualOffset="0" />
<binRepeatCount>${binRepeatCount;1}</binRepeatCount>
<metadataMap>
<mapping key="pluginName">
<constraint constraintValue="binlightning" constraintType="EQUALS" />
</mapping>
<mapping key="source">
<constraint constraintValue="${source}" constraintType="EQUALS" />
</mapping>
</metadataMap>
</resourceData>
</resource>
<resource>
<loadProperties loadWithoutData="true">
</loadProperties>
<properties isSystemResource="false" isBlinking="false" isMapLayer="false" isHoverOn="false"
isVisible="true" />
<resourceData xsi:type="lightningResourceData" isUpdatingOnMetadataOnly="false"
isRequeryNecessaryOnTimeMatch="true" handlingPositiveStrikes="true" handlingNegativeStrikes="true">
<binOffset posOffset="0" negOffset="${negOffset;60}" virtualOffset="0" />
<binRepeatCount>${binRepeatCount;1}</binRepeatCount>
<metadataMap>
<mapping key="pluginName">
<constraint constraintValue="binlightning" constraintType="EQUALS" />
</mapping>
<mapping key="source">
<constraint constraintValue="${source}" constraintType="EQUALS" />
</mapping>
</metadataMap>
</resourceData>
</resource>
</descriptor>
</displays>
</displayList>
</bundle>

View file

@ -19,20 +19,29 @@
further_licensing_information.
-->
<menuTemplate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot60Min.xml"
<contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot.xml"
menuText="1hr plot" id="1HrLightningFlashPlot">
<substitute key="negOffset" value="3600"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot15Min.xml"
<contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot.xml"
menuText="15min plot" id="15MinLightningFlashPlot">
<substitute key="negOffset" value="900"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot15MinPN.xml"
menuText="15min Pos/Neg plot" id="15MinPNLightningFlashPlot">
</contribute>
<contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot5Min.xml"
<contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot.xml"
menuText="5min plot" id="5MinLightningFlashPlot">
<substitute key="negOffset" value="300"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot1Min.xml"
<contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot.xml"
menuText="5min plot (1min update)" id="5Min1MinLightningFlashPlot">
<substitute key="negOffset" value="60"/>
<substitute key="binRepeatCount" value="5"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot.xml"
menuText="1min plot" id="1MinLightningFlashPlot">
<substitute key="negOffset" value="60"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningSeq.xml"
menuText="1min Lgtng Seq Plot" id="1MinLightningFlashSeq">

View file

@ -19,19 +19,31 @@
further_licensing_information.
-->
<menuTemplate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<contribute xsi:type="bundleItem" file="bundles/LightningPlot60Min.xml"
<contribute xsi:type="bundleItem" file="bundles/LightningPlot.xml"
menuText="1hr plot" id="1HrLightningStrokePlot">
<substitute key="negOffset" value="3600"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningPlot15Min.xml"
<contribute xsi:type="bundleItem" file="bundles/LightningPlot.xml"
menuText="15min plot" id="15MinLightningStrokePlot">
<substitute key="negOffset" value="900"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningPlot15MinPN.xml"
menuText="15min Pos/Neg plot" id="15MinPNLightningStrokePlot">
</contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningPlot5Min.xml"
<contribute xsi:type="bundleItem" file="bundles/LightningPlot.xml"
menuText="5min plot" id="5MinLightningStrokePlot">
<substitute key="negOffset" value="300"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningPlot.xml"
menuText="5min plot (1min update)" id="5Min1MinLightningStrokePlot">
<substitute key="negOffset" value="60"/>
<substitute key="binRepeatCount" value="5"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningPlot.xml"
menuText="1min plot" id="1MinLightningStrokePlot">
<substitute key="negOffset" value="60"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningSeq.xml"
menuText="1min Lgtng Seq" id="1MinLightningStrokeSeq">
menuText="1min Lgtng Seq Plot" id="1MinLightningStrokeSeq">
</contribute>
</menuTemplate>

View file

@ -32,5 +32,13 @@
menuText="5min cloud to ground density" id="1HrGridLightningCGPlot">
<substitute key="negOffset" value="300"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningCGPlot.xml"
menuText="5min cloud to ground density (1min update)" id="5Min1MinGridLightningCGPlot">
<substitute key="negOffset" value="60"/>
<substitute key="binRepeatCount" value="5"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningCGPlot.xml"
menuText="1min cloud to ground density" id="1MinGridLightningCGPlot">
<substitute key="negOffset" value="60"/>
</contribute>
</menuTemplate>

View file

@ -56,27 +56,44 @@
<contribute xsi:type="bundleItem" file="bundles/GridLightningCGPlot.xml"
menuText="5min cloud to ground density" id="1HrGridLightningCGPlot">
<substitute key="negOffset" value="300"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningCloudFlashPlot.xml"
menuText="5min cloud flash density" id="1HrGridLightningCloudFlashPlot">
<substitute key="negOffset" value="300"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningTotalFlashPlot.xml"
menuText="5min total flash density" id="1HrGridLightningFlashPlot">
<substitute key="negOffset" value="300"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningPulsePlot.xml"
menuText="5min pulse density" id="1HrGridLightningPulsePlot">
<substitute key="negOffset" value="300"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningCGPlot.xml"
menuText="5min cloud to ground density (1min update)" id="5Min1MinGridLightningCGPlot">
<substitute key="negOffset" value="60"/>
<substitute key="binRepeatCount" value="5"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningCloudFlashPlot.xml"
menuText="5min cloud flash density" id="1HrGridLightningCloudFlashPlot">
menuText="5min cloud flash density (1min update)" id="5Min1MinGridLightningCloudFlashPlot">
<substitute key="negOffset" value="60"/>
<substitute key="binRepeatCount" value="5"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningTotalFlashPlot.xml"
menuText="5min total flash density" id="1HrGridLightningFlashPlot">
menuText="5min total flash density (1min update)" id="5Min1MinGridLightningFlashPlot">
<substitute key="negOffset" value="60"/>
<substitute key="binRepeatCount" value="5"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningPulsePlot.xml"
menuText="5min pulse density" id="1HrGridLightningPulsePlot">
menuText="5min pulse density (1min update)" id="5Min1MinGridLightningPulsePlot">
<substitute key="negOffset" value="60"/>
<substitute key="binRepeatCount" value="5"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningCGPlot.xml"
menuText="1min cloud to ground density" id="1HrGridLightningCGPlot">
menuText="1min cloud to ground density" id="5Min1MinGridLightningCGPlot">
<substitute key="negOffset" value="60"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningCloudFlashPlot.xml"

View file

@ -19,17 +19,29 @@
further_licensing_information.
-->
<menuTemplate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<contribute xsi:type="bundleItem" file="bundles/LightningPlot60Min.xml"
<contribute xsi:type="bundleItem" file="bundles/LightningPlot.xml"
menuText="1hr plot" id="1HrLightningFlashPlot">
<substitute key="negOffset" value="3600"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningPlot15Min.xml"
<contribute xsi:type="bundleItem" file="bundles/LightningPlot.xml"
menuText="15min plot" id="15MinLightningFlashPlot">
<substitute key="negOffset" value="900"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningPlot15MinPN.xml"
menuText="15min Pos/Neg plot" id="15MinPNLightningFlashPlot">
</contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningPlot5Min.xml"
<contribute xsi:type="bundleItem" file="bundles/LightningPlot.xml"
menuText="5min plot" id="5MinLightningFlashPlot">
<substitute key="negOffset" value="300"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningPlot.xml"
menuText="5min plot (1min update)" id="5Min1MinLightningFlashPlot">
<substitute key="negOffset" value="60"/>
<substitute key="binRepeatCount" value="5"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningPlot.xml"
menuText="1min plot" id="1MinLightningFlashPlot">
<substitute key="negOffset" value="60"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningSeq.xml"
menuText="1min Lgtng Seq Plot" id="1MinLightningFlashSeq">

View file

@ -96,6 +96,7 @@ import com.raytheon.viz.lightning.cache.LightningFrameRetriever;
* 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
* Apr 26, 2016 5597 bsteffen Include update interval in legend.
*
* </pre>
*
@ -184,6 +185,9 @@ public class LightningResource extends
int absTimeInterval = Math.abs(resourceData.getRepeatingBinOffset()
.getInterval());
int updateInterval = Math
.abs(resourceData.getBinOffset().getInterval());
// If a virtual offset is provided, it is aged lightning, so use
// the virtual offset to provide the "Old" time
int virtualOffset = resourceData.getBinOffset().getVirtualOffset();
@ -201,6 +205,9 @@ public class LightningResource extends
if (source != null) {
rval += source + ' ';
}
if (updateInterval != absTimeInterval) {
rval += convertTimeIntervalToString(updateInterval) + "Update ";
}
return rval;
}

View file

@ -25,16 +25,23 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.mpe.ui.dialogs.RadarBiasTableDialog;
import com.raytheon.viz.mpe.ui.dialogs.gagetable.GageTableDataManager;
/**
* TODO Add Description
* Retrieves the defined radar identifies and displays the
* {@link RadarBiasTableDialog} on success.
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 15, 2009 2616 snaples Initial creation
* Apr 06, 2016 5512 bkowal Verify retrieval of the radar identifiers before even
* attempting to open the Radar Bias Table dialog.
* </pre>
*
* @author snaples
@ -42,11 +49,27 @@ import com.raytheon.viz.mpe.ui.dialogs.RadarBiasTableDialog;
*/
public class ShowBiasTable extends AbstractHandler {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(getClass());
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
String[] radIds;
try {
radIds = GageTableDataManager.getInstance().getActiveRadarIds();
} catch (VizException e) {
statusHandler.error(
"Failed to retrieve the active radar identifiers.", e);
/*
* No point in displaying the dialog because the primary data type
* that the dialog is dependent on could not be retrieved.
*/
return null;
}
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
RadarBiasTableDialog dialog = new RadarBiasTableDialog(shell);
RadarBiasTableDialog dialog = new RadarBiasTableDialog(shell, radIds);
dialog.open();
return null;

View file

@ -36,6 +36,7 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 28, 2010 mschenke Initial creation
* Apr 20, 2016 5541 dgilling Fix issues with hide/restore and perspective switching.
*
* </pre>
*
@ -86,8 +87,14 @@ public class AbstractMPEDialog extends Dialog implements
@Override
public final void hide() {
if (shell != null && shell.isDisposed() == false) {
wasVisible = shell.isVisible();
hide(false);
}
@Override
public final void hide(boolean isPerspectiveSwitch) {
Shell shell = getShell();
if ((shell != null) && (!shell.isDisposed())) {
wasVisible = shell.isVisible() && isPerspectiveSwitch;
lastLocation = shell.getLocation();
shell.setVisible(false);
}
@ -95,10 +102,17 @@ public class AbstractMPEDialog extends Dialog implements
@Override
public final void restore() {
if (shell != null && shell.isDisposed() == false) {
shell.setVisible(wasVisible);
shell.setLocation(lastLocation);
}
restore(false);
}
@Override
public final void restore(boolean isPerspectiveSwitch) {
Shell shell = getShell();
if ((shell != null) && (!shell.isDisposed())) {
if ((isPerspectiveSwitch && wasVisible) || (!isPerspectiveSwitch)) {
shell.setVisible(true);
shell.setLocation(lastLocation);
}
}
}
}

View file

@ -26,6 +26,7 @@ import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@ -49,7 +50,8 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 4, 2011 lvenable Initial creation
* May 04, 2011 ? lvenable Initial creation
* Apr 05, 2016 5504 bkowal Fix GUI sizing issues.
*
* </pre>
*
@ -153,11 +155,18 @@ public class BadGagesDlg extends AbstractMPEDialog {
listComp.setLayout(new GridLayout(1, false));
listComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 200;
gd.heightHint = 200;
gageList = new List(listComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL
| SWT.H_SCROLL);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
GC gc = new GC(gageList);
/*
* Ensures that a minimum of approximately 38 characters will be
* displayed.
*/
gd.minimumWidth = gc.getFontMetrics().getAverageCharWidth() * 38;
gc.dispose();
// Ensures that a minimum of ten rows will be displayed.
gd.heightHint = gageList.getItemHeight() * 10;
gageList.setLayoutData(gd);
gageList.addSelectionListener(new SelectionAdapter() {
@Override
@ -170,9 +179,9 @@ public class BadGagesDlg extends AbstractMPEDialog {
}
});
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.widthHint = 160;
deleteSelectedBtn = new Button(listComp, SWT.PUSH);
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.minimumWidth = deleteSelectedBtn.getDisplay().getDPI().x;
deleteSelectedBtn.setText("Delete Selected Item");
deleteSelectedBtn.setEnabled(false);
deleteSelectedBtn.setLayoutData(gd);
@ -190,13 +199,13 @@ public class BadGagesDlg extends AbstractMPEDialog {
private void createBottomButtons() {
Composite buttonComp = new Composite(shell, SWT.NONE);
buttonComp.setLayout(new GridLayout(2, true));
buttonComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true,
buttonComp.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true,
false));
int buttonWidth = 80;
int minimumButtonWidth = buttonComp.getDisplay().getDPI().x;
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.widthHint = buttonWidth;
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.minimumWidth = minimumButtonWidth;
Button okBtn = new Button(buttonComp, SWT.PUSH);
okBtn.setText("OK");
okBtn.setLayoutData(gd);
@ -208,8 +217,8 @@ public class BadGagesDlg extends AbstractMPEDialog {
}
});
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.widthHint = buttonWidth;
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.minimumWidth = minimumButtonWidth;
Button cancelBtn = new Button(buttonComp, SWT.PUSH);
cancelBtn.setText("Cancel");
cancelBtn.setLayoutData(gd);

View file

@ -26,8 +26,6 @@ import java.util.Date;
import java.util.Map;
import java.util.TimeZone;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@ -53,7 +51,6 @@ import com.raytheon.viz.mpe.core.MPEDataManager.MPEDateInfo;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.TransmitBestEstimateQPEProvider;
import com.raytheon.viz.mpe.ui.TransmitRFCBiasProvider;
import com.raytheon.viz.mpe.ui.actions.ClearMPEData;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
import com.raytheon.viz.ui.editor.IMultiPaneEditor;
@ -75,6 +72,7 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor;
* Jan 05, 2015 14246 lbousaidi enable Transmit Best Estimate QPE.
* Jul 8, 2015 16790 snaples Updated call to setCurrentEditDate to pass force variable.
* Sep 29, 2015 17975 snaples Fixed issue with Hydro date not following the CAVE time when changed.
* Apr 11, 2016 5512 bkowal Cleanup.
*
* </pre>
*
@ -91,11 +89,11 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
}
private Calendar cal;
private Calendar hydroCal;
public static Date prevDate;
public static Date prevHydDate;
public static String prevArea;
@ -109,11 +107,11 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
private Spinner hourSpinner;
private Spinner daysSpinner;
private Text hydyearText;
private Text hydmonthText;
private Spinner hyddaySpinner;
private Map<Date, MPEDateInfo> dateMap;
@ -141,7 +139,7 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
private Combo areaCombo;
private static Date currentHydroEndingDate;
public ChooseDataPeriodDialog(Shell parentShell) {
super(parentShell);
setBlockOnOpen(false);
@ -171,10 +169,10 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
hydroCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
prevDate = displayMgr.getCurrentEditDate();
cal.setTime(prevDate);
hydroCal.setTime(displayMgr.getCurrentEditDate());
if ( hydroCal.get(Calendar.HOUR_OF_DAY) >= 18 ){
if (hydroCal.get(Calendar.HOUR_OF_DAY) >= 18) {
hydroCal.add(Calendar.DATE, 1);
}
}
@ -346,7 +344,7 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
gageOptionsGroup.setText("6/24 hr gage edit options");
// create ending hydro date area
Label hydrodateLabel = new Label(gageOptionsGroup, SWT.NONE);
hydrodateLabel.setText("Ending Hydrologic Date: ");
new Label(gageOptionsGroup, SWT.None);
@ -387,15 +385,14 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
@Override
public void widgetSelected(SelectionEvent e) {
int day = hyddaySpinner.getSelection();
hydroCal.set(Calendar.DAY_OF_MONTH, day);
updateTimeControls();
}
});
new Label(gageOptionsGroup, SWT.None);
new Label(gageOptionsGroup, SWT.None);
Label selectAreaLabel = new Label(gageOptionsGroup, SWT.NONE);
@ -457,7 +454,7 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
displayMgr.setDqcDays(daysSpinner.getSelection());
prevArea = areaCombo.getItem(areaCombo.getSelectionIndex());
setCurrentHydroEditDate(getHydroTime());
if (QcPrecipOptionsDialog.isFinished() == false) {
QcPrecipOptionsDialog.destroy(false);
}
@ -486,7 +483,7 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
displayMgr.setDqcDays(daysSpinner.getSelection());
prevArea = areaCombo.getItem(areaCombo.getSelectionIndex());
setCurrentHydroEditDate(getHydroTime());
if (QcTempOptionsDialog.isFinished() == false) {
QcTempOptionsDialog.destroy(false);
}
@ -515,7 +512,7 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
displayMgr.setDqcDays(daysSpinner.getSelection());
prevArea = areaCombo.getItem(areaCombo.getSelectionIndex());
setCurrentHydroEditDate(getHydroTime());
if (QcFreezeOptionsDialog.isFinished() == false) {
QcFreezeOptionsDialog.destroy(false);
}
@ -540,39 +537,38 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
}
private void updateTimeControls() {
if (cal.getTime().before(dataMgr.getEarliestDate())
|| cal.getTime().after(dataMgr.getLatestDate())) {
cal.setTime(prevDate);
}
Calendar aCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
aCal.setTime(displayMgr.getCurrentEditDate());
if ( aCal.get(Calendar.HOUR_OF_DAY) >= 18 ){
if (aCal.get(Calendar.HOUR_OF_DAY) >= 18) {
aCal.add(Calendar.DATE, 1);
}
prevDate = cal.getTime();
yearText.setText(Integer.toString(cal.get(Calendar.YEAR)));
monthText.setText(Integer.toString(cal.get(Calendar.MONTH) + 1));
daySpinner.setSelection(cal.get(Calendar.DAY_OF_MONTH));
hourSpinner.setSelection(cal.get(Calendar.HOUR_OF_DAY));
hydyearText.setText(Integer.toString(hydroCal.get(Calendar.YEAR)));
hydmonthText.setText(Integer.toString(hydroCal.get(Calendar.MONTH) + 1));
hyddaySpinner.setSelection( hydroCal.get(Calendar.DAY_OF_MONTH) );
hydmonthText
.setText(Integer.toString(hydroCal.get(Calendar.MONTH) + 1));
hyddaySpinner.setSelection(hydroCal.get(Calendar.DAY_OF_MONTH));
if (dateMap.containsKey(cal.getTime()) == false) {
dateMap = dataMgr.getDateMap(true);
}
MPEDateInfo dateInfo = dateMap.get(cal.getTime());
if (dateInfo != null) {
lastSave.setText(sdf.format(dateInfo.getLastSaveTime()));
lastExec.setText(sdf.format(dateInfo.getLastExecTime()));
@ -608,19 +604,18 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
public Date getTime() {
return cal.getTime();
}
public Date getHydroTime(){
public Date getHydroTime() {
return hydroCal.getTime();
}
private void setCurrentHydroEditDate(Date hydroTime) {
currentHydroEndingDate = hydroTime;
}
public static Date getCurrentHydroEditDate(){
return currentHydroEndingDate;
currentHydroEndingDate = hydroTime;
}
public static Date getCurrentHydroEditDate() {
return currentHydroEndingDate;
}
/**
* Get the selected year;

View file

@ -65,9 +65,10 @@ 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.
* Mar 10, 2015 14575 snaples Added additional status flag.
* Jan 15, 2016 5054 randerso Use proper parent shell
* Apr 05, 2015 18350 snaples Updated static calls to dailyqc utils.
* Apr 11, 2016 5512 bkowal Fix GUI sizing issues. Cleanup.
*
* </pre>
*
@ -126,10 +127,6 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
OtherFreezeOptions ozo = new OtherFreezeOptions();
// Zdata[] zdata = new Zdata[0];
// Ts[] ts;
private int time_pos;
public static Button[] tsbuttons = null;
@ -158,29 +155,33 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
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 && DailyQcUtils.contour_flag == -1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == -1 && DailyQcUtils.map_flag == -1
&& DailyQcUtils.contour_flag == -1) {
ik = 0;
} else if (DailyQcUtils.points_flag == -1 && DailyQcUtils.grids_flag == 1
&& DailyQcUtils.map_flag == -1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == 1 && DailyQcUtils.map_flag == -1) {
ik = 1;
} else if (DailyQcUtils.points_flag == -1 && DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == 1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == -1 && DailyQcUtils.map_flag == 1) {
ik = 2;
} else if (DailyQcUtils.points_flag == 1 && DailyQcUtils.grids_flag == 1
&& DailyQcUtils.map_flag == -1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == 1 && DailyQcUtils.map_flag == -1) {
ik = 3;
} else if (DailyQcUtils.points_flag == 1 && DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == 1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == -1 && DailyQcUtils.map_flag == 1) {
ik = 4;
} else if (DailyQcUtils.points_flag == -1 && DailyQcUtils.contour_flag == 1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.contour_flag == 1) {
ik = 5;
} else if (DailyQcUtils.points_flag == 1 && DailyQcUtils.contour_flag == 1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.contour_flag == 1) {
ik = 6;
} else if (DailyQcUtils.points_flag == -1 && DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == -1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == -1 && DailyQcUtils.map_flag == -1) {
ik = 7;
}
return ik;
@ -343,7 +344,6 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
// checks to see if area or date has changed since last data load
DailyQcUtils dqcu = DailyQcUtils.getInstance();
dqc_good = dqcu.qcDataReload(currDate, QcArea, qcDays, false);
// dqc.zdata = DailyQcUtils.zdata;
if (MPEDisplayManager.pcpn_time_step != 0) {
MPEDisplayManager.pcpn_time_step = 0;
DailyQcUtils.pcpn_time = 0;
@ -359,7 +359,6 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.pcpn_time = 0;
for (i = 0; i < 8; i++) {
time_pos = 100 + DailyQcUtils.pcp_flag;
if ((i != 0 && i != 7) && DailyQcUtils.pcp_in_use[time_pos] == -1) {
@ -367,7 +366,6 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
}
}
// ts = DailyQcUtils.ts;
this.createDataOptionsGroup();
this.createPointSetComp();
this.createPointControlComp();
@ -380,7 +378,7 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
private void createDataOptionsGroup() {
int i = 0;
Group dataOptionsGroup = new Group(shell, SWT.NONE);
dataOptionsGroup.setText(" Data Options ");
dataOptionsGroup.setText("Data Options");
GridLayout groupLayout = new GridLayout(1, false);
dataOptionsGroup.setLayout(groupLayout);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
@ -396,16 +394,18 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
freezeTimeCompLayout.marginHeight = 0;
freezeTimeCompLayout.marginWidth = 0;
freezeTimeComp.setLayout(freezeTimeCompLayout);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
freezeTimeComp.setLayoutData(gd);
Label freezeTimeLbl = new Label(freezeTimeComp, SWT.CENTER);
freezeTimeLbl.setText(" 6 Hour ");
freezeTimeLbl.setText("6 Hour");
// Add the time arrow buttons
Composite timeArrowsComp = new Composite(freezeTimeComp, SWT.NONE);
RowLayout timeArrowRl = new RowLayout(SWT.HORIZONTAL);
timeArrowsComp.setLayout(timeArrowRl);
RowData rd = new RowData(25, 25);
RowData rd = new RowData(SWT.DEFAULT, SWT.DEFAULT);
upTimeBtn = new Button(timeArrowsComp, SWT.ARROW | SWT.UP);
upTimeBtn.setLayoutData(rd);
upTimeBtn.setEnabled(false);
@ -416,7 +416,7 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
}
});
rd = new RowData(25, 25);
rd = new RowData(SWT.DEFAULT, SWT.DEFAULT);
dnTimeBtn = new Button(timeArrowsComp, SWT.ARROW | SWT.DOWN);
dnTimeBtn.setLayoutData(rd);
dnTimeBtn.setEnabled(false);
@ -427,7 +427,7 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
}
});
GridData dd = new GridData(208, SWT.DEFAULT);
GridData dd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
String[] a = new String[dataSet.size()];
dataDispCbo = new Combo(dataOptionsGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
@ -453,8 +453,10 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
renderCompLayout.marginHeight = 0;
renderCompLayout.marginWidth = 0;
renderComp.setLayout(renderCompLayout);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
renderComp.setLayoutData(gd);
gd = new GridData(153, 25);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
renderGridsBtn = new Button(renderComp, SWT.PUSH);
renderGridsBtn.setText("Render Grids+MAZs");
renderGridsBtn.setLayoutData(gd);
@ -479,11 +481,13 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
filterTypeCompLayout.marginHeight = 0;
filterTypeCompLayout.marginWidth = 0;
filterTypeComp.setLayout(filterTypeCompLayout);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
filterTypeComp.setLayoutData(gd);
Label pcpLbl = new Label(filterTypeComp, SWT.CENTER);
pcpLbl.setText("Filter Z:");
gd = new GridData(190, SWT.DEFAULT);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
filterZTypeCbo = new Combo(filterTypeComp, SWT.DROP_DOWN
| SWT.READ_ONLY);
filterZTypeCbo.setTextLimit(30);
@ -503,7 +507,7 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
private void createPointSetComp() {
Composite pntSetComp = new Composite(shell, SWT.NONE);
GridLayout pntSetCompGl = new GridLayout(2, false);
GridLayout pntSetCompGl = new GridLayout(2, true);
pntSetComp.setLayout(pntSetCompGl);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
pntSetComp.setLayoutData(gd);
@ -657,7 +661,6 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
OtherPrecipOptions.change_maxmin_flag = -1;
// initialize the gage filter values
// DailyQcUtils.elevation_filter_value = pntElFilter.getSelection();
pntFilter.setSelection(0);
pntRevFilter.setSelection(0);
dqc.pxtemp = (pxTempFilter.getSelection() - 100) / 100;

View file

@ -21,6 +21,7 @@ package com.raytheon.viz.mpe.ui.dialogs;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
@ -29,7 +30,6 @@ import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowData;
@ -72,7 +72,7 @@ import com.raytheon.viz.mpe.util.DailyQcUtils;
* day rollover >18Z occurs.
* Jan 15, 2016 5054 randerso Use proper parent shell
* Apr 05, 2016 18350 snaples Added method call to dqc.destroy to close instance of DQC Utils when exiting.
*
* Apr 11, 2016 5512 bkowal Fix GUI sizing issues. Cleanup.
* </pre>
*
* @author snaples
@ -85,11 +85,6 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
private static Combo dataDispCbo;
/**
* Font used for controls.
*/
private Font font;
public static Button upTimeBtn;
public static Button dnTimeBtn;
@ -140,18 +135,12 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
private DailyQcUtils dqc;
public static ArrayList<String> dataType = new ArrayList<String>();
public static List<String> dataType = new ArrayList<>();
public static ArrayList<String> dataSet = new ArrayList<String>();
public static List<String> dataSet = new ArrayList<>();
OtherPrecipOptions opo = new OtherPrecipOptions();
// int[] pcp_in_use;
// Pdata[] pdata = new Pdata[0];
// Ts[] ts;
private int time_pos;
public static Button[] tsbuttons = null;
@ -272,13 +261,11 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
shell.setText("QC Precipitation Options");
// Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, true);
mainLayout.marginHeight = 1;
mainLayout.marginWidth = 1;
GridLayout mainLayout = new GridLayout(1, false);
mainLayout.marginHeight = 0;
mainLayout.marginWidth = 0;
shell.setLayout(mainLayout);
font = new Font(shell.getDisplay(), "Courier", 10, SWT.NORMAL);
// Initialize all of the controls and layouts
this.initializeComponents();
@ -317,10 +304,8 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.qpf_flag = false;
isfinished = true;
isOpen = false;
font.dispose();
SaveLevel2Data s2 = new SaveLevel2Data(getShell());
s2.send_dbase_new_area();
dqc.destroy();
displayMgr.displayFieldData(df);
removePerspectiveListener();
if (MPEDisplayManager.getCurrent() != null) {
@ -359,7 +344,6 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.pcpn_time = 0;
for (i = 0; i < 8; i++) {
if (MPEDisplayManager.pcpn_time_step == 0) {
time_pos = DailyQcUtils.pcp_flag;
} else {
@ -371,7 +355,6 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
}
}
// ts = DailyQcUtils.ts;
this.createDataOptionsGroup();
this.createPointTypeGroup();
this.createPointQualityGroup();
@ -386,7 +369,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
private void createDataOptionsGroup() {
int i = 0;
Group dataOptionsGroup = new Group(shell, SWT.NONE);
dataOptionsGroup.setText(" Data Options ");
dataOptionsGroup.setText("Data Options");
GridLayout groupLayout = new GridLayout(1, false);
dataOptionsGroup.setLayout(groupLayout);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
@ -406,11 +389,13 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
six24CompLayout.marginHeight = 0;
six24CompLayout.marginWidth = 0;
six24Comp.setLayout(six24CompLayout);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
six24Comp.setLayoutData(gd);
Label six24Lbl = new Label(six24Comp, SWT.CENTER);
six24Lbl.setText("6/24 Hour:");
GridData sd = new GridData(140, SWT.DEFAULT);
GridData sd = new GridData(SWT.FILL, SWT.CENTER, true, false);
selsix24Cbo = new Combo(six24Comp, SWT.DROP_DOWN | SWT.READ_ONLY);
selsix24Cbo.setTextLimit(30);
selsix24Cbo.setLayoutData(sd);
@ -435,7 +420,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
RowLayout timeArrowRl = new RowLayout(SWT.HORIZONTAL);
timeArrowsComp.setLayout(timeArrowRl);
RowData rd = new RowData(25, 25);
RowData rd = new RowData(SWT.DEFAULT, SWT.DEFAULT);
upTimeBtn = new Button(timeArrowsComp, SWT.ARROW | SWT.UP);
upTimeBtn.setLayoutData(rd);
upTimeBtn.setEnabled(false);
@ -446,7 +431,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
}
});
rd = new RowData(25, 25);
rd = new RowData(SWT.DEFAULT, SWT.DEFAULT);
dnTimeBtn = new Button(timeArrowsComp, SWT.ARROW | SWT.DOWN);
dnTimeBtn.setLayoutData(rd);
dnTimeBtn.setEnabled(false);
@ -457,25 +442,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
}
});
GridData dd = new GridData(208, SWT.DEFAULT);
// int pd = DailyQcUtils.hrgt12z == 1 ? 1 : 0;
// if (pcp_flag == -1) {
// /*
// * Define the pcp_flag based on whether or not there is a partial
// * DQC day. This also depends on whether the time step is 6 or 24
// * hours. Initially this will be 24.
// */
// if (pd == 1) {
// pcp_flag = 4;
// pcpn_day = 1;
// } else {
// pcp_flag = 0;
// pcpn_day = 0;
// }
//
// }
GridData dd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
String[] a = new String[dataSet.size()];
dataDispCbo = new Combo(dataOptionsGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
dataDispCbo.setTextLimit(30);
@ -499,8 +466,10 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
renderCompLayout.marginHeight = 0;
renderCompLayout.marginWidth = 0;
renderComp.setLayout(renderCompLayout);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
renderComp.setLayoutData(gd);
gd = new GridData(153, 25);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
renderGridsBtn = new Button(renderComp, SWT.PUSH);
renderGridsBtn.setText("Render Grids+MAPs");
renderGridsBtn.setLayoutData(gd);
@ -520,18 +489,11 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
}
});
GridData bd = new GridData(110, 25);
GridData bd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
groupEditBtn = new Button(renderComp, SWT.PUSH);
groupEditBtn.setText("Group Edit");
groupEditBtn.setLayoutData(bd);
groupEditBtn.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
GroupEditStationsDialog groupDialog = new GroupEditStationsDialog(
@ -545,11 +507,13 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
pcpTypeCompLayout.marginHeight = 0;
pcpTypeCompLayout.marginWidth = 0;
pcpTypeComp.setLayout(pcpTypeCompLayout);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
pcpTypeComp.setLayoutData(gd);
Label pcpLbl = new Label(pcpTypeComp, SWT.CENTER);
pcpLbl.setText("Precip Type:");
gd = new GridData(190, SWT.DEFAULT);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
pcpTypeCbo = new Combo(pcpTypeComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pcpTypeCbo.setTextLimit(30);
pcpTypeCbo.setLayoutData(gd);
@ -570,7 +534,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
*/
private void createPointTypeGroup() {
Group pointTypeGroup = new Group(shell, SWT.NONE);
pointTypeGroup.setText(" Point Type ");
pointTypeGroup.setText("Point Type");
GridLayout gl = new GridLayout(1, false);
pointTypeGroup.setLayout(gl);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
@ -656,7 +620,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
*/
private void createPointQualityGroup() {
Group pointQualGroup = new Group(shell, SWT.NONE);
pointQualGroup.setText(" Point Quality ");
pointQualGroup.setText("Point Quality");
GridLayout gl = new GridLayout(1, false);
gl.marginWidth = 0;
pointQualGroup.setLayout(gl);
@ -752,7 +716,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
private void createPointSetComp() {
Composite pntSetComp = new Composite(shell, SWT.NONE);
GridLayout pntSetCompGl = new GridLayout(2, false);
GridLayout pntSetCompGl = new GridLayout(2, true);
pntSetComp.setLayout(pntSetCompGl);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
pntSetComp.setLayoutData(gd);
@ -762,7 +726,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.gage_char[0] = 1;
DailyQcUtils.gage_char[1] = 1;
gd = new GridData(160, SWT.DEFAULT);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
pntCharCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntCharCbo.setTextLimit(30);
pntCharCbo.setLayoutData(gd);
@ -782,6 +746,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.plot_view = 4;
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
pntDispCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntDispCbo.setTextLimit(30);
pntDispCbo.setLayoutData(gd);
@ -811,6 +776,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
i = 2;
}
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
pntScnCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntScnCbo.setTextLimit(30);
pntScnCbo.setLayoutData(gd);
@ -836,6 +802,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
i = 2;
}
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
pntTConCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntTConCbo.setTextLimit(30);
pntTConCbo.setLayoutData(gd);
@ -861,6 +828,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
i = 2;
}
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
pntSConCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntSConCbo.setTextLimit(30);
pntSConCbo.setLayoutData(gd);

View file

@ -66,6 +66,7 @@ import com.raytheon.viz.mpe.util.DailyQcUtils;
* Jan 15, 2016 5054 randerso Use proper parent shell
* Feb 22, 2016 18599 snaples Fixed static calls to DailyQCUtils.
* Apr 05, 2016 18350 snaples Added method call to dqc.destroy to close instance of DQC Utils when exiting.
* Apr 11, 2016 5512 bkowal Fix GUI sizing issues. Cleanup.
*
* </pre>
*
@ -132,10 +133,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
OtherTempOptions oto = new OtherTempOptions();
// Tdata[] tdata = new Tdata[0];
// Ts[] ts;
private int time_pos;
public static Button[] tsbuttons = null;
@ -323,7 +320,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
* Initialize the dialog components.
*/
private void initializeComponents() {
// tdata = DailyQcUtils.tdata;
DailyQcUtils.points_flag = 1;
DailyQcUtils.grids_flag = -1;
DailyQcUtils.map_flag = -1;
@ -337,8 +333,6 @@ 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;
}
dataSet.clear();
dataSet.addAll(dataType);
@ -348,7 +342,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.pcpn_time = 0;
for (i = 0; i < 8; i++) {
if (MPEDisplayManager.pcpn_time_step == 0) {
time_pos = 150 + DailyQcUtils.pcp_flag;
} else if (MPEDisplayManager.pcpn_time_step == 1) {
@ -362,7 +355,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
}
}
// ts = DailyQcUtils.ts;
this.createDataOptionsGroup();
this.createPointTypeGroup();
this.createPointQualityGroup();
@ -377,7 +369,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
private void createDataOptionsGroup() {
int i = 0;
Group dataOptionsGroup = new Group(shell, SWT.NONE);
dataOptionsGroup.setText(" Data Options ");
dataOptionsGroup.setText("Data Options");
GridLayout groupLayout = new GridLayout(1, false);
dataOptionsGroup.setLayout(groupLayout);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
@ -393,11 +385,13 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
maxmTimeCompLayout.marginHeight = 0;
maxmTimeCompLayout.marginWidth = 0;
maxmTimeComp.setLayout(maxmTimeCompLayout);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
maxmTimeComp.setLayoutData(gd);
Label maxmTimeLbl = new Label(maxmTimeComp, SWT.CENTER);
maxmTimeLbl.setText("6 Hour/MaxMin:");
GridData sd = new GridData(140, SWT.DEFAULT);
GridData sd = new GridData(SWT.FILL, SWT.CENTER, true, false);
maxminTimeCbo = new Combo(maxmTimeComp, SWT.DROP_DOWN | SWT.READ_ONLY);
maxminTimeCbo.setTextLimit(30);
maxminTimeCbo.setLayoutData(sd);
@ -424,7 +418,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
RowLayout timeArrowRl = new RowLayout(SWT.HORIZONTAL);
timeArrowsComp.setLayout(timeArrowRl);
RowData rd = new RowData(25, 25);
RowData rd = new RowData(SWT.DEFAULT, SWT.DEFAULT);
upTimeBtn = new Button(timeArrowsComp, SWT.ARROW | SWT.UP);
upTimeBtn.setLayoutData(rd);
upTimeBtn.setEnabled(false);
@ -435,7 +429,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
}
});
rd = new RowData(25, 25);
rd = new RowData(SWT.DEFAULT, SWT.DEFAULT);
dnTimeBtn = new Button(timeArrowsComp, SWT.ARROW | SWT.DOWN);
dnTimeBtn.setLayoutData(rd);
dnTimeBtn.setEnabled(false);
@ -446,7 +440,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
}
});
GridData dd = new GridData(208, SWT.DEFAULT);
GridData dd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
String[] a = new String[dataSet.size()];
dataDispCbo = new Combo(dataOptionsGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
@ -471,8 +465,10 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
renderCompLayout.marginHeight = 0;
renderCompLayout.marginWidth = 0;
renderComp.setLayout(renderCompLayout);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
renderComp.setLayoutData(gd);
gd = new GridData(153, 25);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
renderGridsBtn = new Button(renderComp, SWT.PUSH);
renderGridsBtn.setText("Render Grids+MATs");
renderGridsBtn.setLayoutData(gd);
@ -492,18 +488,11 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
}
});
GridData bd = new GridData(110, 25);
GridData bd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
groupEditBtn = new Button(renderComp, SWT.PUSH);
groupEditBtn.setText("Group Edit");
groupEditBtn.setLayoutData(bd);
groupEditBtn.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
GroupEditStationsDialog groupDialog = new GroupEditStationsDialog(
@ -518,7 +507,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
*/
private void createPointTypeGroup() {
Group pointTypeGroup = new Group(shell, SWT.NONE);
pointTypeGroup.setText(" Point Type ");
pointTypeGroup.setText("Point Type");
GridLayout gl = new GridLayout(1, false);
pointTypeGroup.setLayout(gl);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
@ -604,7 +593,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
*/
private void createPointQualityGroup() {
Group pointQualGroup = new Group(shell, SWT.NONE);
pointQualGroup.setText(" Point Quality ");
pointQualGroup.setText("Point Quality");
GridLayout gl = new GridLayout(1, false);
gl.marginWidth = 0;
pointQualGroup.setLayout(gl);
@ -612,14 +601,11 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
pointQualGroup.setLayoutData(gd);
int i;
// int qflag[] = dqc.qflag;
for (i = 0; i < 10; i++) {
DailyQcUtils.qflag[i] = 1;
DailyQcUtils.qflag[i] = 1;
}
// qflag[5] = -1;
boolean mpe_show_missing_gage_set = false;
if (dqc.mpe_show_missing_gage.length() > 0) {
if ((dqc.mpe_show_missing_gage.equalsIgnoreCase("All"))
@ -664,7 +650,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
"Questionable", "Partial", "Estimated", "Bad", "Missing", "All" };
for (i = 0; i < qsbuttons.length / 2; i++) {
final Button b = new Button(ltCkBxComp, SWT.CHECK);
b.setText(qbnames[i]);
b.setData(i);
@ -690,7 +675,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
qsbuttons[5].setEnabled(false);
}
for (i = 0; i < 10; i++) {
if (i == 5) {
continue;
}
@ -704,7 +688,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
private void createPointSetComp() {
Composite pntSetComp = new Composite(shell, SWT.NONE);
GridLayout pntSetCompGl = new GridLayout(2, false);
GridLayout pntSetCompGl = new GridLayout(2, true);
pntSetComp.setLayout(pntSetCompGl);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
pntSetComp.setLayoutData(gd);
@ -714,6 +698,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.plot_view = 4;
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
pntDispCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntDispCbo.setTextLimit(30);
pntDispCbo.setLayoutData(gd);
@ -744,6 +729,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
i = 2;
}
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
pntScnCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntScnCbo.setTextLimit(30);
pntScnCbo.setLayoutData(gd);
@ -757,7 +743,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
}
});
pntScnCbo.select(i);
}
private void createPointControlComp() {
@ -800,7 +785,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
public void mouseUp(MouseEvent e) {
opo.refresh_exposure();
}
});
pfvalueLabel
.setText(String.format("%3d", pntFilter.getSelection() - 50));
@ -881,7 +865,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.elevation_filter_value = sel;
opo.refresh_exposure();
}
});
pevalueLabel.setText(String.format("%d", pntElFilter.getSelection()));
@ -898,7 +881,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
opo.send_expose();
OtherTempOptions oto = new OtherTempOptions();
oto.set_temp_arrow_sensitivity();
}
public static float getPointFilterValue() {

View file

@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
@ -35,7 +36,7 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@ -51,13 +52,14 @@ import com.raytheon.uf.common.dataplugin.shef.tables.Rwbiasstat;
import com.raytheon.uf.common.dataplugin.shef.tables.Rwradarresult;
import com.raytheon.uf.common.dataplugin.shef.tables.DAARadarResult;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.hydrocommon.whfslib.IHFSDbGenerated;
import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.core.MPEDataManager.MPERadarData;
import com.raytheon.viz.mpe.core.MPEDataManager.MPERadarData.RadarAvailability;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.dialogs.gagetable.GageTableDataManager;
import com.raytheon.viz.mpe.ui.radartable.ReadBiasTableParam;
/**
@ -78,6 +80,8 @@ import com.raytheon.viz.mpe.ui.radartable.ReadBiasTableParam;
* May 8, 2014 DCS167 cgobs Updated Dialog for DualPol features
* May 23, 2014 DCS167 cgobs Resolved merge conflict
* Jul 29, 2015 17471 snaples Added logging for radar result table query date value.
* Apr 05, 2016 5504 bkowal Fix GUI sizing issues. Cleanup code - notify users of errors,
* use status handler, etc.
*
* </pre>
*
@ -87,6 +91,9 @@ import com.raytheon.viz.mpe.ui.radartable.ReadBiasTableParam;
public class RadarBiasTableDialog extends Dialog {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(getClass());
public static class Zerocoef_Data {
float mlt_zrcoef;
@ -97,8 +104,6 @@ public class RadarBiasTableDialog extends Dialog {
private Shell shell;
private Font font;
private Button applyBtn;
private Button closeBtn;
@ -107,7 +112,7 @@ public class RadarBiasTableDialog extends Dialog {
private final int retval = 0;
String[] radIds;
private final String[] radIds;
String rid = "";
@ -192,8 +197,9 @@ public class RadarBiasTableDialog extends Dialog {
float[] editedDPBiasValue = new float[60];
public RadarBiasTableDialog(Shell parentShell) {
public RadarBiasTableDialog(Shell parentShell, final String[] radIds) {
super(parentShell);
this.radIds = radIds;
}
/**
@ -210,12 +216,10 @@ public class RadarBiasTableDialog extends Dialog {
// Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, true);
mainLayout.marginHeight = 1;
mainLayout.marginWidth = 1;
mainLayout.marginHeight = 0;
mainLayout.marginWidth = 0;
shell.setLayout(mainLayout);
font = new Font(shell.getDisplay(), "Courier", 10, SWT.NORMAL);
// Initialize all of the controls and layouts
initializeComponents();
@ -228,8 +232,6 @@ public class RadarBiasTableDialog extends Dialog {
}
}
font.dispose();
return retval;
}
@ -237,12 +239,6 @@ public class RadarBiasTableDialog extends Dialog {
* Initialize the dialog components.
*/
private void initializeComponents() {
try {
radIds = GageTableDataManager.getInstance().getActiveRadarIds();
} catch (VizException e) {
e.printStackTrace();
}
String fxa_local_site = appsDefaults.getToken("fxa_local_site");
String where = "WHERE office_id = '" + fxa_local_site + "'";
bList = IHFSDbGenerated.GetRWBiasstat(where);
@ -266,20 +262,15 @@ public class RadarBiasTableDialog extends Dialog {
applyBtnComp.setLayout(applyBtnCompLayout);
applyBtnComp.setLayoutData(gd);
GridData bd = new GridData(110, SWT.DEFAULT);
final int minimumButtonWidth = applyBtnComp.getDisplay().getDPI().x;
GridData bd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
bd.minimumWidth = minimumButtonWidth;
applyBtn = new Button(applyBtnComp, SWT.PUSH);
applyBtn.setText("Apply");
applyBtn.setLayoutData(bd);
applyBtn.setEnabled(false);
applyBtn.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
applyBiasUpdate(dt);
@ -288,19 +279,12 @@ public class RadarBiasTableDialog extends Dialog {
}
});
bd = new GridData(110, SWT.DEFAULT);
bd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
bd.minimumWidth = minimumButtonWidth;
closeBtn = new Button(applyBtnComp, SWT.PUSH);
closeBtn.setText("Close");
closeBtn.setLayoutData(bd);
closeBtn.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
shell.dispose();
@ -310,7 +294,6 @@ public class RadarBiasTableDialog extends Dialog {
}
private void createDateComp() {
GridData bd = new GridData(SWT.LEFT, SWT.CENTER, true, true);
Composite dtLblComp = new Composite(shell, SWT.NONE);
GridLayout dtLblCompLayout = new GridLayout(1, false);
@ -331,7 +314,6 @@ public class RadarBiasTableDialog extends Dialog {
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
bcLblComp = new Composite(shell, SWT.NONE);
GridLayout bcLblCompLayout = new GridLayout(9, true);
bcLblCompLayout.marginWidth = 1;
bcLblComp.setLayout(bcLblCompLayout);
bcLblComp.setLayoutData(gd);
for (int i = 0; i < biasLabelStrings.length; i++) {
@ -347,23 +329,19 @@ public class RadarBiasTableDialog extends Dialog {
* Create the data options group and controls.
*/
private void createBiasListComp() {
final ScrolledComposite biasListScrollComp = new ScrolledComposite(
shell, SWT.BORDER | SWT.V_SCROLL);
GridLayout gl = new GridLayout(1, false);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, true);
gd.heightHint = 300;
biasListScrollComp.setLayout(gl);
biasListScrollComp.setLayoutData(gd);
// Create a container to hold the label and the combo box.
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, true);
final Composite biasListComp = new Composite(biasListScrollComp,
SWT.BORDER);
// dual pol version of table has 9 columns; previous table had 7 columns
GridLayout biasListCompLayout = new GridLayout(9, true);
final int numColumns = 9;
GridLayout biasListCompLayout = new GridLayout(numColumns, true);
biasListCompLayout.marginWidth = 0;
biasListComp.setLayout(biasListCompLayout);
gd.horizontalSpan = 9;
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, true);
gd.horizontalSpan = numColumns;
biasListComp.setLayoutData(gd);
biasListComp
.setSize(biasListComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
@ -371,9 +349,11 @@ public class RadarBiasTableDialog extends Dialog {
Date dt3 = MPEDisplayManager.getCurrent().getCurrentEditDate();
dt = pgsdf.format(dt3);
// This lets us know what date is being requested from radar result
// tables
System.out.println("Radar Bias table query using time: " + dt3);
/*
* This lets us know what date is being requested from radar result
* tables
*/
statusHandler.debug("Radar Bias table query using time: " + dt3);
radarIdToSPDataMap = MPEDataManager.getInstance().readSPRadarData(dt3);
radarIdToDPDataMap = MPEDataManager.getInstance().readDPRadarData(dt3);
@ -384,10 +364,28 @@ public class RadarBiasTableDialog extends Dialog {
spManEditButtonArray = new Button[radIds.length];
dpManEditButtonArray = new Button[radIds.length];
int biasRowHeight = 0;
if (radIds.length == 0) {
/*
* Display "No Data Available" message.
*/
final Label noDataAvailableLabel = new Label(biasListComp, SWT.NONE);
noDataAvailableLabel.setText("No Data Available");
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.horizontalSpan = numColumns;
noDataAvailableLabel.setLayoutData(gd);
GC gc = new GC(noDataAvailableLabel);
biasRowHeight = gc.getFontMetrics().getHeight()
+ noDataAvailableLabel.getBorderWidth()
+ biasListComp.getBorderWidth() + biasListComp.getSize().y;
gc.dispose();
}
for (int i = 0; i < radIds.length; i++) {
// get A and B coefficients from SP radar (does not apply to DP )
abzerocoef.mlt_zrcoef = 0.0f;
abzerocoef.pwr_zrcoef = 0.0f;
@ -412,7 +410,9 @@ public class RadarBiasTableDialog extends Dialog {
try {
dpaz = ReadBiasTableParam.getDpaadaptcoef(rid, dt);
} catch (VizException e1) {
e1.printStackTrace();
statusHandler.error(
"Failed to retrieve the dpaadapt cofficients for radar: "
+ radIds[i] + ". Defaulting to 0.", e1);
}
if (dpaz.length != 0) {
abzerocoef.mlt_zrcoef = dpaz[0];
@ -422,7 +422,7 @@ public class RadarBiasTableDialog extends Dialog {
// -----------------------------------------------------
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, true);
gd = new GridData(SWT.FILL, SWT.CENTER, true, true);
// radar id button
final Button ridBtn = new Button(biasListComp, SWT.PUSH);
@ -431,14 +431,6 @@ public class RadarBiasTableDialog extends Dialog {
ridBtn.setLayoutData(gd);
ridBtn.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org
* .eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
RadarSpanDialog rsd = new RadarSpanDialog(shell,
@ -477,7 +469,6 @@ public class RadarBiasTableDialog extends Dialog {
lbiasSPTxt.setData(i);
lbiasSPTxt.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
final int ei = (Integer) lbiasSPTxt.getData();
@ -485,7 +476,6 @@ public class RadarBiasTableDialog extends Dialog {
float parsedFloat = Float.parseFloat(lbiasSPTxt
.getText());
editedSPBiasValue[ei] = parsedFloat;
// spManEditButtonArray[ei].setSelection(!mbiasSPBtn.getSelection());
spManEditButtonArray[ei].setText("YES");
lbiasSPTxt.setBackground(getParent().getDisplay()
.getSystemColor(SWT.COLOR_WHITE));
@ -516,7 +506,6 @@ public class RadarBiasTableDialog extends Dialog {
// -------------------------------------------------------------
lbiasDPTxt.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
final int ei = (Integer) lbiasDPTxt.getData();
@ -524,7 +513,6 @@ public class RadarBiasTableDialog extends Dialog {
float parsedFloat = Float.parseFloat(lbiasDPTxt
.getText());
editedDPBiasValue[ei] = parsedFloat;
// dpManEditButtonArray[ei].setSelection(!mbiasDPBtn.getSelection());
dpManEditButtonArray[ei].setText("YES");
lbiasDPTxt.setBackground(getParent().getDisplay()
.getSystemColor(SWT.COLOR_WHITE));
@ -534,7 +522,6 @@ public class RadarBiasTableDialog extends Dialog {
lbiasDPTxt.setBackground(getParent().getDisplay()
.getSystemColor(SWT.COLOR_RED));
applyBtn.setEnabled(false);
}
}
});
@ -551,12 +538,6 @@ public class RadarBiasTableDialog extends Dialog {
spManEditButtonArray[i] = mbiasSPBtn;
mbiasSPBtn.addSelectionListener(new SelectionAdapter() {
/**
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
final int ai = (Integer) mbiasSPBtn.getData();
@ -583,12 +564,6 @@ public class RadarBiasTableDialog extends Dialog {
dpManEditButtonArray[i] = mbiasDPBtn;
mbiasDPBtn.addSelectionListener(new SelectionAdapter() {
/**
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
final int ai = (Integer) mbiasDPBtn.getData();
@ -597,8 +572,6 @@ public class RadarBiasTableDialog extends Dialog {
editedDPBiasValue[ai] = oldDPBiasValue[ai];
dpBiasValueTextArray[ai].setText(String.format(
"%-1.2f", editedDPBiasValue[ai]));
// consider replacing the value in the map instead of
// using put()
dpBiasChangeMap.put(radIds[ai], ai);
applyBtn.setEnabled(false);
dpManEditButtonArray[ai].setText("NO");
@ -653,8 +626,31 @@ public class RadarBiasTableDialog extends Dialog {
Label offcLbl = new Label(biasListComp, SWT.CENTER);
offcLbl.setText(ooffice);
offcLbl.setLayoutData(gd);
if (biasRowHeight == 0) {
/*
* Calculate the height of a single row.
*/
biasRowHeight = lbiasDPTxt.getLineHeight()
+ lbiasDPTxt.getBorderWidth()
+ biasListComp.getBorderWidth()
+ biasListComp.getSize().y;
}
}
biasListScrollComp.setContent(biasListComp);
/*
* Minimum number of rows to display in the dialog.
*/
final int minDisplayedRows = 8;
GridLayout gl = new GridLayout(1, false);
gl.marginWidth = 0;
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, true);
gd.heightHint = biasRowHeight * minDisplayedRows;
biasListScrollComp.setLayout(gl);
biasListScrollComp.setLayoutData(gd);
biasListScrollComp.setExpandVertical(true);
biasListScrollComp.setExpandHorizontal(true);
biasListScrollComp.addControlListener(new ControlAdapter() {
@ -664,6 +660,19 @@ public class RadarBiasTableDialog extends Dialog {
SWT.DEFAULT));
}
});
/*
* Set the grid layout on the header row composite to allow for optional
* additional right margin to accommodate a scroll bar. The margin will
* ensure that all header labels will line up correctly even if a
* scrollbar is present.
*/
if (radIds.length > minDisplayedRows
&& biasListScrollComp.getVerticalBar() != null
&& biasListScrollComp.getVerticalBar().getSize() != null
&& bcLblComp.getLayout() instanceof GridLayout) {
((GridLayout) bcLblComp.getLayout()).marginRight = biasListScrollComp
.getVerticalBar().getSize().x;
}
}
private void applyBiasUpdate(String obstime) {
@ -674,15 +683,14 @@ public class RadarBiasTableDialog extends Dialog {
private void applySPBiasUpdate(String obstime) {
String where = "";
final float memspan = -99.0f;
ArrayList<Rwradarresult> rwRadarResultList = new ArrayList<Rwradarresult>();
List<Rwradarresult> rwRadarResultList = new ArrayList<>();
Rwradarresult rwRadarResult = new Rwradarresult();
Iterator<String> bi = spBiasChangeMap.keySet().iterator();
while (bi.hasNext()) {
String rid = bi.next();
where = String.format("WHERE radid='%s' AND obstime='%s'", rid,
obstime);
rwRadarResultList = (ArrayList<Rwradarresult>) IHFSDbGenerated
.GetRWRadarResult(where);
rwRadarResultList = IHFSDbGenerated.GetRWRadarResult(where);
if (rwRadarResultList.size() != 0) {
rwRadarResult = rwRadarResultList.get(0);
} else {
@ -701,7 +709,6 @@ public class RadarBiasTableDialog extends Dialog {
IHFSDbGenerated.UpdateRWRadarResult(rwRadarResult);
}
spBiasChangeMap.clear();
return;
}
// ---------------------------------------------------------------------
@ -709,15 +716,14 @@ public class RadarBiasTableDialog extends Dialog {
private void applyDPBiasUpdate(String obstime) {
String where = "";
final float memspan = -99.0f;
ArrayList<DAARadarResult> daaRadarResultList = new ArrayList<DAARadarResult>();
List<DAARadarResult> daaRadarResultList = new ArrayList<>();
DAARadarResult daaRadarResult = new DAARadarResult();
Iterator<String> bi = dpBiasChangeMap.keySet().iterator();
while (bi.hasNext()) {
String rid = bi.next();
where = String.format("WHERE radid='%s' AND obstime='%s'", rid,
obstime);
daaRadarResultList = (ArrayList<DAARadarResult>) IHFSDbGenerated
.GetDAARadarResult(where);
daaRadarResultList = IHFSDbGenerated.GetDAARadarResult(where);
if (daaRadarResultList.size() != 0) {
daaRadarResult = daaRadarResultList.get(0);
} else {
@ -736,7 +742,6 @@ public class RadarBiasTableDialog extends Dialog {
IHFSDbGenerated.UpdateDAARadarResult(daaRadarResult);
}
dpBiasChangeMap.clear();
return;
}
}

View file

@ -20,22 +20,25 @@
package com.raytheon.viz.mpe.ui.dialogs.polygon;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
@ -58,6 +61,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 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.
* Apr 08, 2016 5504 bkowal Fix GUI sizing issues. Display tabular data in a {@link Table}.
* </pre>
*
* @author mpduff
@ -65,29 +69,64 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
*/
public class DeletePolygonDlg extends CaveSWTDialog {
private static final String format = "%-2s %27s %27s %21s %2.2f";
private static final String format2 = "%-2s %27s %27s %21s %8s";
private static final int NUM_POLYGON_ROWS = 7;
private static final String POLY_TRUE = "T";
private static final String POLY_FALSE = "F";
private static final int DISPLAY_COL_INDEX = 1;
private enum MPE_TABLE_COLUMNS {
NUMBER("Number", 12), DISPLAYED("Displayed", 16), PERSISTENT(
"Persistent", 20), ACTION("Action", 20), VALUE("Value", 16);
private final String text;
private final int numCharacters;
private MPE_TABLE_COLUMNS(String text, int numCharacters) {
this.text = text;
this.numCharacters = numCharacters;
}
public String getText() {
return text;
}
public int getNumCharacters() {
return numCharacters;
}
}
/**
* Date/Time Text Field.
* {@link Table} to display information about the current mpe polygons.
*/
private Text dateTimeTF = null;
private Table table;
/**
* Product Text Field.
* Date/Time Text Label.
*/
private Text productTF = null;
private Label dateTimeLbl;
/**
* Polygon List Text Field.
* Product Label.
*/
private List polygonListBox = null;
private Label productLbl;
private Button displayBtn;
private Button undisplayBtn;
private Button deleteBtn;
private Button deleteAllBtn;
/**
* Polygon list.
*/
private java.util.List<RubberPolyData> polygonList = new ArrayList<RubberPolyData>();
private List<RubberPolyData> polygonList = Collections.emptyList();
/**
* Simple date formatter.
@ -109,8 +148,8 @@ public class DeletePolygonDlg extends CaveSWTDialog {
@Override
protected Layout constructShellLayout() {
GridLayout mainLayout = new GridLayout(1, true);
mainLayout.marginHeight = 1;
mainLayout.marginWidth = 1;
mainLayout.marginHeight = 0;
mainLayout.marginWidth = 0;
return mainLayout;
}
@ -119,7 +158,7 @@ public class DeletePolygonDlg extends CaveSWTDialog {
setReturnValue(false);
Composite comp = createMainComposite();
createDateTimeProduct(comp);
createPolygonList(comp);
createPolygonTable(comp);
createPolygonButtons(comp);
createCloseButton(comp);
populateDlg();
@ -132,8 +171,8 @@ public class DeletePolygonDlg extends CaveSWTDialog {
*/
private Composite createMainComposite() {
Composite comp = new Composite(shell, SWT.NONE);
comp.setLayout(new GridLayout(2, true));
GridData gd = new GridData(500, SWT.DEFAULT);
comp.setLayout(new GridLayout(1, false));
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
comp.setLayoutData(gd);
return comp;
@ -147,25 +186,46 @@ public class DeletePolygonDlg extends CaveSWTDialog {
*/
private void createDateTimeProduct(Composite comp) {
// Create adjust group
Composite dateTimeComp = new Composite(comp, SWT.NONE);
dateTimeComp.setLayout(new GridLayout(2, false));
Composite headerComp = new Composite(comp, SWT.NONE);
GridLayout gl = new GridLayout(2, true);
gl.marginWidth = 0;
headerComp.setLayout(gl);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
headerComp.setLayoutData(gd);
Label dateTimeLbl = new Label(dateTimeComp, SWT.NONE);
dateTimeLbl.setText("Date/Time: ");
Composite dateTimeComp = new Composite(headerComp, SWT.NONE);
gl = new GridLayout(2, false);
gl.marginWidth = 0;
dateTimeComp.setLayout(gl);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
dateTimeComp.setLayoutData(gd);
GridData gd = new GridData(135, SWT.DEFAULT);
dateTimeTF = new Text(dateTimeComp, SWT.BORDER);
dateTimeTF.setLayoutData(gd);
gd = new GridData(SWT.DEFAULT, SWT.CENTER, false, false);
Label dtLbl = new Label(dateTimeComp, SWT.NONE);
dtLbl.setLayoutData(gd);
dtLbl.setText("Date/Time:");
dtLbl.setLayoutData(gd);
Composite productComp = new Composite(comp, SWT.NONE);
productComp.setLayout(new GridLayout(2, false));
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
dateTimeLbl = new Label(dateTimeComp, SWT.BORDER);
dateTimeLbl.setLayoutData(gd);
Composite productComp = new Composite(headerComp, SWT.NONE);
gl = new GridLayout(2, false);
gl.marginWidth = 0;
productComp.setLayout(gl);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
productComp.setLayoutData(gd);
gd = new GridData(SWT.DEFAULT, SWT.CENTER, false, false);
Label prodLbl = new Label(productComp, SWT.NONE);
prodLbl.setText("MPE Product: ");
prodLbl.setLayoutData(gd);
prodLbl.setText("MPE Product:");
prodLbl.setLayoutData(gd);
gd = new GridData(125, SWT.DEFAULT);
productTF = new Text(productComp, SWT.BORDER);
productTF.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
productLbl = new Label(productComp, SWT.BORDER);
productLbl.setLayoutData(gd);
}
/**
@ -174,21 +234,35 @@ public class DeletePolygonDlg extends CaveSWTDialog {
* @param comp
* The main composite
*/
private void createPolygonList(Composite comp) {
Composite dataComp = new Composite(comp, SWT.NONE);
dataComp.setLayout(new GridLayout(1, true));
GridData gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false, 2, 1);
dataComp.setLayoutData(gd);
private void createPolygonTable(Composite comp) {
table = new Table(comp, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
table.setHeaderVisible(true);
table.setLinesVisible(true);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = table.getItemHeight() * NUM_POLYGON_ROWS;
table.setLayoutData(gd);
Label label = new Label(dataComp, SWT.NONE);
label.setText("Number Displayed Persistent Action Value");
/*
* Add table columns.
*/
GC gc = new GC(table);
gc.setFont(table.getFont());
polygonListBox = new List(dataComp, SWT.BORDER | SWT.MULTI
| SWT.V_SCROLL);
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, true);
gd.widthHint = 480;
gd.heightHint = 150;
polygonListBox.setLayoutData(gd);
for (MPE_TABLE_COLUMNS mpeTableColumn : MPE_TABLE_COLUMNS.values()) {
TableColumn tc = new TableColumn(table, SWT.CENTER);
tc.setText(mpeTableColumn.getText());
tc.setWidth(gc.getFontMetrics().getAverageCharWidth()
* mpeTableColumn.getNumCharacters());
}
gc.dispose();
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleTableSelection(e);
}
});
}
/**
@ -199,38 +273,42 @@ public class DeletePolygonDlg extends CaveSWTDialog {
*/
private void createPolygonButtons(Composite comp) {
Composite buttonComp = new Composite(comp, SWT.NONE);
buttonComp.setLayout(new GridLayout(4, false));
GridData gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2, 1);
buttonComp.setLayout(new GridLayout(4, true));
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false);
buttonComp.setLayoutData(gd);
Button displayBtn = new Button(buttonComp, SWT.PUSH);
final int minimumButtonWidth = buttonComp.getDisplay().getDPI().x;
displayBtn = new Button(buttonComp, SWT.PUSH);
displayBtn.setText("Display");
gd = new GridData(116, SWT.DEFAULT);
displayBtn.setAlignment(SWT.CENTER);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.minimumWidth = minimumButtonWidth;
displayBtn.setLayoutData(gd);
displayBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
display(true, polygonListBox.getSelectionIndex());
display(true);
}
});
displayBtn.setEnabled(false);
Button undisplayBtn = new Button(buttonComp, SWT.PUSH);
undisplayBtn = new Button(buttonComp, SWT.PUSH);
undisplayBtn.setText("Undisplay");
gd = new GridData(116, SWT.DEFAULT);
undisplayBtn.setAlignment(SWT.CENTER);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.minimumWidth = minimumButtonWidth;
undisplayBtn.setLayoutData(gd);
undisplayBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
display(false, polygonListBox.getSelectionIndex());
display(false);
}
});
undisplayBtn.setEnabled(false);
Button deleteBtn = new Button(buttonComp, SWT.PUSH);
deleteBtn = new Button(buttonComp, SWT.PUSH);
deleteBtn.setText("Delete");
gd = new GridData(116, SWT.DEFAULT);
deleteBtn.setAlignment(SWT.CENTER);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.minimumWidth = minimumButtonWidth;
deleteBtn.setLayoutData(gd);
deleteBtn.addSelectionListener(new SelectionAdapter() {
@Override
@ -238,11 +316,12 @@ public class DeletePolygonDlg extends CaveSWTDialog {
delete();
}
});
deleteBtn.setEnabled(false);
Button deleteAllBtn = new Button(buttonComp, SWT.PUSH);
deleteAllBtn = new Button(buttonComp, SWT.PUSH);
deleteAllBtn.setText("Delete All");
gd = new GridData(116, SWT.DEFAULT);
deleteAllBtn.setAlignment(SWT.CENTER);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.minimumWidth = minimumButtonWidth;
deleteAllBtn.setLayoutData(gd);
deleteAllBtn.addSelectionListener(new SelectionAdapter() {
@Override
@ -250,6 +329,7 @@ public class DeletePolygonDlg extends CaveSWTDialog {
deleteAll();
}
});
deleteAllBtn.setEnabled(false);
}
/**
@ -257,15 +337,14 @@ public class DeletePolygonDlg extends CaveSWTDialog {
*/
private void createCloseButton(Composite comp) {
// Add separator
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false, 2, 1);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
Label sepLbl = new Label(comp, SWT.SEPARATOR | SWT.HORIZONTAL);
gd.widthHint = 480;
sepLbl.setLayoutData(gd);
Button closeBtn = new Button(comp, SWT.PUSH);
closeBtn.setText("Close");
gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false, 2, 1);
gd.widthHint = 90;
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.minimumWidth = closeBtn.getDisplay().getDPI().x;
closeBtn.setAlignment(SWT.CENTER);
closeBtn.setLayoutData(gd);
closeBtn.addSelectionListener(new SelectionAdapter() {
@ -283,75 +362,70 @@ public class DeletePolygonDlg extends CaveSWTDialog {
MPEDisplayManager displayManager = MPEDisplayManager.getCurrent();
Date editDate = displayManager.getCurrentEditDate();
DisplayFieldData fieldData = displayManager.getDisplayFieldType();
dateTimeTF.setText(sdf.format(editDate));
polygonListBox.removeAll();
dateTimeLbl.setText(sdf.format(editDate));
String type = displayManager.getDisplayFieldType().getFieldName();
productTF.setText(type);
productLbl.setText(type);
polygonList = PolygonEditManager.getPolygonEdits(fieldData, editDate);
recreatePolygonListBox();
populatePolygonTable();
}
/**
* Recreates the polygonListBox based on polygonList field
*/
private void recreatePolygonListBox() {
int[] selected = polygonListBox.getSelectionIndices();
polygonListBox.removeAll();
private void populatePolygonTable() {
table.removeAll();
if (polygonList.isEmpty()) {
displayBtn.setEnabled(false);
undisplayBtn.setEnabled(false);
deleteBtn.setEnabled(false);
deleteAllBtn.setEnabled(false);
return;
}
for (int i = 0; i < polygonList.size(); i++) {
RubberPolyData data = polygonList.get(i);
String number = String.valueOf(i + 1);
String displayed = "F";
if (data.isVisible()) {
displayed = "T";
}
final PolygonEditAction action = data.getEditAction();
String persist = "F";
if (data.isPersistent()) {
persist = "T";
}
final String number = String.valueOf(i + 1);
final String displayed = data.isVisible() ? POLY_TRUE : POLY_FALSE;
final String persist = data.isPersistent() ? POLY_TRUE : POLY_FALSE;
final String value = (action == PolygonEditAction.SUB) ? data
.getSubDrawSource().getFieldName() : Double.toString(data
.getPrecipValue());
PolygonEditAction action = data.getEditAction();
if (action == PolygonEditAction.SUB) {
String value = data.getSubDrawSource().getFieldName();
polygonListBox.add(String.format(format2, number, displayed,
persist, action.toPrettyName(), value));
} else {
double value = data.getPrecipValue();
polygonListBox.add(String.format(format, number, displayed,
persist, action.toPrettyName(), value));
}
TableItem ti = new TableItem(table, SWT.NONE);
ti.setData(data);
final String[] tableItemValues = new String[] { number, displayed,
persist, action.toPrettyName(), value };
ti.setText(tableItemValues);
}
int numGood = 0;
for (int idx : selected) {
if (idx >= 0 && idx < polygonListBox.getItemCount()) {
numGood += 1;
}
deleteAllBtn.setEnabled(true);
}
private void handleTableSelection(SelectionEvent e) {
if (table.getSelectionCount() <= 0) {
this.displayBtn.setEnabled(false);
this.undisplayBtn.setEnabled(false);
this.deleteBtn.setEnabled(false);
return;
}
int[] newSelected = new int[numGood];
int i = 0;
for (int idx : selected) {
if (idx >= 0 && idx < polygonListBox.getItemCount()) {
newSelected[i++] = idx;
}
}
polygonListBox.select(newSelected);
RubberPolyData data = (RubberPolyData) table.getSelection()[0]
.getData();
final boolean visible = data.isVisible();
this.displayBtn.setEnabled(!visible);
this.undisplayBtn.setEnabled(visible);
this.deleteBtn.setEnabled(true);
}
/**
* Delete the selected polygon.
*/
private void delete() {
// Make sure a selection has been made.
if (polygonListBox.getSelectionIndex() < 0) {
return;
}
// Remove selected from list and apply
RubberPolyData polygon = polygonList.remove(polygonListBox
.getSelectionIndex());
applyPolygonList(polygon.isPersistent());
RubberPolyData data = (RubberPolyData) table.getSelection()[0]
.getData();
polygonList.remove(data);
applyPolygonList(data.isPersistent(), true);
}
/**
@ -367,7 +441,7 @@ public class DeletePolygonDlg extends CaveSWTDialog {
}
}
polygonList.clear();
applyPolygonList(persistentRemoved);
applyPolygonList(persistentRemoved, true);
}
/**
@ -379,21 +453,27 @@ public class DeletePolygonDlg extends CaveSWTDialog {
* @param polygon
* The polygon to display/undisplay
*/
private void display(boolean display, int polygon) {
if (polygon >= 0 && polygon < polygonList.size()) {
RubberPolyData data = polygonList.get(polygon);
data.setVisible(display);
applyPolygonList(false);
}
private void display(boolean display) {
TableItem tableItem = table.getSelection()[0];
RubberPolyData data = (RubberPolyData) tableItem.getData();
data.setVisible(display);
applyPolygonList(data.isPersistent(), false);
tableItem
.setText(DISPLAY_COL_INDEX, (display) ? POLY_TRUE : POLY_FALSE);
displayBtn.setEnabled(!display);
undisplayBtn.setEnabled(display);
}
private void applyPolygonList(boolean persistentRemoved) {
private void applyPolygonList(final boolean persistentRemoved, final boolean populate) {
MPEDisplayManager displayManager = MPEDisplayManager.getCurrent();
DisplayFieldData fieldData = displayManager.getDisplayFieldType();
Date editDate = displayManager.getCurrentEditDate();
PolygonEditManager.writePolygonEdits(fieldData, editDate, polygonList,
persistentRemoved);
recreatePolygonListBox();
if (populate) {
populatePolygonTable();
}
}
}

View file

@ -30,13 +30,13 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridData;
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.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Shell;
@ -67,6 +67,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 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.
* Apr 07, 2016 5504 bkowal Fix GUI sizing issues.
*
* </pre>
*
@ -90,11 +91,6 @@ public class DrawPolygonDlg extends CaveSWTDialog {
*/
private Font boldFont = null;
/**
* Normal font.
*/
private Font font = null;
/**
* The field type selection Combo control.
*/
@ -152,14 +148,13 @@ public class DrawPolygonDlg extends CaveSWTDialog {
protected Layout constructShellLayout() {
// Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, true);
mainLayout.marginHeight = 1;
mainLayout.marginWidth = 1;
mainLayout.marginHeight = 0;
mainLayout.marginWidth = 0;
return mainLayout;
}
@Override
protected void disposed() {
font.dispose();
boldFont.dispose();
resource.clearPolygons();
}
@ -168,8 +163,6 @@ public class DrawPolygonDlg extends CaveSWTDialog {
protected void initializeComponents(final Shell shell) {
setReturnValue(false);
boldFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.BOLD);
font = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
// Initialize all of the controls and layoutsendCal
initializeComponents();
shell.addControlListener(new ControlAdapter() {
@ -215,10 +208,14 @@ public class DrawPolygonDlg extends CaveSWTDialog {
private void createPersistentGroup() {
// Create adjust group
Group persistentGroupComp = new Group(shell, SWT.NONE);
FontData fontData = persistentGroupComp.getFont().getFontData()[0];
this.boldFont = new Font(getDisplay(), new FontData(fontData.getName(),
fontData.getHeight(), SWT.BOLD));
persistentGroupComp.setFont(boldFont);
persistentGroupComp.setText(ADJUST_PRECIP_TEXT);
persistentGroupComp.setLayout(new GridLayout(1, true));
GridData gd = new GridData(345, SWT.DEFAULT);
persistentGroupComp.setLayout(new GridLayout(1, false));
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
persistentGroupComp.setLayoutData(gd);
getPersistentChk(persistentGroupComp);
@ -234,8 +231,8 @@ public class DrawPolygonDlg extends CaveSWTDialog {
Group subGroup = new Group(shell, SWT.NONE);
subGroup.setFont(boldFont);
subGroup.setText(SUBSTITUTE_VALUE_TEXT);
subGroup.setLayout(new GridLayout(2, false));
GridData gd = new GridData(345, SWT.DEFAULT);
subGroup.setLayout(new GridLayout(1, false));
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
subGroup.setLayoutData(gd);
createFieldCombo(subGroup);
@ -243,7 +240,8 @@ public class DrawPolygonDlg extends CaveSWTDialog {
// Create Substitute button
final Button subBtn = new Button(subGroup, SWT.PUSH);
subBtn.setData(PolygonEditAction.SUB);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2, 1);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.minimumWidth = subBtn.getDisplay().getDPI().x;
subBtn.setText("Substitute");
subBtn.setLayoutData(gd);
subBtn.addSelectionListener(new SelectionAdapter() {
@ -260,8 +258,8 @@ public class DrawPolygonDlg extends CaveSWTDialog {
private void createCloseBtn() {
Button closeBtn = new Button(shell, SWT.PUSH);
closeBtn.setText("Close");
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false, 1, 1);
closeBtn.setAlignment(SWT.CENTER);
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.minimumWidth = closeBtn.getDisplay().getDPI().x;
closeBtn.setLayoutData(gd);
closeBtn.addSelectionListener(new SelectionAdapter() {
@Override
@ -279,10 +277,9 @@ public class DrawPolygonDlg extends CaveSWTDialog {
*/
private void getPersistentChk(Group groupComp) {
persistentChk = new Button(groupComp, SWT.CHECK);
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false);
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
persistentChk.setLayoutData(gd);
persistentChk.setText(MAKE_PERSISTENT);
persistentChk.setFont(font);
}
/**
@ -293,9 +290,12 @@ public class DrawPolygonDlg extends CaveSWTDialog {
*/
private void getSliderComp(Group groupComp) {
Composite comp = new Composite(groupComp, SWT.NONE);
comp.setLayout(new GridLayout(2, false));
GridLayout gl = new GridLayout(2, false);
comp.setLayout(gl);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
comp.setLayoutData(gd);
GridData gd = new GridData(250, 30);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
precipSlider = new Scale(comp, SWT.HORIZONTAL);
precipSlider.setMinimum(0);
precipSlider.setMaximum(500);
@ -310,7 +310,7 @@ public class DrawPolygonDlg extends CaveSWTDialog {
// Create the Red color spinner.
precipSpinner = new Spinner(comp, SWT.BORDER);
gd = new GridData(30, SWT.DEFAULT);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false);
precipSpinner.setLayoutData(gd);
precipSpinner.setMinimum(0);
precipSpinner.setMaximum(500);
@ -333,7 +333,9 @@ public class DrawPolygonDlg extends CaveSWTDialog {
*/
private void getButtonComp(Group groupComp) {
Composite comp = new Composite(groupComp, SWT.NONE);
comp.setLayout(new GridLayout(5, false));
comp.setLayout(new GridLayout(5, true));
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
comp.setLayoutData(gd);
PolygonEditAction[] editBtns = new PolygonEditAction[] {
PolygonEditAction.SET, PolygonEditAction.RAISE,
@ -344,7 +346,8 @@ public class DrawPolygonDlg extends CaveSWTDialog {
Button editBtn = new Button(comp, SWT.PUSH);
editBtn.setText(action.toPrettyName());
editBtn.setData(action);
editBtn.setLayoutData(new GridData(60, SWT.DEFAULT));
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
editBtn.setLayoutData(gd);
editBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
@ -366,15 +369,10 @@ public class DrawPolygonDlg extends CaveSWTDialog {
// 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);
GridLayout prodListCompLayout = new GridLayout(2, false);
GridLayout prodListCompLayout = new GridLayout(1, false);
prodListComp.setLayout(prodListCompLayout);
prodListComp.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
Label fieldTypeLabel = new Label(prodListComp, SWT.CENTER);
fieldTypeLabel.setText(SUBSTITUTE_VALUE_TEXT);
fieldTypeLabel.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
fieldTypeCombo = new Combo(groupComp, SWT.LEFT | SWT.DROP_DOWN
| SWT.READ_ONLY);
@ -401,7 +399,6 @@ public class DrawPolygonDlg extends CaveSWTDialog {
displayTypeNameArray = new String[displayFieldDataArray.length];
for (int i = 0; i < displayFieldDataArray.length; i++) {
String fieldName = displayFieldDataArray[i].toString();
displayTypeNameArray[i] = fieldName;
}

View file

@ -156,6 +156,8 @@ public class AlarmAlertDlg extends CaveSWTDialog {
// Opens the dialog without ever displaying it, doing all the initialization
// necessary to load the alarm list and get it functioning.
// TODO: restructure code to get rid of this abomination
public void openInvisible() {
Shell parent = getParent();
@ -188,8 +190,6 @@ public class AlarmAlertDlg extends CaveSWTDialog {
}
});
preOpened();
opened();
}

View file

@ -102,7 +102,7 @@ import com.raytheon.viz.ui.dialogs.ModeListener;
* Jul 24, 2014 3423 randerso Created eclipse job to get afos command
* execution off the UI thread
* Sep 09, 2014 3580 mapeters Removed IQueryTransport usage (no longer exists).
* Mar 30, 2016 5513 randerso Fixed to display on same monitor as parent,
* Mar 30, 2016 5513 randerso Fixed to display on same monitor as parent,
* significant code cleanup
* </pre>
*
@ -224,6 +224,7 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
* initialization necessary to get alarms/alerts up and running without the
* user ever having to do more than open the text workstation.
*/
// TODO: restructure code to get rid of this abomination
public void openInvisible() {
Shell parent = getParent();
@ -385,6 +386,8 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
if (dlg == null || dlg.getShell().isDisposed()) {
dlg = new AlarmAlertDlg(shell);
}
// call preOpened() to compute correct location
dlg.preOpened();
dlg.open();
}
});

View file

@ -385,6 +385,7 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeOperations;
* Moved upper case conversion for QC checks into the
* specific checks that need it.
* Mar 17, 2016 RM 18727 D. Friedman Fix use of verification listener when entering and exiting editor.
* Apr 15, 2016 RM 18870 D. Friedman Replace commas with ellipses only at start of edit and then word-wrap.
*
* </pre>
*
@ -4185,19 +4186,18 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
// section
setCurrentHeaderAndBody();
// Mark the uneditable warning text
if (markUneditableText(textEditor)) {
// Enable listener to monitor attempt to edit locked text
verifyUndeditableText = true;
}
// if product is a WarnGen product and is not enabled for mixed case
// transmission, replace all commas with ellipses
if (TextEditorCfg.getTextEditorCfg().getReplaceCommasWithEllipses()
&& product != null && warngenPils.contains(product.getNnnid())
&& !MixedCaseProductSupport.isMixedCase(product.getNnnid())) {
textEditor.setText(textEditor.getText()
.replaceAll(", {0,1}", "..."));
}
// Mark the uneditable warning text
if (markUneditableText(textEditor)) {
// Enable listener to monitor attempt to edit locked text
verifyUndeditableText = true;
replaceCommasWithEllipses(product);
}
// Set the menu buttons to reflect the edit mode.
@ -4227,6 +4227,60 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
editHeader("warning", true);
}
private void replaceCommasWithEllipses(StdTextProduct product) {
boolean wasVerifying = verifyUndeditableText;
try {
verifyUndeditableText = false;
/*
* Performing wrapping as few times as possible to reduce the
* chances of breaking the product format. Also, the location list
* does not wrap properly unless all commas in the paragraph have
* been changed to ellipses.
*/
Pattern p = Pattern.compile(", {0,1}");
int pendingParagraphLineStart = -1;
while (true) {
String text = textEditor.getText();
Matcher m = p.matcher(text);
if (! m.find())
break;
int line = textEditor.getLineAtOffset(m.start());
int paragraphLineStart = findParagraphStart(line);
String lineText = textEditor.getLine(line);
boolean lineNeedsWrap = lineText.length()
- (m.end() - m.start()) + 3 > charWrapCol;
if (pendingParagraphLineStart >= 0
&& paragraphLineStart != pendingParagraphLineStart
&& lineNeedsWrap) {
wrapWholeParagraphAtLine(pendingParagraphLineStart);
pendingParagraphLineStart = -1;
// Line numbers may have changed so restart.
continue;
}
textEditor.replaceTextRange(m.start(), m.end() - m.start(), "...");
if (lineNeedsWrap) {
pendingParagraphLineStart = paragraphLineStart;
}
}
if (pendingParagraphLineStart >= 0) {
wrapWholeParagraphAtLine(pendingParagraphLineStart);
}
} finally {
verifyUndeditableText = wasVerifying;
}
}
void wrapWholeParagraphAtLine(int paragraphLineStart) {
String line = textEditor.getLine(paragraphLineStart);
// Avoid rewrapInternal early bailout check.
if (line.length() < charWrapCol
&& line.indexOf("...") == line.lastIndexOf("...")) {
paragraphLineStart++;
}
int offset = textEditor.getOffsetAtLine(paragraphLineStart);
rewrap(offset, offset);
}
/**
* Cancel the editor mode.
*
@ -8037,7 +8091,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
paragraphStart = paragraphStart.toUpperCase();
// is this the locations paragraph?
if (paragraphStart.startsWith("* LOCATIONS")) {
if (paragraphStart.startsWith("* LOCATIONS")
|| paragraphStart.startsWith(("* SOME LOCATIONS"))
|| paragraphStart.startsWith(("LOCATIONS IMPACTED"))
|| paragraphStart.startsWith(("SOME LOCATIONS THAT"))) {
inLocations = true;
}
@ -8078,7 +8135,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
if (line.length() <= charWrapCol) {
extendShortLine(lineNumber, padding);
extendShortLine(lineNumber, padding, inLocations);
if (textEditor.getLine(lineNumber).length() <= charWrapCol) {
// extended line is still short enough do not wrap
if (lineNumber < endWrapLine) {
@ -8109,8 +8166,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
*
* @param lineNumber
* @param padding
* @param inLocations
*/
private void extendShortLine(int lineNumber, final String padding) {
private void extendShortLine(int lineNumber, final String padding, boolean inLocations) {
// if the line is too short move the next line up
// if there is a next line
String line = textEditor.getLine(lineNumber);
@ -8190,10 +8248,12 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
String wordSpace = "";
if (noSeparatorPattern.matcher(endLine).matches()
&& noSeparatorPattern.matcher(startNextLine)
.matches()) {
.matches()
&& (!inLocations || !line.endsWith("..."))) {
// Put a space between words when merging the lines.
wordSpace = " ";
}
textEditor.replaceTextRange(newlinePosition, deleteLen,
wordSpace);
String afterReplace = textEditor.getText();
@ -8207,7 +8267,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
// is this line still too short?
if (textEditor.getLine(lineNumber).length() <= charWrapCol) {
extendShortLine(lineNumber, padding);
extendShortLine(lineNumber, padding, inLocations);
}
}
}
@ -8460,7 +8520,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
private void recompileRegex() {
this.standardWrapRegex = Pattern.compile("( |..).{1,"
+ (charWrapCol - 3) + "}(\\s|-)");
this.locationsFirstRegex = Pattern.compile("^\\* LOCATIONS [^\\.]{1,"
this.locationsFirstRegex = Pattern.compile("^(?:\\* (?:SOME )?LOCATIONS|LOCATIONS IMPACTED|SOME LOCATIONS THAT) [^\\.]{1,"
+ (charWrapCol - 13) + "}\\s");
this.locationsBodyRegex = Pattern.compile("(( |..).{1,"
+ (charWrapCol - 5) + "}\\.\\.\\.)|(( |..).{1,"

View file

@ -64,6 +64,7 @@ import com.raytheon.viz.texteditor.util.VtecUtil;
* 15 SEP 2014 529 mgamazaychikov Create firstBulletImmediateCauseQCExclusions list and add IC to it.
* 29 MAY 2015 4441 randerso Fixed QC to work with mixed case
* 24 NOV 2015 DR 17501 dhuffman Added lookaheads to ugc pattern to remove the telephone number special case.
* 28 APR 2016 DR 18947 D. Friedman Fixed UGC pattern.
*
* </pre>
*
@ -71,8 +72,12 @@ import com.raytheon.viz.texteditor.util.VtecUtil;
*/
public class TextSegmentCheck implements IQCCheck {
/*
* In order to keep this pattern simple, it does not exclude empty lines.
* The empty line case must be handled separately.
*/
private static final Pattern ugcPtrn = Pattern
.compile("(^(?!\\d{3}-\\d{4}[^-]*)^(?!\\d{3}-\\d{3}-\\d{4}[^-]*)(((\\w{2}[CZ](\\d{3}-){1,}){1,})|(\\d{3}-){1,})(((\\d{2})(\\d{2})(\\d{2})-){0,1}))");
.compile("^(?:(?:[A-Z]{2}[CZ]\\d{3}-)?(?:\\d{3}-)*)*(?:\\d{6}-)?$");
private static Map<String, List<String>> bulletTypeMaps;
static {
@ -191,7 +196,7 @@ public class TextSegmentCheck implements IQCCheck {
}
m = ugcPtrn.matcher(line);
if (m.find()) {
if (m.find() && m.start() != m.end()) {
ugc += line;
countUGC = true;
continue;

View file

@ -1,19 +1,39 @@
package com.raytheon.viz.warnings.rsc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord;
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
import com.raytheon.uf.viz.core.RecordFactory;
import com.raytheon.uf.viz.core.alerts.AbstractAlertMessageParser;
import com.raytheon.uf.viz.core.alerts.AlertMessage;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
/**
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Apr 21, 2016 DR 18905 Qinglu Lin Added code to handle no SPS auto-update issue.
*
*/
@XmlAccessorType(XmlAccessType.NONE)
public class CWASPSResourceData extends WWAResourceData {
private static AlertMessageToPDOParserSPS alertParser = new AlertMessageToPDOParserSPS();
/*
* (non-Javadoc)
*
@ -34,4 +54,42 @@ public class CWASPSResourceData extends WWAResourceData {
return new CWASPSResource(this, loadProperties);
}
@Override
public AbstractAlertMessageParser getAlertParser() {
return alertParser;
}
private static class AlertMessageToPDOParserSPS extends AbstractAlertMessageParser {
@Override
public Object parseAlertMessage(AlertMessage message,
AbstractRequestableResourceData reqResourceData) throws VizException {
Object objectToSend = null;
Map<String, Object> attribs = new HashMap<>(message.decodedAlert);
if (reqResourceData.isUpdatingOnMetadataOnly()) {
PluginDataObject record = RecordFactory.getInstance()
.loadRecordFromMap(attribs);
objectToSend = record;
} else {
/*
* TODO avoid requesting data that will not be used, for example
* when time matching won't allow the frame to be displayed.
*/
attribs.remove(PluginDataObject.DATAURI_ID);
DbQueryRequest request = new DbQueryRequest(
RequestConstraint.toConstraintMappingExcludeNull(attribs));
request.setLimit(1);
DbQueryResponse response = (DbQueryResponse) ThriftClient
.sendRequest(request);
PluginDataObject[] pdos = response
.getEntityObjects(PluginDataObject.class);
if (pdos.length > 0) {
objectToSend = pdos[0];
}
}
return objectToSend;
}
}
}

View file

@ -35,6 +35,7 @@ import gov.noaa.nws.ost.dataplugin.stq.SpotRequestRecord;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* July 29, 2015 DCS17366 pwang Initial creation
* Apr 22, 2016 DCS18916 pwang Support two STQ formats
*
* </pre>
*
@ -104,7 +105,7 @@ public class SpotRequestParser {
PROPERTY_PATTERN_MAP.put("SIZE_NAME", "SIZE\\s*\\(ACRES\\)");
PROPERTY_PATTERN_MAP.put("SITE_NAME", "SITE");
PROPERTY_PATTERN_MAP.put("OFILE_NAME", "OFILE");
PROPERTY_PATTERN_MAP.put("OFILE_VALUE", "\\d{8}\\.\\w{5}\\.\\d{2}");
PROPERTY_PATTERN_MAP.put("OFILE_VALUE", "(\\d{8}\\.\\w{5}\\.\\d{2})|(\\d{7}\\.\\d{1,})");
PROPERTY_PATTERN_MAP.put("TIMEZONE_NAME", "TIMEZONE");
PROPERTY_PATTERN_MAP.put("TIMEZONE_VALUE", "\\w{3}\\d{1}(\\w{3})?");
}
@ -351,10 +352,25 @@ public class SpotRequestParser {
if (propertyValue.matches(PROPERTY_PATTERN_MAP
.get("OFILE_VALUE"))) {
String[] ofileArray = propertyValue.split(DOT_DELIMINATER);
stgPDO.setOfileKey(ofileArray[1]);
stgPDO.setOfileVersion(ofileArray[2]);
String stationId = "";
if(ofileArray == null || ofileArray.length < 2) {
logger.error("STQ Parser: Invalid OFILE Value or fomat: " + propertyValue);
status = false;
}
else if(ofileArray.length < 3) {
//New OFILE value format YY#####.UUUU
stgPDO.setOfileKey(ofileArray[0]);
stgPDO.setOfileVersion(ofileArray[1]);
stationId = ofileArray[0] + ofileArray[1];
}
else {
//Old format: YYYYMMDD.CCCCC.##
stgPDO.setOfileKey(ofileArray[1]);
stgPDO.setOfileVersion(ofileArray[2]);
stationId = ofileArray[1] + ofileArray[2];
}
stgPDO.getLocation()
.setStationId(ofileArray[1] + ofileArray[2]);
.setStationId(stationId);
}
else {
//OFILE is required, return false to discontinue the parsing

View file

@ -0,0 +1,37 @@
#!/awips2/python/bin/python
# Adds the gfe/combinations permission to user ALL for all site level userRoles.xml files
USER_ROLES_PATH = "/awips2/edex/data/utility/common_static/site/*/roles/userRoles.xml"
COMBINATIONS_PERMISSION = "com.raytheon.localization.site/cave_static/gfe/combinations"
import glob
import sys
import xml.etree.ElementTree as ET
def main():
for path in glob.iglob(USER_ROLES_PATH):
print "Updating", path
tree = ET.parse(path)
root = tree.getroot()
for user in root.iterfind("user"):
userId = user.attrib["userId"]
if userId == "ALL":
found = False
for userPermission in user.iterfind("userPermission"):
if userPermission.text == COMBINATIONS_PERMISSION:
found = True
break
if found:
print "userId", userId, "already has", COMBINATIONS_PERMISSION
else:
print "Adding", COMBINATIONS_PERMISSION, "to userId", userId
sub = ET.SubElement(user, "userPermission")
sub.text = COMBINATIONS_PERMISSION
# write out the updated file
tree.write(path)
break
if __name__ == '__main__':
main()

View file

@ -213,39 +213,6 @@
</java>
</target>
<target name="buildHybrid" depends="clean">
<echo message="feature=com.raytheon.uf.common.base.feature" />
<java
classname="org.eclipse.core.launcher.Main"
fork="true"
failonerror="true">
<arg value="-application" />
<arg value="org.eclipse.ant.core.antRunner" />
<arg value="-buildfile" />
<arg value="${uframe.eclipse}/plugins/${pde.build.script}" />
<arg value="-DbaseLocation=${uframe.eclipse}" />
<arg value="-Dbuilder=${basedir}/edex" />
<arg value="-DbuildDirectory=${basedir}/edex/tmp" />
<arg value="-DtopLevelElementId=com.raytheon.uf.common.base.feature" />
<arg value="-Dbase=${basedir}/edex" />
<arg value="-Dconfigs=${build.os},${build.ws},${build.arch}" />
<arg value="-Dgenerate.p2.metadata=true" />
<arg value="-Dp2.metadata.repo=file:/${basedir}/edex/postBuild/awips2/cave/.repository" />
<arg value="-Dp2.artifact.repo=file:/${basedir}/edex/postBuild/awips2/cave/.repository" />
<arg value="-Dp2.publish.artifacts=true" />
<arg value="-DgenerateVersionsList=true" />
<classpath>
<pathelement
location="${uframe.eclipse}/plugins/${eclipse.launcher.jar}" />
</classpath>
</java>
<antcall target="clean" />
</target>
<target name="clean">
<if>
<available file="${basedir}/edex/includes"

View file

@ -62,6 +62,7 @@ import com.raytheon.uf.common.wmo.WMOTimeParser;
* Jun 19, 2014 3226 bclement added validator callback
* Jul 07, 2015 4581 skorolev Corrected decodeStrikes to avoid BufferUnderflowException.
* Apr 07, 2016 DR18763 mgamazaychikov Switched to using LightningWMOHeader.
* Apr 21, 2016 DR18849 mgamazaychikov Decrypt all data in decrypt method.
* May 02, 2016 18336 amoore Keep-alive messages should update the legend.
*
* </pre>
@ -201,9 +202,19 @@ public class TotalLightningDecoder {
*/
private PluginDataObject[] decodeInternal(LightningWMOHeader wmoHdr,
String fileName, byte[] pdata) throws DecoderException {
if (!validFlashPacket(pdata, COMBINATION_PACKET_HEADER_SIZE)) {
/* assume data is encrypted if we can't understand it */
pdata = decrypt(wmoHdr, fileName, pdata);
byte[] pdataPreDecrypt = pdata;
// determine if the data is encrypted or not based on comparing
// checksums for flash packet
pdata = decrypt(wmoHdr, fileName, pdata);
boolean isDecryptedValid = validFlashPacket(pdata,
COMBINATION_PACKET_HEADER_SIZE);
boolean isPreDecryptedValid = validFlashPacket(pdataPreDecrypt,
COMBINATION_PACKET_HEADER_SIZE);
// assume that all data is encrypted, so decrypt it
if (!isDecryptedValid && isPreDecryptedValid) {
// this means that data is not encrypted, proceed without
// decryption
pdata = pdataPreDecrypt;
}
List<LightningStrikePoint> strikes = decodeStrikes(fileName, pdata);

View file

@ -211,11 +211,6 @@
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.ConfigureTextProductsRequest"/>
<constructor-arg ref="configureTextProductsHandler"/>
</bean>
<bean id="SaveCombinationsFileHandler" class="com.raytheon.edex.plugin.gfe.server.handler.SaveCombinationsFileHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.SaveCombinationsFileRequest"/>
<constructor-arg ref="SaveCombinationsFileHandler"/>
</bean>
<bean id="GetSelectTRHandler" class="com.raytheon.edex.plugin.gfe.server.handler.GetSelectTimeRangeHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.GetSelectTimeRangeRequest"/>

View file

@ -1,128 +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.edex.plugin.gfe.server.handler;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.edex.plugin.gfe.util.SendNotifications;
import com.raytheon.uf.common.dataplugin.gfe.request.SaveCombinationsFileRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.dataplugin.gfe.server.notify.CombinationsFileChangedNotification;
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.LocalizationType;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.SaveableOutputStream;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.common.util.StringUtil;
/**
* Request handler for <code>SaveCombinationsFileRequest</code>. Writes the
* specified zone combinations to the specified site's combinations file
* directory.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 16, 2011 dgilling Initial creation
* Dec 02, 2013 #2591 dgilling Only send notification after Writer is
* flushed/closed.
* Feb 05, 2014 #2591 Added CombinationFileChangedNotification
* Jul 21, 2014 2768 bclement removed FileUpdateMessage
* Jan 08, 2016 5237 tgurney Replace calls to deprecated
* LocalizationFile methods
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
public class SaveCombinationsFileHandler implements
IRequestHandler<SaveCombinationsFileRequest> {
private static final String COMBO_FILE_DIR = FileUtil.join("gfe",
"combinations");
@Override
public ServerResponse<Object> handleRequest(
SaveCombinationsFileRequest request) throws Exception {
String siteID = request.getSiteID();
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext localization = pm.getContextForSite(
LocalizationType.CAVE_STATIC, siteID);
String comboName = request.getFileName();
String fileName = FileUtil.join(COMBO_FILE_DIR, comboName) + ".py";
ILocalizationFile lf = pm.getLocalizationFile(localization, fileName);
try (SaveableOutputStream lfStream = lf.openOutputStream();
Writer outWriter = new BufferedWriter(new OutputStreamWriter(
lfStream))) {
String zoneComments = "\n# Automatically generated combinations file\n# "
+ comboName + "\n\nCombinations = [\n";
outWriter.write(zoneComments);
NumberFormat df = new DecimalFormat("00");
for (int i = 0; i < request.getCombos().size(); i++) {
StringBuilder nextLineToWrite = new StringBuilder();
List<String> modZGL = new ArrayList<String>(request.getCombos()
.get(i).size());
for (String zone : request.getCombos().get(i)) {
modZGL.add("'" + zone + "'");
}
nextLineToWrite.append("\t([");
nextLineToWrite.append(StringUtil.join(modZGL, ','));
nextLineToWrite.append("], ");
nextLineToWrite.append("'Region");
nextLineToWrite.append(df.format(i + 1));
nextLineToWrite.append("' ),\n");
outWriter.write(nextLineToWrite.toString());
}
outWriter.write("]");
outWriter.close();
lfStream.save();
}
/*
* placing the notification code here ensures we only send the
* notification on a successful file write operation. Otherwise we would
* have thrown an IOException and never gotten to this portion of the
* request handler.
*/
CombinationsFileChangedNotification notif = new CombinationsFileChangedNotification(
comboName, request.getWorkstationID(), siteID);
SendNotifications.send(notif);
return new ServerResponse<Object>();
}
}

View file

@ -71,7 +71,7 @@ import com.raytheon.uf.edex.activetable.ActiveTablePyIncludeUtil;
* ------------ ---------- ----------- --------------------------
* Oct 03, 2008 njensen Initial creation
* Jul 10, 2009 #2590 njensen Added multiple site support
* May 12, 2014 #3157 dgilling Re-factor based on AbstractWatchNotifierSrv.
* May 12, 2014 #3157 dgilling Re-factor based on AbstractWatchNotifierSrv.
* Jun 10, 2014 #3268 dgilling Re-factor based on AbstractWatchNotifierSrv.
* Oct 08, 2014 #4953 randerso Refactored AbstractWatchNotifierSrv to allow
* subclasses to handle all watches if desired.
@ -83,6 +83,7 @@ import com.raytheon.uf.edex.activetable.ActiveTablePyIncludeUtil;
* Added support for sending TCVAdvisory files to
* VTEC partners
* Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException
* Apr 13, 1016 #5577 randerso Add support for pre-TCV
* Jan 27, 2016 5237 tgurney Replace LocalizationFile with ILocalizationFile
*
* </pre>
@ -104,31 +105,11 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
private static final String DEFAULT_TPC_SITE = "KNHC";
private static final String ALERT_TXT = "Alert: TCV has arrived from TPC. "
private static final String ALERT_TXT = "Alert: TCV has arrived from NHC. "
+ "Check for 'red' locks (owned by others) on your Hazard grid and resolve them. "
+ "If hazards are separated into temporary grids, please run Mergehazards. "
+ "Next...save Hazards grid. Finally, select PlotTPCEvents from Hazards menu.";
private static final Map<String, String> phensigMap;
private static final Map<String, String> actMap;
static {
Map<String, String> phensigMapTemp = new HashMap<String, String>(5, 1f);
phensigMapTemp.put("HU.A", "Hurricane Watch");
phensigMapTemp.put("HU.S", "Hurricane Local Statement");
phensigMapTemp.put("HU.W", "Hurricane Warning");
phensigMapTemp.put("TR.A", "Tropical Storm Watch");
phensigMapTemp.put("TR.W", "Tropical Storm Warning");
phensigMap = Collections.unmodifiableMap(phensigMapTemp);
Map<String, String> actMapTemp = new HashMap<String, String>(3, 1f);
actMapTemp.put("CON", "Continued");
actMapTemp.put("CAN", "Cancelled");
actMapTemp.put("NEW", "New");
actMap = Collections.unmodifiableMap(actMapTemp);
}
private static final ThreadLocal<PythonScript> pythonScript = new ThreadLocal<PythonScript>() {
@Override
@ -181,8 +162,8 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
boolean practiceMode = (record instanceof PracticeWarningRecord);
String issuingOffice = record.getOfficeid();
// if it's a TCV
if ("TCV".equals(pil)) {
// if it's a TCV or pre-TCV
if ("TCV".equals(pil) || "PTC".equals(pil)) {
super.handleWatch(warningRecs);
}
@ -431,7 +412,7 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
private Map<String, Object> loadJSONDictionary(ILocalizationFile lf) {
if (lf != null) {
PythonScript script = this.pythonScript.get();
PythonScript script = pythonScript.get();
if (script != null) {
Map<String, Object> args = new HashMap<String, Object>();
args.put("localizationType", lf.getContext()
@ -456,7 +437,7 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
private void saveJSONDictionary(ILocalizationFile lf,
Map<String, Object> dict) {
if (lf != null) {
PythonScript script = this.pythonScript.get();
PythonScript script = pythonScript.get();
if (script != null) {
Map<String, Object> args = new HashMap<String, Object>();
args.put("localizationType", lf.getContext()
@ -502,31 +483,6 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
return null;
}
// create the message
StringBuilder msg = new StringBuilder(ALERT_TXT);
for (String phensigStorm : phensigStormAct.keySet()) {
Collection<String> acts = phensigStormAct.get(phensigStorm);
String[] splitKey = phensigStorm.split(":");
String phensig = splitKey[0];
String storm = splitKey[1];
String t1 = phensigMap.get(phensig);
if (t1 == null) {
t1 = phensig;
}
msg.append(t1 + ": #" + storm + "(");
String sep = "";
for (String a : acts) {
String a1 = actMap.get(a);
if (a1 == null) {
a1 = a;
}
msg.append(sep).append(a1);
sep = ",";
}
msg.append("). ");
}
return msg.toString();
return ALERT_TXT;
}
}

View file

@ -21,7 +21,7 @@
<constraint constraintValue="warning,practicewarning" constraintType="IN"/>
</mapping>
<mapping key="pil">
<constraint constraintValue="TCV,HLS" constraintType="IN"/>
<constraint constraintValue="TCV,HLS,PTC" constraintType="IN"/>
</mapping>
</metadataMap>
</pluginNotification>

View file

@ -1,83 +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.common.dataplugin.gfe.request;
import java.util.List;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 16, 2011 dgilling Initial creation
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
@DynamicSerialize
public class SaveCombinationsFileRequest extends AbstractGfeRequest {
@DynamicSerializeElement
private String fileName;
@DynamicSerializeElement
private List<List<String>> combos;
/**
* @param fileName
* the fileName to set
*/
public void setFileName(String fileName) {
this.fileName = fileName;
}
/**
* @return the fileName
*/
public String getFileName() {
return fileName;
}
/**
* @param combos
* the combos to set
*/
public void setCombos(List<List<String>> combos) {
this.combos = combos;
}
/**
* @return the combos
*/
public List<List<String>> getCombos() {
return combos;
}
}

View file

@ -9,6 +9,8 @@
## BOOKBINDER 6-15-2015 Corrected bad softball/grapefruit hail sized. ##
## Removed redundant tornado watch phrase from CTA ##
## Bookbinder 10-20-2015 Fixed extraSource var for tornado info ##
## Bookbinder 4-14-2016 Accounted for case where someone inadvertantly ##
## de-selected required source ##
#####################################################################################
## Impact Statements for IBW templates are contained in impactStatements.vm
################################################################
@ -16,7 +18,8 @@
#parse("config.vm")
##SET SOME INITIAL VARIABLES
#set($hazard = "")
#set($source = "")
#set($source = "!** YOU FAILED TO SELECT A SOURCE. PLEASE TYPE ONE OR REGENERATE THIS WARNING **!")
#set($reportAuthSVR = "producing")
#set($torTag = "")
#set($pdssvr = "")
#set($extraSource = "")
@ -444,11 +447,11 @@ Those attending !**EVENT/VENUE NAME OR LOCATION*! are in the path of this storm
## Comment out #parse command below to pull in Dynamic DSS Event Info
## If this feature is utilized, the "specialEvent" bullet (output above) can
## likely be commented out from the impactSevereThunderstormWarning.xml file
##parse("dssEvents.vm")
## #parse("dssEvents.vm")
## parse file command here is to pull in mile marker info
#parse("mileMarkers.vm")
## #parse("mileMarkers.vm")
## parse file command here is to pull in extra points (venues) info
##parse("pointMarkers.vm")
## #parse("pointMarkers.vm")
##################################
######### CALLS TO ACTION ########

View file

@ -20,6 +20,9 @@
## Phil Kurimski 10-20-2015 Added waterspout option to TOR basis ##
## Evan Bookbinder 10-20-2015 fixed extraSource variable usage ##
## Phil Kurimski 10-21-2015 Fixed Tornado Preamble for mixed case ##
## Evan Bookbinder 4-04-2016 "therefore", "and" case/grammar fix in CAN/EXP ##
## Evan Bookbinder 4-14-2016 Added exception case if forecaster ##
## inadvertantly doesn't have a source selected ##
#############################################################################
## Impact Statements for IBW templates are contained in impactStatements.vm
################################################################
@ -48,6 +51,7 @@
##PATHCAST LEAD VARIABLE ADD LATER?????
#if(${phenomena}=="SV")
#set($eventType = "SEVERE THUNDERSTORM")
#set($source = "!** YOU FAILED TO SELECT A SOURCE. PLEASE TYPE ONE OR REGENERATE THIS WARNING **!")
#if(${stormType} == "line")
#set($reportType1 = "severe thunderstorms were")
#set($reportType2 = "these storms were")
@ -189,12 +193,12 @@ ${dateUtil.format(${now}, ${timeFormat.header}, ${localtimezone})}
#if(${action}=="EXP" || ${action}=="CAN" || ${action}=="CANCON" || ${CORCAN}=="true")
#### SET A DEFAULT STATEMENT IN CASE NO BULLET WAS SELECTED OR AVAILABLE
#if(${stormType} == "line")
#set($expcanPhrase = "The storms which prompted the warning have !** weakened. moved out of the warned area.**! therefore the warning ${expcanBODYTag}.")
#set($expcanPhrase = "The storms which prompted the warning have !** weakened. moved out of the warned area.**! Therefore, the warning ${expcanBODYTag}.")
#else
#if(${phenomena}=="SV")
#set($expcanPhrase = "The severe thunderstorm which prompted the warning has !** weakened. moved out of the warned area. **! therefore the warning ${expcanBODYTag}.")
#set($expcanPhrase = "The severe thunderstorm which prompted the warning has !** weakened. moved out of the warned area. **! Therefore, the warning ${expcanBODYTag}.")
#else
#set($expcanPhrase = "The tornadic thunderstorm which prompted the warning has !** weakened. moved out of the warned area. **! therefore the warning ${expcanBODYTag}.")
#set($expcanPhrase = "The tornadic thunderstorm which prompted the warning has !** weakened. moved out of the warned area. **! Therefore, the warning ${expcanBODYTag}.")
#end
#end
#### WEAKENED BELOW SEVERE LIMITS
@ -287,9 +291,9 @@ ${dateUtil.format(${now}, ${timeFormat.header}, ${localtimezone})}
#elseif(${addhailcheck} == "1" && ${addwindcheck} == "1" && ${addraincheck} == "0" )
#set($addthreat = " However ${addhail} and ${addwind} are still possible with ${stormTypePhrase}.")
#elseif(${addhailcheck} == "1" && ${addwindcheck} == "0" && ${addraincheck} == "1" )
#set($addthreat = " However ${addhail} AND ${addrain} are still possible with ${stormTypePhrase}.")
#set($addthreat = " However ${addhail} and ${addrain} are still possible with ${stormTypePhrase}.")
#elseif(${addhailcheck} == "0" && ${addwindcheck} == "1" && ${addraincheck} == "1" )
#set($addthreat = " However ${addwind} AND ${addrain} are still possible with ${stormTypePhrase}.")
#set($addthreat = " However ${addwind} and ${addrain} are still possible with ${stormTypePhrase}.")
#elseif(${addhailcheck} == "1" && ${addwindcheck} == "1" && ${addraincheck} == "1" )
#set($addthreat = " However ${addhail}#commaOrEllipsis()${addwind} and ${addrain} are still possible with ${stormTypePhrase}.")
#end
@ -979,7 +983,7 @@ Those attending the !**EVENT/VENUE NAME OR LOCATION**! are in the path of this s
#end
#end
## parse file command here is to pull in mile marker info
## parse file command here is to pull in DSS info
## #parse("dssEvents.vm")
## parse file command here is to pull in extra locations (venues) info
## #parse("pointMarkers.vm")

View file

@ -51,6 +51,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* Sep 16, 2008 randerso Initial creation
* Mar 31, 2014 2689 mpduff Log input values on conversion failure.
* Dec 09, 2015 18391 snaples Updated gridmapper to use CELL CENTER instead of corner.
* Apr 19, 2016 18865 snaples Updated gridmapper to correct an offset in the grid to point mapping.
* Using CELL_CORNER now to fix that issue.
*
* </pre>
*
@ -210,7 +212,7 @@ public class HRAP {
false);
gridMapper = new GridToEnvelopeMapper(gridRange, userRange);
gridMapper.setPixelAnchor(PixelInCell.CELL_CENTER);
gridMapper.setPixelAnchor(PixelInCell.CELL_CORNER);
gridMapper.setReverseAxis(new boolean[] { false, false });
} catch (Exception e) {

View file

@ -56,6 +56,9 @@
<permission id="com.raytheon.localization.site/cave_static/gfe/comboData">
</permission>
<permission id="com.raytheon.localization.site/cave_static/gfe/combinations">
</permission>
<permission id="com.raytheon.localization.site/cave_static/gfe/tcvAdvisories">
</permission>

View file

@ -30,7 +30,7 @@ BuildRequires: awips2-ant
BuildRequires: awips2-java
%description
AWIPS II Common Base - Contains common plugins utilized by both EDEX and CAVE.
AWIPS II Common Base - Contains common plugins utilized by EDEX.
%prep
# Ensure that a "buildroot" has been specified.
@ -44,27 +44,23 @@ if [ -d %{_build_root} ]; then
rm -rf %{_build_root}
fi
/bin/mkdir -p %{_build_root}
#/bin/mkdir %{_build_root}
if [ $? -ne 0 ]; then
exit 1
fi
%build
_hybrid_target=buildHybrid
_build_xml=build.xml
BUILD_EDEX=%{_baseline_workspace}/build.edex
EDEX_DIST=${BUILD_EDEX}/edex/dist
_pde_build_arch=x86
if [ "%{_build_arch}" = "x86_64" ]; then
_pde_build_arch=%{_build_arch}
fi
cd ${BUILD_EDEX}
/awips2/ant/bin/ant -f ${_build_xml} \
-Dbuild.arch=${_pde_build_arch} \
-Duframe.eclipse=%{_uframe_eclipse} ${_hybrid_target}
-Dbuild.arch=x86_64 \
-Dfeature=com.raytheon.uf.common.base.feature \
-Duframe.eclipse=%{_uframe_eclipse} \
clean \
build \
clean
if [ $? -ne 0 ]; then
exit 1
fi
@ -78,15 +74,6 @@ if [ $? -ne 0 ]; then
exit 1
fi
RPMS_CORE=%{_baseline_workspace}/rpms/awips2.core
RPMS_COMMON_BASE=${RPMS_CORE}/Installer.common-base
SCRIPTS=${RPMS_COMMON_BASE}/scripts
cp -vf ${RPMS_COMMON_BASE}/scripts/* %{_build_root}/awips2/cave
if [ $? -ne 0 ]; then
exit 1
fi
#create a list of all files packaged for /awips2/edex/data/utility
UTILITY=/awips2/edex/data/utility
if [ -d %{_build_root}/$UTILITY ]; then
@ -123,29 +110,7 @@ else if [ $retVal -eq 0 ]; then
fi
fi
# CAVE installed?
# when the plugins are for CAVE, we need to
# use the p2 director to install from a repository.
rpm -q awips2-cave > /dev/null 2>&1
if [ $? -eq 0 ]; then
/bin/bash /awips2/cave/installCAVECommon.sh
rm -f /awips2/cave/installCAVECommon.sh
else
# hide the cave repository
pushd . > /dev/null 2>&1
cd /awips2
rm -rf .cave
mv cave .cave
popd > /dev/null 2>&1
fi
%preun
if [ -d /awips2/.cave ]; then
rm -rf /awips2/.cave
fi
if [ -d /awips2/.edex ]; then
rm -rf /awips2/.edex
fi
@ -160,8 +125,3 @@ rm -rf ${RPM_BUILD_ROOT}
%dir /awips2
%dir /awips2/edex
/awips2/edex/*
%dir /awips2/cave
/awips2/cave/*
%dir /awips2/cave/.repository
/awips2/cave/.repository/*

View file

@ -1,70 +0,0 @@
#!/bin/bash
# Set all paths required by CAVE before installing.
export LD_LIBRARY_PATH=/awips2/java/lib:/awips2/python/lib:$LD_LIBRARY_PATH
export LD_PRELOAD=libpython.so
if [ -d /awips2/cave/lib ]; then
export LD_LIBRARY_PATH=/awips2/cave/lib/lib_illusion:$LD_LIBRARY_PATH
fi
if [ -d /awips2/cave/lib64 ]; then
export LD_LIBRARY_PATH=/awips2/cave/lib64/lib_illusion:$LD_LIBRARY_PATH
fi
# Need to use awips2-java to do this.
export PATH=/awips2/java/bin:/awips2/python/bin:${PATH}
export JAVA_HOME="/awips2/java/jre"
# Set the CAVE logfile location.
export LOGFILE_CAVE=/dev/null
# Use the eclipse p2 manager.
CAVE_EXE="/awips2/cave/cave"
NOSPLASH_ARG="-nosplash"
DIRECTOR_APP="-application org.eclipse.equinox.p2.director"
DESTINATION_ARG="-destination /awips2/cave"
INSTALL_ARG="-i com.raytheon.uf.common.base.feature.feature.group"
UNINSTALL_ARG="-u com.raytheon.uf.common.base.feature.feature.group"
REPO="-repository file:/awips2/cave/.repository/"
COMMON_CMD="${CAVE_EXE} ${NOSPLASH_ARG} ${DIRECTOR_APP} ${DESTINATION_ARG}"
INSTALL_CMD="${COMMON_CMD} ${INSTALL_ARG} ${REPO}"
UNINSTALL_CMD="${COMMON_CMD} ${UNINSTALL_ARG}"
# Uninstall any existing components since the p2 director does not
# support updating.
# If the feature is not installed, this does not fail quietly.
# Determine if the feature needs to be uninstalled.
${UNINSTALL_CMD} -verifyOnly > /dev/null 2>&1
if [ $? -eq 0 ]; then
LOG_TIMESTAMP=`date`
echo "uninstall previous STARTED: ${LOG_TIMESTAMP}"
${UNINSTALL_CMD}
LOG_TIMESTAMP=`date`
echo "uninstall previous COMPLETE: ${LOG_TIMESTAMP}"
fi
# complete the install
LOG_TIMESTAMP=`date`
echo "installation STARTED: ${LOG_TIMESTAMP}"
${INSTALL_CMD}
if [ $? -ne 0 ]; then
exit 1
fi
LOG_TIMESTAMP=`date`
echo "installation COMPLETE: ${LOG_TIMESTAMP}"
# remove the repository
if [ -f /awips2/cave/.repository/artifacts.xml ]; then
rm -f /awips2/cave/.repository/artifacts.xml
fi
if [ -f /awips2/cave/.repository/content.xml ]; then
rm -f /awips2/cave/.repository/content.xml
fi
if [ -d /awips2/cave/.repository/features ]; then
rm -rf /awips2/cave/.repository/features
fi
if [ -d /awips2/cave/.repository/plugins ]; then
rm -rf /awips2/cave/.repository/plugins
fi