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; 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 class GSM extends Message {
public static final int OP_MODE_MAINTENANCE = 0; public static final int OP_MODE_MAINTENANCE = 0;
public static final int OP_MODE_CLEAR_AIR = 1; public static final int OP_MODE_CLEAR_AIR = 1;
public static final int OP_MODE_STORM = 2; 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);
}
protected void decodeBlock(int index, ByteBuffer buf) { public int opMode;
if (index != 1) public int rdaOpStatus;
return; public int vcp;
opMode = buf.getShort(); public int[] cuts; // in tenths of degrees
rdaOpStatus = buf.getShort(); public int rdaStatus;
vcp = buf.getShort(); public int rdaAlarms;
int nCuts = buf.getShort(); public int dataAvailability; // "DTE"
cuts = new int[nCuts]; public int rpgOpStatus;
for (int i = 0; i < 20; ++i) { public int rpgAlarms;
if (i < cuts.length) public int rpgStatus;
cuts[i] = buf.getShort(); public int rpgNarrowbandStatus;
else public int rcc;
buf.getShort(); public int productAvailability;
} public int superResCuts;
rdaStatus = buf.getShort(); public int rdaVersion;
rdaAlarms = buf.getShort(); public int rdaChannel;
dataAvailability = buf.getShort(); public int rpgVersion;
rpgOpStatus = buf.getShort(); public int vcpSupplemental;
rpgAlarms = buf.getShort();
rpgStatus = buf.getShort(); public static GSM decode(byte[] msg) {
rpgNarrowbandStatus = buf.getShort(); return (GSM) MD.decode(msg);
rcc = buf.getShort(); }
productAvailability = buf.getShort();
superResCuts = buf.getShort(); protected void decodeBlock(int index, ByteBuffer buf) {
buf.position(buf.position() + 4); if (index != 1)
rdaVersion = buf.getShort(); return;
rdaChannel = buf.getShort(); opMode = buf.getShort();
buf.position(buf.position() + 4); rdaOpStatus = buf.getShort();
rpgVersion = 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.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import com.raytheon.rcm.config.RadarConfig; import com.raytheon.rcm.config.RadarConfig;
import com.raytheon.rcm.config.RadarType;
import com.raytheon.rcm.config.RcmUtil; import com.raytheon.rcm.config.RcmUtil;
import com.raytheon.rcm.event.OtrEvent; import com.raytheon.rcm.event.OtrEvent;
import com.raytheon.rcm.event.RadarEvent; 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.MessageInfo;
import com.raytheon.rcm.message.ProductRequest; import com.raytheon.rcm.message.ProductRequest;
import com.raytheon.rcm.message.RequestResponse; import com.raytheon.rcm.message.RequestResponse;
import com.raytheon.rcm.products.ElevationInfo;
import com.raytheon.rcm.request.Filter; import com.raytheon.rcm.request.Filter;
import com.raytheon.rcm.request.Request; import com.raytheon.rcm.request.Request;
import com.raytheon.rcm.request.Sequence; import com.raytheon.rcm.request.Sequence;
@ -55,9 +58,18 @@ import com.raytheon.rcm.server.RadarServer;
/** /**
* Manages One Time Requests for the RPGs. * Manages One Time Requests for the RPGs.
* <p> * <p>
* Does not actually do much except provide a place to queue up requests while * Implements a queue for pending requests to the RPGs. Performs some coalescing
* waiting to connect to the RPG. Does do some coalescing of duplicate * of duplicate requests.
* 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 { public class OTRManager extends RadarEventAdapter {
@ -69,7 +81,7 @@ public class OTRManager extends RadarEventAdapter {
*/ */
protected boolean isReady; protected boolean isReady;
protected List<Req> requests = new ArrayList<Req>(); protected List<Req> requests = new ArrayList<>();
protected GSM lastGSM; protected GSM lastGSM;
@ -226,7 +238,7 @@ public class OTRManager extends RadarEventAdapter {
private void trySendingRequests() { private void trySendingRequests() {
if (isReady()) { if (isReady()) {
ArrayList<Request> requestsToSend = new ArrayList<Request>(); ArrayList<Request> requestsToSend = new ArrayList<>();
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
synchronized (this.requests) { synchronized (this.requests) {
for (Req r : requests) { for (Req r : requests) {
@ -319,31 +331,55 @@ public class OTRManager extends RadarEventAdapter {
&& request.getElevationSelection() != Request.SPECIFIC_ELEVATION) { && request.getElevationSelection() != Request.SPECIFIC_ELEVATION) {
if (lastGSM != null) { if (lastGSM != null) {
if (request.getElevationSelection() == Request.ALL_ELEVATIONS) { if (request.getElevationSelection() == Request.ALL_ELEVATIONS) {
/* RadarType radarType = RcmUtil.getRadarType(getRadarConfig());
* We do not get information about duplicate int[] completeElevationList;
* 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;
nElevations = request.getElevationAngle() == 0 ? lastGSM.cuts.length if (radarType == RadarType.WSR
: 1; || (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) { } else if (request.getElevationSelection() == Request.N_ELEVATIONS) {
nElevations = Math.min(lastGSM.cuts.length, nElevations = Math.min(uniqueCount(lastGSM.cuts),
request.getElevationAngle()); request.getElevationAngle());
} else if (request.getElevationSelection() == Request.LOWER_ELEVATIONS) { } else if (request.getElevationSelection() == Request.LOWER_ELEVATIONS) {
HashSet<Integer> seenAngles = new HashSet<>();
nElevations = 0; nElevations = 0;
int reqEA = request.getElevationAngle(); int reqEA = request.getElevationAngle();
for (int ea : lastGSM.cuts) { for (int ea : lastGSM.cuts) {
if (ea <= reqEA) if (ea <= reqEA && !seenAngles.contains(ea)) {
++nElevations; ++nElevations;
else seenAngles.add(ea);
break; }
} }
} else } else
exactCountUnknown = true; exactCountUnknown = true;
@ -356,9 +392,41 @@ public class OTRManager extends RadarEventAdapter {
nExpected = request.count * nElevations; 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) { public void addHandler(OTRHandler handler) {
if (handlers == null) if (handlers == null)
handlers = new ArrayList<OTRHandler>(); handlers = new ArrayList<>();
handlers.add(handler); handlers.add(handler);
} }
@ -387,7 +455,7 @@ public class OTRManager extends RadarEventAdapter {
RadarServer radarServer; RadarServer radarServer;
// ArrayList<Req> requests = new ArrayList<Req>(); // ArrayList<Req> requests = new ArrayList<Req>();
HashMap<String, RadarStatus> state = new HashMap<String, RadarStatus>(); HashMap<String, RadarStatus> state = new HashMap<>();
public OTRManager(RadarServer radarServer) { public OTRManager(RadarServer radarServer) {
this.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. * 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 class EventLogger extends RadarEventAdapter {
public EventLogger() {
}
@Override public EventLogger() {
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 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) { @Override
case GSM.OP_MODE_CLEAR_AIR: s = "clear-air"; break; public void handleRadarEvent(RadarEvent event) {
case GSM.OP_MODE_STORM: s = "storm"; break; switch (event.getType()) {
case GSM.OP_MODE_MAINTENANCE: s = "maintenance"; break; case RadarEvent.CONNECTION_UP:
default: s = "(" +Integer.toString(gsm.opMode) + ")"; Log.eventf("%s: connected", event.getRadarID());
} break;
o.append("opMode=" + s); case RadarEvent.CONNECTION_DOWN:
Log.eventf("%s: disconnected", event.getRadarID());
o.append(" vcp=" + gsm.vcp); break;
o.append(" cuts=" + Arrays.toString(gsm.cuts)); case RadarEvent.MESSAGE_RECEIVED:
{
o.append(String.format(" rdaOp=%s rdaStat=%s rdaAlarm=%s dte=%s rpgOp=%s rpgStat=%s rpgAlarm=%s", StringBuilder s = new StringBuilder();
formatBits((short) gsm.rdaOpStatus, rdaOpStatusStr), byte[] msg = event.getMessageData();
formatBits((short) gsm.rdaStatus, rdaStatusStr), int messageCode = Message.messageCodeOf(msg);
formatBits((short) gsm.rdaAlarms, rdaAlarmStr), s.append("code=" + messageCode);
formatBits((short) gsm.dataAvailability, dteStr), s.append(" size=" + msg.length);
formatBits((short) gsm.rpgOpStatus, rpgOpStr), if (messageCode == Message.GSM) {
formatBits((short) gsm.rpgStatus, rpgStatusStr), s.append(' ');
formatBits((short) gsm.rpgAlarms, rpgAlarmStr))); GSM gsm = null;
try {
o.append(String.format(" avail=%s", gsm = GSM.decode(msg);
formatBits((short) gsm.productAvailability, productAvailStr))); } catch (Exception e) {
s.append("(Message decoding failed)");
o.append(String.format(" rdaVer=%.1f rpgVer=%.1f", gsm.rdaVersion/10.0, gsm.rpgVersion/10.)); }
if (gsm != null)
return o.toString(); s.append(formatGSM(gsm));
} } else if (messageCode == Message.REQUEST_RESPONSE) {
s.append(' ');
protected String formatPRR(RequestResponse rr) { RequestResponse rr = null;
StringBuilder o = new StringBuilder(); try {
rr = RequestResponse.decode(msg);
o.append(String.format("productCode=%d sequence=%d elev=%d flags=%s", } catch (Exception e) {
rr.productCode, s.append("(Message decoding failed)");
rr.sequence, }
rr.elevationAngle, if (rr != null)
formatPrrBits(rr.errorCode, prrStr))); s.append(formatPRR(rr));
} else if (messageCode >= 16) {
return o.toString(); 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 # Jul 23, 2015 ASM#13849 D. Friedman Use a unique Eclipse configuration directory
# Aug 03, 2015 #4694 dlovely Fixed path for log file cleanup # 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 # 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 source /awips2/cave/iniLookup.sh
RC=$? RC=$?
@ -383,11 +386,12 @@ function deleteOldCaveLogs()
local curDir=$(pwd) local curDir=$(pwd)
local mybox=$(hostname) local mybox=$(hostname)
echo -e "Cleaning consoleLogs: " pidof /bin/find > /dev/null
echo -e "find $HOME/$BASE_LOGDIR -type f -name "*.log" -mtime +30 -exec rm {} \;" 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 -exec rm {} \; find "$HOME/$BASE_LOGDIR" -type f -name "*.log" -mtime +30 | xargs rm
fi
exit 0 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 * 14 Jan 2016 5054 randerso Fix the Tips window to display on the correct monitor
* Removed duplicate parent shell * Removed duplicate parent shell
* 25 Jan 2016 5054 randerso Converted to stand alone window * 25 Jan 2016 5054 randerso Converted to stand alone window
* 19 Apr 2016 5517 randerso Fixed saving/restoring location of AlertViz bar
* *
* </pre> * </pre>
* *
@ -271,7 +272,6 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener,
*/ */
public Object open() { public Object open() {
shell = new Shell(display, SWT.ON_TOP | SWT.NO_TRIM); shell = new Shell(display, SWT.ON_TOP | SWT.NO_TRIM);
shell.setBounds(restoreDialogPosition());
shell.addDisposeListener(new DisposeListener() { shell.addDisposeListener(new DisposeListener() {
@Override @Override
@ -292,11 +292,17 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener,
// Initialize all of the controls and layouts // Initialize all of the controls and layouts
initializeComponents(); initializeComponents();
shell.pack(); 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. // force bar location to be within the display.
Point shellLoc = shell.getLocation();
Point shellSize = shell.getSize();
Display d = shell.getDisplay(); Display d = shell.getDisplay();
Rectangle dBounds = d.getBounds(); Rectangle dBounds = d.getBounds();
if (shellLoc.x < dBounds.x) { if (shellLoc.x < dBounds.x) {
@ -310,6 +316,7 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener,
shellLoc.y = (dBounds.y + dBounds.height) - shellSize.y; shellLoc.y = (dBounds.y + dBounds.height) - shellSize.y;
} }
shell.setLocation(shellLoc); shell.setLocation(shellLoc);
shell.open();
if (Boolean.getBoolean("SystemTray") if (Boolean.getBoolean("SystemTray")
&& !Boolean.getBoolean("ShowAlertVizBar")) { && !Boolean.getBoolean("ShowAlertVizBar")) {
@ -1224,7 +1231,7 @@ public class AlertMessageDlg implements MouseMoveListener, MouseListener,
return alertAudioMgr; return alertAudioMgr;
} }
public static Rectangle restoreDialogPosition() { private static Rectangle restoreDialogPosition() {
return new Rectangle( return new Rectangle(
dialogPrefs.getInt(P_ALERT_MSG_DLG_POSITION + ".x"), dialogPrefs.getInt(P_ALERT_MSG_DLG_POSITION + ".x"),
dialogPrefs.getInt(P_ALERT_MSG_DLG_POSITION + ".y"), 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")); 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 + ".x", r.x);
dialogPrefs.setValue(P_ALERT_MSG_DLG_POSITION + ".y", r.y); dialogPrefs.setValue(P_ALERT_MSG_DLG_POSITION + ".y", r.y);
dialogPrefs.setValue(P_ALERT_MSG_DLG_POSITION + ".width", r.width); dialogPrefs.setValue(P_ALERT_MSG_DLG_POSITION + ".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. * 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 * 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 * 25 Jan 2016 5054 randerso Converted to stand alone window
* 19 Apr 2016 5517 randerso Fix GUI sizing issues
* *
* </pre> * </pre>
* *
@ -855,23 +856,46 @@ public class AlertVisConfigDlg implements IConfigurationChangedListener,
// Filler // Filler
new Label(prioritiesComp, SWT.NONE); new Label(prioritiesComp, SWT.NONE);
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); Label label = new Label(prioritiesComp, SWT.CENTER);
gd.horizontalSpan = 6; label.setFont(labelFont);
Label priorityLbl = new Label(prioritiesComp, SWT.CENTER); label.setText("HIGH");
priorityLbl.setText(getPriorityLabelText()); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
priorityLbl.setFont(labelFont); label.setLayoutData(gd);
priorityLbl.setLayoutData(gd);
priorityLbl.setData(MonitorToolTip.tooltipTextKey,
getPrioritiesToolTipText());
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 @Override
public void mouseHover(MouseEvent e) { public void mouseHover(MouseEvent e) {
mttPriorities.open(); 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 // Put the priority canvases on the display
@ -1098,21 +1122,6 @@ public class AlertVisConfigDlg implements IConfigurationChangedListener,
saveNeeded(false); 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. * Add a separator to the display.
* *
@ -1520,14 +1529,14 @@ public class AlertVisConfigDlg implements IConfigurationChangedListener,
private String getCommonSettingToolTipText() { private String getCommonSettingToolTipText() {
StringBuilder sb = new StringBuilder(); 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("side describes how the text message\n");
sb.append("representations will be affected\n"); sb.append("representations will be affected\n");
sb.append("in the main GUI (if text is turned\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("on for the key/priority) and the Pop-ups\n");
sb.append("and how long thetext blinking and system\n"); sb.append("and how long the text blinking and system\n");
sb.append("audio execution willlast (again, if turned\n"); sb.append("audio execution will last (again, if turned\n");
sb.append("on). The right side definesother, general\n"); sb.append("on). The right side defines other, general\n");
sb.append("behavior."); sb.append("behavior.");
sb.append("NOTE: to make blinking or audio \n"); sb.append("NOTE: to make blinking or audio \n");
sb.append("responses perpetual, set the duration to 0."); 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(). * 24 Mar 2011 5853 cjeanbap Add createLayoutControls() to reloadConfig().
* 02 May 2011 9067 cjeanbap Remove createLayoutControls() from reloadConfig(). * 02 May 2011 9067 cjeanbap Remove createLayoutControls() from reloadConfig().
* 07 Feb 2013 15490 Xiaochuan Add configDialog to handle the updated setting * 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> * </pre>
* *
@ -204,7 +205,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
private MenuItem menuItem; private MenuItem menuItem;
private INeedsSaveListener needsSaveListener; private INeedsSaveListener needsSaveListener;
private AlertVisConfigDlg configDialog; private AlertVisConfigDlg configDialog;
/** /**
@ -240,6 +241,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
initControls(); initControls();
this.addDisposeListener(new DisposeListener() { this.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent arg0) { public void widgetDisposed(DisposeEvent arg0) {
controlFont.dispose(); controlFont.dispose();
} }
@ -290,7 +292,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
*/ */
private void createCategoryListControls() { private void createCategoryListControls() {
Composite listComp = new Composite(this, SWT.NONE); 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); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.horizontalIndent = 4; gd.horizontalIndent = 4;
@ -300,15 +302,22 @@ public class LayoutControlsComp extends Composite implements MouseListener {
listLbl.setFont(controlFont); listLbl.setFont(controlFont);
listLbl.setLayoutData(gd); 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 categoryList = new List(listComp, SWT.BORDER | SWT.SINGLE
| SWT.V_SCROLL); | SWT.V_SCROLL);
categoryList.setLayoutData(gd);
categoryList.setFont(controlFont); 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() { categoryList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
handleSourceSelection(); handleSourceSelection();
} }
@ -316,23 +325,27 @@ public class LayoutControlsComp extends Composite implements MouseListener {
populateCategoryList(); populateCategoryList();
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); int buttonWidth = listComp.getDisplay().getDPI().x;
gd.widthHint = 80;
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.minimumWidth = buttonWidth;
Button newBtn = new Button(listComp, SWT.PUSH); Button newBtn = new Button(listComp, SWT.PUSH);
newBtn.setText("New..."); newBtn.setText("New...");
newBtn.setLayoutData(gd); newBtn.setLayoutData(gd);
newBtn.addSelectionListener(new SelectionAdapter() { newBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
createNewCategory(); createNewCategory();
} }
}); });
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.widthHint = 80; gd.minimumWidth = buttonWidth;
deleteBtn = new Button(listComp, SWT.PUSH); deleteBtn = new Button(listComp, SWT.PUSH);
deleteBtn.setText("Delete"); deleteBtn.setText("Delete");
deleteBtn.setLayoutData(gd); deleteBtn.setLayoutData(gd);
deleteBtn.addSelectionListener(new SelectionAdapter() { deleteBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
deleteCategory(); deleteCategory();
} }
@ -344,6 +357,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
clearAllBtn.setText("Clear All Layouts"); clearAllBtn.setText("Clear All Layouts");
clearAllBtn.setLayoutData(gd); clearAllBtn.setLayoutData(gd);
clearAllBtn.addSelectionListener(new SelectionAdapter() { clearAllBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
clearAllCategoryTextBoxes(); clearAllCategoryTextBoxes();
} }
@ -353,6 +367,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
popupMenuCList = new Menu(categoryList); popupMenuCList = new Menu(categoryList);
categoryList.setMenu(popupMenuCList); categoryList.setMenu(popupMenuCList);
popupMenuCList.addListener(SWT.Show, new Listener() { popupMenuCList.addListener(SWT.Show, new Listener() {
@Override
public void handleEvent(Event event) { public void handleEvent(Event event) {
MenuItem[] menuItems = popupMenuCList.getItems(); MenuItem[] menuItems = popupMenuCList.getItems();
@ -363,6 +378,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
if (categoryMap.get(getListIndexToKey()).isLocked() != true) { if (categoryMap.get(getListIndexToKey()).isLocked() != true) {
menuItem = new MenuItem(popupMenuCList, SWT.PUSH); menuItem = new MenuItem(popupMenuCList, SWT.PUSH);
menuItem.addSelectionListener(new SelectionAdapter() { menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
deleteCategory(); deleteCategory();
} }
@ -386,6 +402,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
layoutCombo = new Combo(controlComp, SWT.DROP_DOWN | SWT.READ_ONLY); layoutCombo = new Combo(controlComp, SWT.DROP_DOWN | SWT.READ_ONLY);
populateLayoutCombo(); populateLayoutCombo();
layoutCombo.addSelectionListener(new SelectionAdapter() { layoutCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
int index = layoutCombo.getSelectionIndex(); int index = layoutCombo.getSelectionIndex();
selectedMode = TrayConfiguration.TrayMode.valueOf(layoutCombo selectedMode = TrayConfiguration.TrayMode.valueOf(layoutCombo
@ -393,7 +410,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
selectedModeRecs = layoutRecs.getRectangles(selectedMode); selectedModeRecs = layoutRecs.getRectangles(selectedMode);
canvas.redraw(); canvas.redraw();
updateCellNumbers(); updateCellNumbers();
configDialog.setNewConfig(); configDialog.setNewConfig();
needsSaveListener.saveNeeded(true); needsSaveListener.saveNeeded(true);
} }
}); });
@ -414,6 +431,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
removeSelectionBtn.setEnabled(false); removeSelectionBtn.setEnabled(false);
removeSelectionBtn.setLayoutData(gd); removeSelectionBtn.setLayoutData(gd);
removeSelectionBtn.addSelectionListener(new SelectionAdapter() { removeSelectionBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
int index = categoryList.getSelectionIndex(); int index = categoryList.getSelectionIndex();
@ -451,6 +469,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
canvas.setLayoutData(gd); canvas.setLayoutData(gd);
canvas.addPaintListener(new PaintListener() { canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) { public void paintControl(PaintEvent e) {
drawCanvas(e.gc); drawCanvas(e.gc);
} }
@ -467,7 +486,7 @@ public class LayoutControlsComp extends Composite implements MouseListener {
*/ */
private void drawCanvas(GC gc) { private void drawCanvas(GC gc) {
gc.setFont(controlFont); gc.setFont(controlFont);
aveFontWidth = (int) gc.getFontMetrics().getAverageCharWidth(); aveFontWidth = gc.getFontMetrics().getAverageCharWidth();
gc.setLineWidth(3); gc.setLineWidth(3);
@ -885,8 +904,9 @@ public class LayoutControlsComp extends Composite implements MouseListener {
selectedCell = 0; selectedCell = 0;
} }
if (removeSelectionBtn == null || canvas == null) if (removeSelectionBtn == null || canvas == null) {
return; return;
}
if (selectedCell == 0) { if (selectedCell == 0) {
removeSelectionBtn.setEnabled(false); 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.SelectionEvent;
import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData; 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. * Jun 29, 2015 4311 randerso Reworking AlertViz dialogs to be resizable.
* Jan 25, 2016 5054 randerso Converted to stand alone window * Jan 25, 2016 5054 randerso Converted to stand alone window
* Feb 11, 2016 5314 dgilling Fix System Log functionality. * Feb 11, 2016 5314 dgilling Fix System Log functionality.
* Mar 31, 2016 5517 randerso Fix GUI sizing issues
* *
* </pre> * </pre>
* *
@ -92,6 +94,9 @@ import com.raytheon.uf.viz.core.VizApp;
public class SimpleLogViewer implements IAlertArrivedCallback, public class SimpleLogViewer implements IAlertArrivedCallback,
IAlertVizLogPurgedNotifier { IAlertVizLogPurgedNotifier {
private static final String[] columnLabels = new String[] { "Time",
"Priority", "Source", "Category", "Message" };
private Display display; private Display display;
private Shell shell; private Shell shell;
@ -120,13 +125,6 @@ public class SimpleLogViewer implements IAlertArrivedCallback,
first = true; first = true;
this.display = display; 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); shell.setLayoutData(gd);
table = new Table(shell, SWT.BORDER | SWT.VIRTUAL); table = new Table(shell, SWT.BORDER | SWT.VIRTUAL);
final TableColumn[] columns = new TableColumn[] { table.setHeaderVisible(true);
new TableColumn(table, SWT.NONE),
new TableColumn(table, SWT.NONE), for (String label : columnLabels) {
new TableColumn(table, SWT.NONE), TableColumn column = new TableColumn(table, SWT.NONE);
new TableColumn(table, SWT.NONE), column.setText(label);
new TableColumn(table, SWT.NONE) }; }
GC gc = new GC(table);
int textWidth = gc.getFontMetrics().getAverageCharWidth() * 130;
gc.dispose();
gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 800; gd.widthHint = textWidth;
gd.heightHint = 400; gd.heightHint = table.getItemHeight() * 20;
table.setLayoutData(gd); 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; int sz = 0;
try { try {
@ -192,7 +183,7 @@ public class SimpleLogViewer implements IAlertArrivedCallback,
e2); e2);
} }
table.setSortColumn(columns[0]); table.setSortColumn(table.getColumn(0));
table.setSortDirection(SWT.UP); table.setSortDirection(SWT.UP);
red = new Color(display, new RGB(255, 0, 0)); 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); Composite buttons = new Composite(shell, SWT.NONE);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
buttons.setLayoutData(gd); 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. // Open the shell to display the dialog.
Button button = new Button(buttons, SWT.NONE); Button button = new Button(buttonsLeft, SWT.NONE);
gd = new GridData(SWT.LEFT, SWT.DEFAULT, false, false); gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.widthHint = 100; gd.minimumWidth = buttonWidth;
button.setText("Export Log..."); button.setText("Export Log...");
button.setLayoutData(gd); button.setLayoutData(gd);
button.addSelectionListener(new SelectionAdapter() { button.addSelectionListener(new SelectionAdapter() {
@ -309,9 +307,9 @@ public class SimpleLogViewer implements IAlertArrivedCallback,
}); });
Button close = new Button(buttons, SWT.NONE); Button close = new Button(buttonsLeft, SWT.NONE);
gd = new GridData(SWT.LEFT, SWT.DEFAULT, false, false); gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
gd.widthHint = 100; gd.minimumWidth = buttonWidth;
close.setText("Close"); close.setText("Close");
close.setLayoutData(gd); close.setLayoutData(gd);
close.addSelectionListener(new SelectionListener() { 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 = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false);
gd.widthHint = 100; buttonsRight.setLayoutData(gd);
showLog = new Button(buttons, SWT.NONE); 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.setText("Show Log...");
showLog.setLayoutData(gd); showLog.setLayoutData(gd);
showLog.addSelectionListener(new SelectionAdapter() { showLog.addSelectionListener(new SelectionAdapter() {
@ -363,24 +366,32 @@ public class SimpleLogViewer implements IAlertArrivedCallback,
* @return null * @return null
*/ */
public Object open() { 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); Point minSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
shell.setMinimumSize(minSize); shell.setMinimumSize(minSize);
Point size = minSize; shell.pack();
shell.setSize(size);
showHideLog(); showHideLog();
AlertvizJob.getInstance().addAlertArrivedCallback(this); AlertvizJob.getInstance().addAlertArrivedCallback(this);
PurgeLogJob.getInstance().addLogPurgeListener(this); PurgeLogJob.getInstance().addLogPurgeListener(this);
shell.open(); table.select(table.getItemCount() - 1);
table.showSelection();
if (table.getItemCount() > 0) { for (TableColumn column : table.getColumns()) {
table.showItem(table.getItem(table.getItemCount() - 1)); column.pack();
table.select(table.getItemCount() - 1);
} }
shell.open();
// Wait until the shell is disposed. // Wait until the shell is disposed.
Display display = shell.getDisplay(); Display display = shell.getDisplay();
while (!shell.isDisposed()) { while (!shell.isDisposed()) {

View file

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

View file

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

View file

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

View file

@ -34,6 +34,8 @@
# RollbackMasterInterface. # RollbackMasterInterface.
# 07/23/15 4263 dgilling Support refactored Java # 07/23/15 4263 dgilling Support refactored Java
# SmartToolControllers. # 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") return getattr(sys.modules[name], "WeatherElementEdited", "None")
def getScreenList(self, name): 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): def getVariableList(self, name):
return getattr(sys.modules[name], "VariableList", []) return getattr(sys.modules[name], "VariableList", [])

View file

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

View file

@ -74,8 +74,9 @@ import com.raytheon.viz.gfe.smarttool.script.SmartToolRunnerController;
* Jul 23, 2015 4263 dgilling Support SmartToolMetadataManager. * Jul 23, 2015 4263 dgilling Support SmartToolMetadataManager.
* Aug 27, 2015 4749 njensen Call shutdown() on PythonJobCoordinator * Aug 27, 2015 4749 njensen Call shutdown() on PythonJobCoordinator
* Sep 16, 2015 4871 randerso Return modified varDict from Tool * 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. * 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> * </pre>
* *
@ -433,37 +434,41 @@ public class Tool {
startedParmEdit = false; 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; boolean saveParams = false;
int numberOfGrids = 0; int numberOfGrids = 0;
try { 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); tool.setVarDict(varDict);
// Get the gridInventory for the timeRange // Get the gridInventory for the timeRange
IGridData[] grids = this.inputParm.getGridInventory(timeRange); IGridData[] grids = this.inputParm.getGridInventory(timeRange);
if (grids.length == 0) { numberOfGrids = grids.length;
if (numberOfGrids == 0) {
String message = "Smart Tool " + toolName String message = "Smart Tool " + toolName
+ ": No Grids To Edit for " + ": No Grids To Edit for "
+ inputParm.expressionName(); + inputParm.expressionName();
statusHandler.handle(Priority.EVENTA, message); statusHandler.handle(Priority.EVENTA, message);
return; return;
} }
numberOfGrids = grids.length;
// Make sure parm is mutable
if (parmToEdit != null) {
saveMutableFlag = this.inputParm.isMutable();
this.inputParm.setMutable(true);
}
// Clear missing grids // Clear missing grids
GridCycler.getInstance().clearMissingData(); GridCycler.getInstance().clearMissingData();
// # PreProcess Tool
// PreProcess Tool
handlePreAndPostProcess("preProcessTool", null, timeRange, handlePreAndPostProcess("preProcessTool", null, timeRange,
editArea, dataMode); editArea, dataMode);
statusHandler.handle(Priority.DEBUG, "Running smartTool: " statusHandler.handle(Priority.DEBUG, "Running smartTool: "
@ -477,11 +482,6 @@ public class Tool {
return; 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)) { if (!grid.isOkToEdit() && (parmToEdit != null)) {
String message = "Smart Tool " + toolName String message = "Smart Tool " + toolName
+ ": Encountered locked grid. "; + ": Encountered locked grid. ";
@ -556,7 +556,7 @@ public class Tool {
} }
} // end of grids for loop } // end of grids for loop
// # PostProcess Tool // PostProcess Tool
handlePreAndPostProcess("postProcessTool", null, timeRange, handlePreAndPostProcess("postProcessTool", null, timeRange,
trueEditArea, dataMode); trueEditArea, dataMode);
saveParams = true; saveParams = true;

View file

@ -22,6 +22,10 @@ package com.raytheon.viz.gfe.textformatter;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; 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.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; 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.exception.GfeException;
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil; 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.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.gfe.ifpclient.IFPClient; import com.raytheon.uf.common.gfe.ifpclient.IFPClient;
import com.raytheon.uf.common.localization.IPathManager; 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;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.FileUtil; import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.viz.gfe.GFEException; import com.raytheon.uf.common.util.StringUtil;
import com.raytheon.viz.gfe.core.DataManagerUIFactory;
import com.raytheon.viz.gfe.textformatter.CombinationsFileUtil.ComboData.Entry; 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 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException
* Nov 18, 2015 #5129 dgilling Support new IFPClient. * Nov 18, 2015 #5129 dgilling Support new IFPClient.
* Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs. * 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> * </pre>
* *
@ -97,7 +100,8 @@ public class CombinationsFileUtil {
private static final int MAX_TRIES = 2; 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"); public static String SAVED_COMBO_DIR = FileUtil.join("gfe", "comboData");
@ -133,8 +137,7 @@ public class CombinationsFileUtil {
} }
public ComboData(Map<String, Integer> comboDict) { public ComboData(Map<String, Integer> comboDict) {
this.combos = new ArrayList<CombinationsFileUtil.ComboData.Entry>( this.combos = new ArrayList<>(comboDict.size());
comboDict.size());
for (java.util.Map.Entry<String, Integer> entry : comboDict for (java.util.Map.Entry<String, Integer> entry : comboDict
.entrySet()) { .entrySet()) {
this.combos.add(new Entry(entry.getKey(), entry.getValue())); this.combos.add(new Entry(entry.getKey(), entry.getValue()));
@ -219,7 +222,7 @@ public class CombinationsFileUtil {
try (InputStream in = lf.openInputStream()) { try (InputStream in = lf.openInputStream()) {
ComboData comboData = jaxb.unmarshalFromInputStream(in); ComboData comboData = jaxb.unmarshalFromInputStream(in);
Map<String, Integer> comboDict = new HashMap<String, Integer>( Map<String, Integer> comboDict = new HashMap<>(
comboData.combos.size()); comboData.combos.size());
for (Entry entry : comboData.combos) { for (Entry entry : comboData.combos) {
comboDict.put(entry.zone, entry.group); comboDict.put(entry.zone, entry.group);
@ -237,18 +240,18 @@ public class CombinationsFileUtil {
// retrieve combinations file if it's changed // retrieve combinations file if it's changed
LocalizationFile lf = pm.getStaticLocalizationFile( LocalizationFile lf = pm.getStaticLocalizationFile(
LocalizationType.CAVE_STATIC, LocalizationType.CAVE_STATIC,
FileUtil.join(COMBO_DIR_PATH, comboName + ".py")); FileUtil.join(COMBINATIONS_DIR_PATH, comboName + ".py"));
File pyFile = null; File pyFile = null;
if (lf != null) { if (lf != null) {
try { try {
// get the local .py file // get the local .py file
pyFile = lf.getFile(false); 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 // and regeneration
pyFile.delete(); pyFile.delete();
File pyoFile = new File(pyFile.getPath() + "o"); File pycFile = new File(pyFile.getPath() + "c");
pyoFile.delete(); pycFile.delete();
// retrieve the .py file // retrieve the .py file
pyFile = lf.getFile(true); pyFile = lf.getFile(true);
@ -270,14 +273,14 @@ public class CombinationsFileUtil {
.getPath(), "CombinationsInterface.py"); .getPath(), "CombinationsInterface.py");
List<List<String>> combos = null; List<List<String>> combos = null;
HashMap<String, Object> map = new HashMap<String, Object>(); HashMap<String, Object> map = new HashMap<>();
map.put("comboName", comboName); map.put("comboName", comboName);
for (int retryCount = 0; retryCount < MAX_TRIES; retryCount++) { for (int retryCount = 0; retryCount < MAX_TRIES; retryCount++) {
try (PythonScript python = new PythonScript( try (PythonScript python = new PythonScript(
scriptPath, scriptPath,
PyUtil.buildJepIncludePath( PyUtil.buildJepIncludePath(
GfePyIncludeUtil.getCombinationsIncludePath(), GfePyIncludeUtil.getCombinationsIncludePath(),
PythonIncludePathUtil.getCommonPythonIncludePath()), GfePyIncludeUtil.getCommonPythonIncludePath()),
CombinationsFileUtil.class.getClassLoader())) { CombinationsFileUtil.class.getClassLoader())) {
Object com = python.execute("getCombinations", map); Object com = python.execute("getCombinations", map);
combos = (List<List<String>>) com; combos = (List<List<String>>) com;
@ -285,8 +288,8 @@ public class CombinationsFileUtil {
// if successfully retrieved break out of the loop // if successfully retrieved break out of the loop
break; break;
} catch (JepException e) { } catch (JepException e) {
// remove the .pyo file // remove the .pyc file
new File(pyFile.getAbsolutePath() + "o").delete(); new File(pyFile.getAbsolutePath() + "c").delete();
// if not last try, log and try again // if not last try, log and try again
if (retryCount < (MAX_TRIES - 1)) { if (retryCount < (MAX_TRIES - 1)) {
@ -309,27 +312,53 @@ public class CombinationsFileUtil {
* Generates combinations files based on just running the formatter * Generates combinations files based on just running the formatter
* *
* @param zoneGroupList * @param zoneGroupList
* @param filename * @param comboName
* @throws GFEException * @throws Exception
* @throws IOException
*/ */
public static void generateAutoCombinationsFile( public static void generateAutoCombinationsFile(
List<List<String>> zoneGroupList, String filename) List<List<String>> zoneGroupList, String comboName)
throws GFEException { throws Exception {
IFPClient ifpc = DataManagerUIFactory.getCurrentInstance().getClient();
SaveCombinationsFileRequest req = new SaveCombinationsFileRequest();
req.setFileName(filename);
req.setCombos(zoneGroupList);
statusHandler.info("Saving combinations file: " + filename); IPathManager pm = PathManagerFactory.getPathManager();
ServerResponse<?> sr = ifpc.makeRequest(req); LocalizationContext localization = pm.getContext(
if (sr.isOkay()) { LocalizationType.CAVE_STATIC, LocalizationLevel.SITE);
statusHandler.info("Successfully saved combinations file: "
+ filename); String fileName = FileUtil.join(COMBINATIONS_DIR_PATH, comboName)
} else { + ".py";
String message = String.format( LocalizationFile lf = pm.getLocalizationFile(localization, fileName);
"Error saving combinations file %s: %s", filename,
sr.message()); try (SaveableOutputStream stream = lf.openOutputStream();
throw new GFEException(message); 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.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import com.raytheon.viz.ui.dialogs.ICloseCallback;
/** /**
* Action to display the Get Apps Defaults or SHEF Apps Defaults dialog. * 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. * Dec 06, 2012 1353 rferrel Changes for non blocking GetAppsDefaults.
* Changes for non blocking SHEFAppsDefaultsDlg. * Changes for non blocking SHEFAppsDefaultsDlg.
* Mar 27, 2013 1790 rferrel Bug fix for non-blocking dialogs. * Mar 27, 2013 1790 rferrel Bug fix for non-blocking dialogs.
* Apr 08, 2016 5483 dgilling Bug fixes for SHEFAppsDefaultsDlg.
* *
* </pre> * </pre>
* *
@ -50,13 +53,6 @@ public class AppsDefaultsAction extends AbstractHandler {
private SHEFAppsDefaultsDlg dlg; private SHEFAppsDefaultsDlg dlg;
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
* ExecutionEvent)
*/
@Override @Override
public Object execute(ExecutionEvent event) throws ExecutionException { public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
@ -70,8 +66,15 @@ public class AppsDefaultsAction extends AbstractHandler {
gad.bringToTop(); gad.bringToTop();
} }
} else { } else {
if (dlg == null || dlg.isDisposed()) { if ((dlg == null) || (dlg.isDisposed())) {
dlg = new SHEFAppsDefaultsDlg(shell); dlg = new SHEFAppsDefaultsDlg(shell);
dlg.addCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
dlg = null;
}
});
dlg.open(); dlg.open();
} else { } else {
dlg.bringToTop(); dlg.bringToTop();

View file

@ -19,32 +19,39 @@
**/ **/
package com.raytheon.viz.hydro.appsdefaults; package com.raytheon.viz.hydro.appsdefaults;
import java.io.File; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.Collection;
import java.util.Collections;
import javax.xml.bind.JAXB; 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.SWT;
import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.graphics.Font; 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.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell; 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.IPathManager;
import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.ohd.AppsDefaults; import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.util.Pair;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
/** /**
* Dialog displaying the current Apps_defaults settings for the SHEF Decoder. * 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. * Dec 07, 2012 1353 rferrel Make non-blocking dialog.
* Aug 09, 2013 2033 mschenke Switched File.separator to IPathManager.SEPARATOR * Aug 09, 2013 2033 mschenke Switched File.separator to IPathManager.SEPARATOR
* Nov 04, 2013 2361 njensen Use JAXB instead of SerializationUtil * Nov 04, 2013 2361 njensen Use JAXB instead of SerializationUtil
* Apr 08, 2016 5483 dgilling Refactor based on CaveJFACEDialog, fix
* hi-dpi issues.
* *
* </pre> * </pre>
* *
@ -66,24 +75,13 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0 * @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 private final IUFStatusHandler statusHandler = UFStatus
.getHandler(SHEFAppsDefaultsDlg.class); .getHandler(getClass());
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>();
/** /**
* Constructor. * Constructor.
@ -92,110 +90,138 @@ public class SHEFAppsDefaultsDlg extends CaveSWTDialog {
* Parent shell. * Parent shell.
*/ */
public SHEFAppsDefaultsDlg(Shell parent) { public SHEFAppsDefaultsDlg(Shell parent) {
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); super(parent);
setText("SHEF Apps_defaults Settings"); setBlockOnOpen(false);
populateTokenList(); setShellStyle(SWT.DIALOG_TRIM);
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
@Override @Override
protected void initializeComponents(final Shell shell) { protected Control createDialogArea(Composite parent) {
setReturnValue(false); 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 @Override
public void widgetSelected(SelectionEvent event) { public void keyPressed(KeyEvent e) {
shell.dispose(); 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(); String[] titles = { "Token", "Value" };
} for (String title : titles) {
TableColumn column = new TableColumn(table, SWT.LEFT);
private void populateDlg() { column.setText(title);
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"));
} }
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 // Read in the xml
statusHandler.debug("Searching for " + CONFIG_FILE_NAME);
IPathManager pm = PathManagerFactory.getPathManager(); IPathManager pm = PathManagerFactory.getPathManager();
System.out.println("Searching for " + CONFIG_FILE_NAME); ILocalizationFile file = pm.getStaticLocalizationFile(CONFIG_FILE_NAME);
File file = pm.getStaticFile(this.CONFIG_FILE_NAME);
if (file != null) { if (file != null) {
try { try (InputStream inStream = file.openInputStream()) {
SHEFAppsDefaultsXML xml = JAXB.unmarshal(file, SHEFAppsDefaultsXML xml = JAXB.unmarshal(inStream,
SHEFAppsDefaultsXML.class); SHEFAppsDefaultsXML.class);
tokenList = new ArrayList<>();
for (String token : xml.getTokenList()) { for (String token : xml.getTokenList()) {
tokenList.add(token); tokenList.add(token);
} }
} catch (Exception e) { } catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getMessage(), e); statusHandler.error(String.format("Error reading file [%s]",
CONFIG_FILE_NAME), e);
} }
} else { } else {
MessageBox messageBox = new MessageBox(this.getParent(), SWT.ERROR); MessageDialog.openError(getShell(), "File Not Found",
messageBox.setText("File Not Found"); "shefGadTokens.xml file not found.");
messageBox.setMessage("shefGadTokens.xml file not found.");
messageBox.open();
} }
}
/* return tokenList;
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
protected void disposed() {
font.dispose();
} }
} }

View file

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

View file

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

View file

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

View file

@ -19,40 +19,44 @@
**/ **/
package com.raytheon.viz.hydro.riversummary; package com.raytheon.viz.hydro.riversummary;
import java.text.DecimalFormat; import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; 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.SWT;
import org.eclipse.swt.custom.ScrolledComposite; 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.PaintEvent;
import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; 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.Font;
import org.eclipse.swt.graphics.GC; 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.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell; 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.HydroConstants;
import com.raytheon.viz.hydrocommon.HydroDisplayManager; import com.raytheon.viz.hydrocommon.HydroDisplayManager;
import com.raytheon.viz.hydrocommon.data.RiverDataPoint; import com.raytheon.viz.hydrocommon.data.RiverDataPoint;
import com.raytheon.viz.hydrocommon.datamanager.RiverDataManager; 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. * 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 * 08 Mar 2010 2486 mpduff Changed to open with the river for the
* selected site automatically selected. * selected site automatically selected.
* 15 Mar 2013 1790 rferrel Make dialog non-blocking. * 15 Mar 2013 1790 rferrel Make dialog non-blocking.
* 08 Apr 2016 5483 dgilling Re-factor to fix hi-dpi issues.
* *
* </pre> * </pre>
* *
@ -74,17 +79,30 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0 * @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. * Maximum stage difference.
*/ */
private static final int MAX_STAGE_DIFF = 100; private static final int MAX_STAGE_DIFF = 100;
/**
* Font used for SWT controls.
*/
private Font font;
/** /**
* Font used on the canvas display. * Font used on the canvas display.
*/ */
@ -95,70 +113,37 @@ public class RiverSummaryDlg extends CaveSWTDialog {
*/ */
private List streamList; 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. * Stage basis combo box.
*/ */
private Combo stageBasisCbo; private Combo stageBasisCbo;
/**
* Canvas displaying the labels for the river summaries.
*/
private Canvas labelCanvas;
/** /**
* Canvas displaying the river summaries. * Canvas displaying the river summaries.
*/ */
private Canvas riverSumCanvas; 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. * Width of the label canvas.
*/ */
private final int LABEL_CANVAS_WIDTH = 120; private int labelCanvasWidth;
/** /**
* Width of the river summary canvas. * Width of the river summary canvas.
*/ */
private final int RIVER_SUM_CANVAS_WIDTH = 2000; private int riverSumCanvasWidth;
/** private int itemWidth;
* 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;
/** /**
* First time flag indicating if the canvases have been drawn on. * First time flag indicating if the canvases have been drawn on.
*/ */
private boolean firstTime = true; private boolean firstTime;
/** /**
* Decimal Formatter * Decimal Formatter
*/ */
private DecimalFormat df = new DecimalFormat(); private NumberFormat df;
/**
* Height of the canvas font.
*/
private int canvasFontHeight;
/** /**
* Y coordinate of the flood stage. * Y coordinate of the flood stage.
@ -188,22 +173,17 @@ public class RiverSummaryDlg extends CaveSWTDialog {
/** /**
* All rivers Data structure * All rivers Data structure
*/ */
private Map<String, LinkedHashMap<String, RiverDataPoint>> riversData = null; private Map<String, LinkedHashMap<String, RiverDataPoint>> riversData;
/** /**
* River Summary Data structure * River Summary Data structure
*/ */
private Map<String, RiverDataPoint> riverData = null; private Map<String, RiverDataPoint> riverData;
/** /**
* River datamanager instance * River datamanager instance
*/ */
private RiverDataManager rsdm = null; private RiverDataManager rsdm;
/**
* Location and size of the dialog.
*/
Rectangle bounds;
/** /**
* Constructor. * Constructor.
@ -212,228 +192,156 @@ public class RiverSummaryDlg extends CaveSWTDialog {
* Parent shell. * Parent shell.
*/ */
public RiverSummaryDlg(Shell parent) { public RiverSummaryDlg(Shell parent) {
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); super(parent);
setText("River Summary"); 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);
} }
/* private void disposed(DisposeEvent e) {
* (non-Javadoc) if (canvasFont != null) {
* canvasFont.dispose();
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed() }
*/
@Override
protected void disposed() {
font.dispose();
canvasFont.dispose();
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
@Override @Override
protected void initializeComponents(Shell shell) { protected Control createDialogArea(Composite parent) {
setReturnValue(false); Composite composite = (Composite) super.createDialogArea(parent);
composite.setLayout(new GridLayout(2, false));
font = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
canvasFont = new Font(shell.getDisplay(), "Monospace", 8, SWT.NORMAL);
// Initialize all of the controls and layouts // Initialize all of the controls and layouts
createStreamListLabel(); createStreamListAndOptions(composite);
createStreamListAndOptions(); createCanvasComposite(composite);
fillStreamList();
createCanvasLabel();
createCanvasComposite();
createCloseButton();
setSelection(); setSelection();
} return composite;
/**
* 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");
} }
/** /**
* Create the stream list control and the options group and control. * Create the stream list control and the options group and control.
*
* @param composite
*/ */
private void createStreamListAndOptions() { private void createStreamListAndOptions(Composite parent) {
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); Label listLabel = new Label(parent, SWT.NONE);
Composite listOptionsComp = new Composite(shell, SWT.NONE); listLabel.setText("Stream List");
GridLayout gl = new GridLayout(2, false); listLabel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false,
gl.horizontalSpacing = 10; 2, 1));
listOptionsComp.setLayout(gl);
listOptionsComp.setLayoutData(gd);
gd = new GridData(475, 100); streamList = new List(parent, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
streamList = new List(listOptionsComp, SWT.BORDER | SWT.SINGLE streamList.setFont(JFaceResources.getTextFont());
| SWT.V_SCROLL); 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.setLayoutData(gd);
streamList.setFont(font); streamList.addSelectionListener(new SelectionAdapter() {
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();
}
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
int index = ((List) e.getSource()).getSelectionIndex(); updateRiverDataFromSelection(((List) e.getSource())
int i = 0; .getSelectionIndex());
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(); riverSumCanvas.redraw();
} }
}); });
// ------------------------------------------- Group optionsGroup = new Group(parent, SWT.NONE);
// Create the Options group optionsGroup.setText("Options");
// ------------------------------------------- optionsGroup.setLayout(new GridLayout(2, false));
gd = new GridData(SWT.FILL, SWT.FILL, true, true); optionsGroup.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false,
Group productInfoGroup = new Group(listOptionsComp, SWT.NONE); true));
gl = new GridLayout(2, false);
productInfoGroup.setLayout(gl);
productInfoGroup.setLayoutData(gd);
productInfoGroup.setText(" Options ");
Label stageLbl = new Label(productInfoGroup, SWT.NONE); Label stageBasisLabel = new Label(optionsGroup, SWT.NONE);
stageLbl.setText("Stage Basis:"); stageBasisLabel.setText("Stage Basis:");
stageBasisLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
false));
gd = new GridData(150, SWT.DEFAULT); stageBasisCbo = new Combo(optionsGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
stageBasisCbo = new Combo(productInfoGroup, SWT.DROP_DOWN stageBasisCbo.setItems(STAGE_BASIS_OPTIONS);
| SWT.READ_ONLY);
stageBasisCbo.add("Max Obs/Fcst");
stageBasisCbo.add("Observed");
stageBasisCbo.add("Forecast");
stageBasisCbo.select(0); stageBasisCbo.select(0);
stageBasisCbo.setLayoutData(gd); stageBasisCbo.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT,
false, false));
stageBasisCbo.addSelectionListener(new SelectionListener() { stageBasisCbo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// issue a paint event
riverSumCanvas.redraw();
}
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
// issue a paint event
riverSumCanvas.redraw(); 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. * Create the composite for the label & river summary canvases.
*
* @param composite
*/ */
private void createCanvasComposite() { private void createCanvasComposite(Composite parent) {
Composite canvasComp = new Composite(shell, SWT.NONE); Composite plotComposite = new Composite(parent, SWT.NONE);
GridLayout gl = new GridLayout(2, false); GridLayout gl = new GridLayout(2, false);
gl.horizontalSpacing = 0; gl.horizontalSpacing = 0;
canvasComp.setLayout(gl); plotComposite.setLayout(gl);
plotComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
true, 2, 1));
addLabelCanvas(canvasComp); Label stationsLabel = new Label(plotComposite, SWT.NONE);
addProfileCanvas(canvasComp); stationsLabel.setText("Stations ordered by river mile");
} stationsLabel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true,
false, 2, 1));
/** canvasFont = new Font(plotComposite.getDisplay(), "Monospace", 8,
* Add the label canvas to the canvas composite. SWT.NORMAL);
*
* @param canvasComp Canvas labelCanvas = new Canvas(plotComposite, SWT.DOUBLE_BUFFERED);
* Canvas composite. labelCanvas.setFont(canvasFont);
*/ GridData gd = new GridData(SWT.CENTER, SWT.FILL, false, true);
private void addLabelCanvas(Composite canvasComp) {
labelCanvas = new Canvas(canvasComp, SWT.DOUBLE_BUFFERED);
GridData gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true);
gd.heightHint = CANVAS_HEIGHT; gd.heightHint = CANVAS_HEIGHT;
gd.widthHint = LABEL_CANVAS_WIDTH; GC gc = new GC(labelCanvas);
labelCanvasWidth = gc.textExtent(STAGE_LABEL_TEXT + " ").x;
labelCanvas.setSize(LABEL_CANVAS_WIDTH, CANVAS_HEIGHT); gd.widthHint = labelCanvasWidth;
gc.dispose();
labelCanvas.setLayoutData(gd); labelCanvas.setLayoutData(gd);
labelCanvas.addPaintListener(new PaintListener() { labelCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) { public void paintControl(PaintEvent e) {
drawLabelCanvas(e); drawLabelCanvas(e);
} }
}); });
} ScrolledComposite scrolledComp = new ScrolledComposite(plotComposite,
SWT.H_SCROLL);
/** scrolledComp.setLayout(new FillLayout());
* 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);
riverSumCanvas = new Canvas(scrolledComp, SWT.DOUBLE_BUFFERED); riverSumCanvas = new Canvas(scrolledComp, SWT.DOUBLE_BUFFERED);
gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true); riverSumCanvas.setFont(canvasFont);
gd.heightHint = CANVAS_HEIGHT; gd = new GridData(SWT.LEFT, SWT.FILL, false, true);
gd.widthHint = RIVER_SUM_CANVAS_WIDTH; gc = new GC(riverSumCanvas);
itemWidth = gc.textExtent(HydroConstants.DATE_FORMAT.toPattern()
riverSumCanvas.setSize(RIVER_SUM_CANVAS_WIDTH, CANVAS_HEIGHT); + " ").x;
gc.dispose();
riverSumCanvasWidth = (itemWidth * 15) + INITIAL_X_POS;
riverSumCanvas.setSize(riverSumCanvasWidth, CANVAS_HEIGHT);
riverSumCanvas.setLayoutData(gd); riverSumCanvas.setLayoutData(gd);
riverSumCanvas.addPaintListener(new PaintListener() { riverSumCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) { public void paintControl(PaintEvent e) {
drawRiverSummaryCanvas(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); scrolledComp.setContent(riverSumCanvas);
} }
@ -444,23 +352,19 @@ public class RiverSummaryDlg extends CaveSWTDialog {
* Paint event. * Paint event.
*/ */
private void drawLabelCanvas(PaintEvent e) { private void drawLabelCanvas(PaintEvent e) {
e.gc.setFont(canvasFont); if (firstTime) {
if (firstTime == true) {
calculateCoordinates(e.gc); calculateCoordinates(e.gc);
} }
e.gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK)); e.gc.setBackground(e.display.getSystemColor(SWT.COLOR_BLACK));
e.gc.fillRectangle(0, 0, labelCanvasWidth, CANVAS_HEIGHT);
e.gc.fillRectangle(0, 0, LABEL_CANVAS_WIDTH, CANVAS_HEIGHT);
// ------------------------------------- // -------------------------------------
// Draw dashed flood line // 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.setLineStyle(SWT.LINE_DOT);
e.gc.drawLine(0, FLOOD_LINE_YCOORD, RIVER_SUM_CANVAS_WIDTH, e.gc.drawLine(0, FLOOD_LINE_YCOORD, labelCanvasWidth, FLOOD_LINE_YCOORD);
FLOOD_LINE_YCOORD);
e.gc.drawString("Flood Stage", 2, floodStgYCoord, true); e.gc.drawString("Flood Stage", 2, floodStgYCoord, true);
@ -480,36 +384,29 @@ public class RiverSummaryDlg extends CaveSWTDialog {
* Paint event. * Paint event.
*/ */
private void drawRiverSummaryCanvas(PaintEvent e) { private void drawRiverSummaryCanvas(PaintEvent e) {
e.gc.setFont(canvasFont); /*
* ticInterval is used to determine max and min stages to be displayed
// ticInterval is used to determine max and min stages to be * by a particular station.
// displayed by a particular station. */
int ticInterval = 5; int ticInterval = 5;
if (firstTime == true) { if (firstTime) {
calculateCoordinates(e.gc); calculateCoordinates(e.gc);
} }
e.gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK)); e.gc.setBackground(e.display.getSystemColor(SWT.COLOR_BLACK));
e.gc.fillRectangle(0, 0, riverSumCanvasWidth, CANVAS_HEIGHT);
e.gc.fillRectangle(0, 0, RIVER_SUM_CANVAS_WIDTH, CANVAS_HEIGHT);
// ------------------------------------- // -------------------------------------
// Draw dashed flood line // 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.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); FLOOD_LINE_YCOORD);
if (getRiverData() != null) { if (getRiverData() != null) {
// must deal with x coordinate int x = INITIAL_X_POS; // starting point
// 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);
for (String key : getRiverData().keySet()) { for (String key : getRiverData().keySet()) {
if (getRiverData().containsKey(key)) { if (getRiverData().containsKey(key)) {
@ -620,7 +517,7 @@ public class RiverSummaryDlg extends CaveSWTDialog {
e.gc.drawString(errorText, x, stageYCoord - 15, true); e.gc.drawString(errorText, x, stageYCoord - 15, true);
} }
x += xoffset; x += itemWidth;
} }
} }
} }
@ -633,65 +530,52 @@ public class RiverSummaryDlg extends CaveSWTDialog {
* Graphic component. * Graphic component.
*/ */
private void calculateCoordinates(GC gc) { private void calculateCoordinates(GC gc) {
canvasFontHeight = (gc.getFontMetrics().getHeight()); int fontHeight = gc.getFontMetrics().getHeight();
floodStgYCoord = FLOOD_LINE_YCOORD - canvasFontHeight - 2; floodStgYCoord = FLOOD_LINE_YCOORD - fontHeight - 2;
nameYCoord = CANVAS_HEIGHT - fontHeight - 2;
nameYCoord = CANVAS_HEIGHT - canvasFontHeight - 2; idYCoord = nameYCoord - fontHeight - 2;
idYCoord = nameYCoord - canvasFontHeight - 2; dateYCoord = idYCoord - fontHeight - 2;
dateYCoord = idYCoord - canvasFontHeight - 2; stageYCoord = dateYCoord - fontHeight - 2;
stageYCoord = dateYCoord - canvasFontHeight - 2;
firstTime = false; firstTime = false;
} }
/** @Override
* Create the Close button. protected void createButtonsForButtonBar(Composite parent) {
*/ createButton(parent, IDialogConstants.CLOSE_ID,
private void createCloseButton() { IDialogConstants.CLOSE_LABEL, true);
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);
gd = new GridData(90, SWT.DEFAULT); @Override
Button closeBtn = new Button(centeredComp, SWT.NONE); protected void buttonPressed(int buttonId) {
closeBtn.setText("Close"); switch (buttonId) {
closeBtn.setLayoutData(gd); case IDialogConstants.CLOSE_ID:
closeBtn.addSelectionListener(new SelectionAdapter() { close();
@Override break;
public void widgetSelected(SelectionEvent event) { default:
bounds = shell.getBounds(); statusHandler.warn(String.format(
close(); "Unrecognized button ID [%d] pressed.", buttonId));
} break;
}); }
} }
/** /**
* Populate teh stream list. * Populate the stream list.
*/ */
private void fillStreamList() { private String[] getStreamList() {
rsdm = RiverDataManager.getInstance();
riversData = rsdm.getRiverSummaryData(); riversData = rsdm.getRiverSummaryData();
String tmpStr;
String tmpStr2;
streamNameList.clear();
Collection<String> streamList = new ArrayList<>(riversData.size());
for (String id : riversData.keySet()) { for (String id : riversData.keySet()) {
tmpStr2 = String.format("(%d stations)", riversData.get(id) String first = riversData.get(id).keySet().iterator().next();
.keySet().size()); String name = riversData.get(id).get(first).getRiverName();
String name = null; int numRecords = riversData.get(id).keySet().size();
// extract the river name for display String tmp = String.format("(%d stations)", numRecords);
for (String key : riversData.get(id).keySet()) { streamList.add(String.format("%-40s %-13s", name, tmp));
name = riversData.get(id).get(key).getRiverName();
break;
}
tmpStr = String.format("%-40s %-13s", name, tmpStr2);
streamList.add(tmpStr);
streamNameList.add(name);
} }
return streamList.toArray(new String[0]);
} }
/** /**
@ -702,16 +586,28 @@ public class RiverSummaryDlg extends CaveSWTDialog {
RiverDataPoint riverPoint = RiverDataManager.getInstance() RiverDataPoint riverPoint = RiverDataManager.getInstance()
.getRiverDataPoint(lid); .getRiverDataPoint(lid);
for (int i = 0; i < streamNameList.size(); i++) { if ((riverPoint != null) && (riverPoint.getStreamName() != null)) {
if (streamNameList.get(i).equalsIgnoreCase( for (int i = 0; i < streamList.getItemCount(); i++) {
riverPoint.getStreamName())) { if (streamList.getItem(i)
streamList.select(i); .startsWith(riverPoint.getStreamName())) {
streamList.showSelection(); streamList.select(i);
break; 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; int i = 0;
String riverKey = null; String riverKey = null;
for (String key : riversData.keySet()) { for (String key : riversData.keySet()) {
@ -721,19 +617,7 @@ public class RiverSummaryDlg extends CaveSWTDialog {
} }
i++; i++;
} }
setRiverData(rsdm.populateRiverData(riverKey, riversData.get(riverKey))); riverData = 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;
} }
/** /**
@ -745,24 +629,16 @@ public class RiverSummaryDlg extends CaveSWTDialog {
return riverData; return riverData;
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
*/
@Override @Override
protected void preOpened() { protected void configureShell(Shell newShell) {
super.preOpened(); super.configureShell(newShell);
shell.addShellListener(new ShellAdapter() { newShell.setText("River Summary");
newShell.addDisposeListener(new DisposeListener() {
@Override @Override
public void shellClosed(ShellEvent e) { public void widgetDisposed(DisposeEvent e) {
bounds = shell.getBounds(); 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.HashMap;
import java.util.Map; 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.SWT;
import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener; 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.MouseListener;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; 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.graphics.Font;
import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite; 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.Label;
import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.List; 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.localization.PathManagerFactory;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; 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.core.exception.VizException;
import com.raytheon.uf.viz.localization.LocalizationPerspectiveUtils; import com.raytheon.uf.viz.localization.LocalizationPerspectiveUtils;
import com.raytheon.uf.viz.localization.service.ILocalizationService; 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.ratingcurve.RatingCurveDlg;
import com.raytheon.viz.hydrocommon.textreport.TextReportDataManager; import com.raytheon.viz.hydrocommon.textreport.TextReportDataManager;
import com.raytheon.viz.hydrocommon.textreport.TextReportDlg; 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.CaveSWTDialog;
import com.raytheon.viz.ui.dialogs.ICloseCallback; 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 LowWaterStatementDlg.
* Changes for non-blocking RatingCurveDlg. * Changes for non-blocking RatingCurveDlg.
* Changes for non-blocking TextReportDlg. * 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 * 02/16/2016 5354 bkowal Prevent the closure of the password dialog from
* closing all of CAVE. * closing all of CAVE.
* *
@ -2093,145 +2092,101 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
* Prompt for the password dialog box. * Prompt for the password dialog box.
*/ */
protected boolean promptForPassword(Shell shell) { protected boolean promptForPassword(Shell shell) {
HBPasswordDlg pwDlg = new HBPasswordDlg(); HBPasswordDlg dialog = new HBPasswordDlg(shell);
return pwDlg.open(shell); int returnCode = dialog.open();
return ((returnCode == Window.OK) && (dialog.isVerified()));
} }
/** /**
* Inner class for the password dialog. * Inner class for the password dialog.
*/ */
private class HBPasswordDlg { private class HBPasswordDlg extends CaveJFACEDialog {
private final String password;
private Text text; 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; this.numTries = 0;
this.verified = false;
public HBPasswordDlg() { this.password = getPassword();
numTries = 0;
} }
public boolean open(final Shell shell) { @Override
Display display = shell.getDisplay(); public int open() {
password = getPassword(); if ((password == null) || (password.isEmpty())) {
verified = false; MessageDialog.openInformation(getShell(), "Password",
if ((password == null) || (password.length() == 0)) { "Please set a password for HydroBase\n"
// Show message + "in the Setup/Administration dialog.");
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();
} }
return super.open();
}
dialog = new Shell(shell, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM); @Override
dialog.setText("Enter Password"); protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
composite.setLayout(new GridLayout(2, false));
FormLayout formLayout = new FormLayout(); Label label = new Label(composite, SWT.NONE);
formLayout.marginWidth = 10;
formLayout.marginHeight = 10;
formLayout.spacing = 10;
dialog.setLayout(formLayout);
Label label = new Label(dialog, SWT.NONE);
label.setText("Enter Password:"); label.setText("Enter Password:");
FormData data = new FormData(); label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true));
label.setLayoutData(data);
Button cancel = new Button(dialog, SWT.PUSH); text = new Text(composite, SWT.SINGLE | SWT.PASSWORD | SWT.BORDER);
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.setFocus(); text.setFocus();
data = new FormData(); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
data.width = 200; GC gc = new GC(text);
data.left = new FormAttachment(label, 0, SWT.DEFAULT); gd.widthHint = gc.getFontMetrics().getAverageCharWidth() * 20;
data.right = new FormAttachment(100, 0); gc.dispose();
data.top = new FormAttachment(label, 0, SWT.CENTER); text.setLayoutData(gd);
data.bottom = new FormAttachment(cancel, 0, SWT.DEFAULT);
text.setLayoutData(data);
text.setEchoChar('*');
Button ok = new Button(dialog, SWT.PUSH); return composite;
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; @Override
} protected void okPressed() {
numTries++;
getShell().setVisible(false);
MessageBox messageBox = new MessageBox(shell, SWT.OK); if (text.getText().equals(password)) {
messageBox.setText("Invalid Password"); verified = true;
messageBox.setMessage("Invalid password entered.\n" } else {
+ " Please try again."); String dialogTitle;
messageBox.open(); String message;
if (numTries < 3) {
// Show the password dialog again dialogTitle = "Invalid Password";
dialog.setVisible(true); message = "Invalid password entered.\n"
} else { + "\tPlease try again.";
// Close the password dialog so HydroBase is accessible } else {
dialog.dispose(); dialogTitle = "ABORTING HydroBase";
verified = true; message = "Three failed password attempts - exiting HydroBase.";
}
} }
}); MessageDialog.openError(getShell(), dialogTitle, message);
getShell().setVisible(true);
dialog.addShellListener(new ShellAdapter() { text.setFocus();
@Override
public void shellClosed(ShellEvent event) {
shell.dispose();
}
});
dialog.setDefaultButton(ok);
dialog.pack();
dialog.open();
while (!dialog.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
} }
if (dialog.isDisposed() == false) { if (verified) {
dialog.dispose(); 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; return verified;
} }
@ -2240,14 +2195,12 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
try { try {
java.util.List<AdministrationData> data = HydroDBDataManager java.util.List<AdministrationData> data = HydroDBDataManager
.getInstance().getData(AdministrationData.class); .getInstance().getData(AdministrationData.class);
if (!data.isEmpty()) {
// if no data is returned, clear the current display data pw = data.get(0).getHbPassword();
AdministrationData adminData = (data.size() > 0) ? data.get(0) }
: null;
pw = adminData.getHbPassword();
} catch (VizException e) { } catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, "Data Query:" statusHandler.error("Data Query:"
+ " Error retrirving HB Password."); + " Error retrirving HB Password.", e);
} }
return pw; return pw;

View file

@ -20,8 +20,16 @@
package com.raytheon.viz.hydrobase.data; package com.raytheon.viz.hydrobase.data;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; 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.geospatial.MapUtil;
import com.raytheon.uf.common.hydro.spatial.HRAP; import com.raytheon.uf.common.hydro.spatial.HRAP;
import com.raytheon.viz.hydrocommon.util.HrapUtil; import com.raytheon.viz.hydrocommon.util.HrapUtil;
@ -41,6 +49,8 @@ import com.vividsolutions.jts.geom.Polygon;
* Dec 18, 2015 5217 mpduff Initial creation * Dec 18, 2015 5217 mpduff Initial creation
* Mar 08, 2016 5217 mpduff Fixed column values to be full hrap columns rather * Mar 08, 2016 5217 mpduff Fixed column values to be full hrap columns rather
* than relative to the subgrid. * 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> * </pre>
* *
@ -76,18 +86,28 @@ public class HydroGeoProcessor {
*/ */
public HrapBinList getHrapBinList(GeoAreaData geoData) throws Exception { public HrapBinList getHrapBinList(GeoAreaData geoData) throws Exception {
List<Coordinate> coords = getPointsFromArea(geoData); List<Coordinate> coords = getPointsFromArea(geoData);
Coordinate[] minMaxXY = getMinMaxXY(coords);
Polygon poly = MapUtil.getPolygon(coords.toArray(new Coordinate[0])); 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); int maxRow = (int) Math.ceil(hrapMax.y);
Coordinate hrapMax = HrapUtil.latLonToHrap(maxC); int maxCol = (int) Math.ceil(hrapMax.x);
int maxRow = (int) Math.floor(hrapMax.y);
int maxCol = (int) Math.floor(hrapMax.x);
int minRow = (int) Math.floor(hrapMin.y); int minRow = (int) Math.floor(hrapMin.y);
int minCol = (int) Math.floor(hrapMin.x); int minCol = (int) Math.floor(hrapMin.x);
@ -109,7 +129,6 @@ public class HydroGeoProcessor {
double area = 0; double area = 0;
HrapBinList binList = new HrapBinList(); HrapBinList binList = new HrapBinList();
for (int r = 0; r < rows; r++) { for (int r = 0; r < rows; r++) {
rowNum = r + minRow; rowNum = r + minRow;
startCol = -1; startCol = -1;
@ -122,11 +141,11 @@ public class HydroGeoProcessor {
.getGridCellPolygon(coord); .getGridCellPolygon(coord);
} }
if (poly.intersects(hrapGeometries[rowNum][colNum])) { if (poly.intersects(hrapGeometries[rowNum][colNum])) {
endCol = c + cols; endCol = c;
binCtr++; binCtr++;
if (startCol == -1) { if (startCol == -1) {
// First cell in the row // First cell in the row
startCol = c + cols; startCol = c;
rowCtr++; rowCtr++;
} }
area += HrapUtil.getHrapBinArea(coord); area += HrapUtil.getHrapBinArea(coord);
@ -208,13 +227,13 @@ public class HydroGeoProcessor {
* for each input point from the database, starting with the second * for each input point from the database, starting with the second
* point * point
*/ */
// Add the first point every time.
points.add(new Coordinate(lon[0], lat[0]));
for (int i = 1; i < data.getNumberPoints(); i++) { for (int i = 1; i < data.getNumberPoints(); i++) {
/* if input points are different */ /* if input points are different */
if ((lat[i] != lat[i - 1]) || (lon[i] != lon[i - 1])) { coord = new Coordinate(lon[i], lat[i]);
coord = new Coordinate(lon[i], lat[i]); points.add(coord);
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 * 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. * 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. * 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 * @author lvenable
* @version 1.0 * @version 1.0
@ -104,17 +105,16 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
private ColorChooserDlg colorDlg; private ColorChooserDlg colorDlg;
/** /**
* callback to be execute upon saving of a color set * callback to be execute upon saving of a color set generally used to
* generally used to update the display with the newly-saved color set * update the display with the newly-saved color set
*/ */
private ISaveCallback saveCallback; private ISaveCallback saveCallback;
public interface ISaveCallback { public interface ISaveCallback {
public void execute(); public void execute();
}
}
/** /**
* User's name. * User's name.
@ -139,17 +139,17 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
/** /**
* Updated Color/Value array of color and value labels. * 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. * 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. * Browse Color/Value array of color and value labels.
*/ */
private java.util.List<ColorValueLabels> browseColorValLblArray; private List<ColorValueLabels> browseColorValLblArray;
/** /**
* Source combo box. * Source combo box.
@ -460,14 +460,17 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
// Create the navigation arrow buttons container // Create the navigation arrow buttons container
// ----------------------------------------------- // -----------------------------------------------
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
Composite arraowBtnComp = new Composite(topControlComp, SWT.BOTTOM); Composite arrowBtnComp = new Composite(topControlComp, SWT.BOTTOM);
gl = new GridLayout(2, false); gl = new GridLayout(2, true);
gl.verticalSpacing = 100; arrowBtnComp.setLayout(gl);
arraowBtnComp.setLayout(gl); arrowBtnComp.setLayoutData(gd);
arraowBtnComp.setLayoutData(gd);
gd = new GridData(50, SWT.DEFAULT); final int buttonMinimumWidth = (int) (arrowBtnComp.getDisplay()
Button leftArrowBtn = new Button(arraowBtnComp, SWT.ARROW | SWT.LEFT); .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.setLayoutData(gd);
leftArrowBtn.addSelectionListener(new SelectionAdapter() { leftArrowBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
@ -485,8 +488,9 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
} }
}); });
gd = new GridData(50, SWT.DEFAULT); gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
Button rightArrowBtn = new Button(arraowBtnComp, SWT.ARROW | SWT.RIGHT); gd.minimumWidth = buttonMinimumWidth;
Button rightArrowBtn = new Button(arrowBtnComp, SWT.ARROW | SWT.RIGHT);
rightArrowBtn.setLayoutData(gd); rightArrowBtn.setLayoutData(gd);
rightArrowBtn.addSelectionListener(new SelectionAdapter() { rightArrowBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
@ -695,13 +699,17 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
// Create the navigation arrow buttons container // Create the navigation arrow buttons container
// ----------------------------------------------- // -----------------------------------------------
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); 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); gl = new GridLayout(2, false);
arraowBtnComp.setLayout(gl); arrowBtnComp.setLayout(gl);
arraowBtnComp.setLayoutData(gd); arrowBtnComp.setLayoutData(gd);
gd = new GridData(50, SWT.DEFAULT); final int buttonMinimumWidth = (int) (arrowBtnComp.getDisplay()
leftArrowBtn = new Button(arraowBtnComp, SWT.ARROW | SWT.LEFT); .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.setLayoutData(gd);
leftArrowBtn.addSelectionListener(new SelectionAdapter() { leftArrowBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
@ -719,8 +727,9 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
} }
}); });
gd = new GridData(50, SWT.DEFAULT); gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
rightArrowBtn = new Button(arraowBtnComp, SWT.ARROW | SWT.RIGHT); gd.minimumWidth = buttonMinimumWidth;
rightArrowBtn = new Button(arrowBtnComp, SWT.ARROW | SWT.RIGHT);
rightArrowBtn.setLayoutData(gd); rightArrowBtn.setLayoutData(gd);
rightArrowBtn.addSelectionListener(new SelectionAdapter() { rightArrowBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
@ -827,13 +836,14 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
// ------------------------------------- // -------------------------------------
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
Composite btnComp = new Composite(editControlsComp, SWT.NONE); Composite btnComp = new Composite(editControlsComp, SWT.NONE);
gl = new GridLayout(4, false); gl = new GridLayout(3, true);
btnComp.setLayout(gl); btnComp.setLayout(gl);
btnComp.setLayoutData(gd); 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); Button addBtn = new Button(btnComp, SWT.PUSH);
addBtn.setText("Add/Update"); addBtn.setText("Add/Update");
addBtn.setToolTipText("Add/Update Color-Value Pair"); 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); Button undoBtn = new Button(btnComp, SWT.PUSH);
undoBtn.setText("Undo"); undoBtn.setText("Undo");
undoBtn.setToolTipText("Undo unsaved changes"); 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); Button deleteBtn = new Button(btnComp, SWT.PUSH);
deleteBtn.setText("Delete"); deleteBtn.setText("Delete");
deleteBtn.setToolTipText("Delete Color-Value Pair"); deleteBtn.setToolTipText("Delete Color-Value Pair");
@ -935,7 +947,6 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
} }
}; };
/** /**
* Update the color label on the display * 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); gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
Composite buttonComp = new Composite(dbControlGroup, SWT.NONE); Composite buttonComp = new Composite(dbControlGroup, SWT.NONE);
gl = new GridLayout(4, false); gl = new GridLayout(4, true);
buttonComp.setLayout(gl); buttonComp.setLayout(gl);
buttonComp.setLayoutData(gd); 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 = new Button(buttonComp, SWT.PUSH);
saveAsUserBtn.setText("Save as:\n" + userName); saveAsUserBtn.setText("Save as:\n" + userName);
saveAsUserBtn.setLayoutData(gd); 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 = new Button(buttonComp, SWT.PUSH);
saveAsOfficeBtn.setText("Save as:\nOffice"); saveAsOfficeBtn.setText("Save as:\nOffice");
saveAsOfficeBtn.setLayoutData(gd); 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 = new Button(buttonComp, SWT.PUSH);
deleteAsUserBtn.setText("Delete as:\n" + userName); deleteAsUserBtn.setText("Delete as:\n" + userName);
deleteAsUserBtn.setLayoutData(gd); 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 = new Button(buttonComp, SWT.PUSH);
deleteAsOfficeBtn.setText("Delete as:\nOffice"); deleteAsOfficeBtn.setText("Delete as:\nOffice");
deleteAsOfficeBtn.setLayoutData(gd); deleteAsOfficeBtn.setLayoutData(gd);
@ -1458,8 +1475,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
*/ */
private void updateBrowseDurationCombo() { private void updateBrowseDurationCombo() {
String source = getSource(); String source = getSource();
java.util.List<String> durations; List<String> durations;
if (source.equals(DEFAULT)) { if (DEFAULT.equals(source)) {
durations = new ArrayList<String>(); durations = new ArrayList<String>();
durations.add("0"); durations.add("0");
} else { } else {
@ -1484,12 +1501,9 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
String source = getSource(); String source = getSource();
java.util.List<ColorScaleData> updatedColorSet = editColorData List<ColorScaleData> updatedColorSet = editColorData
.getColorScaleDataArray(source, selectedDurationInSeconds + "_" .getColorScaleDataArray(source, selectedDurationInSeconds + "_"
+ dataTypeCbo.getText()); + dataTypeCbo.getText());
// java.util.List<ColorScaleData> updatedColorSet = editColorData
// .getColorScaleDataArray(source, durationCbo.getText() + "_"
// + dataTypeCbo.getText());
if (updatedColorSet.size() == 0) { if (updatedColorSet.size() == 0) {
updatedColorSet = editColorData.getColorScaleDataArray(source, 0 updatedColorSet = editColorData.getColorScaleDataArray(source, 0
@ -1530,7 +1544,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
String source = getSource(); String source = getSource();
java.util.List<ColorScaleData> updatedColorSet = editColorData List<ColorScaleData> updatedColorSet = editColorData
.getColorScaleDataArray(source, selectedBrowseDurationInSeconds .getColorScaleDataArray(source, selectedBrowseDurationInSeconds
+ "_" + browseDataTypeCbo.getText()); + "_" + browseDataTypeCbo.getText());
if (updatedColorSet == null) { if (updatedColorSet == null) {
@ -1572,10 +1586,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
String source = getSource(); String source = getSource();
// java.util.List<ColorScaleData> updatedColorSet = editColorData List<ColorScaleData> updatedColorSet = editColorData
// .getUsedColorScaleDataArray(source, durationCbo.getText() + "_"
// + dataTypeCbo.getText());
java.util.List<ColorScaleData> updatedColorSet = editColorData
.getUsedColorScaleDataArray(source, selectedDurationInSeconds .getUsedColorScaleDataArray(source, selectedDurationInSeconds
+ "_" + dataTypeCbo.getText()); + "_" + dataTypeCbo.getText());
@ -1643,7 +1654,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
* @param array * @param array
* Array of color value labels. * Array of color value labels.
*/ */
private void disposeLabelsInArray(java.util.List<ColorValueLabels> array) { private void disposeLabelsInArray(List<ColorValueLabels> array) {
if (array != null) { if (array != null) {
for (ColorValueLabels cvl : array) { for (ColorValueLabels cvl : array) {
cvl.disposeLabels(); cvl.disposeLabels();
@ -1691,12 +1702,6 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
* Populate the source combo box. * Populate the source combo box.
*/ */
private void populateSourceCombo() { 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(DEFAULT);
sourceCbo.add(USER); sourceCbo.add(USER);
sourceCbo.add(OFFICE); sourceCbo.add(OFFICE);
@ -1802,8 +1807,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
// for each datatype in database... // for each datatype in database...
for (String dataType : userDataTypes) { for (String dataType : userDataTypes) {
// get all durations for this datatype and this user // get all durations for this datatype and this user
java.util.List<String> durations = colorManager.getDurations( List<String> durations = colorManager
userId, dataType); .getDurations(userId, dataType);
// for each duration for datatype // for each duration for datatype
for (String duration : durations) { for (String duration : durations) {
@ -1816,13 +1821,13 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
try { try {
// actually get the data from database // 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 // sort data by double value because data is stored as
// String // String
// see ColorValueData class for compareTo function // see ColorValueData class for compareTo function
Collections.sort(data); Collections.sort(data);
ColorScaleSets colorScaleSets = new ColorScaleSets(); ColorScaleSets colorScaleSets = new ColorScaleSets();
java.util.List<ColorScaleData> origList = new ArrayList<ColorScaleData>(); List<ColorScaleData> origList = new ArrayList<ColorScaleData>();
for (ColorValueData colorValue : data) { for (ColorValueData colorValue : data) {
ColorScaleData csd = new ColorScaleData(); ColorScaleData csd = new ColorScaleData();
@ -1841,7 +1846,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
} }
origList.add(csd); origList.add(csd);
} }
java.util.List<ColorScaleData> usedList = new ArrayList<ColorScaleData>(); List<ColorScaleData> usedList = new ArrayList<ColorScaleData>();
usedList.addAll(origList); usedList.addAll(origList);
colorScaleSets.setOriginalArray(origList); colorScaleSets.setOriginalArray(origList);
@ -1875,8 +1880,9 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
gd.horizontalSpan = 2; gd.horizontalSpan = 2;
centeredComp.setLayoutData(gd); centeredComp.setLayoutData(gd);
gd = new GridData(90, SWT.DEFAULT);
Button closeBtn = new Button(centeredComp, SWT.NONE); 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.setText("Close");
closeBtn.setLayoutData(gd); closeBtn.setLayoutData(gd);
closeBtn.addSelectionListener(new SelectionAdapter() { closeBtn.addSelectionListener(new SelectionAdapter() {
@ -1891,8 +1897,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
* Creates the default color data * Creates the default color data
*/ */
private void createDefaultData() { private void createDefaultData() {
java.util.List<String> defaultDataTypes = colorManager List<String> defaultDataTypes = colorManager.getDefaultDataTypes();
.getDefaultDataTypes();
editColorData = new EditColorData(); editColorData = new EditColorData();
@ -1900,7 +1905,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
for (int i = 0; i < defaultDataTypes.size(); i++) { for (int i = 0; i < defaultDataTypes.size(); i++) {
ColorScaleSets colorScaleSets = new ColorScaleSets(); ColorScaleSets colorScaleSets = new ColorScaleSets();
java.util.List<ColorScaleData> origList = colorManager List<ColorScaleData> origList = colorManager
.getDefaultColorScaleData(defaultDataTypes.get(i)); .getDefaultColorScaleData(defaultDataTypes.get(i));
colorScaleSets.setOriginalArray(origList); colorScaleSets.setOriginalArray(origList);
@ -1961,41 +1966,39 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
return true; return true;
} }
private void deleteDataFromDb(String applicationName, String colorUseName,
private void deleteDataFromDb(String applicationName, String colorUseName, String userId, String durationString) { String userId, String durationString) {
HydroDBDataManager manager = HydroDBDataManager.getInstance(); HydroDBDataManager manager = HydroDBDataManager.getInstance();
String whereClause = " WHERE application_name = '" + applicationName + "' AND " + String whereClause = " WHERE application_name = '" + applicationName
"color_use_name = '" + colorUseName + "' AND " + + "' AND " + "color_use_name = '" + colorUseName + "' AND "
"userId = '" + userId + "' AND " + + "userId = '" + userId + "' AND " + "duration = '"
"duration = '" + durationString + "' AND " + + durationString + "' AND " + "threshold_unit = 'E' ";
"threshold_unit = 'E' ";
String statement = "delete from colorValue " + whereClause; String statement = "delete from colorValue " + whereClause;
try {
try { DirectDbQuery.executeStatement(statement, HydroConstants.IHFS,
DirectDbQuery.executeStatement(statement,HydroConstants.IHFS, QueryLanguage.SQL); QueryLanguage.SQL);
} }
catch (VizException e) { catch (VizException e) {
statusHandler.handle(Priority.ERROR, statusHandler.handle(Priority.ERROR,
"Error deleting Color Value Data: ", e); "Error deleting Color Value Data: ", e);
} }
// 0. Collect data to delete (user, dataType, duration // 0. Collect data to delete (user, dataType, duration
java.util.List<ColorScaleData> usedColorData = null; List<ColorScaleData> usedColorData = null;
try try {
{ usedColorData = editColorData.getUsedColorScaleDataArray(userId,
usedColorData = editColorData durationString + "_" + colorUseName);
.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) { if (usedColorData != null) {
ColorValueData cvd = new ColorValueData(); ColorValueData cvd = new ColorValueData();
cvd.setApplicationName(applicationName); cvd.setApplicationName(applicationName);
@ -2003,8 +2006,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
cvd.setUserId(userId); cvd.setUserId(userId);
cvd.setDuration(durationString); cvd.setDuration(durationString);
System.out.println("Attempting to delete data from cvd = " + statusHandler.debug("Attempting to delete data from cvd = "
getStringFromColorValueData(cvd) ); + getStringFromColorValueData(cvd));
// 1. Delete each record from database // 1. Delete each record from database
for (ColorScaleData csd : usedColorData) { for (ColorScaleData csd : usedColorData) {
@ -2015,23 +2018,19 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
statusHandler.handle(Priority.ERROR, statusHandler.handle(Priority.ERROR,
"Error deleting Color Value Data: ", e); "Error deleting Color Value Data: ", e);
} }
} //end for } // end for
} }
} }
private String getStringFromColorValueData(ColorValueData cvd) {
private String getStringFromColorValueData(ColorValueData cvd)
{
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("appName: " + cvd.getApplicationName() + builder.append("appName: " + cvd.getApplicationName()
" colorUseName: " + cvd.getColorUseName() + + " colorUseName: " + cvd.getColorUseName() + " userId: "
" userId: " + cvd.getUserId() + + cvd.getUserId() + " duration: " + cvd.getDuration());
" duration: " + cvd.getDuration());
return builder.toString(); return builder.toString();
} }
/** /**
* save the data to the database * save the data to the database
* *
@ -2048,69 +2047,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
String colorUseName = colorManager.getDataTypeName(saveDataTypeCbo String colorUseName = colorManager.getDataTypeName(saveDataTypeCbo
.getText()); .getText());
String duration = selectedDurationInSeconds.toString(); String duration = selectedDurationInSeconds.toString();
deleteDataFromDb(applicationName, colorUseName, userId, duration); 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(); ColorValueData cvd = new ColorValueData();
for (ColorValueLabels cvls : colorValLblArray) { for (ColorValueLabels cvls : colorValLblArray) {
@ -2122,6 +2060,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
} else if (ColorScaleData.LESS_THAN_MIN.equals(threshold)) { } else if (ColorScaleData.LESS_THAN_MIN.equals(threshold)) {
threshold = "-8888"; threshold = "-8888";
} }
cvd.setApplicationName(applicationName); cvd.setApplicationName(applicationName);
cvd.setUserId(userId); cvd.setUserId(userId);
cvd.setColorName(colorName); cvd.setColorName(colorName);
@ -2131,6 +2070,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
cvd.setThresholdValue(threshold); cvd.setThresholdValue(threshold);
try { try {
manager.putData(cvd); manager.putData(cvd);
} catch (VizException e1) { } catch (VizException e1) {
statusHandler.handle(Priority.ERROR, statusHandler.handle(Priority.ERROR,
@ -2138,41 +2078,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
} }
} }
if (DEFAULT.equals(sourceCbo.getText())) {
//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)) {
createDefaultData(); createDefaultData();
} else { } else {
createColorData(user); createColorData(user);
@ -2180,15 +2086,14 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
updateDurationCombo(); updateDurationCombo();
updateColorValueLabelBar(); updateColorValueLabelBar();
if (this.saveCallback != null) { if (this.saveCallback != null) {
this.saveCallback.execute(); this.saveCallback.execute();
} }
setReturnValue(true); setReturnValue(true);
} }
public void setSaveCallback(ISaveCallback iSaveCallback) public void setSaveCallback(ISaveCallback iSaveCallback) {
{
this.saveCallback = iSaveCallback; this.saveCallback = iSaveCallback;
} }
@ -2230,10 +2135,10 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
* update delete buttons based on source/user * update delete buttons based on source/user
*/ */
private void updateButtons() { private void updateButtons() {
if (sourceCbo.getText().equals(OFFICE)) { if (OFFICE.equals(sourceCbo.getText())) {
deleteAsOfficeBtn.setEnabled(true); deleteAsOfficeBtn.setEnabled(true);
deleteAsUserBtn.setEnabled(false); deleteAsUserBtn.setEnabled(false);
} else if (sourceCbo.getText().equals(USER)) { } else if (USER.equals(sourceCbo.getText())) {
deleteAsOfficeBtn.setEnabled(false); deleteAsOfficeBtn.setEnabled(false);
if (userIdCbo.getText().equals(userName)) { if (userIdCbo.getText().equals(userName)) {
deleteAsUserBtn.setEnabled(true); deleteAsUserBtn.setEnabled(true);
@ -2253,8 +2158,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
// 0. Collect data to delete (user, dataType, duration // 0. Collect data to delete (user, dataType, duration
String dataType = dataTypeCbo.getText(); String dataType = dataTypeCbo.getText();
String duration = selectedDurationInSeconds.toString(); String duration = selectedDurationInSeconds.toString();
java.util.List<ColorScaleData> data = editColorData List<ColorScaleData> data = editColorData.getUsedColorScaleDataArray(
.getUsedColorScaleDataArray(source, duration + "_" + dataType); source, duration + "_" + dataType);
ColorValueData cvd = new ColorValueData(); ColorValueData cvd = new ColorValueData();
cvd.setApplicationName(colorManager.getApplicationName()); cvd.setApplicationName(colorManager.getApplicationName());
cvd.setColorUseName(colorManager.getDataTypeName(dataType)); cvd.setColorUseName(colorManager.getDataTypeName(dataType));
@ -2274,7 +2179,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
// 2. Update editColorData // 2. Update editColorData
boolean dataLeft = true; boolean dataLeft = true;
if (source.equals(DEFAULT)) { if (DEFAULT.equals(source)) {
createDefaultData(); createDefaultData();
} else { } else {
dataLeft = createColorData(source); dataLeft = createColorData(source);
@ -2315,9 +2220,9 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
public String getSource() { public String getSource() {
sourceColor = sourceCbo.getText(); sourceColor = sourceCbo.getText();
if (sourceColor.equals(OFFICE)) { if (OFFICE.equals(sourceColor)) {
sourceColor = OFFICE_DEFAULT; sourceColor = OFFICE_DEFAULT;
} else if (sourceColor.equals(USER)) { } else if (USER.equals(sourceColor)) {
sourceColor = userIdCbo.getItem(userIdCbo.getSelectionIndex()); sourceColor = userIdCbo.getItem(userIdCbo.getSelectionIndex());
} }

View file

@ -1,51 +1,48 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- <!--
This_software_was_developed_and_/_or_modified_by_Raytheon_Company, This_software_was_developed_and_/_or_modified_by_Raytheon_Company,
pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government. pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government.
U.S._EXPORT_CONTROLLED_TECHNICAL_DATA U.S._EXPORT_CONTROLLED_TECHNICAL_DATA
This_software_product_contains_export-restricted_data_whose This_software_product_contains_export-restricted_data_whose
export/transfer/disclosure_is_restricted_by_U.S._law._Dissemination export/transfer/disclosure_is_restricted_by_U.S._law._Dissemination
to_non-U.S._persons_whether_in_the_United_States_or_abroad_requires to_non-U.S._persons_whether_in_the_United_States_or_abroad_requires
an_export_license_or_other_authorization. an_export_license_or_other_authorization.
Contractor_Name:________Raytheon_Company Contractor_Name:________Raytheon_Company
Contractor_Address:_____6825_Pine_Street,_Suite_340 Contractor_Address:_____6825_Pine_Street,_Suite_340
________________________Mail_Stop_B8 ________________________Mail_Stop_B8
________________________Omaha,_NE_68106 ________________________Omaha,_NE_68106
________________________402.291.0100 ________________________402.291.0100
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
further_licensing_information. further_licensing_information.
--> -->
<bundle> <bundle>
<displayList> <displayList>
<displays xsi:type="d2DMapRenderableDisplay" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <displays xsi:type="d2DMapRenderableDisplay" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<descriptor xsi:type="mapDescriptor"> <descriptor xsi:type="mapDescriptor">
<resource> <resource>
<loadProperties xsi:type="gridLoadProperties" displayType="IMAGE" loadWithoutData="true"> <loadProperties xsi:type="gridLoadProperties" displayType="IMAGE" loadWithoutData="true">
</loadProperties> </loadProperties>
<properties isSystemResource="false" <properties isSystemResource="false" isBlinking="false" isMapLayer="false" isHoverOn="false"
isBlinking="false" isMapLayer="false" isHoverOn="false" isVisible="true" />
isVisible="true" /> <resourceData xsi:type="gridLightningResourceData" isUpdatingOnMetadataOnly="false"
<resourceData xsi:type="gridLightningResourceData" isRequeryNecessaryOnTimeMatch="true" handlingPositiveStrikes="true" handlingNegativeStrikes="true"
isUpdatingOnMetadataOnly="false" isRequeryNecessaryOnTimeMatch="true" handlingPulses="false" handlingCloudFlashes="false" kmResolution="${resolution}">
handlingPositiveStrikes="true" handlingNegativeStrikes="true" <binOffset posOffset="0" negOffset="${negOffset}" virtualOffset="0" />
handlingPulses="false" handlingCloudFlashes="false" <binRepeatCount>${binRepeatCount;1}</binRepeatCount>
kmResolution="${resolution}"> <metadataMap>
<binOffset posOffset="0" negOffset="${negOffset}" virtualOffset="0"/> <mapping key="pluginName">
<binRepeatCount>${binRepeatCount;1}</binRepeatCount> <constraint constraintValue="binlightning" constraintType="EQUALS" />
<metadataMap> </mapping>
<mapping key="pluginName"> <mapping key="source">
<constraint constraintValue="binlightning" constraintType="EQUALS" /> <constraint constraintValue="${source}" constraintType="EQUALS" />
</mapping> </mapping>
<mapping key="source"> </metadataMap>
<constraint constraintValue="${source}" constraintType="EQUALS" /> </resourceData>
</mapping> </resource>
</metadataMap> </descriptor>
</resourceData> </displays>
</resource> </displayList>
</descriptor>
</displays>
</displayList>
</bundle> </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. further_licensing_information.
--> -->
<menuTemplate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <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"> menuText="1hr plot" id="1HrLightningFlashPlot">
<substitute key="negOffset" value="3600"/>
</contribute> </contribute>
<contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot15Min.xml" <contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot.xml"
menuText="15min plot" id="15MinLightningFlashPlot"> menuText="15min plot" id="15MinLightningFlashPlot">
<substitute key="negOffset" value="900"/>
</contribute> </contribute>
<contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot15MinPN.xml" <contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot15MinPN.xml"
menuText="15min Pos/Neg plot" id="15MinPNLightningFlashPlot"> menuText="15min Pos/Neg plot" id="15MinPNLightningFlashPlot">
</contribute> </contribute>
<contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot5Min.xml" <contribute xsi:type="bundleItem" file="bundles/TotalLightningPlot.xml"
menuText="5min plot" id="5MinLightningFlashPlot"> menuText="5min plot" id="5MinLightningFlashPlot">
<substitute key="negOffset" value="300"/>
</contribute> </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"> menuText="1min plot" id="1MinLightningFlashPlot">
<substitute key="negOffset" value="60"/>
</contribute> </contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningSeq.xml" <contribute xsi:type="bundleItem" file="bundles/LightningSeq.xml"
menuText="1min Lgtng Seq Plot" id="1MinLightningFlashSeq"> menuText="1min Lgtng Seq Plot" id="1MinLightningFlashSeq">

View file

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

View file

@ -32,5 +32,13 @@
menuText="5min cloud to ground density" id="1HrGridLightningCGPlot"> menuText="5min cloud to ground density" id="1HrGridLightningCGPlot">
<substitute key="negOffset" value="300"/> <substitute key="negOffset" value="300"/>
</contribute> </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> </menuTemplate>

View file

@ -56,27 +56,44 @@
<contribute xsi:type="bundleItem" file="bundles/GridLightningCGPlot.xml" <contribute xsi:type="bundleItem" file="bundles/GridLightningCGPlot.xml"
menuText="5min cloud to ground density" id="1HrGridLightningCGPlot"> 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="negOffset" value="60"/>
<substitute key="binRepeatCount" value="5"/> <substitute key="binRepeatCount" value="5"/>
</contribute> </contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningCloudFlashPlot.xml" <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="negOffset" value="60"/>
<substitute key="binRepeatCount" value="5"/> <substitute key="binRepeatCount" value="5"/>
</contribute> </contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningTotalFlashPlot.xml" <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="negOffset" value="60"/>
<substitute key="binRepeatCount" value="5"/> <substitute key="binRepeatCount" value="5"/>
</contribute> </contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningPulsePlot.xml" <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="negOffset" value="60"/>
<substitute key="binRepeatCount" value="5"/> <substitute key="binRepeatCount" value="5"/>
</contribute> </contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningCGPlot.xml" <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"/> <substitute key="negOffset" value="60"/>
</contribute> </contribute>
<contribute xsi:type="bundleItem" file="bundles/GridLightningCloudFlashPlot.xml" <contribute xsi:type="bundleItem" file="bundles/GridLightningCloudFlashPlot.xml"

View file

@ -19,17 +19,29 @@
further_licensing_information. further_licensing_information.
--> -->
<menuTemplate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <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"> menuText="1hr plot" id="1HrLightningFlashPlot">
<substitute key="negOffset" value="3600"/>
</contribute> </contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningPlot15Min.xml" <contribute xsi:type="bundleItem" file="bundles/LightningPlot.xml"
menuText="15min plot" id="15MinLightningFlashPlot"> menuText="15min plot" id="15MinLightningFlashPlot">
<substitute key="negOffset" value="900"/>
</contribute> </contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningPlot15MinPN.xml" <contribute xsi:type="bundleItem" file="bundles/LightningPlot15MinPN.xml"
menuText="15min Pos/Neg plot" id="15MinPNLightningFlashPlot"> menuText="15min Pos/Neg plot" id="15MinPNLightningFlashPlot">
</contribute> </contribute>
<contribute xsi:type="bundleItem" file="bundles/LightningPlot5Min.xml" <contribute xsi:type="bundleItem" file="bundles/LightningPlot.xml"
menuText="5min plot" id="5MinLightningFlashPlot"> 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>
<contribute xsi:type="bundleItem" file="bundles/LightningSeq.xml" <contribute xsi:type="bundleItem" file="bundles/LightningSeq.xml"
menuText="1min Lgtng Seq Plot" id="1MinLightningFlashSeq"> 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 10, 2015 4856 njensen synchronize in remove(DataTime)
* Sep 25, 2015 4605 bsteffen repeat binning * Sep 25, 2015 4605 bsteffen repeat binning
* Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling
* Apr 26, 2016 5597 bsteffen Include update interval in legend.
* *
* </pre> * </pre>
* *
@ -184,6 +185,9 @@ public class LightningResource extends
int absTimeInterval = Math.abs(resourceData.getRepeatingBinOffset() int absTimeInterval = Math.abs(resourceData.getRepeatingBinOffset()
.getInterval()); .getInterval());
int updateInterval = Math
.abs(resourceData.getBinOffset().getInterval());
// If a virtual offset is provided, it is aged lightning, so use // If a virtual offset is provided, it is aged lightning, so use
// the virtual offset to provide the "Old" time // the virtual offset to provide the "Old" time
int virtualOffset = resourceData.getBinOffset().getVirtualOffset(); int virtualOffset = resourceData.getBinOffset().getVirtualOffset();
@ -201,6 +205,9 @@ public class LightningResource extends
if (source != null) { if (source != null) {
rval += source + ' '; rval += source + ' ';
} }
if (updateInterval != absTimeInterval) {
rval += convertTimeIntervalToString(updateInterval) + "Update ";
}
return rval; return rval;
} }

View file

@ -25,16 +25,23 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI; 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.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> * <pre>
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jul 15, 2009 2616 snaples Initial creation * 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> * </pre>
* *
* @author snaples * @author snaples
@ -42,11 +49,27 @@ import com.raytheon.viz.mpe.ui.dialogs.RadarBiasTableDialog;
*/ */
public class ShowBiasTable extends AbstractHandler { public class ShowBiasTable extends AbstractHandler {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(getClass());
@Override @Override
public Object execute(ExecutionEvent arg0) throws ExecutionException { 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() Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell(); .getShell();
RadarBiasTableDialog dialog = new RadarBiasTableDialog(shell); RadarBiasTableDialog dialog = new RadarBiasTableDialog(shell, radIds);
dialog.open(); dialog.open();
return null; return null;

View file

@ -36,6 +36,7 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Apr 28, 2010 mschenke Initial creation * Apr 28, 2010 mschenke Initial creation
* Apr 20, 2016 5541 dgilling Fix issues with hide/restore and perspective switching.
* *
* </pre> * </pre>
* *
@ -86,8 +87,14 @@ public class AbstractMPEDialog extends Dialog implements
@Override @Override
public final void hide() { public final void hide() {
if (shell != null && shell.isDisposed() == false) { hide(false);
wasVisible = shell.isVisible(); }
@Override
public final void hide(boolean isPerspectiveSwitch) {
Shell shell = getShell();
if ((shell != null) && (!shell.isDisposed())) {
wasVisible = shell.isVisible() && isPerspectiveSwitch;
lastLocation = shell.getLocation(); lastLocation = shell.getLocation();
shell.setVisible(false); shell.setVisible(false);
} }
@ -95,10 +102,17 @@ public class AbstractMPEDialog extends Dialog implements
@Override @Override
public final void restore() { public final void restore() {
if (shell != null && shell.isDisposed() == false) { restore(false);
shell.setVisible(wasVisible);
shell.setLocation(lastLocation);
}
} }
@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.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
@ -49,7 +50,8 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
* *
* Date Ticket# Engineer Description * 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> * </pre>
* *
@ -153,11 +155,18 @@ public class BadGagesDlg extends AbstractMPEDialog {
listComp.setLayout(new GridLayout(1, false)); listComp.setLayout(new GridLayout(1, false));
listComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); 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 gageList = new List(listComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL
| SWT.H_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.setLayoutData(gd);
gageList.addSelectionListener(new SelectionAdapter() { gageList.addSelectionListener(new SelectionAdapter() {
@Override @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); 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.setText("Delete Selected Item");
deleteSelectedBtn.setEnabled(false); deleteSelectedBtn.setEnabled(false);
deleteSelectedBtn.setLayoutData(gd); deleteSelectedBtn.setLayoutData(gd);
@ -190,13 +199,13 @@ public class BadGagesDlg extends AbstractMPEDialog {
private void createBottomButtons() { private void createBottomButtons() {
Composite buttonComp = new Composite(shell, SWT.NONE); Composite buttonComp = new Composite(shell, SWT.NONE);
buttonComp.setLayout(new GridLayout(2, true)); 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)); false));
int buttonWidth = 80; int minimumButtonWidth = buttonComp.getDisplay().getDPI().x;
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.widthHint = buttonWidth; gd.minimumWidth = minimumButtonWidth;
Button okBtn = new Button(buttonComp, SWT.PUSH); Button okBtn = new Button(buttonComp, SWT.PUSH);
okBtn.setText("OK"); okBtn.setText("OK");
okBtn.setLayoutData(gd); okBtn.setLayoutData(gd);
@ -208,8 +217,8 @@ public class BadGagesDlg extends AbstractMPEDialog {
} }
}); });
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.widthHint = buttonWidth; gd.minimumWidth = minimumButtonWidth;
Button cancelBtn = new Button(buttonComp, SWT.PUSH); Button cancelBtn = new Button(buttonComp, SWT.PUSH);
cancelBtn.setText("Cancel"); cancelBtn.setText("Cancel");
cancelBtn.setLayoutData(gd); cancelBtn.setLayoutData(gd);

View file

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

View file

@ -65,9 +65,10 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jul, 7 2009 snaples Initial creation * Jul, 7 2009 snaples Initial creation
* Sep 11, 2013 #2353 lvenable Fixed cursor memory leak. * 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 * Jan 15, 2016 5054 randerso Use proper parent shell
* Apr 05, 2015 18350 snaples Updated static calls to dailyqc utils. * Apr 05, 2015 18350 snaples Updated static calls to dailyqc utils.
* Apr 11, 2016 5512 bkowal Fix GUI sizing issues. Cleanup.
* *
* </pre> * </pre>
* *
@ -126,10 +127,6 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
OtherFreezeOptions ozo = new OtherFreezeOptions(); OtherFreezeOptions ozo = new OtherFreezeOptions();
// Zdata[] zdata = new Zdata[0];
// Ts[] ts;
private int time_pos; private int time_pos;
public static Button[] tsbuttons = null; public static Button[] tsbuttons = null;
@ -158,29 +155,33 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
private int getOpts() { private int getOpts() {
int ik = 0; 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; ik = 0;
} else if (DailyQcUtils.points_flag == 1 && DailyQcUtils.grids_flag == -1 } else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.map_flag == -1 && DailyQcUtils.contour_flag == -1) { && DailyQcUtils.grids_flag == -1 && DailyQcUtils.map_flag == -1
&& DailyQcUtils.contour_flag == -1) {
ik = 0; ik = 0;
} else if (DailyQcUtils.points_flag == -1 && DailyQcUtils.grids_flag == 1 } else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.map_flag == -1) { && DailyQcUtils.grids_flag == 1 && DailyQcUtils.map_flag == -1) {
ik = 1; ik = 1;
} else if (DailyQcUtils.points_flag == -1 && DailyQcUtils.grids_flag == -1 } else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.map_flag == 1) { && DailyQcUtils.grids_flag == -1 && DailyQcUtils.map_flag == 1) {
ik = 2; ik = 2;
} else if (DailyQcUtils.points_flag == 1 && DailyQcUtils.grids_flag == 1 } else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.map_flag == -1) { && DailyQcUtils.grids_flag == 1 && DailyQcUtils.map_flag == -1) {
ik = 3; ik = 3;
} else if (DailyQcUtils.points_flag == 1 && DailyQcUtils.grids_flag == -1 } else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.map_flag == 1) { && DailyQcUtils.grids_flag == -1 && DailyQcUtils.map_flag == 1) {
ik = 4; ik = 4;
} else if (DailyQcUtils.points_flag == -1 && DailyQcUtils.contour_flag == 1) { } else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.contour_flag == 1) {
ik = 5; ik = 5;
} else if (DailyQcUtils.points_flag == 1 && DailyQcUtils.contour_flag == 1) { } else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.contour_flag == 1) {
ik = 6; ik = 6;
} else if (DailyQcUtils.points_flag == -1 && DailyQcUtils.grids_flag == -1 } else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.map_flag == -1) { && DailyQcUtils.grids_flag == -1 && DailyQcUtils.map_flag == -1) {
ik = 7; ik = 7;
} }
return ik; return ik;
@ -343,7 +344,6 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
// checks to see if area or date has changed since last data load // checks to see if area or date has changed since last data load
DailyQcUtils dqcu = DailyQcUtils.getInstance(); DailyQcUtils dqcu = DailyQcUtils.getInstance();
dqc_good = dqcu.qcDataReload(currDate, QcArea, qcDays, false); dqc_good = dqcu.qcDataReload(currDate, QcArea, qcDays, false);
// dqc.zdata = DailyQcUtils.zdata;
if (MPEDisplayManager.pcpn_time_step != 0) { if (MPEDisplayManager.pcpn_time_step != 0) {
MPEDisplayManager.pcpn_time_step = 0; MPEDisplayManager.pcpn_time_step = 0;
DailyQcUtils.pcpn_time = 0; DailyQcUtils.pcpn_time = 0;
@ -359,7 +359,6 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.pcpn_time = 0; DailyQcUtils.pcpn_time = 0;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
time_pos = 100 + DailyQcUtils.pcp_flag; time_pos = 100 + DailyQcUtils.pcp_flag;
if ((i != 0 && i != 7) && DailyQcUtils.pcp_in_use[time_pos] == -1) { 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.createDataOptionsGroup();
this.createPointSetComp(); this.createPointSetComp();
this.createPointControlComp(); this.createPointControlComp();
@ -380,7 +378,7 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
private void createDataOptionsGroup() { private void createDataOptionsGroup() {
int i = 0; int i = 0;
Group dataOptionsGroup = new Group(shell, SWT.NONE); Group dataOptionsGroup = new Group(shell, SWT.NONE);
dataOptionsGroup.setText(" Data Options "); dataOptionsGroup.setText("Data Options");
GridLayout groupLayout = new GridLayout(1, false); GridLayout groupLayout = new GridLayout(1, false);
dataOptionsGroup.setLayout(groupLayout); dataOptionsGroup.setLayout(groupLayout);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
@ -396,16 +394,18 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
freezeTimeCompLayout.marginHeight = 0; freezeTimeCompLayout.marginHeight = 0;
freezeTimeCompLayout.marginWidth = 0; freezeTimeCompLayout.marginWidth = 0;
freezeTimeComp.setLayout(freezeTimeCompLayout); freezeTimeComp.setLayout(freezeTimeCompLayout);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
freezeTimeComp.setLayoutData(gd);
Label freezeTimeLbl = new Label(freezeTimeComp, SWT.CENTER); Label freezeTimeLbl = new Label(freezeTimeComp, SWT.CENTER);
freezeTimeLbl.setText(" 6 Hour "); freezeTimeLbl.setText("6 Hour");
// Add the time arrow buttons // Add the time arrow buttons
Composite timeArrowsComp = new Composite(freezeTimeComp, SWT.NONE); Composite timeArrowsComp = new Composite(freezeTimeComp, SWT.NONE);
RowLayout timeArrowRl = new RowLayout(SWT.HORIZONTAL); RowLayout timeArrowRl = new RowLayout(SWT.HORIZONTAL);
timeArrowsComp.setLayout(timeArrowRl); 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 = new Button(timeArrowsComp, SWT.ARROW | SWT.UP);
upTimeBtn.setLayoutData(rd); upTimeBtn.setLayoutData(rd);
upTimeBtn.setEnabled(false); 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 = new Button(timeArrowsComp, SWT.ARROW | SWT.DOWN);
dnTimeBtn.setLayoutData(rd); dnTimeBtn.setLayoutData(rd);
dnTimeBtn.setEnabled(false); 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()]; String[] a = new String[dataSet.size()];
dataDispCbo = new Combo(dataOptionsGroup, SWT.DROP_DOWN | SWT.READ_ONLY); dataDispCbo = new Combo(dataOptionsGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
@ -453,8 +453,10 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
renderCompLayout.marginHeight = 0; renderCompLayout.marginHeight = 0;
renderCompLayout.marginWidth = 0; renderCompLayout.marginWidth = 0;
renderComp.setLayout(renderCompLayout); 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 = new Button(renderComp, SWT.PUSH);
renderGridsBtn.setText("Render Grids+MAZs"); renderGridsBtn.setText("Render Grids+MAZs");
renderGridsBtn.setLayoutData(gd); renderGridsBtn.setLayoutData(gd);
@ -479,11 +481,13 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
filterTypeCompLayout.marginHeight = 0; filterTypeCompLayout.marginHeight = 0;
filterTypeCompLayout.marginWidth = 0; filterTypeCompLayout.marginWidth = 0;
filterTypeComp.setLayout(filterTypeCompLayout); filterTypeComp.setLayout(filterTypeCompLayout);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
filterTypeComp.setLayoutData(gd);
Label pcpLbl = new Label(filterTypeComp, SWT.CENTER); Label pcpLbl = new Label(filterTypeComp, SWT.CENTER);
pcpLbl.setText("Filter Z:"); 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 filterZTypeCbo = new Combo(filterTypeComp, SWT.DROP_DOWN
| SWT.READ_ONLY); | SWT.READ_ONLY);
filterZTypeCbo.setTextLimit(30); filterZTypeCbo.setTextLimit(30);
@ -503,7 +507,7 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
private void createPointSetComp() { private void createPointSetComp() {
Composite pntSetComp = new Composite(shell, SWT.NONE); Composite pntSetComp = new Composite(shell, SWT.NONE);
GridLayout pntSetCompGl = new GridLayout(2, false); GridLayout pntSetCompGl = new GridLayout(2, true);
pntSetComp.setLayout(pntSetCompGl); pntSetComp.setLayout(pntSetCompGl);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
pntSetComp.setLayoutData(gd); pntSetComp.setLayoutData(gd);
@ -657,7 +661,6 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
OtherPrecipOptions.change_maxmin_flag = -1; OtherPrecipOptions.change_maxmin_flag = -1;
// initialize the gage filter values // initialize the gage filter values
// DailyQcUtils.elevation_filter_value = pntElFilter.getSelection();
pntFilter.setSelection(0); pntFilter.setSelection(0);
pntRevFilter.setSelection(0); pntRevFilter.setSelection(0);
dqc.pxtemp = (pxTempFilter.getSelection() - 100) / 100; 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.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter; 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.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowData; import org.eclipse.swt.layout.RowData;
@ -72,7 +72,7 @@ import com.raytheon.viz.mpe.util.DailyQcUtils;
* day rollover >18Z occurs. * day rollover >18Z occurs.
* Jan 15, 2016 5054 randerso Use proper parent shell * 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 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> * </pre>
* *
* @author snaples * @author snaples
@ -85,11 +85,6 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
private static Combo dataDispCbo; private static Combo dataDispCbo;
/**
* Font used for controls.
*/
private Font font;
public static Button upTimeBtn; public static Button upTimeBtn;
public static Button dnTimeBtn; public static Button dnTimeBtn;
@ -140,18 +135,12 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
private DailyQcUtils dqc; 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(); OtherPrecipOptions opo = new OtherPrecipOptions();
// int[] pcp_in_use;
// Pdata[] pdata = new Pdata[0];
// Ts[] ts;
private int time_pos; private int time_pos;
public static Button[] tsbuttons = null; public static Button[] tsbuttons = null;
@ -272,13 +261,11 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
shell.setText("QC Precipitation Options"); shell.setText("QC Precipitation Options");
// Create the main layout for the shell. // Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, true); GridLayout mainLayout = new GridLayout(1, false);
mainLayout.marginHeight = 1; mainLayout.marginHeight = 0;
mainLayout.marginWidth = 1; mainLayout.marginWidth = 0;
shell.setLayout(mainLayout); shell.setLayout(mainLayout);
font = new Font(shell.getDisplay(), "Courier", 10, SWT.NORMAL);
// Initialize all of the controls and layouts // Initialize all of the controls and layouts
this.initializeComponents(); this.initializeComponents();
@ -317,10 +304,8 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.qpf_flag = false; DailyQcUtils.qpf_flag = false;
isfinished = true; isfinished = true;
isOpen = false; isOpen = false;
font.dispose();
SaveLevel2Data s2 = new SaveLevel2Data(getShell()); SaveLevel2Data s2 = new SaveLevel2Data(getShell());
s2.send_dbase_new_area(); s2.send_dbase_new_area();
dqc.destroy();
displayMgr.displayFieldData(df); displayMgr.displayFieldData(df);
removePerspectiveListener(); removePerspectiveListener();
if (MPEDisplayManager.getCurrent() != null) { if (MPEDisplayManager.getCurrent() != null) {
@ -359,7 +344,6 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.pcpn_time = 0; DailyQcUtils.pcpn_time = 0;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
if (MPEDisplayManager.pcpn_time_step == 0) { if (MPEDisplayManager.pcpn_time_step == 0) {
time_pos = DailyQcUtils.pcp_flag; time_pos = DailyQcUtils.pcp_flag;
} else { } else {
@ -371,7 +355,6 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
} }
} }
// ts = DailyQcUtils.ts;
this.createDataOptionsGroup(); this.createDataOptionsGroup();
this.createPointTypeGroup(); this.createPointTypeGroup();
this.createPointQualityGroup(); this.createPointQualityGroup();
@ -386,7 +369,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
private void createDataOptionsGroup() { private void createDataOptionsGroup() {
int i = 0; int i = 0;
Group dataOptionsGroup = new Group(shell, SWT.NONE); Group dataOptionsGroup = new Group(shell, SWT.NONE);
dataOptionsGroup.setText(" Data Options "); dataOptionsGroup.setText("Data Options");
GridLayout groupLayout = new GridLayout(1, false); GridLayout groupLayout = new GridLayout(1, false);
dataOptionsGroup.setLayout(groupLayout); dataOptionsGroup.setLayout(groupLayout);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
@ -406,11 +389,13 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
six24CompLayout.marginHeight = 0; six24CompLayout.marginHeight = 0;
six24CompLayout.marginWidth = 0; six24CompLayout.marginWidth = 0;
six24Comp.setLayout(six24CompLayout); six24Comp.setLayout(six24CompLayout);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
six24Comp.setLayoutData(gd);
Label six24Lbl = new Label(six24Comp, SWT.CENTER); Label six24Lbl = new Label(six24Comp, SWT.CENTER);
six24Lbl.setText("6/24 Hour:"); 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 = new Combo(six24Comp, SWT.DROP_DOWN | SWT.READ_ONLY);
selsix24Cbo.setTextLimit(30); selsix24Cbo.setTextLimit(30);
selsix24Cbo.setLayoutData(sd); selsix24Cbo.setLayoutData(sd);
@ -435,7 +420,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
RowLayout timeArrowRl = new RowLayout(SWT.HORIZONTAL); RowLayout timeArrowRl = new RowLayout(SWT.HORIZONTAL);
timeArrowsComp.setLayout(timeArrowRl); 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 = new Button(timeArrowsComp, SWT.ARROW | SWT.UP);
upTimeBtn.setLayoutData(rd); upTimeBtn.setLayoutData(rd);
upTimeBtn.setEnabled(false); 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 = new Button(timeArrowsComp, SWT.ARROW | SWT.DOWN);
dnTimeBtn.setLayoutData(rd); dnTimeBtn.setLayoutData(rd);
dnTimeBtn.setEnabled(false); dnTimeBtn.setEnabled(false);
@ -457,25 +442,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
} }
}); });
GridData dd = new GridData(208, SWT.DEFAULT); GridData dd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
// 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;
// }
//
// }
String[] a = new String[dataSet.size()]; String[] a = new String[dataSet.size()];
dataDispCbo = new Combo(dataOptionsGroup, SWT.DROP_DOWN | SWT.READ_ONLY); dataDispCbo = new Combo(dataOptionsGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
dataDispCbo.setTextLimit(30); dataDispCbo.setTextLimit(30);
@ -499,8 +466,10 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
renderCompLayout.marginHeight = 0; renderCompLayout.marginHeight = 0;
renderCompLayout.marginWidth = 0; renderCompLayout.marginWidth = 0;
renderComp.setLayout(renderCompLayout); 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 = new Button(renderComp, SWT.PUSH);
renderGridsBtn.setText("Render Grids+MAPs"); renderGridsBtn.setText("Render Grids+MAPs");
renderGridsBtn.setLayoutData(gd); 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 = new Button(renderComp, SWT.PUSH);
groupEditBtn.setText("Group Edit"); groupEditBtn.setText("Group Edit");
groupEditBtn.setLayoutData(bd); groupEditBtn.setLayoutData(bd);
groupEditBtn.addSelectionListener(new SelectionAdapter() { groupEditBtn.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
GroupEditStationsDialog groupDialog = new GroupEditStationsDialog( GroupEditStationsDialog groupDialog = new GroupEditStationsDialog(
@ -545,11 +507,13 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
pcpTypeCompLayout.marginHeight = 0; pcpTypeCompLayout.marginHeight = 0;
pcpTypeCompLayout.marginWidth = 0; pcpTypeCompLayout.marginWidth = 0;
pcpTypeComp.setLayout(pcpTypeCompLayout); pcpTypeComp.setLayout(pcpTypeCompLayout);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
pcpTypeComp.setLayoutData(gd);
Label pcpLbl = new Label(pcpTypeComp, SWT.CENTER); Label pcpLbl = new Label(pcpTypeComp, SWT.CENTER);
pcpLbl.setText("Precip Type:"); 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 = new Combo(pcpTypeComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pcpTypeCbo.setTextLimit(30); pcpTypeCbo.setTextLimit(30);
pcpTypeCbo.setLayoutData(gd); pcpTypeCbo.setLayoutData(gd);
@ -570,7 +534,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
*/ */
private void createPointTypeGroup() { private void createPointTypeGroup() {
Group pointTypeGroup = new Group(shell, SWT.NONE); Group pointTypeGroup = new Group(shell, SWT.NONE);
pointTypeGroup.setText(" Point Type "); pointTypeGroup.setText("Point Type");
GridLayout gl = new GridLayout(1, false); GridLayout gl = new GridLayout(1, false);
pointTypeGroup.setLayout(gl); pointTypeGroup.setLayout(gl);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
@ -656,7 +620,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
*/ */
private void createPointQualityGroup() { private void createPointQualityGroup() {
Group pointQualGroup = new Group(shell, SWT.NONE); Group pointQualGroup = new Group(shell, SWT.NONE);
pointQualGroup.setText(" Point Quality "); pointQualGroup.setText("Point Quality");
GridLayout gl = new GridLayout(1, false); GridLayout gl = new GridLayout(1, false);
gl.marginWidth = 0; gl.marginWidth = 0;
pointQualGroup.setLayout(gl); pointQualGroup.setLayout(gl);
@ -752,7 +716,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
private void createPointSetComp() { private void createPointSetComp() {
Composite pntSetComp = new Composite(shell, SWT.NONE); Composite pntSetComp = new Composite(shell, SWT.NONE);
GridLayout pntSetCompGl = new GridLayout(2, false); GridLayout pntSetCompGl = new GridLayout(2, true);
pntSetComp.setLayout(pntSetCompGl); pntSetComp.setLayout(pntSetCompGl);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
pntSetComp.setLayoutData(gd); pntSetComp.setLayoutData(gd);
@ -762,7 +726,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.gage_char[0] = 1; DailyQcUtils.gage_char[0] = 1;
DailyQcUtils.gage_char[1] = 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 = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntCharCbo.setTextLimit(30); pntCharCbo.setTextLimit(30);
pntCharCbo.setLayoutData(gd); pntCharCbo.setLayoutData(gd);
@ -782,6 +746,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.plot_view = 4; DailyQcUtils.plot_view = 4;
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
pntDispCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY); pntDispCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntDispCbo.setTextLimit(30); pntDispCbo.setTextLimit(30);
pntDispCbo.setLayoutData(gd); pntDispCbo.setLayoutData(gd);
@ -811,6 +776,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
i = 2; i = 2;
} }
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
pntScnCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY); pntScnCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntScnCbo.setTextLimit(30); pntScnCbo.setTextLimit(30);
pntScnCbo.setLayoutData(gd); pntScnCbo.setLayoutData(gd);
@ -836,6 +802,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
i = 2; i = 2;
} }
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
pntTConCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY); pntTConCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntTConCbo.setTextLimit(30); pntTConCbo.setTextLimit(30);
pntTConCbo.setLayoutData(gd); pntTConCbo.setLayoutData(gd);
@ -861,6 +828,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
i = 2; i = 2;
} }
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
pntSConCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY); pntSConCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntSConCbo.setTextLimit(30); pntSConCbo.setTextLimit(30);
pntSConCbo.setLayoutData(gd); 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 * Jan 15, 2016 5054 randerso Use proper parent shell
* Feb 22, 2016 18599 snaples Fixed static calls to DailyQCUtils. * 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 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> * </pre>
* *
@ -132,10 +133,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
OtherTempOptions oto = new OtherTempOptions(); OtherTempOptions oto = new OtherTempOptions();
// Tdata[] tdata = new Tdata[0];
// Ts[] ts;
private int time_pos; private int time_pos;
public static Button[] tsbuttons = null; public static Button[] tsbuttons = null;
@ -323,7 +320,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
* Initialize the dialog components. * Initialize the dialog components.
*/ */
private void initializeComponents() { private void initializeComponents() {
// tdata = DailyQcUtils.tdata;
DailyQcUtils.points_flag = 1; DailyQcUtils.points_flag = 1;
DailyQcUtils.grids_flag = -1; DailyQcUtils.grids_flag = -1;
DailyQcUtils.map_flag = -1; DailyQcUtils.map_flag = -1;
@ -337,8 +333,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
int qcDays = MPEDisplayManager.getCurrent().getDqcDays(); int qcDays = MPEDisplayManager.getCurrent().getDqcDays();
// checks to see if area or date has changed since last data load // checks to see if area or date has changed since last data load
dqc_good = dqc.qcDataReload(currDate, QcArea, qcDays, false); dqc_good = dqc.qcDataReload(currDate, QcArea, qcDays, false);
// tdata = DailyQcUtils.tdata;
} }
dataSet.clear(); dataSet.clear();
dataSet.addAll(dataType); dataSet.addAll(dataType);
@ -348,7 +342,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.pcpn_time = 0; DailyQcUtils.pcpn_time = 0;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
if (MPEDisplayManager.pcpn_time_step == 0) { if (MPEDisplayManager.pcpn_time_step == 0) {
time_pos = 150 + DailyQcUtils.pcp_flag; time_pos = 150 + DailyQcUtils.pcp_flag;
} else if (MPEDisplayManager.pcpn_time_step == 1) { } else if (MPEDisplayManager.pcpn_time_step == 1) {
@ -362,7 +355,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
} }
} }
// ts = DailyQcUtils.ts;
this.createDataOptionsGroup(); this.createDataOptionsGroup();
this.createPointTypeGroup(); this.createPointTypeGroup();
this.createPointQualityGroup(); this.createPointQualityGroup();
@ -377,7 +369,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
private void createDataOptionsGroup() { private void createDataOptionsGroup() {
int i = 0; int i = 0;
Group dataOptionsGroup = new Group(shell, SWT.NONE); Group dataOptionsGroup = new Group(shell, SWT.NONE);
dataOptionsGroup.setText(" Data Options "); dataOptionsGroup.setText("Data Options");
GridLayout groupLayout = new GridLayout(1, false); GridLayout groupLayout = new GridLayout(1, false);
dataOptionsGroup.setLayout(groupLayout); dataOptionsGroup.setLayout(groupLayout);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
@ -393,11 +385,13 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
maxmTimeCompLayout.marginHeight = 0; maxmTimeCompLayout.marginHeight = 0;
maxmTimeCompLayout.marginWidth = 0; maxmTimeCompLayout.marginWidth = 0;
maxmTimeComp.setLayout(maxmTimeCompLayout); maxmTimeComp.setLayout(maxmTimeCompLayout);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
maxmTimeComp.setLayoutData(gd);
Label maxmTimeLbl = new Label(maxmTimeComp, SWT.CENTER); Label maxmTimeLbl = new Label(maxmTimeComp, SWT.CENTER);
maxmTimeLbl.setText("6 Hour/MaxMin:"); 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 = new Combo(maxmTimeComp, SWT.DROP_DOWN | SWT.READ_ONLY);
maxminTimeCbo.setTextLimit(30); maxminTimeCbo.setTextLimit(30);
maxminTimeCbo.setLayoutData(sd); maxminTimeCbo.setLayoutData(sd);
@ -424,7 +418,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
RowLayout timeArrowRl = new RowLayout(SWT.HORIZONTAL); RowLayout timeArrowRl = new RowLayout(SWT.HORIZONTAL);
timeArrowsComp.setLayout(timeArrowRl); 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 = new Button(timeArrowsComp, SWT.ARROW | SWT.UP);
upTimeBtn.setLayoutData(rd); upTimeBtn.setLayoutData(rd);
upTimeBtn.setEnabled(false); 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 = new Button(timeArrowsComp, SWT.ARROW | SWT.DOWN);
dnTimeBtn.setLayoutData(rd); dnTimeBtn.setLayoutData(rd);
dnTimeBtn.setEnabled(false); 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()]; String[] a = new String[dataSet.size()];
dataDispCbo = new Combo(dataOptionsGroup, SWT.DROP_DOWN | SWT.READ_ONLY); dataDispCbo = new Combo(dataOptionsGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
@ -471,8 +465,10 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
renderCompLayout.marginHeight = 0; renderCompLayout.marginHeight = 0;
renderCompLayout.marginWidth = 0; renderCompLayout.marginWidth = 0;
renderComp.setLayout(renderCompLayout); 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 = new Button(renderComp, SWT.PUSH);
renderGridsBtn.setText("Render Grids+MATs"); renderGridsBtn.setText("Render Grids+MATs");
renderGridsBtn.setLayoutData(gd); 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 = new Button(renderComp, SWT.PUSH);
groupEditBtn.setText("Group Edit"); groupEditBtn.setText("Group Edit");
groupEditBtn.setLayoutData(bd); groupEditBtn.setLayoutData(bd);
groupEditBtn.addSelectionListener(new SelectionAdapter() { groupEditBtn.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
GroupEditStationsDialog groupDialog = new GroupEditStationsDialog( GroupEditStationsDialog groupDialog = new GroupEditStationsDialog(
@ -518,7 +507,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
*/ */
private void createPointTypeGroup() { private void createPointTypeGroup() {
Group pointTypeGroup = new Group(shell, SWT.NONE); Group pointTypeGroup = new Group(shell, SWT.NONE);
pointTypeGroup.setText(" Point Type "); pointTypeGroup.setText("Point Type");
GridLayout gl = new GridLayout(1, false); GridLayout gl = new GridLayout(1, false);
pointTypeGroup.setLayout(gl); pointTypeGroup.setLayout(gl);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
@ -604,7 +593,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
*/ */
private void createPointQualityGroup() { private void createPointQualityGroup() {
Group pointQualGroup = new Group(shell, SWT.NONE); Group pointQualGroup = new Group(shell, SWT.NONE);
pointQualGroup.setText(" Point Quality "); pointQualGroup.setText("Point Quality");
GridLayout gl = new GridLayout(1, false); GridLayout gl = new GridLayout(1, false);
gl.marginWidth = 0; gl.marginWidth = 0;
pointQualGroup.setLayout(gl); pointQualGroup.setLayout(gl);
@ -612,14 +601,11 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
pointQualGroup.setLayoutData(gd); pointQualGroup.setLayoutData(gd);
int i; int i;
// int qflag[] = dqc.qflag;
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
DailyQcUtils.qflag[i] = 1; DailyQcUtils.qflag[i] = 1;
} }
// qflag[5] = -1;
boolean mpe_show_missing_gage_set = false; boolean mpe_show_missing_gage_set = false;
if (dqc.mpe_show_missing_gage.length() > 0) { if (dqc.mpe_show_missing_gage.length() > 0) {
if ((dqc.mpe_show_missing_gage.equalsIgnoreCase("All")) if ((dqc.mpe_show_missing_gage.equalsIgnoreCase("All"))
@ -664,7 +650,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
"Questionable", "Partial", "Estimated", "Bad", "Missing", "All" }; "Questionable", "Partial", "Estimated", "Bad", "Missing", "All" };
for (i = 0; i < qsbuttons.length / 2; i++) { for (i = 0; i < qsbuttons.length / 2; i++) {
final Button b = new Button(ltCkBxComp, SWT.CHECK); final Button b = new Button(ltCkBxComp, SWT.CHECK);
b.setText(qbnames[i]); b.setText(qbnames[i]);
b.setData(i); b.setData(i);
@ -690,7 +675,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
qsbuttons[5].setEnabled(false); qsbuttons[5].setEnabled(false);
} }
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
if (i == 5) { if (i == 5) {
continue; continue;
} }
@ -704,7 +688,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
private void createPointSetComp() { private void createPointSetComp() {
Composite pntSetComp = new Composite(shell, SWT.NONE); Composite pntSetComp = new Composite(shell, SWT.NONE);
GridLayout pntSetCompGl = new GridLayout(2, false); GridLayout pntSetCompGl = new GridLayout(2, true);
pntSetComp.setLayout(pntSetCompGl); pntSetComp.setLayout(pntSetCompGl);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
pntSetComp.setLayoutData(gd); pntSetComp.setLayoutData(gd);
@ -714,6 +698,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.plot_view = 4; DailyQcUtils.plot_view = 4;
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
pntDispCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY); pntDispCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntDispCbo.setTextLimit(30); pntDispCbo.setTextLimit(30);
pntDispCbo.setLayoutData(gd); pntDispCbo.setLayoutData(gd);
@ -744,6 +729,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
i = 2; i = 2;
} }
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
pntScnCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY); pntScnCbo = new Combo(pntSetComp, SWT.DROP_DOWN | SWT.READ_ONLY);
pntScnCbo.setTextLimit(30); pntScnCbo.setTextLimit(30);
pntScnCbo.setLayoutData(gd); pntScnCbo.setLayoutData(gd);
@ -757,7 +743,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
} }
}); });
pntScnCbo.select(i); pntScnCbo.select(i);
} }
private void createPointControlComp() { private void createPointControlComp() {
@ -800,7 +785,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
public void mouseUp(MouseEvent e) { public void mouseUp(MouseEvent e) {
opo.refresh_exposure(); opo.refresh_exposure();
} }
}); });
pfvalueLabel pfvalueLabel
.setText(String.format("%3d", pntFilter.getSelection() - 50)); .setText(String.format("%3d", pntFilter.getSelection() - 50));
@ -881,7 +865,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
DailyQcUtils.elevation_filter_value = sel; DailyQcUtils.elevation_filter_value = sel;
opo.refresh_exposure(); opo.refresh_exposure();
} }
}); });
pevalueLabel.setText(String.format("%d", pntElFilter.getSelection())); pevalueLabel.setText(String.format("%d", pntElFilter.getSelection()));
@ -898,7 +881,6 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
opo.send_expose(); opo.send_expose();
OtherTempOptions oto = new OtherTempOptions(); OtherTempOptions oto = new OtherTempOptions();
oto.set_temp_arrow_sensitivity(); oto.set_temp_arrow_sensitivity();
} }
public static float getPointFilterValue() { public static float getPointFilterValue() {

View file

@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; 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.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; 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.graphics.Rectangle;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; 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.Rwradarresult;
import com.raytheon.uf.common.dataplugin.shef.tables.DAARadarResult; import com.raytheon.uf.common.dataplugin.shef.tables.DAARadarResult;
import com.raytheon.uf.common.ohd.AppsDefaults; 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.uf.viz.core.exception.VizException;
import com.raytheon.viz.hydrocommon.whfslib.IHFSDbGenerated; import com.raytheon.viz.hydrocommon.whfslib.IHFSDbGenerated;
import com.raytheon.viz.mpe.core.MPEDataManager; import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.core.MPEDataManager.MPERadarData; import com.raytheon.viz.mpe.core.MPEDataManager.MPERadarData;
import com.raytheon.viz.mpe.core.MPEDataManager.MPERadarData.RadarAvailability; import com.raytheon.viz.mpe.core.MPEDataManager.MPERadarData.RadarAvailability;
import com.raytheon.viz.mpe.ui.MPEDisplayManager; import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.dialogs.gagetable.GageTableDataManager;
import com.raytheon.viz.mpe.ui.radartable.ReadBiasTableParam; 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 8, 2014 DCS167 cgobs Updated Dialog for DualPol features
* May 23, 2014 DCS167 cgobs Resolved merge conflict * May 23, 2014 DCS167 cgobs Resolved merge conflict
* Jul 29, 2015 17471 snaples Added logging for radar result table query date value. * 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> * </pre>
* *
@ -87,6 +91,9 @@ import com.raytheon.viz.mpe.ui.radartable.ReadBiasTableParam;
public class RadarBiasTableDialog extends Dialog { public class RadarBiasTableDialog extends Dialog {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(getClass());
public static class Zerocoef_Data { public static class Zerocoef_Data {
float mlt_zrcoef; float mlt_zrcoef;
@ -97,8 +104,6 @@ public class RadarBiasTableDialog extends Dialog {
private Shell shell; private Shell shell;
private Font font;
private Button applyBtn; private Button applyBtn;
private Button closeBtn; private Button closeBtn;
@ -107,7 +112,7 @@ public class RadarBiasTableDialog extends Dialog {
private final int retval = 0; private final int retval = 0;
String[] radIds; private final String[] radIds;
String rid = ""; String rid = "";
@ -192,8 +197,9 @@ public class RadarBiasTableDialog extends Dialog {
float[] editedDPBiasValue = new float[60]; float[] editedDPBiasValue = new float[60];
public RadarBiasTableDialog(Shell parentShell) { public RadarBiasTableDialog(Shell parentShell, final String[] radIds) {
super(parentShell); super(parentShell);
this.radIds = radIds;
} }
/** /**
@ -210,12 +216,10 @@ public class RadarBiasTableDialog extends Dialog {
// Create the main layout for the shell. // Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, true); GridLayout mainLayout = new GridLayout(1, true);
mainLayout.marginHeight = 1; mainLayout.marginHeight = 0;
mainLayout.marginWidth = 1; mainLayout.marginWidth = 0;
shell.setLayout(mainLayout); shell.setLayout(mainLayout);
font = new Font(shell.getDisplay(), "Courier", 10, SWT.NORMAL);
// Initialize all of the controls and layouts // Initialize all of the controls and layouts
initializeComponents(); initializeComponents();
@ -228,8 +232,6 @@ public class RadarBiasTableDialog extends Dialog {
} }
} }
font.dispose();
return retval; return retval;
} }
@ -237,12 +239,6 @@ public class RadarBiasTableDialog extends Dialog {
* Initialize the dialog components. * Initialize the dialog components.
*/ */
private void initializeComponents() { private void initializeComponents() {
try {
radIds = GageTableDataManager.getInstance().getActiveRadarIds();
} catch (VizException e) {
e.printStackTrace();
}
String fxa_local_site = appsDefaults.getToken("fxa_local_site"); String fxa_local_site = appsDefaults.getToken("fxa_local_site");
String where = "WHERE office_id = '" + fxa_local_site + "'"; String where = "WHERE office_id = '" + fxa_local_site + "'";
bList = IHFSDbGenerated.GetRWBiasstat(where); bList = IHFSDbGenerated.GetRWBiasstat(where);
@ -266,20 +262,15 @@ public class RadarBiasTableDialog extends Dialog {
applyBtnComp.setLayout(applyBtnCompLayout); applyBtnComp.setLayout(applyBtnCompLayout);
applyBtnComp.setLayoutData(gd); 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 = new Button(applyBtnComp, SWT.PUSH);
applyBtn.setText("Apply"); applyBtn.setText("Apply");
applyBtn.setLayoutData(bd); applyBtn.setLayoutData(bd);
applyBtn.setEnabled(false); applyBtn.setEnabled(false);
applyBtn.addSelectionListener(new SelectionAdapter() { applyBtn.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
applyBiasUpdate(dt); 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 = new Button(applyBtnComp, SWT.PUSH);
closeBtn.setText("Close"); closeBtn.setText("Close");
closeBtn.setLayoutData(bd); closeBtn.setLayoutData(bd);
closeBtn.addSelectionListener(new SelectionAdapter() { closeBtn.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
shell.dispose(); shell.dispose();
@ -310,7 +294,6 @@ public class RadarBiasTableDialog extends Dialog {
} }
private void createDateComp() { private void createDateComp() {
GridData bd = new GridData(SWT.LEFT, SWT.CENTER, true, true); GridData bd = new GridData(SWT.LEFT, SWT.CENTER, true, true);
Composite dtLblComp = new Composite(shell, SWT.NONE); Composite dtLblComp = new Composite(shell, SWT.NONE);
GridLayout dtLblCompLayout = new GridLayout(1, false); 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); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
bcLblComp = new Composite(shell, SWT.NONE); bcLblComp = new Composite(shell, SWT.NONE);
GridLayout bcLblCompLayout = new GridLayout(9, true); GridLayout bcLblCompLayout = new GridLayout(9, true);
bcLblCompLayout.marginWidth = 1;
bcLblComp.setLayout(bcLblCompLayout); bcLblComp.setLayout(bcLblCompLayout);
bcLblComp.setLayoutData(gd); bcLblComp.setLayoutData(gd);
for (int i = 0; i < biasLabelStrings.length; i++) { for (int i = 0; i < biasLabelStrings.length; i++) {
@ -347,23 +329,19 @@ public class RadarBiasTableDialog extends Dialog {
* Create the data options group and controls. * Create the data options group and controls.
*/ */
private void createBiasListComp() { private void createBiasListComp() {
final ScrolledComposite biasListScrollComp = new ScrolledComposite( final ScrolledComposite biasListScrollComp = new ScrolledComposite(
shell, SWT.BORDER | SWT.V_SCROLL); 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. // 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, final Composite biasListComp = new Composite(biasListScrollComp,
SWT.BORDER); SWT.BORDER);
// dual pol version of table has 9 columns; previous table had 7 columns // 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); biasListComp.setLayout(biasListCompLayout);
gd.horizontalSpan = 9; GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, true);
gd.horizontalSpan = numColumns;
biasListComp.setLayoutData(gd); biasListComp.setLayoutData(gd);
biasListComp biasListComp
.setSize(biasListComp.computeSize(SWT.DEFAULT, SWT.DEFAULT)); .setSize(biasListComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
@ -371,9 +349,11 @@ public class RadarBiasTableDialog extends Dialog {
Date dt3 = MPEDisplayManager.getCurrent().getCurrentEditDate(); Date dt3 = MPEDisplayManager.getCurrent().getCurrentEditDate();
dt = pgsdf.format(dt3); dt = pgsdf.format(dt3);
// This lets us know what date is being requested from radar result /*
// tables * This lets us know what date is being requested from radar result
System.out.println("Radar Bias table query using time: " + dt3); * tables
*/
statusHandler.debug("Radar Bias table query using time: " + dt3);
radarIdToSPDataMap = MPEDataManager.getInstance().readSPRadarData(dt3); radarIdToSPDataMap = MPEDataManager.getInstance().readSPRadarData(dt3);
radarIdToDPDataMap = MPEDataManager.getInstance().readDPRadarData(dt3); radarIdToDPDataMap = MPEDataManager.getInstance().readDPRadarData(dt3);
@ -384,10 +364,28 @@ public class RadarBiasTableDialog extends Dialog {
spManEditButtonArray = new Button[radIds.length]; spManEditButtonArray = new Button[radIds.length];
dpManEditButtonArray = 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++) { for (int i = 0; i < radIds.length; i++) {
// get A and B coefficients from SP radar (does not apply to DP ) // get A and B coefficients from SP radar (does not apply to DP )
abzerocoef.mlt_zrcoef = 0.0f; abzerocoef.mlt_zrcoef = 0.0f;
abzerocoef.pwr_zrcoef = 0.0f; abzerocoef.pwr_zrcoef = 0.0f;
@ -412,7 +410,9 @@ public class RadarBiasTableDialog extends Dialog {
try { try {
dpaz = ReadBiasTableParam.getDpaadaptcoef(rid, dt); dpaz = ReadBiasTableParam.getDpaadaptcoef(rid, dt);
} catch (VizException e1) { } 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) { if (dpaz.length != 0) {
abzerocoef.mlt_zrcoef = dpaz[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 // radar id button
final Button ridBtn = new Button(biasListComp, SWT.PUSH); final Button ridBtn = new Button(biasListComp, SWT.PUSH);
@ -431,14 +431,6 @@ public class RadarBiasTableDialog extends Dialog {
ridBtn.setLayoutData(gd); ridBtn.setLayoutData(gd);
ridBtn.addSelectionListener(new SelectionAdapter() { ridBtn.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org
* .eclipse .swt.events.SelectionEvent)
*/
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
RadarSpanDialog rsd = new RadarSpanDialog(shell, RadarSpanDialog rsd = new RadarSpanDialog(shell,
@ -477,7 +469,6 @@ public class RadarBiasTableDialog extends Dialog {
lbiasSPTxt.setData(i); lbiasSPTxt.setData(i);
lbiasSPTxt.addModifyListener(new ModifyListener() { lbiasSPTxt.addModifyListener(new ModifyListener() {
@Override @Override
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
final int ei = (Integer) lbiasSPTxt.getData(); final int ei = (Integer) lbiasSPTxt.getData();
@ -485,7 +476,6 @@ public class RadarBiasTableDialog extends Dialog {
float parsedFloat = Float.parseFloat(lbiasSPTxt float parsedFloat = Float.parseFloat(lbiasSPTxt
.getText()); .getText());
editedSPBiasValue[ei] = parsedFloat; editedSPBiasValue[ei] = parsedFloat;
// spManEditButtonArray[ei].setSelection(!mbiasSPBtn.getSelection());
spManEditButtonArray[ei].setText("YES"); spManEditButtonArray[ei].setText("YES");
lbiasSPTxt.setBackground(getParent().getDisplay() lbiasSPTxt.setBackground(getParent().getDisplay()
.getSystemColor(SWT.COLOR_WHITE)); .getSystemColor(SWT.COLOR_WHITE));
@ -516,7 +506,6 @@ public class RadarBiasTableDialog extends Dialog {
// ------------------------------------------------------------- // -------------------------------------------------------------
lbiasDPTxt.addModifyListener(new ModifyListener() { lbiasDPTxt.addModifyListener(new ModifyListener() {
@Override @Override
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
final int ei = (Integer) lbiasDPTxt.getData(); final int ei = (Integer) lbiasDPTxt.getData();
@ -524,7 +513,6 @@ public class RadarBiasTableDialog extends Dialog {
float parsedFloat = Float.parseFloat(lbiasDPTxt float parsedFloat = Float.parseFloat(lbiasDPTxt
.getText()); .getText());
editedDPBiasValue[ei] = parsedFloat; editedDPBiasValue[ei] = parsedFloat;
// dpManEditButtonArray[ei].setSelection(!mbiasDPBtn.getSelection());
dpManEditButtonArray[ei].setText("YES"); dpManEditButtonArray[ei].setText("YES");
lbiasDPTxt.setBackground(getParent().getDisplay() lbiasDPTxt.setBackground(getParent().getDisplay()
.getSystemColor(SWT.COLOR_WHITE)); .getSystemColor(SWT.COLOR_WHITE));
@ -534,7 +522,6 @@ public class RadarBiasTableDialog extends Dialog {
lbiasDPTxt.setBackground(getParent().getDisplay() lbiasDPTxt.setBackground(getParent().getDisplay()
.getSystemColor(SWT.COLOR_RED)); .getSystemColor(SWT.COLOR_RED));
applyBtn.setEnabled(false); applyBtn.setEnabled(false);
} }
} }
}); });
@ -551,12 +538,6 @@ public class RadarBiasTableDialog extends Dialog {
spManEditButtonArray[i] = mbiasSPBtn; spManEditButtonArray[i] = mbiasSPBtn;
mbiasSPBtn.addSelectionListener(new SelectionAdapter() { mbiasSPBtn.addSelectionListener(new SelectionAdapter() {
/**
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
final int ai = (Integer) mbiasSPBtn.getData(); final int ai = (Integer) mbiasSPBtn.getData();
@ -583,12 +564,6 @@ public class RadarBiasTableDialog extends Dialog {
dpManEditButtonArray[i] = mbiasDPBtn; dpManEditButtonArray[i] = mbiasDPBtn;
mbiasDPBtn.addSelectionListener(new SelectionAdapter() { mbiasDPBtn.addSelectionListener(new SelectionAdapter() {
/**
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
final int ai = (Integer) mbiasDPBtn.getData(); final int ai = (Integer) mbiasDPBtn.getData();
@ -597,8 +572,6 @@ public class RadarBiasTableDialog extends Dialog {
editedDPBiasValue[ai] = oldDPBiasValue[ai]; editedDPBiasValue[ai] = oldDPBiasValue[ai];
dpBiasValueTextArray[ai].setText(String.format( dpBiasValueTextArray[ai].setText(String.format(
"%-1.2f", editedDPBiasValue[ai])); "%-1.2f", editedDPBiasValue[ai]));
// consider replacing the value in the map instead of
// using put()
dpBiasChangeMap.put(radIds[ai], ai); dpBiasChangeMap.put(radIds[ai], ai);
applyBtn.setEnabled(false); applyBtn.setEnabled(false);
dpManEditButtonArray[ai].setText("NO"); dpManEditButtonArray[ai].setText("NO");
@ -653,8 +626,31 @@ public class RadarBiasTableDialog extends Dialog {
Label offcLbl = new Label(biasListComp, SWT.CENTER); Label offcLbl = new Label(biasListComp, SWT.CENTER);
offcLbl.setText(ooffice); offcLbl.setText(ooffice);
offcLbl.setLayoutData(gd); 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); 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.setExpandVertical(true);
biasListScrollComp.setExpandHorizontal(true); biasListScrollComp.setExpandHorizontal(true);
biasListScrollComp.addControlListener(new ControlAdapter() { biasListScrollComp.addControlListener(new ControlAdapter() {
@ -664,6 +660,19 @@ public class RadarBiasTableDialog extends Dialog {
SWT.DEFAULT)); 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) { private void applyBiasUpdate(String obstime) {
@ -674,15 +683,14 @@ public class RadarBiasTableDialog extends Dialog {
private void applySPBiasUpdate(String obstime) { private void applySPBiasUpdate(String obstime) {
String where = ""; String where = "";
final float memspan = -99.0f; final float memspan = -99.0f;
ArrayList<Rwradarresult> rwRadarResultList = new ArrayList<Rwradarresult>(); List<Rwradarresult> rwRadarResultList = new ArrayList<>();
Rwradarresult rwRadarResult = new Rwradarresult(); Rwradarresult rwRadarResult = new Rwradarresult();
Iterator<String> bi = spBiasChangeMap.keySet().iterator(); Iterator<String> bi = spBiasChangeMap.keySet().iterator();
while (bi.hasNext()) { while (bi.hasNext()) {
String rid = bi.next(); String rid = bi.next();
where = String.format("WHERE radid='%s' AND obstime='%s'", rid, where = String.format("WHERE radid='%s' AND obstime='%s'", rid,
obstime); obstime);
rwRadarResultList = (ArrayList<Rwradarresult>) IHFSDbGenerated rwRadarResultList = IHFSDbGenerated.GetRWRadarResult(where);
.GetRWRadarResult(where);
if (rwRadarResultList.size() != 0) { if (rwRadarResultList.size() != 0) {
rwRadarResult = rwRadarResultList.get(0); rwRadarResult = rwRadarResultList.get(0);
} else { } else {
@ -701,7 +709,6 @@ public class RadarBiasTableDialog extends Dialog {
IHFSDbGenerated.UpdateRWRadarResult(rwRadarResult); IHFSDbGenerated.UpdateRWRadarResult(rwRadarResult);
} }
spBiasChangeMap.clear(); spBiasChangeMap.clear();
return;
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
@ -709,15 +716,14 @@ public class RadarBiasTableDialog extends Dialog {
private void applyDPBiasUpdate(String obstime) { private void applyDPBiasUpdate(String obstime) {
String where = ""; String where = "";
final float memspan = -99.0f; final float memspan = -99.0f;
ArrayList<DAARadarResult> daaRadarResultList = new ArrayList<DAARadarResult>(); List<DAARadarResult> daaRadarResultList = new ArrayList<>();
DAARadarResult daaRadarResult = new DAARadarResult(); DAARadarResult daaRadarResult = new DAARadarResult();
Iterator<String> bi = dpBiasChangeMap.keySet().iterator(); Iterator<String> bi = dpBiasChangeMap.keySet().iterator();
while (bi.hasNext()) { while (bi.hasNext()) {
String rid = bi.next(); String rid = bi.next();
where = String.format("WHERE radid='%s' AND obstime='%s'", rid, where = String.format("WHERE radid='%s' AND obstime='%s'", rid,
obstime); obstime);
daaRadarResultList = (ArrayList<DAARadarResult>) IHFSDbGenerated daaRadarResultList = IHFSDbGenerated.GetDAARadarResult(where);
.GetDAARadarResult(where);
if (daaRadarResultList.size() != 0) { if (daaRadarResultList.size() != 0) {
daaRadarResult = daaRadarResultList.get(0); daaRadarResult = daaRadarResultList.get(0);
} else { } else {
@ -736,7 +742,6 @@ public class RadarBiasTableDialog extends Dialog {
IHFSDbGenerated.UpdateDAARadarResult(daaRadarResult); IHFSDbGenerated.UpdateDAARadarResult(daaRadarResult);
} }
dpBiasChangeMap.clear(); dpBiasChangeMap.clear();
return;
} }
} }

View file

@ -20,22 +20,25 @@
package com.raytheon.viz.mpe.ui.dialogs.polygon; package com.raytheon.viz.mpe.ui.dialogs.polygon;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell; 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.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager; import com.raytheon.viz.mpe.ui.MPEDisplayManager;
@ -58,6 +61,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* the "sub" action. * the "sub" action.
* Jan 7, 2015 16954 cgobs Fix for cv_use issue - using getFieldName() in certain parts. * 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. * 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> * </pre>
* *
* @author mpduff * @author mpduff
@ -65,29 +69,64 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
*/ */
public class DeletePolygonDlg extends 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. * Polygon list.
*/ */
private java.util.List<RubberPolyData> polygonList = new ArrayList<RubberPolyData>(); private List<RubberPolyData> polygonList = Collections.emptyList();
/** /**
* Simple date formatter. * Simple date formatter.
@ -109,8 +148,8 @@ public class DeletePolygonDlg extends CaveSWTDialog {
@Override @Override
protected Layout constructShellLayout() { protected Layout constructShellLayout() {
GridLayout mainLayout = new GridLayout(1, true); GridLayout mainLayout = new GridLayout(1, true);
mainLayout.marginHeight = 1; mainLayout.marginHeight = 0;
mainLayout.marginWidth = 1; mainLayout.marginWidth = 0;
return mainLayout; return mainLayout;
} }
@ -119,7 +158,7 @@ public class DeletePolygonDlg extends CaveSWTDialog {
setReturnValue(false); setReturnValue(false);
Composite comp = createMainComposite(); Composite comp = createMainComposite();
createDateTimeProduct(comp); createDateTimeProduct(comp);
createPolygonList(comp); createPolygonTable(comp);
createPolygonButtons(comp); createPolygonButtons(comp);
createCloseButton(comp); createCloseButton(comp);
populateDlg(); populateDlg();
@ -132,8 +171,8 @@ public class DeletePolygonDlg extends CaveSWTDialog {
*/ */
private Composite createMainComposite() { private Composite createMainComposite() {
Composite comp = new Composite(shell, SWT.NONE); Composite comp = new Composite(shell, SWT.NONE);
comp.setLayout(new GridLayout(2, true)); comp.setLayout(new GridLayout(1, false));
GridData gd = new GridData(500, SWT.DEFAULT); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
comp.setLayoutData(gd); comp.setLayoutData(gd);
return comp; return comp;
@ -147,25 +186,46 @@ public class DeletePolygonDlg extends CaveSWTDialog {
*/ */
private void createDateTimeProduct(Composite comp) { private void createDateTimeProduct(Composite comp) {
// Create adjust group // Create adjust group
Composite dateTimeComp = new Composite(comp, SWT.NONE); Composite headerComp = new Composite(comp, SWT.NONE);
dateTimeComp.setLayout(new GridLayout(2, false)); 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); Composite dateTimeComp = new Composite(headerComp, SWT.NONE);
dateTimeLbl.setText("Date/Time: "); 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); gd = new GridData(SWT.DEFAULT, SWT.CENTER, false, false);
dateTimeTF = new Text(dateTimeComp, SWT.BORDER); Label dtLbl = new Label(dateTimeComp, SWT.NONE);
dateTimeTF.setLayoutData(gd); dtLbl.setLayoutData(gd);
dtLbl.setText("Date/Time:");
dtLbl.setLayoutData(gd);
Composite productComp = new Composite(comp, SWT.NONE); gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
productComp.setLayout(new GridLayout(2, 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); 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); gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
productTF = new Text(productComp, SWT.BORDER); productLbl = new Label(productComp, SWT.BORDER);
productTF.setLayoutData(gd); productLbl.setLayoutData(gd);
} }
/** /**
@ -174,21 +234,35 @@ public class DeletePolygonDlg extends CaveSWTDialog {
* @param comp * @param comp
* The main composite * The main composite
*/ */
private void createPolygonList(Composite comp) { private void createPolygonTable(Composite comp) {
Composite dataComp = new Composite(comp, SWT.NONE); table = new Table(comp, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
dataComp.setLayout(new GridLayout(1, true)); table.setHeaderVisible(true);
GridData gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false, 2, 1); table.setLinesVisible(true);
dataComp.setLayoutData(gd); 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 for (MPE_TABLE_COLUMNS mpeTableColumn : MPE_TABLE_COLUMNS.values()) {
| SWT.V_SCROLL); TableColumn tc = new TableColumn(table, SWT.CENTER);
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, true); tc.setText(mpeTableColumn.getText());
gd.widthHint = 480; tc.setWidth(gc.getFontMetrics().getAverageCharWidth()
gd.heightHint = 150; * mpeTableColumn.getNumCharacters());
polygonListBox.setLayoutData(gd); }
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) { private void createPolygonButtons(Composite comp) {
Composite buttonComp = new Composite(comp, SWT.NONE); Composite buttonComp = new Composite(comp, SWT.NONE);
buttonComp.setLayout(new GridLayout(4, false)); buttonComp.setLayout(new GridLayout(4, true));
GridData gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2, 1); GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false);
buttonComp.setLayoutData(gd); 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"); displayBtn.setText("Display");
gd = new GridData(116, SWT.DEFAULT); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
displayBtn.setAlignment(SWT.CENTER); gd.minimumWidth = minimumButtonWidth;
displayBtn.setLayoutData(gd); displayBtn.setLayoutData(gd);
displayBtn.addSelectionListener(new SelectionAdapter() { displayBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent event) { 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"); undisplayBtn.setText("Undisplay");
gd = new GridData(116, SWT.DEFAULT); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
undisplayBtn.setAlignment(SWT.CENTER); gd.minimumWidth = minimumButtonWidth;
undisplayBtn.setLayoutData(gd); undisplayBtn.setLayoutData(gd);
undisplayBtn.addSelectionListener(new SelectionAdapter() { undisplayBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent event) { 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"); deleteBtn.setText("Delete");
gd = new GridData(116, SWT.DEFAULT); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
deleteBtn.setAlignment(SWT.CENTER); gd.minimumWidth = minimumButtonWidth;
deleteBtn.setLayoutData(gd); deleteBtn.setLayoutData(gd);
deleteBtn.addSelectionListener(new SelectionAdapter() { deleteBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
@ -238,11 +316,12 @@ public class DeletePolygonDlg extends CaveSWTDialog {
delete(); delete();
} }
}); });
deleteBtn.setEnabled(false);
Button deleteAllBtn = new Button(buttonComp, SWT.PUSH); deleteAllBtn = new Button(buttonComp, SWT.PUSH);
deleteAllBtn.setText("Delete All"); deleteAllBtn.setText("Delete All");
gd = new GridData(116, SWT.DEFAULT); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
deleteAllBtn.setAlignment(SWT.CENTER); gd.minimumWidth = minimumButtonWidth;
deleteAllBtn.setLayoutData(gd); deleteAllBtn.setLayoutData(gd);
deleteAllBtn.addSelectionListener(new SelectionAdapter() { deleteAllBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
@ -250,6 +329,7 @@ public class DeletePolygonDlg extends CaveSWTDialog {
deleteAll(); deleteAll();
} }
}); });
deleteAllBtn.setEnabled(false);
} }
/** /**
@ -257,15 +337,14 @@ public class DeletePolygonDlg extends CaveSWTDialog {
*/ */
private void createCloseButton(Composite comp) { private void createCloseButton(Composite comp) {
// Add separator // 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); Label sepLbl = new Label(comp, SWT.SEPARATOR | SWT.HORIZONTAL);
gd.widthHint = 480;
sepLbl.setLayoutData(gd); sepLbl.setLayoutData(gd);
Button closeBtn = new Button(comp, SWT.PUSH); Button closeBtn = new Button(comp, SWT.PUSH);
closeBtn.setText("Close"); closeBtn.setText("Close");
gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false, 2, 1); gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.widthHint = 90; gd.minimumWidth = closeBtn.getDisplay().getDPI().x;
closeBtn.setAlignment(SWT.CENTER); closeBtn.setAlignment(SWT.CENTER);
closeBtn.setLayoutData(gd); closeBtn.setLayoutData(gd);
closeBtn.addSelectionListener(new SelectionAdapter() { closeBtn.addSelectionListener(new SelectionAdapter() {
@ -283,75 +362,70 @@ public class DeletePolygonDlg extends CaveSWTDialog {
MPEDisplayManager displayManager = MPEDisplayManager.getCurrent(); MPEDisplayManager displayManager = MPEDisplayManager.getCurrent();
Date editDate = displayManager.getCurrentEditDate(); Date editDate = displayManager.getCurrentEditDate();
DisplayFieldData fieldData = displayManager.getDisplayFieldType(); DisplayFieldData fieldData = displayManager.getDisplayFieldType();
dateTimeTF.setText(sdf.format(editDate)); dateTimeLbl.setText(sdf.format(editDate));
polygonListBox.removeAll();
String type = displayManager.getDisplayFieldType().getFieldName(); String type = displayManager.getDisplayFieldType().getFieldName();
productLbl.setText(type);
productTF.setText(type);
polygonList = PolygonEditManager.getPolygonEdits(fieldData, editDate); polygonList = PolygonEditManager.getPolygonEdits(fieldData, editDate);
recreatePolygonListBox(); populatePolygonTable();
} }
/** private void populatePolygonTable() {
* Recreates the polygonListBox based on polygonList field table.removeAll();
*/
private void recreatePolygonListBox() { if (polygonList.isEmpty()) {
int[] selected = polygonListBox.getSelectionIndices(); displayBtn.setEnabled(false);
polygonListBox.removeAll(); undisplayBtn.setEnabled(false);
deleteBtn.setEnabled(false);
deleteAllBtn.setEnabled(false);
return;
}
for (int i = 0; i < polygonList.size(); i++) { for (int i = 0; i < polygonList.size(); i++) {
RubberPolyData data = polygonList.get(i); RubberPolyData data = polygonList.get(i);
String number = String.valueOf(i + 1); final PolygonEditAction action = data.getEditAction();
String displayed = "F";
if (data.isVisible()) {
displayed = "T";
}
String persist = "F"; final String number = String.valueOf(i + 1);
if (data.isPersistent()) { final String displayed = data.isVisible() ? POLY_TRUE : POLY_FALSE;
persist = "T"; 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(); TableItem ti = new TableItem(table, SWT.NONE);
if (action == PolygonEditAction.SUB) { ti.setData(data);
String value = data.getSubDrawSource().getFieldName(); final String[] tableItemValues = new String[] { number, displayed,
polygonListBox.add(String.format(format2, number, displayed, persist, action.toPrettyName(), value };
persist, action.toPrettyName(), value)); ti.setText(tableItemValues);
} else {
double value = data.getPrecipValue();
polygonListBox.add(String.format(format, number, displayed,
persist, action.toPrettyName(), value));
}
} }
int numGood = 0; deleteAllBtn.setEnabled(true);
for (int idx : selected) { }
if (idx >= 0 && idx < polygonListBox.getItemCount()) {
numGood += 1; 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; RubberPolyData data = (RubberPolyData) table.getSelection()[0]
for (int idx : selected) { .getData();
if (idx >= 0 && idx < polygonListBox.getItemCount()) { final boolean visible = data.isVisible();
newSelected[i++] = idx; this.displayBtn.setEnabled(!visible);
} this.undisplayBtn.setEnabled(visible);
} this.deleteBtn.setEnabled(true);
polygonListBox.select(newSelected);
} }
/** /**
* Delete the selected polygon. * Delete the selected polygon.
*/ */
private void delete() { private void delete() {
// Make sure a selection has been made.
if (polygonListBox.getSelectionIndex() < 0) {
return;
}
// Remove selected from list and apply // Remove selected from list and apply
RubberPolyData polygon = polygonList.remove(polygonListBox RubberPolyData data = (RubberPolyData) table.getSelection()[0]
.getSelectionIndex()); .getData();
applyPolygonList(polygon.isPersistent()); polygonList.remove(data);
applyPolygonList(data.isPersistent(), true);
} }
/** /**
@ -367,7 +441,7 @@ public class DeletePolygonDlg extends CaveSWTDialog {
} }
} }
polygonList.clear(); polygonList.clear();
applyPolygonList(persistentRemoved); applyPolygonList(persistentRemoved, true);
} }
/** /**
@ -379,21 +453,27 @@ public class DeletePolygonDlg extends CaveSWTDialog {
* @param polygon * @param polygon
* The polygon to display/undisplay * The polygon to display/undisplay
*/ */
private void display(boolean display, int polygon) { private void display(boolean display) {
if (polygon >= 0 && polygon < polygonList.size()) { TableItem tableItem = table.getSelection()[0];
RubberPolyData data = polygonList.get(polygon); RubberPolyData data = (RubberPolyData) tableItem.getData();
data.setVisible(display); data.setVisible(display);
applyPolygonList(false); 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(); MPEDisplayManager displayManager = MPEDisplayManager.getCurrent();
DisplayFieldData fieldData = displayManager.getDisplayFieldType(); DisplayFieldData fieldData = displayManager.getDisplayFieldType();
Date editDate = displayManager.getCurrentEditDate(); Date editDate = displayManager.getCurrentEditDate();
PolygonEditManager.writePolygonEdits(fieldData, editDate, polygonList, PolygonEditManager.writePolygonEdits(fieldData, editDate, polygonList,
persistentRemoved); 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.events.SelectionEvent;
import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Scale; import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Shell; 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. * 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 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. * Feb 15, 2016 5338 bkowal Remove commented code. Cleanup.
* Apr 07, 2016 5504 bkowal Fix GUI sizing issues.
* *
* </pre> * </pre>
* *
@ -90,11 +91,6 @@ public class DrawPolygonDlg extends CaveSWTDialog {
*/ */
private Font boldFont = null; private Font boldFont = null;
/**
* Normal font.
*/
private Font font = null;
/** /**
* The field type selection Combo control. * The field type selection Combo control.
*/ */
@ -152,14 +148,13 @@ public class DrawPolygonDlg extends CaveSWTDialog {
protected Layout constructShellLayout() { protected Layout constructShellLayout() {
// Create the main layout for the shell. // Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, true); GridLayout mainLayout = new GridLayout(1, true);
mainLayout.marginHeight = 1; mainLayout.marginHeight = 0;
mainLayout.marginWidth = 1; mainLayout.marginWidth = 0;
return mainLayout; return mainLayout;
} }
@Override @Override
protected void disposed() { protected void disposed() {
font.dispose();
boldFont.dispose(); boldFont.dispose();
resource.clearPolygons(); resource.clearPolygons();
} }
@ -168,8 +163,6 @@ public class DrawPolygonDlg extends CaveSWTDialog {
protected void initializeComponents(final Shell shell) { protected void initializeComponents(final Shell shell) {
setReturnValue(false); 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 // Initialize all of the controls and layoutsendCal
initializeComponents(); initializeComponents();
shell.addControlListener(new ControlAdapter() { shell.addControlListener(new ControlAdapter() {
@ -215,10 +208,14 @@ public class DrawPolygonDlg extends CaveSWTDialog {
private void createPersistentGroup() { private void createPersistentGroup() {
// Create adjust group // Create adjust group
Group persistentGroupComp = new Group(shell, SWT.NONE); 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.setFont(boldFont);
persistentGroupComp.setText(ADJUST_PRECIP_TEXT); persistentGroupComp.setText(ADJUST_PRECIP_TEXT);
persistentGroupComp.setLayout(new GridLayout(1, true)); persistentGroupComp.setLayout(new GridLayout(1, false));
GridData gd = new GridData(345, SWT.DEFAULT); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
persistentGroupComp.setLayoutData(gd); persistentGroupComp.setLayoutData(gd);
getPersistentChk(persistentGroupComp); getPersistentChk(persistentGroupComp);
@ -234,8 +231,8 @@ public class DrawPolygonDlg extends CaveSWTDialog {
Group subGroup = new Group(shell, SWT.NONE); Group subGroup = new Group(shell, SWT.NONE);
subGroup.setFont(boldFont); subGroup.setFont(boldFont);
subGroup.setText(SUBSTITUTE_VALUE_TEXT); subGroup.setText(SUBSTITUTE_VALUE_TEXT);
subGroup.setLayout(new GridLayout(2, false)); subGroup.setLayout(new GridLayout(1, false));
GridData gd = new GridData(345, SWT.DEFAULT); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
subGroup.setLayoutData(gd); subGroup.setLayoutData(gd);
createFieldCombo(subGroup); createFieldCombo(subGroup);
@ -243,7 +240,8 @@ public class DrawPolygonDlg extends CaveSWTDialog {
// Create Substitute button // Create Substitute button
final Button subBtn = new Button(subGroup, SWT.PUSH); final Button subBtn = new Button(subGroup, SWT.PUSH);
subBtn.setData(PolygonEditAction.SUB); 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.setText("Substitute");
subBtn.setLayoutData(gd); subBtn.setLayoutData(gd);
subBtn.addSelectionListener(new SelectionAdapter() { subBtn.addSelectionListener(new SelectionAdapter() {
@ -260,8 +258,8 @@ public class DrawPolygonDlg extends CaveSWTDialog {
private void createCloseBtn() { private void createCloseBtn() {
Button closeBtn = new Button(shell, SWT.PUSH); Button closeBtn = new Button(shell, SWT.PUSH);
closeBtn.setText("Close"); closeBtn.setText("Close");
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false, 1, 1); GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
closeBtn.setAlignment(SWT.CENTER); gd.minimumWidth = closeBtn.getDisplay().getDPI().x;
closeBtn.setLayoutData(gd); closeBtn.setLayoutData(gd);
closeBtn.addSelectionListener(new SelectionAdapter() { closeBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
@ -279,10 +277,9 @@ public class DrawPolygonDlg extends CaveSWTDialog {
*/ */
private void getPersistentChk(Group groupComp) { private void getPersistentChk(Group groupComp) {
persistentChk = new Button(groupComp, SWT.CHECK); 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.setLayoutData(gd);
persistentChk.setText(MAKE_PERSISTENT); persistentChk.setText(MAKE_PERSISTENT);
persistentChk.setFont(font);
} }
/** /**
@ -293,9 +290,12 @@ public class DrawPolygonDlg extends CaveSWTDialog {
*/ */
private void getSliderComp(Group groupComp) { private void getSliderComp(Group groupComp) {
Composite comp = new Composite(groupComp, SWT.NONE); 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 = new Scale(comp, SWT.HORIZONTAL);
precipSlider.setMinimum(0); precipSlider.setMinimum(0);
precipSlider.setMaximum(500); precipSlider.setMaximum(500);
@ -310,7 +310,7 @@ public class DrawPolygonDlg extends CaveSWTDialog {
// Create the Red color spinner. // Create the Red color spinner.
precipSpinner = new Spinner(comp, SWT.BORDER); 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.setLayoutData(gd);
precipSpinner.setMinimum(0); precipSpinner.setMinimum(0);
precipSpinner.setMaximum(500); precipSpinner.setMaximum(500);
@ -333,7 +333,9 @@ public class DrawPolygonDlg extends CaveSWTDialog {
*/ */
private void getButtonComp(Group groupComp) { private void getButtonComp(Group groupComp) {
Composite comp = new Composite(groupComp, SWT.NONE); 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[] editBtns = new PolygonEditAction[] {
PolygonEditAction.SET, PolygonEditAction.RAISE, PolygonEditAction.SET, PolygonEditAction.RAISE,
@ -344,7 +346,8 @@ public class DrawPolygonDlg extends CaveSWTDialog {
Button editBtn = new Button(comp, SWT.PUSH); Button editBtn = new Button(comp, SWT.PUSH);
editBtn.setText(action.toPrettyName()); editBtn.setText(action.toPrettyName());
editBtn.setData(action); 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() { editBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent event) { 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. // Create a container to hold the label and the combo box.
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
Composite prodListComp = new Composite(shell, SWT.NONE); Composite prodListComp = new Composite(shell, SWT.NONE);
GridLayout prodListCompLayout = new GridLayout(2, false); GridLayout prodListCompLayout = new GridLayout(1, false);
prodListComp.setLayout(prodListCompLayout); prodListComp.setLayout(prodListCompLayout);
prodListComp.setLayoutData(gd); 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); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
fieldTypeCombo = new Combo(groupComp, SWT.LEFT | SWT.DROP_DOWN fieldTypeCombo = new Combo(groupComp, SWT.LEFT | SWT.DROP_DOWN
| SWT.READ_ONLY); | SWT.READ_ONLY);
@ -401,7 +399,6 @@ public class DrawPolygonDlg extends CaveSWTDialog {
displayTypeNameArray = new String[displayFieldDataArray.length]; displayTypeNameArray = new String[displayFieldDataArray.length];
for (int i = 0; i < displayFieldDataArray.length; i++) { for (int i = 0; i < displayFieldDataArray.length; i++) {
String fieldName = displayFieldDataArray[i].toString(); String fieldName = displayFieldDataArray[i].toString();
displayTypeNameArray[i] = fieldName; 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 // Opens the dialog without ever displaying it, doing all the initialization
// necessary to load the alarm list and get it functioning. // necessary to load the alarm list and get it functioning.
// TODO: restructure code to get rid of this abomination
public void openInvisible() { public void openInvisible() {
Shell parent = getParent(); Shell parent = getParent();
@ -188,8 +190,6 @@ public class AlarmAlertDlg extends CaveSWTDialog {
} }
}); });
preOpened();
opened(); 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 * Jul 24, 2014 3423 randerso Created eclipse job to get afos command
* execution off the UI thread * execution off the UI thread
* Sep 09, 2014 3580 mapeters Removed IQueryTransport usage (no longer exists). * 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 * significant code cleanup
* </pre> * </pre>
* *
@ -224,6 +224,7 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
* initialization necessary to get alarms/alerts up and running without the * initialization necessary to get alarms/alerts up and running without the
* user ever having to do more than open the text workstation. * user ever having to do more than open the text workstation.
*/ */
// TODO: restructure code to get rid of this abomination
public void openInvisible() { public void openInvisible() {
Shell parent = getParent(); Shell parent = getParent();
@ -385,6 +386,8 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
if (dlg == null || dlg.getShell().isDisposed()) { if (dlg == null || dlg.getShell().isDisposed()) {
dlg = new AlarmAlertDlg(shell); dlg = new AlarmAlertDlg(shell);
} }
// call preOpened() to compute correct location
dlg.preOpened();
dlg.open(); dlg.open();
} }
}); });

View file

@ -385,6 +385,7 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeOperations;
* Moved upper case conversion for QC checks into the * Moved upper case conversion for QC checks into the
* specific checks that need it. * specific checks that need it.
* Mar 17, 2016 RM 18727 D. Friedman Fix use of verification listener when entering and exiting editor. * 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> * </pre>
* *
@ -4185,19 +4186,18 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
// section // section
setCurrentHeaderAndBody(); 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 // if product is a WarnGen product and is not enabled for mixed case
// transmission, replace all commas with ellipses // transmission, replace all commas with ellipses
if (TextEditorCfg.getTextEditorCfg().getReplaceCommasWithEllipses() if (TextEditorCfg.getTextEditorCfg().getReplaceCommasWithEllipses()
&& product != null && warngenPils.contains(product.getNnnid()) && product != null && warngenPils.contains(product.getNnnid())
&& !MixedCaseProductSupport.isMixedCase(product.getNnnid())) { && !MixedCaseProductSupport.isMixedCase(product.getNnnid())) {
textEditor.setText(textEditor.getText() replaceCommasWithEllipses(product);
.replaceAll(", {0,1}", "..."));
}
// Mark the uneditable warning text
if (markUneditableText(textEditor)) {
// Enable listener to monitor attempt to edit locked text
verifyUndeditableText = true;
} }
// Set the menu buttons to reflect the edit mode. // Set the menu buttons to reflect the edit mode.
@ -4227,6 +4227,60 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
editHeader("warning", true); 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. * Cancel the editor mode.
* *
@ -8037,7 +8091,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
paragraphStart = paragraphStart.toUpperCase(); paragraphStart = paragraphStart.toUpperCase();
// is this the locations paragraph? // 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; inLocations = true;
} }
@ -8078,7 +8135,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
} }
if (line.length() <= charWrapCol) { if (line.length() <= charWrapCol) {
extendShortLine(lineNumber, padding); extendShortLine(lineNumber, padding, inLocations);
if (textEditor.getLine(lineNumber).length() <= charWrapCol) { if (textEditor.getLine(lineNumber).length() <= charWrapCol) {
// extended line is still short enough do not wrap // extended line is still short enough do not wrap
if (lineNumber < endWrapLine) { if (lineNumber < endWrapLine) {
@ -8109,8 +8166,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
* *
* @param lineNumber * @param lineNumber
* @param padding * @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 the line is too short move the next line up
// if there is a next line // if there is a next line
String line = textEditor.getLine(lineNumber); String line = textEditor.getLine(lineNumber);
@ -8190,10 +8248,12 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
String wordSpace = ""; String wordSpace = "";
if (noSeparatorPattern.matcher(endLine).matches() if (noSeparatorPattern.matcher(endLine).matches()
&& noSeparatorPattern.matcher(startNextLine) && noSeparatorPattern.matcher(startNextLine)
.matches()) { .matches()
&& (!inLocations || !line.endsWith("..."))) {
// Put a space between words when merging the lines. // Put a space between words when merging the lines.
wordSpace = " "; wordSpace = " ";
} }
textEditor.replaceTextRange(newlinePosition, deleteLen, textEditor.replaceTextRange(newlinePosition, deleteLen,
wordSpace); wordSpace);
String afterReplace = textEditor.getText(); String afterReplace = textEditor.getText();
@ -8207,7 +8267,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
// is this line still too short? // is this line still too short?
if (textEditor.getLine(lineNumber).length() <= charWrapCol) { 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() { private void recompileRegex() {
this.standardWrapRegex = Pattern.compile("( |..).{1," this.standardWrapRegex = Pattern.compile("( |..).{1,"
+ (charWrapCol - 3) + "}(\\s|-)"); + (charWrapCol - 3) + "}(\\s|-)");
this.locationsFirstRegex = Pattern.compile("^\\* LOCATIONS [^\\.]{1," this.locationsFirstRegex = Pattern.compile("^(?:\\* (?:SOME )?LOCATIONS|LOCATIONS IMPACTED|SOME LOCATIONS THAT) [^\\.]{1,"
+ (charWrapCol - 13) + "}\\s"); + (charWrapCol - 13) + "}\\s");
this.locationsBodyRegex = Pattern.compile("(( |..).{1," this.locationsBodyRegex = Pattern.compile("(( |..).{1,"
+ (charWrapCol - 5) + "}\\.\\.\\.)|(( |..).{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. * 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 * 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. * 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> * </pre>
* *
@ -71,8 +72,12 @@ import com.raytheon.viz.texteditor.util.VtecUtil;
*/ */
public class TextSegmentCheck implements IQCCheck { 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 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; private static Map<String, List<String>> bulletTypeMaps;
static { static {
@ -191,7 +196,7 @@ public class TextSegmentCheck implements IQCCheck {
} }
m = ugcPtrn.matcher(line); m = ugcPtrn.matcher(line);
if (m.find()) { if (m.find() && m.start() != m.end()) {
ugc += line; ugc += line;
countUGC = true; countUGC = true;
continue; continue;

View file

@ -1,19 +1,39 @@
package com.raytheon.viz.warnings.rsc; package com.raytheon.viz.warnings.rsc;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord; 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.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.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties; 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) @XmlAccessorType(XmlAccessType.NONE)
public class CWASPSResourceData extends WWAResourceData { public class CWASPSResourceData extends WWAResourceData {
private static AlertMessageToPDOParserSPS alertParser = new AlertMessageToPDOParserSPS();
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -34,4 +54,42 @@ public class CWASPSResourceData extends WWAResourceData {
return new CWASPSResource(this, loadProperties); 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 * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* July 29, 2015 DCS17366 pwang Initial creation * July 29, 2015 DCS17366 pwang Initial creation
* Apr 22, 2016 DCS18916 pwang Support two STQ formats
* *
* </pre> * </pre>
* *
@ -104,7 +105,7 @@ public class SpotRequestParser {
PROPERTY_PATTERN_MAP.put("SIZE_NAME", "SIZE\\s*\\(ACRES\\)"); PROPERTY_PATTERN_MAP.put("SIZE_NAME", "SIZE\\s*\\(ACRES\\)");
PROPERTY_PATTERN_MAP.put("SITE_NAME", "SITE"); PROPERTY_PATTERN_MAP.put("SITE_NAME", "SITE");
PROPERTY_PATTERN_MAP.put("OFILE_NAME", "OFILE"); 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_NAME", "TIMEZONE");
PROPERTY_PATTERN_MAP.put("TIMEZONE_VALUE", "\\w{3}\\d{1}(\\w{3})?"); 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 if (propertyValue.matches(PROPERTY_PATTERN_MAP
.get("OFILE_VALUE"))) { .get("OFILE_VALUE"))) {
String[] ofileArray = propertyValue.split(DOT_DELIMINATER); String[] ofileArray = propertyValue.split(DOT_DELIMINATER);
stgPDO.setOfileKey(ofileArray[1]); String stationId = "";
stgPDO.setOfileVersion(ofileArray[2]); 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() stgPDO.getLocation()
.setStationId(ofileArray[1] + ofileArray[2]); .setStationId(stationId);
} }
else { else {
//OFILE is required, return false to discontinue the parsing //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> </java>
</target> </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"> <target name="clean">
<if> <if>
<available file="${basedir}/edex/includes" <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 * Jun 19, 2014 3226 bclement added validator callback
* Jul 07, 2015 4581 skorolev Corrected decodeStrikes to avoid BufferUnderflowException. * Jul 07, 2015 4581 skorolev Corrected decodeStrikes to avoid BufferUnderflowException.
* Apr 07, 2016 DR18763 mgamazaychikov Switched to using LightningWMOHeader. * 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. * May 02, 2016 18336 amoore Keep-alive messages should update the legend.
* *
* </pre> * </pre>
@ -201,9 +202,19 @@ public class TotalLightningDecoder {
*/ */
private PluginDataObject[] decodeInternal(LightningWMOHeader wmoHdr, private PluginDataObject[] decodeInternal(LightningWMOHeader wmoHdr,
String fileName, byte[] pdata) throws DecoderException { String fileName, byte[] pdata) throws DecoderException {
if (!validFlashPacket(pdata, COMBINATION_PACKET_HEADER_SIZE)) { byte[] pdataPreDecrypt = pdata;
/* assume data is encrypted if we can't understand it */ // determine if the data is encrypted or not based on comparing
pdata = decrypt(wmoHdr, fileName, pdata); // 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); 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 value="com.raytheon.uf.common.dataplugin.gfe.request.ConfigureTextProductsRequest"/>
<constructor-arg ref="configureTextProductsHandler"/> <constructor-arg ref="configureTextProductsHandler"/>
</bean> </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 id="GetSelectTRHandler" class="com.raytheon.edex.plugin.gfe.server.handler.GetSelectTimeRangeHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register"> <bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.GetSelectTimeRangeRequest"/> <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 * Oct 03, 2008 njensen Initial creation
* Jul 10, 2009 #2590 njensen Added multiple site support * 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. * Jun 10, 2014 #3268 dgilling Re-factor based on AbstractWatchNotifierSrv.
* Oct 08, 2014 #4953 randerso Refactored AbstractWatchNotifierSrv to allow * Oct 08, 2014 #4953 randerso Refactored AbstractWatchNotifierSrv to allow
* subclasses to handle all watches if desired. * 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 * Added support for sending TCVAdvisory files to
* VTEC partners * VTEC partners
* Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException * 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 * Jan 27, 2016 5237 tgurney Replace LocalizationFile with ILocalizationFile
* *
* </pre> * </pre>
@ -104,31 +105,11 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
private static final String DEFAULT_TPC_SITE = "KNHC"; 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. " + "Check for 'red' locks (owned by others) on your Hazard grid and resolve them. "
+ "If hazards are separated into temporary grids, please run Mergehazards. " + "If hazards are separated into temporary grids, please run Mergehazards. "
+ "Next...save Hazards grid. Finally, select PlotTPCEvents from Hazards menu."; + "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>() { private static final ThreadLocal<PythonScript> pythonScript = new ThreadLocal<PythonScript>() {
@Override @Override
@ -181,8 +162,8 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
boolean practiceMode = (record instanceof PracticeWarningRecord); boolean practiceMode = (record instanceof PracticeWarningRecord);
String issuingOffice = record.getOfficeid(); String issuingOffice = record.getOfficeid();
// if it's a TCV // if it's a TCV or pre-TCV
if ("TCV".equals(pil)) { if ("TCV".equals(pil) || "PTC".equals(pil)) {
super.handleWatch(warningRecs); super.handleWatch(warningRecs);
} }
@ -431,7 +412,7 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
private Map<String, Object> loadJSONDictionary(ILocalizationFile lf) { private Map<String, Object> loadJSONDictionary(ILocalizationFile lf) {
if (lf != null) { if (lf != null) {
PythonScript script = this.pythonScript.get(); PythonScript script = pythonScript.get();
if (script != null) { if (script != null) {
Map<String, Object> args = new HashMap<String, Object>(); Map<String, Object> args = new HashMap<String, Object>();
args.put("localizationType", lf.getContext() args.put("localizationType", lf.getContext()
@ -456,7 +437,7 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
private void saveJSONDictionary(ILocalizationFile lf, private void saveJSONDictionary(ILocalizationFile lf,
Map<String, Object> dict) { Map<String, Object> dict) {
if (lf != null) { if (lf != null) {
PythonScript script = this.pythonScript.get(); PythonScript script = pythonScript.get();
if (script != null) { if (script != null) {
Map<String, Object> args = new HashMap<String, Object>(); Map<String, Object> args = new HashMap<String, Object>();
args.put("localizationType", lf.getContext() args.put("localizationType", lf.getContext()
@ -502,31 +483,6 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
return null; return null;
} }
// create the message return ALERT_TXT;
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();
} }
} }

View file

@ -21,7 +21,7 @@
<constraint constraintValue="warning,practicewarning" constraintType="IN"/> <constraint constraintValue="warning,practicewarning" constraintType="IN"/>
</mapping> </mapping>
<mapping key="pil"> <mapping key="pil">
<constraint constraintValue="TCV,HLS" constraintType="IN"/> <constraint constraintValue="TCV,HLS,PTC" constraintType="IN"/>
</mapping> </mapping>
</metadataMap> </metadataMap>
</pluginNotification> </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. ## ## BOOKBINDER 6-15-2015 Corrected bad softball/grapefruit hail sized. ##
## Removed redundant tornado watch phrase from CTA ## ## Removed redundant tornado watch phrase from CTA ##
## Bookbinder 10-20-2015 Fixed extraSource var for tornado info ## ## 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 ## Impact Statements for IBW templates are contained in impactStatements.vm
################################################################ ################################################################
@ -16,7 +18,8 @@
#parse("config.vm") #parse("config.vm")
##SET SOME INITIAL VARIABLES ##SET SOME INITIAL VARIABLES
#set($hazard = "") #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($torTag = "")
#set($pdssvr = "") #set($pdssvr = "")
#set($extraSource = "") #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 ## Comment out #parse command below to pull in Dynamic DSS Event Info
## If this feature is utilized, the "specialEvent" bullet (output above) can ## If this feature is utilized, the "specialEvent" bullet (output above) can
## likely be commented out from the impactSevereThunderstormWarning.xml file ## 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 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 file command here is to pull in extra points (venues) info
##parse("pointMarkers.vm") ## #parse("pointMarkers.vm")
################################## ##################################
######### CALLS TO ACTION ######## ######### CALLS TO ACTION ########

View file

@ -20,6 +20,9 @@
## Phil Kurimski 10-20-2015 Added waterspout option to TOR basis ## ## Phil Kurimski 10-20-2015 Added waterspout option to TOR basis ##
## Evan Bookbinder 10-20-2015 fixed extraSource variable usage ## ## Evan Bookbinder 10-20-2015 fixed extraSource variable usage ##
## Phil Kurimski 10-21-2015 Fixed Tornado Preamble for mixed case ## ## 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 ## Impact Statements for IBW templates are contained in impactStatements.vm
################################################################ ################################################################
@ -48,6 +51,7 @@
##PATHCAST LEAD VARIABLE ADD LATER????? ##PATHCAST LEAD VARIABLE ADD LATER?????
#if(${phenomena}=="SV") #if(${phenomena}=="SV")
#set($eventType = "SEVERE THUNDERSTORM") #set($eventType = "SEVERE THUNDERSTORM")
#set($source = "!** YOU FAILED TO SELECT A SOURCE. PLEASE TYPE ONE OR REGENERATE THIS WARNING **!")
#if(${stormType} == "line") #if(${stormType} == "line")
#set($reportType1 = "severe thunderstorms were") #set($reportType1 = "severe thunderstorms were")
#set($reportType2 = "these storms 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") #if(${action}=="EXP" || ${action}=="CAN" || ${action}=="CANCON" || ${CORCAN}=="true")
#### SET A DEFAULT STATEMENT IN CASE NO BULLET WAS SELECTED OR AVAILABLE #### SET A DEFAULT STATEMENT IN CASE NO BULLET WAS SELECTED OR AVAILABLE
#if(${stormType} == "line") #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 #else
#if(${phenomena}=="SV") #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 #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
#end #end
#### WEAKENED BELOW SEVERE LIMITS #### WEAKENED BELOW SEVERE LIMITS
@ -287,9 +291,9 @@ ${dateUtil.format(${now}, ${timeFormat.header}, ${localtimezone})}
#elseif(${addhailcheck} == "1" && ${addwindcheck} == "1" && ${addraincheck} == "0" ) #elseif(${addhailcheck} == "1" && ${addwindcheck} == "1" && ${addraincheck} == "0" )
#set($addthreat = " However ${addhail} and ${addwind} are still possible with ${stormTypePhrase}.") #set($addthreat = " However ${addhail} and ${addwind} are still possible with ${stormTypePhrase}.")
#elseif(${addhailcheck} == "1" && ${addwindcheck} == "0" && ${addraincheck} == "1" ) #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" ) #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" ) #elseif(${addhailcheck} == "1" && ${addwindcheck} == "1" && ${addraincheck} == "1" )
#set($addthreat = " However ${addhail}#commaOrEllipsis()${addwind} and ${addrain} are still possible with ${stormTypePhrase}.") #set($addthreat = " However ${addhail}#commaOrEllipsis()${addwind} and ${addrain} are still possible with ${stormTypePhrase}.")
#end #end
@ -979,7 +983,7 @@ Those attending the !**EVENT/VENUE NAME OR LOCATION**! are in the path of this s
#end #end
#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("dssEvents.vm")
## parse file command here is to pull in extra locations (venues) info ## parse file command here is to pull in extra locations (venues) info
## #parse("pointMarkers.vm") ## #parse("pointMarkers.vm")

View file

@ -51,6 +51,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* Sep 16, 2008 randerso Initial creation * Sep 16, 2008 randerso Initial creation
* Mar 31, 2014 2689 mpduff Log input values on conversion failure. * 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. * 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> * </pre>
* *
@ -210,7 +212,7 @@ public class HRAP {
false); false);
gridMapper = new GridToEnvelopeMapper(gridRange, userRange); gridMapper = new GridToEnvelopeMapper(gridRange, userRange);
gridMapper.setPixelAnchor(PixelInCell.CELL_CENTER); gridMapper.setPixelAnchor(PixelInCell.CELL_CORNER);
gridMapper.setReverseAxis(new boolean[] { false, false }); gridMapper.setReverseAxis(new boolean[] { false, false });
} catch (Exception e) { } catch (Exception e) {

View file

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

View file

@ -30,7 +30,7 @@ BuildRequires: awips2-ant
BuildRequires: awips2-java BuildRequires: awips2-java
%description %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 %prep
# Ensure that a "buildroot" has been specified. # Ensure that a "buildroot" has been specified.
@ -44,27 +44,23 @@ if [ -d %{_build_root} ]; then
rm -rf %{_build_root} rm -rf %{_build_root}
fi fi
/bin/mkdir -p %{_build_root} /bin/mkdir -p %{_build_root}
#/bin/mkdir %{_build_root}
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
%build %build
_hybrid_target=buildHybrid
_build_xml=build.xml _build_xml=build.xml
BUILD_EDEX=%{_baseline_workspace}/build.edex BUILD_EDEX=%{_baseline_workspace}/build.edex
EDEX_DIST=${BUILD_EDEX}/edex/dist 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} cd ${BUILD_EDEX}
/awips2/ant/bin/ant -f ${_build_xml} \ /awips2/ant/bin/ant -f ${_build_xml} \
-Dbuild.arch=${_pde_build_arch} \ -Dbuild.arch=x86_64 \
-Duframe.eclipse=%{_uframe_eclipse} ${_hybrid_target} -Dfeature=com.raytheon.uf.common.base.feature \
-Duframe.eclipse=%{_uframe_eclipse} \
clean \
build \
clean
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
@ -78,15 +74,6 @@ if [ $? -ne 0 ]; then
exit 1 exit 1
fi 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 #create a list of all files packaged for /awips2/edex/data/utility
UTILITY=/awips2/edex/data/utility UTILITY=/awips2/edex/data/utility
if [ -d %{_build_root}/$UTILITY ]; then if [ -d %{_build_root}/$UTILITY ]; then
@ -123,29 +110,7 @@ else if [ $retVal -eq 0 ]; then
fi fi
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 %preun
if [ -d /awips2/.cave ]; then
rm -rf /awips2/.cave
fi
if [ -d /awips2/.edex ]; then if [ -d /awips2/.edex ]; then
rm -rf /awips2/.edex rm -rf /awips2/.edex
fi fi
@ -160,8 +125,3 @@ rm -rf ${RPM_BUILD_ROOT}
%dir /awips2 %dir /awips2
%dir /awips2/edex %dir /awips2/edex
/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