Search in sources :

Example 6 with TechnicalException

use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.

the class FilterAction method run.

@Override
public void run() {
    if (isFilterRunning) {
        MessageBox msgBox = new MessageBox(textTableView.getSite().getShell());
        msgBox.setMessage("The filter is already running!");
        msgBox.setText("Filter");
        msgBox.open();
        return;
    }
    isFilterRunning = true;
    if (textTableView.getFilterPattern() == null) {
        textTableView.setFilterPattern(new FilterPattern(new TimeInterval("", "", textTableView.getLogFileMetaData().getTimeStampFormat())));
        SortedMap<String, Boolean> eventsToFilter = new TreeMap<String, Boolean>();
        for (Map.Entry<String, String[]> entry : Constants.EVENT_CATEGORIES.entrySet()) {
            eventsToFilter.put(entry.getKey(), true);
        }
        textTableView.getFilterPattern().setEventsToFilter(eventsToFilter, true, false);
    }
    MSCFilterDialog dialog = new MSCFilterDialog(textTableView.getSite().getShell(), textTableView.getFilterPattern());
    if (dialog.open() == 0 && dialog.getChanged() && !dialog.getFilterPattern().equals(textTableView.getFilterPattern())) {
        final FilterPattern tmpFilterPattern = dialog.getFilterPattern();
        WorkspaceJob op = new WorkspaceJob("Filtering") {

            @Override
            public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
                try {
                    textTableView.getFilteredLogReader().runFilter(tmpFilterPattern, monitor);
                } catch (IOException e) {
                    ErrorReporter.logExceptionStackTrace(e);
                    // $NON-NLS-1$
                    TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("TextTableModel.6") + e.getMessage()));
                    monitor.setCanceled(true);
                } catch (ParseException e) {
                    ErrorReporter.logExceptionStackTrace(e);
                    // $NON-NLS-1$
                    TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("TextTableModel.7") + e.getMessage()));
                    monitor.setCanceled(true);
                }
                if (monitor.isCanceled()) {
                    monitor.done();
                    Display.getDefault().asyncExec(new Runnable() {

                        @Override
                        public void run() {
                            isFilterRunning = false;
                            textTableView.getTable().setEnabled(true);
                        }
                    });
                    monitor.done();
                    return Status.CANCEL_STATUS;
                }
                monitor.done();
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        textTableView.setFilterPattern(tmpFilterPattern);
                        textTableView.refreshTable();
                        isFilterRunning = false;
                        textTableView.getTable().setEnabled(true);
                    }
                });
                return Status.OK_STATUS;
            }
        };
        op.setPriority(Job.LONG);
        op.setSystem(false);
        op.setUser(true);
        op.setRule(ResourcesPlugin.getWorkspace().getRoot());
        op.setProperty(IProgressConstants.ICON_PROPERTY, Activator.getImageDescriptor("titan.gif"));
        textTableView.getTable().setEnabled(false);
        op.schedule();
    } else {
        isFilterRunning = false;
    }
}
Also used : TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) TimeInterval(org.eclipse.titan.log.viewer.models.TimeInterval) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) IOException(java.io.IOException) TreeMap(java.util.TreeMap) MessageBox(org.eclipse.swt.widgets.MessageBox) MSCFilterDialog(org.eclipse.titan.log.viewer.views.MSCFilterDialog) FilterPattern(org.eclipse.titan.log.viewer.models.FilterPattern) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ParseException(java.text.ParseException) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap)

Example 7 with TechnicalException

use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.

the class LogSearchPage method getLogFilesFromResource.

private void getLogFilesFromResource(final IResource resource, final List<IFile> files) {
    if (resource == null || files == null) {
        return;
    }
    if (resource instanceof IFile) {
        IFile myFile = (IFile) resource;
        if (isValidLogFile(myFile) && !files.contains(myFile)) {
            files.add((IFile) resource);
        }
    } else if (resource instanceof IContainer) {
        try {
            if (resource instanceof IProject) {
                IProject project = (IProject) resource;
                if (!project.isOpen() || project.getNature(Constants.NATURE_ID) == null) {
                    return;
                }
            }
            for (IResource r : ((IContainer) resource).members()) {
                getLogFilesFromResource(r, files);
            }
        } catch (CoreException e) {
            ErrorReporter.logExceptionStackTrace(e);
            TitanLogExceptionHandler.handleException(// $NON-NLS-1$
            new TechnicalException(Messages.getString("Could not collect the log files. Reason: ") + e.getMessage()));
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) CoreException(org.eclipse.core.runtime.CoreException) IContainer(org.eclipse.core.resources.IContainer) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource)

Example 8 with TechnicalException

use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.

the class LogSearchResultPage method configureTreeViewer.

@Override
protected void configureTreeViewer(final TreeViewer viewer) {
    treeViewer = viewer;
    contentProvider = new TreeContentProvider(this);
    viewer.setContentProvider(contentProvider);
    viewer.setLabelProvider(new SearchLabelProvider());
    viewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
    treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            try {
                Object selectedElement = ((TreeSelection) event.getSelection()).getFirstElement();
                if (selectedElement instanceof Match) {
                    showMatch((Match) selectedElement, 0, 0, true);
                    return;
                }
            } catch (PartInitException e) {
                ErrorReporter.logExceptionStackTrace(e);
                // $NON-NLS-1$
                TitanLogExceptionHandler.handleException(new TechnicalException("Could not show the selected match. Reason: " + e.getMessage()));
            }
        }
    });
}
Also used : TreeContentProvider(org.eclipse.titan.log.viewer.search.TreeContentProvider) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) SearchLabelProvider(org.eclipse.titan.log.viewer.search.SearchLabelProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) PartInitException(org.eclipse.ui.PartInitException) Match(org.eclipse.search.ui.text.Match)

Example 9 with TechnicalException

use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.

the class TextTableViewHelper method open.

/**
 * Opens a TextTable view for the given log file. If the view is already open
 * the record with the number recordToSelect will be selected.
 * @param projectName The name of the logfile's project.
 * @param projectRelativePath The project relative path of the log file
 * @param recordToSelect The number of the record that will be initially selected.
 * @return The newly created view or null if the view can not be opened.
 */
public static TextTableView open(final String projectName, final String projectRelativePath, final int recordToSelect) {
    String secondId = projectRelativePath;
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IViewReference reference = activePage.findViewReference(Constants.TEXT_TABLE_VIEW_ID, secondId);
    if (reference != null) {
        try {
            TextTableView view = (TextTableView) activePage.showView(Constants.TEXT_TABLE_VIEW_ID, secondId, IWorkbenchPage.VIEW_ACTIVATE);
            view.setSelectedRecord(recordToSelect);
            view.setFocus();
            return view;
        } catch (PartInitException e) {
        // do nothing
        }
    }
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    IProject project = root.getProject(projectName);
    final IFile logFile = project.getFile(projectRelativePath.substring(projectName.length() + 1));
    if (!logFile.exists()) {
        IViewReference[] viewReferences = activePage.getViewReferences();
        ActionUtils.closeAssociatedViews(activePage, viewReferences, logFile);
        // $NON-NLS-1$
        TitanLogExceptionHandler.handleException(new UserException(Messages.getString("OpenMSCViewMenuAction.4")));
        return null;
    }
    try {
        Object temp = logFile.getSessionProperty(Constants.EXTRACTION_RUNNING);
        if (temp != null && (Boolean) temp) {
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    MessageDialog.openInformation(null, "View can not be opened.", "Test case extraction is already running on " + logFile.getName());
                }
            });
            return null;
        }
    } catch (CoreException e) {
        ErrorReporter.logExceptionStackTrace(e);
        TitanLogExceptionHandler.handleException(new UserException(e.getMessage()));
    }
    if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
        LogFileCacheHandler.handleLogFileChange(logFile);
        return null;
    }
    try {
        TextTableView view = (TextTableView) activePage.showView(Constants.TEXT_TABLE_VIEW_ID, secondId, IWorkbenchPage.VIEW_ACTIVATE);
        view.setInput(logFile, recordToSelect);
        view.setFocus();
        return view;
    } catch (FileNotFoundException e) {
        ErrorReporter.logExceptionStackTrace(e);
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableTestCasesViewMenuAction.0") + e.getMessage()));
    } catch (IOException e) {
        ErrorReporter.logExceptionStackTrace(e);
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableTestCasesViewMenuAction.1") + e.getMessage()));
    } catch (PartInitException e) {
        ErrorReporter.logExceptionStackTrace(e);
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableTestCasesViewMenuAction.2") + e.getMessage()));
    } catch (ClassNotFoundException e) {
        ErrorReporter.logExceptionStackTrace(e);
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableTestCasesViewMenuAction.2") + e.getMessage()));
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) IViewReference(org.eclipse.ui.IViewReference) IWorkspace(org.eclipse.core.resources.IWorkspace) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) UserException(org.eclipse.titan.log.viewer.exceptions.UserException)

Example 10 with TechnicalException

use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.

the class Activator method getCachedResource.

/**
 * Return the resource asked for, if the resource is not found in the cache, it will be created
 * @param key the resource key
 * @return resource the resource
 */
public Resource getCachedResource(final RGB color) {
    String key = String.valueOf(color.red) + PreferenceConstants.RGB_COLOR_SEPARATOR + String.valueOf(color.green) + PreferenceConstants.RGB_COLOR_SEPARATOR + String.valueOf(color.blue);
    if (this.guiResourceCache.containsKey(key)) {
        return this.guiResourceCache.get(key);
    }
    Resource resource = new Color(Display.getDefault(), color);
    // $NON-NLS-1$
    TitanLogExceptionHandler.handleException(new TechnicalException("Resource could not be found"));
    return addResource(key, resource);
}
Also used : TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) Color(org.eclipse.swt.graphics.Color) Resource(org.eclipse.swt.graphics.Resource)

Aggregations

TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)33 IOException (java.io.IOException)18 IFile (org.eclipse.core.resources.IFile)16 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)10 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)10 File (java.io.File)9 IViewReference (org.eclipse.ui.IViewReference)8 CoreException (org.eclipse.core.runtime.CoreException)7 PartInitException (org.eclipse.ui.PartInitException)7 ParseException (java.text.ParseException)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 IProject (org.eclipse.core.resources.IProject)5 PreferencesHolder (org.eclipse.titan.log.viewer.preferences.PreferencesHolder)5 FileNotFoundException (java.io.FileNotFoundException)4 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)4 LogFileMetaData (org.eclipse.titan.log.viewer.models.LogFileMetaData)4 TestCase (org.eclipse.titan.log.viewer.parsers.data.TestCase)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 Map (java.util.Map)3