Package org.geoforge.guillc.panel

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

/*
*  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.event.ActionEvent;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Logger;
import javax.swing.event.*;
import javax.swing.tree.TreeModel;
import org.geoforge.guillc.button.BtnTransientAllCollapse;
import org.geoforge.guillc.button.BtnTransientAllExpand;
import org.geoforge.guillc.scrollpane.GfrScrCtrTopSpcTreAbs;
import org.geoforge.guillc.toolbar.GfrTbrHlpSubCtrTreAbs;
import org.geoforge.guillc.tree.GfrTreCtrTopSpcAbs;
import org.geoforge.guillc.treenode.GfrNodCtrAbs;
import org.geoforge.guillc.treenode.GfrNodCtrFixFolderTopAbs;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldat.event.GfrEvtMdlDtaRemovedAllTlo;

/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*/
abstract public class GfrPnlPrintableSctAwtCtrTreAbs extends GfrPnlPrintableSctAwtCtrAbs implements
    TreeSelectionListener,
    TreeExpansionListener,
    TreeModelListener,
    Observer
{
   // ----
   // begin: instantiate logger for this class
   final private static Logger _LOGGER_ = Logger.getLogger(GfrPnlPrintableSctAwtCtrTreAbs.class.getName());

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

    protected GfrPnlPrintableSctAwtCtrTreAbs(String strOrientationToolbar)
    {
        super(strOrientationToolbar);
       
    }
   
    @Override
   public void update(Observable obs, Object objEvt)
   {
      if (! (objEvt instanceof GfrEvtMdlDtaRemovedAllTlo))
          return;
     
      javax.swing.SwingUtilities.invokeLater(new Runnable()
      {
         @Override
         public void run()
         {
            try
            {
               _removedAllTLo();
            }

            catch(Exception exc)
            {
               exc.printStackTrace();
               GfrPnlPrintableSctAwtCtrTreAbs._LOGGER_.info("_removedAllTLo(): exc caught, don't care");
            }
         }
      });
   }

    @Override
    public void actionPerformed(ActionEvent e)
    {
        if (e.getSource() instanceof BtnTransientAllCollapse)
        {
            ((GfrScrCtrTopSpcTreAbs) super._scr).folderAllCollapse();
            return;
        }
       
        if (e.getSource() instanceof BtnTransientAllExpand)
        {
            ((GfrScrCtrTopSpcTreAbs) super._scr).folderAllExpand();
            return;
        }

        super.actionPerformed(e);
    }

   @Override
   public void valueChanged(TreeSelectionEvent evt)
   {
      // ???????????????????????
      //if (! evt.isAddedPath())
        //return;
     
      final GfrTreCtrTopSpcAbs tre = (GfrTreCtrTopSpcAbs) evt.getSource();
     
      javax.swing.SwingUtilities.invokeLater(new Runnable()
      {
         @Override
         public void run()
         {
            try
            {
               _valueChanged(tre);
            }

            catch(Exception exc)
            {
               exc.printStackTrace();
               GfrPnlPrintableSctAwtCtrTreAbs._LOGGER_.info("_valueChanged(tre): exc caught, don't care");
            }
         }
      });
   }

   @Override
   public void treeExpanded(TreeExpansionEvent evt)
   {
      final GfrTreCtrTopSpcAbs tre = (GfrTreCtrTopSpcAbs) evt.getSource();
     
      javax.swing.SwingUtilities.invokeLater(new Runnable()
      {
         @Override
         public void run()
         {
            try
            {
               _treeExpanded(tre);
            }

            catch(Exception exc)
            {
               exc.printStackTrace();
               GfrPnlPrintableSctAwtCtrTreAbs._LOGGER_.info("exc caught, don't care");
            }
         }
      });
   }

   @Override
   public void treeCollapsed(TreeExpansionEvent evt)
   {
      final GfrTreCtrTopSpcAbs tre = (GfrTreCtrTopSpcAbs) evt.getSource();
     
      javax.swing.SwingUtilities.invokeLater(new Runnable()
      {
         @Override
         public void run()
         {
            try
            {
               _treeCollapsed(tre);
            }

            catch(Exception exc)
            {
               exc.printStackTrace();
               GfrPnlPrintableSctAwtCtrTreAbs._LOGGER_.info("exc caught, don't care");
            }
         }
      });
   }

  

   @Override
   public void treeNodesInserted(TreeModelEvent e)
   {
      TreeModel tml = (TreeModel) e.getSource();
      Object[] objsChildren = e.getChildren();

      if (objsChildren.length == 1)
      {
         Object obj = objsChildren[0];

         if (obj instanceof GfrNodCtrFixFolderTopAbs)
               return;
      }
     
      final GfrNodCtrAbs nodRootTree = (GfrNodCtrAbs) tml.getRoot();
     
      javax.swing.SwingUtilities.invokeLater(new Runnable()
      {
         @Override
         public void run()
         {
            try
            {
               _treeNodesInserted(nodRootTree);
            }

            catch(Exception exc)
            {
               exc.printStackTrace();
               GfrPnlPrintableSctAwtCtrTreAbs._LOGGER_.info("exc caught, don't care");
            }
         }
      });
   }

   @Override
   public void treeNodesRemoved(TreeModelEvent e)
   {
      TreeModel tml = (TreeModel) e.getSource();
      final GfrNodCtrAbs nodRootTree = (GfrNodCtrAbs) tml.getRoot();
     
      javax.swing.SwingUtilities.invokeLater(new Runnable()
      {
         @Override
         public void run()
         {
            try
            {
               _treeNodesRemoved(nodRootTree);
            }

            catch(Exception exc)
            {
               exc.printStackTrace();
               GfrPnlPrintableSctAwtCtrTreAbs._LOGGER_.info("exc caught, don't care");
            }
         }
      });
   }

   // beg don't care
   @Override
   public void treeStructureChanged(TreeModelEvent e) {}
  
   @Override
   public void treeNodesChanged(TreeModelEvent e) {}
   // end don't care
  
   // ---
  
   protected void _treeNodesInserted(GfrNodCtrAbs nodRootTree) throws Exception
   {
      boolean blnCollapse = ((GfrScrCtrTopSpcTreAbs) super._scr).isAllowedFolderAllCollapseTree(nodRootTree);
      ((GfrTbrHlpSubCtrTreAbs) super._tbr).setEnabledButtonCollapseAll(blnCollapse);
     
      boolean blnExpand = ((GfrScrCtrTopSpcTreAbs) super._scr).isAllowedFolderAllExpandTree(nodRootTree);
      ((GfrTbrHlpSubCtrTreAbs) super._tbr).setEnabledButtonExpandAll(blnExpand);
   }
  
   protected void _treeNodesRemoved(GfrNodCtrAbs nodRootTree) throws Exception
   {
      boolean blnCollapse = ((GfrScrCtrTopSpcTreAbs) super._scr).isAllowedFolderAllCollapseTree(nodRootTree);
      ((GfrTbrHlpSubCtrTreAbs) super._tbr).setEnabledButtonCollapseAll(blnCollapse);
     
      boolean blnExpand = ((GfrScrCtrTopSpcTreAbs) super._scr).isAllowedFolderAllExpandTree(nodRootTree);
      ((GfrTbrHlpSubCtrTreAbs) super._tbr).setEnabledButtonExpandAll(blnExpand);
   }
  
   protected void _valueChanged(GfrTreCtrTopSpcAbs tre) throws Exception
   {
      boolean blnCollapse = ((GfrScrCtrTopSpcTreAbs) super._scr).isAllowedFolderAllCollapseTree();
      ((GfrTbrHlpSubCtrTreAbs) super._tbr).setEnabledButtonCollapseAll(blnCollapse);
     
      boolean blnExpand = ((GfrScrCtrTopSpcTreAbs) super._scr).isAllowedFolderAllExpandTree();
      ((GfrTbrHlpSubCtrTreAbs) super._tbr).setEnabledButtonExpandAll(blnExpand);
   }
  
   protected void _treeExpanded(GfrTreCtrTopSpcAbs tre) throws Exception
   {
      boolean blnCollapse = ((GfrScrCtrTopSpcTreAbs) super._scr).isAllowedFolderAllCollapseTree();
      ((GfrTbrHlpSubCtrTreAbs) super._tbr).setEnabledButtonCollapseAll(blnCollapse);
     
      boolean blnExpand = ((GfrScrCtrTopSpcTreAbs) super._scr).isAllowedFolderAllExpandTree();
      ((GfrTbrHlpSubCtrTreAbs) super._tbr).setEnabledButtonExpandAll(blnExpand);
   }
  
   protected void _treeCollapsed(GfrTreCtrTopSpcAbs tre) throws Exception
   {
      boolean blnCollapse = ((GfrScrCtrTopSpcTreAbs) super._scr).isAllowedFolderAllCollapseTree();
      ((GfrTbrHlpSubCtrTreAbs) super._tbr).setEnabledButtonCollapseAll(blnCollapse);
     
      boolean blnExpand = ((GfrScrCtrTopSpcTreAbs) super._scr).isAllowedFolderAllExpandTree();
      ((GfrTbrHlpSubCtrTreAbs) super._tbr).setEnabledButtonExpandAll(blnExpand);
   }

   protected void _removedAllTLo() throws Exception
   {
      boolean blnCollapse = ((GfrScrCtrTopSpcTreAbs) super._scr).isAllowedFolderAllCollapseTree();
      ((GfrTbrHlpSubCtrTreAbs) super._tbr).setEnabledButtonCollapseAll(blnCollapse);
     
      boolean blnExpand = ((GfrScrCtrTopSpcTreAbs) super._scr).isAllowedFolderAllExpandTree();
      ((GfrTbrHlpSubCtrTreAbs) super._tbr).setEnabledButtonExpandAll(blnExpand);
   }
  
  
  
}
TOP

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

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.