use of com.rockwellcollins.atc.tcg.suite.TestSuite in project AGREE by loonwerks.
the class SaveHandler method doAnalysis.
protected IStatus doAnalysis(final IProgressMonitor monitor) {
Thread analysisThread = new Thread() {
String filePath;
TestSuiteView view;
@Override
public void run() {
activateTerminateHandler(monitor);
Shell activeShell = getWindow().getShell();
System.out.println("Saving test suite...");
syncExec(() -> {
view = (TestSuiteView) getWindow().getActivePage().findView(TestSuiteView.ID);
});
if (view != null) {
TestSuite suite = view.getInput();
if (suite != null) {
System.out.println("Bringing up file dialog...");
syncExec(() -> {
FileDialog dialog = new FileDialog(activeShell, SWT.SAVE);
if (startingFilePath != null) {
dialog.setFileName(startingFilePath);
}
String[] filterNames = new String[] { "XML Files", "All Files (*)" };
String[] filterExtensions = new String[] { "*.xml", "*" };
dialog.setFilterNames(filterNames);
dialog.setFilterExtensions(filterExtensions);
dialog.setOverwrite(true);
filePath = dialog.open();
});
if (filePath != null) {
startingFilePath = filePath;
System.out.println("filePath: " + filePath);
TestSuiteLinker linker = (TestSuiteLinker) view.getMenuListener().getLinker();
AnalysisResult result = view.getMenuListener().getAnalysisResult();
List<Type> types = linker.getAgreeProgram(result).globalTypes;
try {
TcgXmlWriter tcgXmlWriter = new TcgXmlWriter(filePath, types, false);
tcgXmlWriter.writeSuite(suite);
System.out.println("This would be where test suite written to " + filePath);
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
}
// TcgXmlWriter consoleWriter = new TcgXmlWriter(null, null, true);
// consoleWriter.writeSuite(suite);
}
} else {
syncExec(() -> {
MessageBox mb = new MessageBox(activeShell);
mb.setMessage("Error: no test suite loaded. Please open a test suite\n");
mb.open();
});
}
} else {
syncExec(() -> {
MessageBox mb = new MessageBox(activeShell);
mb.setMessage("Error: test suite view needs to be active in order to save.\n");
mb.open();
});
}
deactivateTerminateHandler();
}
};
analysisThread.start();
return Status.OK_STATUS;
}
Aggregations