/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.geoforge.guillc.splitpane;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.logging.Logger;
import javax.help.HelpBroker;
import javax.swing.JSplitPane;
import org.geoforge.guihlp.handler.IGfrHandlerSetEnabledTrueHelpOnThisSection;
import org.geoforge.guillc.handler.IGfrHandlerCloseSpace;
import org.geoforge.guillc.jdesktop.swingx.jxtaskpanecontainer.GfrTpc;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.guillc.panel.GfrPnlPrintableSctAwtCtrAbs;
import org.geoforge.guillc.panel.GfrPnlCtrsAppSpcAbs;
import org.geoforge.guillc.scrollpane.GfrScr;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
/*
* at left: controls
* ie project ==> control objects
* ie workspace ==> control "my" default objects
* at right:
* ie project ==> display wwdEarthMan, wwdEarthSel, desktopInternalFramesRun
* ie workspace ==> display appli's default objects (ATTN: as not editable "controls")
*/
/**
*
* @author bantchao
*/
abstract public class GfrSplHlpMainAppAbs extends GfrSplHlpAbs implements
ActionListener,
IGfrHandlerCloseSpace,
PropertyChangeListener
{
final private static Logger _LOGGER_ = Logger.getLogger(GfrSplHlpMainAppAbs.class.getName());
static
{
GfrSplHlpMainAppAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// ---
protected HelpBroker _hbr = null;
protected GfrPnlPrintableSctAwtCtrAbs _pnlControlLeftThis = null; // could remain nil, ie Geozilla
protected GfrPnlCtrsAppSpcAbs _pnlControlsLeft = null;
protected GfrTpc _tpcCtrsLeft = null;
private String _strNameTabThis_ = null;
private GfrScr _scrCtrsLeft_ = null;
abstract protected void _saveValueLocationDivider(int intVal) throws Exception;
abstract protected int _loadValueLocationDivider() throws Exception;
protected GfrSplHlpMainAppAbs(String strNameTabThis)
{
super();
this._strNameTabThis_ = strNameTabThis;
this._tpcCtrsLeft = new GfrTpc();
this._scrCtrsLeft_ = new GfrScr((Component) this._tpcCtrsLeft);
}
@Override
public void setDividerLocation(int intVal)
{
super.setDividerLocation(intVal);
}
@Override
public void propertyChange(PropertyChangeEvent evtPropertyChange)
{
String strName = evtPropertyChange.getPropertyName();
if (strName.compareTo(JSplitPane.DIVIDER_LOCATION_PROPERTY) != 0)
return;
Object objNewValue = evtPropertyChange.getNewValue();
Integer itgNewValue = (Integer) objNewValue;
int intNewValue = itgNewValue.intValue();
if (intNewValue < 1)
return;
try
{
_saveValueLocationDivider(intNewValue);
}
catch(Exception exc)
{
exc.printStackTrace();
GfrSplHlpMainAppAbs._LOGGER_.severe(exc.getMessage());
GfrOptionPaneAbs.s_showDialogError(null, exc.getMessage());
}
}
@Override
public void actionPerformed(ActionEvent e)
{
String str = "uncaught source, e.getSource().getClass().toString()=" +
e.getSource().getClass().toString();
GfrSplHlpMainAppAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, str);
}
@Override
public void closeSpace() throws Exception
{
super.removePropertyChangeListener((PropertyChangeListener) this);
if (this._pnlControlLeftThis != null)
this._pnlControlLeftThis.closeSpace();
if (this._pnlControlsLeft != null)
this._pnlControlsLeft.closeSpace();
}
/*
* !!!!!!!!!!
*/
@Override
public void setEnabledTrueHelpOnThisSection(HelpBroker hbr)
{
this._hbr = hbr;
for (int i=0; i<super.getComponentCount(); i++)
{
Component cmp = super.getComponent(i);
if (cmp instanceof IGfrHandlerSetEnabledTrueHelpOnThisSection)
{
((IGfrHandlerSetEnabledTrueHelpOnThisSection) cmp).setEnabledTrueHelpOnThisSection(hbr);
}
}
this._pnlControlsLeft.setEnabledTrueHelpOnThisSection(hbr);
if (this._pnlControlLeftThis != null)
this._pnlControlLeftThis.setEnabledTrueHelpOnThisSection(hbr);
}
@Override
public boolean init()
{
if (! super.init())
return false;
if (! this._pnlControlsLeft.init())
return false;
if (! this._scrCtrsLeft_.init())
return false;
if (this._pnlControlLeftThis != null)
if (! this._pnlControlLeftThis.init())
return false;
if (! this._tpcCtrsLeft.init())
return false;
if (this._pnlControlLeftThis != null)
this._tpcCtrsLeft.add(this._strNameTabThis_, this._pnlControlLeftThis);
this._pnlControlsLeft.add(this._scrCtrsLeft_, BorderLayout.CENTER);
super.add((Component) this._pnlControlsLeft, JSplitPane.LEFT);
return true;
}
@Override
public void destroy()
{
super.destroy();
if (this._pnlControlsLeft != null)
{
this._pnlControlsLeft.destroy();
this._pnlControlsLeft = null;
}
if (this._pnlControlLeftThis != null)
{
this._pnlControlLeftThis.destroy();
this._pnlControlLeftThis = null;
}
if (this._scrCtrsLeft_ != null)
{
this._scrCtrsLeft_.destroy();
this._scrCtrsLeft_ = null;
}
if (this._tpcCtrsLeft != null)
{
this._tpcCtrsLeft.destroy();
this._tpcCtrsLeft = null;
}
}
protected void _openSpace(ActionListener lstAction) throws Exception
{
super.addPropertyChangeListener((PropertyChangeListener) this);
if (this._pnlControlsLeft != null)
this._pnlControlsLeft.openSpaceAny(lstAction);
}
}