Search in sources :

Example 1 with TimeRangeType

use of com.att.aro.core.packetanalysis.pojo.TimeRange.TimeRangeType in project VideoOptimzer by attdevsupport.

the class AROFileMenu method openTraceFolder.

/**
 * Choose a trace folder for direct analysis
 *
 * @param aEvent
 * @param isRecent
 * @return
 */
private void openTraceFolder(ActionEvent aEvent, boolean isRecent) {
    File traceFolder = null;
    Object event = aEvent.getSource();
    if (event instanceof JMenuItem) {
        if ((traceFolder = selectTraceFolder(aEvent, isRecent)) != null) {
            File trj;
            TimeRange timeRange = null;
            if ((trj = new File(traceFolder, "time-range.json")).exists()) {
                try {
                    String jsonData = fileManager.readAllData(trj.getPath());
                    if (!jsonData.contains("\"timeRangeType\" : \"DEFAULT\",")) {
                        JDialog splash = new TransitionDialog(parent.getFrame(), "Time-Range file detected\n", "Preparing to open in Time-Range chooser/editor dialog");
                        TimeRangeEditorDialog dialog;
                        try {
                            if ((dialog = displayTimeRangeEditor(traceFolder, true, splash)) != null && dialog.isContinueWithAnalyze()) {
                                timeRange = dialog.getTimeRange();
                            } else {
                                LOG.debug("Time-Range, Selection cancelled by user");
                                splash.dispose();
                                return;
                            }
                        } catch (Exception e) {
                            LOG.error("Exception in TimeRangeDialog:", e);
                            new MessageDialogFactory().showErrorDialog(null, "Exception in TimeRangeDialog:" + e.getMessage());
                            return;
                        }
                    } else {
                        TraceTimeRange traceTimeRange;
                        if ((traceTimeRange = timeRangeReadWrite.readData(traceFolder)) != null) {
                            if (traceTimeRange.getTimeRangeList().stream().filter(a -> a.getTimeRangeType().equals(TimeRangeType.DEFAULT)).count() > 1) {
                                LOG.error("Too many TimeRanges set to AUTO");
                                MessageDialogFactory.getInstance().showErrorDialog(parent.getFrame(), "Too many TimeRanges set to AUTO, please fix the selections");
                                return;
                            }
                            Optional<TimeRange> optionalTimeRange = traceTimeRange.getTimeRangeList().stream().filter(p -> p.getTimeRangeType().equals(TimeRange.TimeRangeType.DEFAULT)).findFirst();
                            if (optionalTimeRange.isPresent()) {
                                timeRange = optionalTimeRange.get();
                            }
                        }
                    }
                } catch (IOException e) {
                    LOG.error("Problem reading time-range.json", e);
                }
            }
            if (timeRange != null) {
                launchTraceFolderAnalysis(traceFolder, timeRange);
            } else {
                launchTraceFolderAnalysis(traceFolder);
            }
        } else {
            LOG.error("Invalid trace folder selected, no traffic file");
        }
    }
}
Also used : JDialog(javax.swing.JDialog) IFileManager(com.att.aro.core.fileio.IFileManager) TabPanels(com.att.aro.ui.view.SharedAttributesProcesses.TabPanels) ITimeRangeReadWrite(com.att.aro.core.peripheral.ITimeRangeReadWrite) TabPanelCommon(com.att.aro.ui.commonui.TabPanelCommon) IAROPrintable(com.att.aro.ui.commonui.IAROPrintable) PrinterJob(java.awt.print.PrinterJob) Logger(org.apache.log4j.Logger) AROUIIllegalStateException(com.att.aro.ui.exception.AROUIIllegalStateException) TimeRangeType(com.att.aro.core.packetanalysis.pojo.TimeRange.TimeRangeType) GoogleAnalyticsUtil(com.att.aro.core.util.GoogleAnalyticsUtil) AROMenuAdder(com.att.aro.ui.commonui.AROMenuAdder) Map(java.util.Map) MouseAdapter(java.awt.event.MouseAdapter) JFileChooser(javax.swing.JFileChooser) UserPreferences(com.att.aro.core.preferences.UserPreferences) ToolTipManager(javax.swing.ToolTipManager) TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) Set(java.util.Set) JMenu(javax.swing.JMenu) KeyEvent(java.awt.event.KeyEvent) MenuListener(javax.swing.event.MenuListener) MissingTraceFiles(com.att.aro.ui.view.menu.file.MissingTraceFiles) PreferencesDialog(com.att.aro.ui.view.menu.file.PreferencesDialog) PrinterException(java.awt.print.PrinterException) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) Optional(java.util.Optional) TimeRangeEditorDialog(com.att.aro.ui.view.menu.file.TimeRangeEditorDialog) ActionListener(java.awt.event.ActionListener) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) ModalityType(java.awt.Dialog.ModalityType) AROPrintablePanel(com.att.aro.ui.commonui.AROPrintablePanel) MessageFormat(java.text.MessageFormat) LinkedHashMap(java.util.LinkedHashMap) OpenPcapFileDialog(com.att.aro.ui.view.menu.file.OpenPcapFileDialog) ADBPathDialog(com.att.aro.ui.view.menu.file.ADBPathDialog) JMenuItem(javax.swing.JMenuItem) UserPreferencesFactory(com.att.aro.core.preferences.UserPreferencesFactory) ResourceBundleHelper(com.att.aro.ui.utils.ResourceBundleHelper) TimeRangeReadWrite(com.att.aro.core.peripheral.impl.TimeRangeReadWrite) JComponent(javax.swing.JComponent) TraceTimeRange(com.att.aro.core.peripheral.pojo.TraceTimeRange) Iterator(java.util.Iterator) Files(java.nio.file.Files) Util(com.att.aro.core.util.Util) TraceDataConst(com.att.aro.core.packetanalysis.pojo.TraceDataConst) SpringContextUtil(com.att.aro.core.SpringContextUtil) IOException(java.io.IOException) ActionEvent(java.awt.event.ActionEvent) ApplicationContext(org.springframework.context.ApplicationContext) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) SharedAttributesProcesses(com.att.aro.ui.view.SharedAttributesProcesses) Paths(java.nio.file.Paths) CrashHandler(com.att.aro.core.util.CrashHandler) MenuEvent(javax.swing.event.MenuEvent) LogManager(org.apache.log4j.LogManager) TimeRangeEditorDialog(com.att.aro.ui.view.menu.file.TimeRangeEditorDialog) IOException(java.io.IOException) AROUIIllegalStateException(com.att.aro.ui.exception.AROUIIllegalStateException) PrinterException(java.awt.print.PrinterException) IOException(java.io.IOException) TraceTimeRange(com.att.aro.core.peripheral.pojo.TraceTimeRange) TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) TraceTimeRange(com.att.aro.core.peripheral.pojo.TraceTimeRange) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) JMenuItem(javax.swing.JMenuItem) File(java.io.File) JDialog(javax.swing.JDialog)

Aggregations

SpringContextUtil (com.att.aro.core.SpringContextUtil)1 IFileManager (com.att.aro.core.fileio.IFileManager)1 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)1 TimeRangeType (com.att.aro.core.packetanalysis.pojo.TimeRange.TimeRangeType)1 TraceDataConst (com.att.aro.core.packetanalysis.pojo.TraceDataConst)1 ITimeRangeReadWrite (com.att.aro.core.peripheral.ITimeRangeReadWrite)1 TimeRangeReadWrite (com.att.aro.core.peripheral.impl.TimeRangeReadWrite)1 TraceTimeRange (com.att.aro.core.peripheral.pojo.TraceTimeRange)1 UserPreferences (com.att.aro.core.preferences.UserPreferences)1 UserPreferencesFactory (com.att.aro.core.preferences.UserPreferencesFactory)1 CrashHandler (com.att.aro.core.util.CrashHandler)1 GoogleAnalyticsUtil (com.att.aro.core.util.GoogleAnalyticsUtil)1 Util (com.att.aro.core.util.Util)1 AROMenuAdder (com.att.aro.ui.commonui.AROMenuAdder)1 AROPrintablePanel (com.att.aro.ui.commonui.AROPrintablePanel)1 IAROPrintable (com.att.aro.ui.commonui.IAROPrintable)1 MessageDialogFactory (com.att.aro.ui.commonui.MessageDialogFactory)1 TabPanelCommon (com.att.aro.ui.commonui.TabPanelCommon)1 AROUIIllegalStateException (com.att.aro.ui.exception.AROUIIllegalStateException)1 ResourceBundleHelper (com.att.aro.ui.utils.ResourceBundleHelper)1