Package org.geoforge.guillc.menubar

Source Code of org.geoforge.guillc.menubar.GfrMbrAbs

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

import java.awt.Component;
import javax.help.HelpBroker;
import javax.swing.Box;
import javax.swing.JMenuBar;
import org.geoforge.guihlp.handler.IGfrHandlerSetEnabledTrueHelpOnThisSection;
import org.geoforge.guillc.menu.*;
import org.geoforge.io.handler.IGfrHandlerUnserializedObject;
import org.geoforge.lang.handler.IGfrHandlerLifeCycleObject;

/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*/

abstract public class GfrMbrAbs extends JMenuBar implements
        IGfrHandlerLifeCycleObject,
        IGfrHandlerSetEnabledTrueHelpOnThisSection,
        IGfrHandlerUnserializedObject // !!!!!!!!!!!!!!!!!!!!!!!!!!!!
{
    protected GfrMenFle _menFile = null;      // mandatory
    protected GfrMenViewAbs _menView = null;      // optional
    protected GfrMenIcnTlsAbs _menTools = null// optional
    protected GfrMenWinAbs _menWindow = null;    // optional
    protected GfrMenHlpAbs _menHelp = null;      // optional

    protected GfrMbrAbs()
    {
        super();   
    }


    @Override
    public boolean init()
    {
       
        // ----
        /// initing
       
        if (! this._menFile.init())
            return false;


        if (this._menView != null)
            if (! this._menView.init())
                return false;
   

        if (this._menTools != null)
        {
            if (! this._menTools.init())
                return false;
        }

        if (this._menWindow != null)
        {
            if (! this._menWindow.init())
                return false;
        }

        if (this._menHelp != null)
           if (! this._menHelp.init())
              return false;
       
        // ----
        // adding


        super.add(this._menFile);

        if (this._menView != null)
            super.add(this._menView);

        if (this._menTools != null)
            super.add(this._menTools);

        if (this._menWindow != null)
            super.add(this._menWindow);

        if (this._menHelp != null)
        {
            super.add(Box.createHorizontalGlue());
            super.add(Box.createVerticalGlue()); // !!
            super.add(this._menHelp);
        }

        return true;
    }

    @Override
    public void destroy()
    {
        for (int i=0; i<super.getComponentCount(); i++)
        {
            Component cmpCur = super.getComponent(i);

            if (cmpCur instanceof IGfrHandlerLifeCycleObject)
            {
                IGfrHandlerLifeCycleObject objCur = (IGfrHandlerLifeCycleObject) cmpCur;
               
                if (objCur != null)
                {
                  objCur.destroy();
                  objCur = null;
                }
            }
        }
    }

    @Override
    public void loadUnserializedObject() throws Exception
    {

        for (int i=0; i<super.getComponentCount(); i++)
        {
            Component cmpCur = super.getComponent(i);

            if (cmpCur instanceof IGfrHandlerUnserializedObject)
            {
                IGfrHandlerUnserializedObject serCur = (IGfrHandlerUnserializedObject) cmpCur;
                serCur.loadUnserializedObject();
            }
        }
    }
   
    @Override
    public void releaseUnserializedObject() throws Exception
    {
        for (int i=0; i<super.getComponentCount(); i++)
        {
            Component cmpCur = super.getComponent(i);

            if (cmpCur instanceof IGfrHandlerUnserializedObject)
            {
                IGfrHandlerUnserializedObject serCur = (IGfrHandlerUnserializedObject) cmpCur;
                serCur.releaseUnserializedObject();
            }
        }
    }
   
    @Override
    public void setEnabledTrueHelpOnThisSection(HelpBroker hbr)
    {
        if (this._menHelp != null)
            ((IGfrHandlerSetEnabledTrueHelpOnThisSection) this._menHelp).setEnabledTrueHelpOnThisSection(hbr);
    }
}
TOP

Related Classes of org.geoforge.guillc.menubar.GfrMbrAbs

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.