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.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.handlers.HandlerUtil; 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.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay; 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.uf.viz.kml.export.KmlExportOptions.KmlExportTimeMode;
import com.raytheon.viz.ui.EditorUtil; import com.raytheon.viz.ui.EditorUtil;
@ -46,13 +45,15 @@ import com.raytheon.viz.ui.EditorUtil;
* Date Ticket# Engineer Description * 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> * </pre>
* *
* @author bsteffen * @author bsteffen
* @version 1.0 * @version 1.0
*/ */
public class KmlExportHandler extends AbstractHandler { public class KmlExportHandler extends AbstractMapHandler {
@Override @Override
public Object execute(ExecutionEvent event) throws ExecutionException { public Object execute(ExecutionEvent event) throws ExecutionException {
@ -85,19 +86,4 @@ public class KmlExportHandler extends AbstractHandler {
return options; 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; package com.raytheon.viz.bcd;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.SWT; 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.VizApp;
import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.map.IMapDescriptor; 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.MapResourceGroup;
import com.raytheon.uf.viz.core.maps.rsc.MapResourceGroupData; import com.raytheon.uf.viz.core.maps.rsc.MapResourceGroupData;
import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.ProgressiveDisclosureProperties; import com.raytheon.uf.viz.core.rsc.ProgressiveDisclosureProperties;
import com.raytheon.uf.viz.core.rsc.ResourceList; import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.core.rsc.ResourceProperties; import com.raytheon.uf.viz.core.rsc.ResourceProperties;
import com.raytheon.uf.viz.core.status.StatusConstants;
import com.raytheon.viz.ui.EditorUtil; import com.raytheon.viz.ui.EditorUtil;
/** /**
@ -55,15 +54,16 @@ import com.raytheon.viz.ui.EditorUtil;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Sep 24, 2007 377 randerso Initial Creation. * Sep 24, 2007 377 randerso Initial Creation.
* * Nov 13, 2012 #1326 randerso Changed to extend AbstractMapHandler
* </pre> * </pre>
* *
* @author randerso * @author randerso
* @version 1 * @version 1
* *
*/ */
public class OpenBCDHandler extends AbstractHandler { public class OpenBCDHandler extends AbstractMapHandler {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(OpenBCDHandler.class); private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(OpenBCDHandler.class);
/* /*
* (non-Javadoc) * (non-Javadoc)

View file

@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.viz.core, com.raytheon.viz.core,
org.geotools, org.geotools,
com.raytheon.viz.ui, 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-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: com.raytheon.viz.geotiff.rsc Export-Package: com.raytheon.viz.geotiff.rsc

View file

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

View file

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

View file

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