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