Package org.geoforge.guillc.splitpane

Source Code of org.geoforge.guillc.splitpane.GfrSplHlpMainAppCadPrjWwdEarthAbs

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






import java.awt.Component;
import java.awt.event.ActionListener;
import java.util.EventObject;
import java.util.logging.Logger;
import javax.swing.JSplitPane;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.guillc.panel.*;
import org.geoforge.guillc.util.threadpoolexecutor.GfrWrkOpenDisplayWwdEarth;
import org.geoforge.guillc.util.threadpoolexecutor.GfrWrkOpenDisplayWwdEarth.EvtWrkOpenDisplay;
import org.geoforge.java.enumeration.GfrEnuSystemPropertiesKeys;
import org.geoforge.lang.runnable.IHandlerQueuableOpenerSpaceProject;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.lang.util.threadpoolexecutor.GfrTpeSpcPrj;

/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*
*/

abstract public class GfrSplHlpMainAppCadPrjWwdEarthAbs extends GfrSplHlpMainAppCadPrjAbs implements
        GfrWrkOpenDisplayWwdEarth.WrkOpenDisplayListener
{   
   // ---
   static private boolean _BLN_DEBUG_ = false;
  
   static
   {
      String str = System.getProperty(GfrEnuSystemPropertiesKeys.DEBUG_APPLI.getLabel());
     
      if (str!=null && str.compareTo("true") == 0)
         _BLN_DEBUG_ = true;
   }
  
   // beg tempo
    static private boolean _BLN_DEV_NO_DISPLAY_ = false;
   
    static
    {
       String str = System.getProperty(GfrEnuSystemPropertiesKeys.SHOULD_HIDE_DISPLAY_EARTH_WORLDWIND.getLabel());
      
       if (str != null && str.compareTo("true") == 0)
          _BLN_DEV_NO_DISPLAY_ = true;
         
    }
    // end tempo
   
    // ----
    // begin: instantiate logger for this class
    final private static Logger _LOGGER_ = Logger.getLogger(GfrSplHlpMainAppCadPrjWwdEarthAbs.class.getName());

    static
    {
        GfrSplHlpMainAppCadPrjWwdEarthAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
    }

    // end: instantiate logger for this class
    // ----

   
   
    private String _strNameSuffixThreadOpenDisplay_ = null;
   
    private GfrPnlEarthLoadingAbs _pnlLoadingNot_ = null;
    private GfrPnlEarthLoadingAbs _pnlLoadingStarted_ = null;
    private GfrPnlEarthLoadingAbs _pnlLoadingFailed_ = null;
   
    
    private GfrWrkOpenDisplayWwdEarth _wrk_ = null;
    // ---
   
    public void setProjectionFlat(String str)
    {
        ((GfrPnlPrintableSctAwtDspPrjWwdEarthAbs) super._pnlDisplay).setProjectionFlat(str);  
    }
   
   
    public void restoreStateOrbitView(String str)
    {
       if (super._pnlDisplay != null)
       {
          ((GfrPnlPrintableSctAwtDspPrjWwdEarthAbs) super._pnlDisplay).restoreStateOrbitView(str);
       }
    }
   
    public String getRestorableStateOrbitView()
    {
       if (super._pnlDisplay != null)
          return ((GfrPnlPrintableSctAwtDspPrjWwdEarthAbs) super._pnlDisplay).getRestorableStateOrbitView();
      
       return null;
    }
   
    // ---

    protected GfrSplHlpMainAppCadPrjWwdEarthAbs(
            String strNameSuffixThreadOpenDisplay,
            String strWhatViewer,
            String strNameTabThis) throws Exception
    {
        super(strNameTabThis);
      
        this._strNameSuffixThreadOpenDisplay_ = "wwdEarth-" + strNameSuffixThreadOpenDisplay;

        this._pnlLoadingNot_ = new GfrPnlEarthLoadingNot(strWhatViewer);
        this._pnlLoadingStarted_ = new GfrPnlEarthLoadingStarted(strWhatViewer);
        this._pnlLoadingFailed_ = new GfrPnlEarthLoadingFailed(strWhatViewer);
    }

   @Override
    public void openSpaceApplicationProject(ActionListener alrControllerSpcPrj, ActionListener alrControllerPrs) throws Exception
    {
       super.openSpaceApplicationProject(alrControllerSpcPrj, alrControllerPrs);
      
       if (super._pnlControlLeftThis != null)
         ((IHandlerQueuableOpenerSpaceProject)super._pnlControlLeftThis).doJobQueuedOpenSpaceProject(alrControllerSpcPrj, alrControllerPrs);
      
       
       
        if (! _BLN_DEV_NO_DISPLAY_)
        {
           boolean blnDoValidate = false;
          
           if (super.isAncestorOf(super._pnlDisplay))
           {
              super.remove(super._pnlDisplay);
              blnDoValidate |= true;
           }
          
           if (super.isAncestorOf(this._pnlLoadingFailed_))
           {
              super.remove(this._pnlLoadingFailed_);
              blnDoValidate |= true;
           }
          
           if (super.isAncestorOf(this._pnlLoadingNot_))
           {
              super.remove(this._pnlLoadingNot_);
              blnDoValidate |= true;
           }
        
           if (! super.isAncestorOf(this._pnlLoadingStarted_))
           {
              super.add((Component) this._pnlLoadingStarted_, JSplitPane.RIGHT);
              blnDoValidate |= true;
           }
          
           if (blnDoValidate && super.isVisible())
               _validateFixTrbl_();
      
           this._wrk_ = new GfrWrkOpenDisplayWwdEarth(
               alrControllerSpcPrj,
               alrControllerPrs,
               this._strNameSuffixThreadOpenDisplay_,
               (GfrPnlPrintableSctAwtDspPrjAbs) super._pnlDisplay,
               (GfrWrkOpenDisplayWwdEarth.WrkOpenDisplayListener) this);
          
          
           GfrTpeSpcPrj.s_getInstance().execute(this._wrk_);
        }
     
    }

   
    @Override
    public void closeSpace() throws Exception
    {
       if (this._wrk_ != null)
       {
          this._wrk_.removeEventListener(this);
          this._wrk_ = null;
       }
      
        super.closeSpace();

       
        if (! _BLN_DEV_NO_DISPLAY_)
        {
           boolean blnDoValidate = false;
          
           if (super.isAncestorOf(super._pnlDisplay))
           {
              super.remove(super._pnlDisplay);
              blnDoValidate |= true;
           }
          
           if (super.isAncestorOf(this._pnlLoadingFailed_))
           {
              super.remove(this._pnlLoadingFailed_);
              blnDoValidate |= true;
           }
          
           if (super.isAncestorOf(this._pnlLoadingStarted_))
           {
              super.remove(this._pnlLoadingStarted_);
              blnDoValidate |= true;
           }
        
           if (! super.isAncestorOf(this._pnlLoadingNot_))
           {
              super.add((Component) this._pnlLoadingNot_, JSplitPane.RIGHT);
              blnDoValidate |= true;
           }
           
           if (blnDoValidate && super.isVisible())
               _validateFixTrbl_();
          
           if ( super._pnlDisplay != null)
               super._pnlDisplay.close();
        }
    }
   
   
   
   

    @Override
    public boolean init()
    {
      if (! super.init())
         return false;
     
      if (! super._pnlDisplay.init())
         return false;

      super.add((Component) this._pnlLoadingNot_, JSplitPane.RIGHT);

      return true;
    }

    @Override
    public void destroy()
    {
       if (this._wrk_ != null)
       {
          this._wrk_.removeEventListener(this);
          this._wrk_ = null;
       }
      
        super.destroy();
       
       
        if (this._pnlLoadingNot_ != null) // !!! NO INIT !!!
        {
            this._pnlLoadingNot_.destroy();
            this._pnlLoadingNot_ = null;
        }
       
        if (this._pnlLoadingStarted_ != null) // !!! NO INIT !!!
        {
            this._pnlLoadingStarted_.destroy();
            this._pnlLoadingStarted_ = null;
        }
       
        if (this._pnlLoadingFailed_ != null) // !!! NO INIT !!!
        {
            this._pnlLoadingFailed_.destroy();
            this._pnlLoadingFailed_ = null;
        }

       
    }
   
    @Override
    public void handleEventWrkOpenDisplay(EventObject evt)
    {
       try
       {
       EvtWrkOpenDisplay evtMy = (EvtWrkOpenDisplay) evt;
      
       GfrWrkOpenDisplayWwdEarth wrk = (GfrWrkOpenDisplayWwdEarth) evt.getSource();

         String strNameThread = wrk.toString();
         String strValueNew = evtMy.getResult();
        
         //if (_BLN_DEBUG_)
           // System.out.println("strNameThread=" + strNameThread + ", " + strValueNew); 
        
         if (strValueNew.compareTo(GfrWrkOpenDisplayWwdEarth.STR_STARTED) == 0)
         {
            //if (_BLN_DEBUG_)
              // System.out.println(">> info: " + strValueNew);
           
            return;
         }
        
         if (strValueNew.compareTo(GfrWrkOpenDisplayWwdEarth.STR_FAILED) == 0)
         {
            boolean blnDoValidate = false;
           
            if (super.isAncestorOf(this._pnlLoadingNot_))
            {
               super.remove(this._pnlLoadingNot_);
               blnDoValidate |= true;
            }
           
            if (super.isAncestorOf(this._pnlLoadingStarted_))
            {
               super.remove(this._pnlLoadingStarted_);
               blnDoValidate |= true;
            }
           
            if (super.isAncestorOf(super._pnlDisplay))
            {
               super.remove(super._pnlDisplay);
               blnDoValidate |= true;
            }
           
            if (! super.isAncestorOf(this._pnlLoadingFailed_))
            {
               super.add((Component) this._pnlLoadingFailed_, JSplitPane.RIGHT);
               blnDoValidate |= true;
            }
           
            if (blnDoValidate && super.isVisible())
               _validateFixTrbl_();
           
            return;
         }
        
         if (strValueNew.compareTo(GfrWrkOpenDisplayWwdEarth.STR_DONE) == 0)
         {
           
           
            boolean blnDoValidate = false;
           
            if (super.isAncestorOf(this._pnlLoadingNot_))
            {
               super.remove(this._pnlLoadingNot_);
               blnDoValidate |= true;
            }
           
            if (super.isAncestorOf(this._pnlLoadingStarted_))
            {
               super.remove(this._pnlLoadingStarted_);
               blnDoValidate |= true;
            }
           
           
            if (super.isAncestorOf(this._pnlLoadingFailed_))
            {
               super.remove(this._pnlLoadingFailed_);
                blnDoValidate |= true;
            }
           
            if (! super.isAncestorOf(super._pnlDisplay))
            {
               super.add((Component) super._pnlDisplay, JSplitPane.RIGHT);
                blnDoValidate |= true;
            }
           
            if (blnDoValidate && super.isVisible())
               _validateFixTrbl_();
           
            super._pnlDisplay.setEnabledTrueHelpOnThisSection(super._hbr);
           
            return;
         }  
        
       }
      
       catch(Exception exc)
       {
          exc.printStackTrace();
          GfrSplHlpMainAppCadPrjWwdEarthAbs._LOGGER_.warning(exc.getMessage());
       }
    }

    /*
     * manage tbrl, no problem with select!
     */
    private void _validateFixTrbl_()
    {
       int intDividerLocationPrev = super.getDividerLocation();
       super.validate();
      
       if (super.getDividerLocation() != intDividerLocationPrev)
       {
          if (intDividerLocationPrev > 0)
          {
             super.setDividerLocation(intDividerLocationPrev);
            
             try
               {
                  _saveValueLocationDivider(intDividerLocationPrev);
               }

               catch(Exception exc)
               {
                  exc.printStackTrace();
                  GfrSplHlpMainAppCadPrjWwdEarthAbs._LOGGER_.severe(exc.getMessage());
                  GfrOptionPaneAbs.s_showDialogError(null, exc.getMessage());
               }
          }
       }
    }
  
}
TOP

Related Classes of org.geoforge.guillc.splitpane.GfrSplHlpMainAppCadPrjWwdEarthAbs

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.