/*
* 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.Dimension;
import javax.swing.JScrollPane;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.geoforge.guillc.scrollpane.GfrScr;
import org.geoforge.guillc.textarea.GfrTaa;
/**
*
* @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"
*/
public class GfrPnlGrpSngTaa extends GfrPnlGrpAbs implements DocumentListener
{
//--
//-- beg private fields
private GfrTaa _taa_;
private GfrScr _scr_;
//-- end private fields
//--
public String getContent()
{
return this._taa_.getText();
}
//
private int _intColumnsTaa_ = -1;
public GfrPnlGrpSngTaa(
String strWhat,
String strContents,
int intColumns)
{
this(
strWhat,
strContents);
this._intColumnsTaa_ = intColumns;
this._taa_.setColumns(intColumns);
}
public GfrPnlGrpSngTaa(
String strWhat,
String strContents)
{
super(
strWhat,
GfrTaa.INT_HEIGHT);
this._taa_ = new GfrTaa(strContents);
this._scr_ = new GfrScr(this._taa_);
this._taa_.getDocument().addDocumentListener((DocumentListener) this);
}
public GfrPnlGrpSngTaa(
String strWhat)
{
this(
strWhat,
"");
}
@Override
public boolean init()
{
if (!super.init())
return false;
if (!this._scr_.init())
return false;
if (!this._taa_.init())
return false;
this.setMandatoryIcon(false);
this._taa_.setEditable(true);
Dimension dim = null;
if (this._intColumnsTaa_ == -1)
{
dim = new Dimension(
this.getWidthContent(),
this.getHeightComponent());
this._scr_.setMaximumSize(dim);
}
else
{
dim = new Dimension(
this._taa_.getPreferredSize().width,
this.getHeightComponent());
}
this._scr_.setPreferredSize(dim);
this._scr_.setMinimumSize(dim);
this._scr_.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
super.add(this._scr_);
return true;
}
@Override
public void destroy()
{
if (this._scr_ != null)
{
this._scr_.destroy();
this._scr_ = null;
}
if (this._taa_ != null)
{
this._taa_.destroy();
this._taa_ = null;
}
super.destroy();
}
@Override
public void insertUpdate(DocumentEvent e)
{
firePanelUpdate();
}
@Override
public void removeUpdate(DocumentEvent e)
{
firePanelUpdate();
}
@Override
public void changedUpdate(DocumentEvent e)
{
//-- void
}
}