use of org.eclipse.titan.log.viewer.models.FilterPattern 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;
}
}
use of org.eclipse.titan.log.viewer.models.FilterPattern in project titan.EclipsePlug-ins by eclipse.
the class SearchPattern method create.
public static SearchPattern create(final IDialogSettings settings) {
String loadedSearchString = settings.get("searchString");
boolean loadedIsCaseSensitive = settings.getBoolean("isCaseSensitive");
boolean loadedIsRegularExpression = settings.getBoolean("isRegularExpression");
SortedMap<String, Boolean> loadedEvents = new TreeMap<String, Boolean>();
for (String entry : Constants.EVENT_CATEGORIES.keySet()) {
loadedEvents.put(entry, settings.getBoolean(entry));
}
Map<Field, Boolean> loadedLimitTo = new HashMap<Field, Boolean>();
loadedLimitTo.put(Field.SOURCE_INFO, settings.getBoolean(Field.SOURCE_INFO.toString()));
loadedLimitTo.put(Field.MESSAGE, settings.getBoolean(Field.MESSAGE.toString()));
FilterPattern loadedFilterPattern = new FilterPattern(loadedSearchString, loadedLimitTo, loadedIsCaseSensitive, loadedIsRegularExpression);
loadedFilterPattern.setEventsToFilter(loadedEvents, true, false);
// $NON-NLS-1$
String[] wsIds = settings.getArray("workingSets");
IWorkingSet[] workingSets = null;
if (wsIds != null && wsIds.length > 0) {
IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
workingSets = new IWorkingSet[wsIds.length];
for (int i = 0; workingSets != null && i < wsIds.length; i++) {
workingSets[i] = workingSetManager.getWorkingSet(wsIds[i]);
if (workingSets[i] == null) {
workingSets = null;
}
}
}
return new SearchPattern(loadedFilterPattern, settings.getInt("scope"), workingSets);
}
Aggregations