Search in sources :

Example 1 with TextTableView

use of org.eclipse.titan.log.viewer.views.text.table.TextTableView in project titan.EclipsePlug-ins by eclipse.

the class LogSearchResultPage method showMatch.

@Override
protected void showMatch(final Match match, final int currentOffset, final int currentLength, final boolean activate) throws PartInitException {
    IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
    if (!selection.toList().contains(match)) {
        treeViewer.setSelection(new StructuredSelection(match));
    }
    IFile logFile = (IFile) match.getElement();
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    TextTableView openedView;
    IViewReference viewReference = activePage.findViewReference(Constants.TEXT_TABLE_VIEW_ID, logFile.getFullPath().toOSString());
    if (viewReference == null) {
        openTextTableView(logFile, match.getOffset());
        return;
    }
    TextTableView view = (TextTableView) viewReference.getView(false);
    if (view != null && view.isFiltered() && !view.contains(match.getOffset())) {
        MessageBox mb = new MessageBox(this.getSite().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
        mb.setText("Filtered match");
        mb.setMessage("The selected record can not be displayed in the opened TextTableView." + " Would you like to open a new view? (The old one will be closed)");
        switch(mb.open()) {
            case SWT.YES:
                activePage.hideView(viewReference);
                openTextTableView(logFile, match.getOffset());
                break;
            case SWT.NO:
                break;
            default:
                return;
        }
        return;
    }
    openedView = (TextTableView) activePage.showView(Constants.TEXT_TABLE_VIEW_ID, logFile.getFullPath().toOSString(), org.eclipse.ui.IWorkbenchPage.VIEW_VISIBLE);
    openedView.setSelectedRecord(match.getOffset());
}
Also used : IFile(org.eclipse.core.resources.IFile) IViewReference(org.eclipse.ui.IViewReference) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TextTableView(org.eclipse.titan.log.viewer.views.text.table.TextTableView) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 2 with TextTableView

use of org.eclipse.titan.log.viewer.views.text.table.TextTableView in project titan.EclipsePlug-ins by eclipse.

the class MSCView method createPartControl.

@Override
public void createPartControl(final Composite c) {
    // restores any saved state
    final WorkspaceJob job = restoreState();
    if (this.problemDuringRestore) {
        Label text = new Label(c, SWT.LEFT);
        // $NON-NLS-1$
        text.setText(Messages.getString("MSCView.0"));
        return;
    }
    Composite parent = new Composite(c, SWT.NONE);
    GridLayout parentLayout = new GridLayout();
    parentLayout.numColumns = 1;
    parentLayout.marginWidth = 0;
    parentLayout.marginHeight = 0;
    parent.setLayout(parentLayout);
    GridData seqDiagLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
    this.mscWidget = new MSCWidget(parent, SWT.NONE);
    this.mscWidget.setLayoutData(seqDiagLayoutData);
    this.mscWidget.setDragAutoScroll(false);
    this.mscWidget.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(final KeyEvent e) {
            if (e.keyCode != SWT.CR) {
                return;
            }
            PreferencesHolder preferences = PreferencesHandler.getInstance().getPreferences(MSCView.this.logFileMetaData.getProjectName());
            int defaultBehaviour = preferences.getMscViewDefault();
            if (defaultBehaviour == PreferenceConstants.DEFAULT_TEXT) {
                MSCView.this.openTextTable.run();
            } else {
                MSCView.this.openValueView.run();
            }
        }
    });
    this.mscWidget.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(final MouseEvent e) {
            PreferencesHolder preferences = PreferencesHandler.getInstance().getPreferences(MSCView.this.logFileMetaData.getProjectName());
            int defaultBehaviour = preferences.getMscViewDefault();
            if (defaultBehaviour == PreferenceConstants.DEFAULT_TEXT) {
                MSCView.this.openTextTable.run();
            } else {
                MSCView.this.openValueView.run();
            }
        }
    });
    this.mscWidget.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            if (!(event.getSelection() instanceof IStructuredSelection)) {
                return;
            }
            if (MSCView.this.model == null) {
                return;
            }
            final IFile logFile = MSCView.this.model.getTestCase().getLogFile();
            if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
                LogFileCacheHandler.handleLogFileChange(logFile);
                return;
            }
            final IStructuredSelection structuredSelection = (IStructuredSelection) event.getSelection();
            final IViewReference[] viewReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
            if (MSCView.this.logFileMetaData == null) {
                return;
            }
            for (IViewReference viewReference : viewReferences) {
                final IViewPart viewPart = viewReference.getView(false);
                if (viewPart instanceof TextTableView && ((TextTableView) viewPart).getLogFileMetaData() != null && MSCView.this.logFileMetaData.getFilePath().equals(((TextTableView) viewPart).getLogFileMetaData().getFilePath())) {
                    final Integer selectedLine = (Integer) structuredSelection.getFirstElement();
                    final int recordNumber = MSCView.this.model.getEvent(selectedLine - 2).getRecordNumber();
                    TextTableView textTableView = (TextTableView) viewPart;
                    if (textTableView.getSelectedRecord() != null && textTableView.getSelectedRecord().getRecordNumber() != recordNumber) {
                        textTableView.setSelectedRecord(recordNumber);
                    }
                    break;
                }
            }
            silentOpenSource.delayedRun(event.getSelection());
            silentOpenValueView.delayedRun(event.getSelection());
        }
    });
    createCoolbarContent();
    hookContextMenu();
    parent.layout(true);
    WorkspaceJob job2 = new WorkspaceJob("Displaying loaded log information") {

        @Override
        public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
            if (job == null) {
                return Status.OK_STATUS;
            }
            try {
                job.join();
            } catch (InterruptedException e) {
                return Status.CANCEL_STATUS;
            }
            // Check if model was restored
            if ((MSCView.this.logFileMetaData != null) && (MSCView.this.model != null)) {
                // always open restore at top
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        setModel(MSCView.this.model, MSCView.this.restoredSelection);
                    }
                });
            }
            return Status.OK_STATUS;
        }
    };
    job2.setSystem(true);
    job2.schedule();
}
Also used : IViewPart(org.eclipse.ui.IViewPart) MouseEvent(org.eclipse.swt.events.MouseEvent) IFile(org.eclipse.core.resources.IFile) Composite(org.eclipse.swt.widgets.Composite) MSCWidget(org.eclipse.titan.log.viewer.views.msc.ui.view.MSCWidget) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) KeyEvent(org.eclipse.swt.events.KeyEvent) PreferencesHolder(org.eclipse.titan.log.viewer.preferences.PreferencesHolder) GridLayout(org.eclipse.swt.layout.GridLayout) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IViewReference(org.eclipse.ui.IViewReference) GridData(org.eclipse.swt.layout.GridData) TextTableView(org.eclipse.titan.log.viewer.views.text.table.TextTableView)

Example 3 with TextTableView

use of org.eclipse.titan.log.viewer.views.text.table.TextTableView 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 4 with TextTableView

use of org.eclipse.titan.log.viewer.views.text.table.TextTableView in project titan.EclipsePlug-ins by eclipse.

the class LogSearchResultPage method openTextTableView.

private TextTableView openTextTableView(final IFile logFile, final int recordToSelect) {
    try {
        TextTableView part = (TextTableView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(Constants.TEXT_TABLE_VIEW_ID, logFile.getFullPath().toOSString(), IWorkbenchPage.VIEW_VISIBLE);
        part.setInput(logFile, recordToSelect);
        return part;
    } catch (IOException e) {
        ErrorReporter.logExceptionStackTrace(e);
        // $NON-NLS-1$
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableProjectsViewMenuAction.5") + e.getMessage()));
    } catch (PartInitException e) {
        ErrorReporter.logExceptionStackTrace(e);
        // $NON-NLS-1$
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableProjectsViewMenuAction.6") + e.getMessage()));
    } catch (ClassNotFoundException e) {
        ErrorReporter.logExceptionStackTrace(e);
        // $NON-NLS-1$
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableProjectsViewMenuAction.7") + e.getMessage()));
    }
    return null;
}
Also used : TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) IOException(java.io.IOException) PartInitException(org.eclipse.ui.PartInitException) TextTableView(org.eclipse.titan.log.viewer.views.text.table.TextTableView)

Aggregations

TextTableView (org.eclipse.titan.log.viewer.views.text.table.TextTableView)4 IFile (org.eclipse.core.resources.IFile)3 IViewReference (org.eclipse.ui.IViewReference)3 IOException (java.io.IOException)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 PartInitException (org.eclipse.ui.PartInitException)2 ParseException (java.text.ParseException)1 IProject (org.eclipse.core.resources.IProject)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 KeyAdapter (org.eclipse.swt.events.KeyAdapter)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1