/*
 * Copyright 2009 Lari Natri <lari.natri@gmail.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU 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 General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


package compid.gui;

import compid.application.CompidApp;
import org.jdesktop.application.Action;

/**
 * GUI component "about box" for Compid
 * @author Lari Natri
 */
public class CompidAboutBox extends javax.swing.JDialog {

    public CompidAboutBox(java.awt.Frame parent) {
        super(parent);
        initComponents();

        // use parents icon
        this.setIconImage(parent.getIconImage());

        boolean mascotParserAvailable = CompidApp.getApplication().isMascotParserLoaded();

        if (mascotParserAvailable) {
            pluginsTable.getModel().setValueAt("   YES", 0, 3);
            pluginsTable.setEnabled(true);
            jScrollPane2.setEnabled(true);
        } else {
            pluginsTable.getModel().setValueAt("   NO", 0, 3);
            pluginsTable.setEnabled(false);
            jScrollPane2.setEnabled(false);

        }
        
        getRootPane().setDefaultButton(closeButton);
    }
    
    @Action public void closeAboutBox() {
        dispose();
    }

    /** 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() {

        closeButton = new javax.swing.JButton();
        javax.swing.JLabel appTitleLabel = new javax.swing.JLabel();
        javax.swing.JLabel versionLabel = new javax.swing.JLabel();
        javax.swing.JLabel appVersionLabel = new javax.swing.JLabel();
        javax.swing.JLabel authorLabel = new javax.swing.JLabel();
        javax.swing.JLabel appAuthorLabel = new javax.swing.JLabel();
        javax.swing.JLabel licenseLabel = new javax.swing.JLabel();
        javax.swing.JLabel appLicenseLabel = new javax.swing.JLabel();
        javax.swing.JLabel appDescLabel = new javax.swing.JLabel();
        javax.swing.JLabel imageLabel = new javax.swing.JLabel();
        pluginsLabel = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        includedTable = new javax.swing.JTable();
        inclSoftwareLabel = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        pluginsTable = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(compid.application.CompidApp.class).getContext().getResourceMap(CompidAboutBox.class);
        setTitle(resourceMap.getString("title")); // NOI18N
        setIconImage(null);
        setModal(true);
        setName("aboutBox"); // NOI18N
        setResizable(false);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(compid.application.CompidApp.class).getContext().getActionMap(CompidAboutBox.class, this);
        closeButton.setAction(actionMap.get("closeAboutBox")); // NOI18N
        closeButton.setName("closeButton"); // NOI18N

        appTitleLabel.setFont(appTitleLabel.getFont().deriveFont(appTitleLabel.getFont().getStyle() | java.awt.Font.BOLD, appTitleLabel.getFont().getSize()+6));
        appTitleLabel.setText(resourceMap.getString("Application.title")); // NOI18N
        appTitleLabel.setName("appTitleLabel"); // NOI18N

        versionLabel.setFont(versionLabel.getFont().deriveFont(versionLabel.getFont().getStyle() | java.awt.Font.BOLD));
        versionLabel.setText(resourceMap.getString("versionLabel.text")); // NOI18N
        versionLabel.setName("versionLabel"); // NOI18N

        appVersionLabel.setText(resourceMap.getString("Application.version")); // NOI18N
        appVersionLabel.setName("appVersionLabel"); // NOI18N

        authorLabel.setFont(authorLabel.getFont().deriveFont(authorLabel.getFont().getStyle() | java.awt.Font.BOLD));
        authorLabel.setText(resourceMap.getString("authorLabel.text")); // NOI18N
        authorLabel.setName("authorLabel"); // NOI18N

        appAuthorLabel.setText(resourceMap.getString("appAuthorLabel.text")); // NOI18N
        appAuthorLabel.setName("appAuthorLabel"); // NOI18N

        licenseLabel.setFont(licenseLabel.getFont().deriveFont(licenseLabel.getFont().getStyle() | java.awt.Font.BOLD));
        licenseLabel.setText(resourceMap.getString("licenseLabel.text")); // NOI18N
        licenseLabel.setName("licenseLabel"); // NOI18N

        appLicenseLabel.setText(resourceMap.getString("appLicenseLabel.text")); // NOI18N
        appLicenseLabel.setName("appLicenseLabel"); // NOI18N

        appDescLabel.setText(resourceMap.getString("appDescLabel.text")); // NOI18N
        appDescLabel.setName("appDescLabel"); // NOI18N

        imageLabel.setIcon(resourceMap.getIcon("imageLabel.icon")); // NOI18N
        imageLabel.setName("imageLabel"); // NOI18N
        imageLabel.setVerticalTextPosition(javax.swing.SwingConstants.TOP);

        pluginsLabel.setFont(pluginsLabel.getFont().deriveFont(pluginsLabel.getFont().getStyle() | java.awt.Font.BOLD));
        pluginsLabel.setLabelFor(pluginsTable);
        pluginsLabel.setText(resourceMap.getString("pluginsLabel.text")); // NOI18N
        pluginsLabel.setName("pluginsLabel"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        includedTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Apache POI", "http://poi.apache.org/", "Apache License Version 2.0"},
                {"Apache Derby", "http://db.apache.org/derby/", "Apache Licence Version 2.0"},
                {"Apache Harmony", "http://harmony.apache.org/", "Apache Licence Version 2.0"},
                {"Swing Application Framework", "https://appframework.dev.java.net/", "GNU Lesser General Public License"},
                {"XOM", "http://www.xom.nu/", "GNU Lesser General Public License"},
                {"Oxygen icons", "http://www.oxygen-icons.org/", "GNU Lesser General Public License"},
                {"aa-javautils", null, "GNU Lesser General Public License"}
            },
            new String [] {
                "Title", "Address", "License"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        includedTable.setToolTipText(resourceMap.getString("includedTable.toolTipText")); // NOI18N
        includedTable.setName("includedTable"); // NOI18N
        includedTable.setShowHorizontalLines(false);
        includedTable.setShowVerticalLines(false);
        includedTable.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(includedTable);
        includedTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("includedTable.columnModel.title0")); // NOI18N
        includedTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("includedTable.columnModel.title1")); // NOI18N
        includedTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("includedTable.columnModel.title2")); // NOI18N

        inclSoftwareLabel.setFont(resourceMap.getFont("inclSoftwareLabel.font")); // NOI18N
        inclSoftwareLabel.setLabelFor(includedTable);
        inclSoftwareLabel.setText(resourceMap.getString("inclSoftwareLabel.text")); // NOI18N
        inclSoftwareLabel.setName("inclSoftwareLabel"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        pluginsTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Matrix Science: Mascot Parser", "http://www.matrixscience.com/parser_support.html", "(custom)", "NO"}
            },
            new String [] {
                "Title", "Address", "License", "Loaded"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Object.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        pluginsTable.setToolTipText(resourceMap.getString("pluginsTable.toolTipText")); // NOI18N
        pluginsTable.setName("pluginsTable"); // NOI18N
        pluginsTable.setShowHorizontalLines(false);
        pluginsTable.setShowVerticalLines(false);
        pluginsTable.getTableHeader().setReorderingAllowed(false);
        jScrollPane2.setViewportView(pluginsTable);
        pluginsTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("pluginsTable.columnModel.title0")); // NOI18N
        pluginsTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("pluginsTable.columnModel.title1")); // NOI18N
        pluginsTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("pluginsTable.columnModel.title2")); // NOI18N
        pluginsTable.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("pluginsTable.columnModel.title3")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 685, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 685, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(imageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(versionLabel)
                                    .addComponent(authorLabel)
                                    .addComponent(licenseLabel))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(appAuthorLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
                                            .addComponent(appVersionLabel))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(appLicenseLabel)))
                            .addComponent(appTitleLabel)
                            .addComponent(appDescLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 518, Short.MAX_VALUE)))
                    .addComponent(inclSoftwareLabel, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(closeButton)
                    .addComponent(pluginsLabel, javax.swing.GroupLayout.Alignment.LEADING))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(appTitleLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(appDescLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(versionLabel)
                            .addComponent(appVersionLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(authorLabel)
                            .addComponent(appAuthorLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(licenseLabel)
                            .addComponent(appLicenseLabel)))
                    .addComponent(imageLabel))
                .addGap(18, 18, 18)
                .addComponent(inclSoftwareLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pluginsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(closeButton))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton closeButton;
    private javax.swing.JLabel inclSoftwareLabel;
    private javax.swing.JTable includedTable;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel pluginsLabel;
    private javax.swing.JTable pluginsTable;
    // End of variables declaration//GEN-END:variables
    
}
