Search in sources :

Example 16 with TestCase

use of org.eclipse.titan.log.viewer.parsers.data.TestCase in project titan.EclipsePlug-ins by eclipse.

the class SwitchToMscAction method run.

@Override
public void run() {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    LogFileMetaData logFileMetaData = textTableView.getLogFileMetaData();
    IProject project = root.getProject(logFileMetaData.getProjectName());
    IFile logFile = project.getFile(logFileMetaData.getProjectRelativePath().substring(logFileMetaData.getProjectName().length() + 1));
    if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
        LogFileCacheHandler.handleLogFileChange(logFile);
        return;
    }
    final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    TestCaseExtractor extractor = new TestCaseExtractor();
    try {
        extractor.extractTestCasesFromIndexedLogFile(logFile);
    } catch (IOException e) {
        ErrorReporter.logExceptionStackTrace(e);
        MessageBox mb = new MessageBox(activePage.getActivePart().getSite().getShell(), SWT.ICON_ERROR | SWT.OK);
        mb.setText("Test case extraction failed.");
        mb.setMessage("Error while extracting the test cases.");
        return;
    } catch (ClassNotFoundException e) {
        ErrorReporter.logExceptionStackTrace(e);
        MessageBox mb = new MessageBox(activePage.getActivePart().getSite().getShell(), SWT.ICON_ERROR | SWT.OK);
        mb.setText("Test case extraction failed.");
        mb.setMessage("Error while extracting the test cases.");
        return;
    }
    List<TestCase> testCases = extractor.getTestCases();
    if (textTableView.getSelectedRecord() == null) {
        MessageBox mb = new MessageBox(activePage.getActivePart().getSite().getShell(), SWT.ICON_ERROR | SWT.OK);
        mb.setText("Invalid selection.");
        mb.setMessage("Please select a record to open the MSC view.");
        return;
    }
    int recordNumber = textTableView.getSelectedRecord().getRecordNumber();
    int testCaseNumber = findContainingTestCase(testCases, recordNumber);
    if (testCaseNumber == -1) {
        MessageBox mb = new MessageBox(activePage.getActivePart().getSite().getShell(), SWT.ICON_ERROR | SWT.OK);
        mb.setText("Testcase can not be found.");
        mb.setMessage("The testcase containing the selected log record can not be found.");
        return;
    }
    final OpenMSCViewAction openMSCAction = new OpenMSCViewAction();
    openMSCAction.selectionChanged(null, new StructuredSelection(testCases.get(testCaseNumber)));
    openMSCAction.setFirstRow(recordNumber);
    openMSCAction.run();
}
Also used : IFile(org.eclipse.core.resources.IFile) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) OpenMSCViewAction(org.eclipse.titan.log.viewer.actions.OpenMSCViewAction) TestCaseExtractor(org.eclipse.titan.log.viewer.extractors.TestCaseExtractor) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) MessageBox(org.eclipse.swt.widgets.MessageBox) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) LogFileMetaData(org.eclipse.titan.log.viewer.models.LogFileMetaData) TestCase(org.eclipse.titan.log.viewer.parsers.data.TestCase) IWorkspace(org.eclipse.core.resources.IWorkspace) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 17 with TestCase

use of org.eclipse.titan.log.viewer.parsers.data.TestCase 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)

Example 18 with TestCase

use of org.eclipse.titan.log.viewer.parsers.data.TestCase in project titan.EclipsePlug-ins by eclipse.

the class MSCView method saveState.

@Override
public void saveState(final IMemento memento) {
    // Do not save empty views
    if (this.model == null) {
        return;
    }
    // $NON-NLS-1$
    IMemento tempMemento = memento.createChild("mscview");
    try {
        // $NON-NLS-1$
        IMemento viewAttributes = tempMemento.createChild("attributes");
        // Save state to be able to restore logfilemetaData
        Path filePath = new Path(this.logFileMetaData.getProjectRelativePath());
        IFile logFile = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
        // Store project name
        // $NON-NLS-1$
        viewAttributes.putString("projectName", this.logFileMetaData.getProjectName());
        if ((logFile != null) && logFile.exists()) {
            // Store property file
            // $NON-NLS-1$
            viewAttributes.putString("propertyFile", LogFileCacheHandler.getPropertyFileForLogFile(logFile).getAbsolutePath());
            File aLogFile = logFile.getLocation().toFile();
            // $NON-NLS-1$
            viewAttributes.putString("fileSize", String.valueOf(aLogFile.length()));
            // $NON-NLS-1$
            viewAttributes.putString("fileModification", String.valueOf(aLogFile.lastModified()));
        }
        // Store test case number
        TestCase testCase = this.model.getTestCase();
        // $NON-NLS-1$
        viewAttributes.putInteger("testCaseNumber", testCase.getTestCaseNumber());
        // Store current selection
        if (this.mscWidget != null && this.mscWidget.getFrame() != null) {
            // $NON-NLS-1$
            viewAttributes.putInteger("rowSelection", this.mscWidget.getFrame().getSelectedLine());
        } else {
            // $NON-NLS-1$
            viewAttributes.putInteger("rowSelection", 0);
        }
    } catch (Exception e) {
        ErrorReporter.logExceptionStackTrace(e);
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) TestCase(org.eclipse.titan.log.viewer.parsers.data.TestCase) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IMemento(org.eclipse.ui.IMemento) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException)

Example 19 with TestCase

use of org.eclipse.titan.log.viewer.parsers.data.TestCase in project titan.EclipsePlug-ins by eclipse.

the class StatisticalView method createTestCaseTable.

private Table createTestCaseTable(final Composite composite) {
    Table testCasesTable = toolkit.createTable(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.VIRTUAL);
    testCasesTable.setHeaderVisible(true);
    testCasesTable.setLinesVisible(true);
    testCasesTable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (e.getSource() instanceof Table) {
                Table table = (Table) e.getSource();
                TableItem tableItem = table.getItem(table.getSelectionIndex());
                Object data = tableItem.getData();
                if (data instanceof TestCase) {
                    StatisticalView.this.testcaseSelection = (TestCase) data;
                } else {
                    StatisticalView.this.testcaseSelection = null;
                }
                fireSelectionChangeEvent();
            }
        }
    });
    testCasesTable.setMenu(hookStatisticalViewTableContextMenu(testCasesTable));
    new TableColumn(testCasesTable, SWT.BORDER);
    createTestCasesColumn(testCasesTable, Messages.getString("StatisticalView.9"), DEFAULT_COLUMN_WIDTH);
    createTestCasesColumn(testCasesTable, Messages.getString("StatisticalView.10"), 5 * DEFAULT_COLUMN_WIDTH);
    createTestCasesColumn(testCasesTable, Messages.getString("StatisticalView.11"), 4 * DEFAULT_COLUMN_WIDTH);
    createTestCasesColumn(testCasesTable, Messages.getString("StatisticalView.12"), 4 * DEFAULT_COLUMN_WIDTH);
    testCasesTable.redraw();
    return testCasesTable;
}
Also used : Table(org.eclipse.swt.widgets.Table) TestCase(org.eclipse.titan.log.viewer.parsers.data.TestCase) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 20 with TestCase

use of org.eclipse.titan.log.viewer.parsers.data.TestCase in project titan.EclipsePlug-ins by eclipse.

the class StatisticalView method setData.

/**
 * Set data for Statistical View
 * @param statisticalDataVector the new data
 */
public void setData(final List<StatisticalData> statisticalDataVector) {
    this.statisticalDataVector = statisticalDataVector;
    if (this.statisticalDataVector.size() > 1) {
        Set<String> keys = cachedSections.keySet();
        for (String currentKey : keys) {
            Section tmpSection = cachedSections.get(currentKey);
            if (tmpSection != null && !tmpSection.isDisposed()) {
                tmpSection.dispose();
            }
        }
        cachedSections.clear();
    }
    for (StatisticalData statisticalData : this.statisticalDataVector) {
        this.logFileMetaData = statisticalData.getLogFileMetaData();
        List<TestCase> tmpTestCases = statisticalData.getTestCaseVector();
        this.reader = statisticalData.getCachedLogFileReader();
        String projectRelativePath = this.logFileMetaData.getProjectRelativePath();
        Section tmpSection = cachedSections.get(projectRelativePath);
        if (tmpSection == null) {
            createSection();
        }
        // Clear all tables before setting the data
        this.amountTable.removeAll();
        this.errorTestCasesTable.removeAll();
        this.failTestCasesTable.removeAll();
        this.testCases.removeAll();
        int noOfPass = 0;
        int noOfFail = 0;
        int noOfInconc = 0;
        int noOfNone = 0;
        int noOfError = 0;
        int noOfCrash = 0;
        // If input is null
        if (tmpTestCases == null) {
            continue;
        }
        int noTotal = tmpTestCases.size();
        for (TestCase tc : tmpTestCases) {
            TableItem tcItem = new TableItem(this.testCases, SWT.BORDER);
            LogRecord record = getLogRecordAtRow(tc.getStartRecordNumber());
            String start = record.getTimestamp();
            record = getLogRecordAtRow(tc.getEndRecordNumber());
            String stop = record.getTimestamp();
            Image image;
            switch(tc.getVerdict()) {
                case Constants.VERDICT_PASS:
                    image = Activator.getDefault().getIcon(Constants.ICONS_PASS);
                    noOfPass++;
                    break;
                case Constants.VERDICT_ERROR:
                    image = Activator.getDefault().getIcon(Constants.ICONS_ERROR);
                    TableItem tcErrorItem = new TableItem(this.errorTestCasesTable, SWT.BORDER);
                    tcErrorItem.setImage(1, image);
                    tcErrorItem.setText(2, tc.getTestCaseName());
                    tcErrorItem.setText(3, start);
                    tcErrorItem.setText(4, stop);
                    tcErrorItem.setData(tc);
                    noOfError++;
                    break;
                case Constants.VERDICT_FAIL:
                    image = Activator.getDefault().getIcon(Constants.ICONS_FAIL);
                    TableItem tcFailItem = new TableItem(this.failTestCasesTable, SWT.BORDER);
                    tcFailItem.setImage(1, image);
                    tcFailItem.setText(2, tc.getTestCaseName());
                    tcFailItem.setText(3, start);
                    tcFailItem.setText(4, stop);
                    tcFailItem.setData(tc);
                    noOfFail++;
                    break;
                case Constants.VERDICT_INCONCLUSIVE:
                    image = Activator.getDefault().getIcon(Constants.ICONS_INCONCLUSIVE);
                    noOfInconc++;
                    break;
                case Constants.VERDICT_NONE:
                    image = Activator.getDefault().getIcon(Constants.ICONS_NONE);
                    noOfNone++;
                    break;
                case Constants.VERDICT_CRASHED:
                    image = Activator.getDefault().getIcon(Constants.ICONS_CRASHED);
                    noOfCrash++;
                    break;
                default:
                    // Could not find image return null
                    image = null;
                    break;
            }
            tcItem.setImage(1, image);
            tcItem.setText(2, tc.getTestCaseName());
            tcItem.setText(3, start);
            tcItem.setText(4, stop);
            tcItem.setData(tc);
        }
        if (this.errorTestCasesTable.getItems().length < 1) {
            this.errorTestCasesTable.setLinesVisible(false);
        } else {
            this.errorTestCasesTable.redraw();
            ecError.setExpanded(true);
        }
        if (this.failTestCasesTable.getItems().length < 1) {
            this.failTestCasesTable.setLinesVisible(false);
        } else {
            this.failTestCasesTable.redraw();
            ecFail.setExpanded(true);
        }
        // Create the statistical row
        TableItem item = new TableItem(this.amountTable, SWT.BORDER);
        item.setText(0, String.valueOf(noTotal));
        item.setText(1, String.valueOf(noOfPass + getPercent(noOfPass, noTotal)));
        item.setText(2, String.valueOf(noOfFail + getPercent(noOfFail, noTotal)));
        item.setText(3, String.valueOf(noOfInconc + getPercent(noOfInconc, noTotal)));
        item.setText(4, String.valueOf(noOfNone + getPercent(noOfNone, noTotal)));
        item.setText(5, String.valueOf(noOfError + getPercent(noOfError, noTotal)));
        item.setText(6, String.valueOf(noOfCrash + getPercent(noOfCrash, noTotal)));
    }
    if (statisticalDataVector.size() > 1) {
        // $NON-NLS-1$
        setPartName("Statistics");
        // $NON-NLS-1$
        setContentDescription("");
    } else if (this.logFileMetaData != null) {
        File file = new File(this.logFileMetaData.getFilePath());
        String fileName = file.getName();
        // Set the name of the part
        setPartName(fileName);
        setContentDescription(this.logFileMetaData.getProjectRelativePath());
    }
    // Finally redraw form
    form.reflow(true);
    form.setRedraw(true);
}
Also used : StatisticalData(org.eclipse.titan.log.viewer.views.details.StatisticalData) TestCase(org.eclipse.titan.log.viewer.parsers.data.TestCase) LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) TableItem(org.eclipse.swt.widgets.TableItem) Image(org.eclipse.swt.graphics.Image) Section(org.eclipse.ui.forms.widgets.Section) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Aggregations

TestCase (org.eclipse.titan.log.viewer.parsers.data.TestCase)20 IFile (org.eclipse.core.resources.IFile)10 File (java.io.File)7 IOException (java.io.IOException)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)5 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)5 ArrayList (java.util.ArrayList)4 CoreException (org.eclipse.core.runtime.CoreException)4 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)4 PreferencesHolder (org.eclipse.titan.log.viewer.preferences.PreferencesHolder)4 IViewReference (org.eclipse.ui.IViewReference)4 ParseException (java.text.ParseException)3 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 TestCaseExtractor (org.eclipse.titan.log.viewer.extractors.TestCaseExtractor)3 LogFileMetaData (org.eclipse.titan.log.viewer.models.LogFileMetaData)3 LogRecordIndex (org.eclipse.titan.log.viewer.models.LogRecordIndex)3 Parser (org.eclipse.titan.log.viewer.parsers.Parser)3 StatisticalData (org.eclipse.titan.log.viewer.views.details.StatisticalData)3