Issue #2400 fix so active map editor is used if applicable

Change-Id: I642edc1bdc94eac871a07c26e900c2431f567ab1

Former-commit-id: 563212924964f8ca66cba789d7867b19c68d0682
This commit is contained in:
Nate Jensen 2013-09-30 11:47:26 -05:00
parent 9c02d45802
commit c1dd4b40fb

View file

@ -46,6 +46,7 @@ import com.raytheon.viz.ui.EditorUtil;
* Feb 15, 2011 7975 bkowal Restore the DistanceSpeedLayer
* associated with the Display Pane.
* Aug 30, 2013 2310 bsteffen Ensure tool is used on a map editor.
* Sep 30, 2013 2400 njensen Ensure tool opens on the active map editor if applicable
*
* </pre>
*
@ -58,11 +59,19 @@ public class DistanceSpeedAction extends
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
IEditorPart editorPart = EditorUtil.findEditor(VizMapEditor.EDITOR_ID);
if (editorPart == null) {
new NewMapEditor().execute(arg0);
} else {
IEditorPart editorPart = EditorUtil.getActiveEditor();
if (editorPart != null && editorPart instanceof VizMapEditor) {
// if the current editor is a map, use that one
editorPart.getSite().getPage().bringToTop(editorPart);
} else {
// find any map editor that's open
editorPart = EditorUtil.findEditor(VizMapEditor.EDITOR_ID);
if (editorPart == null) {
// no map editor open, make a new one
new NewMapEditor().execute(arg0);
} else {
editorPart.getSite().getPage().bringToTop(editorPart);
}
}
return super.execute(arg0);
}