Search in sources :

Example 16 with MessageDialogFactory

use of com.att.aro.ui.commonui.MessageDialogFactory 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 17 with MessageDialogFactory

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

the class DependenciesDialog method readContent.

private String readContent(String textFile) {
    StringBuffer txtBuf = null;
    htmlContent = false;
    InputStream inputStream = getClass().getClassLoader().getResourceAsStream(textFile);
    if (inputStream != null) {
        Reader reader = new BufferedReader(new InputStreamReader(inputStream));
        txtBuf = new StringBuffer();
        try {
            char[] buf = new char[2048];
            int count;
            while ((count = reader.read(buf, 0, buf.length)) >= 0) {
                txtBuf.append(buf, 0, count);
            }
            if (txtBuf.toString().trim().toLowerCase().startsWith("<html>")) {
                htmlContent = true;
            }
        } catch (IOException e) {
            new MessageDialogFactory().showUnexpectedExceptionDialog(this, e);
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
            }
        }
    }
    return txtBuf != null ? txtBuf.toString() : null;
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) IOException(java.io.IOException)

Example 18 with MessageDialogFactory

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

the class SelectProfileDialog method getProfilesTable.

/**
 * Initializes and returns the JTable that displays the the list of
 * predefined profiles with their types on the SElect Profile dialog.
 */
private DataTable<Profile> getProfilesTable() {
    if (jProfilesTable == null) {
        MessageDialogFactory dialog = new MessageDialogFactory();
        try {
            jProfilesTable = new DataTable<Profile>(new ProfileListTableModel(ProfileManager.getInstance().getPredefinedProfilesList()));
            jProfilesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            jProfilesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

                @Override
                public void valueChanged(ListSelectionEvent e) {
                    if (jProfilesTable.getSelectedRowCount() != -1) {
                        getOpenButton().setEnabled(true);
                    }
                    getFilenameTextField().setText(null);
                }
            });
            DataTablePopupMenu popupMenu = (DataTablePopupMenu) jProfilesTable.getPopup();
            popupMenu.initialize();
        } catch (IOException e) {
            dialog.showErrorDialog(SelectProfileDialog.this, MessageFormat.format(ResourceBundleHelper.getMessageString("profile.profileListError"), e.getMessage()));
        } catch (ProfileException e) {
            dialog.showErrorDialog(SelectProfileDialog.this, MessageFormat.format(ResourceBundleHelper.getMessageString("profile.profileListError"), e.getMessage()));
        }
    }
    return jProfilesTable;
}
Also used : ListSelectionEvent(javax.swing.event.ListSelectionEvent) DataTablePopupMenu(com.att.aro.ui.model.DataTablePopupMenu) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) IOException(java.io.IOException) Profile(com.att.aro.core.configuration.pojo.Profile) ListSelectionListener(javax.swing.event.ListSelectionListener)

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