Search in sources :

Example 21 with MainFrame

use of com.att.aro.ui.view.MainFrame in project VideoOptimzer by attdevsupport.

the class AROToolMenu method openPcapAnalysis.

private void openPcapAnalysis() {
    // Open PCAP analysis tool
    AROTraceData traceData = ((MainFrame) parent).getController().getTheModel();
    IFileManager fileManager = ContextAware.getAROConfigContext().getBean(IFileManager.class);
    File dir = fileManager.createFile(traceData.getAnalyzerResult().getTraceresult().getTraceDirectory());
    File[] trafficFiles;
    if (fileManager.isFile(dir.getAbsolutePath())) {
        trafficFiles = new File[] { new File(dir.getAbsolutePath()) };
    } else {
        trafficFiles = getTrafficTextFiles(dir);
    }
    if (trafficFiles != null && trafficFiles.length > 0) {
        try {
            for (File trafficFile : trafficFiles) {
                if (trafficFile.getName().equals(TraceDataConst.FileName.PCAP_FILE)) {
                    Desktop.getDesktop().open(trafficFile);
                    break;
                }
            }
        } catch (NullPointerException e) {
            MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.tools.error.noPcap"));
        } catch (IllegalArgumentException e) {
            MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.tools.error.noPcap"));
        } catch (IOException e) {
            MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.tools.error.noPcapApp"));
        }
    }
}
Also used : IOException(java.io.IOException) AROTraceData(com.att.aro.core.pojo.AROTraceData) File(java.io.File) MainFrame(com.att.aro.ui.view.MainFrame) IFileManager(com.att.aro.core.fileio.IFileManager)

Example 22 with MainFrame

use of com.att.aro.ui.view.MainFrame in project VideoOptimzer by attdevsupport.

the class OpenPcapFileDialog method processPcapFile.

private Void processPcapFile(boolean retainDirectory) {
    StringBuilder commands = new StringBuilder();
    if (Util.isWindowsOS()) {
        commands.append("mkdir \"" + newPcapFileTracePath + "\" && ");
        // Create an empty .readme file to identify if its a folder created by VO
        commands.append("type nul > \"" + newPcapFileTracePath + Util.FILE_SEPARATOR + ".readme\" && ");
        commands.append("attrib +h \"" + newPcapFileTracePath + Util.FILE_SEPARATOR + ".readme\" && ");
        if (retainDirectory) {
            commands.append("move \"" + originalPcapFileObj.getAbsolutePath() + "\" \"" + newPcapFileTracePath + "\"");
        } else {
            commands.append("copy \"" + originalPcapFileObj.getAbsolutePath() + "\" \"" + newPcapFileTracePath + "\"");
        }
    } else {
        commands.append("mkdir '" + newPcapFileTracePath + "' ; ");
        // Create an empty .readme file to identify if its a folder created by VO
        commands.append("touch '" + newPcapFileTracePath + Util.FILE_SEPARATOR + ".readme' ; ");
        if (retainDirectory) {
            commands.append("mv '" + originalPcapFileObj.getAbsolutePath() + "' '" + newPcapFileTracePath + "'");
        } else {
            commands.append("ln -s '" + originalPcapFileObj.getAbsolutePath() + "' '" + newPcapFileTracePath + Util.FILE_SEPARATOR + originalPcapFileObj.getName() + "'");
        }
    }
    LOG.debug("Command to execute: " + commands.toString());
    String result = extRunner.executeCmd(commands.toString());
    LOG.debug("Command execution result: " + result);
    reloadTrace();
    if (retainDirectory) {
        UserPreferencesFactory.getInstance().create().setLastTraceDirectory(new File(newPcapFileTracePath));
    }
    GoogleAnalyticsUtil.getAndIncrementTraceCounter();
    // Delete the new directory after analysis is completed, if don't need to retain
    if (!retainDirectory) {
        if (parent instanceof MainFrame) {
            while (!((MainFrame) parent).getAroSwingWorker().isDone()) {
                LOG.debug("Waiting for analysis to be completed");
                Util.sleep(1000);
            }
            PacketAnalyzerResult analyzerResult = ((MainFrame) parent).getController().getCurrentTraceInitialAnalyzerResult();
            if (analyzerResult != null && analyzerResult.getStreamingVideoData() != null && !analyzerResult.getStreamingVideoData().isFinished()) {
                StreamingVideoData streamingVideoData = analyzerResult.getStreamingVideoData();
                // Wait for FFMpegRunner to complete
                if (!streamingVideoData.getVideoStreamMap().isEmpty()) {
                    Runnable waitingForUpdate = () -> {
                        int count = 1;
                        while (!streamingVideoData.isFinished()) {
                            LOG.info(String.format("(%d) Waiting for FFmpegRunner to complete", count++));
                            Util.sleep(1000);
                        }
                        Util.sleep(1000);
                        deleteDirectory(newPcapFileTracePath);
                    };
                    new Thread(waitingForUpdate, "FFMpegRunnerWaitingThread").start();
                } else {
                    deleteDirectory(newPcapFileTracePath);
                }
            } else {
                deleteDirectory(newPcapFileTracePath);
            }
        } else {
            deleteDirectory(newPcapFileTracePath);
        }
        PreferenceHandlerImpl.getInstance().setPref("TRACE_PATH", originalPcapFileObj.toString());
    }
    return null;
}
Also used : StreamingVideoData(com.att.aro.core.videoanalysis.pojo.StreamingVideoData) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) File(java.io.File) MainFrame(com.att.aro.ui.view.MainFrame)

Example 23 with MainFrame

use of com.att.aro.ui.view.MainFrame in project VideoOptimzer by attdevsupport.

the class ExportReport method saveFile.

/**
 * Method to export the table content in to the JSON or HTML file format.
 *
 * @param chooser
 *            {@link JFileChooser} object to validate the save option.
 */
private void saveFile(JFileChooser chooser) throws Exception {
    if (chooser.showSaveDialog(((MainFrame) parent).getJFrame()) == JFileChooser.APPROVE_OPTION) {
        exportPath = chooser.getSelectedFile();
        if (!chooser.getFileFilter().accept(exportPath)) {
            if (json) {
                exportPath = new File(exportPath.getAbsolutePath() + "." + ResourceBundleHelper.getMessageString("fileChooser.contentType.json"));
            } else {
                exportPath = new File(exportPath.getAbsolutePath() + "." + ResourceBundleHelper.getMessageString("fileChooser.contentType.html"));
            }
        }
        if (exportPath.exists()) {
            // file already exists
            int res = MessageDialogFactory.showConfirmDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.tools.export.warning"));
            if (res != JOptionPane.YES_OPTION) {
                return;
            } else if (res == JOptionPane.YES_OPTION) {
                printReport();
            }
        } else {
            printReport();
        }
        if (exportPath.getName().contains(".html") || exportPath.getName().contains(".json")) {
            MessageDialogFactory dialogFactory = new MessageDialogFactory();
            int res = dialogFactory.showExportConfirmDialog(((MainFrame) parent).getJFrame());
            if (res == JOptionPane.YES_OPTION) {
                try {
                    Desktop desktop = Desktop.getDesktop();
                    if (desktop != null) {
                        desktop.open(exportPath);
                    } else {
                        showFailedToOpen();
                    }
                } catch (Exception unsupportedException) {
                    showFailedToOpen();
                }
            }
        }
    }
}
Also used : Desktop(java.awt.Desktop) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) File(java.io.File) MainFrame(com.att.aro.ui.view.MainFrame)

Example 24 with MainFrame

use of com.att.aro.ui.view.MainFrame in project VideoOptimzer by attdevsupport.

the class AROViewMenu method openTimeRangeAnalysis.

private void openTimeRangeAnalysis() {
    MainFrame mainFrame = ((MainFrame) parent);
    if (mainFrame.getController().getTheModel() != null && mainFrame.getController().getTheModel().getAnalyzerResult() != null) {
        TimeRangeAnalysisDialog timeRangeDialog = new TimeRangeAnalysisDialog(mainFrame.getJFrame(), parent);
        timeRangeDialog.setVisible(true);
    } else {
        MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.error.noTraceLoadedMessage"), ResourceBundleHelper.getMessageString("menu.error.title"), JOptionPane.ERROR_MESSAGE);
    }
}
Also used : TimeRangeAnalysisDialog(com.att.aro.ui.view.menu.tools.TimeRangeAnalysisDialog) MainFrame(com.att.aro.ui.view.MainFrame)

Aggregations

MainFrame (com.att.aro.ui.view.MainFrame)24 File (java.io.File)7 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)5 AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)4 IOException (java.io.IOException)4 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 IFileManager (com.att.aro.core.fileio.IFileManager)2 FileManagerImpl (com.att.aro.core.fileio.impl.FileManagerImpl)2 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)2 StreamingVideoData (com.att.aro.core.videoanalysis.pojo.StreamingVideoData)2 EnableEscKeyCloseDialog (com.att.aro.ui.commonui.EnableEscKeyCloseDialog)2 MessageDialogFactory (com.att.aro.ui.commonui.MessageDialogFactory)2 TimeRangeAnalysisDialog (com.att.aro.ui.view.menu.tools.TimeRangeAnalysisDialog)2 JButton (javax.swing.JButton)2 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)2 IDevice (com.android.ddmlib.IDevice)1 IExternalProcessRunner (com.att.aro.core.commandline.IExternalProcessRunner)1 ExternalProcessRunnerImpl (com.att.aro.core.commandline.impl.ExternalProcessRunnerImpl)1 ProfileType (com.att.aro.core.configuration.pojo.ProfileType)1