/*
* 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.popupmenu;
import java.util.logging.Logger;
import javax.swing.Action;
import javax.swing.JButton;
import org.geoforge.guillc.menuitem.GfrMimActPlg;
import org.geoforge.guillc.menuitem.GfrMimAbs;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mgrplg.handler.IGfrHandlerPlugin;
import org.geoforge.mgrplg.handler.IGfrHandlerPluginActionsDspWwdEarthSel;
/**
*
* @author bantchao
*/
abstract public class GfrPmuBtnPlgsActDspWwdEarthSelAbs extends GfrPmuBtnPlgsActAbs
{
final private static Logger _LOGGER_ = Logger.getLogger(GfrPmuBtnPlgsActDspWwdEarthSelAbs.class.getName());
static
{
GfrPmuBtnPlgsActDspWwdEarthSelAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// ---
protected GfrPmuBtnPlgsActDspWwdEarthSelAbs(JButton btnOwner)
{
super(btnOwner);
}
@Override
protected void _add(IGfrHandlerPlugin plg)
{
if (! (plg instanceof IGfrHandlerPluginActionsDspWwdEarthSel))
return;
if (! plg.isValidPlugin())
return;
if (_addValidated((IGfrHandlerPluginActionsDspWwdEarthSel) plg))
{
if (! super._btnOwner.isEnabled())
super._btnOwner.setEnabled(true);
}
}
protected boolean _addValidated(IGfrHandlerPluginActionsDspWwdEarthSel plg)
{
try
{
Action[] acts = plg.createActionsPluginDisplayWwdEathSelector();
for (int i=0; i<acts.length; i++)
{
GfrMimAbs mimCur = new GfrMimActPlg(acts[i], plg);
if (! mimCur.init())
{
String strWhat = "! mimCur.init()";
throw new Exception(strWhat);
}
super.add(mimCur);
}
return true;
}
catch(Exception exc)
{
exc.printStackTrace();
String strWhat = exc.getMessage();
GfrPmuBtnPlgsActDspWwdEarthSelAbs._LOGGER_.warning(strWhat);
super._showDialogFailedPlugin(plg, strWhat);
return false;
}
catch(AbstractMethodError errAbstractMethod)
{
errAbstractMethod.printStackTrace();
String strWhat = errAbstractMethod.getMessage();
GfrPmuBtnPlgsActDspWwdEarthSelAbs._LOGGER_.warning(strWhat);
super._showDialogFailedPlugin(plg, strWhat);
return false;
}
}
}