Search in sources :

Example 1 with StatisticalView

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

the class OpenStatisticalViewMenuAction method run.

public void run(final IStructuredSelection selection) {
    this.logFileMetaData = null;
    this.logFileIsSupported = true;
    if (this.selection == null) {
        return;
    }
    Set<IFile> logFiles = new HashSet<IFile>(selection.size());
    for (Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) {
        Object object = iterator.next();
        if (object instanceof IFile) {
            logFiles.add((IFile) object);
        } else if (object instanceof TestCase) {
            logFiles.add(((TestCase) object).getLogFile());
        }
    }
    if (logFiles.isEmpty()) {
        return;
    }
    List<StatisticalData> statisticalDataVector = createStatisticalData(logFiles);
    if (statisticalDataVector == null || statisticalDataVector.isEmpty()) {
        return;
    }
    String secondId = Constants.STATISTICAL_VIEW;
    if (statisticalDataVector.size() < 2) {
        secondId = File.separator + this.logFile.getProject().getName() + File.separator + this.logFile.getProjectRelativePath().toOSString();
    }
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IViewReference reference = activePage.findViewReference(Constants.STATISTICAL_VIEW_ID, secondId);
    // get the view
    if (reference != null) {
        StatisticalView part = (StatisticalView) reference.getView(false);
    }
    // create a new view
    try {
        StatisticalView part = (StatisticalView) activePage.showView(Constants.STATISTICAL_VIEW_ID, secondId, IWorkbenchPage.VIEW_ACTIVATE);
        part.setData(statisticalDataVector);
        part.setFocus();
    } catch (PartInitException e) {
        ErrorReporter.logExceptionStackTrace(e);
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenStatisticalViewMenuAction.0") + e.getMessage()));
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) StatisticalData(org.eclipse.titan.log.viewer.views.details.StatisticalData) TestCase(org.eclipse.titan.log.viewer.parsers.data.TestCase) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) StatisticalView(org.eclipse.titan.log.viewer.views.StatisticalView) PartInitException(org.eclipse.ui.PartInitException) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 IFile (org.eclipse.core.resources.IFile)1 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)1 TestCase (org.eclipse.titan.log.viewer.parsers.data.TestCase)1 StatisticalView (org.eclipse.titan.log.viewer.views.StatisticalView)1 StatisticalData (org.eclipse.titan.log.viewer.views.details.StatisticalData)1 IViewReference (org.eclipse.ui.IViewReference)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 PartInitException (org.eclipse.ui.PartInitException)1