Search in sources :

Example 1 with LogFileHandler

use of org.eclipse.titan.log.viewer.utils.LogFileHandler in project titan.EclipsePlug-ins by eclipse.

the class OpenStatisticalViewMenuAction method processLogFile.

private void processLogFile() {
    try {
        new ProgressMonitorDialog(null).run(false, false, new IRunnableWithProgress() {

            @Override
            public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                OpenStatisticalViewMenuAction.this.monitor = monitor;
                OpenStatisticalViewMenuAction.this.testCaseExtractor = null;
                try {
                    LogFileHandler logFileHandler = new LogFileHandler(logFile);
                    // First of all, verify that the file is a TITAN supported log file
                    try {
                        OpenStatisticalViewMenuAction.this.logFileMetaData = logFileHandler.autoDetect();
                    } catch (final TechnicalException e) {
                        ErrorReporter.logExceptionStackTrace(e);
                        OpenStatisticalViewMenuAction.this.logFileIsSupported = false;
                        TitanLogExceptionHandler.handleException(new UserException(e.getMessage()));
                        return;
                    }
                    OpenStatisticalViewMenuAction.this.testCaseExtractor = new TestCaseExtractor();
                    OpenStatisticalViewMenuAction.this.testCaseExtractor.addObserver(OpenStatisticalViewMenuAction.this);
                    if (OpenStatisticalViewMenuAction.this.monitor != null) {
                        OpenStatisticalViewMenuAction.this.monitor.beginTask(Messages.getString("OpenStatisticalViewMenuAction.4") + OpenStatisticalViewMenuAction.this.logFile.getName() + Messages.getString("OpenStatisticalViewMenuAction.3"), 100);
                    }
                    // Extract test cases from log file
                    OpenStatisticalViewMenuAction.this.testCaseExtractor.extractTestCasesFromLogFile(OpenStatisticalViewMenuAction.this.logFileMetaData, monitor);
                    LogFileCacheHandler.fillCache(logFile, logFileMetaData, testCaseExtractor.getTestCases(), testCaseExtractor.getLogRecordIndexes());
                    if (OpenStatisticalViewMenuAction.this.testCaseExtractor.failedDuringExtraction()) {
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                MessageDialog.openInformation(null, Messages.getString("OpenStatisticalViewMenuAction.2"), Messages.getString("OpenStatisticalViewMenuAction.1"));
                            }
                        });
                    }
                } catch (IOException e) {
                    ErrorReporter.logExceptionStackTrace(e);
                    TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenStatisticalViewMenuAction.0") + e.getMessage()));
                } finally {
                    if (OpenStatisticalViewMenuAction.this.testCaseExtractor != null) {
                        OpenStatisticalViewMenuAction.this.testCaseExtractor.deleteObserver(OpenStatisticalViewMenuAction.this);
                    }
                    if (OpenStatisticalViewMenuAction.this.monitor != null) {
                        OpenStatisticalViewMenuAction.this.monitor.done();
                    }
                }
            }
        });
    } catch (InvocationTargetException e) {
        ErrorReporter.logExceptionStackTrace(e);
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenStatisticalViewMenuAction.0") + e.getTargetException()));
    } catch (InterruptedException e) {
        ErrorReporter.logExceptionStackTrace(e);
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenStatisticalViewMenuAction.0") + e.getMessage()));
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) LogFileHandler(org.eclipse.titan.log.viewer.utils.LogFileHandler) UserException(org.eclipse.titan.log.viewer.exceptions.UserException) TestCaseExtractor(org.eclipse.titan.log.viewer.extractors.TestCaseExtractor) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)1 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)1 TestCaseExtractor (org.eclipse.titan.log.viewer.extractors.TestCaseExtractor)1 LogFileHandler (org.eclipse.titan.log.viewer.utils.LogFileHandler)1