Search in sources :

Example 1 with DetailsView

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

use of org.eclipse.titan.log.viewer.views.DetailsView 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 3 with DetailsView

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

the class CloseAllAction method run.

@Override
public void run() {
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IViewReference[] viewReferences = activePage.getViewReferences();
    for (IViewReference reference : viewReferences) {
        IViewPart view = reference.getView(false);
        // memento restored views that never have had focus are null!!!
        if (view == null) {
            activePage.hideView(reference);
        } else if (view instanceof TextTableView) {
            activePage.hideView(reference);
        }
    }
    // Clear Details View if needed
    DetailsView detailsView = (DetailsView) activePage.findView(Constants.DETAILS_VIEW_ID);
    if (detailsView != null && "".equals(detailsView.getTestCaseName())) {
        detailsView.setData(null, false);
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) DetailsView(org.eclipse.titan.log.viewer.views.DetailsView) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 4 with DetailsView

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

the class TextTableView method dispose.

@Override
public void dispose() {
    if (this.cachedLogReader != null) {
        this.cachedLogReader.close();
    }
    if (this.filteredLogReader != null) {
        this.filteredLogReader.close();
    }
    // Clear Details View if needed
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (activePage != null) {
        DetailsView detailsView = (DetailsView) activePage.findView(Constants.DETAILS_VIEW_ID);
        if ((detailsView != null) && (this.selectedEventObject != null)) {
            URI dvFullPath = detailsView.getFullPath();
            URI ttFullPath = this.logFileMetaData.getFilePath();
            if ((dvFullPath != null) && (ttFullPath != null) && dvFullPath.equals(ttFullPath)) {
                detailsView.setData(null, false);
            }
        }
    }
    super.dispose();
}
Also used : DetailsView(org.eclipse.titan.log.viewer.views.DetailsView) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) URI(java.net.URI)

Example 5 with DetailsView

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

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