/*
* AppForm.java
*
* Dependant on:
* - net.sf.jsearchtool.core.index.FileIndexer to perform index documents creation.
* - net.sf.jsearchtool.core.search.VectorSpaceHandler to perform searching based on Vector Space Model.
* - net.sf.jsearchtool.core.search.LocateHandler to perform search process using Locate indexing service.
* - net.sf.jsearchtool.core.search.Spotlight to perform search process using Spotlight service.
* - net.sf.jsearchtool.core.search.GoogleHandler to search document using Google Base feeds services.
* - net.sf.jsearchtool.util.SystemUtilities to determine OS dependant features and configurations.
* - net.sf.jsearchtool.UIComponents package to handle all UI components interaction with user.
* - net.sf.jsearchtool.io package to perform spesific I/O operation for JSearchTool to behave with suitable manner.
* - net.sf.jsearchtool.bookmark package for basic bookmark add and reading require for updating UI components.
*
* Using by net.sf.jsearchtool.launcher package to show main window.
*/
package net.sf.jsearchtool.UIComponents;
import java.awt.Event;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.prefs.Preferences;
import javax.swing.JTable;
import javax.swing.KeyStroke;
import javax.swing.ImageIcon;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import net.sf.jsearchtool.UIComponents.TableFactory.DTableModel;
import net.sf.jsearchtool.io.*;
import net.sf.jsearchtool.xml.*;
import net.sf.jsearchtool.util.SystemUtilities;
import net.sf.jsearchtool.core.search.LocateHandler;
import net.sf.jsearchtool.core.search.SpotlightHandler;
import net.sf.jsearchtool.core.search.VectorSpaceHandler;
import net.sf.jsearchtool.core.search.GoogleBaseClient;
import net.sf.jsearchtool.core.search.YouTubeClient;
/**
* Main view class handle <CODE>JSearchTool</CODE> main window and handle all user interaction.
*
* @see <a href="BookmarkManager.html"><CODE>BookmarkManager</CODE></a>
* @see <a href="TableFactory.html"><CODE>TableFactory</CODE></a>
* @see <a href="../core/search/VectorSpaceHandler.html"><CODE>VectorSpaceHandler</CODE></a>
* @see <a href="../core/search/SpotlightHandler.html"><CODE>SpotlightHandler</CODE></a>
* @see <a href="../core/search/LocateHandler.html"><CODE>LocateHandler</CODE></a>
* @see <a href="../core/search/GoogleHandler.html"><CODE>GoogleHandler</CODE></a>
* @see <a href="../core/index/FileIndexer.html"><CODE>FileIndexer</CODE></a>
* @see <a href="../bookmark/XMLReader.html"><CODE>XMLReader</CODE></a>
* @see <a href="../bookmark/XMLWriter.html"><CODE>XMLWriter</CODE></a>
* @see <a href="../util/SystemUtilities.html"><CODE>SystemUtilities</CODE></a>
* @see <a href="../io/package-summary.html"><CODE>net.sf.jsearchtool.io</CODE></a>
*
* @version 2.4.5
* @author Mario Yohanes, 2008<BR/>
* <small><b>Contacts Information :</b><ul>
* <li><a href='mailto:mario.yohanes@gmail.com'>Send Email</a></li>
* <li><a href='http://sourceforge.net/projects/jsearchtool/'>JSearchTool Project Site</a></li>
* </ul></small>
*/
public class AppForm extends javax.swing.JFrame {
/** Version unique id, ensuring proper serialize or deserialize process. */
private static final long serialVersionUID = -7564646507696514980L;
private final javax.swing.JRootPane root = getRootPane();
private final ImageIcon MUSIC = new ImageIcon(getClass().getResource("/net/sf/jsearchtool/UIComponents/resources/music.png"));
private final ImageIcon FOLDER = new ImageIcon(getClass().getResource("/net/sf/jsearchtool/UIComponents/resources/folder.png"));
private final ImageIcon MOVIE = new ImageIcon(getClass().getResource("/net/sf/jsearchtool/UIComponents/resources/movie.png"));
private final ImageIcon TEXT = new ImageIcon(getClass().getResource("/net/sf/jsearchtool/UIComponents/resources/text.png"));
private final ImageIcon OFFICE = new ImageIcon(getClass().getResource("/net/sf/jsearchtool/UIComponents/resources/office.png"));
private final ImageIcon PDF = new ImageIcon(getClass().getResource("/net/sf/jsearchtool/UIComponents/resources/pdf.png"));
private final ImageIcon GENERIC = new ImageIcon(getClass().getResource("/net/sf/jsearchtool/UIComponents/resources/generic.png"));
private final String mail = "mario.yohanes@gmail.com?subject=JSearchTool Feedback";
private final String site = "http://sourceforge.net/projects/jsearchtool";
private PreferencesDialog prefDialog;
private Preferences prefs = Preferences.userNodeForPackage(PreferencesDialog.class);
private JTable tableResult;
private Thread threadPreview;
private ID3TagDescriptor desc;
private ImagesDescriptor idesc;
private boolean preview = false;
private final AppForm app = this;
private final File bookmark = new File(SystemUtilities.getPreferencesPath()+"bookmark.xml");
private String[] titles = {"#", "Name", "Kind", "When", "Where"};
/** Creates new form AppForm */
public AppForm() {
initComponents();
updateBookmark();
pack();
}
/**
* Netbeans GUI Builder IDE generated code.
* Do Not Modify Directly Without NetBeans GUI Builder IDE!
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
groupOptions = new javax.swing.ButtonGroup();
popup = new javax.swing.JPopupMenu();
itemPopupOpen = new javax.swing.JMenuItem();
itemPopupFolder = new javax.swing.JMenuItem();
itemPopupPreview = new javax.swing.JMenuItem();
separatorPopup = new javax.swing.JSeparator();
itemPopupPreferences = new javax.swing.JMenuItem();
panelTop = new javax.swing.JPanel();
progressSearching = new javax.swing.JProgressBar();
progressSearching.setVisible(false);
if(SystemUtilities.isMac()){
progressSearching.putClientProperty("JProgressBar.style", "circular");
}//end if
textSearch = new javax.swing.JTextField();
labelIcon = new javax.swing.JLabel();
labelNumResults = new javax.swing.JLabel();
labelNumResults.setVisible(false);
labelWarning = new javax.swing.JLabel();
labelWarning.setVisible(false);
panelMid = new javax.swing.JPanel();
panelInfo = new javax.swing.JPanel();
labelFileIcon = new javax.swing.JLabel();
labelTitle1 = new javax.swing.JLabel();
labelTitle2 = new javax.swing.JLabel();
labelTitle3 = new javax.swing.JLabel();
labelTitle4 = new javax.swing.JLabel();
labelTitle5 = new javax.swing.JLabel();
labelTitle6 = new javax.swing.JLabel();
menubar = new javax.swing.JMenuBar();
menuFile = new javax.swing.JMenu();
itemNew = new javax.swing.JMenuItem();
separatorFile = new javax.swing.JSeparator();
itemOpen = new javax.swing.JMenuItem();
itemOpenFolder = new javax.swing.JMenuItem();
itemPreview = new javax.swing.JMenuItem();
itemClose = new javax.swing.JMenuItem();
menuView = new javax.swing.JMenu();
itemViewLogs = new javax.swing.JMenuItem();
separatorView = new javax.swing.JSeparator();
menuBookmark = new javax.swing.JMenu();
itemAdd = new javax.swing.JMenuItem();
itemOrganize = new javax.swing.JMenuItem();
itemOrganize.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
new BookmarkDialog(app).setV