Search in sources :

Example 1 with TcgXmlWriter

use of com.rockwellcollins.atc.tcg.writers.TcgXmlWriter 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;
}
Also used : TestSuiteView(com.rockwellcollins.atc.tcg.views.TestSuiteView) TestSuiteLinker(com.rockwellcollins.atc.tcg.views.TestSuiteLinker) FileNotFoundException(java.io.FileNotFoundException) AnalysisResult(jkind.api.results.AnalysisResult) TcgXmlWriter(com.rockwellcollins.atc.tcg.writers.TcgXmlWriter) MessageBox(org.eclipse.swt.widgets.MessageBox) Shell(org.eclipse.swt.widgets.Shell) Type(jkind.lustre.Type) TestSuite(com.rockwellcollins.atc.tcg.suite.TestSuite) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 2 with TcgXmlWriter

use of com.rockwellcollins.atc.tcg.writers.TcgXmlWriter in project AGREE by loonwerks.

the class VerifyHandler method emitResult.

private void emitResult(TestSuite testSuite) {
    TcgPreferenceUtils.AutoSaveFileInfo fileInfo = TcgPreferenceUtils.getAutoSaveFileInfo();
    Boolean doAutoSave = fileInfo.autoSaveType != TcgPreferenceUtils.AutoSaveType.DO_NOT_SAVE;
    if (doAutoSave) {
        String fileName = fileInfo.saveDestination;
        if (fileInfo.autoSaveType == TcgPreferenceUtils.AutoSaveType.SAVE_TO_NEW_FILE) {
            fileName = TcgWriterUtils.createUniqueFileName(fileName);
        }
        try {
            testSuite.setName(TcgWriterUtils.getFileNameNoExtension(fileName));
            TcgXmlWriter writer = new TcgXmlWriter(fileName, null, false);
            writer.writeSuite(testSuite);
        } catch (Exception e) {
            throw new TcgException("Error creating XML output file", e);
        }
    }
}
Also used : TcgPreferenceUtils(com.rockwellcollins.atc.tcg.preferences.TcgPreferenceUtils) TcgXmlWriter(com.rockwellcollins.atc.tcg.writers.TcgXmlWriter) TcgException(com.rockwellcollins.atc.tcg.TcgException) PartInitException(org.eclipse.ui.PartInitException) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) JKindException(jkind.JKindException) FileNotFoundException(java.io.FileNotFoundException) TcgException(com.rockwellcollins.atc.tcg.TcgException)

Aggregations

TcgXmlWriter (com.rockwellcollins.atc.tcg.writers.TcgXmlWriter)2 FileNotFoundException (java.io.FileNotFoundException)2 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)1 TcgException (com.rockwellcollins.atc.tcg.TcgException)1 TcgPreferenceUtils (com.rockwellcollins.atc.tcg.preferences.TcgPreferenceUtils)1 TestSuite (com.rockwellcollins.atc.tcg.suite.TestSuite)1 TestSuiteLinker (com.rockwellcollins.atc.tcg.views.TestSuiteLinker)1 TestSuiteView (com.rockwellcollins.atc.tcg.views.TestSuiteView)1 JKindException (jkind.JKindException)1 AnalysisResult (jkind.api.results.AnalysisResult)1 Type (jkind.lustre.Type)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 Shell (org.eclipse.swt.widgets.Shell)1 PartInitException (org.eclipse.ui.PartInitException)1