Search in sources :

Example 11 with EventObject

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

the class EventObjectFactory method createEventObject.

public EventObject createEventObject(final EventType type, final LogRecord logRecord, MessageAnalyser messageAnalyser1, int timeStampConstant) {
    EventObject eventObject = new EventObject(type);
    if (logRecord != null) {
        // otherwise send the whole timestamp
        if (timeStampConstant == org.eclipse.titan.log.viewer.utils.Constants.DATETIME_FORMAT_LENGTH) {
            String timestamp = logRecord.getTimestamp();
            eventObject.setTime(getTimeStamp(timestamp));
        } else {
            eventObject.setTime(logRecord.getTimestamp());
        }
        // event type in
        eventObject.setEventType(logRecord.getEventType());
        // log file
        eventObject.setRecordOffset(logRecord.getRecordOffset());
        eventObject.setRecordLength(logRecord.getRecordLength());
        eventObject.setRecordNumber(logRecord.getRecordNumber());
        // Set reference if the componentReference exists in the log file
        if ((logRecord.getComponentReference() != null) && (logRecord.getComponentReference().trim().length() > 0)) {
            eventObject.setReference(logRecord.getComponentReference());
        }
    }
    // settings in eventObject depending on event type
    switch(type) {
        // and get the name specified by the user in preferences
        case SYSTEM_CREATE:
        case SYSTEM_TERMINATE:
            eventObject.setReference(org.eclipse.titan.log.viewer.utils.Constants.SUT_REFERENCE);
            break;
        // log.
        case MTC_CREATE:
        case MTC_TERMINATE:
            eventObject.setName(org.eclipse.titan.log.viewer.utils.Constants.MTC);
            eventObject.setReference(org.eclipse.titan.log.viewer.utils.Constants.MTC_REFERENCE);
            break;
        case HC_CREATE:
        case HC_TERMINATE:
            eventObject.setName(org.eclipse.titan.log.viewer.utils.Constants.HC);
            eventObject.setReference(org.eclipse.titan.log.viewer.utils.Constants.HC_REFERENCE);
            break;
        // This event type represents a component creation.
        case PTC_CREATE:
            eventObject.setReference(messageAnalyser1.getComponentCreationReference());
            eventObject.setName(messageAnalyser1.getComponentCreationName());
            break;
        // This event type represents a component done event.
        case PTC_DONE:
            // $NON-NLS-1$
            eventObject.setName("done");
            eventObject.setReference(messageAnalyser1.getComponentDoneReference());
            eventObject.setTarget(org.eclipse.titan.log.viewer.utils.Constants.MTC_REFERENCE);
            break;
        // This event type represents a test case start event.
        case TC_START:
            String tcName = messageAnalyser1.getTestcaseName();
            eventObject.setName(tcName);
            break;
        // This event type represents a test case termination event.
        case TC_END:
            eventObject.setName(messageAnalyser1.getTestcaseVerdict());
            break;
        // This event type represents a send event.
        case SEND:
            String sendSource = messageAnalyser1.getSendSource();
            eventObject.setReference(sendSource);
            eventObject.setPort(sendSource);
            break;
        case SILENT_EVENT:
            if (logRecord != null) {
                eventObject.setTarget(logRecord.getComponentReference());
            }
            break;
        default:
            break;
    }
    return eventObject;
}
Also used : EventObject(org.eclipse.titan.log.viewer.views.msc.model.EventObject)

Example 12 with EventObject

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

the class TextTableView method createEventObject.

private EventObject createEventObject(LogRecord logrecord) {
    EventObject newEventObject = new EventObject(EventType.UNKNOWN);
    newEventObject.setRecordLength(logrecord.getRecordLength());
    newEventObject.setRecordNumber(logrecord.getRecordNumber());
    newEventObject.setRecordOffset(logrecord.getRecordOffset());
    newEventObject.setReference(logrecord.getComponentReference());
    newEventObject.setEventType(logrecord.getEventType());
    return newEventObject;
}
Also used : EventObject(org.eclipse.titan.log.viewer.views.msc.model.EventObject)

Example 13 with EventObject

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

the class OpenSourceAction method run.

@Override
public void run() {
    if (selectedLineInvalid()) {
        return;
    }
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    IWorkbenchPage activePage = window.getActivePage();
    if (activePage == null) {
        return;
    }
    LogFileMetaData logFileMetaData = this.mscView.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(Messages.getString("OpenValueViewAction.1")));
        return;
    }
    if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
        LogFileCacheHandler.handleLogFileChange(logFile);
        return;
    }
    ExecutionModel model = this.mscView.getModel();
    String testCase = model.getTestCase().getTestCaseName();
    EventObject eventObject;
    int actualLine = selectedLine;
    SourceInformation sourceInformation = null;
    while (sourceInformation == null && actualLine > 2) {
        IEventObject ieventObject = model.getEvent(actualLine - 2);
        if (!(ieventObject instanceof EventObject)) {
            actualLine--;
            continue;
        }
        eventObject = (EventObject) ieventObject;
        if ((testCase == null) || eventObject.getRecordNumber() == 0) {
            return;
        }
        // get value
        LogRecord logrecord;
        try {
            logrecord = ValueReader.getInstance().readLogRecordFromLogFileCached(this.mscView.getLogFileMetaData().getFilePath(), eventObject);
        } catch (final IOException valueException) {
            ErrorReporter.logExceptionStackTrace(valueException);
            // $NON-NLS-1$
            ErrorReporter.INTERNAL_ERROR(Messages.getString("OpenValueViewAction.3"));
            return;
        } catch (final ParseException valueException) {
            ErrorReporter.logExceptionStackTrace(valueException);
            // $NON-NLS-1$
            ErrorReporter.INTERNAL_ERROR(Messages.getString("OpenValueViewAction.3"));
            return;
        }
        try {
            sourceInformation = SourceInformation.createInstance(logrecord.getSourceInformation());
        } catch (InvalidSourceInformationException e) {
        // Do nothing
        // try to find the closest source information
        }
        actualLine--;
    }
    if (sourceInformation == null) {
        if (!silent) {
            String setting = logFileMetaData.getOptionsSettings("SourceInfoFormat");
            if (setting == null) {
                ErrorReporter.parallelErrorDisplayInMessageDialog("Error opening source", "This log file is not generated with source location information inserted. And it really does not seem to contain source location information");
            } else {
                ErrorReporter.parallelErrorDisplayInMessageDialog("Error opening source", "This log record does not seem to contain source location information");
            }
        }
        return;
    }
    if (sourceInformation.getSourceFileName() == null) {
        mscView.getViewSite().getActionBars().getStatusLineManager().setErrorMessage("The name of the target file could not be extracted");
        return;
    }
    final String fileName = sourceInformation.getSourceFileName();
    IFile targetFile;
    if (lastFilename != null && lastFilename.equals(fileName) && lastPath != null) {
        IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(lastPath);
        if (files.length == 0) {
            mscView.getViewSite().getActionBars().getStatusLineManager().setErrorMessage("The file `" + lastFilename + "' could not be found");
            setLastFilename(null);
            return;
        }
        targetFile = files[0];
    } else {
        targetFile = findSourceFile(project, fileName);
        if (targetFile == null) {
            mscView.getViewSite().getActionBars().getStatusLineManager().setErrorMessage("The file `" + fileName + "' could not be found");
            return;
        }
        setLastFilename(fileName);
        setLastPath(targetFile.getLocationURI());
    }
    openEditor(targetFile, sourceInformation.getLineNumber(), mscView, forceEditorOpening);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) InvalidSourceInformationException(org.eclipse.titan.log.viewer.models.SourceInformation.InvalidSourceInformationException) IOException(java.io.IOException) 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) SourceInformation(org.eclipse.titan.log.viewer.models.SourceInformation) IEventObject(org.eclipse.titan.log.viewer.views.msc.model.IEventObject) ExecutionModel(org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel) 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) ParseException(java.text.ParseException)

Aggregations

EventObject (org.eclipse.titan.log.viewer.views.msc.model.EventObject)13 LogRecord (org.eclipse.titan.log.viewer.parsers.data.LogRecord)7 IFile (org.eclipse.core.resources.IFile)5 ParseException (java.text.ParseException)4 IProject (org.eclipse.core.resources.IProject)4 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)4 LogFileMetaData (org.eclipse.titan.log.viewer.models.LogFileMetaData)4 IViewReference (org.eclipse.ui.IViewReference)4 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 IWorkspace (org.eclipse.core.resources.IWorkspace)3 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)3 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)3 ExecutionModel (org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 SourceInformation (org.eclipse.titan.log.viewer.models.SourceInformation)2 InvalidSourceInformationException (org.eclipse.titan.log.viewer.models.SourceInformation.InvalidSourceInformationException)2