Search in sources :

Example 11 with TechnicalException

use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.

the class ExtractTestCasesAction method handleExtractingError.

private void handleExtractingError(final Exception e) throws InterruptedException {
    ErrorReporter.logExceptionStackTrace(e);
    // Generate Technical Error
    String errorMsg = Messages.getString("ExtractTestCasesAction.5") + this.logFile.getName() + Messages.getString("ExtractTestCasesAction.6") + e.getMessage();
    TitanLogExceptionHandler.handleException(new TechnicalException(errorMsg));
    // Clear cache so index file is regenerated next time
    LogFileCacheHandler.clearCache(this.logFile);
    throw new InterruptedException(errorMsg);
}
Also used : TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException)

Example 12 with TechnicalException

use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.

the class OpenMSCViewMenuAction method showView.

private void showView(final ExecutionModel model, final Parser parser, final TestCase tc) {
    final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    final String viewId = Constants.MSC_VIEW_ID;
    final String secondId = generateSecondaryViewId(tc, this.logFileMetaData);
    IViewReference reference = activePage.findViewReference(viewId, secondId);
    MSCView part = null;
    // Get the view
    if (reference != null) {
        part = (MSCView) reference.getView(false);
    }
    // If something is wrong, close the view
    if (part != null) {
        activePage.hideView(part);
    }
    // Create the new view
    try {
        part = (MSCView) activePage.showView(viewId, secondId, IWorkbenchPage.VIEW_ACTIVATE);
    } catch (PartInitException e) {
        ErrorReporter.logExceptionStackTrace(e);
        TitanLogExceptionHandler.handleException(new TechnicalException(// $NON-NLS-1$
        Messages.getString("OpenMSCViewMenuAction.3") + e.getMessage()));
        return;
    }
    part.setLogFileMetaData(OpenMSCViewMenuAction.this.logFileMetaData);
    final PreferencesHolder preferences = PreferencesHandler.getInstance().getPreferences(this.logFileMetaData.getProjectName());
    part.setModel(model, getFirstRowToSelect(preferences, model));
}
Also used : PreferencesHolder(org.eclipse.titan.log.viewer.preferences.PreferencesHolder) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) IViewReference(org.eclipse.ui.IViewReference) MSCView(org.eclipse.titan.log.viewer.views.MSCView) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException)

Example 13 with TechnicalException

use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.

the class OpenSourceViewMenuAction method run.

@Override
public void run() {
    if (this.eventSelection == null) {
        return;
    }
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    LogFileMetaData logFileMetaData;
    logFileMetaData = this.view.getLogFileMetaData();
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    IProject project = root.getProject(logFileMetaData.getProjectName());
    IFile logFile = project.getFile(logFileMetaData.getProjectRelativePath().substring(logFileMetaData.getProjectName().length() + 1));
    if (!logFile.exists()) {
        IViewReference[] viewReferences = activePage.getViewReferences();
        ActionUtils.closeAssociatedViews(activePage, viewReferences, logFile);
        // $NON-NLS-1$
        TitanLogExceptionHandler.handleException(new UserException("The log file could not be found.\n Please perform the Open Text Table action again."));
        return;
    }
    if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
        LogFileCacheHandler.handleLogFileChange(logFile);
        return;
    }
    EventObject eventObject = this.eventSelection.getEventObject();
    String testCase = this.eventSelection.getTestCaseName();
    if ((eventObject == null) || (testCase == null)) {
        return;
    }
    // get value
    LogRecord logrecord;
    try {
        logrecord = ValueReader.getInstance().readLogRecordFromLogFile(logFileMetaData.getFilePath(), eventObject);
    } catch (Exception e) {
        ErrorReporter.logExceptionStackTrace(e);
        // $NON-NLS-1$
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("MSCView.8")));
        return;
    }
    SourceInformation sourceInformation = null;
    try {
        sourceInformation = SourceInformation.createInstance(logrecord.getSourceInformation());
    } catch (InvalidSourceInformationException e) {
        if (!silent) {
            String setting = logFileMetaData.getOptionsSettings("SourceInfoFormat");
            if (setting == null) {
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        MessageDialog.openError(null, "Error opening source", // $NON-NLS-1$
                        "This log file is not generated with source location information inserted. And it really does not seem to contain source location information");
                    }
                });
            } else {
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        // $NON-NLS-1$
                        MessageDialog.openError(null, "Error opening source", "This log record does not seem to contain source location information");
                    }
                });
            }
        }
        return;
    }
    final String fileName = sourceInformation.getSourceFileName();
    if (fileName == null) {
        view.getViewSite().getActionBars().getStatusLineManager().setErrorMessage("The name of the target file could not be extracted");
        return;
    }
    IFile targetFile;
    if (lastFilename != null && lastFilename.equals(fileName) && lastPath != null) {
        IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(lastPath);
        if (files.length == 0) {
            view.getViewSite().getActionBars().getStatusLineManager().setErrorMessage("The file `" + lastFilename + "' could not be found");
            setLastFilename(null);
            return;
        }
        targetFile = files[0];
    } else {
        targetFile = OpenSourceAction.findSourceFile(project, fileName);
        if (targetFile == null) {
            view.getViewSite().getActionBars().getStatusLineManager().setErrorMessage("The file `" + fileName + "' could not be found");
            return;
        }
        setLastFilename(fileName);
        setLastPath(targetFile.getLocationURI());
    }
    OpenSourceAction.openEditor(targetFile, sourceInformation.getLineNumber(), view, forceEditorOpening);
}
Also used : IFile(org.eclipse.core.resources.IFile) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) InvalidSourceInformationException(org.eclipse.titan.log.viewer.models.SourceInformation.InvalidSourceInformationException) IProject(org.eclipse.core.resources.IProject) EventObject(org.eclipse.titan.log.viewer.views.msc.model.EventObject) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) InvalidSourceInformationException(org.eclipse.titan.log.viewer.models.SourceInformation.InvalidSourceInformationException) UserException(org.eclipse.titan.log.viewer.exceptions.UserException) SourceInformation(org.eclipse.titan.log.viewer.models.SourceInformation) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) LogFileMetaData(org.eclipse.titan.log.viewer.models.LogFileMetaData) LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) IWorkspace(org.eclipse.core.resources.IWorkspace) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) UserException(org.eclipse.titan.log.viewer.exceptions.UserException)

Example 14 with TechnicalException

use of org.eclipse.titan.log.viewer.exceptions.TechnicalException 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)

Example 15 with TechnicalException

use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.

the class OpenValueViewMenuAction method run.

@Override
public void run() {
    if (this.eventSelection == null) {
        return;
    }
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    LogFileMetaData logFileMetaData;
    if (this.view instanceof MSCView) {
        logFileMetaData = ((MSCView) this.view).getLogFileMetaData();
    } else if (this.view instanceof TextTableView) {
        logFileMetaData = ((TextTableView) this.view).getLogFileMetaData();
    } else {
        return;
    }
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    IProject project = root.getProject(logFileMetaData.getProjectName());
    IFile logFile = project.getFile(logFileMetaData.getProjectRelativePath().substring(logFileMetaData.getProjectName().length() + 1));
    if (!logFile.exists()) {
        IViewReference[] viewReferences = activePage.getViewReferences();
        ActionUtils.closeAssociatedViews(activePage, viewReferences, logFile);
        if (this.view instanceof TextTableView) {
            // $NON-NLS-1$
            TitanLogExceptionHandler.handleException(new UserException("The log file could not be found.\n Please perform the Open Text Table action again."));
        } else {
            // $NON-NLS-1$
            TitanLogExceptionHandler.handleException(new UserException(Messages.getString("OpenValueViewMenuAction.1")));
        }
        return;
    }
    if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
        LogFileCacheHandler.handleLogFileChange(logFile);
        return;
    }
    DetailsView detailsview = (DetailsView) activePage.findView(Constants.DETAILS_VIEW_ID);
    if (detailsview == null && !forceEditorOpening) {
        return;
    }
    if (forceEditorOpening) {
        try {
            detailsview = (DetailsView) activePage.showView(Constants.DETAILS_VIEW_ID);
        } catch (PartInitException e) {
            ErrorReporter.logExceptionStackTrace(e);
            // $NON-NLS-1$
            TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("MSCView.1") + e.getMessage()));
            return;
        }
    }
    // pass log file meta data
    detailsview.setLogFileMetaData(logFileMetaData);
    EventObject eventObject = this.eventSelection.getEventObject();
    String testCase = this.eventSelection.getTestCaseName();
    if ((eventObject == null) || (testCase == null)) {
        return;
    }
    // get value
    LogRecord logrecord;
    try {
        logrecord = ValueReader.getInstance().readLogRecordFromLogFile(logFileMetaData.getFilePath(), eventObject);
    } catch (final IOException e) {
        ErrorReporter.logExceptionStackTrace(e);
        // $NON-NLS-1$
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("MSCView.8")));
        return;
    } catch (final ParseException e) {
        ErrorReporter.logExceptionStackTrace(e);
        // $NON-NLS-1$
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("MSCView.8")));
        return;
    }
    String message = logrecord.getMessage();
    DetailData detailData = new DetailData(eventObject.getName(), eventObject.getPort(), message, testCase, eventObject.getEventType(), logrecord.getSourceInformation());
    detailsview.setData(detailData, false);
    detailsview.setFocus();
}
Also used : IFile(org.eclipse.core.resources.IFile) DetailsView(org.eclipse.titan.log.viewer.views.DetailsView) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) EventObject(org.eclipse.titan.log.viewer.views.msc.model.EventObject) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) LogFileMetaData(org.eclipse.titan.log.viewer.models.LogFileMetaData) LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) IWorkspace(org.eclipse.core.resources.IWorkspace) IViewReference(org.eclipse.ui.IViewReference) MSCView(org.eclipse.titan.log.viewer.views.MSCView) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) UserException(org.eclipse.titan.log.viewer.exceptions.UserException) PartInitException(org.eclipse.ui.PartInitException) ParseException(java.text.ParseException) TextTableView(org.eclipse.titan.log.viewer.views.text.table.TextTableView) DetailData(org.eclipse.titan.log.viewer.views.details.DetailData)

Aggregations

TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)33 IOException (java.io.IOException)18 IFile (org.eclipse.core.resources.IFile)16 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)10 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)10 File (java.io.File)9 IViewReference (org.eclipse.ui.IViewReference)8 CoreException (org.eclipse.core.runtime.CoreException)7 PartInitException (org.eclipse.ui.PartInitException)7 ParseException (java.text.ParseException)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 IProject (org.eclipse.core.resources.IProject)5 PreferencesHolder (org.eclipse.titan.log.viewer.preferences.PreferencesHolder)5 FileNotFoundException (java.io.FileNotFoundException)4 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)4 LogFileMetaData (org.eclipse.titan.log.viewer.models.LogFileMetaData)4 TestCase (org.eclipse.titan.log.viewer.parsers.data.TestCase)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 Map (java.util.Map)3