/*
* 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.ScrollPaneConstants;
import javax.swing.border.BevelBorder;
import javax.swing.border.SoftBevelBorder;
import org.geoforge.guillc.editorpane.GfrEditorPane;
import org.geoforge.guillc.editorpane.GfrEditorPaneHtmlTxt;
import org.geoforge.guillc.scrollpane.GfrScr;
/**
*
* @author bantchao
*/
abstract public class GfrPnlKeyValueEpnHtmlAbs extends GfrPnlKeyValueAbs
{
final static private int _INT_HEIGHT_DEFAULT_ = 80;
private GfrEditorPane _epnHtml_ = null;
private int _intHeight_ = GfrPnlKeyValueEpnHtmlAbs._INT_HEIGHT_DEFAULT_;
private int intWidth_ = -1;
protected GfrPnlKeyValueEpnHtmlAbs(int intWidth, String strKey, String strValueInHtml, int intHeight)
{
this(intWidth, strKey, strValueInHtml);
this._intHeight_ = intHeight;
}
protected GfrPnlKeyValueEpnHtmlAbs(int intWidth, String strKey, String strValueInHtml)
{
super(strKey);
this.intWidth_ = intWidth;
this._epnHtml_ = new GfrEditorPaneHtmlTxt(strValueInHtml);
super._objText = new GfrScr(this._epnHtml_);
((JScrollPane) super._objText).setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
this._epnHtml_.setEditable(false); // ????
if (strValueInHtml != null && strValueInHtml.length()>0)
this._epnHtml_.setCaretPosition(0);
}
@Override
public boolean init()
{
if (! super.init())
return false;
Dimension dim = new Dimension(this.intWidth_, this._intHeight_);
((JScrollPane) super._objText).setPreferredSize(dim);
((JScrollPane) super._objText).setMaximumSize(dim);
((JScrollPane) super._objText).setMinimumSize(dim);
this._epnHtml_.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
return true;
}
@Override
public void destroy()
{
super.destroy();
if (this._epnHtml_ != null)
{
this._epnHtml_ = null;
}
}
}