package turgen.dtb;

import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Rectangle;
import java.io.File;
import javax.swing.JDialog;
import turgen.DialogManager;
import turgen.UIPersistor;
import turgen.tapeimage.TapeImage;


public class StatisticsDialog extends javax.swing.JDialog implements UIPersistor {

    /** Creates new form StatisticsDialog
     * @param parent Parent dialog */
    public StatisticsDialog(JDialog parent) {
        super(parent);
        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.
     */
    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        pButtons = new javax.swing.JPanel();
        btnClose = new javax.swing.JButton();
        pCards = new javax.swing.JPanel();
        pMainBinary = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jlbTotalSegments = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jlbDataSegments = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jlbJumpSegments = new javax.swing.JLabel();
        jlbGeneral = new javax.swing.JLabel();
        jlbFragment = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jlbTiny = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jlbSmall = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jlbOther = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jlsSegments = new javax.swing.JList();
        pMainOther = new javax.swing.JPanel();
        jlbOtherGeneral = new javax.swing.JLabel();
        pFiller2 = new javax.swing.JPanel();
        pMainTapeImage = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jlbTITotalChunks = new javax.swing.JLabel();
        jlbUnsupportedChunks = new javax.swing.JLabel();
        jlbUnsupportedChunksCount = new javax.swing.JLabel();
        jlbGeneral1 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jlsChunks = new javax.swing.JList();
        jLabel1 = new javax.swing.JLabel();
        pCommon = new javax.swing.JPanel();
        jlbFileType = new javax.swing.JLabel();
        jspFilespec = new javax.swing.JScrollPane();
        jtaFilespec = new javax.swing.JTextArea();
        pSize = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jlbSize = new javax.swing.JLabel();

        setTitle("File statistics");
        setModal(true);
        getContentPane().setLayout(new java.awt.GridBagLayout());

        btnClose.setText("Close");
        btnClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCloseActionPerformed(evt);
            }
        });
        pButtons.add(btnClose);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        getContentPane().add(pButtons, gridBagConstraints);

        pCards.setLayout(new java.awt.CardLayout());

        pMainBinary.setLayout(new java.awt.GridBagLayout());

        jLabel2.setText("Total number of segments:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
        pMainBinary.add(jLabel2, gridBagConstraints);

        jlbTotalSegments.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jlbTotalSegments.setText("0");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 8);
        pMainBinary.add(jlbTotalSegments, gridBagConstraints);

        jLabel3.setText("DATA segments:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
        pMainBinary.add(jLabel3, gridBagConstraints);

        jlbDataSegments.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jlbDataSegments.setText("0");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 8);
        pMainBinary.add(jlbDataSegments, gridBagConstraints);

        jLabel5.setText("JUMP segments:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
        pMainBinary.add(jLabel5, gridBagConstraints);

        jlbJumpSegments.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jlbJumpSegments.setText("0");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 8);
        pMainBinary.add(jlbJumpSegments, gridBagConstraints);

        jlbGeneral.setForeground(java.awt.Color.blue);
        jlbGeneral.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jlbGeneral.setText("DOS 2 BINARY FILE");
        jlbGeneral.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 0);
        pMainBinary.add(jlbGeneral, gridBagConstraints);

        jlbFragment.setForeground(java.awt.Color.blue);
        jlbFragment.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jlbFragment.setText("Fragmentation");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 0);
        pMainBinary.add(jlbFragment, gridBagConstraints);

        jLabel8.setText("Bytes in segments smaller than 1 KB:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
        pMainBinary.add(jLabel8, gridBagConstraints);

        jlbTiny.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jlbTiny.setText("<1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 8);
        pMainBinary.add(jlbTiny, gridBagConstraints);

        jLabel9.setText("Bytes in segments from 1 KB to 3 KB:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
        pMainBinary.add(jLabel9, gridBagConstraints);

        jlbSmall.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jlbSmall.setText("<1,3>");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 8);
        pMainBinary.add(jlbSmall, gridBagConstraints);

        jLabel10.setText("Bytes in other segments:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
        pMainBinary.add(jLabel10, gridBagConstraints);

        jlbOther.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jlbOther.setText(">3");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 8);
        pMainBinary.add(jlbOther, gridBagConstraints);

        jLabel6.setForeground(java.awt.Color.blue);
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel6.setText("Structure");
        jLabel6.setToolTipText("");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 11;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 0);
        pMainBinary.add(jLabel6, gridBagConstraints);

        jlsSegments.setVisibleRowCount(10);
        jScrollPane1.setViewportView(jlsSegments);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weighty = 0.6;
        gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
        pMainBinary.add(jScrollPane1, gridBagConstraints);

        pCards.add(pMainBinary, "BINARY");

        pMainOther.setLayout(new java.awt.GridBagLayout());

        jlbOtherGeneral.setForeground(java.awt.Color.blue);
        jlbOtherGeneral.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jlbOtherGeneral.setText("GENERAL FILE");
        jlbOtherGeneral.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 0);
        pMainOther.add(jlbOtherGeneral, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weighty = 1.0;
        pMainOther.add(pFiller2, gridBagConstraints);

        pCards.add(pMainOther, "OTHER");

        pMainTapeImage.setLayout(new java.awt.GridBagLayout());

        jLabel13.setText("Total number of chunks:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
        pMainTapeImage.add(jLabel13, gridBagConstraints);

        jlbTITotalChunks.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jlbTITotalChunks.setText("0");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 8);
        pMainTapeImage.add(jlbTITotalChunks, gridBagConstraints);

        jlbUnsupportedChunks.setText("Unsupported chunks:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
        pMainTapeImage.add(jlbUnsupportedChunks, gridBagConstraints);

        jlbUnsupportedChunksCount.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jlbUnsupportedChunksCount.setText("0");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 8);
        pMainTapeImage.add(jlbUnsupportedChunksCount, gridBagConstraints);

        jlbGeneral1.setForeground(java.awt.Color.blue);
        jlbGeneral1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jlbGeneral1.setText("TAPE IMAGE");
        jlbGeneral1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 0);
        pMainTapeImage.add(jlbGeneral1, gridBagConstraints);

        jlsChunks.setVisibleRowCount(10);
        jScrollPane2.setViewportView(jlsChunks);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weighty = 0.6;
        gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
        pMainTapeImage.add(jScrollPane2, gridBagConstraints);

        jLabel1.setForeground(java.awt.Color.blue);
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel1.setText("CHUNKS");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 0);
        pMainTapeImage.add(jLabel1, gridBagConstraints);

        pCards.add(pMainTapeImage, "TAPE");

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 0.8;
        getContentPane().add(pCards, gridBagConstraints);

        pCommon.setLayout(new java.awt.GridBagLayout());

        jlbFileType.setText("File:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 8);
        pCommon.add(jlbFileType, gridBagConstraints);

        jtaFilespec.setEditable(false);
        jtaFilespec.setFont(new java.awt.Font("Monospaced", 0, 12));
        jtaFilespec.setLineWrap(true);
        jtaFilespec.setRows(3);
        jtaFilespec.setWrapStyleWord(true);
        jspFilespec.setViewportView(jtaFilespec);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 8);
        pCommon.add(jspFilespec, gridBagConstraints);

        pSize.setLayout(new java.awt.GridBagLayout());

        jLabel4.setFont(new java.awt.Font("Dialog", 1, 14));
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel4.setText("File size:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
        pSize.add(jLabel4, gridBagConstraints);

        jlbSize.setFont(new java.awt.Font("Dialog", 1, 14));
        jlbSize.setText("0");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 8);
        pSize.add(jlbSize, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        pCommon.add(pSize, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 0.2;
        getContentPane().add(pCommon, gridBagConstraints);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed
        setVisible(false);
    }//GEN-LAST:event_btnCloseActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new StatisticsDialog(null).setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnClose;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel jlbDataSegments;
    private javax.swing.JLabel jlbFileType;
    private javax.swing.JLabel jlbFragment;
    private javax.swing.JLabel jlbGeneral;
    private javax.swing.JLabel jlbGeneral1;
    private javax.swing.JLabel jlbJumpSegments;
    private javax.swing.JLabel jlbOther;
    private javax.swing.JLabel jlbOtherGeneral;
    private javax.swing.JLabel jlbSize;
    private javax.swing.JLabel jlbSmall;
    private javax.swing.JLabel jlbTITotalChunks;
    private javax.swing.JLabel jlbTiny;
    private javax.swing.JLabel jlbTotalSegments;
    private javax.swing.JLabel jlbUnsupportedChunks;
    private javax.swing.JLabel jlbUnsupportedChunksCount;
    private javax.swing.JList jlsChunks;
    private javax.swing.JList jlsSegments;
    private javax.swing.JScrollPane jspFilespec;
    private javax.swing.JTextArea jtaFilespec;
    private javax.swing.JPanel pButtons;
    private javax.swing.JPanel pCards;
    private javax.swing.JPanel pCommon;
    private javax.swing.JPanel pFiller2;
    private javax.swing.JPanel pMainBinary;
    private javax.swing.JPanel pMainOther;
    private javax.swing.JPanel pMainTapeImage;
    private javax.swing.JPanel pSize;
    // End of variables declaration//GEN-END:variables


    public void fill(DOS2Binary dtb,int[] valArray) {

        jtaFilespec.setText(dtb.getFileName());
        jlbSize.setText(Integer.toString(valArray[0]));
        jlbTotalSegments.setText(Integer.toString(valArray[1]));
        jlbDataSegments.setText(Integer.toString(valArray[2]));
        jlbJumpSegments.setText(Integer.toString(valArray[3]));

        jlbTiny.setText(Integer.toString(valArray[4]));
        jlbSmall.setText(Integer.toString(valArray[5]));
        jlbOther.setText(Integer.toString(valArray[6]));

        jlsSegments.setListData(dtb.getListing());
        jlsSegments.repaint();

        CardLayout cl =(CardLayout)this.pCards.getLayout();
        cl.show(pCards, "BINARY");
    }

    public void fill(String fn, long ln) {
           jtaFilespec.setText(fn);
           jlbSize.setText(Integer.toString((int)ln));

           CardLayout cl =(CardLayout)this.pCards.getLayout();
           cl.show(pCards, "OTHER");
 
    }

    public void fill(String fn,long ln,int tr,int ur,TapeImage ti) {
        this.jtaFilespec.setText(fn);
        this.jlbSize.setText(Integer.toString((int)ln));
        this.jlbTITotalChunks.setText(Integer.toString(tr));
        this.jlbUnsupportedChunksCount.setText(Integer.toString(ur));

        
        if (ur==0) {
            jlbUnsupportedChunksCount.setForeground(Color.black);
            jlbUnsupportedChunks.setForeground(Color.black);

        }
        else {
            jlbUnsupportedChunksCount.setForeground(Color.red);
            jlbUnsupportedChunks.setForeground(Color.red);
        }

        jlsChunks.setListData(ti.getListing());
        jlsChunks.repaint();

        CardLayout cl =(CardLayout)this.pCards.getLayout();
        cl.show(pCards, "TAPE");

    }

    public static boolean fillStatisticsDialog(String filespec,StatisticsDialog dlg) {

        /*Check file existence type*/
        File f = new File(filespec);

        if (!f.exists()) return false;
        long ln=f.isDirectory()?0:f.length();

        /*Is that DOS 2 binary file?*/
        try {
            DOS2Binary dtb = new DOS2Binary(filespec);
            dtb.analyzeFromFile();

            dlg.fill(dtb, dtb.getFileStatistics());
            return true;
        }
        catch (Exception e) {
            /*Intentionally left blank*/
        }

        /*Is that tape image ?*/
        try {
            TapeImage ti = new TapeImage();
            ti.parse(filespec);

            int[] chunkBilance = ti.getChunkBilance();
            dlg.fill(filespec,ln,chunkBilance[0],chunkBilance[1],ti);

            return true;
        }
        catch (Exception e) {
            e.printStackTrace();
        }

        /*Ordinary file*/
        dlg.fill(filespec, ln);
        return true;

    }

    public Object[] getPersistenceData() {
        Object[] pData = new Object[1];
        pData[0]=getBounds();

        return pData;
    }

    public void setPersistenceData(Object[] data) throws Exception {
        setBounds((Rectangle)data[0]);
    }

    public String getPersistenceId() {
        return getClass().getName();
    }

    public void setPersistenceDefaults() {
        pack();
        DialogManager.centerContainer(this);
        
    }

}
