Search in sources :

Example 1 with ExecutionModel

use of org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel in project titan.EclipsePlug-ins by eclipse.

the class JumpToNextSetverdictAction method run.

@Override
public void run() {
    if (this.widget == null) {
        return;
    }
    ExecutionModel model = this.view.getModel();
    if (model == null) {
        return;
    }
    int[] setverdictPlaces = model.getSetverdict();
    int selectedLine = (Integer) this.selection.getFirstElement();
    selectSetVerdict(setverdictPlaces, selectedLine);
}
Also used : ExecutionModel(org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel)

Example 2 with ExecutionModel

use of org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel in project titan.EclipsePlug-ins by eclipse.

the class JumpToNextSetverdictAction method selectionChanged.

@Override
public void selectionChanged(final IStructuredSelection selection) {
    this.selection = selection;
    int selectedLine = (Integer) this.selection.getFirstElement();
    boolean enable = false;
    ExecutionModel model = this.view.getModel();
    if (model == null) {
        setEnabled(false);
        return;
    }
    for (int j = 0; j < model.getSetverdict().length; j++) {
        if (model.getSetverdict()[j] > selectedLine) {
            enable = true;
            break;
        }
    }
    setEnabled(enable);
}
Also used : ExecutionModel(org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel)

Example 3 with ExecutionModel

use of org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel in project titan.EclipsePlug-ins by eclipse.

the class JumpToPreviousSetverdictAction method selectionChanged.

@Override
public void selectionChanged(final IStructuredSelection selection) {
    this.selection = selection;
    int selectedLine = (Integer) this.selection.getFirstElement();
    boolean enable = false;
    ExecutionModel model = this.view.getModel();
    if (model == null) {
        setEnabled(false);
        return;
    }
    for (int j = 0; j < model.getSetverdict().length; j++) {
        if (model.getSetverdict()[j] < selectedLine) {
            enable = true;
            break;
        }
    }
    setEnabled(enable);
}
Also used : ExecutionModel(org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel)

Example 4 with ExecutionModel

use of org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel in project titan.EclipsePlug-ins by eclipse.

the class OpenValueViewAction method run.

@Override
public void run() {
    if (selectedLine == null || this.mscView == null || selectedLine < 2 || selectedLine >= this.mscView.getModel().getNumberOfEvents() + 2) {
        return;
    }
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (activePage == null) {
        return;
    }
    LogFileMetaData logFileMetaData = this.mscView.getLogFileMetaData();
    IProject project = getProjectByName(logFileMetaData);
    IFile logFile = getLogFileFromProject(logFileMetaData, project);
    if (!logFile.exists()) {
        IViewReference[] viewReferences = activePage.getViewReferences();
        ActionUtils.closeAssociatedViews(activePage, viewReferences, logFile);
        // $NON-NLS-1$
        TitanLogExceptionHandler.handleException(new UserException(Messages.getString("OpenValueViewAction.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("OpenValueViewAction.4") + e.getMessage()));
            return;
        }
    }
    // pass log file meta data
    detailsview.setLogFileMetaData(this.mscView.getLogFileMetaData());
    ExecutionModel model = this.mscView.getModel();
    IEventObject ieventObject = model.getEvent(selectedLine - 2);
    if (!(ieventObject instanceof EventObject)) {
        return;
    }
    EventObject eventObject = (EventObject) ieventObject;
    String testCase = model.getTestCase().getTestCaseName();
    if ((testCase == null) || eventObject.getRecordNumber() == 0) {
        return;
    }
    // get value
    LogRecord logrecord;
    try {
        logrecord = ValueReader.getInstance().readLogRecordFromLogFileCached(this.mscView.getLogFileMetaData().getFilePath(), eventObject);
    } catch (Exception e) {
        ErrorReporter.logExceptionStackTrace(e);
        // $NON-NLS-1$
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenValueViewAction.3")));
        return;
    }
    String message = logrecord.getMessage();
    DetailData detailData = new DetailData(eventObject.getName(), eventObject.getPort(), message, testCase, eventObject.getEventType(), logrecord.getSourceInformation());
    detailsview.setData(detailData, false);
}
Also used : IFile(org.eclipse.core.resources.IFile) DetailsView(org.eclipse.titan.log.viewer.views.DetailsView) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) IProject(org.eclipse.core.resources.IProject) EventObject(org.eclipse.titan.log.viewer.views.msc.model.EventObject) IEventObject(org.eclipse.titan.log.viewer.views.msc.model.IEventObject) PartInitException(org.eclipse.ui.PartInitException) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) UserException(org.eclipse.titan.log.viewer.exceptions.UserException) IEventObject(org.eclipse.titan.log.viewer.views.msc.model.IEventObject) ExecutionModel(org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel) LogFileMetaData(org.eclipse.titan.log.viewer.models.LogFileMetaData) LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) UserException(org.eclipse.titan.log.viewer.exceptions.UserException) PartInitException(org.eclipse.ui.PartInitException) DetailData(org.eclipse.titan.log.viewer.views.details.DetailData)

Example 5 with ExecutionModel

use of org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel in project titan.EclipsePlug-ins by eclipse.

the class RefreshMSCViewAction method run.

@Override
public void run() {
    // Set current log file meta data
    final LogFileMetaData logFileMetaData = this.mscView.getLogFileMetaData();
    ExecutionModel model = this.mscView.getModel();
    final PreferencesHolder preferences = PreferencesHandler.getInstance().getPreferences(logFileMetaData.getProjectName());
    if (preferences.getVisualOrderComponents().isEmpty()) {
        // $NON-NLS-1$
        String userE = Messages.getString("RefreshMSCViewAction.3");
        TitanLogExceptionHandler.handleException(new UserException(userE));
        return;
    }
    final IFile logFile = getSelectedLogFile(logFileMetaData);
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    // Check if the log file exists
    if (!logFile.exists()) {
        IViewReference[] viewReferences = activePage.getViewReferences();
        ActionUtils.closeAssociatedViews(activePage, viewReferences, logFile);
        // $NON-NLS-1$
        TitanLogExceptionHandler.handleException(new UserException(Messages.getString("RefreshMSCViewAction.1")));
        return;
    }
    // Check if the log file has been modified
    if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
        LogFileCacheHandler.handleLogFileChange(logFile);
        return;
    }
    // Get log record index file for selected log file - No need to check is exists due to
    // LogFileCacheHandler.hasLogFileChanged(logFile) returning false above
    File logRecordIndexFile = LogFileCacheHandler.getLogRecordIndexFileForLogFile(logFile);
    try {
        // Read/parse log file
        final TestCase tc = model.getTestCase();
        final LogRecordIndex[] logRecordIndexes = LogFileCacheHandler.readLogRecordIndexFile(logRecordIndexFile, tc.getStartRecordNumber(), tc.getNumberOfRecords());
        WorkspaceJob job = new WorkspaceJob("Loading log information") {

            @Override
            public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
                ExecutionModel model;
                try {
                    model = parseLogFile();
                } catch (Exception e) {
                    ErrorReporter.logExceptionStackTrace(e);
                    TitanLogExceptionHandler.handleException(new TechnicalException(// $NON-NLS-1$
                    Messages.getString("RefreshMSCViewAction.5") + e.getMessage()));
                    return Status.CANCEL_STATUS;
                }
                final int firstRow = getFirstRow(model, preferences);
                final ExecutionModel finalModel = model;
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        RefreshMSCViewAction.this.mscView.setModel(finalModel, firstRow);
                    }
                });
                return Status.OK_STATUS;
            }

            private ExecutionModel parseLogFile() throws TechnicalException {
                ExecutionModel model;
                if (logFileMetaData.getExecutionMode() == null) {
                    throw new TechnicalException("Error while parsing of the log file: ExecutionMode is null");
                }
                try {
                    // re-parse tc
                    Parser parser = new Parser(logFileMetaData);
                    model = parser.preParse(tc, logRecordIndexes, preferences, mscView.getFilterPattern(), null);
                } catch (IOException e) {
                    throw new TechnicalException("Error while parsing of the log file");
                } catch (ParseException e) {
                    throw new TechnicalException("Error while parsing of the log file");
                }
                return model;
            }
        };
        job.schedule();
    } catch (IOException e) {
        ErrorReporter.logExceptionStackTrace("Error while parsing of the log file", e);
        TitanLogExceptionHandler.handleException(new TechnicalException(e.getMessage()));
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) LogRecordIndex(org.eclipse.titan.log.viewer.models.LogRecordIndex) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException) ParseException(java.text.ParseException) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) IOException(java.io.IOException) UserException(org.eclipse.titan.log.viewer.exceptions.UserException) Parser(org.eclipse.titan.log.viewer.parsers.Parser) ExecutionModel(org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel) PreferencesHolder(org.eclipse.titan.log.viewer.preferences.PreferencesHolder) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) LogFileMetaData(org.eclipse.titan.log.viewer.models.LogFileMetaData) TestCase(org.eclipse.titan.log.viewer.parsers.data.TestCase) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) UserException(org.eclipse.titan.log.viewer.exceptions.UserException) ParseException(java.text.ParseException) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Aggregations

ExecutionModel (org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel)9 ParseException (java.text.ParseException)4 IFile (org.eclipse.core.resources.IFile)4 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)4 IViewReference (org.eclipse.ui.IViewReference)4 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 IOException (java.io.IOException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)3 LogFileMetaData (org.eclipse.titan.log.viewer.models.LogFileMetaData)3 LogRecord (org.eclipse.titan.log.viewer.parsers.data.LogRecord)3 EventObject (org.eclipse.titan.log.viewer.views.msc.model.EventObject)3 File (java.io.File)2 IProject (org.eclipse.core.resources.IProject)2 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)2 LogRecordIndex (org.eclipse.titan.log.viewer.models.LogRecordIndex)2 Parser (org.eclipse.titan.log.viewer.parsers.Parser)2 TestCase (org.eclipse.titan.log.viewer.parsers.data.TestCase)2 PreferencesHolder (org.eclipse.titan.log.viewer.preferences.PreferencesHolder)2 IEventObject (org.eclipse.titan.log.viewer.views.msc.model.IEventObject)2