Issue #1395 Factored out AbstractMapHandler pattern

Change-Id: I24e9e12f10742292b04dbf31571f0adfe24e35cd

Former-commit-id: 522b3bd9cc24c1d75fe5fbdf6222e72ffb8a8468
This commit is contained in:
Ron Anderson 2012-12-06 15:18:49 -06:00
parent 0aa3a3d1cb
commit 91f8c043e1
7 changed files with 89 additions and 36 deletions

View file

@ -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.uf.viz.core.maps.actions;
import org.eclipse.core.commands.AbstractHandler;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.maps.display.MapRenderableDisplay;
import com.raytheon.viz.ui.EditorUtil;
/**
* Abstract handler for actions that only apply to Map Editors. Disables itself
* if the current editor is not a map editor.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 13, 2012 #1326 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public abstract class AbstractMapHandler extends AbstractHandler {
@Override
public void setEnabled(Object evaluationContext) {
IDisplayPaneContainer container = EditorUtil.getActiveVizContainer();
if (container == null) {
super.setBaseEnabled(false);
return;
}
IDisplayPane pane = container.getActiveDisplayPane();
if (pane == null) {
super.setBaseEnabled(false);
return;
}
super.setBaseEnabled(pane.getRenderableDisplay() instanceof MapRenderableDisplay);
}
}

View file

@ -23,7 +23,6 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.handlers.HandlerUtil;
@ -31,7 +30,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay;
import com.raytheon.uf.viz.core.maps.display.MapRenderableDisplay;
import com.raytheon.uf.viz.core.maps.actions.AbstractMapHandler;
import com.raytheon.uf.viz.kml.export.KmlExportOptions.KmlExportTimeMode;
import com.raytheon.viz.ui.EditorUtil;
@ -45,14 +44,16 @@ import com.raytheon.viz.ui.EditorUtil;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 1, 2012 bsteffen Initial creation
* Jun 1, 2012 bsteffen Initial creation
* Nov 13, 2012 #1326 randerso Moved setEnabled method into
* AbstractMapHandler for reuse
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class KmlExportHandler extends AbstractHandler {
public class KmlExportHandler extends AbstractMapHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
@ -85,19 +86,4 @@ public class KmlExportHandler extends AbstractHandler {
return options;
}
@Override
public void setEnabled(Object evaluationContext) {
IDisplayPaneContainer container = EditorUtil.getActiveVizContainer();
if (container == null) {
super.setBaseEnabled(false);
return;
}
IDisplayPane pane = container.getActiveDisplayPane();
if (pane == null) {
super.setBaseEnabled(false);
return;
}
super.setBaseEnabled(pane.getRenderableDisplay() instanceof MapRenderableDisplay);
}
}

View file

@ -20,7 +20,6 @@
package com.raytheon.viz.bcd;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.SWT;
@ -37,13 +36,13 @@ import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.maps.actions.AbstractMapHandler;
import com.raytheon.uf.viz.core.maps.rsc.MapResourceGroup;
import com.raytheon.uf.viz.core.maps.rsc.MapResourceGroupData;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.ProgressiveDisclosureProperties;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
import com.raytheon.uf.viz.core.status.StatusConstants;
import com.raytheon.viz.ui.EditorUtil;
/**
@ -55,15 +54,16 @@ import com.raytheon.viz.ui.EditorUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 24, 2007 377 randerso Initial Creation.
*
* Nov 13, 2012 #1326 randerso Changed to extend AbstractMapHandler
* </pre>
*
* @author randerso
* @version 1
*
*/
public class OpenBCDHandler extends AbstractHandler {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(OpenBCDHandler.class);
public class OpenBCDHandler extends AbstractMapHandler {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(OpenBCDHandler.class);
/*
* (non-Javadoc)

View file

@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.viz.core,
org.geotools,
com.raytheon.viz.ui,
org.apache.commons.lang
org.apache.commons.lang,
com.raytheon.uf.viz.core.maps;bundle-version="1.12.1174"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: com.raytheon.viz.geotiff.rsc

View file

@ -22,7 +22,6 @@ package com.raytheon.viz.geotiff.ui;
import java.io.File;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Status;
@ -34,6 +33,7 @@ import org.eclipse.ui.PlatformUI;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.maps.actions.AbstractMapHandler;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.ProgressiveDisclosureProperties;
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
@ -56,7 +56,7 @@ import com.raytheon.viz.ui.EditorUtil;
* @author chammack
* @version 1
*/
public class OpenImageAction extends AbstractHandler {
public class OpenImageAction extends AbstractMapHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
@ -76,6 +76,7 @@ public class OpenImageAction extends AbstractHandler {
+ fd.getFileName();
VizApp.runAsync(new Runnable() {
@Override
public void run() {
try {
IDescriptor mapDesc = container.getActiveDisplayPane()

View file

@ -20,7 +20,6 @@
package com.raytheon.viz.lpi;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Status;
@ -37,12 +36,12 @@ import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.maps.actions.AbstractMapHandler;
import com.raytheon.uf.viz.core.maps.rsc.MapResourceGroup;
import com.raytheon.uf.viz.core.maps.rsc.MapResourceGroupData;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.ProgressiveDisclosureProperties;
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
import com.raytheon.uf.viz.core.status.StatusConstants;
import com.raytheon.viz.ui.EditorUtil;
/**
@ -54,15 +53,16 @@ import com.raytheon.viz.ui.EditorUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 24, 2007 377 randerso Initial Creation.
*
* Nov 13, 2012 #1326 randerso Changed to extend AbstractMapHandler
* </pre>
*
* @author randerso
* @version 1
*
*/
public class OpenLPIHandler extends AbstractHandler {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(OpenLPIHandler.class);
public class OpenLPIHandler extends AbstractMapHandler {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(OpenLPIHandler.class);
/*
* (non-Javadoc)

View file

@ -20,7 +20,6 @@
package com.raytheon.viz.spi;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Status;
@ -37,12 +36,12 @@ import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.maps.actions.AbstractMapHandler;
import com.raytheon.uf.viz.core.maps.rsc.MapResourceGroup;
import com.raytheon.uf.viz.core.maps.rsc.MapResourceGroupData;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.ProgressiveDisclosureProperties;
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
import com.raytheon.uf.viz.core.status.StatusConstants;
import com.raytheon.viz.ui.EditorUtil;
/**
@ -54,6 +53,7 @@ import com.raytheon.viz.ui.EditorUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 10, 2008 562 bphillip Initial Creation.
* Nov 13, 2012 #1326 randerso Changed to extend AbstractMapHandler
*
* </pre>
*
@ -61,8 +61,9 @@ import com.raytheon.viz.ui.EditorUtil;
* @version 1
*
*/
public class OpenSPIHandler extends AbstractHandler {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(OpenSPIHandler.class);
public class OpenSPIHandler extends AbstractMapHandler {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(OpenSPIHandler.class);
/*
* (non-Javadoc)