/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * ServerMainForm.java * * Created on Oct 27, 2009, 11:41:37 AM */ package com.server.gui; import com.server.conn.ClientManager; import com.server.gui.mngr.NavigationManager; import com.server.conn.ConnectionManager; import com.server.filetransfer.FileSender; import com.server.utils.ImageSendingThread; import com.server.utils.SettingsConstatnts; import com.server.utils.Utility; import java.awt.BorderLayout; import java.awt.Font; import java.awt.Frame; import java.awt.GridLayout; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; import java.util.Date; import java.util.Timer; import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.ZipOutputStream; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; /** * * @author Administrator */ public class ServerMainForm extends javax.swing.JFrame { /** Creates new form ServerMainForm */ NavigationManager navigationManager = null; Utility utility = null; Timer timer = null; public ServerMainForm() { try { initComponents(); jToolBar1.setFloatable(false); utility = new Utility(); loadTreeNodes(); utility.loadSettings(); navigationManager = new NavigationManager(this); setIconImage(new ImageIcon( getClass().getResource("/com/server/icons/icon.PNG")).getImage()); timer = new Timer(); } catch (IOException ex) { Logger.getLogger(ServerMainForm.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(ServerMainForm.class.getName()).log(Level.SEVERE, null, ex); } } private void loadTreeNodes() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("RDViewer"); DefaultMutableTreeNode remoteMonitor = new DefaultMutableTreeNode("Remote Monitor"); DefaultMutableTreeNode history = new DefaultMutableTreeNode("View History"); DefaultMutableTreeNode backup = new DefaultMutableTreeNode("View Backup"); utility.addTreeNodeForHistory(history); utility.addTreeNodeForBackup(backup); root.add(remoteMonitor); root.add(history); root.add(backup); navigatorTree.setModel(new DefaultTreeModel(root)); } /** 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() { navigPopupMenu = new javax.swing.JPopupMenu(); delBackPopMenuItem = new javax.swing.JMenuItem(); clearHistoryPopMenuItem = new javax.swing.JMenuItem(); exportMenuItem = new javax.swing.JMenuItem(); exportAllPopMenuItem = new javax.swing.JMenuItem(); jSplitPane1 = new javax.swing.JSplitPane(); jScrollPane1 = new javax.swing.JScrollPane(); clientContainerPanel = new javax.swing.JPanel(); welcomLabel1 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); navigatorTree = new javax.swing.JTree(); jToolBar1 = new javax.swing.JToolBar(); startButton = new javax.swing.JButton(); jSeparator3 = new javax.swing.JToolBar.Separator(); clearHistoryButton = new javax.swing.JButton(); delBackupButton = new javax.swing.JButton(); settingsButton = new javax.swing.JButton(); jSeparator4 = new javax.swing.JToolBar.Separator(); inboxButton = new javax.swing.JButton(); chatWithClientsButton = new javax.swing.JButton(); fileSendButton = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); statusLabel = new javax.swing.JLabel(); ipAddressLabel = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); osNameLabel = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); osVersionLabel = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); userLabel = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); hostNameLabel1 = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); startMenuItem = new javax.swing.JMenuItem(); jSeparator2 = new javax.swing.JSeparator(); exportImgsMenuItem = new javax.swing.JMenuItem(); exportAllMenuItem = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JSeparator(); exitMenuItem = new javax.swing.JMenuItem(); jMenu4 = new javax.swing.JMenu(); deleteBackupMenuItem = new javax.swing.JMenuItem(); clearHistoryMenuItem = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); optionsMenuItem = new javax.swing.JMenuItem(); alertAllUsersMenuItem = new javax.swing.JMenuItem(); chatMenu = new javax.swing.JMenu(); inboxMenuItem = new javax.swing.JMenuItem(); chatMenuItem = new javax.swing.JMenuItem(); jMenu3 = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); jMenuItem2 = new javax.swing.JMenuItem(); delBackPopMenuItem.setText("Delete Backup Images"); delBackPopMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { delBackPopMenuItemActionPerformed(evt); } }); navigPopupMenu.add(delBackPopMenuItem); clearHistoryPopMenuItem.setText("Clear History"); clearHistoryPopMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { clearHistoryPopMenuItemActionPerformed(evt); } }); navigPopupMenu.add(clearHistoryPopMenuItem); exportMenuItem.setText("Export"); exportMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exportMenuItemActionPerformed(evt); } }); navigPopupMenu.add(exportMenuItem); exportAllPopMenuItem.setText("Export All"); exportAllPopMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exportAllPopMenuItemActionPerformed(evt); } }); navigPopupMenu.add(exportAllPopMenuItem); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("JEXENASERVER"); setResizable(false); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); jSplitPane1.setDividerLocation(110); clientContainerPanel.setLayout(new java.awt.GridLayout(1, 1, 3, 3)); welcomLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/server/icons/main_window.PNG"))); // NOI18N clientContainerPanel.add(welcomLabel1); jScrollPane1.setViewportView(clientContainerPanel); jSplitPane1.setRightComponent(jScrollPane1); navigatorTree.setPreferredSize(new java.awt.Dimension(100, 64)); navigatorTree.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { navigatorTreeMouseClicked(evt); } }); navigatorTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() { public void valueChanged(javax.swing.event.TreeSelectionEvent evt) { navigatorTreeValueChanged(evt); } }); jScrollPane2.setViewportView(navigatorTree); jSplitPane1.setLeftComponent(jScrollPane2); jToolBar1.setRollover(true); startButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/server/icons/start_butt.png"))); // NOI18N startButton.setToolTipText("Start Server"); startButton.setFocusable(false); startButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); startButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); startButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { startButtonActionPerformed(evt); } }); jToolBar1.add(startButton); jToolBar1.add(jSeparator3); clearHistoryButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/server/icons/delete-history.png"))); // NOI18N clearHistoryButton.setToolTipText("Clear History"); clearHistoryButton.setFocusable(false); clearHistoryButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); clearHistoryButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); clearHistoryButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { clearHistoryButtonActionPerformed(evt); } }); jToolBar1.add(clearHistoryButton); delBackupButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/server/icons/del_backup.png"))); // NOI18N delBackupButton.setToolTipText("Delete Backup"); delBackupButton.setFocusable(false); delBackupButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); delBackupButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); delBackupButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { delBackupButtonActionPerformed(evt); } }); jToolBar1.add(delBackupButton); settingsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/server/icons/Gear.png"))); // NOI18N settingsButton.setToolTipText("Settings..."); settingsButton.setFocusable(false); settingsButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); settingsButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); settingsButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { settingsButtonActionPerformed(evt); } }); jToolBar1.add(settingsButton); jToolBar1.add(jSeparator4); inboxButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/server/icons/inbox_button.png"))); // NOI18N inboxButton.setToolTipText("Inbox..."); inboxButton.setFocusable(false); inboxButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); inboxButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); inboxButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { inboxButtonActionPerformed(evt); } }); jToolBar1.add(inboxButton); chatWithClientsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/server/icons/chat_button.png"))); // NOI18N chatWithClientsButton.setToolTipText("Chat with Clients.."); chatWithClientsButton.setFocusable(false); chatWithClientsButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); chatWithClientsButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); chatWithClientsButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { chatWithClientsButtonActionPerformed(evt); } }); jToolBar1.add(chatWithClientsButton); fileSendButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/server/icons/filetransfer.png"))); // NOI18N fileSendButton.setToolTipText("Send File"); fileSendButton.setFocusable(false); fileSendButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); fileSendButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); fileSendButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { fileSendButtonActionPerformed(evt); } }); jToolBar1.add(fileSendButton); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Remote System Information")); jLabel1.setText("IP Address:"); jLabel2.setText("Connection Status:"); statusLabel.setForeground(new java.awt.Color(255, 0, 255)); statusLabel.setText("Disconnected"); ipAddressLabel.setForeground(new java.awt.Color(255, 0, 255)); ipAddressLabel.setText("Unknown"); jLabel5.setText("Operating System:"); osNameLabel.setForeground(new java.awt.Color(255, 0, 255)); osNameLabel.setText("Unknown"); jLabel7.setText("Operating System Version:"); osVersionLabel.setForeground(new java.awt.Color(255, 0, 255)); osVersionLabel.setText("Unknown"); jLabel9.setText("Current User:"); userLabel.setForeground(new java.awt.Color(255, 0, 255)); userLabel.setText("Unknown"); jLabel11.setText("Host Name:"); hostNameLabel1.setForeground(new java.awt.Color(255, 0, 255)); hostNameLabel1.setText("Unknown"); 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.TRAILING) .addComponent(jLabel2) .addComponent(jLabel1) .addComponent(jLabel11)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(statusLabel) .addComponent(ipAddressLabel) .addComponent(hostNameLabel1)) .addGap(59, 59, 59) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel7) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(38, 38, 38) .addComponent(jLabel5))) .addComponent(jLabel9)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(osNameLabel) .addComponent(osVersionLabel) .addComponent(userLabel)) .addContainerGap(372, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(ipAddressLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(statusLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel11) .addComponent(hostNameLabel1))) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(osNameLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel7) .addComponent(osVersionLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(userLabel) .addComponent(jLabel9)))) .addContainerGap(19, Short.MAX_VALUE)) ); jMenu1.setText("File"); startMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); startMenuItem.setText("Start Server"); startMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { startMenuItemActionPerformed(evt); } }); jMenu1.add(startMenuItem); jMenu1.add(jSeparator2); exportImgsMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK)); exportImgsMenuItem.setText("Export Images"); exportImgsMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exportImgsMenuItemActionPerformed(evt); } }); jMenu1.add(exportImgsMenuItem); exportAllMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK)); exportAllMenuItem.setText("Export All"); exportAllMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exportAllMenuItemActionPerformed(evt); } }); jMenu1.add(exportAllMenuItem); jMenu1.add(jSeparator1); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exitMenuItemActionPerformed(evt); } }); jMenu1.add(exitMenuItem); jMenuBar1.add(jMenu1); jMenu4.setText("Edit"); deleteBackupMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/server/icons/del_backup_m.png"))); // NOI18N deleteBackupMenuItem.setText("Clear Backup"); deleteBackupMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { deleteBackupMenuItemActionPerformed1(evt); } }); jMenu4.add(deleteBackupMenuItem); clearHistoryMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/server/icons/delhistory.png"))); // NOI18N clearHistoryMenuItem.setText("Clear History"); clearHistoryMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { clearHistoryMenuItemActionPerformed(evt); } }); jMenu4.add(clearHistoryMenuItem); jMenuBar1.add(jMenu4); jMenu2.setText("Tools"); optionsMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); optionsMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/server/icons/Gear1.png"))); // NOI18N optionsMenuItem.setText("Settings"); optionsMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { optionsMenuItemActionPerformed(evt); } }); jMenu2.add(optionsMenuItem); alertAllUsersMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK)); alertAllUsersMenuItem.setText("Alert Users"); alertAllUsersMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { alertAllUsersMenuItemActionPerformed(evt); } }); jMenu2.add(alertAllUsersMenuItem); jMenuBar1.add(jMenu2); inboxMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.CTRL_MASK)); inboxMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/server/icons/inbox_menuItem.png"))); // NOI18N inboxMenuItem.setText("Inbox..."); inboxMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { inboxMenuItemActionPerformed(evt); } }); chatMenu.add(inboxMenuItem); chatMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/server/icons/chat_menu.png"))); // NOI18N chatMenuItem.setText("Chat With Clients"); chatMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { chatMenuItemActionPerformed(evt); } }); chatMenu.add(chatMenuItem); jMenuBar1.add(chatMenu); jMenu3.setText("Help"); jMenuItem1.setText("Help Contents..."); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenu3.add(jMenuItem1); jMenuItem2.setText("About Us"); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jMenu3.add(jMenuItem2); jMenuBar1.add(jMenu3); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 813, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 793, Short.MAX_VALUE) .addContainerGap()) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jSplitPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 286, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void startMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startMenuItemActionPerformed // TODO add your handling code here: start(); }//GEN-LAST:event_startMenuItemActionPerformed private void navigatorTreeValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_navigatorTreeValueChanged // TODO add your handling code here: DefaultMutableTreeNode selectedNode = ((DefaultMutableTreeNode) navigatorTree.getLastSelectedPathComponent()); if (selectedNode != null) { String option = selectedNode.toString(); navigationManager.navigate(option, selectedNode.getLevel(), selectedNode); } java.awt.EventQueue.invokeLater(new Runnable() { public void run() { navigatorTree.updateUI(); } }); }//GEN-LAST:event_navigatorTreeValueChanged private void optionsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_optionsMenuItemActionPerformed // TODO add your handling code here: SettingsDialog settingsDialog = new SettingsDialog(this, true); settingsDialog.setLocationRelativeTo(this); settingsDialog.setVisible(true); }//GEN-LAST:event_optionsMenuItemActionPerformed private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing // TODO add your handling code here: utility.saveSettings(); }//GEN-LAST:event_formWindowClosing private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed // TODO add your handling code here: utility.saveSettings(); System.exit(0); }//GEN-LAST:event_exitMenuItemActionPerformed private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed // TODO add your handling code here: start(); }//GEN-LAST:event_startButtonActionPerformed private void inboxMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inboxMenuItemActionPerformed // TODO add your handling code here: InboxDialog inboxDialog = new InboxDialog(this, true); inboxDialog.setLocationRelativeTo(this); inboxDialog.setVisible(true); }//GEN-LAST:event_inboxMenuItemActionPerformed private void navigatorTreeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_navigatorTreeMouseClicked // TODO add your handling code here: if (evt.isMetaDown()) { navigPopupMenu.show(navigatorTree, evt.getX(), evt.getY()); } }//GEN-LAST:event_navigatorTreeMouseClicked private void exportImgsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportImgsMenuItemActionPerformed // TODO add your handling code here: exportImages(); loadTreeNodes(); }//GEN-LAST:event_exportImgsMenuItemActionPerformed private void exportAllMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportAllMenuItemActionPerformed // TODO add your handling code here: exportAllImages(); loadTreeNodes(); }//GEN-LAST:event_exportAllMenuItemActionPerformed private void clearHistoryMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearHistoryMenuItemActionPerformed clearHistory(); loadTreeNodes(); }//GEN-LAST:event_clearHistoryMenuItemActionPerformed private void clearHistoryPopMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearHistoryPopMenuItemActionPerformed clearHistory(); loadTreeNodes(); }//GEN-LAST:event_clearHistoryPopMenuItemActionPerformed private void exportMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportMenuItemActionPerformed exportImages(); loadTreeNodes(); }//GEN-LAST:event_exportMenuItemActionPerformed private void exportAllPopMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportAllPopMenuItemActionPerformed // TODO add your handling code here: exportAllImages(); loadTreeNodes(); }//GEN-LAST:event_exportAllPopMenuItemActionPerformed private void clearHistoryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearHistoryButtonActionPerformed clearHistory(); loadTreeNodes(); }//GEN-LAST:event_clearHistoryButtonActionPerformed private void deleteBackupMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteBackupMenuItemActionPerformed clearBackup(); loadTreeNodes(); }//GEN-LAST:event_deleteBackupMenuItemActionPerformed private void settingsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_settingsButtonActionPerformed SettingsDialog settingsDialog = new SettingsDialog(this, true); settingsDialog.setLocationRelativeTo(this); settingsDialog.setVisible(true); }//GEN-LAST:event_settingsButtonActionPerformed private void inboxButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inboxButtonActionPerformed InboxDialog inboxDialog = new InboxDialog(this, true); inboxDialog.setLocationRelativeTo(this); inboxDialog.setVisible(true); }//GEN-LAST:event_inboxButtonActionPerformed private void delBackPopMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delBackPopMenuItemActionPerformed clearBackup(); loadTreeNodes(); }//GEN-LAST:event_delBackPopMenuItemActionPerformed private void delBackupButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delBackupButtonActionPerformed clearBackup(); loadTreeNodes(); }//GEN-LAST:event_delBackupButtonActionPerformed private void chatWithClientsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chatWithClientsButtonActionPerformed chat(); }//GEN-LAST:event_chatWithClientsButtonActionPerformed private void chatMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chatMenuItemActionPerformed chat(); }//GEN-LAST:event_chatMenuItemActionPerformed private void fileSendButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileSendButtonActionPerformed ClientPanel clientPanel = ConnectionManager.panelManager.getSelectedClientPanel(); String sourceFileName = ""; if (clientPanel != null && clientPanel.getClientIp() != null && !clientPanel.getClientIp().equals("")) { try { String ip = clientPanel.getClientIp(); Socket socket = new Socket(ip, 8080); JFileChooser chooser = new JFileChooser(); int option = chooser.showDialog(this, "Select"); if (option == JFileChooser.APPROVE_OPTION) { if ((chooser.getSelectedFile()).exists()) { sourceFileName = chooser.getSelectedFile().getAbsolutePath(); FileSender fileSender = new FileSender(socket, sourceFileName, ip, false); new Thread(fileSender).start(); } } } catch (UnknownHostException ex) { JOptionPane.showMessageDialog(this, ex); } catch (IOException ex) { JOptionPane.showMessageDialog(this, ex); } } else { JOptionPane.showMessageDialog(this, "No Clients Selected!"); } }//GEN-LAST:event_fileSendButtonActionPerformed private void deleteBackupMenuItemActionPerformed1(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteBackupMenuItemActionPerformed1 // TODO add your handling code here: clearBackup(); loadTreeNodes(); }//GEN-LAST:event_deleteBackupMenuItemActionPerformed1 private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed // TODO add your handling code here: HelpJDialog helpJDialog = new HelpJDialog(this, true); helpJDialog.setLocationRelativeTo(this); helpJDialog.setVisible(true); }//GEN-LAST:event_jMenuItem1ActionPerformed private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed // TODO add your handling code here: AboutJDialog aboutJDialog = new AboutJDialog(this, true); aboutJDialog.setLocationRelativeTo(this); aboutJDialog.setVisible(true); }//GEN-LAST:event_jMenuItem2ActionPerformed private void alertAllUsersMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_alertAllUsersMenuItemActionPerformed // TODO add your handling code here: AlertUser alertUser = new AlertUser(this, true); alertUser.setLocationRelativeTo(this); alertUser.setVisible(true); }//GEN-LAST:event_alertAllUsersMenuItemActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ServerMainForm().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JMenuItem alertAllUsersMenuItem; private javax.swing.JMenu chatMenu; private javax.swing.JMenuItem chatMenuItem; private javax.swing.JButton chatWithClientsButton; private javax.swing.JButton clearHistoryButton; private javax.swing.JMenuItem clearHistoryMenuItem; private javax.swing.JMenuItem clearHistoryPopMenuItem; private javax.swing.JPanel clientContainerPanel; private javax.swing.JMenuItem delBackPopMenuItem; private javax.swing.JButton delBackupButton; private javax.swing.JMenuItem deleteBackupMenuItem; private javax.swing.JMenuItem exitMenuItem; private javax.swing.JMenuItem exportAllMenuItem; private javax.swing.JMenuItem exportAllPopMenuItem; private javax.swing.JMenuItem exportImgsMenuItem; private javax.swing.JMenuItem exportMenuItem; private javax.swing.JButton fileSendButton; private javax.swing.JLabel hostNameLabel1; private javax.swing.JButton inboxButton; private javax.swing.JMenuItem inboxMenuItem; private javax.swing.JLabel ipAddressLabel; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel9; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenu jMenu3; private javax.swing.JMenu jMenu4; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JSeparator jSeparator1; private javax.swing.JSeparator jSeparator2; private javax.swing.JToolBar.Separator jSeparator3; private javax.swing.JToolBar.Separator jSeparator4; private javax.swing.JSplitPane jSplitPane1; private javax.swing.JToolBar jToolBar1; private javax.swing.JPopupMenu navigPopupMenu; private javax.swing.JTree navigatorTree; private javax.swing.JMenuItem optionsMenuItem; private javax.swing.JLabel osNameLabel; private javax.swing.JLabel osVersionLabel; private javax.swing.JButton settingsButton; private javax.swing.JButton startButton; private javax.swing.JMenuItem startMenuItem; private javax.swing.JLabel statusLabel; private javax.swing.JLabel userLabel; private javax.swing.JLabel welcomLabel1; // End of variables declaration//GEN-END:variables public void addClientPanel(ClientPanel clientPanel) { clientContainerPanel.add(clientPanel); clientContainerPanel.updateUI(); } public void removeAllPanel() { clientContainerPanel.removeAll(); clientContainerPanel.updateUI(); } void addImagePanel(ImagePanel imagePanel) { clientContainerPanel.add(imagePanel); clientContainerPanel.updateUI(); } public JPanel getPanel() { return clientContainerPanel; } private void start() { clientContainerPanel.setLayout(getGridLayout(4, 0)); clientContainerPanel.removeAll(); new ConnectionManager(this).startServer(); timer.schedule(new ImageSendingThread(), 20, SettingsConstatnts.MAIL_SENGING_INTRV); startButton.setEnabled(false); startMenuItem.setEnabled(false); } public void setSelectedClientInfo(String clientIp, String hostName, String osName, String osVersion, String osArch, String currentUserNeame) { if (!clientIp.equals("")) { statusLabel.setText("Connected"); ipAddressLabel.setText(clientIp); } else { statusLabel.setText("Disconnected"); ipAddressLabel.setText("Unknown"); } hostNameLabel1.setText(hostName); osNameLabel.setText(osName); osVersionLabel.setText(osVersion); userLabel.setText(currentUserNeame); } public void setWelcomePage() { clientContainerPanel.setLayout(getGridLayout(1, 1)); clientContainerPanel.add(welcomLabel1); clientContainerPanel.updateUI(); } public void setPannelLabel() { clientContainerPanel.setLayout(new BorderLayout()); JLabel label = new JLabel("The Server is not started!!!"); label.setFont(new Font("Tahoma", Font.BOLD, 16)); label.setHorizontalAlignment(SwingConstants.CENTER); clientContainerPanel.removeAll(); clientContainerPanel.add(label, BorderLayout.CENTER); clientContainerPanel.updateUI(); } private void clearHistory() { int option = JOptionPane.showConfirmDialog(this, "Do you want to Clear History", "Clear", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (option == JOptionPane.YES_OPTION) { utility.clearHistory( new File(System.getProperty("user.dir") + File.separator + SettingsConstatnts.IMG_DIR)); JOptionPane.showMessageDialog(this, "Clear history successfully completed"); } } private void exportImages() { DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) navigatorTree.getLastSelectedPathComponent(); if (selectedNode != null && selectedNode.getLevel() >= 2) { JFileChooser selectExpDir = new JFileChooser(); selectExpDir.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (selectExpDir.showDialog(this, "Select") == JFileChooser.APPROVE_OPTION) { try { String imageDir = utility.getImageDir(selectedNode); System.out.println(imageDir); File destDir = selectExpDir.getSelectedFile(); if (!destDir.exists()) { destDir.mkdirs(); } File outFile = new File(destDir.getAbsolutePath() + File.separator + new Date().toString().replaceAll(":", "_") + ".zip"); if (!outFile.exists()) { outFile.createNewFile(); } ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(outFile)); utility.zip(true, new File(imageDir), zipOut); zipOut.close(); new File(imageDir).deleteOnExit(); JOptionPane.showMessageDialog(this, "Export image success fully compleated!", "Export image", JOptionPane.INFORMATION_MESSAGE); } catch (IOException ex) { Logger.getLogger(ServerMainForm.class.getName()).log(Level.SEVERE, null, ex); } } } else { JOptionPane.showMessageDialog(this, "Please select the image directory.", "export", JOptionPane.WARNING_MESSAGE); } } private void exportAllImages() { JFileChooser selectExpDir = new JFileChooser(); selectExpDir.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (selectExpDir.showDialog(this, "Select Directory") == JFileChooser.APPROVE_OPTION) { ZipOutputStream zipOut = null; try { String imageDir = System.getProperty("user.dir") + File.separator + SettingsConstatnts.IMG_DIR; System.out.println(imageDir); File destDir = selectExpDir.getSelectedFile(); if (!destDir.exists()) { destDir.mkdirs(); } File outFile = new File(destDir.getAbsolutePath() + File.separator + new Date().toString().replaceAll(":", "_") + ".zip"); if (!outFile.exists()) { outFile.createNewFile(); } zipOut = new ZipOutputStream(new FileOutputStream(outFile)); utility.zip(true, new File(imageDir), zipOut); zipOut.close(); } catch (FileNotFoundException ex) { Logger.getLogger(ServerMainForm.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ServerMainForm.class.getName()).log(Level.SEVERE, null, ex); } finally { try { zipOut.close(); } catch (IOException ex) { Logger.getLogger(ServerMainForm.class.getName()).log(Level.SEVERE, null, ex); } } } } public GridLayout getGridLayout(int column, int rows) { GridLayout gridLayout = new GridLayout(); gridLayout.setVgap(2); gridLayout.setHgap(2); gridLayout.setColumns(column); gridLayout.setRows(rows); return gridLayout; } public void setImageViewLayout() { clientContainerPanel.setLayout(getGridLayout(4, 0)); } private void clearBackup() { int option = JOptionPane.showConfirmDialog(this, "Do you want to Clear Backup", "Clear", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (option == JOptionPane.YES_OPTION) { utility.clearHistory( new File(System.getProperty("user.dir") + File.separator + SettingsConstatnts.BACKUP_DIR)); JOptionPane.showMessageDialog(this, "Clear Backup successfully compleated"); } } private void chat() { try { ClientPanel clientPanel = ConnectionManager.panelManager.getSelectedClientPanel(); if (clientPanel != null) { ClientManager clientManager = (ClientManager) ConnectionManager.connectedClients.get( clientPanel.getClientIp()); if (!clientPanel.isFree() && clientManager != null) { ChatWithClientJFrame chatWithClientJFrame = ConnectionManager.chatClients.get(clientPanel.getIpAddress()); if (chatWithClientJFrame == null) { chatWithClientJFrame = new ChatWithClientJFrame(clientManager); chatWithClientJFrame.setLocationRelativeTo(null); ConnectionManager.chatClients.put(clientPanel.getIpAddress(), chatWithClientJFrame); } chatWithClientJFrame.setVisible(true); chatWithClientJFrame.setTitle("Chat With - " + clientPanel.getIpAddress()); chatWithClientJFrame.setState(Frame.NORMAL); } else { JOptionPane.showMessageDialog(this, "Client not connected.", "Select Client", JOptionPane.WARNING_MESSAGE); } } else { JOptionPane.showMessageDialog(this, "Please select the client you want to chat !", "Chat", JOptionPane.WARNING_MESSAGE); } } catch (NullPointerException ex) { JOptionPane.showMessageDialog(this, "Please start the server !", "Server Off", WIDTH); } } }