/*
* 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.util.Enumeration;
import javax.swing.*;
import org.geoforge.guillc.button.GfrBcnAbs;
import org.geoforge.guillc.button.GfrBcnResetViewDefault;
import org.geoforge.guillc.button.GfrBcnSnapshotOglWwd;
import org.geoforge.guillc.buttongroup.GfrBgpKindViewWwdEarth;
import org.geoforge.guillc.buttongroup.GfrBgp;
import org.geoforge.guillc.togglebutton.GfrTbnAbs;
import org.geoforge.guillc.togglebutton.GfrTbnNetworkWwdEarth;
import org.geoforge.guillc.togglebutton.GfrTbnPreferencesWwdEarth;
import org.geoforge.awt.image.GfrFactoryIconAbs;
/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*/
abstract public class GfrTbrHlpSubDspWwdEarthAbs extends GfrTbrHlpSubDspAbs
{
// beg tempo, should be replaced by combo-box: latLon|UTM|MGRS
//private GfrTbnAbs _tbnPositionUtm_ = null;
protected GfrBgp _bgpKindView = null;
private GfrBcnAbs _btnScreenshot_ = null;
private GfrBcnAbs _btnResetDefaultView_ = null;
private GfrTbnAbs _tbnNetwork_ = null;
private GfrTbnAbs _tbnPreferences_ = null;
final private int _intPositionThis_;
protected GfrTbrHlpSubDspWwdEarthAbs(
int intSizeIcons,
int intInsetRadiobuttons,
int intLocationTextRadioButtons,
ActionListener alrParentComponent,
int intOrientation,
boolean blnLocationToolTipTop) throws Exception
{
super(
"Display toolbar", // strSuffixTitleDetached
intOrientation, intSizeIcons);
this._intPositionThis_ = intOrientation;
this._btnScreenshot_ = new GfrBcnSnapshotOglWwd(
alrParentComponent,
intSizeIcons,
blnLocationToolTipTop);
this._bgpKindView = new GfrBgpKindViewWwdEarth(intSizeIcons,
intInsetRadiobuttons, intLocationTextRadioButtons, alrParentComponent);
this._tbnNetwork_ = new GfrTbnNetworkWwdEarth(intSizeIcons, blnLocationToolTipTop);
//this._tbnPositionUtm_ = new GfrTbnPositionUtmVsMgrs(intSizeIcons);
this._tbnPreferences_ = new GfrTbnPreferencesWwdEarth(intSizeIcons, blnLocationToolTipTop);
this._btnResetDefaultView_ = new GfrBcnResetViewDefault(
GfrFactoryIconAbs.INT_SIZE_SMALL,
true,
alrParentComponent);
this._tbnNetwork_.addActionListener(alrParentComponent);
//this._tbnPositionUtm_.addActionListener(alrParentComponent);
this._tbnPreferences_.addActionListener(alrParentComponent);
}
@Override
public void close() throws Exception
{
super.close();
((GfrBgpKindViewWwdEarth) this._bgpKindView).resetSelected();
}
@Override
public void setEnabledButtons(boolean bln)
{
try
{
this._bgpKindView.setEnabled(bln);
this._tbnNetwork_.setEnabled(bln);
//this._tbnPositionUtm_.setEnabled(bln);
this._tbnPreferences_.setEnabled(bln);
this._btnScreenshot_.setEnabled(bln);
this._btnResetDefaultView_.setEnabled(bln);
}
catch (NullPointerException excNullPointer)
{
excNullPointer.printStackTrace();
throw new Error(excNullPointer.getMessage());
}
}
@Override
public boolean init()
{
if (!this._btnScreenshot_.init())
return false;
if (!this._btnResetDefaultView_.init())
return false;
if (!super.init())
return false;
if (!this._bgpKindView.init())
return false;
if (!this._tbnNetwork_.init())
return false;
//if (! this._tbnPositionUtm_.init())
// return false;
if (!this._tbnPreferences_.init())
return false;
int intPos = 0; // !!!!
if (super._btnPlugins != null)
{
super.add(super._btnPlugins, 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++);
}
// ----
super.add(this._btnScreenshot_, intPos++);
super.add(this._btnResetDefaultView_, intPos++);
intPos = this._add(this._bgpKindView.getElements(), intPos); // ATTN: no ++ out there!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//super.add(new Separator(), intPos++);
//
//intPos++; // btnPrint
//super.add(new Separator(), intPos++);
super.add(this._tbnNetwork_, intPos++);
//super.add(this._tbnPositionUtm_, intPos++);
super.add(this._tbnPreferences_, intPos++);
this.setEnabledButtons(false);
return true;
}
private int _add(Enumeration<AbstractButton> enu, int intPos)
{
while (enu.hasMoreElements())
{
JRadioButton btn = (JRadioButton) enu.nextElement();
super.add(btn, intPos++);
}
return intPos;
}
@Override
public void destroy()
{
super.destroy();
if (this._btnScreenshot_ != null)
{
this._btnScreenshot_.destroy();
this._btnScreenshot_ = null;
}
if (this._btnResetDefaultView_ != null)
{
this._btnResetDefaultView_.destroy();
this._btnResetDefaultView_ = null;
}
if (this._bgpKindView != null)
{
this._bgpKindView.destroy();
this._bgpKindView = null;
}
if (this._tbnNetwork_ != null)
{
this._tbnNetwork_.destroy();
this._tbnNetwork_ = null;
}
/*if (this._tbnPositionUtm_ != null)
{
this._tbnPositionUtm_.destroy();
this._tbnPositionUtm_ = null;
}*/
if (this._tbnPreferences_ != null)
{
this._tbnPreferences_.destroy();
this._tbnPreferences_ = null;
}
}
}