/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ImportProgressDialog.java
 *
 * Created on Jan 8, 2010, 12:34:37 PM
 */

package usda.weru.weps.startup;

/**
 *
 * @author Joseph Levin <joelevin@weru.ksu.edu>
 */
public class ImportProgressDialog extends javax.swing.JDialog {
    private static final long serialVersionUID = 1L;

    /** Creates new form ImportProgressDialog
	 * @param parent
	 * @param modal */
    public ImportProgressDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        importingLabel = new javax.swing.JLabel();
        pleaseWaitLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Import Progress");
        setAlwaysOnTop(true);
        setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
        setModal(true);
        setResizable(false);

        importingLabel.setFont(importingLabel.getFont().deriveFont(importingLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
        importingLabel.setText("Importing previous WEPS settings.");

        pleaseWaitLabel.setFont(pleaseWaitLabel.getFont().deriveFont(pleaseWaitLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
        pleaseWaitLabel.setText("Please wait...");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(importingLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
                    .addComponent(pleaseWaitLabel))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(importingLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(pleaseWaitLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(20, 20, 20))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-332)/2, (screenSize.height-119)/2, 332, 119);
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                ImportProgressDialog dialog = new ImportProgressDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

	/**
	 *
	 * @param max
	 */
	public void setMaximum(int max){
        progressBar.setMaximum(max);
    }

	/**
	 *
	 * @param progress
	 */
	public void setProgress(int progress){
        progressBar.setValue(progress);
    }

	/**
	 *
	 */
	public void close(){
        setVisible(false);
        dispose();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel importingLabel;
    private javax.swing.JLabel pleaseWaitLabel;
    private javax.swing.JProgressBar progressBar;
    // End of variables declaration//GEN-END:variables

}
