ca.uviccscu.lp.server.main.MainFrame.java Source code

Java tutorial

Introduction

Here is the source code for ca.uviccscu.lp.server.main.MainFrame.java

Source

/*
 *  Copyright 2010 Nikita Kuklev.
 * 
 *  This file is part of LPServer
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

/*
 * MainFrame.java
 *
 * Created on 23-Sep-2010, 1:00:08 PM
 */
package ca.uviccscu.lp.server.main;

import ca.uviccscu.lp.persistence.Game;
import ca.uviccscu.lp.persistence.GamelistStorage;
import ca.uviccscu.lp.persistence.SettingsManager;
import ca.uviccscu.lp.server.tracker.HashingProgressListener;
import ca.uviccscu.lp.server.tracker.TrackerManager;
import ca.uviccscu.lp.shared.Shared;
import ca.uviccscu.lp.utils.ObjectPlaceholder;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Desktop;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Timer;
import java.util.concurrent.SynchronousQueue;
import javax.swing.JComponent;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.config.PropertyPrinter;
import org.gudy.azureus2.core3.torrent.TOTorrent;
import org.gudy.azureus2.core3.torrent.TOTorrentException;

/**
 *
 * @author Nikita Kuklev
 */
public class MainFrame extends javax.swing.JFrame {

    static Logger l = Logger.getLogger(MainFrame.class.getName());
    List components = new LinkedList<JComponent>();
    static JPopupMenu popupMenu = new JPopupMenu();
    static Timer t1 = new Timer();
    static Timer t2 = new Timer();
    static Queue q1 = new SynchronousQueue();
    static Queue q2 = new SynchronousQueue();

    /** Creates new form MainFrame */
    public MainFrame() {
        initComponents();
        this.addWindowListener(new ShutdownListener());
        setupTablePopup();
        setupOther();
        jFileChooser1.setFileFilter(new FileNameExtensionFilter("uTorrent executable(.exe)", "exe"));
    }

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

        jOptionPane1 = new javax.swing.JOptionPane();
        jFileChooser1 = new javax.swing.JFileChooser();
        jPanel6 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jScrollPane1.getViewport().setBackground(new Color(51, 51, 51));
        jTable1 = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JSeparator();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jScrollPane1.getViewport().setBackground(new Color(51, 51, 51));
        jTable2 = new javax.swing.JTable();
        jButton14 = new javax.swing.JButton();
        jButton15 = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jButton17 = new javax.swing.JButton();
        jLabel22 = new javax.swing.JLabel();
        jSeparator7 = new javax.swing.JSeparator();
        jPanel4 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jTextField1 = new javax.swing.JTextField();
        jButton12 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jSeparator4 = new javax.swing.JSeparator();
        jSeparator5 = new javax.swing.JSeparator();
        jLabel17 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jSeparator6 = new javax.swing.JSeparator();
        jLabel20 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jButton13 = new javax.swing.JButton();
        jLabel21 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jProgressBar1 = new javax.swing.JProgressBar();
        jLabel1 = new javax.swing.JLabel();

        jOptionPane1.setBackground(new java.awt.Color(51, 51, 51));
        jOptionPane1.setMessage("Are you sure you want to delete the game?");
        jOptionPane1.setMessageType(3);
        jOptionPane1.setOptionType(2);
        jOptionPane1.setName("You sure?"); // NOI18N

        jFileChooser1.setAcceptAllFileFilterUsed(false);
        jFileChooser1.setApproveButtonText("Set");
        jFileChooser1.setBackground(java.awt.Color.white);
        jFileChooser1.setDialogTitle("Select uTorrent.exe location");
        jFileChooser1.setDialogType(javax.swing.JFileChooser.CUSTOM_DIALOG);

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("UVIC LP SERVER");
        setBackground(new java.awt.Color(51, 51, 51));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setLocationByPlatform(true);
        setResizable(false);

        jPanel6.setBackground(new java.awt.Color(51, 51, 51));

        jTabbedPane1.setBackground(new java.awt.Color(51, 51, 51));

        jPanel2.setBackground(new java.awt.Color(51, 51, 51));

        jScrollPane1.setBackground(new java.awt.Color(51, 51, 51));

        jTable1.setBackground(new java.awt.Color(51, 51, 51));
        jTable1.setForeground(new java.awt.Color(204, 204, 204));
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
                new Object[][] { { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null } },
                new String[] { "Name", "Exec path", "Size", "Status", "GL" }) {
            Class[] types = new Class[] { java.lang.Object.class, java.lang.Object.class, java.lang.Object.class,
                    java.lang.Object.class, java.lang.Boolean.class };
            boolean[] canEdit = new boolean[] { false, false, false, false, false };

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

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        jTable1.setGridColor(new java.awt.Color(153, 153, 153));
        jTable1.setSelectionBackground(new java.awt.Color(153, 153, 153));
        jTable1.setSelectionForeground(new java.awt.Color(255, 255, 255));
        jTable1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jTable1.getTableHeader().setReorderingAllowed(false);
        jTable1.setVerifyInputWhenFocusTarget(false);
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(4).setPreferredWidth(5);

        jButton1.setBackground(new java.awt.Color(51, 51, 51));
        jButton1.setText("Add game");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setBackground(new java.awt.Color(51, 51, 51));
        jButton2.setText("Edit selected");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setBackground(new java.awt.Color(51, 51, 51));
        jButton3.setText("Remove selected");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setBackground(new java.awt.Color(51, 51, 51));
        jButton4.setText("Load games config");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setBackground(new java.awt.Color(51, 51, 51));
        jButton5.setText("Hash selected");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setBackground(new java.awt.Color(51, 51, 51));
        jButton6.setText("Put on GL");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton7.setBackground(new java.awt.Color(51, 51, 51));
        jButton7.setText("Remove from GL");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jButton8.setBackground(new java.awt.Color(51, 51, 51));
        jButton8.setText("Save games config");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton9.setBackground(new java.awt.Color(51, 51, 51));
        jButton9.setText("Send GL to uTorrent");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jButton10.setBackground(new java.awt.Color(51, 51, 51));
        jButton10.setText("Open .torrent folder");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jButton11.setBackground(new java.awt.Color(51, 51, 51));
        jButton11.setText("Send GL to clients");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(jPanel2Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 681, Short.MAX_VALUE)
                        .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 681, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jButton4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton10))
                        .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 96,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 102,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 120,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 107,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton7)))
                        .addContainerGap()));
        jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(jPanel2Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jButton2).addComponent(jButton3).addComponent(jButton5)
                                        .addComponent(jButton6).addComponent(jButton7))
                                .addComponent(jButton1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 2,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jButton4).addComponent(jButton8).addComponent(jButton9)
                                .addComponent(jButton11).addComponent(jButton10))
                        .addGap(12, 12, 12)));

        jTabbedPane1.addTab("Gamelist", jPanel2);

        jPanel3.setBackground(new java.awt.Color(51, 51, 51));

        jTable2.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { { null, null, null },
                { null, null, null }, { null, null, null }, { null, null, null } },
                new String[] { "Client name", "Client IP", "Status" }) {
            boolean[] canEdit = new boolean[] { true, true, false };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        jScrollPane3.setViewportView(jTable2);

        jButton14.setBackground(new java.awt.Color(51, 51, 51));
        jButton14.setText("Start");

        jButton15.setBackground(new java.awt.Color(51, 51, 51));
        jButton15.setText("Stop");

        jButton16.setBackground(new java.awt.Color(51, 51, 51));
        jButton16.setText("Restart");

        jButton17.setBackground(new java.awt.Color(51, 51, 51));
        jButton17.setText("jButton17");

        jLabel22.setText("Network module status");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(jPanel3Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jScrollPane3).addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                jPanel3Layout.createSequentialGroup().addGroup(jPanel3Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addGroup(jPanel3Layout.createSequentialGroup().addComponent(jButton14)
                                                .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(jButton15))
                                        .addComponent(jLabel22))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jPanel3Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        false)
                                                .addGroup(jPanel3Layout.createSequentialGroup()
                                                        .addComponent(jButton16).addGap(399, 399, 399)
                                                        .addComponent(jButton17))
                                                .addComponent(jSeparator7))))
                        .addContainerGap()));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel22))
                        .addGap(35, 35, 35)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jButton14).addComponent(jButton15).addComponent(jButton16)
                                .addComponent(jButton17))
                        .addGap(20, 20, 20)));

        jTabbedPane1.addTab("Client control", jPanel3);

        jPanel4.setBackground(new java.awt.Color(102, 102, 102));

        jPanel7.setBackground(new java.awt.Color(153, 153, 153));
        jPanel7.setToolTipText("Statistics on the currently selected game");

        jLabel3.setText("Azureus core status:");

        jLabel4.setText("Games hosted:");

        jLabel5.setText("Active hosted:");

        jLabel6.setText("Total UL(KB/s):");

        jLabel7.setText("Messenger core status:");

        jLabel8.setText("Active clients:");

        jLabel9.setText("Hashed(ready to seed):");

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel10.setText("Torrents");

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel11.setText("Clients");

        jLabel12.setText("Left room:");

        jLabel13.setText("Right room:");

        jLabel14.setText("Not hashed:");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(jPanel7Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap().addGroup(jPanel7Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel7Layout.createSequentialGroup().addGroup(jPanel7Layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel3).addComponent(jLabel7)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                        jPanel7Layout.createSequentialGroup().addComponent(jLabel10)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        125, Short.MAX_VALUE)
                                                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        485, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addContainerGap())
                        .addGroup(jPanel7Layout.createSequentialGroup().addComponent(jLabel4).addContainerGap(597,
                                Short.MAX_VALUE))
                        .addGroup(jPanel7Layout.createSequentialGroup().addComponent(jLabel5).addContainerGap(599,
                                Short.MAX_VALUE))
                        .addGroup(jPanel7Layout.createSequentialGroup().addComponent(jLabel6).addContainerGap(597,
                                Short.MAX_VALUE))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                                .addGroup(
                                        jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel11).addComponent(jLabel8))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 107,
                                        Short.MAX_VALUE)
                                .addGroup(jPanel7Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(jPanel7Layout.createSequentialGroup().addGap(10, 10, 10)
                                                .addComponent(jLabel12).addGap(38, 38, 38).addComponent(jLabel13)
                                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        Short.MAX_VALUE))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout
                                                .createSequentialGroup()
                                                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        485, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addContainerGap())))
                        .addGroup(jPanel7Layout.createSequentialGroup().addComponent(jLabel9).addContainerGap(554,
                                Short.MAX_VALUE))
                        .addGroup(jPanel7Layout.createSequentialGroup().addComponent(jLabel14).addContainerGap(610,
                                Short.MAX_VALUE)))));
        jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap().addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel7)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel7Layout.createSequentialGroup().addGap(18, 18, 18).addComponent(
                                        jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel7Layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel10)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel14)
                        .addGap(62, 62, 62)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel11).addComponent(jSeparator2,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel8).addComponent(jLabel12).addComponent(jLabel13))
                        .addContainerGap(91, Short.MAX_VALUE)));

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(jPanel4Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap().addComponent(jPanel7,
                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap()));
        jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap().addComponent(jPanel7,
                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap()));

        jTabbedPane1.addTab("Statistics", jPanel4);

        jPanel1.setBackground(new java.awt.Color(51, 51, 51));

        jTextField1.setBackground(new java.awt.Color(51, 51, 51));
        jTextField1.setText("jTextField1");

        jButton12.setBackground(new java.awt.Color(51, 51, 51));
        jButton12.setText("Set");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        jLabel2.setText("Client game save folder");

        jTextField2.setBackground(new java.awt.Color(51, 51, 51));
        jTextField2.setEditable(false);
        jTextField2.setText("jTextField2");

        jLabel16.setText("Current:");

        jLabel17.setText("Server working folder(can't change when running, only during startup)");

        jTextField3.setBackground(new java.awt.Color(51, 51, 51));
        jTextField3.setEditable(false);
        jTextField3.setText("jTextField3");

        jLabel18.setText("Current:");

        jLabel19.setText("Server utorrent.exe location");

        jLabel20.setText("Current:");

        jTextField4.setBackground(new java.awt.Color(51, 51, 51));
        jTextField4.setEditable(false);
        jTextField4.setText("jTextField3");

        jButton13.setBackground(new java.awt.Color(51, 51, 51));
        jButton13.setText("...");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });

        jLabel21.setText("Version:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(jPanel1Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 562,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel16)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout
                                                .createSequentialGroup()
                                                .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        579, Short.MAX_VALUE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jButton12))
                                        .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 634,
                                                Short.MAX_VALUE)))
                        .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel17)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                                        jSeparator4, javax.swing.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE))
                        .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel18)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                                        jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 634, Short.MAX_VALUE))
                        .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel19)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                                        jSeparator6, javax.swing.GroupLayout.DEFAULT_SIZE, 538, Short.MAX_VALUE))
                        .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel20)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 583,
                                        Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton13))
                        .addComponent(jLabel21)).addContainerGap()));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
                                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 24,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jPanel1Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel16).addComponent(jTextField2,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(jPanel1Layout.createSequentialGroup().addGap(21, 21, 21).addComponent(
                                        jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButton12))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel17).addComponent(jSeparator4,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 7,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel18)
                                .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel19).addComponent(jSeparator6,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 7,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel20)
                                .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButton13))
                        .addGap(125, 125, 125).addComponent(jLabel21).addGap(25, 25, 25)));

        jTabbedPane1.addTab("System variables", jPanel1);

        jLabel15.setFont(new java.awt.Font("Kristen ITC", 1, 11));
        jLabel15.setForeground(new java.awt.Color(255, 0, 0));
        jLabel15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ca/uviccscu/lp/icons/lock2.png"))); // NOI18N
        jLabel15.setText("Interface locked");

        jProgressBar1.setBackground(new java.awt.Color(102, 102, 102));
        jProgressBar1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jProgressBar1.setForeground(new java.awt.Color(255, 255, 255));

        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Idle...");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(jPanel6Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap().addGroup(jPanel6Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 704, Short.MAX_VALUE)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(jPanel6Layout.createSequentialGroup().addComponent(jLabel1)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jLabel15))
                                        .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 704,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap()));
        jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 415,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel1).addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                javax.swing.GroupLayout.PREFERRED_SIZE));

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

    @Deprecated
    public static void setupTablePopupOld() {

        JMenuItem menuItem = new JMenuItem("Start");
        menuItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                /*
                lockInterface();
                l.trace(e.paramString());
                int row = jTable1.rowAtPoint(new Point(Shared.guiLastTablePopupX, Shared.guiLastTablePopupY));
                String game = (String) jTable1.getModel().getValueAt(row, 0);
                l.trace("Popup action! row: " + row + " and name " + game);
                int status = GamelistStorage.getGame(game).gameStatus;
                if (status == 0) {
                File g = new File(GamelistStorage.getGame(game).gameAbsoluteFolderPath);
                File tp = new File(Utils.concatenatePaths(new String[]{Shared.workingDirectory, Shared.torrentStoreSubDirectory}));
                try {
                TOTorrent t = TrackerManager.createNewTorrent(g, tp, new ProgressListener(game));
                TrackerManager.getCore().addTorrentToTracker(t, tp.getAbsolutePath(), g.getAbsolutePath());
                } catch (Exception ex) {
                l.error("Torrent create failed: " + game, ex);
                }
                } else if (status == 1||status == 2) {
                l.error("Game torrent already created");
                } else {
                l.error("Game has been run already");
                }
                unlockInterface();
                 *
                 */
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    public Void doInBackground() {
                        MainFrame.lockInterface();
                        l.trace(e.paramString());
                        int row = jTable1
                                .rowAtPoint(new Point(Shared.guiLastTablePopupX, Shared.guiLastTablePopupY));
                        String game = (String) jTable1.getModel().getValueAt(row, 0);
                        l.trace("Popup start action! row: " + row + " and name " + game);
                        int status = GamelistStorage.getGame(game).gameStatus;
                        if (status == 0) {
                            File g = new File(GamelistStorage.getGame(game).gameAbsoluteFolderPath);
                            File tp = new File(Shared.workingDirectory + Shared.torrentStoreSubDirectory + "\\"
                                    + GamelistStorage.getGame(game).gameName + ".torrent");
                            try {
                                MainFrame.setReportingActive();
                                TOTorrent t = TrackerManager.createNewTorrent(g, tp,
                                        new HashingProgressListener(game));
                                TrackerManager.getCore().addTorrentToTracker(t, tp.getAbsolutePath(),
                                        g.getAbsolutePath());
                                GamelistStorage.getGame(game).gameStatus = 1;
                                MainFrame.setReportingIdle();
                            } catch (Exception ex) {
                                l.error("Torrent create failed: " + game, ex);
                            }
                        } else if (status == 1 || status == 2) {
                            l.error("Game torrent already created");
                        } else if (status == 4) {
                            TrackerManager.getCore()
                                    .resumeTorrentSeeding(GamelistStorage.getGame(game).gameTorrent);
                            TrackerManager.getCore()
                                    .resumeTorrentTracking(GamelistStorage.getGame(game).gameTorrent);
                        } else {
                            l.error("Game has been started already");
                        }
                        return null;
                    }

                    @Override
                    public void done() {
                        MainFrame.updateProgressBar(-1, 0, 100000, "Idle", true, true);
                        MainFrame.updateProgressBar(-1, 0, 100000, "Idle", false, true);
                        MainFrame.updateTask("Idle...", true);
                        MainFrame.unlockInterface();
                    }
                };
                worker.execute();
            }
        });
        popupMenu.add(menuItem);
        JMenuItem menuItem2 = new JMenuItem("Stop");
        menuItem2.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    public Void doInBackground() {
                        MainFrame.lockInterface();
                        l.trace(e.paramString());
                        int row = jTable1
                                .rowAtPoint(new Point(Shared.guiLastTablePopupX, Shared.guiLastTablePopupY));
                        String game = (String) jTable1.getModel().getValueAt(row, 0);
                        l.trace("Popup stop action! row: " + row + " and name " + game);
                        Game g = GamelistStorage.getGame(game);
                        int status = g.gameStatus;
                        if (status == 3) {
                            try {
                                TrackerManager.getCore()
                                        .pauseTorrentSeeding(GamelistStorage.getGame(game).gameTorrent);
                                TrackerManager.getCore()
                                        .pauseTorrentTracking(GamelistStorage.getGame(game).gameTorrent);
                                g.gameStatus = 4;
                            } catch (Exception ex) {
                                l.error("Torrent create failed: " + game, ex);
                            }
                        } else if (status == 1 || status == 2) {
                            l.error("Game torrent already created");
                        } else {
                            l.error("Game has been started already");
                        }
                        return null;
                    }

                    @Override
                    public void done() {
                        MainFrame.updateProgressBar(-1, 0, 100000, "Idle", true, true);
                        MainFrame.updateProgressBar(-1, 0, 100000, "Idle", false, true);
                        MainFrame.updateTask("Idle...", true);
                        MainFrame.unlockInterface();
                    }
                };
                worker.execute();
            }
        });
        //menuItem.addActionListener(new ActionAdapter(this));
        popupMenu.add(menuItem2);
        MouseListener popupListener = new PopupListener();
        jTable1.addMouseListener(popupListener);

    }

    public static void setupOther() {
        jFileChooser1.setFileFilter(new FileNameExtensionFilter("uTorrent executable(.exe)", "exe"));
    }

    public static void setupTablePopup() {
        JMenuItem menuItem = new JMenuItem("Edit");
        menuItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                int row = jTable1.rowAtPoint(new Point(Shared.guiLastTablePopupX, Shared.guiLastTablePopupY));
                DefaultTableModel md = (DefaultTableModel) jTable1.getModel();
                jTable1.setRowSelectionInterval(row, row);
                jButton2.doClick();
            }
        });
        popupMenu.add(menuItem);
        JMenuItem menuItem2 = new JMenuItem("Hash");
        menuItem2.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                int row = jTable1.rowAtPoint(new Point(Shared.guiLastTablePopupX, Shared.guiLastTablePopupY));
                DefaultTableModel md = (DefaultTableModel) jTable1.getModel();
                jTable1.setRowSelectionInterval(row, row);
                jButton5.doClick();
            }
        });
        //menuItem.addActionListener(new ActionAdapter(this));
        popupMenu.add(menuItem2);
        MouseListener popupListener = new PopupListener();
        jTable1.addMouseListener(popupListener);
    }

    public static void updateGameInterfaceFromStorage() {
        wipeGameTableRows();
        Iterator it = GamelistStorage.getAllGames().listIterator();
        while (it.hasNext()) {
            Game g = (Game) it.next();
            addFreeRow();
            int row = jTable1.getRowCount() - 1;
            jTable1.getModel().setValueAt(g.gameName, row, 0);
            jTable1.getModel().setValueAt(g.gameAbsoluteExecPath, row, 1);
            jTable1.getModel().setValueAt(FileUtils.byteCountToDisplaySize(g.gameSize), row, 2);
            jTable1.getModel().setValueAt(GamelistStorage.gameStatusToString(g.gameStatus), row, 3);
        }
        jTextField1.setText(SettingsManager.getStorage().getFirstCfgValue("clientgamefolder"));
        jTextField2.setText(SettingsManager.getStorage().getFirstCfgValue("clientgamefolder"));
        jTextField3.setText(Shared.workingDirectory);
        jTextField4.setText(SettingsManager.getStorage().getFirstCfgValue("serverutorrentlocation"));
        jLabel21.setText("Server version: " + Shared.serverConfigVersion);
    }

    public static void updateNetworkInterfaceFromStorage() {
        wipeGameTableRows();
        Iterator it = GamelistStorage.getAllGames().listIterator();
        while (it.hasNext()) {
            Game g = (Game) it.next();
            addFreeRow();
            int row = jTable1.getRowCount() - 1;
            jTable1.getModel().setValueAt(g.gameName, row, 0);
            jTable1.getModel().setValueAt(g.gameAbsoluteExecPath, row, 1);
            jTable1.getModel().setValueAt(FileUtils.byteCountToDisplaySize(g.gameSize), row, 2);
            jTable1.getModel().setValueAt(GamelistStorage.gameStatusToString(g.gameStatus), row, 3);
        }
        jTextField1.setText(SettingsManager.getStorage().getFirstCfgValue("clientgamefolder"));
        jTextField2.setText(SettingsManager.getStorage().getFirstCfgValue("clientgamefolder"));
        jTextField3.setText(Shared.workingDirectory);
        jTextField4.setText(SettingsManager.getStorage().getFirstCfgValue("serverutorrentlocation"));
        jLabel21.setText("Server version: " + Shared.serverConfigVersion);
    }

    public static void wipeGameTableRows() {
        DefaultTableModel md = (DefaultTableModel) jTable1.getModel();
        int lim = md.getRowCount();
        for (int i = 0; i < lim; i++) {
            md.removeRow(0);
        }
    }

    public static void wipeNetworkTableRows() {
        DefaultTableModel md = (DefaultTableModel) jTable2.getModel();
        int lim = md.getRowCount();
        for (int i = 0; i < lim; i++) {
            md.removeRow(0);
        }
    }

    public static void addFreeRow() {
        DefaultTableModel md = (DefaultTableModel) jTable1.getModel();
        md.setRowCount(jTable1.getRowCount() + 1);
    }

    //ADD GAME
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        l.info("Add game action activated");
        MainFrame.lockInterface();
        MainFrame.updateTask("Adding game...", true);
        AddGameDialog addGameDialog = new AddGameDialog(this, true);
        addGameDialog.setLocationRelativeTo(null);
        //addGameDialog.setVisible(true);
        final Game g = addGameDialog.popupCreateDialog();
        if (g != null) {
            l.trace("Analyzing game: " + g.gameAbsoluteFolderPath);
            MainFrame.updateTask("Adding game...", true);
            final int row = getNextFreeRowNumber();
            addFreeRow();
            jTable1.getModel().setValueAt(g.gameName, row, 0);
            jTable1.getModel().setValueAt(g.gameAbsoluteExecPath, row, 1);
            jTable1.getModel().setValueAt(GamelistStorage.gameStatusToString(g.gameStatus), row, 3);
            MainFrame.updateProgressBar(0, 0, 0, "Analyzing game", true, true);
            final ObjectPlaceholder obj = new ObjectPlaceholder();
            SwingWorker worker = new SwingWorker<Long, Void>() {

                @Override
                public Long doInBackground() throws IOException {
                    l.trace("Checking size");
                    MainFrame.updateProgressBar(0, 0, 0, "Analyzing game size", true, true);
                    obj.payload = FileUtils.sizeOfDirectory(new File(g.gameAbsoluteFolderPath));
                    l.trace("Checking files");
                    MainFrame.updateProgressBar(0, 0, 0, "Analyzing game files", true, true);
                    g.gameFileNumber = FileUtils.listFiles(new File(g.gameAbsoluteFolderPath), null, true).size();
                    l.trace("Checking CRC32");
                    MainFrame.updateProgressBar(0, 0, 0, "Analyzing game signature", true, true);
                    g.gameExecCRC32 = FileUtils.checksumCRC32(new File(g.gameAbsoluteExecPath));
                    return ((Long) obj.payload);
                }

                public void done() {
                    l.trace("Finishing game check");
                    MainFrame.updateProgressBar(0, 0, 0, "Finishing game creation", false, false);
                    g.gameSize = ((Long) obj.payload);
                    /*
                    double mbsize = Math.ceil(g.gameSize / (1024 * 1024));
                    jTable1.getModel().setValueAt(mbsize, row, 2);
                     * 
                     */
                    jTable1.getModel().setValueAt(FileUtils.byteCountToDisplaySize(g.gameSize), row, 2);
                    Shared.lastCreatedGame = null;
                    GamelistStorage.addGame(g);
                    jTable1.getModel().setValueAt(GamelistStorage.gameStatusToString(g.gameStatus), row, 3);
                    g.gameStatus = 0;
                    SettingsManager.getStorage().storeGame(g);
                    /*
                    try {
                    SettingsManager.storeCurrentSettings();
                    } catch (Exception ex) {
                    l.debug(ex.getMessage(), ex);
                    }
                     * 
                     */
                    l.trace("Done adding game");
                    MainFrame.setReportingIdle();
                    MainFrame.unlockInterface();
                }
            };
            worker.execute();
        } else {
            l.debug("Add game dialog - null game returned, nothing done");
            MainFrame.setReportingIdle();
            MainFrame.unlockInterface();
        }
        MainFrame.updateGameInterfaceFromStorage();
    }//GEN-LAST:event_jButton1ActionPerformed

    //EDIT SELECTED
    //have to use the stupid payload b/c of inner class
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        l.info("Edit game action activated");
        MainFrame.lockInterface();
        MainFrame.updateTask("Editing game...", true);
        l.info("Starting game edit action");
        DefaultTableModel mdl = (DefaultTableModel) jTable1.getModel();
        final int row = jTable1.getSelectedRow();
        if (row >= 0 && mdl.getValueAt(row, 0) != null) {
            AddGameDialog addGameDialog = new AddGameDialog(this, true);
            addGameDialog.setLocationRelativeTo(null);
            //addGameDialog.setVisible(true);
            final Game temp = GamelistStorage.getGame((String) mdl.getValueAt(row, 0));
            final Game g = addGameDialog.popupEditDialog(temp);
            if (g != null) {
                l.trace("Edit done, checking for changes");
                //l.trace("Calculating folder size: " + g.gameAbsoluteFolderPath);
                MainFrame.updateTask("Checking for changes...", true);
                MainFrame.updateGameInterfaceFromStorage();
                boolean changed = true;
                if (temp.gameAbsoluteExecPath.equals(g.gameAbsoluteExecPath)
                        && temp.gameAbsoluteFolderPath.equals(g.gameAbsoluteFolderPath)) {
                    l.trace("Location same - assuming no changes made");
                    g.gameName = temp.gameName;
                    g.gameBatCommands = temp.gameBatCommands;
                    g.gamePName = temp.gamePName;
                    g.gamePUser = temp.gamePUser;
                    g.gamePWName = temp.gamePWName;
                    g.gameRuntimeFlags = temp.gameRuntimeFlags;
                    changed = false;
                } else {
                    l.trace("Locations changed - rescanning the game");
                    g.gameStatus = 0;
                    MainFrame.updateProgressBar(0, 0, 0, "Calculating game size", true, true);
                    final ObjectPlaceholder obj = new ObjectPlaceholder();
                    SwingWorker worker = new SwingWorker<Long, Void>() {

                        @Override
                        public Long doInBackground() throws IOException {
                            MainFrame.lockInterface();
                            l.trace("Checking size");
                            MainFrame.updateProgressBar(0, 0, 0, "Analyzing game size", true, true);
                            obj.payload = FileUtils.sizeOfDirectory(new File(g.gameAbsoluteFolderPath));
                            l.trace("Checking files");
                            MainFrame.updateProgressBar(0, 0, 0, "Analyzing game files", true, true);
                            g.gameFileNumber = FileUtils.listFiles(new File(g.gameAbsoluteFolderPath), null, true)
                                    .size();
                            l.trace("Checking CRC32");
                            MainFrame.updateProgressBar(0, 0, 0, "Analyzing game signature", true, true);
                            g.gameExecCRC32 = FileUtils.checksumCRC32(new File(g.gameAbsoluteExecPath));
                            return ((Long) obj.payload);
                        }

                        @Override
                        public void done() {
                            l.trace("Finishing game check");
                            MainFrame.updateProgressBar(0, 0, 0, "Finishing game edit", false, false);
                            g.gameSize = ((Long) obj.payload);
                            /*
                            double mbsize = Math.ceil(g.gameSize / (1024 * 1024));
                            jTable1.getModel().setValueAt(mbsize, row, 2);
                             *
                             */
                            g.copyTo(temp);
                            Shared.lastCreatedGame = null;
                            l.trace("Done editing game");
                            MainFrame.updateGameInterfaceFromStorage();
                            MainFrame.unlockInterface();
                            MainFrame.setReportingIdle();
                        }
                    };
                    worker.execute();
                }
                //we are trusting the size task to finish here ELSE TROUBLE
                /*
                GamelistStorage.removeGame(temp.gameName);
                GamelistStorage.addGame(g);
                 * 
                 */
                if (!changed) {
                    MainFrame.unlockInterface();
                    MainFrame.setReportingIdle();
                }
                MainFrame.updateGameInterfaceFromStorage();
            } else {
                MainFrame.unlockInterface();
                MainFrame.setReportingIdle();
                MainFrame.updateGameInterfaceFromStorage();
            }
        } else {
            l.trace("Game edit - bad selection or empty table");
            JOptionPane.showMessageDialog(this, "Invalid selection - can't edit", "Edit error",
                    JOptionPane.WARNING_MESSAGE);
            MainFrame.unlockInterface();
            MainFrame.setReportingIdle();
            MainFrame.updateGameInterfaceFromStorage();
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    //REMOVE SELECTED
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        l.info("Remove game action activated");
        //JOptionPane conf = new JOptionPane();
        if (jTable1.getSelectedRow() >= 0) {
            int result = JOptionPane.showConfirmDialog(rootPane, "Are you sure you want to delete?", "Confirmation",
                    2, 3);
            //JDialog dialog = conf.createDialog(jPanel1, "Are you sure u want to delete?");
            //dialog.show();
            //Object selectedValue = conf.getValue();

            l.trace("Game delete dialog code: " + result);
            if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) {
                l.trace("Game delete cancelled");
            } else if (result == JOptionPane.OK_OPTION) {
                DefaultTableModel mdl = (DefaultTableModel) jTable1.getModel();
                String name = (String) mdl.getValueAt(jTable1.getSelectedRow(), 0);
                if (name != null) {
                    l.trace("Removing game: " + name);
                    GamelistStorage.removeGame(name);
                    SettingsManager.getStorage().removeGame(name);
                    mdl.removeRow(jTable1.getSelectedRow());
                    l.debug("Game removed: " + name);
                } else {
                    mdl.removeRow(jTable1.getSelectedRow());
                    l.trace("Empty row - just erasing in table");
                }
            }
        }
        MainFrame.updateGameInterfaceFromStorage();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        l.info("Load config action activated");
        try {
            SettingsManager.showLoadSettingsDialog();
        } catch (Exception ex) {
            l.error("Settings load failed", ex);
        }
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        l.info("Save config action activated");
        try {
            SettingsManager.showSaveSettingsDialog();
        } catch (Exception ex) {
            l.error("Settings save failed", ex);
        }
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        l.info("Hash action activated");
        final ActionEvent ev = evt;
        if (!Shared.hashInProgress) {
            //final Game gg;
            if (jTable1.getSelectedRow() >= 0) {
                DefaultTableModel mdl = (DefaultTableModel) jTable1.getModel();
                String name = (String) mdl.getValueAt(jTable1.getSelectedRow(), 0);
                if (name != null) {
                    MainFrame.lockInterface();
                    SwingWorker worker = new SwingWorker<Void, Void>() {

                        @Override
                        public Void doInBackground() {
                            l.trace("Starting hashing");
                            MainFrame.lockInterface();
                            Shared.hashInProgress = true;
                            int row = jTable1.getSelectedRow();
                            String game = (String) jTable1.getModel().getValueAt(row, 0);
                            l.trace("Selection -  row: " + row + " and name " + game);
                            int status = GamelistStorage.getGame(game).gameStatus;
                            if (status == 0) {
                                File g = new File(GamelistStorage.getGame(game).gameAbsoluteFolderPath);
                                File tp = new File(SettingsManager.getTorrentFolderPath()
                                        + GamelistStorage.getGame(game).gameName + ".torrent");
                                try {
                                    updateTask("Preparing to hash - wait!", true);
                                    updateProgressBar(0, 0, 0, "...", false, true);
                                    jButton5.setText("STOP");
                                    //jButton5.setForeground(Color.RED);
                                    jButton5.setEnabled(true);
                                    jButton5.requestFocusInWindow();
                                    MainFrame.setReportingActive();
                                    GamelistStorage.getGame(game).gameStatus = 1;
                                    MainFrame.updateGameInterfaceFromStorage();
                                    TOTorrent t = TrackerManager.createNewTorrent(g, tp,
                                            new HashingProgressListener(game));
                                    TrackerManager.getCore().addTorrentToTracker(t, tp.getAbsolutePath(),
                                            g.getAbsolutePath());
                                    GamelistStorage.getGame(game).gameStatus = 2;
                                    MainFrame.updateGameInterfaceFromStorage();
                                    MainFrame.setReportingIdle();
                                } catch (Exception ex) {
                                    l.error("Torrent create failed: " + game, ex);
                                }
                            } else if (status == 1 || status == 2) {
                                l.error("Game torrent already created");
                                int ans = JOptionPane.showConfirmDialog(null,
                                        "This game has already been hashed. Rehash?", "Hashing error",
                                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
                                if (ans == JOptionPane.OK_OPTION) {
                                    GamelistStorage.getGame(game).gameStatus = 0;
                                    File tp = new File(Shared.workingDirectory + Shared.torrentStoreSubDirectory
                                            + "\\" + GamelistStorage.getGame(game).gameName + ".torrent");
                                    FileUtils.deleteQuietly(tp);
                                    Shared.hashInProgress = false;
                                    jButton5ActionPerformed(ev);
                                    Shared.hashInProgress = true;
                                } else {
                                    //
                                }
                            } else {
                                l.error("Game status invalid - hashing aborted");
                            }
                            return null;
                        }

                        @Override
                        public void done() {
                            MainFrame.setReportingIdle();
                            jButton5.setText("Hash selected");
                            //jButton5.setForeground(Color.WHITE);
                            MainFrame.unlockInterface();
                            Shared.hashInProgress = false;
                            MainFrame.updateGameInterfaceFromStorage();
                        }
                    };
                    worker.execute();
                } else {
                    l.trace("Empty row - no action required");
                }
            }
        } else {
            try {
                l.trace("Stopping current hashing");
                TrackerManager.cancelNewTorrentCreation();
                int row = jTable1.getSelectedRow();
                String game = (String) jTable1.getModel().getValueAt(row, 0);
                GamelistStorage.getGame(game).gameStatus = 0;
                MainFrame.unlockInterface();
                MainFrame.updateGameInterfaceFromStorage();
            } catch (TOTorrentException ex) {
                l.info("Abort exception received as expected", ex);
            } catch (Exception ex) {
                l.error("Hash abort unexpected exception - abort failed");
            }
            jButton5.setText("Hash selected");
            jButton5.setForeground(Color.WHITE);
        }
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        l.info("Send to uTorrent action activated");
        /*
         * readout test
        l.trace(jTable1.getModel().getValueAt(0, 0));
        l.trace(jTable1.getModel().getValueAt(0, 1));
        l.trace(jTable1.getModel().getValueAt(0, 2));
        l.trace(jTable1.getModel().getValueAt(0, 3));
        l.trace(jTable1.getModel().getValueAt(0, 4));
        l.trace(jTable1.getValueAt(0, 4));
         * 
         */
        boolean at_least_one = false;
        for (int i = 0; i < jTable1.getRowCount(); i++) {
            try {
                //can't read in value directly becuase table sometimes has null, not true or false
                Object obj = jTable1.getModel().getValueAt(i, 4);
                if (obj != null) {
                    boolean on_gl = (Boolean) obj;
                    if (on_gl) {
                        at_least_one = true;
                        String s = (String) jTable1.getValueAt(i, 0);
                        Game g = GamelistStorage.getGame(s);
                        if (g.gameStatus != 2) {
                            l.trace("Game " + g.gameName + " is on GL but wrong status");
                        } else {
                            l.trace("Adding game " + g.gameName);
                            String cmd = "C:\\Program Files\\uTorrent\\uTorrent.exe" + " /DIRECTORY \""
                                    + g.gameAbsoluteFolderPath.substring(0, g.gameAbsoluteFolderPath.length() - 1)
                                    + "\" \"" + Shared.workingDirectory + "\\Torrents\\" + g.gameName
                                    + ".torrent\"";
                            l.trace("Executing command: " + cmd);
                            // TODO implement apache exec library for easier flag passing
                            Process p = Runtime.getRuntime().exec(cmd);
                        }
                    }
                }
            } catch (Exception ex) {
                l.error("uTorrent call error - row " + i, ex);
            }
            if (!at_least_one) {
                JOptionPane.showMessageDialog(null, "No games on GL!", "uTorrent send error",
                        JOptionPane.WARNING_MESSAGE);
            }
        }
        // Process p = Runtime.getRuntime().exec(null)
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        l.info("Put on GL action activated");
        int row = jTable1.getSelectedRow();
        if (jTable1.getSelectedRow() >= 0) {
            String s = (String) jTable1.getValueAt(row, 0);
            Game g = GamelistStorage.getGame(s);
            if (g.gameStatus != 2) {
                JOptionPane.showMessageDialog(this, "This game has not been hashed yet!", "Game status invalid",
                        JOptionPane.WARNING_MESSAGE);
            } else {
                jTable1.getModel().setValueAt(true, row, 4);
                l.trace("Game added to GL: " + g.gameName);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Select a row first", "Row operation error",
                    JOptionPane.WARNING_MESSAGE);
        }
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        l.info("Remove from GL action activated");
        int row = jTable1.getSelectedRow();
        if (jTable1.getSelectedRow() >= 0) {
            jTable1.getModel().setValueAt(false, row, 4);
        } else {
            JOptionPane.showMessageDialog(null, "Select a row first", "Row operation error",
                    JOptionPane.WARNING_MESSAGE);
        }
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        String s = jTextField1.getText();
        if (SettingsManager.verifyClientGameFolder(s) == 0) {
            SettingsManager.getStorage().removeCfgValue("clientgamefolder");
            SettingsManager.getStorage().putCfgValue("clientgamefolder", jTextField1.getText());
            jTextField2.setText(jTextField1.getText());
        } else {
            JOptionPane.showMessageDialog(null, "Client game folder invalid", "Property set error",
                    JOptionPane.WARNING_MESSAGE);
        }
    }//GEN-LAST:event_jButton12ActionPerformed

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
        int result = jFileChooser1.showDialog(this, "Set");
        if (result == 0) {
            jTextField4.setText(jFileChooser1.getSelectedFile().getAbsolutePath() + "\\");
            l.trace("FC 1: " + result + ", chosen file: " + jFileChooser1.getSelectedFile().getAbsolutePath()
                    + "\\");
        } else if (result == 1) {
            l.trace("FC 1: " + result + ", choosing cancelled");
        }
    }//GEN-LAST:event_jButton13ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        l.info("Show torrent folder action activated");
        File f = new File(SettingsManager.getTorrentFolderPath());
        if (f.isDirectory()) {
            try {
                if (Desktop.isDesktopSupported()) {
                    l.trace("System supported - opening");
                    Desktop.getDesktop().open(f);
                } else {
                    JOptionPane.showMessageDialog(null, "OS is not supported - open manually", "OS error",
                            JOptionPane.WARNING_MESSAGE);
                }
            } catch (Exception ex) {
                l.error("Opening folder exception", ex);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Folder doesn't exist, likely because no games have been hashed",
                    "OS error", JOptionPane.WARNING_MESSAGE);
        }
    }//GEN-LAST:event_jButton10ActionPerformed

    public static void updateTask(String msg, boolean enabled) {
        l.trace("Task update");
        t1.cancel();
        jLabel1.setText(msg);
        jLabel1.setEnabled(enabled);
    }

    //variable scope issues, need to do a separate thread
    /*
    public static void updateTask(String msg, boolean enabled, int timeout) {
    TimerTask tsk = new TimerTask() {
        
    @Override
    public void run() {
    l.trace("TimerTask task update");
    Object[] obj = (Object[]) q1.poll();
    String s = (String) (obj[0]);
    jLabel1.setText(s);
    jLabel1.setEnabled((Boolean) (obj[1]));
    TimerTask tsk2 = new TimerTask() {
        
    @Override
    public void run() {
    l.trace("TimerTask task text hiding");
    jLabel1.setText("");
    if (q1.size() != 0) {
    t1.schedule(tsk, 0);
    }
    }
    };
    t1.schedule(tsk2, (Integer) (((Object[]) q1.poll())[2]));
    }
    };
    if (q1.size() != 0) {
    q1.offer(new Object[]{msg, enabled, timeout});
    } else {
    q1.offer(new Object[]{msg, enabled, timeout});
    t1.schedule(tsk, 0);
    }
    }
     *
     */
    public static void updateTooltip(String msg, boolean enabled) {
        t2.cancel();
        //jLabel2.setText(msg);
        //jLabel2.setVisible(enabled);
    }

    /*
    public static void updateTooltip(String msg, boolean enabled, int timeout) {
    jLabel2.setText(msg);
    jLabel2.setVisible(enabled);
    Timer t = new Timer();
    TimerTask tsk = new TimerTask() {
        
    @Override
    public void run() {
    jLabel2.setText("");
    }
    };
    t.schedule(tsk, timeout);
    }
     * 
     */
    public static void updateProgressBar(int value, int min, int max, String msg, boolean indeterminate,
            boolean string_painted) {
        jProgressBar1.setMaximum(max);
        jProgressBar1.setMinimum(min);
        jProgressBar1.setValue(value);
        jProgressBar1.setString(msg);
        jProgressBar1.setIndeterminate(indeterminate);
        jProgressBar1.setStringPainted(string_painted);
    }

    public static void updateProgressBar(int value) {
        jProgressBar1.setValue(value);
    }

    public static void setReportingIdle() {
        MainFrame.updateTask("Idle...", true);
        MainFrame.updateTooltip(" ", false);
        MainFrame.updateProgressBar(0, 0, 0, "***", false, false);
        MainFrame.jProgressBar1.setForeground(new Color(255, 255, 255));
        MainFrame.jProgressBar1.setBorderPainted(false);
    }

    public static void setReportingActive() {
        MainFrame.jProgressBar1.setForeground(new Color(0, 130, 0));
        MainFrame.jProgressBar1.setBorderPainted(true);
    }

    public static void lockInterface() {
        jTabbedPane1.setEnabled(false);
        for (Component c : jTabbedPane1.getComponents()) {
            recursiveComponentChange(c, false);
        }
        jPanel6.setEnabled(false);
        jLabel15.setVisible(true);
        //jButton8.setEnabled(true);
        //jButton8.setEnabled(false);
    }

    public static void unlockInterface() {
        /*
        for (Window w : MainFrame.getWindows()) {
        w.setEnabled(true);
        for (Component c : w.getComponents()) {
        c.setEnabled(false);
        }
        }
         *
         */
        jTabbedPane1.setEnabled(true);
        for (Component c : jTabbedPane1.getComponents()) {
            recursiveComponentChange(c, true);
        }

        jPanel6.setEnabled(true);
        jLabel15.setVisible(false);
        //jButton8.setEnabled(false);
        //jButton8.setEnabled(true);
    }

    // TODO implement recursive auto search starting from only single top frame
    public static void recursiveComponentChange(Component c, boolean enabled) {
        if (c instanceof Container) {
            Component[] components = ((Container) c).getComponents();
            if (components != null && components.length > 0) {
                int count = components.length;
                for (int i = 0; i < count; i++) {
                    components[i].setEnabled(enabled);
                    recursiveComponentChange(components[i], enabled);
                }
            }
        }
        c.setEnabled(enabled);
    }

    public static int getNextFreeRowNumber() {
        DefaultTableModel md = (DefaultTableModel) jTable1.getModel();
        if (jTable1.getRowCount() == 0) {
            md.setRowCount(1);
            return 0;
        }
        int i = 0;
        for (; i < jTable1.getRowCount(); i++) {
            if (jTable1.getValueAt(i, 0) == null) {
                return i;
            }
        }
        return i;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex) {
            //
        }
        Logger.getRootLogger().setLevel(Level.ALL);
        Logger.getRootLogger()
                .addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
        PropertyPrinter.main(new String[] {});
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private static javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private static javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private static javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private static javax.swing.JFileChooser jFileChooser1;
    private static javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private static javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private static javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JOptionPane jOptionPane1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private static javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private static javax.swing.JProgressBar jProgressBar1;
    private static javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JSeparator jSeparator7;
    private static javax.swing.JTabbedPane jTabbedPane1;
    private static javax.swing.JTable jTable1;
    private static javax.swing.JTable jTable2;
    private static javax.swing.JTextField jTextField1;
    private static javax.swing.JTextField jTextField2;
    private static javax.swing.JTextField jTextField3;
    private static javax.swing.JTextField jTextField4;
    // End of variables declaration//GEN-END:variables
}