diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/actions/ClearAction.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/actions/ClearAction.java index 5df6c34b9f..37aa7319b3 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/actions/ClearAction.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/actions/ClearAction.java @@ -32,10 +32,12 @@ import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.globals.VizGlobalsManager; +import com.raytheon.uf.viz.core.maps.display.VizMapEditor; import com.raytheon.uf.viz.core.status.StatusConstants; import com.raytheon.uf.viz.d2d.ui.Activator; import com.raytheon.viz.ui.EditorUtil; import com.raytheon.viz.ui.HistoryList; +import com.raytheon.viz.ui.editor.AbstractEditor; import com.raytheon.viz.ui.editor.IMultiPaneEditor; /** @@ -60,7 +62,8 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor; * @version 1 */ public class ClearAction extends AbstractHandler { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(ClearAction.class); + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(ClearAction.class); @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { @@ -69,15 +72,14 @@ public class ClearAction extends AbstractHandler { new NewMapEditor().execute(null); return null; } - - if (!(part instanceof IDisplayPaneContainer)) { - return null; - } - try { - HistoryList.getInstance().refreshLatestBundle(); - clear((IDisplayPaneContainer) part); - HistoryList.getInstance().addBundle(); + if (part instanceof IDisplayPaneContainer) { + HistoryList.getInstance().refreshLatestBundle(); + clear(part); + HistoryList.getInstance().addBundle(); + } else { + clear(part); + } } catch (VizException e) { throw new ExecutionException("Error during clear", e); } @@ -85,26 +87,19 @@ public class ClearAction extends AbstractHandler { return null; } - /** - * Clears the map - * - * The map is cleared with either the provided default-procedure.xml or a - * default world map, if no default-bundle.xml is available. - * - * @param target - * the graphics target - * @return the map descriptor prepared - * @throws VizException - */ - public static void clear(IDisplayPaneContainer container) - throws VizException { - if (container instanceof IMultiPaneEditor) { - ((IMultiPaneEditor) container).clear(); + public static void clear(IEditorPart part) throws VizException { + if (part instanceof VizMapEditor) { + ((VizMapEditor) part).clear(); + } else if (part instanceof AbstractEditor) { + // AbstractEditor asks the user if they are sure if we pass in + // save=true, if the user clicked clear than they must be sure so + // pass in save=false. + part.getSite().getPage().closeEditor(part, false); } else { - for (IDisplayPane displayPane : container.getDisplayPanes()) { - displayPane.clear(); - } + // Give other editors a chance to save. + part.getSite().getPage().closeEditor(part, true); } + if (EditorUtil.getActiveEditor() == null) { try { new NewMapEditor().execute(null);