rscs = first.getDescriptor()
+ .getResourceList()
+ .getResourcesByTypeAsType(MPEGageResource.class);
+ for (MPEGageResource rsc : rscs) {
+ rsc.getProperties().setVisible(true);
+ EditableManager.makeEditable(rsc, true);
+ rsc.issueRefresh();
+ }
}
}
+
return null;
}
@@ -88,5 +93,4 @@ public class ShowDisplay7x7 extends AbstractHandler implements IElementUpdater {
}
}
}
-
}
diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ToggleGageIdDisplay.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ToggleGageIdDisplay.java
new file mode 100644
index 0000000000..2681788d3c
--- /dev/null
+++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ToggleGageIdDisplay.java
@@ -0,0 +1,66 @@
+/**
+ * This software was developed and / or modified by Raytheon Company,
+ * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
+ *
+ * U.S. EXPORT CONTROLLED TECHNICAL DATA
+ * This software product contains export-restricted data whose
+ * export/transfer/disclosure is restricted by U.S. law. Dissemination
+ * to non-U.S. persons whether in the United States or abroad requires
+ * an export license or other authorization.
+ *
+ * Contractor Name: Raytheon Company
+ * Contractor Address: 6825 Pine Street, Suite 340
+ * Mail Stop B8
+ * Omaha, NE 68106
+ * 402.291.0100
+ *
+ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
+ * further licensing information.
+ **/
+package com.raytheon.viz.mpe.ui.actions;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import com.raytheon.viz.mpe.ui.MPEDisplayManager;
+import com.raytheon.viz.mpe.ui.MPEDisplayManager.GageDisplay;
+
+/**
+ * Handler for Toggling Gage Id display.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 13, 2013 1457 mpduff Initial creation.
+ *
+ *
+ *
+ * @author mpduff
+ * @version 1.0
+ */
+
+public class ToggleGageIdDisplay extends AbstractHandler {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
+ * .ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ Command command = event.getCommand();
+ boolean oldValue = HandlerUtil.toggleCommandState(command);
+
+ MPEDisplayManager dm = MPEDisplayManager.getCurrent();
+ dm.toggleGageDisplay(GageDisplay.Ids, !oldValue);
+ return null;
+ }
+}
diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ToggleGageTriangleDisplay.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ToggleGageTriangleDisplay.java
new file mode 100644
index 0000000000..7fe208216b
--- /dev/null
+++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ToggleGageTriangleDisplay.java
@@ -0,0 +1,64 @@
+/**
+ * This software was developed and / or modified by Raytheon Company,
+ * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
+ *
+ * U.S. EXPORT CONTROLLED TECHNICAL DATA
+ * This software product contains export-restricted data whose
+ * export/transfer/disclosure is restricted by U.S. law. Dissemination
+ * to non-U.S. persons whether in the United States or abroad requires
+ * an export license or other authorization.
+ *
+ * Contractor Name: Raytheon Company
+ * Contractor Address: 6825 Pine Street, Suite 340
+ * Mail Stop B8
+ * Omaha, NE 68106
+ * 402.291.0100
+ *
+ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
+ * further licensing information.
+ **/
+package com.raytheon.viz.mpe.ui.actions;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import com.raytheon.viz.mpe.ui.MPEDisplayManager;
+import com.raytheon.viz.mpe.ui.MPEDisplayManager.GageDisplay;
+
+/**
+ * Handler for Gage Triangle Display.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 13, 2013 1457 mpduff Initial creation.
+ *
+ *
+ *
+ * @author mpduff
+ * @version 1.0
+ */
+
+public class ToggleGageTriangleDisplay extends AbstractHandler {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
+ * .ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ Command command = event.getCommand();
+ boolean oldValue = HandlerUtil.toggleCommandState(command);
+ MPEDisplayManager dm = MPEDisplayManager.getCurrent();
+ dm.toggleGageDisplay(GageDisplay.Triangles, !oldValue);
+ return null;
+ }
+}
diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ToggleGageDisplay.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ToggleGageValueDisplay.java
similarity index 77%
rename from cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ToggleGageDisplay.java
rename to cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ToggleGageValueDisplay.java
index d39c741362..89edb8e052 100644
--- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ToggleGageDisplay.java
+++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ToggleGageValueDisplay.java
@@ -20,8 +20,10 @@
package com.raytheon.viz.mpe.ui.actions;
import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.handlers.HandlerUtil;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.MPEDisplayManager.GageDisplay;
@@ -34,14 +36,14 @@ import com.raytheon.viz.mpe.ui.MPEDisplayManager.GageDisplay;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 24, 2008 1748 snaples Initial creation
+ * Mar 14, 2013 1457 mpduff Renamed to ToggleGageValueDisplay.
*
*
* @author snaples
* @version 1.0
*/
-public class ToggleGageDisplay extends AbstractHandler {
-
+public class ToggleGageValueDisplay extends AbstractHandler {
/*
* (non-Javadoc)
*
@@ -50,11 +52,12 @@ public class ToggleGageDisplay extends AbstractHandler {
* .ExecutionEvent)
*/
@Override
- public Object execute(ExecutionEvent arg0) throws ExecutionException {
- String g = arg0.getParameter("Gage");
- GageDisplay disp = GageDisplay.valueOf(g);
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ Command command = event.getCommand();
+ boolean oldValue = HandlerUtil.toggleCommandState(command);
+
MPEDisplayManager dm = MPEDisplayManager.getCurrent();
- dm.toggleGageDisplay(disp);
+ dm.toggleGageDisplay(GageDisplay.Values, !oldValue);
return null;
}
diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java
index f26748d3c2..6b2f0e0f93 100644
--- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java
+++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java
@@ -27,12 +27,12 @@ import java.nio.channels.FileChannel;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashSet;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
-import java.util.Set;
+import java.util.Map;
import java.util.TimeZone;
import org.eclipse.swt.events.DisposeEvent;
@@ -63,6 +63,7 @@ import com.raytheon.uf.viz.core.rsc.GenericResourceData;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.viz.core.rsc.jts.JTSCompiler;
+import com.raytheon.viz.mpe.MPECommandConstants;
import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.core.MPEDataManager.MPEGageData;
import com.raytheon.viz.mpe.ui.Activator;
@@ -93,6 +94,7 @@ import com.vividsolutions.jts.index.strtree.STRtree;
* Aug 17, 2012 15271 snaples Added check to add only PP gages
* Sep 5, 2012 15079 snaples Added constant for Milli to inches conversion factor
* Feb 12, 2013 15773 snaples Updated addPoints to display PC gages when token is set to use PC data.
+ * Mar 14, 2013 1457 mpduff Fixed various bugs.
*
*
*
@@ -107,8 +109,6 @@ public class MPEGageResource extends AbstractMPEInputResource implements
private static final double POINT_RADIUS = 2;
- private static final RGB WHITE = new RGB(255, 255, 255);
-
private final SimpleDateFormat sdf;
private final Object mutex = new Object();
@@ -132,32 +132,56 @@ public class MPEGageResource extends AbstractMPEInputResource implements
private IWireframeShape gageTriangles;
private MPEFontFactory fontFactory;
-
+
private final AppsDefaults appsDefaults = AppsDefaults.getInstance();
-
- private Set displayTypes = new HashSet();
+ private final Map displayTypes = new HashMap();
/**
+ * Constructor.
+ *
* @param resourceData
+ * The resourceData
* @param loadProperties
+ * The loadProperties
*/
public MPEGageResource(GenericResourceData resourceData,
LoadProperties loadProperties) {
super(resourceData, loadProperties);
sdf = new SimpleDateFormat("yyyyMMddHH");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
+
+ setStates();
+ }
+
+ /**
+ * Set the state of the Gage display for values and Ids
+ */
+ private void setStates() {
+ boolean stateSetting = MPEDisplayManager
+ .getToggleState(MPECommandConstants.TOGGLE_GAGE_VALUE_COMMAND_ID);
+ displayTypes.put(GageDisplay.Values, stateSetting);
+
+ stateSetting = MPEDisplayManager
+ .getToggleState(MPECommandConstants.TOGGLE_GAGEID_COMMAND_ID);
+ displayTypes.put(GageDisplay.Ids, stateSetting);
+
+ // Triangles default to off
+ MPEDisplayManager.setToggleState(
+ MPECommandConstants.TOGGLE_GAGE_TRIANGLE_COMMAND_ID, false);
+ displayTypes.put(GageDisplay.Triangles, false);
}
/**
* Toggles visibility of {@link GageDisplay} type
*
* @param display
+ * The GageDisplay
+ * @param isOn
+ * true if on
*/
- public void toggleGageDisplay(GageDisplay display) {
- if (displayTypes.remove(display) == false) {
- displayTypes.add(display);
- }
+ public void toggleGageDisplay(GageDisplay display, boolean isOn) {
+ displayTypes.put(display, isOn);
}
@Override
@@ -215,8 +239,7 @@ public class MPEGageResource extends AbstractMPEInputResource implements
@Override
protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
- // set the plot draw or no draw values
- if (displayTypes.isEmpty()) {
+ if (!displayTypes.containsValue(Boolean.TRUE)) {
// Nothing to paint
return;
}
@@ -230,15 +253,15 @@ public class MPEGageResource extends AbstractMPEInputResource implements
}
}
- if (displayTypes.contains(GageDisplay.Ids)
- || displayTypes.contains(GageDisplay.Values)) {
+ if (displayTypes.get(GageDisplay.Ids)
+ || displayTypes.get(GageDisplay.Values)) {
paintPlotInfo(target, paintProps,
- displayTypes.contains(GageDisplay.Ids),
- displayTypes.contains(GageDisplay.Values));
+ displayTypes.get(GageDisplay.Ids),
+ displayTypes.get(GageDisplay.Values));
}
try {
- if (displayTypes.contains(GageDisplay.Triangles)) {
+ if (displayTypes.get(GageDisplay.Triangles)) {
paintTriangles(target, paintProps);
}
} catch (Exception e) {
@@ -264,7 +287,6 @@ public class MPEGageResource extends AbstractMPEInputResource implements
String fileName = String.format(GAGE_TRIANGLES,
sdf.format(lastDate));
File file = new File(dir, fileName);
-
if (!file.exists()) {
return;
}
@@ -327,18 +349,19 @@ public class MPEGageResource extends AbstractMPEInputResource implements
MPEDisplayManager.GageMissingOptions gm = MPEDisplayManager
.getGageMissing();
- boolean displayIsEdit = displayMgr.getCurrentEditDate().equals(
- paintProps.getDataTime().getRefTime());
+ boolean displayIsEdit = false;
+ if (paintProps.getDataTime() != null
+ && displayMgr.getCurrentEditDate() != null) {
+ displayIsEdit = displayMgr.getCurrentEditDate().equals(
+ paintProps.getDataTime().getRefTime());
+ }
boolean xor = MPEDisplayManager.getGageColor() == GageColor.Contrast
&& displayIsEdit;
for (Coordinate point : dataMap.keySet()) {
if (extent.contains(new double[] { point.x, point.y })) {
MPEGageData gageData = dataMap.get(point);
- RGB gageColor = WHITE;
- if (displayIsEdit) {
- gageColor = getGageColor(gageData);
- }
+ RGB gageColor = getGageColor(gageData);
boolean isReportedMissing = gageData.isReported_missing();
boolean isMissing = ((gageData.getGval() == -999.f || gageData
@@ -383,6 +406,7 @@ public class MPEGageResource extends AbstractMPEInputResource implements
}
}
}
+
if (isGageIdsDisplayed) {
gageId = gageData.getId();
@@ -421,7 +445,7 @@ public class MPEGageResource extends AbstractMPEInputResource implements
private RGB getGageColor(MPEGageData gageData) {
RGB gageColor = new RGB(255, 255, 255);
- if (displayTypes.isEmpty() == false) {
+ if (displayTypes.containsValue(Boolean.TRUE)) {
MPEDisplayManager.GageColor gc = MPEDisplayManager.getGageColor();
switch (gc) {
case Solid:
@@ -449,9 +473,7 @@ public class MPEGageResource extends AbstractMPEInputResource implements
if (gageData.getId().contains("PSEUDO")) {
fltVal = (float) (gageData.getGval() / MILLICVT);
}
- // System.out.println("--- fltVal = " + fltVal);
gageColor = getColorByValue(fltVal);
- // gageColor = getColorByValue(gageData.getGval());
break;
default:
@@ -475,14 +497,15 @@ public class MPEGageResource extends AbstractMPEInputResource implements
boolean process_PC = false;
if (processpc.equalsIgnoreCase("ON")) {
process_PC = true;
- }
+ }
if (!gages.isEmpty()) {
for (ListIterator it = gages.listIterator(); it
.hasNext();) {
MPEGageData gageData = it.next();
// DR15773 Use PC gages only when token set to ON.
- if ((gageData.getPe().equalsIgnoreCase("PC")) && (process_PC == false)) {
+ if ((gageData.getPe().equalsIgnoreCase("PC"))
+ && (process_PC == false)) {
continue;
}
Coordinate latLon = gageData.getLatLon();
diff --git a/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java b/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java
index a0e4fa52ca..f22fd148cf 100644
--- a/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java
+++ b/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java
@@ -31,8 +31,6 @@ import javax.measure.unit.NonSI;
import javax.measure.unit.SI;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
@@ -56,6 +54,7 @@ import com.raytheon.viz.mpe.core.MPEDataManager.MPEGageData;
* Oct 30, 2008 snaples Initial creation
* Aug 8, 2012 15271 snaples Updated hourly slot
* Jan 02, 2013 15565 snaples Fixed problem with wrong time being sent to mpe_fieldgen
+ * Mar 14, 2013 1457 mpduff Fixed memory leak.
*
*
* @author snaples
@@ -181,8 +180,6 @@ public class RegenHrFlds {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
- Cursor prev = shell.getCursor();
- Cursor wait = new Cursor(Display.getDefault(), SWT.CURSOR_WAIT);
this.checkGages();
boolean ref = MPEDataManager.getInstance().isRadarEditFlag();
/* Store any gage edits into the HourlyPP or PseudoGageVal table. */
@@ -291,7 +288,7 @@ public class RegenHrFlds {
String drr = "1 " + hour + " " + dr.format(datetime);
System.out.println("Regen args are " + drr);
MpeFieldGenJob regen = new MpeFieldGenJob(drr);
- shell.setCursor(wait);
+ shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
regen.schedule();
try {
regen.join();
@@ -300,9 +297,8 @@ public class RegenHrFlds {
e.printStackTrace();
}
- /* Clear gage edits */
MPEDataManager.getInstance().clearEditGages();
- shell.setCursor(prev);
+ shell.setCursor(null);
}
}