diff --git a/cave/com.raytheon.viz.mpe.ui/plugin.xml b/cave/com.raytheon.viz.mpe.ui/plugin.xml index 2a7f9f0443..cee551b58d 100644 --- a/cave/com.raytheon.viz.mpe.ui/plugin.xml +++ b/cave/com.raytheon.viz.mpe.ui/plugin.xml @@ -240,8 +240,7 @@ + mnemonic="A"> + mnemonic="D"> - - - - - - - - @@ -1032,6 +1013,32 @@ id="com.raytheon.viz.mpe.ui.dialogs.postanalysis.SummedHourlyMpe" name="Launch Post Analysis"> + + + + + + + + + + + + @@ -1209,8 +1216,8 @@ + class="com.raytheon.viz.mpe.ui.actions.ToggleGageValueDisplay" + commandId="com.raytheon.viz.mpe.ui.actions.toggleGageValueDisplay"> @@ -1394,6 +1401,24 @@ class="com.raytheon.viz.mpe.ui.actions.SummedHourlyMpeAction" commandId="com.raytheon.viz.mpe.ui.dialogs.postanalysis.SummedHourlyMpe"> + + + + + + + + + + + + diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/MPECommandConstants.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/MPECommandConstants.java index 65bc94c189..1ddbf71360 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/MPECommandConstants.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/MPECommandConstants.java @@ -30,7 +30,8 @@ import org.eclipse.ui.IWorkbenchCommandConstants; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Nov 29, 2012 mschenke Initial creation + * Nov 29, 2012 mschenke Initial creation + * Mar 19, 2013 1457 mpduff Added gage toggle commands. * * * @@ -39,12 +40,38 @@ import org.eclipse.ui.IWorkbenchCommandConstants; */ public interface MPECommandConstants { - + /** + * Font command id. + */ public static final String FONT = "com.raytheon.viz.mpe.ui.actions.setfont"; + /** + * Gage color command id. + */ public static final String GAGE_COLOR = "com.raytheon.viz.mpe.ui.actions.toggleGageColor"; + /** + * Gage missing command id. + */ public static final String GAGE_MISSING_OPTION = "com.raytheon.viz.mpe.ui.actions.toggleGageMissing"; + /** + * Display mode command id. + */ public static final String DISPLAY_MODE = "com.raytheon.viz.mpe.ui.actions.toggleDisplayMode"; + + /** + * Toggle Gage Id Command ID. + */ + public static final String TOGGLE_GAGEID_COMMAND_ID = "com.raytheon.viz.mpe.ui.actions.toggleGageIdDisplay"; + + /** + * Toggle gage triangle command ID. + */ + public static final String TOGGLE_GAGE_TRIANGLE_COMMAND_ID = "com.raytheon.viz.mpe.ui.actions.ToggleGageTriangleDisplay"; + + /** + * Toggle gage value Command ID. + */ + public static final String TOGGLE_GAGE_VALUE_COMMAND_ID = "com.raytheon.viz.mpe.ui.actions.toggleGageValueDisplay"; } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/BaseFieldsPopulator.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/BaseFieldsPopulator.java index 1ce860ee18..2a699635be 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/BaseFieldsPopulator.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/BaseFieldsPopulator.java @@ -6,54 +6,55 @@ import java.util.Map; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.MenuManager; - /** * Dynamic Field populator for the menu item BaseFields. * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * May 23, 2011            rgeorge     Initial creation
- *
+ * Mar 14, 2013   1457     mpduff      Changed to use the ToggleGageTriangleDisplay handler.
+ * 
  * 
- * + * * @author rgeorge - * @version 1.0 + * @version 1.0 */ public class BaseFieldsPopulator extends FieldsPopulator { - private static DisplayFieldData[] menuItems = new DisplayFieldData[] { DisplayFieldData.p3lMosaic }; + private static DisplayFieldData[] menuItems = new DisplayFieldData[] { DisplayFieldData.p3lMosaic }; - private static MenuManager menuMgr = new MenuManager("BaseFields", - "com.raytheon.viz.mpe.BaseFields"); + private static MenuManager menuMgr = new MenuManager("BaseFields", + "com.raytheon.viz.mpe.BaseFields"); - private static Map gageMap = new HashMap(); - static { - gageMap.put("Gage", "Triangles"); - } - private static Map textMap = new HashMap(); - static { - textMap.put(DisplayFieldData.p3lMosaic, new MenuData( - "Gage Triangles", "G", Action.AS_CHECK_BOX, - "com.raytheon.viz.mpe.ui.actions.toggleGageDisplay", gageMap)); - } + private static Map gageMap = new HashMap(); + static { + gageMap.put("Gage", "Triangles"); + } - @Override - protected Map getTexMap() { - return BaseFieldsPopulator.textMap; - } + private static Map textMap = new HashMap(); + static { + textMap.put(DisplayFieldData.p3lMosaic, new MenuData("Gage Triangles", + "G", Action.AS_CHECK_BOX, + "com.raytheon.viz.mpe.ui.actions.ToggleGageTriangleDisplay", + gageMap)); + } - @Override - protected DisplayFieldData[] getMenuItems() { - return BaseFieldsPopulator.menuItems; - } + @Override + protected Map getTexMap() { + return BaseFieldsPopulator.textMap; + } - @Override - protected MenuManager getMenuManger() { - return BaseFieldsPopulator.menuMgr; - } + @Override + protected DisplayFieldData[] getMenuItems() { + return BaseFieldsPopulator.menuItems; + } -} + @Override + protected MenuManager getMenuManger() { + return BaseFieldsPopulator.menuMgr; + } +} \ No newline at end of file diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java index 1d67798e35..b8ac2daf9b 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java @@ -43,6 +43,7 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.handlers.RadioState; +import org.eclipse.ui.handlers.RegistryToggleState; import com.raytheon.uf.common.colormap.ColorMap; import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue; @@ -97,6 +98,7 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 18, 2012 mschenke Initial creation + * Mar 14, 2013 1457 mpduff Reset the gages on the resource. * * * @@ -391,15 +393,15 @@ public class MPEDisplayManager { return null; } - private Set timeChangedListeners = new LinkedHashSet(); + private final Set timeChangedListeners = new LinkedHashSet(); - private Set fieldChangedListeners = new LinkedHashSet(); + private final Set fieldChangedListeners = new LinkedHashSet(); private final IRenderableDisplay display; private DisplayFieldData displayedField; - private MPEFieldResourceData fieldResourceData = new MPEFieldResourceData(); + private final MPEFieldResourceData fieldResourceData = new MPEFieldResourceData(); private MPEFieldResource displayedFieldResource; @@ -420,16 +422,7 @@ public class MPEDisplayManager { } editTime = getCurrentDisplayedDate(); - displayedField = DisplayFieldData.rMosaic; - String baseRadarMosaic = AppsDefaults.getInstance().getToken( - "mpe_base_radar_mosaic"); - if (baseRadarMosaic != null) { - DisplayFieldData fieldData = DisplayFieldData - .fromString(baseRadarMosaic); - if (fieldData != null) { - displayedField = fieldData; - } - } + displayedField = DisplayFieldData.mMosaic; ChangeTimeProvider.update(this); @@ -549,12 +542,14 @@ public class MPEDisplayManager { /** * @param gageDisplay * the gageDisplay to set + * @param isOn + * is set to draw */ - public void toggleGageDisplay(GageDisplay gageDisplay) { + public void toggleGageDisplay(GageDisplay gageDisplay, boolean isOn) { List rscs = display.getDescriptor().getResourceList() .getResourcesByTypeAsType(MPEGageResource.class); for (MPEGageResource rsc : rscs) { - rsc.toggleGageDisplay(gageDisplay); + rsc.toggleGageDisplay(gageDisplay, isOn); } display.refresh(); } @@ -730,6 +725,14 @@ public class MPEDisplayManager { listener.displayFieldChanged(oldField, fieldToDisplay); } } + + // reset gages + List rscs = display.getDescriptor() + .getResourceList() + .getResourcesByTypeAsType(MPEGageResource.class); + for (MPEGageResource rsc : rscs) { + rsc.reloadGages(); + } } displayedFieldResource.issueRefresh(); @@ -817,6 +820,42 @@ public class MPEDisplayManager { return null; } + /** + * Gets the current command toggle state. + * + * @param commandId + * The Command ID + * @return the toggle state, or false if command not found + */ + public static Boolean getToggleState(String commandId) { + Command command = service.getCommand(commandId); + if (command != null) { + State state = command.getState(RegistryToggleState.STATE_ID); + if (state != null) { + return (Boolean) state.getValue(); + } + } + return Boolean.FALSE; + } + + /** + * Set the toggle state. + * + * @param commandId + * The command Id to set the toggle state on + * @param toggleState + * The toggle state value + */ + public static void setToggleState(String commandId, boolean toggleState) { + Command command = service.getCommand(commandId); + if (command != null) { + State state = command.getState(RegistryToggleState.STATE_ID); + if (state != null) { + state.setValue(toggleState); + } + } + } + /** * Returns the radio state id of the command specified by commandId as an * enum of the type of defaultValue with defaultValue being the default to diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ShowDisplay7x7.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ShowDisplay7x7.java index 5496047769..0168adae22 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ShowDisplay7x7.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ShowDisplay7x7.java @@ -33,6 +33,7 @@ import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.capabilities.EditableCapability; +import com.raytheon.viz.mpe.ui.MPEDisplayManager; import com.raytheon.viz.mpe.ui.rsc.MPEGageResource; import com.raytheon.viz.ui.EditorUtil; import com.raytheon.viz.ui.input.EditableManager; @@ -45,6 +46,7 @@ import com.raytheon.viz.ui.input.EditableManager; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jan 6, 2009 snaples Initial creation + * Mar 14, 2013 1457 mpduff Don't throw error if nothing displayed. * * * @author snaples @@ -54,20 +56,23 @@ public class ShowDisplay7x7 extends AbstractHandler implements IElementUpdater { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart activeEditor = (IEditorPart) EditorUtil - .getActiveEditorAs(IDisplayPaneContainer.class); - if (activeEditor != null) { - IDisplayPane first = ((IDisplayPaneContainer) activeEditor) - .getDisplayPanes()[0]; - List rscs = first.getDescriptor() - .getResourceList() - .getResourcesByTypeAsType(MPEGageResource.class); - for (MPEGageResource rsc : rscs) { - rsc.getProperties().setVisible(true); - EditableManager.makeEditable(rsc, true); - rsc.issueRefresh(); + if (MPEDisplayManager.getCurrent().getDisplayedFieldResource() != null) { + IEditorPart activeEditor = (IEditorPart) EditorUtil + .getActiveEditorAs(IDisplayPaneContainer.class); + if (activeEditor != null) { + IDisplayPane first = ((IDisplayPaneContainer) activeEditor) + .getDisplayPanes()[0]; + List 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); } }