Package org.geoforge.guillc.panel

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

/*
*  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.ActionListener;
import java.awt.event.MouseEvent;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Logger;
import javax.help.HelpBroker;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import org.geoforge.guihlp.handler.IGfrHandlerSetEnabledTrueHelpOnThisSection;
import org.geoforge.guillc.handler.IGfrHandlerToggableNode;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.guillc.treenode.GfrNodAbs;
import org.geoforge.guillc.treenode.GfrNodCtrAbs;
import org.geoforge.guillc.treenode.GfrNodCtrFixFolderRootChkSecTopTlo;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldsp.state.multiple.GfrMdlTogMltSecCbx;
import org.geoforge.mdldsp.state.singleton.selecttlo.GfrMdlSttSngSelTlo;

/**
*
* @author robert
*/
abstract public class GfrPnlCntWinViewerAppTloAbs extends GfrPnlCntWinViewerAppAbs implements
        java.util.Observer
{
   // ----
   // begin: instantiate logger for this class
   final private static Logger _LOGGER_ = Logger.getLogger(GfrPnlCntWinViewerAppTloAbs.class.getName());

   static
   {
      GfrPnlCntWinViewerAppTloAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
   }
   // end: instantiate logger for this class
   // ----
  
   protected String _strIdTlo = null;
   protected String _strIdViewer = null;
   protected GfrPnlStatusBarSec _pnlStatusBar = null;
  
   transient protected GfrPnlPrintableSctAwtDspSecTloAbs _pnlTransientDisplay = null;
   protected GfrPnlPrintableSctAwtCtrTreTogChkPrjSecAbs _pnlTreeControl = null;
  
   protected GfrPnlCntWinViewerAppTloAbs(
           GfrPnlStatusBarSec pnlStatusBar,
           ActionListener alrControllerSpcPrj,
           String strIdViewer,
           String strIdTlo
           )
   {
      super(
              300 // intDividerLocation
              );
     
      this._strIdTlo = strIdTlo;
     
      this._pnlStatusBar = pnlStatusBar;
      this._strIdViewer = strIdViewer;
     
      GfrMdlSttSngSelTlo.getInstance().addObserver((Observer) this); // maybe no need for that
      GfrMdlTogMltSecCbx.getInstance().addObserver((Observer) this); // maybe no need for that
   }
  
   @Override
    public boolean init()
    {
       if (! super.init())
            return false;

       if (! this._pnlTreeControl.init())
          return false;

      
       return true;
    }
  
   @Override
   public void loadUnserializedObject() throws Exception
   {
      //GfrPnlCntSecTloOneChkJfcChartAbs._LOGGER_.info("###");
      super.loadUnserializedObject();
       
      if (this._pnlTreeControl != null)
         this._pnlTreeControl.loadUnserializedObject();

      if (this._pnlTransientDisplay != null)
         this._pnlTransientDisplay.loadUnserializedObject(); // !!!!!!!!!! nil
   }
  
   @Override
    public void releaseUnserializedObject() throws Exception
    {
       //GfrPnlCntSecTloOneChkJfcChartAbs._LOGGER_.info("###");
      super.releaseUnserializedObject();

      if (this._pnlTreeControl != null)
         this._pnlTreeControl.releaseUnserializedObject();

      if (this._pnlTransientDisplay != null)
         this._pnlTransientDisplay.releaseUnserializedObject();
    }
  
   @Override
   public void loadTransient() throws Exception
   {
      //GfrPnlCntSecTloOneChkJfcChartAbs._LOGGER_.info("###");
      super.loadTransient();
   }
  
   @Override
   public void releaseTransient() throws Exception
   {
      //GfrPnlCntSecTloOneChkJfcChartAbs._LOGGER_.info("###");
      if (this._pnlTransientDisplay != null)
      {
         super._pnlContainerDisplay.remove(this._pnlTransientDisplay);
        
         this._pnlTransientDisplay.releaseTransient();
         this._pnlTransientDisplay.destroy();
         this._pnlTransientDisplay = null;
      }
        
      super.releaseTransient();
        
   }
  
   @Override
   public void destroy()
   {
      //GfrPnlCntSecTloOneChkJfcChartAbs._LOGGER_.info("###");
      super.destroy();
     
      if (this._pnlTreeControl != null)
      {
         this._pnlTreeControl.destroy();
         this._pnlTreeControl = null;
      }


      if (this._pnlTransientDisplay != null)
      {
         this._pnlTransientDisplay.destroy();
         this._pnlTransientDisplay = null;
      }
     
      GfrMdlSttSngSelTlo.getInstance().deleteObserver((Observer) this);
      GfrMdlTogMltSecCbx.getInstance().deleteObserver((Observer) this);
   }
  
   @Override
    public void mousePressed(MouseEvent evt)
    {
        if (! (evt.getSource() instanceof JTree))
        {
            String str = "! (e.getSource() instanceof JTree)";
            GfrPnlCntWinViewerAppTloAbs._LOGGER_.severe(str);
            GfrOptionPaneAbs.s_showDialogError(null, str);
            return;
        }
       
        JTree tre = (JTree) evt.getSource();
 
        if (SwingUtilities.isRightMouseButton(evt) | SwingUtilities.isMiddleMouseButton(evt))
            return;

        int intX = evt.getX();
        int intY = evt.getY();

        int intRow = tre.getRowForLocation(intX, intY);
        javax.swing.tree.TreePath pth = tre.getPathForRow(intRow);


        if (pth == null)
            return;


        GfrNodAbs nod = (GfrNodAbs) pth.getLastPathComponent();

        if (! (nod instanceof IGfrHandlerToggableNode))
            return;
       

        final IGfrHandlerToggableNode nodCheck = (IGfrHandlerToggableNode) nod;

        javax.swing.SwingUtilities.invokeLater(new Runnable()
        {
            @Override
            public void run()
            {
                 _invokedLaterUpdateCheckUncheckLlo_(nodCheck);
            }
        });
       
    }
  
   @Override
    public void setEnabledTrueHelpOnThisSection(HelpBroker hbr)
    {
       super.setEnabledTrueHelpOnThisSection(hbr);
              
        if (this._pnlTreeControl != null)
            ((IGfrHandlerSetEnabledTrueHelpOnThisSection) this._pnlTreeControl).setEnabledTrueHelpOnThisSection(hbr);
       
        if (this._pnlTransientDisplay != null)
            ((IGfrHandlerSetEnabledTrueHelpOnThisSection) this._pnlTransientDisplay).setEnabledTrueHelpOnThisSection(hbr);
   
    }
  
   @Override
   public void update(Observable obs, Object objEvt)
   {     
      /*String strDummy = "uncaught event: objEvt.getClass().toString():" + objEvt.getClass().toString();
      strDummy += "\n" + "this.getClass().toString():" + this.getClass().toString();;
      GfrPnlCntSecTloOneChkJfcChartAbs._LOGGER_.info(strDummy);*/
   }
  
  
  
   @Override
    public void open(ActionListener alrControllerSpcPrj, ActionListener alrControllerPrs) throws Exception
    {
       //GfrPnlCntSecTloOneChkJfcChartAbs._LOGGER_.info("###");
      
      
      if (! this._pnlTransientDisplay.init())
      {
         String strError = "! this._pnlTransientDisplay.init()";
         GfrPnlCntWinViewerAppTloAbs._LOGGER_.severe(strError);
         throw new Exception(strError);
      }
     
      super._pnlContainerDisplay.add((Component) this._pnlTransientDisplay, BorderLayout.CENTER);
      
      
       super.open(alrControllerSpcPrj, alrControllerPrs);
      
       this._pnlTreeControl.openSpaceApplicationProject(alrControllerSpcPrj, alrControllerPrs);
    }
  
   // ---
  
   public void setVisibleDisplayOnly(boolean bln)
    {     
       //this._pnlTransientDisplay.setVisibleDisplayOnly(bln);
      
       if (bln)
       {
          super._spnHorizontal.setDividerLocation(0.0d);
          super._pnlContainerControl.setVisible(false);
          super._spnHorizontal.setDividerSize(0);
       }
      
       else
       {
          super._spnHorizontal.setDividerSize(10);
          super._spnHorizontal.setDividerLocation(300);
          super._pnlContainerControl.setVisible(true);
       }
    }
  
   private void _invokedLaterUpdateCheckUncheckLlo_(IGfrHandlerToggableNode nodCheck)
   {
      TreeNode nodRoot = ((DefaultMutableTreeNode) nodCheck).getRoot();

      
       if (nodRoot instanceof GfrNodCtrFixFolderRootChkSecTopTlo)
       {
         // updating buttons in control toolbar
          this._pnlTreeControl.updateButtonsToolbarCheckUncheck( (GfrNodCtrAbs) nodRoot);
         
          return;
       }
      
       String strError = "Uncaught nodRoot: " + nodRoot.getClass().toString();
       GfrPnlCntWinViewerAppTloAbs._LOGGER_.severe(strError);
       GfrOptionPaneAbs.s_showDialogError(null, strError);
   }
}
TOP

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

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.