use of com.att.aro.ui.commonui.MessageDialogFactory in project VideoOptimzer by attdevsupport.
the class DataDump method showSaveChooser.
/**
* Initiates the save chooser options and creates a file.
*/
private boolean showSaveChooser() {
final String fileExtention = ResourceBundleHelper.getMessageString(MessageItem.fileChooser_contentType_json);
JFileChooser chooser = new JFileChooser(userPreferences.getLastExportDirectory());
FileNameExtensionFilter ff;
ff = new FileNameExtensionFilter(ResourceBundleHelper.getMessageString(MessageItem.fileChooser_desc_json), fileExtention);
chooser.addChoosableFileFilter(ff);
chooser.setFileFilter(ff);
chooser.setDialogTitle(ResourceBundleHelper.getMessageString(MessageItem.fileChooser_Title));
chooser.setApproveButtonText(ResourceBundleHelper.getMessageString(MessageItem.fileChooser_Save));
chooser.setMultiSelectionEnabled(false);
if (chooser.showSaveDialog(MSG_WINDOW) != JFileChooser.APPROVE_OPTION) {
return false;
}
fileToSave = chooser.getSelectedFile();
if (fileToSave.getName().length() >= FILE_NAME_MAX_LENGTH) {
new MessageDialogFactory().showErrorDialog(MSG_WINDOW, ResourceBundleHelper.getMessageString(MessageItem.exportall_errorLongFileName));
return false;
}
if (!chooser.getFileFilter().accept(fileToSave)) {
fileToSave = new File(fileToSave.getAbsolutePath() + "." + fileExtention);
}
String message = MessageFormat.format(ResourceBundleHelper.getMessageString(MessageItem.fileChooser_fileExists), fileToSave.getAbsolutePath());
if (fileToSave.exists()) {
int option = new MessageDialogFactory().showConfirmDialog(MSG_WINDOW, message, JOptionPane.YES_NO_OPTION);
if (option == JOptionPane.NO_OPTION) {
return false;
}
}
return true;
}
use of com.att.aro.ui.commonui.MessageDialogFactory in project VideoOptimzer by attdevsupport.
the class DataDump method getValidFolderList.
/**
* Collects valid trace folders.
*
* @param traceFolders
* - List of available folder names.
* @param validFolderList
* - List of valid trace folder names.
*/
private void getValidFolderList(List<File> traceFolders, List<File> validFolderList) {
for (File traceDirectory : traceFolders) {
// Check if it is a valid trace folder or not
if (new File(traceDirectory, ResourceBundleHelper.getMessageString(MessageItem.datadump_trafficFile)).exists()) {
validFolderList.add(traceDirectory);
}
// Check if it has sub-folders or not
List<File> allFolders = null;
if (traceDirectory == null) {
allFolders = new ArrayList<File>();
} else {
File[] folders = traceDirectory.listFiles(new java.io.FileFilter() {
@Override
public boolean accept(File arg0) {
return arg0.isDirectory();
}
});
if (folders == null) {
allFolders = new ArrayList<File>();
} else {
allFolders = Arrays.asList(folders);
}
}
if (subfolderAccess && allFolders.size() > 0) {
if (!userConfirmation && new MessageDialogFactory().showConfirmDialog(MSG_WINDOW, ResourceBundleHelper.getMessageString(MessageItem.datadump_subfolder), JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
subfolderAccess = false;
continue;
}
userConfirmation = true;
getValidFolderList(allFolders, validFolderList);
}
}
}
use of com.att.aro.ui.commonui.MessageDialogFactory in project VideoOptimzer by attdevsupport.
the class DataDump method startDataDump.
/**
* Starts dumping data in CSV file for the provided trace files.
*
* @param traceFolders
* - List of trace folder names.
* @return A FileWriter object.
* @throws IOException
*/
private FileWriter startDataDump(List<File> traceFolders) throws IOException, ProfileException {
FileWriter writer = new FileWriter(fileToSave);
try {
List<File> validFolderList = new ArrayList<File>();
Set<AROTraceData> analysis = new LinkedHashSet<AROTraceData>();
getValidFolderList(traceFolders, validFolderList);
for (File traceDirectory : validFolderList) {
try {
analysis.add(controller.runAnalyzer(traceDirectory.getAbsolutePath(), controller.getTheModel().getAnalyzerResult().getProfile(), null));
} catch (Exception e) {
LOG.warn("Unable to run analysis on folder: " + traceDirectory, e);
}
}
try {
new ObjectMapper().writeValue(fileToSave, analysis);
} catch (JsonGenerationException e) {
LOG.error(e.getMessage());
new MessageDialogFactory().showUnexpectedExceptionDialog(MSG_WINDOW, e);
} catch (JsonMappingException e) {
LOG.error(e.getMessage());
new MessageDialogFactory().showUnexpectedExceptionDialog(MSG_WINDOW, e);
} catch (IOException e) {
LOG.error(e.getMessage());
new MessageDialogFactory().showUnexpectedExceptionDialog(MSG_WINDOW, e);
}
userPreferences.setLastTraceDirectory(traceDir);
} finally {
writer.close();
}
return writer;
}
use of com.att.aro.ui.commonui.MessageDialogFactory 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");
}
}
}
use of com.att.aro.ui.commonui.MessageDialogFactory in project VideoOptimzer by attdevsupport.
the class ADBPathDialog method onOk.
private void onOk() {
if (txtFile.getText().length() < 3) {
new MessageDialogFactory().showErrorDialog(null, "Please provide location of ADB to continue.");
} else {
settings.setAndSaveAttribute("adb", txtFile.getText());
System.setProperty("ANDROID_ADB", txtFile.getText());
dispose();
}
}
Aggregations