/*
* 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.panel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JButton;
import org.geoforge.guillc.list.GfrLst;
import org.geoforge.guillc.scrollpane.GfrScr;
/**
*
* @author Amadeus.Sowerby
*
* email: Amadeus.Sowerby_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
* Should be refactored => remove "Sng"
*/
abstract public class GfrPnlGrpSngLstAbs extends GfrPnlGrpAbs
{
private String[] _strsItems_ = null;
private GfrScr _scr_;
protected GfrLst _lstContent_ = null;
protected JButton _btnAction_;
@Override
public void destroy()
{
super.destroy();
if (this._lstContent_ != null)
{
this._lstContent_.destroy();
this._lstContent_ = null;
}
}
public boolean isEmpty()
{
if (this._strsItems_ == null || this._strsItems_.length == 0)
return true;
return false;
}
public String[] getList()
{
return this._strsItems_;
}
protected GfrPnlGrpSngLstAbs(
String strWhat,
String[] strs)
{
super(
strWhat,
80);
this._lstContent_ = new GfrLst(strs);
this._scr_ = new GfrScr(this._lstContent_);
this._strsItems_ = strs;
}
@Override
public boolean init()
{
if (!super.init())
return false;
if (!this._scr_.init())
return false;
if (!this._lstContent_.init())
return false;
this.setMandatoryIcon(false);
this._scr_.setPreferredSize(
new Dimension(this.getWidthContent(), this.getHeightComponent()));
this._pnlContent.add(this._scr_, BorderLayout.CENTER);
return true;
}
public boolean alreadyExists(String str)
{
if (str == null)
return false;
if (this._strsItems_ == null)
return false;
if (this._strsItems_.length < 1)
return false;
for (int i = 0; i < this._strsItems_.length; i++)
{
if (str.compareTo(this._strsItems_[i]) == 0)
return true;
}
return false;
}
}