Search in sources :

Example 1 with MessageDialogFactory

use of com.att.aro.ui.commonui.MessageDialogFactory in project VideoOptimzer by attdevsupport.

the class RequestResponseDetailsPanel method getJRequestResponseTable.

/**
 * Initializes and returns the the DataTable that contains Http request and
 * response informations.
 */
public DataTable<HttpRequestResponseInfo> getJRequestResponseTable() {
    if (jRequestResponseTable == null) {
        jRequestResponseTable = new DataTable<HttpRequestResponseInfo>(jRequestResponseTableModel);
        jRequestResponseTable.setName(ResourceBundleHelper.getMessageString("diagnostics.request.response.view.tableName"));
        jRequestResponseTable.setAutoCreateRowSorter(true);
        jRequestResponseTable.setGridColor(Color.LIGHT_GRAY);
        DataTablePopupMenu popupMenu = (DataTablePopupMenu) jRequestResponseTable.getPopup();
        popupMenu.initialize();
        jRequestResponseTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent event) {
                // Enable view and save as buttons appropriately
                HttpRequestResponseInfo httpRRInfo = jRequestResponseTable.getSelectedItem();
                boolean validResponse = httpRRInfo != null && httpRRInfo.getContentLength() > 0 && httpRRInfo.getDirection() == HttpDirection.RESPONSE && httpRRInfo.getStatusCode() != 0;
                boolean isVideo = (validResponse) ? ((httpRRInfo != null && httpRRInfo.getContentType() != null) ? httpRRInfo.getContentType().contains("video/") : false) : false;
                boolean isApplicationZip = httpRRInfo != null && httpRRInfo.getContentType() != null && httpRRInfo.getContentType().contains("application/zip");
                boolean isContentTypeAvailable = httpRRInfo != null && httpRRInfo.getContentType() != null;
                getViewBtn().setEnabled(!isApplicationZip && !isVideo && validResponse && isContentTypeAvailable);
                getSaveBtn().setEnabled(!isApplicationZip && validResponse && isContentTypeAvailable);
            }
        });
        jRequestResponseTable.addMouseListener(new MouseAdapter() {

            public void mouseClicked(MouseEvent event) {
                if (event.getClickCount() == 2 && getViewBtn().isEnabled()) {
                    try {
                        viewContent(jRequestResponseTable.getSelectedItem());
                    } catch (Exception e) {
                        LOG.error("Failed to open the content in the view window with unexpected error", e);
                        new MessageDialogFactory().showPlainDialog(RequestResponseDetailsPanel.this.getTopLevelAncestor(), ResourceBundleHelper.getMessageString("view.requestresponsedetails.error.Message"), ResourceBundleHelper.getMessageString("view.requestresponsedetails.error.Title"));
                    }
                }
            }
        });
    }
    return jRequestResponseTable;
}
Also used : MouseEvent(java.awt.event.MouseEvent) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) DataTablePopupMenu(com.att.aro.ui.model.DataTablePopupMenu) ListSelectionEvent(javax.swing.event.ListSelectionEvent) MouseAdapter(java.awt.event.MouseAdapter) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) IOException(java.io.IOException) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 2 with MessageDialogFactory

use of com.att.aro.ui.commonui.MessageDialogFactory in project VideoOptimzer by attdevsupport.

the class RequestResponseDetailsPanel method getViewBtn.

/**
 * Initializes and returns the "View" button for the Request-Response Table.
 */
private JButton getViewBtn() {
    if (viewBtn == null) {
        viewBtn = new JButton(ResourceBundleHelper.getMessageString("button.View"));
        viewBtn.setEnabled(false);
        viewBtn.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                try {
                    viewContent(jRequestResponseTable.getSelectedItem());
                } catch (Exception e) {
                    LOG.error("Failed to open the content in the view window with unexpected error", e);
                    new MessageDialogFactory().showPlainDialog(RequestResponseDetailsPanel.this.getTopLevelAncestor(), ResourceBundleHelper.getMessageString("view.requestresponsedetails.error.Message"), ResourceBundleHelper.getMessageString("view.requestresponsedetails.error.Title"));
                }
            }
        });
    }
    return viewBtn;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) IOException(java.io.IOException)

Example 3 with MessageDialogFactory

use of com.att.aro.ui.commonui.MessageDialogFactory in project VideoOptimzer by attdevsupport.

the class ARODataCollectorMenu method chooseDevice.

private IAroDevice chooseDevice(IAroDevices aroDevices, List<IDataCollector> collectors) {
    ArrayList<IAroDevice> deviceList = aroDevices.getDeviceList();
    IAroDevice device = null;
    int delayTimeDL = 0;
    int throttleDL = 0;
    int throttleUL = 0;
    boolean throttleDLEnable = false;
    boolean throttleULEnable = false;
    boolean profileBoolean = false;
    String traceFolderName = "";
    String profileLocation = "";
    if (((MainFrame) parent).getPreviousOptions() != null) {
        previousOptions = ((MainFrame) parent).getPreviousOptions();
    }
    metaDataModel = new MetaDataModel();
    DataCollectorSelectNStartDialog dialog = new DataCollectorSelectNStartDialog(((MainFrame) parent).getJFrame(), parent, deviceList, traceFolderName, collectors, true, previousOptions, metaDataModel);
    if (dialog.getResponse()) {
        device = dialog.getDevice();
        traceFolderName = dialog.getTraceFolder();
        device.setCollector(dialog.getCollectorOption());
        /*debug purpose*/
        delayTimeDL = dialog.getDeviceOptionPanel().getAttenuatorModel().getDelayDS();
        dialog.getDeviceOptionPanel().getAttenuatorModel().getDelayUS();
        throttleDL = dialog.getDeviceOptionPanel().getAttenuatorModel().getThrottleDL();
        throttleUL = dialog.getDeviceOptionPanel().getAttenuatorModel().getThrottleUL();
        throttleDLEnable = dialog.getDeviceOptionPanel().getAttenuatorModel().isThrottleDLEnabled();
        throttleULEnable = dialog.getDeviceOptionPanel().getAttenuatorModel().isThrottleULEnabled();
        profileLocation = dialog.getDeviceOptionPanel().getAttenuatorModel().getLocalPath();
        profileBoolean = dialog.getDeviceOptionPanel().getAttenuatorModel().isLoadProfile();
        LOG.info("set U delay: " + delayTimeDL + ", set D delay: " + delayTimeDL + ", set U throttle: " + throttleUL + ", set D throttle: " + throttleDL + ", set profile: " + profileBoolean + ", set profileLocation: " + profileLocation);
        if (device.isPlatform(IAroDevice.Platform.iOS)) {
            IDataCollector iosCollector = findIOSCollector(collectors);
            if ((throttleDLEnable || throttleULEnable) && !NetworkUtil.isNetworkUp(SharedNetIF)) {
                MessageDialogFactory.getInstance().showInformationDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.attenuation.finalwarning"), ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.attenuation.noshared"));
                return null;
            }
            if (!checkSetSuPassword(iosCollector)) {
                return null;
            } else {
                LOG.info("pw validated");
            }
        }
        String traceFolderPath = (device.getPlatform().equals(IAroDevice.Platform.Android)) ? Util.getAROTraceDirAndroid() + System.getProperty("file.separator") + traceFolderName : Util.getAROTraceDirIOS() + System.getProperty("file.separator") + traceFolderName;
        String currentPath = ((MainFrame) parent).getTracePath();
        if (fileManager.directoryExistAndNotEmpty(traceFolderPath)) {
            int result = folderExistsDialog();
            if (result == JOptionPane.OK_OPTION) {
                if (traceFolderPath.equals(currentPath)) {
                    new MessageDialogFactory().showErrorDialog(null, ResourceBundleHelper.getMessageString("viewer.contentUnwritable"));
                    return null;
                }
                File mountPoint = fileManager.createFile(traceFolderPath, IOSCollectorImpl.IOSAPP_MOUNT);
                if (fileManager.createFile(traceFolderPath, IOSCollectorImpl.IOSAPP_MOUNT).exists() && device.getPlatform().equals(IAroDevice.Platform.iOS)) {
                    IExternalProcessRunner runner = new ExternalProcessRunnerImpl();
                    String results = runner.executeCmd(String.format("umount %s;rmdir %s", mountPoint, mountPoint));
                    if (!results.isEmpty()) {
                        new MessageDialogFactory().showErrorDialog(null, traceFolderPath + "/" + IOSCollectorImpl.IOSAPP_MOUNT + " is BUSY");
                        return null;
                    } else {
                        int count = 0;
                        while (fileManager.directoryExistAndNotEmpty(mountPoint.toString())) {
                            if (++count > 5) {
                                new MessageDialogFactory().showErrorDialog(null, traceFolderPath + "/" + IOSCollectorImpl.IOSAPP_MOUNT + " will not release, please detach the iOS device and delete the foldere manually");
                                return null;
                            }
                            try {
                                Thread.sleep(1000);
                            } catch (InterruptedException e) {
                                Log.error("sleep interrupted");
                            }
                        }
                    }
                }
                fileManager.deleteFolderContents(traceFolderPath);
            } else {
                return null;
            }
        }
        Hashtable<String, Object> extras = prepareStartCollectorExtras(device, traceFolderName, dialog);
        updateMetaData(device, traceFolderName, dialog);
        extras.put("DIALOG_SIZE", dialog.getBaseSize());
        if (dialog.getDeviceOptionPanel().getLabeledExpandedOptionFields().isVisible()) {
            extras.put("MetaDataExpanded", true);
        }
        ((MainFrame) parent).startCollector(device, traceFolderName, extras, metaDataModel);
    } else {
        traceFolderName = null;
    }
    dialog.dispose();
    return device;
}
Also used : MetaDataModel(com.att.aro.core.tracemetadata.pojo.MetaDataModel) MainFrame(com.att.aro.ui.view.MainFrame) IExternalProcessRunner(com.att.aro.core.commandline.IExternalProcessRunner) IAroDevice(com.att.aro.core.mobiledevice.pojo.IAroDevice) DataCollectorSelectNStartDialog(com.att.aro.ui.commonui.DataCollectorSelectNStartDialog) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) IDataCollector(com.att.aro.core.datacollector.IDataCollector) File(java.io.File) ExternalProcessRunnerImpl(com.att.aro.core.commandline.impl.ExternalProcessRunnerImpl)

Example 4 with MessageDialogFactory

use of com.att.aro.ui.commonui.MessageDialogFactory in project VideoOptimzer by attdevsupport.

the class AROFileMenu method handlePrint.

private void handlePrint() {
    final JComponent currentTabComponent = (JComponent) parent.getCurrentTabComponent();
    if (currentTabComponent instanceof IAROPrintable) {
        final IAROPrintable aroPrintable = (IAROPrintable) currentTabComponent;
        final PrinterJob printJob = PrinterJob.getPrinterJob();
        if (printJob.printDialog()) {
            new Thread(new Runnable() {

                @Override
                public void run() {
                    Thread.setDefaultUncaughtExceptionHandler(new CrashHandler());
                    printJob.setPrintable(new AROPrintablePanel(aroPrintable.getPrintablePanel()));
                    try {
                        printJob.print();
                    } catch (PrinterException e) {
                        String[] messageWrapper = new String[1];
                        messageWrapper[0] = e.getLocalizedMessage();
                        new MessageDialogFactory().showErrorDialog(null, tabPanelCommon.getText(MenuItem.error_printer, messageWrapper));
                    }
                }
            }).start();
        }
    } else {
        throw new AROUIIllegalStateException(tabPanelCommon.getText(MenuItem.error_printer_notprintable));
    }
}
Also used : AROUIIllegalStateException(com.att.aro.ui.exception.AROUIIllegalStateException) CrashHandler(com.att.aro.core.util.CrashHandler) JComponent(javax.swing.JComponent) AROPrintablePanel(com.att.aro.ui.commonui.AROPrintablePanel) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) PrinterException(java.awt.print.PrinterException) IAROPrintable(com.att.aro.ui.commonui.IAROPrintable) PrinterJob(java.awt.print.PrinterJob)

Example 5 with MessageDialogFactory

use of com.att.aro.ui.commonui.MessageDialogFactory in project VideoOptimzer by attdevsupport.

the class AROFileMenu method openTraceFolderInTimeRange.

/**
 * Choose a trace folder and transfer to time-range dialog
 *
 * @param aEvent
 * @param isRecent
 */
private void openTraceFolderInTimeRange(ActionEvent aEvent) {
    File traceFolder = null;
    Object event = aEvent.getSource();
    if (event instanceof JMenuItem) {
        traceFolder = selectTraceFolder(aEvent, false);
        if (traceFolder != null) {
            try {
                JDialog splash = new TransitionDialog(parent.getFrame(), "Preparing to open Time-Range chooser/editor dialog");
                TimeRangeEditorDialog dialog;
                dialog = displayTimeRangeEditor(traceFolder, false, splash);
                if (dialog != null && dialog.isContinueWithAnalyze()) {
                    launchTraceFolderAnalysis(traceFolder, dialog.getTimeRange());
                }
            } catch (Exception e) {
                LOG.error("Exception in TimeRangeDialog:", e);
                new MessageDialogFactory().showErrorDialog(null, "Exception in TimeRangeDialog:" + e.getMessage());
            }
        } else {
            LOG.error("failed to identify action event:" + aEvent.getClass().getName());
        }
    }
}
Also used : TimeRangeEditorDialog(com.att.aro.ui.view.menu.file.TimeRangeEditorDialog) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) JMenuItem(javax.swing.JMenuItem) File(java.io.File) JDialog(javax.swing.JDialog) AROUIIllegalStateException(com.att.aro.ui.exception.AROUIIllegalStateException) PrinterException(java.awt.print.PrinterException) IOException(java.io.IOException)

Aggregations

MessageDialogFactory (com.att.aro.ui.commonui.MessageDialogFactory)18 IOException (java.io.IOException)10 File (java.io.File)9 Profile (com.att.aro.core.configuration.pojo.Profile)3 CrashHandler (com.att.aro.core.util.CrashHandler)3 AROUIIllegalStateException (com.att.aro.ui.exception.AROUIIllegalStateException)3 JFileChooser (javax.swing.JFileChooser)3 AROPrintablePanel (com.att.aro.ui.commonui.AROPrintablePanel)2 IAROPrintable (com.att.aro.ui.commonui.IAROPrintable)2 DataTablePopupMenu (com.att.aro.ui.model.DataTablePopupMenu)2 MainFrame (com.att.aro.ui.view.MainFrame)2 TimeRangeEditorDialog (com.att.aro.ui.view.menu.file.TimeRangeEditorDialog)2 PrinterException (java.awt.print.PrinterException)2 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)2 TableCellEditor (javax.swing.table.TableCellEditor)2 SpringContextUtil (com.att.aro.core.SpringContextUtil)1 IExternalProcessRunner (com.att.aro.core.commandline.IExternalProcessRunner)1 ExternalProcessRunnerImpl (com.att.aro.core.commandline.impl.ExternalProcessRunnerImpl)1 IDataCollector (com.att.aro.core.datacollector.IDataCollector)1 IFileManager (com.att.aro.core.fileio.IFileManager)1