Package org.geoforge.guillc.tabbedpane

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

/*
*  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.util.ArrayList;
import javax.help.HelpBroker;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.geoforge.guihlp.handler.IGfrHandlerSetEnabledTrueHelpOnThisSection;
import org.geoforge.guillc.panel.GfrPnlPrintableSctAwtSpcWlcAbs;
import org.geoforge.awt.image.GfrFactoryIconAbs;
import org.geoforge.io.awt.image.GfrFactoryIconAppGfr;
import org.geoforge.lang.handler.IGfrHandlerLifeCycleObject;
import org.geoforge.lang.util.GfrResBundleLang;


/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*/
/*
* "Spc" means "Space"
*/
abstract public class GfrTabSpcAppAbs extends GfrTab implements
        IGfrHandlerSetEnabledTrueHelpOnThisSection,
        ChangeListener
{
    protected GfrPnlPrintableSctAwtSpcWlcAbs _pnlWelcome = null;
    protected ArrayList<IGfrHandlerSetEnabledTrueHelpOnThisSection> _altPanels_ = null;
   
    public String getKind() { return this._strKind; }
   
    abstract protected void _updateStateChanged(int intIndex);

    @Override
    public void setEnabledTrueHelpOnThisSection(HelpBroker hbr)
    {
        for (int i=0; i<this._altPanels_.size(); i++)
        {
            this._altPanels_.get(i).setEnabledTrueHelpOnThisSection(hbr);
        }
    }
   
    @Override
    public void stateChanged(ChangeEvent evtChange)
    {
      JTabbedPane tabSource = (JTabbedPane) evtChange.getSource();
      int index = tabSource.getSelectedIndex();
      _updateStateChanged(index);
    }


    protected GfrTabSpcAppAbs(String strKind)
    {
        super();

        this._altPanels_ = new ArrayList<IGfrHandlerSetEnabledTrueHelpOnThisSection>();

        this._strKind = strKind;
    }

    @Override
    public boolean init()
    {
        if (! super.init())
            return false;
       
        if (this._pnlWelcome != null)
        {
            super.addTab(
                    GfrResBundleLang.s_getInstance().getValue("word.welcome"),
                GfrFactoryIconAppGfr.s_getHome(GfrFactoryIconAbs.INT_SIZE_XXSMALL),
                this._pnlWelcome);
        }

        for (int i=0; i<this._altPanels_.size(); i++)
        {
            IGfrHandlerLifeCycleObject objCur = (IGfrHandlerLifeCycleObject) this._altPanels_.get(i);
           
            if (! objCur.init())
                return false;
        }

        return true;
    }

    @Override
    public void destroy()
    {
        super.destroy();

        for (int i=0; i<this._altPanels_.size(); i++)
        {
            IGfrHandlerLifeCycleObject objCur = (IGfrHandlerLifeCycleObject) this._altPanels_.get(i);
           
            if (objCur != null)
            {
                objCur.destroy();
            }
        }

        this._altPanels_.clear();
        this._altPanels_ = null;

        this._strKind = null;
    }


    private String _strKind = null;
}
TOP

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

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.