/*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.geoforge.guillc.panel;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.geoforge.guillc.button.BtnChoiceColorRectangle;
import org.geoforge.guillc.checkbox.CbxSettingsSetDefault;
/**
*
* @author bantchao
*/
public class PnlDspRowButtonColorObj extends PnlDspRowAbs
{
private CbxSettingsSetDefault _cbxSetDefault_ = null;
private void _init_(
ActionListener alrParent,
Color colCustom)
{
ActionListener[] alrs = new ActionListener[]
{
alrParent,
(ActionListener) this
};
super._pnlChoice = new PnlChoiceButtonColor(alrs, colCustom);
this._cbxSetDefault_ = new CbxSettingsSetDefault();
super._btnReset.addActionListener(alrParent);
}
public boolean isSetDefault()
{
return this._cbxSetDefault_.isSelected();
}
public Color getValue()
{
return ((PnlChoiceButtonColor) super._pnlChoice).getValue();
}
public PnlDspRowButtonColorObj(
ActionListener alrParent,
Color colCustom)
{
super();
super._pnlLabel = new PnlDspLabel(
"", // strPrefix
"color",
"" // strSuffix
);
this._init_(alrParent, colCustom);
}
public PnlDspRowButtonColorObj(
ActionListener alrParent,
Color colCustom,
String strPrefix)
{
super();
super._pnlLabel = new PnlDspLabel(strPrefix,
"color",
"" // suffix
);
this._init_(alrParent, colCustom);
}
public PnlDspRowButtonColorObj(
ActionListener alrParent,
Color colCustom,
String strPrefix,
String strSufix)
{
super();
super._pnlLabel = new PnlDspLabel(strPrefix,
"color",
strSufix);
this._init_(alrParent, colCustom);
}
@Override
public void actionPerformed(ActionEvent e)
{
if (e.getSource() instanceof BtnChoiceColorRectangle)
{
if (super._pnlChoice.hasChangedValue())
super._btnReset.setEnabled(true);
else
super._btnReset.setEnabled(false);
return;
}
super.actionPerformed(e);
}
@Override
public boolean init()
{
if (!super.init())
return false;
if (!_cbxSetDefault_.init())
return false;
super.add(this._cbxSetDefault_);
return true;
}
@Override
public void destroy()
{
// TODO
super.destroy();
}
}