Package org.geoforge.guillc.treenode

Source Code of org.geoforge.guillc.treenode.GfrNodCtrMovFolderLblTloPrjAbs

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


import java.awt.event.ActionListener;
import java.util.Observable;
import javax.swing.tree.TreeNode;
import org.geoforge.guillc.handler.IGfrHandlerDisplayableObjectsSet;
import org.geoforge.guillc.handler.IGfrHandlerRenamerChildNode;
import org.geoforge.guillc.handler.IGfrHandlerToggableNode;
import org.geoforge.guillc.tree.GfrTreAbs;
import org.geoforge.mdldat.event.*;

/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
* !!! notion of check in Lbl !!!!!!!!!!!!
*
*/
abstract public class GfrNodCtrMovFolderLblTloPrjAbs extends GfrNodCtrMovFolderAbs
{
    protected ActionListener _alrParentPanelMvc = null;
    transient protected ActionListener _alrControllerPerspective = null;

    protected GfrNodCtrMovFolderLblTloPrjAbs(
            ActionListener alrControllerSpcPrj,
            ActionListener alrControllerSpcPrsRun,
            ActionListener alrParentPanelMvc,
            String strId,
            String userObject,
            IGfrHandlerDisplayableObjectsSet enuValueKindObjectTlo,
            GfrTreAbs tre)
    {
        super(alrControllerSpcPrj,
                strId,
                userObject,
                enuValueKindObjectTlo.getSmallImageIconItemDisplayableObjectsSet(),
                tre);
       
        this._alrControllerPerspective = alrControllerSpcPrsRun;
        this._alrParentPanelMvc = alrParentPanelMvc;
    }
   
    @Override
   public void update(Observable obs, Object objEvt)
   {
      if (objEvt instanceof GfrEvtMdlIdDatAddedLloVarAbs)
         return;
     
      if (objEvt instanceof GfrEvtMdlIdDatRemovedLloVarAbs)
         return;
     
      if (objEvt instanceof GfrEvtMdlIdDatRemovedAllLloAbs)
         return;
     
      if (objEvt instanceof GfrEvtMdlIdDatRenamedLloVar)
         return;
     
      if (objEvt instanceof GfrEvtMdlIdDatRenamedTlo)
      {
         GfrEvtMdlIdDatRenamedTlo evt = (GfrEvtMdlIdDatRenamedTlo) objEvt;
         String strId = evt.getId();

         if (strId.compareTo(super._strId) != 0)
            return;

         ((IGfrHandlerRenamerChildNode) super.getParent()).renameChildNode(this, evt.getValueNew());

         return;
      }

      super.update(obs, objEvt);
   }
   
    public void childrenAllCheck()
    {
        boolean blnShouldRedraw = _childrenAllCheck_(this);
       
        if (blnShouldRedraw)
        {
            if (super._tree.isVisible())
                super._tree.repaint();
        }
    }
   
    private boolean _childrenAllCheck_(TreeNode nodParent)
    {
       boolean blnShouldRedraw = false;
      
       for (int i=0; i<nodParent.getChildCount(); i++)
       {
          TreeNode nodCurChild = nodParent.getChildAt(i);
         
          if (nodCurChild.isLeaf())
          {
             if (nodCurChild instanceof IGfrHandlerToggableNode)
             {
                IGfrHandlerToggableNode nodCheck = (IGfrHandlerToggableNode) nodCurChild;
               
                if (nodCheck.isSelectedToggableNode())
                    continue;
               
                nodCheck.setSelected(true);
                blnShouldRedraw = true;
                continue;
             }
            
             continue;
          }
         
          // folder
          blnShouldRedraw |= _childrenAllCheck_(nodCurChild);
       }
      
       return blnShouldRedraw;
    }
   
    private boolean _childrenAllUncheck_(TreeNode nodParent)
    {
       boolean blnShouldRedraw = false;
      
       for (int i=0; i<nodParent.getChildCount(); i++)
       {
          TreeNode nodCurChild = nodParent.getChildAt(i);
         
          if (nodCurChild.isLeaf())
          {
             if (nodCurChild instanceof IGfrHandlerToggableNode)
             {
                IGfrHandlerToggableNode nodCheck = (IGfrHandlerToggableNode) nodCurChild;
               
                if (! nodCheck.isSelectedToggableNode())
                    continue;
               
                nodCheck.setSelected(false);
                blnShouldRedraw = true;
                continue;
             }
            
             continue;
          }
         
          // folder
          blnShouldRedraw |= _childrenAllUncheck_(nodCurChild);
       }
      
       return blnShouldRedraw;
    }

    public void childrenAllUncheck()
    {
        boolean blnShouldRedraw = _childrenAllUncheck_(this);
       
        if (blnShouldRedraw)
        {
            if (super._tree.isVisible())
                super._tree.repaint();
        }
    }
   
}

TOP

Related Classes of org.geoforge.guillc.treenode.GfrNodCtrMovFolderLblTloPrjAbs

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.