Search in sources :

Example 1 with OpenPcapFileDialog

use of com.att.aro.ui.view.menu.file.OpenPcapFileDialog in project VideoOptimzer by attdevsupport.

the class AROFileMenu method actionPerformed.

/**
 */
@Override
public void actionPerformed(ActionEvent aEvent) {
    if (menuAdder.isMenuSelected(MenuItem.menu_file_open, aEvent)) {
        openTraceFolder(aEvent, false);
    } else if (menuAdder.isMenuSelected(MenuItem.menu_file_open_time_range, aEvent)) {
        openTraceFolderInTimeRange(aEvent);
    } else if (menuAdder.isMenuSelected(MenuItem.menu_file_pcap, aEvent)) {
        File tracePath = null;
        Object event = aEvent.getSource();
        if (event instanceof JMenuItem) {
            tracePath = chooseFileOrFolder(JFileChooser.FILES_ONLY, ResourceBundleHelper.getMessageString(MenuItem.menu_file_pcap));
            if (tracePath != null) {
                String newDirectoryName = tracePath.getName().substring(0, tracePath.getName().lastIndexOf("."));
                String parentFolderName = tracePath.getParentFile().getName();
                /*
					 * Do not open the new dialog here if,
					 * 1. Parent Folder name matches with file name and .readme file exists in the current folder OR,
					 * 2. traffic.cap was chosen and time file exists in the same directorry
					 */
                if (("traffic.cap".equals(tracePath.getName()) && Files.exists(Paths.get(tracePath.getParent() + Util.FILE_SEPARATOR + "time"))) || (newDirectoryName.equals(parentFolderName) && Files.exists(Paths.get(tracePath.getParent() + Util.FILE_SEPARATOR + ".readme")))) {
                    parent.updateTracePath(tracePath);
                    userPreferences.setLastTraceDirectory(tracePath.getParentFile().getParentFile());
                    GoogleAnalyticsUtil.getAndIncrementTraceCounter();
                } else {
                    new OpenPcapFileDialog(parent, (JMenuItem) aEvent.getSource(), tracePath).setVisible(true);
                }
            }
        }
    } else if (menuAdder.isMenuSelected(MenuItem.menu_file_pref, aEvent)) {
        new PreferencesDialog(parent, (JMenuItem) aEvent.getSource()).setVisible(true);
    } else if (menuAdder.isMenuSelected(MenuItem.menu_file_adb, aEvent)) {
        new ADBPathDialog(parent).setVisible(true);
    } else if (menuAdder.isMenuSelected(MenuItem.menu_file_print, aEvent)) {
        handlePrint();
    } else if (menuAdder.isMenuSelected(MenuItem.menu_file_exit, aEvent)) {
        parent.dispose();
        System.exit(0);
    } else if (aEvent.getSource() != null) {
        JMenuItem jmenuSource = (JMenuItem) aEvent.getSource();
        if (jmenuSource.getName() != null && jmenuSource.getName().equals(ResourceBundleHelper.getMessageString("menu.file.recent"))) {
            openTraceFolder(aEvent, true);
        }
    }
}
Also used : ADBPathDialog(com.att.aro.ui.view.menu.file.ADBPathDialog) PreferencesDialog(com.att.aro.ui.view.menu.file.PreferencesDialog) JMenuItem(javax.swing.JMenuItem) OpenPcapFileDialog(com.att.aro.ui.view.menu.file.OpenPcapFileDialog) File(java.io.File)

Aggregations

ADBPathDialog (com.att.aro.ui.view.menu.file.ADBPathDialog)1 OpenPcapFileDialog (com.att.aro.ui.view.menu.file.OpenPcapFileDialog)1 PreferencesDialog (com.att.aro.ui.view.menu.file.PreferencesDialog)1 File (java.io.File)1 JMenuItem (javax.swing.JMenuItem)1