Package org.geoforge.guillc.panel

Source Code of org.geoforge.guillc.panel.GfrPnlPrintableSctAwtDspSecTloAbs

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

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Logger;
import javax.help.HelpBroker;
import javax.swing.JPanel;
import org.geoforge.guihlp.handler.IGfrHandlerSetEnabledTrueHelpOnThisSection;
import org.geoforge.guillc.border.GfrBorderHelpOnThis;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.lang.handler.IGfrHandlerLifeCycleObject;
import org.geoforge.lang.handler.IGfrHandlerTransitoryObject;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldsp.event.state.multiple.GfrEvtMdlTogMltSecCbx;
import org.geoforge.mdldsp.state.multiple.GfrMdlTogMltSecCbx;

/**
*
* @author robert
*/
abstract public class GfrPnlPrintableSctAwtDspSecTloAbs extends GfrPnlPrintableSctAwt implements
      IGfrHandlerSetEnabledTrueHelpOnThisSection,
      Observer,
      MouseListener
{
   // ----
   // begin: instantiate logger for this class

   final private static Logger _LOGGER_ = Logger.getLogger(GfrPnlPrintableSctAwtDspSecTloAbs.class.getName());

   static
   {
      GfrPnlPrintableSctAwtDspSecTloAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
   }
   // end: instantiate logger for this class
   // ----
  
   protected String _strIdTlo = null; // memo: tlo
   protected GfrPnlStatusBarAbs _pnlStatusBar = null;
   protected IGfrHandlerTransitoryObject _tot = null;
   protected String _strIdViewer = null;

   abstract protected boolean _toggleCheckboxObject(String strIdObject, boolean blnValue) throws Exception;

   @Override
   public void loadTransient() throws Exception
   {
      super.loadTransient();

      ((IGfrHandlerTransitoryObject) this._tot).loadTransient();
   }

   @Override
   public void releaseTransient() throws Exception
   {
      super.releaseTransient();

      ((IGfrHandlerTransitoryObject) this._tot).releaseTransient();
   }

   public String getIdTlo()
   {
      return this._strIdTlo;
   }

   protected GfrPnlPrintableSctAwtDspSecTloAbs(
         GfrPnlStatusBarAbs pnlStatusBar,
         String strIdTlo,
         String strIdViewer)
   {
      super();

      this._pnlStatusBar = pnlStatusBar;
      this._strIdTlo = strIdTlo;
      this._strIdViewer = strIdViewer;

      super.setLayout(new BorderLayout());
      GfrBorderHelpOnThis.s_set((JPanel) this);
      GfrMdlTogMltSecCbx.getInstance().addObserver((Observer) this);
   }

   public void setVisibleDisplayOnly(boolean bln)
   {
      // void  
   }

   @Override
   public void update(Observable obs, Object objEvt)
   {
      try
      {
         if (objEvt instanceof GfrEvtMdlTogMltSecCbx)
         {
            GfrEvtMdlTogMltSecCbx evt = (GfrEvtMdlTogMltSecCbx) objEvt;

            String strIdViewer = evt.getKeyViewer();

            if (strIdViewer.compareTo(this._strIdViewer) != 0)
               return;

            String strIdObject = evt.getKeyObject();
            boolean blnValue = evt.getValueObject();

            _toggleCheckboxObject(strIdObject, blnValue);

            // ending
            return;
         }
      }
      catch (Exception exc)
      {
         exc.printStackTrace();
         String str = exc.getMessage();
         GfrPnlPrintableSctAwtDspSecTloAbs._LOGGER_.severe(str);
         GfrOptionPaneAbs.s_showDialogError(null, str);
         return;
      }


      /*String strClassThis = this.getClass().toString();
      String strObs = obs.getClass().toString();
      String strObjEvt = objEvt.getClass().toString();
     
      GfrPnlDspSecJfcChartTloAbs._LOGGER_.info(
      "#### GOT: strObs=" + strObs +
      ", strObjEvt=" + strObjEvt +
      ",\nstrClassThis=" + strClassThis +
      "\n");*/
   }

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

      if (!((IGfrHandlerLifeCycleObject) this._tot).init())
         return false;

      super.add(((Component) this._tot), BorderLayout.CENTER);

      return true;
   }

   @Override
   public void destroy()
   {
      super.destroy();

      GfrMdlTogMltSecCbx.getInstance().deleteObserver((Observer) this);


      if (this._tot != null)
      {
         ((IGfrHandlerLifeCycleObject) this._tot).destroy();
         this._tot = null;
      }
   }

   @Override
   public void setVisible(boolean bln)
   {
      super.setVisible(bln);
      //System.err.println("setVisible(bln)");
   }

   @Override
   public void setEnabledTrueHelpOnThisSection(HelpBroker hbr)
   {
      if (hbr == null)
         return;

      for (int i = 0; i < super.getComponentCount(); i++)
      {
         Component cmpCur = super.getComponent(i);

         if (cmpCur instanceof IGfrHandlerSetEnabledTrueHelpOnThisSection)
            ((IGfrHandlerSetEnabledTrueHelpOnThisSection) cmpCur).setEnabledTrueHelpOnThisSection(hbr);
      }
   }

   @Override
   public void mouseClicked(MouseEvent e)
   {
   }

   @Override
   public void mousePressed(MouseEvent e)
   {
   }

   @Override
   public void mouseReleased(MouseEvent e)
   {
   }

   @Override
   public void mouseEntered(MouseEvent e)
   {
   }

   @Override
   public void mouseExited(MouseEvent e)
   {
      if (this._pnlStatusBar == null)
      {
         //System.out.println("this._pnlStatusBar == null");
         return;
      }

      this._pnlStatusBar.setMessage("");
   }
}
TOP

Related Classes of org.geoforge.guillc.panel.GfrPnlPrintableSctAwtDspSecTloAbs

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.