/*
* Copyright (C) 2011-2014 GeoForge Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.geoforge.guillc.menuitem;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Logger;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.guillc.frame.GfrFrmAbs;
import org.geoforge.awt.image.GfrFactoryIconAbs;
import org.geoforge.io.awt.image.GfrFactoryIconAppGfr;
import org.geoforge.lang.util.GfrResBundleLang;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*/
public class GfrMimAlrPrintFrame extends GfrMimAlrAbs implements
ActionListener
{
// ----
// begin: instantiate logger for this class
final static private Logger _LOGGER_ = Logger.getLogger(GfrMimAlrPrintFrame.class.getName());
static
{
GfrMimAlrPrintFrame._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// end: instantiate logger for this class
// ----
/**
*
*/
private static final long serialVersionUID = 1L;
// ------
// public
public GfrMimAlrPrintFrame()
{
super(GfrResBundleLang.s_getInstance().getValue("verb.print"),
(ActionListener) null,
GfrFactoryIconAppGfr.s_getPrintAll(GfrMimAbs._INT_SIZE_ICON));
super.addActionListener((ActionListener) this);
}
@Override
public void destroy()
{
super.destroy();
super.removeActionListener((ActionListener) this);
}
@Override
public void actionPerformed(ActionEvent arg0)
{
// memo: bug ig ~JMenuItem.getRootPane();
JPopupMenu pop = (JPopupMenu) GfrMimAlrPrintFrame.this.getParent();
JMenuItem mim = (JMenuItem)pop.getInvoker();
GfrFrmAbs frm = (GfrFrmAbs) GfrFrmAbs.s_getFrameOwner(mim);
if (frm != null)
{
if (! frm.doPrint())
{
String str = "! frm.doPrint()";
GfrMimAlrPrintFrame._LOGGER_.warning(str);
GfrOptionPaneAbs.s_showDialogWarning(frm, str);
}
}
else
{
String str = "frm = null";
GfrMimAlrPrintFrame._LOGGER_.warning(str);
GfrOptionPaneAbs.s_showDialogWarning(frm, str);
}
}
}