/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.geoforge.plggazetteers.swing.dialog;
import java.awt.Container;
import java.awt.Point;
import java.util.HashSet;
import java.util.logging.Logger;
import javax.swing.JDesktopPane;
import org.geoforge.appogcecl.util.hashset.GfrHstFrmIntViewersPrsRun;
import org.geoforge.guillc.frame.GfrFrmAbs;
import org.geoforge.guillc.internalframe.GfrIfrWinViewRunAbs;
import org.geoforge.guillc.internalframe.GfrIfrWinViewRunIdRegAbs;
import org.geoforge.guillc.internalframe.GfrIfrWinViewRunIdRegSerAppTopsWwdEarthAbs;
import org.geoforge.guillc.panel.GfrPnlStatusBarMain;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.plggazetteers.swing.panel.PnlContentsGazetteerYahooSec;
/**
*
* @author bantchao
*/
public class GfrDlgCmdCancelGazetteerYahooSec extends GfrDlgCmdCancelGazetteerYahooAbs
{
final static private Logger _LOGGER_ = Logger.getLogger(GfrDlgCmdCancelGazetteerYahooSec.class.getName());
static
{
GfrDlgCmdCancelGazetteerYahooSec._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
static protected String _s_getNameViewer(String strIdViewer)
{
HashSet<GfrIfrWinViewRunAbs> hstIfr = GfrHstFrmIntViewersPrsRun.s_getInstance().get();
if (hstIfr==null || hstIfr.isEmpty())
{
// tbrls !!!
return "[no name]";
}
for (GfrIfrWinViewRunAbs ifrCur: hstIfr)
{
if (! (ifrCur instanceof GfrIfrWinViewRunIdRegSerAppTopsWwdEarthAbs))
continue;
if (ifrCur.isIcon()) // by-pass
continue;
GfrIfrWinViewRunIdRegAbs ifrId = (GfrIfrWinViewRunIdRegAbs) ifrCur;
String strIdCur = ifrId.getUniqueId();
if (strIdCur.compareTo(strIdViewer) != 0)
continue;
return ifrId.getUniqueName();
}
// tbrls !!!
return "[no name]";
}
/*
* trick, just getting location of desktopPane
* first internalFrame is OK
*
* for now, just pointing to processPanel's location
* ==> maybe in the future: synchronize
*/
static protected Point _s_getLocationOwner(
String strIdViewer // not yet in use
)
{
Point pntLocationMainFrame = GfrFrmAbs.s_getFrameOwner(GfrPnlStatusBarMain.s_getInstance()).getLocation();
HashSet<GfrIfrWinViewRunAbs> hst = GfrHstFrmIntViewersPrsRun.s_getInstance().get();
if (hst==null || hst.isEmpty())
{
String strError = "hst==null || hst.isEmpty(), returning pntLocationMainFrame";
GfrDlgCmdCancelGazetteerYahooSec._LOGGER_.severe(strError);
return pntLocationMainFrame;
}
for (GfrIfrWinViewRunAbs ifrCur: hst)
{
Container cntParent = ifrCur.getParent();
if (cntParent == null)
continue;
if (! (cntParent instanceof JDesktopPane))
{
String strWarning = "! (cntParent instanceof JDesktopPane), cntParent.getClass().toString()=" + cntParent.getClass().toString();
GfrDlgCmdCancelGazetteerYahooSec._LOGGER_.warning(strWarning);
continue;
}
Container cntGrandParent = cntParent.getParent();
int intX = pntLocationMainFrame.x;
intX += cntGrandParent.getLocation().x;
int intY = pntLocationMainFrame.y;
intY += cntGrandParent.getLocation().y;
Point pntResult = new Point(intX, intY);
return pntResult;
}
// ---
String strError = "Failed to get ifr owner, returning pntLocationMainFrame";
GfrDlgCmdCancelGazetteerYahooSec._LOGGER_.severe(strError);
return pntLocationMainFrame;
}
public GfrDlgCmdCancelGazetteerYahooSec(String strIdViewer)
{
super(
GfrDlgCmdCancelGazetteerYahooSec._s_getLocationOwner(strIdViewer)
);
super.setTitle(super.getTitle() + " - " + GfrDlgCmdCancelGazetteerYahooSec._s_getNameViewer(strIdViewer));
super._pnlContents = new PnlContentsGazetteerYahooSec(strIdViewer);
}
}