Search in sources :

Example 1 with LogFileMetaData

use of org.eclipse.titan.log.viewer.models.LogFileMetaData in project titan.EclipsePlug-ins by eclipse.

the class ActionUtils method closeView.

private static void closeView(IFile file, IWorkbenchPage activePage, IViewReference reference) {
    IViewPart view = reference.getView(false);
    // a restored view with faulty content
    if (view == null) {
        activePage.hideView(reference);
        return;
    }
    if (!(view instanceof ILogViewerView)) {
        return;
    }
    final ILogViewerView logViewerView = (ILogViewerView) view;
    final LogFileMetaData metadata = logViewerView.getLogFileMetaData();
    if (metadata == null) {
        activePage.hideView(reference);
        return;
    }
    if (file.getLocationURI().equals(metadata.getFilePath())) {
        if (logViewerView instanceof DetailsView) {
            ((DetailsView) logViewerView).setData(null, false);
        }
        activePage.hideView(reference);
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) ILogViewerView(org.eclipse.titan.log.viewer.views.ILogViewerView) DetailsView(org.eclipse.titan.log.viewer.views.DetailsView) LogFileMetaData(org.eclipse.titan.log.viewer.models.LogFileMetaData)

Example 2 with LogFileMetaData

use of org.eclipse.titan.log.viewer.models.LogFileMetaData in project titan.EclipsePlug-ins by eclipse.

the class ActionUtils method closeView.

private static void closeView(IProject project, IWorkbenchPage activePage, IViewReference reference, IViewPart view) {
    // a restored view with faulty content
    if (view == null) {
        activePage.hideView(reference);
        return;
    }
    if (!(view instanceof ILogViewerView)) {
        return;
    }
    final ILogViewerView logViewerView = (ILogViewerView) view;
    final LogFileMetaData metaData = logViewerView.getLogFileMetaData();
    if (metaData == null) {
        activePage.hideView(reference);
        return;
    }
    if (project.getName().equals(metaData.getProjectName())) {
        activePage.hideView(reference);
    }
}
Also used : ILogViewerView(org.eclipse.titan.log.viewer.views.ILogViewerView) LogFileMetaData(org.eclipse.titan.log.viewer.models.LogFileMetaData)

Example 3 with LogFileMetaData

use of org.eclipse.titan.log.viewer.models.LogFileMetaData in project titan.EclipsePlug-ins by eclipse.

the class LogFileCacheHandler method logFileMetaDataReader.

/**
 * @param propertyFile property file to read from
 * @return Log file meta data
 * @throws IOException if log file meta data can not be found
 * @throws ClassNotFoundException if log file meta data can not be found
 */
public static LogFileMetaData logFileMetaDataReader(final File propertyFile) throws IOException, ClassNotFoundException {
    FileInputStream stream = null;
    LogFileMetaData logFileMetaData = null;
    ObjectInputStream objectFile = null;
    try {
        stream = new FileInputStream(propertyFile);
        objectFile = new ObjectInputStream(stream);
        logFileMetaData = (LogFileMetaData) objectFile.readObject();
    } catch (final InvalidClassException e) {
        FileUtils.deleteQuietly(propertyFile);
    } finally {
        IOUtils.closeQuietly(stream, objectFile);
    }
    return logFileMetaData;
}
Also used : LogFileMetaData(org.eclipse.titan.log.viewer.models.LogFileMetaData) InvalidClassException(java.io.InvalidClassException) FileInputStream(java.io.FileInputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 4 with LogFileMetaData

use of org.eclipse.titan.log.viewer.models.LogFileMetaData in project titan.EclipsePlug-ins by eclipse.

the class LogFileCacheHandler method isPropertyFileInvalid.

private static boolean isPropertyFileInvalid(IFile logFile, File propertyFile) {
    try {
        LogFileMetaData logFileMetaData = logFileMetaDataReader(propertyFile);
        String projectName = logFile.getProject().getName();
        String projectRelativePath = File.separator + projectName + File.separator + logFile.getProjectRelativePath().toOSString();
        URI logFilePath = logFile.getLocationURI();
        if (!logFileMetaData.getProjectRelativePath().contentEquals(projectRelativePath) || !logFileMetaData.getFilePath().equals(logFilePath)) {
            return true;
        }
    } catch (final IOException e) {
        return true;
    } catch (final ClassNotFoundException e) {
        return true;
    }
    return false;
}
Also used : LogFileMetaData(org.eclipse.titan.log.viewer.models.LogFileMetaData) IOException(java.io.IOException) URI(java.net.URI)

Example 5 with LogFileMetaData

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

Aggregations

LogFileMetaData (org.eclipse.titan.log.viewer.models.LogFileMetaData)16 IOException (java.io.IOException)8 IFile (org.eclipse.core.resources.IFile)8 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)7 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)7 IProject (org.eclipse.core.resources.IProject)6 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)6 ParseException (java.text.ParseException)5 IViewReference (org.eclipse.ui.IViewReference)5 IWorkspace (org.eclipse.core.resources.IWorkspace)4 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)4 LogRecord (org.eclipse.titan.log.viewer.parsers.data.LogRecord)4 EventObject (org.eclipse.titan.log.viewer.views.msc.model.EventObject)4 PartInitException (org.eclipse.ui.PartInitException)4 File (java.io.File)3 TestCaseExtractor (org.eclipse.titan.log.viewer.extractors.TestCaseExtractor)3 TestCase (org.eclipse.titan.log.viewer.parsers.data.TestCase)3 DetailsView (org.eclipse.titan.log.viewer.views.DetailsView)3 ExecutionModel (org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel)3 CoreException (org.eclipse.core.runtime.CoreException)2