Package org.geoforge.guillc.treenode

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

/*
*  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 java.util.Observer;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import org.geoforge.awt.image.GfrFactoryIconAbs;
import org.geoforge.guillc.handler.IGfrHandlerDisplayableObjectsSet;
import org.geoforge.guillc.handler.IGfrHandlerRenamerChildNode;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.guillc.panel.GfrPnlStatusBarMain;
import org.geoforge.guillc.tree.GfrTreAbs;
import org.geoforge.guillc.tree.GfrTreCtrTopSpcTogChkPrjSelCatTlosAbs;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldat.event.GfrEvtMdlIdDatRenamedTlo;
import org.geoforge.mdldsp.event.state.singleton.GfrEvtMdlSttSngAbs;
import org.geoforge.mdldsp.event.state.singleton.selecttlo.GfrEvtMdlSttSngSelTlo;
import org.geoforge.mdldsp.state.singleton.selecttlo.GfrMdlSttSngSelTlo;
import org.geoforge.wrpbasprsdsp.state.singleton.selecttlo.GfrWrpObjSttSngSelTlo;

/**
*
* @author bgwilliams71
*
* email: bgwilliams71_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*/
abstract public class GfrNodCtrMovLeafPrjChkCbxSelTloAbs extends GfrNodCtrMovLeafPrjChkCbxAbs
{
   // ----
   // begin: instantiate logger for this class

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

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

   // end: instantiate logger for this class
   // ----
   protected GfrNodCtrMovLeafPrjChkCbxSelTloAbs(
           ActionListener alrControllerSpcPrj,
           ActionListener alrControllerPrs,
           String strIdUnique,
           String strName,
           GfrTreAbs tre,
           IGfrHandlerDisplayableObjectsSet enuValueKindObject)
           throws Exception
   {
      super(
              alrControllerSpcPrj,
              alrControllerPrs,
              strIdUnique,
              strName,
              (ImageIcon) null,
              tre,
              GfrWrpObjSttSngSelTlo.getInstance().isEnabled(strIdUnique),
              GfrPnlStatusBarMain.s_getInstance());


      GfrMdlSttSngSelTlo.getInstance().addObserver((Observer) this);

      //??? Maybe this line could be located in the super call, instead of null????
      super.setImageIcon(enuValueKindObject.getSmallImageIconItemDisplayableObjectsSet());
   }

   @Override
   public void destroy()
   {
      GfrMdlSttSngSelTlo.getInstance().deleteObserver((Observer) this);

      super.destroy();
   }

   /*
    * memo: could be called by:
    * . MouseAdapterNodTogCbx (clicking on respective checkbox)
    * . popUpMenu of respective parent's node
    * . ???
    */
   @Override
   public void setSelected(boolean bln)
   {
      super.setSelected(bln);

      try
      {
         GfrMdlSttSngSelTlo.getInstance().doJob(super._strId, bln);
      }
      catch (Exception exc)
      {
         exc.printStackTrace();
         String str = exc.getMessage();
         GfrNodCtrMovLeafPrjChkCbxSelTloAbs._LOGGER_.severe(str);
         GfrOptionPaneAbs.s_showDialogError(null, str);
         return;
      }
   }

   @Override
   public void update(Observable obs, Object objEvt)
   {
      if (objEvt instanceof GfrEvtMdlSttSngSelTlo)
      {
         GfrEvtMdlSttSngAbs evt = (GfrEvtMdlSttSngAbs) objEvt;
         String strId = evt.getKey();

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

         boolean blnValue = evt.getValue();

         if (blnValue && super._blnIsSelected)
            return;

         if (!blnValue && !super._blnIsSelected)
            return;

         super.setSelected(blnValue);

         // TRICK
         if (super._tree != null)
         {
            ((GfrTreCtrTopSpcTogChkPrjSelCatTlosAbs) super._tree).fireValueChangedTrick();
         }

         return;
      }

      if (objEvt instanceof GfrEvtMdlIdDatRenamedTlo)
      {
         GfrEvtMdlIdDatRenamedTlo evt = (GfrEvtMdlIdDatRenamedTlo) objEvt;
         String strId = evt.getId();

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

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

         return;
      }

      super.update(obs, objEvt);
   }
}
TOP

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

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.