Search in sources :

Example 1 with TimeInterval

use of org.eclipse.titan.log.viewer.models.TimeInterval 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 2 with TimeInterval

use of org.eclipse.titan.log.viewer.models.TimeInterval in project titan.EclipsePlug-ins by eclipse.

the class MSCFilterDialog method okPressed.

@Override
protected void okPressed() {
    if (!changed) {
        setReturnCode(OK);
        close();
        return;
    }
    for (TreeItem item : checkTree.getItems()) {
        filterPattern.getEventsToFilter().put((String) item.getData(), item.getChecked());
    }
    filterPattern.setInclusive(inclusiveButton.getSelection());
    Map<Field, Boolean> fieldsToFilter = new HashMap<Field, Boolean>();
    fieldsToFilter.put(Field.SOURCE_INFO, sourceInfoButton.getSelection());
    fieldsToFilter.put(Field.MESSAGE, messageButton.getSelection());
    filterPattern.setFilterExpression(filterStringBox.getText(), fieldsToFilter, isCaseSensitiveButton.getSelection(), isRegularExpressionButton.getSelection());
    filterPattern.setCaseSensitive(isCaseSensitiveButton.getSelection());
    filterPattern.setRegularExpression(isRegularExpressionButton.getSelection());
    filterPattern.setTimeInterval(new TimeInterval(startTimestamp.getText(), endTimestamp.getText(), filterPattern.getTimeInterval().getTimeStampFormat()));
    setReturnCode(OK);
    close();
}
Also used : Field(org.eclipse.titan.log.viewer.models.FilterPattern.Field) TimeInterval(org.eclipse.titan.log.viewer.models.TimeInterval) TreeItem(org.eclipse.swt.widgets.TreeItem) HashMap(java.util.HashMap)

Aggregations

TimeInterval (org.eclipse.titan.log.viewer.models.TimeInterval)2 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 HashMap (java.util.HashMap)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 TreeItem (org.eclipse.swt.widgets.TreeItem)1 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)1 FilterPattern (org.eclipse.titan.log.viewer.models.FilterPattern)1 Field (org.eclipse.titan.log.viewer.models.FilterPattern.Field)1 MSCFilterDialog (org.eclipse.titan.log.viewer.views.MSCFilterDialog)1