Package org.geoforge.guillc.menu

Source Code of org.geoforge.guillc.menu.GfrMenPlgsSpotActNewViewerRunAbs

/*
* 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.menu;

import java.awt.Container;
import java.util.logging.Logger;
import javax.swing.Action;
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.IGfrHandlerPluginActionDspNewViewerRun;


/**
*
* @author robert
*/
abstract public class GfrMenPlgsSpotActNewViewerRunAbs extends GfrMenPlgsSpotActAbs
{
   // ----
    // begin: instantiate logger for this class
    final private static Logger _LOGGER_ = Logger.getLogger(GfrMenPlgsSpotActNewViewerRunAbs.class.getName());

    static
    {
        GfrMenPlgsSpotActNewViewerRunAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
    }
   
    // ---
   
    private Container _cntDesktopPane_ = null;
  
   protected GfrMenPlgsSpotActNewViewerRunAbs(Container cntDesktopPane)
   {
      super();
     
      this._cntDesktopPane_ = cntDesktopPane;
   }
  
  

   @Override
   protected void _add(IGfrHandlerPlugin plg)
   {
      if (! (plg instanceof IGfrHandlerPluginActionDspNewViewerRun))
        return;
     
      if (! plg.isValidPlugin())
            return;
     
      if (_add_((IGfrHandlerPluginActionDspNewViewerRun) plg))
      {
         if (! super.isEnabled())
            super.setEnabled(true);
      }
   }
  
   protected boolean _add_(IGfrHandlerPluginActionDspNewViewerRun plg)
   {
      try
      {
        
         Action act = plg.createActionPluginNewViewerRunFromDisplay(this._cntDesktopPane_);
         GfrMimAbs mim = new GfrMimActPlg(act, plg);

         if (! mim.init())
         {
            String strWhat = "! mim.init()";
            GfrMenPlgsSpotActNewViewerRunAbs._LOGGER_.warning(strWhat);
            super._showDialogFailedPlugin(plg, strWhat);
            return false;
         }

         super.add(mim);
         return true;
      }

      catch(Exception exc)
      {
         exc.printStackTrace();
         String strWhat = exc.getMessage();
         GfrMenPlgsSpotActNewViewerRunAbs._LOGGER_.warning(strWhat);
         super._showDialogFailedPlugin(plg, strWhat);
         return false;
      }

      catch(AbstractMethodError errAbstractMethod)
      {
         errAbstractMethod.printStackTrace();
         String strWhat = errAbstractMethod.getMessage();
         GfrMenPlgsSpotActNewViewerRunAbs._LOGGER_.warning(strWhat);
         super._showDialogFailedPlugin(plg, strWhat);
         return false;
      }
   }
}
TOP

Related Classes of org.geoforge.guillc.menu.GfrMenPlgsSpotActNewViewerRunAbs

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.