From 4fe4709862cc99d356f60f6ffb6b5be58fd3996b Mon Sep 17 00:00:00 2001 From: Max Schenkelberg Date: Tue, 5 Jun 2012 16:42:55 -0500 Subject: [PATCH] Issue #590 fixed GFE session creation bugs. Added refresh to tool items on undo/redo from keyboard Former-commit-id: 603726498f1c305f386863b43108eb2cd475b6c0 [formerly f0e2ef8c91242cdab7e44c6b034ec301aa6cd394] [formerly b5da470e0a2cf8a07f0f67d5f551571c401d35b7] [formerly 8b87b6a0a102a06439eb610e7542c62db18eb3a5 [formerly b5da470e0a2cf8a07f0f67d5f551571c401d35b7 [formerly 5c3d4a7fffe3873afbe8db60310afae2b3f0738b]]] Former-commit-id: 8b87b6a0a102a06439eb610e7542c62db18eb3a5 Former-commit-id: 1b3f753ea0cf2015ee33e8f1e26d5a3ddf66eec2 [formerly a6ca2ee4f61b7332583434e9470b50c2dc2be106] Former-commit-id: af72c6411acff73ddbc36b0f67375d5170e4a8ec --- .../common/cave/etc/pyViz/GFEPainter.py | 1 + .../ui/session/CollaborationSessionView.java | 18 +++--- .../telestrator/handlers/UndoRedoHandler.java | 60 +++++++++++++++---- ...f.common.serialization.ISerializableObject | 1 + .../viz/gfe/core/GFEMapRenderableDisplay.java | 34 +++++------ .../perspective/GFEPerspectiveManager.java | 7 ++- .../raytheon/viz/gfe/rsc/GFEResourceData.java | 5 +- 7 files changed, 83 insertions(+), 43 deletions(-) diff --git a/cave/build/static/common/cave/etc/pyViz/GFEPainter.py b/cave/build/static/common/cave/etc/pyViz/GFEPainter.py index 33e9b71864..5b23857c1a 100644 --- a/cave/build/static/common/cave/etc/pyViz/GFEPainter.py +++ b/cave/build/static/common/cave/etc/pyViz/GFEPainter.py @@ -68,6 +68,7 @@ class GFEPainter(VizPainter.VizPainter): envelope = self.dataMgr.getRefManager().loadRefSet(self.refId).overallDomain(CoordinateType.LATLON) geom = GfeImageUtil.getLocationGeometry(gloc, envelope, float(imageWidth), float(imageHeight), expandLeft / 100.0, expandRight / 100.0, expandTop / 100.0, expandBottom / 100.0) display = GFEMapRenderableDisplay(MapDescriptor(geom)) + display.setDataManager(self.dataMgr) desc = display.getDescriptor() self.dataMgr.getSpatialDisplayManager().setDescriptor(desc) VizPainter.VizPainter.__init__(self, display) diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java index 2797666c00..daa0efd8d1 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java @@ -167,7 +167,7 @@ public class CollaborationSessionView extends SessionView implements assigned = assignLayer(); } if (assigned) { - updateToolItem(); + updateToolItems(); } } @@ -224,7 +224,7 @@ public class CollaborationSessionView extends SessionView implements } else { layer.setDrawMode(DrawMode.DRAW); } - updateToolItem(); + updateToolItems(); } }); drawAction.getAction().setImageDescriptor( @@ -236,7 +236,7 @@ public class CollaborationSessionView extends SessionView implements @Override public void run() { layer.undo(); - updateToolItem(); + updateToolItems(); } }); undoAction.getAction().setImageDescriptor( @@ -248,7 +248,7 @@ public class CollaborationSessionView extends SessionView implements @Override public void run() { layer.redo(); - updateToolItem(); + updateToolItems(); } }); redoAction.getAction().setImageDescriptor( @@ -265,7 +265,7 @@ public class CollaborationSessionView extends SessionView implements } else { layer.setDrawMode(DrawMode.ERASE); } - updateToolItem(); + updateToolItems(); } }); eraseAction.getAction().setImageDescriptor( @@ -276,7 +276,7 @@ public class CollaborationSessionView extends SessionView implements clearAction = new ActionContributionItem(new Action("Clear") { public void run() { layer.clear(); - updateToolItem(); + updateToolItems(); }; }); clearAction.getAction().setImageDescriptor( @@ -289,7 +289,7 @@ public class CollaborationSessionView extends SessionView implements public void run() { resource.setLockingDrawing(((ToolItem) lockAction.getWidget()) .getSelection()); - updateToolItem(); + updateToolItems(); }; }); lockAction.getAction().setImageDescriptor( @@ -307,7 +307,7 @@ public class CollaborationSessionView extends SessionView implements mgr.insert(mgr.getSize() - 1, new Separator()); } - private void updateToolItem() { + public void updateToolItems() { boolean assigned = true; if (layer == null) { assigned = assignLayer(); @@ -445,7 +445,7 @@ public class CollaborationSessionView extends SessionView implements clearAction.getAction().setEnabled(false); eraseAction.getAction().setEnabled(false); } else { - updateToolItem(); + updateToolItems(); } } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/handlers/UndoRedoHandler.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/handlers/UndoRedoHandler.java index e0a21f3dbd..850ede7ecd 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/handlers/UndoRedoHandler.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/handlers/UndoRedoHandler.java @@ -19,11 +19,20 @@ **/ package com.raytheon.uf.viz.collaboration.ui.telestrator.handlers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.handlers.HandlerUtil; +import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView; import com.raytheon.uf.viz.collaboration.ui.telestrator.CollaborationDrawingResource; +import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.uf.viz.drawing.DrawingToolLayer; import com.raytheon.viz.ui.EditorUtil; @@ -62,18 +71,45 @@ public class UndoRedoHandler extends AbstractHandler { */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { - CollaborationDrawingResource resource = (CollaborationDrawingResource) EditorUtil - .getActiveEditorAs(IDisplayPaneContainer.class) - .getActiveDisplayPane().getDescriptor().getResourceList() - .getResourcesByTypeAsType(CollaborationDrawingResource.class) - .get(0); - DrawingToolLayer layer = resource.getDrawingLayerFor(resource - .getMyUser()); - String action = event.getParameter(ACTION_ID); - if (UNDO_ID.equals(action)) { - layer.undo(); - } else if (REDO_ID.equals(action)) { - layer.redo(); + IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); + if (window != null) { + IDisplayPaneContainer container = EditorUtil.getActiveEditorAs( + window, IDisplayPaneContainer.class); + if (container != null) { + Map viewMap = new HashMap(); + for (IViewReference view : window.getActivePage() + .getViewReferences()) { + if (CollaborationSessionView.ID.equals(view.getId())) { + CollaborationSessionView csv = (CollaborationSessionView) view + .getPart(false); + viewMap.put(csv.getSessionId(), csv); + } + } + + for (IDisplayPane pane : container.getDisplayPanes()) { + List resources = pane + .getDescriptor() + .getResourceList() + .getResourcesByTypeAsType( + CollaborationDrawingResource.class); + for (CollaborationDrawingResource resource : resources) { + DrawingToolLayer layer = resource + .getDrawingLayerFor(resource.getMyUser()); + String action = event.getParameter(ACTION_ID); + if (UNDO_ID.equals(action)) { + layer.undo(); + } else if (REDO_ID.equals(action)) { + layer.redo(); + } + CollaborationSessionView view = viewMap.get(resource + .getResourceData().getSessionId()); + if (view != null) { + view.updateToolItems(); + } + } + } + } + } return null; } diff --git a/cave/com.raytheon.viz.gfe/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/cave/com.raytheon.viz.gfe/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject index cabd07b374..9bdfe2ec83 100644 --- a/cave/com.raytheon.viz.gfe/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ b/cave/com.raytheon.viz.gfe/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -1,5 +1,6 @@ com.raytheon.viz.gfe.core.GFEMapRenderableDisplay com.raytheon.viz.gfe.rsc.GFELegendResourceData +com.raytheon.viz.gfe.rsc.GFEResourceData com.raytheon.uf.common.site.xml.AdjacentWfoXML com.raytheon.uf.common.site.xml.CwaXML com.raytheon.viz.gfe.textformatter.CombinationsFileUtil$ComboData diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFEMapRenderableDisplay.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFEMapRenderableDisplay.java index 325deb4f6f..5cf9fc03a0 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFEMapRenderableDisplay.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFEMapRenderableDisplay.java @@ -25,9 +25,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; - import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.drawables.PaintProperties; @@ -73,19 +70,20 @@ public class GFEMapRenderableDisplay extends PlainMapRenderableDisplay private DataManager dataMgr; - @SuppressWarnings("unchecked") public GFEMapRenderableDisplay() { - super(); - dataMgr = DataManager.getCurrentInstance(); - dataMgr.getSpatialDisplayManager().addSpatialEditorTimeChangedListener( - this); - Message.registerInterest(this, ShowQuickViewDataMsg.class); + } + + public GFEMapRenderableDisplay(MapDescriptor desc) { + super(desc); } @SuppressWarnings("unchecked") - public GFEMapRenderableDisplay(MapDescriptor desc) { - super(desc); - dataMgr = DataManager.getCurrentInstance(); + public void setDataManager(DataManager dataManager) { + if (this.dataMgr != null) { + dataMgr.getSpatialDisplayManager() + .removeSpatialEditorTimeChangedListener(this); + } + dataMgr = dataManager; dataMgr.getSpatialDisplayManager().addSpatialEditorTimeChangedListener( this); Message.registerInterest(this, ShowQuickViewDataMsg.class); @@ -118,15 +116,11 @@ public class GFEMapRenderableDisplay extends PlainMapRenderableDisplay @Override protected PaintProperties calcPaintDataTime(PaintProperties paintProps, AbstractVizResource rsc) { - IWorkbenchWindow window = null; - if (container != null) { - window = ((IWorkbenchPart) container).getSite() - .getWorkbenchWindow(); + if (dataMgr != null) { + Date date = dataMgr.getSpatialDisplayManager() + .getSpatialEditorTime(); + paintProps.setDataTime(new DataTime(date)); } - Date date = DataManager.getInstance(window).getSpatialDisplayManager() - .getSpatialEditorTime(); - - paintProps.setDataTime(new DataTime(date)); GFEPaintProperties gfeProps = new GFEPaintProperties(paintProps); if (qvTime != null) { diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/perspective/GFEPerspectiveManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/perspective/GFEPerspectiveManager.java index e53065865a..638e528a2e 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/perspective/GFEPerspectiveManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/perspective/GFEPerspectiveManager.java @@ -49,6 +49,7 @@ import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.PixelExtent; +import com.raytheon.uf.viz.core.drawables.IRenderableDisplay; import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.map.IMapDescriptor; @@ -57,6 +58,7 @@ import com.raytheon.viz.gfe.Activator; import com.raytheon.viz.gfe.PythonPreferenceStore; import com.raytheon.viz.gfe.actions.FormatterlauncherAction; import com.raytheon.viz.gfe.core.DataManager; +import com.raytheon.viz.gfe.core.GFEMapRenderableDisplay; import com.raytheon.viz.gfe.core.ISpatialDisplayManager; import com.raytheon.viz.gfe.core.internal.GFESpatialDisplayManager; import com.raytheon.viz.gfe.procedures.ProcedureJob; @@ -128,7 +130,10 @@ public class GFEPerspectiveManager extends AbstractCAVEPerspectiveManager { defineKeys(); DataManager dm = DataManager.getInstance(perspectiveWindow); - + IRenderableDisplay display = pane.getRenderableDisplay(); + if (display instanceof GFEMapRenderableDisplay) { + ((GFEMapRenderableDisplay) display).setDataManager(dm); + } // Add GFE Legend try { ResourcePair legend = ResourcePair diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEResourceData.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEResourceData.java index 4bfe6d11b4..939927a27b 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEResourceData.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEResourceData.java @@ -19,6 +19,9 @@ **/ package com.raytheon.viz.gfe.rsc; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; + import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.rsc.AbstractResourceData; @@ -40,7 +43,7 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties; * @author chammack * @version 1.0 */ - +@XmlAccessorType(XmlAccessType.NONE) public class GFEResourceData extends AbstractResourceData { @Override