Package org.geoforge.guillc.dialog

Source Code of org.geoforge.guillc.dialog.DlgViewText

/*
*  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.dialog;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.border.SoftBevelBorder;
import org.geoforge.guillc.border.GfrUtilBorder;
import org.geoforge.guillc.panel.GfrPnlCmdCloseWindow;
import org.geoforge.guillc.scrollpane.GfrScr;
import org.geoforge.guillc.textarea.GfrTaa;
import org.geoforge.awt.image.GfrFactoryIconAbs;
import org.geoforge.java.enumeration.GfrEnuSystemPropertiesKeys;

/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*/

public class DlgViewText extends DlgAbs implements
    ActionListener
{
   final static private int _INT_WIDTH_TEXT_ = 340;
   final static private int _INT_HEIGHT_TEXT_ = 120;

    private GfrTaa _taa_ = null;
    private GfrScr _scr_ = null;
    private GfrPnlCmdCloseWindow _pnlCommands_ = null;
   
    public DlgViewText(Component cmpFrameOwner, String strTitle, String strContents)
            throws Exception
    {
        super((Frame) cmpFrameOwner, true); // true ==> modal=true
       
        this._pnlCommands_ = new GfrPnlCmdCloseWindow(
                (ActionListener) this,
                GfrFactoryIconAbs.INT_SIZE_XXSMALL);
       
        this._taa_ = new GfrTaa();
       
       
        this._taa_.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
        this._taa_.setEditable(false);
        this._taa_.setText(strContents);

     
      if (strContents != null && strContents.length()>0)
         this._taa_.setCaretPosition(0);
       
      this._scr_ = new GfrScr(this._taa_);
      this._scr_.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
       
       
       
      super.setTitle(System.getProperty(GfrEnuSystemPropertiesKeys.NAME_LONG_APPLI.getLabel()) + " - " + strTitle);
   
     
        if (! init())
           throw new Exception("Failed to init dialog");
       
        super.setVisible(true); // !!!!!
    }

    @Override
    public void destroy()
    {
        if (this._pnlCommands_ != null)
        {
            this._pnlCommands_.destroy();
            this._pnlCommands_ = null;
        }
       
       
      if (this._taa_ != null)
      {
         this._taa_.destroy();
         this._taa_ = null;
      }
       
      if (this._scr_ != null)
      {
         this._scr_.destroy();
         this._scr_ = null;
      }
       
      super.destroy();
    }


    @Override
    public void actionPerformed(ActionEvent evtAction)
    {
        _cancel_();
    }



    @Override
    public void windowClosing(WindowEvent e)
    {
        _cancel_();
    }

    @Override
    public boolean init()
    {
       if(!super.init())
          return false;
      

        // --------------


       
        if (! this._pnlCommands_.init())
         return false;
       
        if (! this._taa_.init())
         return false;
       
        if (! this._scr_.init())
         return false;
       
        Dimension dim = new Dimension(_INT_WIDTH_TEXT_, _INT_HEIGHT_TEXT_);

        _scr_.setPreferredSize(dim);
        _scr_.setMaximumSize(dim);
        _scr_.setMinimumSize(dim);

        JPanel pnl = new JPanel();
        pnl.setLayout(new BorderLayout() );
        JPanel pnlAll = new JPanel();
        pnl.add(pnlAll, BorderLayout.CENTER);

        // -------
        Container cntContentPane = getContentPane();
        cntContentPane.setLayout(new BorderLayout());

       
        // --- BEGIN border

        GfrUtilBorder.s_setEtched(pnlAll);

        // --- END border
        cntContentPane.add(pnlAll, BorderLayout.CENTER);

        pnlAll.setLayout(new BoxLayout(pnlAll, BoxLayout.Y_AXIS));
  
        pnlAll.add(this._scr_);
        pnlAll.add(Box.createVerticalStrut(10));
        pnlAll.add(_pnlCommands_);

        // ending
        return true;
    }

    private void _cancel_()
    {
        super._cancel();

        this._taa_.setText("_dummy_text_");
    }

   
}
TOP

Related Classes of org.geoforge.guillc.dialog.DlgViewText

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.