/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.geoforge.guillcogcecl.wwd.util;
import gov.nasa.worldwind.avlist.AVList;
import gov.nasa.worldwind.event.SelectEvent;
import java.awt.Component;
import java.awt.event.ActionListener;
import java.util.logging.Logger;
import org.geoforge.guillc.popupmenu.GfrPmuCtlDspWwdAbs;
import org.geoforge.guillcogcecl.popupmenu.*;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.worldwind.handler.IGfrHandlerWwdEarthObjectGeoforgeAbs;
import org.geoforge.worldwind.render.GfrKeysRnd;
import org.geoforge.worldwind.util.GfrCtrMenContextObjectAbs;
import org.geoforge.worldwindecl.render.*;
/**
*
* @author robert
*/
public class GfrCtrMenContextObjectMainOgcEcl extends GfrCtrMenContextObjectAbs
{
// ----
// begin: instantiate logger for this class
final private static Logger _LOGGER_ = Logger.getLogger(GfrCtrMenContextObjectMainOgcEcl.class.getName());
static
{
GfrCtrMenContextObjectMainOgcEcl._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// end: instantiate logger for this class
// ----
protected String _strValueKindTargetWindow = null;
public GfrCtrMenContextObjectMainOgcEcl(ActionListener alrController,
String strValueKindTargetWindow)
{
super(alrController);
this._strValueKindTargetWindow = strValueKindTargetWindow;
}
@Override
protected void _showContextextualMenu(SelectEvent evt) throws Exception
{
Object objTopWwd = evt.getTopObject();
if (!(objTopWwd instanceof AVList))
return;
AVList lstTopWwd = (AVList) objTopWwd;
Object objHasContext = lstTopWwd.getValue(GfrKeysRnd.STR_HAS_CONTEXTUAL_MENU);
if (objHasContext == null)
return;
Boolean booHasContextMenu = (Boolean) objHasContext;
if (!booHasContextMenu.booleanValue())
return;
GfrPmuCtlDspWwdAbs pop = null;
if (lstTopWwd instanceof GfrRndSurfaceSectorTloSct)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclSct(super._alrController, strId, this._strValueKindTargetWindow);
}
else if (lstTopWwd instanceof GfrRndSurfacePolygonTloAre)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclAre(super._alrController, strId, this._strValueKindTargetWindow);
}
else if (lstTopWwd instanceof GfrRndSurfacePolylineWisNoTloPth)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclPth(super._alrController, strId, this._strValueKindTargetWindow);
}
else if (lstTopWwd instanceof GfrRndSurfaceSegmentWiseYesTloEcl)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclSegWiseYes(super._alrController, strId, this._strValueKindTargetWindow);
}
else if (lstTopWwd instanceof GfrRndPointPlacemarkPushpinTloPlc)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclPlc(super._alrController, strId, this._strValueKindTargetWindow);
}
else if (lstTopWwd instanceof GfrRndPointPlacemarkCircleLloSpn)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclSpn(super._alrController, strId, this._strValueKindTargetWindow);
}
else if (lstTopWwd instanceof GfrRndPointPlacemarkCircleTloPnt)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclPnt(super._alrController, strId, this._strValueKindTargetWindow);
}
else
{
String str = "uncaught instanceof: " + lstTopWwd.getClass().toString();
GfrCtrMenContextObjectMainOgcEcl._LOGGER_.severe(str);
throw new Exception(str);
}
if (!pop.init())
{
String str = "! pop.init()";
GfrCtrMenContextObjectMainOgcEcl._LOGGER_.severe(str);
throw new Exception(str);
}
Component cmpSource = (Component) evt.getSource();
pop.show(cmpSource, evt.getMouseEvent().getX(), evt.getMouseEvent().getY());
}
}