Package org.geoforge.mdldspgsi.plugin

Source Code of org.geoforge.mdldspgsi.plugin.GfrMdlDspPlgGsi

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.geoforge.mdldspgsi.plugin;

import java.io.File;
import org.geoforge.mdldsp.event.plugin.EvtMdlDspPlgAdded;
import org.geoforge.mdldsp.event.plugin.EvtMdlDspPlgRemoved;
import org.geoforge.mdldsp.plugin.GfrMdlDspPlgAbs;
import org.geoforge.mgrplg.handler.IGfrHandlerLicensingPlugin;
import org.geoforge.mgrplg.handler.IGfrHandlerPlugin;
import org.geoforge.mgrplggsi.GfrPluginManagerUtilGsi;
import org.geoforge.wrpbasusr.GfrWrpUsrSpcDspPrtAppRoot;

/**
*
* @author robert
*/
public class GfrMdlDspPlgGsi extends GfrMdlDspPlgAbs
{
   static private GfrMdlDspPlgGsi _INSTANCE_;
  
   static public GfrMdlDspPlgGsi getInstance()
   {
      if (_INSTANCE_ == null)
      {
         _INSTANCE_ = new GfrMdlDspPlgGsi();
      }
      return _INSTANCE_;
   }
  
   // ---
  
   // ---
   /*
    * what about existing internal frames?
    * ==> taking care in calling method
    */
   @Override
   public boolean removeAll() throws Exception
   {
      GfrWrpUsrSpcDspPrtAppRoot.getInstance().removeAllPluginLicenceDbRelatedRecordings();
      boolean bln = GfrPluginManagerUtilGsi.s_getInstance().removeAllPlugins();

      if (bln)
         super.removeAll();

      return bln;
   }
  
   @Override
   public IGfrHandlerPlugin add(File fleSource) throws Exception
   {
      IGfrHandlerPlugin plg = GfrPluginManagerUtilGsi.s_getInstance().addPlugin(fleSource);
     
      if (plg == null)
         return null;
     
      if (plg instanceof IGfrHandlerLicensingPlugin)
      {
         String strName = plg.getNamePlugin();
         String strVersion = plg.getVersionThisPlugin();

         GfrWrpUsrSpcDspPrtAppRoot.getInstance().addPluginLicenceDbRelatedRecordings(
               strName, strVersion);
      }
     
      // notify observers
      super.setChanged();
      Object obj = new EvtMdlDspPlgAdded(plg);
      super.notifyObservers(obj);
     
      return plg;
   }
  
   /*
    * what about existing internal frames?
    * ==> taking care in calling method
    */
   @Override
   public boolean remove(IGfrHandlerPlugin plg) throws Exception
   {
      if (plg instanceof IGfrHandlerLicensingPlugin)
      {
         String strVersion = plg.getVersionThisPlugin();
         String strName = plg.getNamePlugin();

         GfrWrpUsrSpcDspPrtAppRoot.getInstance().removePluginLicencedDbRelatedRecordings(
               strName,
               strVersion);
      }
     
      boolean bln = GfrPluginManagerUtilGsi.s_getInstance().removePlugin(plg)
     
      if (bln)
      {
         // notify observers
         super.setChanged();
         Object obj = new EvtMdlDspPlgRemoved(plg);
         super.notifyObservers(obj);
      }
     
      return bln;
   }
  
  
   // ---
   private GfrMdlDspPlgGsi()
   {
      super();
   }
}
TOP

Related Classes of org.geoforge.mdldspgsi.plugin.GfrMdlDspPlgGsi

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.