/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* MainFrame.java
*
* Created on 06.07.2010, 15:22:13
*/
package meganetpo;
import java.awt.AWTException;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import javax.swing.Timer;
import java.util.concurrent.ExecutorService;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import javax.swing.DefaultListModel;
import meganetpo.picturehandler.PictureHandler;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.log4j.Logger;
/**
*
* @author Semen
*/
public class MainFrame extends javax.swing.JFrame implements ActionListener {
private static final Logger logger = Logger.getLogger(PictureHandler.class);
private DefaultListModel listModel;
private String errorMsg = "";
ExecutorService exec;
private PictureHandler picH;
private Timer timer = null;
private PropertiesConfiguration conf = picture.Main.config;
private PlayersRepository playersRepository = new PlayersRepository();
private boolean autoupdate;
private Integer autoupdateVal;
private String monitorText = "";
private SystemTray systemTray = SystemTray.getSystemTray();
private TrayIcon trayIcon = null;
private boolean hideTray;
private boolean hideTraySaved;
/** Creates new form MainFrame */
public MainFrame() {
listModel = new DefaultListModel();
try {
trayIcon = new TrayIcon(ImageIO.read(new File("ico.gif")), "MeganetSpy");
} catch (IOException ex) {
logger.error(ex.getMessage());
}
trayIcon.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(true);
setState(MainFrame.NORMAL);
removeTrayIcon();
}
});
initComponents();
timer = new Timer(500, this);
timer.start();
autoupdate = conf.getBoolean("picturehandler.doautoupdate");
autoupdateVal = conf.getInt("picturehandler.autoupdate");
hideTraySaved = hideTray = conf.getBoolean("mainframe.hidetray");
trayIcon.setPopupMenu(trayMenu);
}
/** 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() {
jErrorMsg = new javax.swing.JDialog();
jErrorOKButton = new javax.swing.JButton();
jErrorLabel = new javax.swing.JLabel();
trayMenu = new java.awt.PopupMenu();
trayShowMenu = new java.awt.MenuItem();
trayExitMenu = new java.awt.MenuItem();
jTabbedPane1 = new javax.swing.JTabbedPane();
monitor = new javax.swing.JPanel();
jProgressBar1 = new javax.swing.JProgressBar();
jUpdateButton = new javax.swing.JButton();
errorString = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jEditorPane1 = new javax.swing.JEditorPane();
settingPanel = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
nickList = new javax.swing.JList();
nickTextForm = new javax.swing.JTextField();
addNick = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jSpinner1 = new javax.swing.JSpinner();
applySetting = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
autoupdateCheck = new javax.swing.JCheckBox();
jLabel8 = new javax.swing.JLabel();
hideTrayChickBox = new javax.swing.JCheckBox();
jPanel2 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
saveList = new javax.swing.JComboBox();
saveListLoad = new javax.swing.JButton();
saveListRemove = new javax.swing.JButton();
saveListSave = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
jEditorPane2 = new javax.swing.JEditorPane();
jErrorMsg.setTitle("Error");
jErrorMsg.setMinimumSize(new java.awt.Dimension(300, 150));
jErrorMsg.setResizable(false);
jErrorOKButton.setText("OK");
jErrorOKButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
jErrorOKButtonMousePressed(evt);
}
});
javax.swing.GroupLayout jErrorMsgLayout = new javax.swing.GroupLayout(jErrorMsg.getContentPane());
jErrorMsg.getContentPane().setLayout(jErrorMsgLayout);
jErrorMsgLayout.setHorizontalGroup(
jErrorMsgLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jErrorMsgLayout.createSequentialGroup()
.addGap(65, 65, 65)
.addComponent(jErrorLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jErrorMsgLayout.createSequentialGroup()
.addContainerGap(129, Short.MAX_VALUE)
.addComponent(jErrorOKButton, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(98, 98, 98))
);
jErrorMsgLayout.setVerticalGroup(
jErrorMsgLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jErrorMsgLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jErrorLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jErrorOKButton, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE)
.addContainerGap())
);
jErrorLabel.getAccessibleContext().setAccessibleName("ErrorLabel");
trayMenu.setFont(trayMenu.getFont());
trayMenu.setLabel("popupMenu1");
trayShowMenu.setFont(trayShowMenu.getFont());
trayShowMenu.setLabel("Show");
trayShowMenu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
trayShowMenuActionPerformed(evt);
}
});
trayMenu.add(trayShowMenu);
trayMenu.addSeparator();
trayExitMenu.setFont(trayExitMenu.getFont());
trayExitMenu.setLabel("Exit");
trayExitMenu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
trayExitMenuActionPerformed(evt);
}
});
trayMenu.add(trayExitMenu);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("MeganetSpy");
setIconImage(Toolkit.getDefaultToolkit().getImage("ico.gif"));
setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowIconified(java.awt.event.WindowEvent evt) {
formWindowIconified(evt);
}
});
jTabbedPane1.setPreferredSize(new java.awt.Dimension(492, 558));
monitor.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
monitor.setFont(monitor.getFont());
jUpdateButton.setFont(jUpdateButton.getFont());
jUpdateButton.setText("Update");
jUpdateButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jUpdateButtonMouseClicked(evt);
}
});
errorString.setFont(errorString.getFont());
errorString.setForeground(java.awt.Color.red);
errorString.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
errorString.setAlignmentY(0.0F);
errorString.setMaximumSize(new java.awt.Dimension(200, 16));
errorString.setMinimumSize(new java.awt.Dimension(200, 16));
jEditorPane1.setBorder(null);
jEditorPane1.setContentType("text/html");
jEditorPane1.setEditable(false);
jScrollPane2.setViewportView(jEditorPane1);
javax.swing.GroupLayout monitorLayout = new javax.swing.GroupLayout(monitor);
monitor.setLayout(monitorLayout);
monitorLayout.setHorizontalGroup(
monitorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, monitorLayout.createSequentialGroup()
.addContainerGap()
.addGroup(monitorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 475, Short.MAX_VALUE)
.addGroup(monitorLayout.createSequentialGroup()
.addComponent(errorString, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(monitorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(monitorLayout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 196, Short.MAX_VALUE)
.addComponent(jUpdateButton))
.addGroup(monitorLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE)))))
.addContainerGap())
);
monitorLayout.setVerticalGroup(
monitorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, monitorLayout.createSequentialGroup()
.addGap(74, 74, 74)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jUpdateButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(monitorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(errorString, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
jTabbedPane1.addTab("�������", monitor);
nickList.setModel(listModel);
jScrollPane1.setViewportView(nickList);
addNick.setLabel(">>");
addNick.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
addPlayer(evt);
}
});
jButton2.setText("<<");
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
removePlayer(evt);
}
});
jLabel1.setText("������� ��:");
jLabel2.setText("������ �����������:");
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel1.setOpaque(false);
jLabel3.setText("��������� �������������");
jSpinner1.setValue(conf.getInt("picturehandler.autoupdate")/1000);
jSpinner1.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
jSpinner1StateChanged(evt);
}
});
applySetting.setText("���������");
applySetting.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
applySettingMouseClicked(evt);
}
});
jLabel5.setText("��������� ���������:");
jLabel6.setText("�������� ����������");
autoupdateCheck.setSelected(conf.getBoolean("picturehandler.doautoupdate"));
autoupdateCheck.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
autoupdateCheckItemStateChanged(evt);
}
});
jLabel8.setText("������� � ����");
hideTrayChickBox.setSelected(conf.getBoolean("mainframe.hidetray"));
hideTrayChickBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
hideTrayChickBoxItemStateChanged(evt);
}
});
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.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel5)
.addContainerGap(139, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(autoupdateCheck)
.addComponent(hideTrayChickBox)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 157, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(19, 19, 19)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(applySetting)
.addContainerGap())))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel5)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(autoupdateCheck, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jSpinner1, javax.swing.GroupLayout.Alignment.TRAILING, 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.CENTER)
.addComponent(hideTrayChickBox)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 147, Short.MAX_VALUE)
.addComponent(applySetting)
.addContainerGap())
);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
jLabel4.setText("������ ��� ��������");
saveList.setEditable(true);
saveList.setModel(new javax.swing.DefaultComboBoxModel(getSaveFileList()));
saveList.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
saveListLoad.setText("���������");
saveListLoad.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
saveListLoadMouseClicked(evt);
}
});
saveListRemove.setText("�������");
saveListRemove.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
saveListRemoveMouseClicked(evt);
}
});
saveListSave.setText("���������");
saveListSave.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
saveListSaveMouseClicked(evt);
}
});
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(jLabel4)
.addComponent(saveList, 0, 129, Short.MAX_VALUE)
.addComponent(saveListSave, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(saveListLoad, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
.addComponent(saveListRemove, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(saveListLoad)
.addComponent(saveList, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(saveListRemove)
.addComponent(saveListSave))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout settingPanelLayout = new javax.swing.GroupLayout(settingPanel);
settingPanel.setLayout(settingPanelLayout);
settingPanelLayout.setHorizontalGroup(
settingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(settingPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(settingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(settingPanelLayout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(183, 183, 183))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, settingPanelLayout.createSequentialGroup()
.addComponent(nickTextForm, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(settingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)
.addComponent(addNick, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, settingPanelLayout.createSequentialGroup()
.addGroup(settingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addGroup(settingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
settingPanelLayout.setVerticalGroup(
settingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(settingPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(settingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(settingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(settingPanelLayout.createSequentialGroup()
.addGroup(settingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(addNick)
.addComponent(nickTextForm))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addGap(45, 45, 45)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE))
.addContainerGap())
);
jTabbedPane1.addTab("���������", settingPanel);
jPanel3.setPreferredSize(new java.awt.Dimension(500, 550));
jLabel7.setIcon(new javax.swing.ImageIcon("D:\\Sam\\Programming\\JAVA\\Meganet\\MeganetSpy\\about.gif")); // NOI18N
jEditorPane2.setContentType("text/html");
jEditorPane2.setEditable(false);
jEditorPane2.setText("<html>\r\n <head>\r\n\r\n </head>\r\n <body>\r\n <p><strong>MeganetSpy </strong>v0.4 Beta</p>\n<p>Copyright � 2010 by Astoret</p>\n<p>��� ��������� ���������; �� ������ �������� �������������� � �/��� �������������� � � ������������ � ����������� ������������ �������� GNU, �������������� ������ ���������� ��; ���� ������ 3, ���� (�� ������ ������) ����� ����� ������� ������. ��� ��������� ���������������� � �������, ��� ��� ����� ��������, �� ��� �����-���� ��������; ���� ��� ��������������� �������� ������������ �������� ��� ����������� ��� ���������� ����. ��� ��������� ��������� �������� �������� ����������� ������������ �������� GNU. �� ������ ���� �������� ����� ����������� ������������ �������� GNU ������ � ���� ����������; ���� ���,�������� <a href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a>.</p>\n<p>Website: <a href=\"https://sourceforge.net/projects/meganetspy/\">http://sourceforge.net/projects/meganetspy</a></p>\n </body>\r\n</html>\r\n"); // NOI18N
jScrollPane3.setViewportView(jEditorPane2);
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.CENTER)
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE)
.addComponent(jLabel7))
.addGap(37, 37, 37))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel7)
.addGap(18, 18, 18)
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)
.addContainerGap())
);
jTabbedPane1.addTab("� ���������", jPanel3);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 502, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 578, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void addPlayer(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_addPlayer
String nick = nickTextForm.getText();
Player player = playersRepository.get(nick);
listModel.addElement(player);
picH.setListModel(listModel);
}//GEN-LAST:event_addPlayer
private void jErrorOKButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jErrorOKButtonMousePressed
jErrorMsg.setVisible(false);
}//GEN-LAST:event_jErrorOKButtonMousePressed
private void removePlayer(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removePlayer
int index = nickList.getSelectedIndex();
if (index >= 0) {
playersRepository.remove((Player) getListModel().get(index));
getListModel().removeElementAt(index);
picH.setListModel(listModel);
}
}//GEN-LAST:event_removePlayer
private void jUpdateButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jUpdateButtonMouseClicked
try {
picH.update();
} catch (IOException ex) {
logger.error(ex);
}
}//GEN-LAST:event_jUpdateButtonMouseClicked
private void jSpinner1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner1StateChanged
autoupdateVal = (Integer) jSpinner1.getValue();
Integer msUpdate = 1000 * autoupdateVal;
if (autoupdateVal <= 0) {
jSpinner1.setValue(1000);
}
else {
conf.setProperty("picturehandler.autoupdate", msUpdate);
}
}//GEN-LAST:event_jSpinner1StateChanged
private void applySettingMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_applySettingMouseClicked
ApplyAllConfig();
try {
conf.save();
} catch (ConfigurationException ex) {
logger.error(ex.getMessage());
}
}//GEN-LAST:event_applySettingMouseClicked
private void saveListSaveMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveListSaveMouseClicked
String fileName = conf.getString("meganetpo.savelist.path")
+ saveList.getSelectedItem();
fileName += ".xml";
try {
playersRepository.save(fileName);
} catch (FileNotFoundException ex) {
logger.error(ex.getMessage());
}
saveList.setModel(new javax.swing.DefaultComboBoxModel(getSaveFileList()));
}//GEN-LAST:event_saveListSaveMouseClicked
private void saveListLoadMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveListLoadMouseClicked
String fileName = conf.getString("meganetpo.savelist.path")
+ saveList.getSelectedItem();
fileName += ".xml";
try {
playersRepository.load(fileName);
} catch (FileNotFoundException ex) {
logger.error(ex.getMessage());
}
listModel.removeAllElements();
for (Player player : playersRepository.getPlayerList()) {
listModel.addElement(player);
}
picH.setListModel(listModel);
}//GEN-LAST:event_saveListLoadMouseClicked
private void saveListRemoveMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveListRemoveMouseClicked
String fileName = conf.getString("meganetpo.savelist.path")
+ saveList.getSelectedItem();
fileName += ".xml";
File file = new File(fileName);
file.delete();
}//GEN-LAST:event_saveListRemoveMouseClicked
private void autoupdateCheckItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_autoupdateCheckItemStateChanged
autoupdate = autoupdateCheck.isSelected();
conf.setProperty("picturehandler.doautoupdate", autoupdate);
}//GEN-LAST:event_autoupdateCheckItemStateChanged
private void formWindowIconified(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowIconified
if (hideTraySaved) {
setVisible(false);
addTrayIcon();
}
}//GEN-LAST:event_formWindowIconified
private void trayShowMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_trayShowMenuActionPerformed
setVisible(true);
setState(MainFrame.NORMAL);
removeTrayIcon();
}//GEN-LAST:event_trayShowMenuActionPerformed
private void trayExitMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_trayExitMenuActionPerformed
dispose();
System.exit(0);
}//GEN-LAST:event_trayExitMenuActionPerformed
private void hideTrayChickBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_hideTrayChickBoxItemStateChanged
hideTray = hideTrayChickBox.isSelected();
conf.setProperty("mainframe.hidetray", hideTray);
}//GEN-LAST:event_hideTrayChickBoxItemStateChanged
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton addNick;
private javax.swing.JButton applySetting;
private javax.swing.JCheckBox autoupdateCheck;
private javax.swing.JLabel errorString;
private javax.swing.JCheckBox hideTrayChickBox;
private javax.swing.JButton jButton2;
private javax.swing.JEditorPane jEditorPane1;
private javax.swing.JEditorPane jEditorPane2;
private javax.swing.JLabel jErrorLabel;
private javax.swing.JDialog jErrorMsg;
private javax.swing.JButton jErrorOKButton;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JProgressBar jProgressBar1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JSpinner jSpinner1;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JButton jUpdateButton;
private javax.swing.JPanel monitor;
private javax.swing.JList nickList;
private javax.swing.JTextField nickTextForm;
private javax.swing.JComboBox saveList;
private javax.swing.JButton saveListLoad;
private javax.swing.JButton saveListRemove;
private javax.swing.JButton saveListSave;
private javax.swing.JPanel settingPanel;
private java.awt.MenuItem trayExitMenu;
private java.awt.PopupMenu trayMenu;
private java.awt.MenuItem trayShowMenu;
// End of variables declaration//GEN-END:variables
public PictureHandler getPicH() {
return picH;
}
public void setPicH(PictureHandler picH) {
this.picH = picH;
}
public void actionPerformed(ActionEvent e) {
setMonitorText();
errorString.setText(errorMsg);
errorString.setToolTipText(errorMsg);
timer.restart();
}
public void setError(String error) {
errorMsg = error;
}
private synchronized DefaultListModel getListModel() {
return listModel;
}
private String[] getSaveFileList() {
String[] list = null;
String fileName = conf.getString("meganetpo.savelist.path");
File path = new File(fileName);
list = path.list(new FilenameFilter() {
private Pattern pattern = Pattern.compile(".*\\.xml");
public boolean accept(File dir, String name) {
return pattern.matcher(name).matches();
}
});
if (list == null) {
list = new String[1];
list[0] = "";
}
for (int i = 0; i < list.length; i++) {
String str = list[i];
list[i] = str.replaceAll("\\.xml$", "");
}
return list;
}
private void ApplyAllConfig() {
picH.setAutoupdateVal(autoupdateVal);
picH.setAutoupdate(autoupdate);
picH.timerRestar();
hideTraySaved = hideTray;
}
private void setMonitorText() {
String slist = "";
if (picH != null) {
jProgressBar1.setValue(20 * picH.getProcess());
DefaultListModel list = picH.getFindList();
for (int i = 0; i < list.size(); i++) {
Player player = (Player) list.get(i);
slist += player.getName() + "<br>";
}
if (!monitorText.equals(slist)) {
jEditorPane1.setText(slist);
}
}
monitorText = slist;
}
private void removeTrayIcon() {
systemTray.remove(trayIcon);
}
private void addTrayIcon() {
try {
systemTray.add(trayIcon);
} catch (AWTException ex) {
logger.error(ex.getMessage());
}
}
}