Search in sources :

Example 1 with MSCView

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

the class OpenMSCViewMenuAction method showView.

private void showView(final ExecutionModel model, final Parser parser, final TestCase tc) {
    final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    final String viewId = Constants.MSC_VIEW_ID;
    final String secondId = generateSecondaryViewId(tc, this.logFileMetaData);
    IViewReference reference = activePage.findViewReference(viewId, secondId);
    MSCView part = null;
    // Get the view
    if (reference != null) {
        part = (MSCView) reference.getView(false);
    }
    // If something is wrong, close the view
    if (part != null) {
        activePage.hideView(part);
    }
    // Create the new view
    try {
        part = (MSCView) activePage.showView(viewId, secondId, IWorkbenchPage.VIEW_ACTIVATE);
    } catch (PartInitException e) {
        ErrorReporter.logExceptionStackTrace(e);
        TitanLogExceptionHandler.handleException(new TechnicalException(// $NON-NLS-1$
        Messages.getString("OpenMSCViewMenuAction.3") + e.getMessage()));
        return;
    }
    part.setLogFileMetaData(OpenMSCViewMenuAction.this.logFileMetaData);
    final PreferencesHolder preferences = PreferencesHandler.getInstance().getPreferences(this.logFileMetaData.getProjectName());
    part.setModel(model, getFirstRowToSelect(preferences, model));
}
Also used : PreferencesHolder(org.eclipse.titan.log.viewer.preferences.PreferencesHolder) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) IViewReference(org.eclipse.ui.IViewReference) MSCView(org.eclipse.titan.log.viewer.views.MSCView) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException)

Example 2 with MSCView

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

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

the class TextTableViewHelper method updateSelectionInConnectedMscView.

static void updateSelectionInConnectedMscView(int selectedRecord, LogFileMetaData fileMetaData) {
    final IViewReference[] viewReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
    for (IViewReference viewReference : viewReferences) {
        final IViewPart viewPart = viewReference.getView(false);
        if (!(viewPart instanceof MSCView)) {
            continue;
        }
        final MSCView mscView = (MSCView) viewPart;
        if (mscView.getModel() == null || mscView.getModel().getTestCase() == null) {
            continue;
        }
        final TestCase testCase = mscView.getModel().getTestCase();
        if (fileMetaData.getFilePath().equals((mscView).getLogFileMetaData().getFilePath()) && testCase.getStartRecordNumber() <= selectedRecord && testCase.getEndRecordNumber() >= selectedRecord) {
            if (mscView.getSelectedRecordNumber() != selectedRecord) {
                mscView.setSelection(selectedRecord);
            }
            // Only one MSC view can be opened for one test case
            break;
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) TestCase(org.eclipse.titan.log.viewer.parsers.data.TestCase) IViewReference(org.eclipse.ui.IViewReference) MSCView(org.eclipse.titan.log.viewer.views.MSCView)

Aggregations

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