Package org.geoforge.guillcogcecl.dialog

Source Code of org.geoforge.guillcogcecl.dialog.GfrDlgCmdCancelBldObjWwdEarthAbs

package org.geoforge.guillcogcecl.dialog;

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


import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.EventObject;
import java.util.logging.Logger;
import javax.swing.JFrame;
import org.geoforge.guillc.button.*;
import org.geoforge.guillc.dialog.GfrDlgCmdCancelAbs;
import org.geoforge.guillc.panel.GfrPnlCmdCancelOk;
import org.geoforge.guillc.panel.GfrPnlCmdCancelOkEnableDisableAbs;
import org.geoforge.guillc.panel.GfrPnlEarthLoadingAbs;
import org.geoforge.guillc.panel.GfrPnlEarthLoadingFailed;
import org.geoforge.guillc.panel.GfrPnlEarthLoadingNot;
import org.geoforge.guillc.panel.GfrPnlEarthLoadingStarted;
import org.geoforge.guillc.panel.GfrPnlDspPrjWwdEarthMainBldObjAbs;
import org.geoforge.guillc.handler.IGfrHandlerBuilderObjectWwdEarth;
import org.geoforge.guillc.util.threadpoolexecutor.GfrWrkOpenDisplayWwdEarth;
import org.geoforge.java.enumeration.GfrEnuSystemPropertiesKeys;
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
*
* cancel, ok, new, clear
*
*/
abstract public class GfrDlgCmdCancelBldObjWwdEarthAbs extends GfrDlgCmdCancelAbs 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;
   }
   
    final static private Dimension _DIM_ = new Dimension(700, 600);
    final static private String _STR_TITLE_SUFFIX_ = "step 1/2";
   
   
   
    // ----
    // begin: instantiate logger for this class
    final private static Logger _LOGGER_ = Logger.getLogger(GfrDlgCmdCancelBldObjWwdEarthAbs.class.getName());

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

    // end: instantiate logger for this class
    // ----
   
   
   
   
    // 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
   

   
    private GfrPnlEarthLoadingAbs _pnlLoadingNot_ = null;
    private GfrPnlEarthLoadingAbs _pnlLoadingStarted_ = null;
    private GfrPnlEarthLoadingAbs _pnlLoadingFailed_ = null;
   
    protected GfrPnlDspPrjWwdEarthMainBldObjAbs _pnlDisplay = null;
   
    private String _strNameSuffixThreadOpenDisplay_ = null;
   
    private GfrWrkOpenDisplayWwdEarth _wrk_ = null;
   
   
    public Object getValue()
    {
        return ((IGfrHandlerBuilderObjectWwdEarth) this._pnlDisplay).getValueGeometryObjectEarthDrawn();
    }
   
   
   
    protected GfrDlgCmdCancelBldObjWwdEarthAbs(
            String strTitle,
            String strWhat)
    {
        super((JFrame) null,
                System.getProperty(GfrEnuSystemPropertiesKeys.NAME_LONG_APPLI.getLabel()) +
                    " - " +
                    strTitle +
                    " - " +
                    GfrDlgCmdCancelBldObjWwdEarthAbs._STR_TITLE_SUFFIX_,
                GfrDlgCmdCancelBldObjWwdEarthAbs._DIM_
                );
       
       
       
       
        this._strNameSuffixThreadOpenDisplay_ = "wwdEarthBuilderObject";
       
        this._pnlLoadingNot_ = new GfrPnlEarthLoadingNot(strWhat.toLowerCase());
        this._pnlLoadingStarted_ = new GfrPnlEarthLoadingStarted(strWhat.toLowerCase());
        this._pnlLoadingFailed_ = new GfrPnlEarthLoadingFailed(strWhat.toLowerCase());
       
        super.setResizable(true);
       
    }
   
    @Override
    public boolean init()
    {
        if (! super.init())
            return false;
       
        if (! this._pnlDisplay.init())
            return false;
       
       
        super.getContentPane().add(this._pnlLoadingNot_, BorderLayout.CENTER);
       
        if (super.getContentPane().isVisible())
           super.getContentPane().validate();
       
        if (! _BLN_DEV_NO_DISPLAY_)
        {
           _executeDisplay_();
        }
       
        return true;
    }
   
    @Override
    public void destroy()
    {
       if (this._wrk_ != null)
       {
          this._wrk_.removeEventListener(this);
          this._wrk_ = null;
       }
      
      
        super.destroy();
       
        if (this._pnlDisplay != null)
        {
           this._pnlDisplay.destroy();
           this._pnlDisplay = null;
        }
       
        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 actionPerformed(ActionEvent evt)
    {
        Object objSource = evt.getSource();

        if (objSource instanceof GfrBtnTxtRndCmdOkXXSmall)
        {
            super.setCancelled(false);
            super.setVisible(false);
           
            // TODO: get values
            return;
        }
       
        if (objSource instanceof GfrBtnTxtRndCmdNewXXSmall ||
            objSource instanceof GfrBtnTxtRndCmdCheckAllXXSmall)
        {
            ((IGfrHandlerBuilderObjectWwdEarth) this._pnlDisplay).setEnabledEditorBuilderObjectWwdEarth(true);
            return;
        }
       
        if (objSource instanceof GfrBtnTxtRndCmdClearXXSmall ||
            objSource instanceof GfrBtnTxtRndCmdUncheckAllXXSmall)
        {
            ((IGfrHandlerBuilderObjectWwdEarth) this._pnlDisplay).setEnabledEditorBuilderObjectWwdEarth(false);
            ((GfrPnlCmdCancelOk) super._pnlCommand).setEnabledOkCommandDialog(false);
            return;
        }

        // redirecting to subclass's method
        super.actionPerformed(evt);
    }

  
   
   
    @Override
    public void handleEventWrkOpenDisplay(EventObject evt)
    {
       try
       {
         GfrWrkOpenDisplayWwdEarth.EvtWrkOpenDisplay evtMy = (GfrWrkOpenDisplayWwdEarth.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 (getContentPane().isAncestorOf(this._pnlLoadingNot_))
            {
               getContentPane().remove(this._pnlLoadingNot_);
               blnDoValidate |= true;
            }
           
            if (getContentPane().isAncestorOf(this._pnlLoadingStarted_))
            {
               getContentPane().remove(this._pnlLoadingStarted_);
               blnDoValidate |= true;
            }
           
            if (getContentPane().isAncestorOf(this._pnlDisplay))
            {
               getContentPane().remove(this._pnlDisplay);
               blnDoValidate |= true;
            }
           
            if (! getContentPane().isAncestorOf(this._pnlLoadingFailed_))
            {
               getContentPane().add((Component) this._pnlLoadingFailed_, BorderLayout.CENTER);
               blnDoValidate |= true;
            }
           
            if (blnDoValidate && getContentPane().isVisible())
               getContentPane().validate();
           
            return;
         }
        
         if (strValueNew.compareTo(GfrWrkOpenDisplayWwdEarth.STR_DONE) == 0)
         {
            boolean blnDoValidate = false;
           
            if (getContentPane().isAncestorOf(this._pnlLoadingNot_))
            {
               getContentPane().remove(this._pnlLoadingNot_);
               blnDoValidate |= true;
            }
           
            if (getContentPane().isAncestorOf(this._pnlLoadingStarted_))
            {
               getContentPane().remove(this._pnlLoadingStarted_);
               blnDoValidate |= true;
            }
           
           
            if (getContentPane().isAncestorOf(this._pnlLoadingFailed_))
            {
               getContentPane().remove(this._pnlLoadingFailed_);
                blnDoValidate |= true;
            }
           
            if (! getContentPane().isAncestorOf(this._pnlDisplay))
            {
               getContentPane().add((Component) this._pnlDisplay, BorderLayout.CENTER);
                blnDoValidate |= true;
            }
           
            if (blnDoValidate && getContentPane().isVisible())
               getContentPane().validate();
           

            ((GfrPnlCmdCancelOkEnableDisableAbs) super._pnlCommand).setEnabledButtonEnablingOk(true);
           
            return;
         }
       
       }
      
       catch(Exception exc)
       {
          exc.printStackTrace();
          GfrDlgCmdCancelBldObjWwdEarthAbs._LOGGER_.warning(exc.getMessage());
       }
    }
   
    private void _executeDisplay_()
    {
        if (_BLN_DEV_NO_DISPLAY_)
           return;
       

         boolean blnDoValidate = false;

         if (getContentPane().isAncestorOf(this._pnlDisplay))
         {
            getContentPane().remove(this._pnlDisplay);
            blnDoValidate |= true;
         }

         if (getContentPane().isAncestorOf(this._pnlLoadingFailed_))
         {
            getContentPane().remove(this._pnlLoadingFailed_);
            blnDoValidate |= true;
         }

         if (getContentPane().isAncestorOf(this._pnlLoadingNot_))
         {
            getContentPane().remove(this._pnlLoadingNot_);
            blnDoValidate |= true;
         }

         if (! getContentPane().isAncestorOf(this._pnlLoadingStarted_))
         {
            getContentPane().add((Component) this._pnlLoadingStarted_, BorderLayout.CENTER);
            blnDoValidate |= true;
         }

         if (blnDoValidate && getContentPane().isVisible())
            getContentPane().validate();

         this._wrk_ = new GfrWrkOpenDisplayWwdEarth(
            (ActionListener) null,  // alrControllerSpcPrj
            (ActionListener) null, // alrControllerPrs
            this._strNameSuffixThreadOpenDisplay_,
            this._pnlDisplay,
            (GfrWrkOpenDisplayWwdEarth.WrkOpenDisplayListener) this);


         GfrTpeSpcPrj.s_getInstance().execute(this._wrk_);
    }
}
TOP

Related Classes of org.geoforge.guillcogcecl.dialog.GfrDlgCmdCancelBldObjWwdEarthAbs

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.