Issue #1131 Change behavior of Clear Action in D2D to always close Non-map editors

Change-Id: I4ad0516be0fc72111d91f50bcf099a45ec0d38f8

Former-commit-id: 513bd44ba0 [formerly dc6f5805ef] [formerly 4272f4c885] [formerly c618ee9057 [formerly 4272f4c885 [formerly 5da7b54e1bff66ed46400bc624b9d881d0b967ce]]]
Former-commit-id: c618ee9057
Former-commit-id: 1e8fa5942894142a7af4316bb2f69d7081706dc3 [formerly e0a4fe2c43]
Former-commit-id: 66e9b24e51
This commit is contained in:
Ben Steffensmeier 2012-09-04 13:40:42 -05:00
parent 20e088a957
commit 49524b9109

View file

@ -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);