Package org.geoforge.guillc.internalframe

Source Code of org.geoforge.guillc.internalframe.GfrIfrWinViewRunIdSpcPlgVolTloAbs

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.geoforge.guillc.internalframe;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionListener;
import java.beans.PropertyVetoException;
import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.help.HelpBroker;
import javax.swing.JComponent;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.event.InternalFrameListener;
import org.geoforge.guihlp.handler.IGfrHandlerSetEnabledTrueHelpOnThisSection;
import org.geoforge.guillc.border.GfrBorderHelpOnThis;
import org.geoforge.guillc.panel.GfrPnl;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.lang.handler.IGfrHandlerLifeCycleObject;
import org.geoforge.mdldsp.action.control.GfrMdlDspActCtrMainRunPrc;
import org.geoforge.mdldsp.event.action.control.GfrEvtMdlDspActCtrIdZoomAbs;
import org.geoforge.mdldsp.event.action.control.GfrEvtMdlDspActCtrIdZoomObject;

/*
* !!
*/

/**
*
* @author bantchao
*/
abstract public class GfrIfrWinViewRunIdSpcPlgVolTloAbs extends GfrIfrWinViewRunIdAbs  implements
        IGfrHandlerSetEnabledTrueHelpOnThisSection,
        Observer
{
    static private String _s_getPrefixTitle_(String strNamePlugin, String strNameTlo)
    {
        return strNamePlugin + " - " + strNameTlo;
    }
   
   
    // tempo location
    static public boolean _BLN_ALWAYS_SAVE = false;
    static public boolean _BLN_ALWAYS_DONT_SAVE = false;
   
   
    final private static Logger _LOGGER_ = Logger.getLogger(GfrIfrWinViewRunIdSpcPlgVolTloAbs.class.getName());

   static
   {
      GfrIfrWinViewRunIdSpcPlgVolTloAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
   }
   
   // ---
  
   protected String _strNamePlugin;
   protected String _strNameTlo;
   private String _strSuffixTitle_;
  
   private String _strIdTlo_ = null;
   protected GfrPnl _pnlContentPane_ = null;
   protected ArrayList<IGfrHandlerLifeCycleObject> _altObjComponentChildren = null;
   public String getIdTlo() { return this._strIdTlo_; }
  
  
  
   abstract public void openSpaceLeaf(ActionListener lstAction) throws Exception;
  
   abstract public void closeSpaceLeaf() throws Exception;
   /*
     * could be the place to store frame's bounds
     */
    abstract public void closeSpaceRoot() throws Exception;
  
  
   abstract public boolean canSave();
   abstract public void doSave();
   
   
    protected GfrIfrWinViewRunIdSpcPlgVolTloAbs(
            int intWidthPref,
           int intHeightPref,
           InternalFrameListener ifrListenerController,
           String strUniqueIdMe,
           String strIdTlo,
           String strNameTlo,
            String strNamePlugin
           ) throws Exception
    {
        super(
                intWidthPref,
                intHeightPref,
                ifrListenerController,
                strUniqueIdMe,
                "_DUMMY_strUniqueNameMe" // wrong
                );
       
        this._strIdTlo_ = strIdTlo;
        this._strNameTlo = strNameTlo;
        this._strNamePlugin = strNamePlugin;
       
        this._altObjComponentChildren = new ArrayList<IGfrHandlerLifeCycleObject>();
       
        // ---
        this._pnlContentPane_ = new GfrPnl(new BorderLayout());
       
        /*if (! this._pnlContentPane_.init())
        {
            String strError = "! this._pnlContentPane_.init()";
            GfrIfrWinViewRunIdSpcPlgVolTloAbs._LOGGER_.severe(strError);
            throw new Exception(strError);
        }*/
       
        super.setContentPane(this._pnlContentPane_);
        GfrBorderHelpOnThis.s_set(this._pnlContentPane_);
    }
   
    private void _updateTitle_()
    {
        String str = _s_getPrefixTitle_(this._strNamePlugin, this._strNameTlo);
      
       if (this._strSuffixTitle_!=null && this._strSuffixTitle_.length()>0)
       {
           str += " - " + this._strSuffixTitle_;
       }
      
       super.setTitle(str);
    }
   
    protected void _updateTitle(String strNameTloNew)
   {
       this._strNameTlo = strNameTloNew;
      
       _updateTitle_();
   }
   
    @Override
    public void destroy()
    {
        super.destroy();
       
        if (this._pnlContentPane_ != null)
        {
            this._pnlContentPane_.destroy();
            this._pnlContentPane_ = null;
        }
    }
   
    @Override
    public boolean init()
    {
        if (! super.init())
            return false;
       
        if (! this._pnlContentPane_.init())
        {
            String strError = "! this._pnlContentPane_.init()";
            GfrIfrWinViewRunIdSpcPlgVolTloAbs._LOGGER_.severe(strError);
            return false;
        }

        for (int i=0; i<this._altObjComponentChildren.size(); i++)
        {
            IGfrHandlerLifeCycleObject obj = this._altObjComponentChildren.get(i);

            if (! obj.init())
                return false;
        }
       
        //this._pnlContentPane.add(GfrPnlStatusBarMain.s_getInstance(), BorderLayout.SOUTH);
       
        return true;
    }
   
    @Override
   public void update(Observable obs, Object objEvent)
   {
      if (objEvent instanceof GfrEvtMdlDspActCtrIdZoomObject)
      {
         GfrEvtMdlDspActCtrIdZoomAbs actEvent = (GfrEvtMdlDspActCtrIdZoomAbs) objEvent;
        
         String strIdTarget = actEvent.getIdTarget();
        
         if (this._strIdTlo_.compareTo(strIdTarget) != 0)
             return;
        
         if (super.isIcon())
            try
            {
                super.setIcon(false);
            }
            catch (PropertyVetoException ex)
            {
                Logger.getLogger(GfrIfrWinViewRunIdRegVolPlgCtrTloAbs.class.getName()).log(Level.SEVERE, null, ex);
            }
        
         super.toFront();
        
         return;
      }
     
      // TODO: specialize for mlos, llos, and so on
   }
   
    @Override
    public void setEnabledTrueHelpOnThisSection(HelpBroker hbr)
    {
        for (int i=0; i<this._altObjComponentChildren.size(); i++)
        {
            IGfrHandlerLifeCycleObject obj = this._altObjComponentChildren.get(i);

            if (obj instanceof IGfrHandlerSetEnabledTrueHelpOnThisSection)
            {
                ((IGfrHandlerSetEnabledTrueHelpOnThisSection) obj).setEnabledTrueHelpOnThisSection(hbr);
            }
        }
    }
   
    protected void _setSpace(
            String strSuffixTitle,
            JMenuBar mbr,
            JToolBar tbr,
            JPanel pnlContents,
            JPanel pnlStatusBar)
    {
        this._strSuffixTitle_ = strSuffixTitle;
        _updateTitle_();

        JMenuBar mbrPrev = super.getJMenuBar();

        if (mbrPrev != null)
            super.remove(mbrPrev);

        super.setJMenuBar(mbr);

        //Component[] cmps = super.getContentPane().getComponents();
        Component[] cmps = this._pnlContentPane_.getComponents();
       
        boolean blnSameContents = false;
        boolean blnSameStatusBar = false;
       
        // removing toolbar and contents
        for (int i=0; i<cmps.length; i++)
        {
            if (cmps[i] instanceof JPanel)
            {
                if (cmps[i] == pnlContents)
                {
                    blnSameContents = true; // ie: same space, different perspective
                    continue;
                }
               
                if (cmps[i] == pnlStatusBar)
                {
                    blnSameStatusBar = true; // ie: same space, different perspective
                    continue;
                }
            }
           
            this._pnlContentPane_.remove(cmps[i]);  
        }

        this._pnlContentPane_.add(tbr, BorderLayout.NORTH);
       
        if (! blnSameContents)
           this._pnlContentPane_.add((Component) pnlContents, BorderLayout.CENTER);
       
        if (! blnSameStatusBar)
           this._pnlContentPane_.add((Component) pnlStatusBar, BorderLayout.SOUTH);

     
        /*String strTitle = System.getProperty(GfrEnuSystemPropertiesKeys.NAME_LONG_APPLI.getLabel());

        if (strTypeDisplay != null) // TODO: first letter in upperCase
        {
            strTitle += " - ";
            strTitle += strTypeDisplay;
        }*/

       

     
        JComponent cmp = (JComponent) this._pnlContentPane_;
        cmp.revalidate();
       
        if (cmp.isVisible())
            cmp.repaint();
    }
   
    @Override
    public void loadTransient() throws Exception
    {
        super.loadTransient();
       
        GfrMdlDspActCtrMainRunPrc.s_getInstance().addObserver((Observer) this);
    }
   
    @Override
    public void releaseTransient() throws Exception
    {
       GfrMdlDspActCtrMainRunPrc.s_getInstance().deleteObserver((Observer) this);
        super.releaseTransient();
    }
   
  
}
TOP

Related Classes of org.geoforge.guillc.internalframe.GfrIfrWinViewRunIdSpcPlgVolTloAbs

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.