Package org.geoforge.guillc.panel

Source Code of org.geoforge.guillc.panel.PnlSelEditTaaAbs

/*
*  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 org.geoforge.guillc.panel.PnlSelLblEditAbs;
import java.awt.Dimension;
import javax.swing.JScrollPane;
import javax.swing.border.BevelBorder;
import javax.swing.border.SoftBevelBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import org.geoforge.guillc.textarea.TaaCheckableAbs;


/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
* "Taa": JTextArea
*/
abstract public class PnlSelEditTaaAbs extends PnlSelLblEditAbs implements
        DocumentListener
{
    final static public int INT_HEIGHT = 80;
    protected TaaCheckableAbs _taa = null;
   
    @Override
    abstract public String getWrongFormat();
   
    @Override
    abstract public boolean isOk();
   
    abstract public boolean belongsTo(Document doc);
   
    protected PnlSelEditTaaAbs(String strLabel, boolean blnFiedRequired)
    {
        super(strLabel,
                blnFiedRequired
                );
    }
   
    private JScrollPane _scr_ = null;
   
    @Override
    public boolean init()
    {
        if (! super.init())
            return false;
       
        if (! this._taa.init())
            return false;
       
       
        this._scr_ = new JScrollPane(this._taa);
        this._scr_.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    
        Dimension dim = new Dimension(
                250,
                PnlSelEditTaaAbs.INT_HEIGHT);
       
        this._scr_.setPreferredSize(dim);
        this._scr_.setMaximumSize(dim);
        this._scr_.setMinimumSize(dim);

        this._taa.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
       
        super._pnl.add(this._scr_);
       
        return true;
    }
   
    public void setSizeWidthScrollText(int intW)
    {       
        Dimension dim = new Dimension(intW, this._scr_.getPreferredSize().height);
        this._scr_.setPreferredSize(dim);
        this._scr_.setMinimumSize(dim);
        this._scr_.setSize(dim);
    }
   
    @Override
    public void destroy()
    {
        super.destroy();
       
        if (this._taa != null)
        {
            this._taa.destroy();
            this._taa = null;
        }
       
        this._scr_ = null;
    }
   
    @Override
    public void insertUpdate(DocumentEvent e)
    {
        _updateIconLabel();
    }

    @Override
    public void removeUpdate(DocumentEvent e)
    {
        _updateIconLabel();
    }

    @Override
    public void changedUpdate(DocumentEvent e) {}
   
    private void _updateIconLabel()
    {
        if (! super._blnFieldRequired)
            return;
       
        if (this.isOk())
            super.getLabel().setIcon(_iinReqFieldSet);
        else
            super.getLabel().setIcon(_iinReqFieldUnset);
    }
}
TOP

Related Classes of org.geoforge.guillc.panel.PnlSelEditTaaAbs

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.