Package org.geoforge.mdldatogc.worldwind.thread

Source Code of org.geoforge.mdldatogc.worldwind.thread.GfrPgsThrOgcWmsLoad

/*
*  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 2
*  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, write to the Free Software
*  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

package org.geoforge.mdldatogc.worldwind.thread;


import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.util.Iterator;
import java.util.logging.Logger;
import javax.xml.stream.XMLStreamException;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldatogc.worldwind.capabilities.GfrCapWms;
import org.geoforge.worldwindogc.capabilities.GfrWMSCapabilities;
import org.geoforge.lang.util.eventobject.GfrEventObjectAbs;
import org.geoforge.worldwindogc.util.eventobject.GfrEventObjectLoadedCapWmsOgc;
import org.geoforge.lang.handler.IGfrHandlerEventListenerThreadJobProgress;
import org.geoforge.worldwindogc.thread.GfrPgsThrOgcWmsAbs;

/**
*
* @author bantchao
*/


public class GfrPgsThrOgcWmsLoad extends GfrPgsThrOgcWmsAbs
{

   // ----
   // begin: instantiate logger for this class
   final private static Logger _LOGGER_ = Logger.getLogger(GfrPgsThrOgcWmsLoad.class.getName());

   static
   {
      GfrPgsThrOgcWmsLoad._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
   }
   // end: instantiate logger for this class
   // ----

  
   public GfrPgsThrOgcWmsLoad(String strIdParent, IGfrHandlerEventListenerThreadJobProgress lst)
           throws Exception
   {
      super(strIdParent, lst);
   }


   @Override
   protected void _doJob()
   {
      try
      {
         if (! GfrCapWms.getInstance().isOpen())
         {
            if (super._listeners != null) // ???
               super._listeners.clear();
           
            return;
         }
        
         GfrWMSCapabilities capWms = GfrCapWms.getInstance().newObject(super._strIdParent, super._strUrlServerParent);

         if (capWms == null)
         {
            String strWarning = "Failed to get WMS capabilities";
            GfrPgsThrOgcWmsLoad._LOGGER_.warning(strWarning);
            super._strError = strWarning;
         }
      }
     
     catch(java.net.UnknownHostException excUnknownHost)
      {
         excUnknownHost.printStackTrace();
         String str = "Unknown host: " + excUnknownHost.getMessage();
         GfrPgsThrOgcWmsLoad._LOGGER_.severe(str);
         super._strError = str;
        
         // TODO: dialog choice for removing this WMS
         GfrPgsThrOgcWmsLoad._LOGGER_.warning("TODO: dialog choice for removing this WMS");
      }
     
      catch (URISyntaxException excURISyntax)
      {
         excURISyntax.printStackTrace();
         String str = excURISyntax.getMessage();
         GfrPgsThrOgcWmsLoad._LOGGER_.severe(str);
         super._strError = str;
        
         // TODO: dialog choice for removing this WMS
         GfrPgsThrOgcWmsLoad._LOGGER_.warning("TODO: dialog choice for removing this WMS");
      }
     
      catch (MalformedURLException excMalformedURL)
      {
         excMalformedURL.printStackTrace();
         String str = excMalformedURL.getMessage();
         GfrPgsThrOgcWmsLoad._LOGGER_.severe(str);
         super._strError = str;
        
         // TODO: dialog choice for removing this WMS
         GfrPgsThrOgcWmsLoad._LOGGER_.warning("TODO: parent - dialog choice for removing this WMS");
      }
     
      catch (XMLStreamException excXMLStream)
      {
         excXMLStream.printStackTrace();
         String str = excXMLStream.getMessage();
         GfrPgsThrOgcWmsLoad._LOGGER_.severe(str);
         super._strError = str;
        
         // TODO: dialog choice for removing this WMS
         GfrPgsThrOgcWmsLoad._LOGGER_.warning("TODO: children - dialog choice for removing this WMS");
      }
     
      catch(java.net.SocketException excSocket)
      {
         excSocket.printStackTrace();
         String str = excSocket.getMessage();
         GfrPgsThrOgcWmsLoad._LOGGER_.warning(str);
         super._strError = str;
        
         // TODO: dialog choice for removing this WMS
         GfrPgsThrOgcWmsLoad._LOGGER_.warning("TODO: children - dialog choice for removing this WMS");
      }
     
      catch (IOException excIO)
      {
         excIO.printStackTrace();
         String str = excIO.getMessage();
         GfrPgsThrOgcWmsLoad._LOGGER_.severe(str);
         super._strError = str;
        
         // TODO: dialog choice for removing this WMS
         GfrPgsThrOgcWmsLoad._LOGGER_.warning("TODO: children - dialog choice for removing this WMS");
      }
     
      catch (Exception exc)
      {
         exc.printStackTrace();
         String str = exc.getMessage();
         GfrPgsThrOgcWmsLoad._LOGGER_.severe(str);
         super._strError = str;
        
         // TODO: dialog choice for removing this WMS
         GfrPgsThrOgcWmsLoad._LOGGER_.warning("TODO: children - dialog choice for removing this WMS");
      }
     
   }
  

   @Override
  protected synchronized void _fireEvent() throws Exception
  {
      GfrEventObjectAbs event = new GfrEventObjectLoadedCapWmsOgc(this,
              super._strError, this._strIdParent);
     
      Iterator i = super._listeners.iterator();
     
      while(i.hasNext()) 
      {
         ((IGfrHandlerEventListenerThreadJobProgress) i.next()).handleEventThreadJobDone(event);
      }
  }

   @Override
   protected void _actionCancelled()
   {
      // handled in DlgProgress parent
   }

  
}
TOP

Related Classes of org.geoforge.mdldatogc.worldwind.thread.GfrPgsThrOgcWmsLoad

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.