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"));
}
}
}
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;
}
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();
}
}
}
}
}
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);
}
}
Aggregations