Package org.geoforge.guillc.panel

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

/*
*  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.Dimension;
import javax.swing.JScrollPane;
import javax.swing.border.BevelBorder;
import javax.swing.border.SoftBevelBorder;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import org.geoforge.guillc.table.GfrTblEditCheckableAbs;


/**
*
* @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 PnlSelEditTblAbs extends PnlSelLblEditAbs implements
        TableModelListener
{
    final static public int INT_H = 200;
   
    protected GfrTblEditCheckableAbs _tbl = null;
   
    @Override
    abstract public String getWrongFormat();
   
    @Override
    abstract public boolean isOk();

   
    protected PnlSelEditTblAbs(String strLabel, boolean blnFiedRequired)
    {
        super(strLabel,
                blnFiedRequired
                );
    }
   
    private JScrollPane _scr_ = null;
   
    @Override
    public boolean init()
    {
        if (! super.init())
            return false;
       
        if (! this._tbl.init())
            return false;
       
       
        this._scr_ = new JScrollPane(this._tbl);
        this._scr_.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    
        Dimension dim = new Dimension(
                250,
                PnlSelEditTblAbs.INT_H);
       
        this._scr_.setPreferredSize(dim);
        this._scr_.setMaximumSize(dim);
        this._scr_.setMinimumSize(dim);

        this._tbl.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._tbl != null)
        {
            this._tbl.destroy();
            this._tbl = null;
        }
       
        this._scr_ = null;
    }
   
    @Override
    public void tableChanged(TableModelEvent e)
    {
        _updateIconLabel();
    }
   
    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.PnlSelEditTblAbs

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.