/*
* 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.toolbar;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
import javax.swing.JSeparator;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
import org.geoforge.guillc.button.BtnTransientAbs;
import org.geoforge.guillc.button.BtnTransientAllCollapse;
import org.geoforge.guillc.button.BtnTransientAllExpand;
/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*/
/*
* "Ctr" means "Control"
* "Tre" means "Tree"
*/
abstract public class GfrTbrHlpSubCtrTreAbs extends GfrTbrHlpSubPrnSpcCtrAbs
{
private BtnTransientAbs _btnAllExpand_ = null;
protected BtnTransientAbs _btnAllCollapse = null;
public void setEnabledButtonCollapseAll(boolean bln)
{
if (this._btnAllCollapse != null)
this._btnAllCollapse.setEnabled(bln);
}
public void setEnabledButtonExpandAll(boolean bln)
{
if (this._btnAllExpand_ != null)
this._btnAllExpand_.setEnabled(bln);
}
final private int _intPositionThis_;
protected GfrTbrHlpSubCtrTreAbs(
MouseListener mlrEffectsBorder,
ActionListener alrParentComponent,
int intPositionThis,
int inSizeIcons)
{
super(
mlrEffectsBorder,
alrParentComponent,
intPositionThis,
inSizeIcons
);
this._intPositionThis_ = intPositionThis;
this._btnAllExpand_ = new BtnTransientAllExpand(alrParentComponent, inSizeIcons);
this._btnAllCollapse = new BtnTransientAllCollapse(alrParentComponent, inSizeIcons);
}
@Override
public void closeSpace() throws Exception
{
super.closeSpace();
this._btnAllCollapse.setEnabled(false);
this._btnAllExpand_.setEnabled(false);
}
@Override
public boolean init()
{
if (! super.init()) // !!!
return false;
if (! this._btnAllExpand_.init())
return false;
if (! this._btnAllCollapse.init())
return false;
int intPos = 0;
super.add(this._btnAllExpand_, intPos++);
super.add(this._btnAllCollapse, intPos++);
JSeparator sep;
if (this._intPositionThis_ == JToolBar.HORIZONTAL)
sep = new JSeparator(SwingConstants.VERTICAL);
else
sep = new JSeparator(SwingConstants.HORIZONTAL);
sep.setMaximumSize(new Dimension(super._intSizeIcons, super._intSizeIcons));
sep.setMinimumSize(new Dimension(super._intSizeIcons, super._intSizeIcons));
super.add(sep, intPos++);
return true;
}
@Override
public void destroy()
{
super.destroy();
if (this._btnAllExpand_ != null)
{
this._btnAllExpand_.destroy();
this._btnAllExpand_ = null;
}
if (this._btnAllCollapse != null)
{
this._btnAllCollapse.destroy();
this._btnAllCollapse = null;
}
}
@Override
public void loadTransient() throws Exception
{
this._btnAllExpand_.loadTransient();
this._btnAllCollapse.loadTransient();
super.loadTransient();
}
@Override
public void releaseTransient() throws Exception
{
this._btnAllExpand_.releaseTransient();
this._btnAllCollapse.releaseTransient();
super.releaseTransient();
}
@Override
protected void _resetButtonsNotEmpty()
{
if (! super._blnIsOpen)
return;
super._resetButtonsNotEmpty();
this._btnAllExpand_.setEnabled(true);
}
@Override
protected void _resetButtonsEmpty()
{
if (! super._blnIsOpen)
return;
super._resetButtonsEmpty();
this._btnAllCollapse.setEnabled(false);
this._btnAllExpand_.setEnabled(false);
}
}