Search in sources :

Example 1 with MSCFilterDialog

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

Aggregations

IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)1 FilterPattern (org.eclipse.titan.log.viewer.models.FilterPattern)1 TimeInterval (org.eclipse.titan.log.viewer.models.TimeInterval)1 MSCFilterDialog (org.eclipse.titan.log.viewer.views.MSCFilterDialog)1