Package org.geoforge.guillc.tabbedpane

Source Code of org.geoforge.guillc.tabbedpane.GfrTabDspSecClsNoJfcChartAbs

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

import java.text.Collator;
import java.util.Observable;
import java.util.logging.Logger;
import javax.swing.event.ChangeListener;
import org.geoforge.guillc.handler.IGfrHandlerDisplayableObjectsSet;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.guillc.panel.GfrPnlPrintableSctAwtDspSecTloJfcChartAbs;
import org.geoforge.guillc.panel.GfrPnlStatusBarAbs;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdl.event.GfrEvtMdlIdAbs;
import org.geoforge.mdldat.event.*;
import org.geoforge.mdldsp.event.state.multiple.GfrEvtMdlTogMltSecCbx;
import org.geoforge.mdldsp.event.state.singleton.selecttlo.GfrEvtMdlSttSngSelTlo;

/**
*
* @author bantchao
*/
abstract public class GfrTabDspSecClsNoJfcChartAbs extends GfrTabDspSecClsNoAbs
{
   //--
   //--beg static
   // ----
   // begin: instantiate logger for this class
   final private static Logger _LOGGER_ = Logger.getLogger(GfrTabDspSecClsNoJfcChartAbs.class.getName());

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

  
   abstract protected boolean _deleteAllCandidates(Observable obs) throws Exception;
   abstract protected Object _addCandidateObjectSelected(String strId) throws Exception;
   abstract protected Object _addCandidateObjectChecked(String strId) throws Exception;
  
  
   protected GfrTabDspSecClsNoJfcChartAbs(
           GfrPnlStatusBarAbs pnlStatusBar,
           ChangeListener lstChangeOwnerFrame,
           String strIdViewer
           )
   {
      super(pnlStatusBar, strIdViewer);
     
      if (lstChangeOwnerFrame != null)
         super.addChangeListener(lstChangeOwnerFrame);
   }
  
  
   public void zoomToTlo(String strIdTlo)
   {
      int intCount = super.getComponentCount();
     
      if (intCount == 0)
         return;
     
      for (int i=0; i<intCount; i++)
      {
         GfrPnlPrintableSctAwtDspSecTloJfcChartAbs pnlCur = (GfrPnlPrintableSctAwtDspSecTloJfcChartAbs) super.getComponentAt(i);
        
         try
         {
            String strIdTloCur = pnlCur.getIdTlo();
           
            if (strIdTloCur.compareTo(strIdTlo) != 0)
               continue;
           
            super.setSelectedIndex(i);
            return;
         }
        
         catch(Exception exc)
         {
            exc.printStackTrace();
            return;
         }
      }
     
     
   }
  
    @Override
   public void update(Observable obs, Object objEvt)
   {
      try
      {
         if (objEvt instanceof GfrEvtMdlIdDatRenamedTlo)
         {
            GfrEvtMdlIdDatRenamedTlo evt = (GfrEvtMdlIdDatRenamedTlo) objEvt;
            String strId = evt.getId();
            String strNameNew = evt.getValueNew();
           
            _updateRenamedTlo_(strId, strNameNew);
           
            return;
         }
        
        
         if (objEvt instanceof GfrEvtMdlIdDatRemovedLloVarAbs)
            return;
        
         if (objEvt instanceof GfrEvtMdlIdDatAddedLloVarAbs)
            return;
        
         if (objEvt instanceof GfrEvtMdlIdDatRemovedAllLloAbs)
            return;
        
         // ---
        
       
         if (objEvt instanceof GfrEvtMdlDtaRemovedAllTlo)
         {
            _deleteAllCandidates(obs)
            return;
         }
        
         if (objEvt instanceof GfrEvtMdlIdDatRemovedTlo)
         {
            GfrEvtMdlIdDatRemovedTlo evtRemovedTlo = (GfrEvtMdlIdDatRemovedTlo) objEvt;
            _removeObject(evtRemovedTlo.getId());
           
            return;
         }
        
         if (objEvt instanceof GfrEvtMdlIdDatAddedTlo ||
             objEvt instanceof GfrEvtMdlIdDatClonedTlo)
         {
            GfrEvtMdlIdAbs evtId = (GfrEvtMdlIdAbs) objEvt;
            _addCandidateObjectSelected(evtId.getId());
           
            return;
         }

         if (objEvt instanceof GfrEvtMdlSttSngSelTlo)
         {
            GfrEvtMdlSttSngSelTlo evtSelTlo = (GfrEvtMdlSttSngSelTlo) objEvt;

            String strIdTlo = evtSelTlo.getKey();

            boolean bln = evtSelTlo.getValue();           
           
            if (! bln)
            {
               _removeObject(strIdTlo);
               return;
            }
     
   
            _addCandidateObjectSelected(strIdTlo);
            // ending
            return;
         }

         if (objEvt instanceof GfrEvtMdlTogMltSecCbx)
         {
            GfrEvtMdlTogMltSecCbx evt = (GfrEvtMdlTogMltSecCbx) objEvt;
     
            String strIdViewer = evt.getKeyViewer();

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

            String strId = evt.getKeyObject();
            boolean bln = evt.getValueObject();
           
            // memo: could not be tlo
           
            if (! bln)
            {
               _removeObject(strId); // if existing
               return;
            }
           
            _addCandidateObjectChecked(strId);
            return;
         }
      }

      catch (Exception exc)
      {
         exc.printStackTrace();
         String str = exc.getMessage();
         GfrTabDspSecClsNoJfcChartAbs._LOGGER_.severe(str);
         GfrOptionPaneAbs.s_showDialogError(null, str);
         return;
      }
     
      /*String strDummy = "uncaught event: objEvt.getClass().toString():" + objEvt.getClass().toString();
      strDummy += "\n" + "this.getClass().toString():" + this.getClass().toString();;
      GfrTabDspSecClsNoJfcChartAbs._LOGGER_.info(strDummy);*/
   }
  
  
  
  
  
  
  
  
   private void _updateRenamedTlo_(String strId, String strNameNew)
   {
      for (int i = 0; i < super.getComponentCount(); i++)
      {
         GfrPnlPrintableSctAwtDspSecTloJfcChartAbs pnlCur = (GfrPnlPrintableSctAwtDspSecTloJfcChartAbs) super.getComponentAt(i);
        
         String strIdCur = pnlCur.getIdTlo();
        
         if (strIdCur.compareTo(strId) != 0)
            continue;
        
         super.setTitleAt(i, strNameNew);
         return;
      }
   }
  
   protected void _insertTab(GfrPnlPrintableSctAwtDspSecTloJfcChartAbs pnl, IGfrHandlerDisplayableObjectsSet enuValueKindObject)
           throws Exception
   {
      String strName = pnl.getUniqueNameTlo();

      Collator myDefaultCollator = Collator.getInstance();

      for (int i = 0; i < super.getComponentCount(); i++)
      {
         GfrPnlPrintableSctAwtDspSecTloJfcChartAbs pnlCur = (GfrPnlPrintableSctAwtDspSecTloJfcChartAbs) super.getComponentAt(i);

         String strNameCur = pnlCur.getUniqueNameTlo();

         if (myDefaultCollator.compare(strName, strNameCur) != -1)
            continue;

         super.insertTab(strName, enuValueKindObject.getSmallImageIconItemDisplayableObjectsSet(), pnl, (String) null, i);

         return;

      }

      // ----
      super.addTab(strName, enuValueKindObject.getSmallImageIconItemDisplayableObjectsSet(), pnl);
   }
  
   protected boolean _removeObject(String strIdTlo) throws Exception
   {
      for (int i=0; i<super.getComponentCount(); i++)
      {

         GfrPnlPrintableSctAwtDspSecTloJfcChartAbs pnlCur = (GfrPnlPrintableSctAwtDspSecTloJfcChartAbs) super.getComponentAt(i);
         String strUniqueIdCur = pnlCur.getIdTlo();

         if (strUniqueIdCur.compareTo(strIdTlo) != 0)
            continue;

         // doJob
         super.remove(pnlCur);
         pnlCur.destroy();

         // ending
         return true;
      }
     
      return false;
   }
}
TOP

Related Classes of org.geoforge.guillc.tabbedpane.GfrTabDspSecClsNoJfcChartAbs

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.