Search in sources :

Example 1 with DetailData

use of org.eclipse.titan.log.viewer.views.details.DetailData 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 2 with DetailData

use of org.eclipse.titan.log.viewer.views.details.DetailData 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)

Example 3 with DetailData

use of org.eclipse.titan.log.viewer.views.details.DetailData in project titan.EclipsePlug-ins by eclipse.

the class DetailsView method restoreState.

/**
 * Called in the view life-cycle restore chain
 * Reads back all view data if memento has been set
 *
 * The restore is very restricted an checks that the
 * <li> Project still exists and is open
 * <li> The file is within the project
 * <li> The file size and file date has not changed
 */
private void restoreState() {
    if (memento == null) {
        return;
    }
    // $NON-NLS-1$
    memento = memento.getChild("selection");
    if (memento != null) {
        DetailData detailObject = new DetailData();
        try {
            // $NON-NLS-1$
            IMemento mementoEventObject = memento.getChild("eventObject");
            // $NON-NLS-1$
            detailObject.setName(mementoEventObject.getString("name"));
            // $NON-NLS-1$
            detailObject.setPort(mementoEventObject.getString("port"));
            // $NON-NLS-1$
            detailObject.setLine(mementoEventObject.getString("line"));
            // $NON-NLS-1$
            detailObject.setTestCase(mementoEventObject.getString("testCaseName"));
            // $NON-NLS-1$
            detailObject.setEventType(mementoEventObject.getString("eventType"));
            // $NON-NLS-1$
            detailObject.setSourceInfo(mementoEventObject.getString("sourceInfo"));
            // $NON-NLS-1$
            long fileSize = Long.parseLong(mementoEventObject.getString("fileSize"));
            // $NON-NLS-1$
            long fileModification = Long.parseLong(mementoEventObject.getString("fileModification"));
            // retrieve logfilemetaData
            // $NON-NLS-1$
            String propertyFilePath = mementoEventObject.getString("propertyFile");
            if (propertyFilePath != null) {
                File propertyFile = new File(propertyFilePath);
                if (!propertyFile.exists()) {
                    return;
                }
                logFileMetaData = LogFileCacheHandler.logFileMetaDataReader(propertyFile);
            }
            IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(logFileMetaData.getProjectName());
            if (project != null && project.exists() && project.isOpen()) {
                Path path = new Path(logFileMetaData.getProjectRelativePath());
                IFile logFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
                if (logFile != null && logFile.getProject().getName().equals(project.getName()) && logFile.exists()) {
                    File file = logFile.getLocation().toFile();
                    if (file.lastModified() == fileModification && file.length() == fileSize) {
                        // $NON-NLS-1$
                        Integer silentEvent = mementoEventObject.getInteger("isSilentEvent");
                        this.textView = getTextView();
                        if (silentEvent == 1) {
                            this.useFormatting = true;
                            this.textView.setUseFormatting(false);
                        } else {
                            this.useFormatting = false;
                            this.textView.setUseFormatting(true);
                        }
                        setData(detailObject, this.useFormatting);
                    }
                }
            }
        } catch (final IOException e) {
            ErrorReporter.logExceptionStackTrace(e);
        } catch (final ClassNotFoundException e) {
            ErrorReporter.logExceptionStackTrace(e);
        }
    }
    memento = null;
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IOException(java.io.IOException) IFile(org.eclipse.core.resources.IFile) File(java.io.File) DetailData(org.eclipse.titan.log.viewer.views.details.DetailData) IMemento(org.eclipse.ui.IMemento) IProject(org.eclipse.core.resources.IProject)

Aggregations

IFile (org.eclipse.core.resources.IFile)3 IProject (org.eclipse.core.resources.IProject)3 DetailData (org.eclipse.titan.log.viewer.views.details.DetailData)3 IOException (java.io.IOException)2 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)2 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)2 LogFileMetaData (org.eclipse.titan.log.viewer.models.LogFileMetaData)2 LogRecord (org.eclipse.titan.log.viewer.parsers.data.LogRecord)2 DetailsView (org.eclipse.titan.log.viewer.views.DetailsView)2 EventObject (org.eclipse.titan.log.viewer.views.msc.model.EventObject)2 IViewReference (org.eclipse.ui.IViewReference)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 PartInitException (org.eclipse.ui.PartInitException)2 File (java.io.File)1 ParseException (java.text.ParseException)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 Path (org.eclipse.core.runtime.Path)1 MSCView (org.eclipse.titan.log.viewer.views.MSCView)1 ExecutionModel (org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel)1