Commit 633838e7 authored by Florian's avatar Florian

Preference if Filter is Case Sensitive. Automatically refreshs filter when preference changes.

parent 1efd172b
......@@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.jface.text;bundle-version="3.10.0",
org.eclipse.ui.editors;bundle-version="3.9.0",
org.eclipse.jdt.core;bundle-version="3.11.0",
org.eclipse.equinox.registry
org.eclipse.equinox.registry,
org.eclipse.swt
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
......
package kieker.tools.eclipse.analysis.helper;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.TreeColumn;
public class FilterModifyListener implements ModifyListener {
TreeViewer viewer;
TreeFilter filter;
Text text;
public FilterModifyListener(TreeViewer viewer, TreeFilter filter, Text text) {
this.viewer = viewer;
this.filter = filter;
this.text = text;
}
public void resetText(){
filter.setSearchText(text.getText());
viewer.refresh();
TreeColumn[] treeColumns = viewer.getTree().getColumns();
for (TreeColumn treeColumn : treeColumns)
treeColumn.pack();
}
@Override
public void modifyText(ModifyEvent e) {
filter.setSearchText(text.getText());
viewer.refresh();
TreeColumn[] treeColumns = viewer.getTree().getColumns();
for (TreeColumn treeColumn : treeColumns)
treeColumn.pack();
}
}
......@@ -17,6 +17,8 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
Properties.OperationRepresentationTypes.SHORT.toString());
store.setDefault(Properties.Names.COMPONENTS.toString(),
Properties.ComponentsRepresentationTypes.SHORT.toString());
store.setDefault(Properties.Names.FILTERCASESENSITIVE.toString(), true);
store.setDefault(Properties.Names.FILTERREGEX.toString(), false);
store.setDefault(Properties.Names.ADDITIONALANALYSIS.toString(), true);
store.setDefault(Properties.Names.TIMESTAMP.toString(), Properties.TimestampTypes.DATE_AND_TIME.toString());
}
......
......@@ -2,11 +2,16 @@ package kieker.tools.eclipse.analysis.helper;
import java.util.regex.Pattern;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import kieker.tools.eclipse.analysis.Activator;
import kieker.tools.eclipse.analysis.model.Properties;
/**
* @author Florian Echternkamp
*/
......@@ -14,18 +19,35 @@ public class TreeFilter extends ViewerFilter {
private String searchString;
private int index;
private boolean caseSensitive;
public TreeFilter() {
index = -1;
this(-1);
}
public TreeFilter(int i) {
index = i;
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(Properties.Names.FILTERCASESENSITIVE.toString())) {
caseSensitive = (boolean) event.getNewValue();
}
}
});
caseSensitive = Activator.getDefault().getPreferenceStore()
.getBoolean(Properties.Names.FILTERCASESENSITIVE.toString());
}
public void setSearchText(String s) {
// ensure that the value can be used for matching
this.searchString = ".*" + Pattern.quote(s) + ".*";
// ensure that the value can be used for matching
s = Pattern.quote(s);
if (!caseSensitive) {
s = "(?i:" + s + ")";
}
this.searchString = ".*" + s + ".*";
}
@Override
......@@ -35,23 +57,24 @@ public class TreeFilter extends ViewerFilter {
}
TreeViewer treeViewer = (TreeViewer) viewer;
if(index == -1){
if (index == -1) {
int numberOfColumns = treeViewer.getTree().getColumnCount();
boolean isMatch = false;
for (int columnIndex = 0; columnIndex < numberOfColumns; columnIndex++) {
ColumnLabelProvider labelProvider = (ColumnLabelProvider)treeViewer.getLabelProvider(columnIndex);
String labelText = labelProvider.getText(element);
isMatch |= labelText.matches(searchString);
}
return isMatch;
boolean isMatch = false;
for (int columnIndex = 0; columnIndex < numberOfColumns; columnIndex++) {
ColumnLabelProvider labelProvider = (ColumnLabelProvider) treeViewer.getLabelProvider(columnIndex);
String labelText = labelProvider.getText(element);
isMatch |= labelText.matches(searchString);
}
return isMatch;
}
if(0 <= index && index < treeViewer.getTree().getColumns().length){
if (0 <= index && index < treeViewer.getTree().getColumns().length) {
ColumnLabelProvider labelProvider = (ColumnLabelProvider) treeViewer.getLabelProvider(index);
String labelText = labelProvider.getText(element);
return labelText.matches(searchString);
}
return false;
}
}
......@@ -11,7 +11,7 @@ import kieker.tools.eclipse.analysis.Activator;
public class Properties {
public enum Names{
TIMEUNIT, OPERATION, COMPONENTS, ADDITIONALANALYSIS, TIMESTAMP
TIMEUNIT, OPERATION, COMPONENTS, ADDITIONALANALYSIS, TIMESTAMP, FILTERREGEX, FILTERCASESENSITIVE
}
public enum TimestampTypes {
......
......@@ -21,8 +21,6 @@ import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
......@@ -42,6 +40,7 @@ import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.part.ViewPart;
import kieker.tools.eclipse.analysis.helper.CallViewerComparator;
import kieker.tools.eclipse.analysis.helper.FilterModifyListener;
import kieker.tools.eclipse.analysis.helper.TreeFilter;
import kieker.tools.eclipse.analysis.model.ColumnDef;
......@@ -90,17 +89,7 @@ public abstract class AbstractJFaceView extends ViewPart {
TreeFilter createFilter(TreeViewer viewer, int col, Text text) {
TreeFilter filter = new TreeFilter(col);
text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
System.out.println(text.getMessage());
filter.setSearchText(text.getText());
viewer.refresh();
}
});
text.addModifyListener(new FilterModifyListener(viewer, filter, text));
return filter;
}
......
......@@ -18,17 +18,23 @@ import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TypedListener;
import kieker.tools.eclipse.analysis.Activator;
import kieker.tools.eclipse.analysis.helper.AggregatedOperationCallViewerComparator;
import kieker.tools.eclipse.analysis.helper.AggregatedTraceViewerComparator;
import kieker.tools.eclipse.analysis.helper.FilterModifyListener;
import kieker.tools.eclipse.analysis.helper.OperationCallViewerComparator;
import kieker.tools.eclipse.analysis.helper.TraceViewerComparator;
import kieker.tools.eclipse.analysis.model.ColumnDef;
import kieker.tools.eclipse.analysis.model.Properties;
import kieker.tools.eclipse.analysis.provider.DataProvider;
import kieker.tools.eclipse.analysis.provider.SelectionProviderIntermediate;
import kieker.tools.eclipse.analysis.provider.content.OperationCallContentProvider;
......@@ -110,6 +116,23 @@ public class AnalysisTreeView extends AbstractJFaceView {
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
String propertyName = event.getProperty();
if (propertyName.equals(Properties.Names.FILTERCASESENSITIVE.toString()) || propertyName.equals(Properties.Names.FILTERREGEX.toString())) {
List<List<Text>> lists = getFilterTextLists();
for(List<Text> list : lists){
for(Text t: list){
Listener[] listener = t.getListeners(SWT.Modify);
if(listener.length > 0){
TypedListener l = (TypedListener) listener[0];
if(l.getEventListener() instanceof FilterModifyListener){
((FilterModifyListener) l.getEventListener()).resetText();
}
}
}
}
}
for (ColumnViewer v : viewerList) {
v.refresh();
}
......
......@@ -31,6 +31,7 @@ public class Messages extends NLS {
public static String AnalysisTreeView_FilterContainer;
public static String PluginPreferencesPage_GroupAppearance;
public static String PluginPreferencesPage_GroupFilter;
public static String PluginPreferencesPage_GroupAnalysis;
public static String PluginPreferencesPage_TimeUnit;
......@@ -49,6 +50,9 @@ public class Messages extends NLS {
public static String PluginPreferencesPage_ComponentsShort;
public static String PluginPreferencesPage_ComponentsLong;
public static String PluginPreferencesPage_FilterRegEx;
public static String PluginPreferencesPage_FilterCaseSensitive;
public static String PluginPreferencesPage_AnalysisAdditional;
public static String PluginPreferencesPage_Timestamps;
......
......@@ -47,7 +47,13 @@ public class PluginPreferencesPage extends FieldEditorPreferencePage implements
entryNamesAndValues = getTimestamps();
addField(new ComboFieldEditor(Properties.Names.TIMESTAMP.toString(), Messages.PluginPreferencesPage_Timestamps, entryNamesAndValues,
appearance));
Group filter = createGroup(composite, Messages.PluginPreferencesPage_GroupFilter);
addField(new BooleanFieldEditor(Properties.Names.FILTERREGEX.toString(), Messages.PluginPreferencesPage_FilterRegEx,
filter));
addField(new BooleanFieldEditor(Properties.Names.FILTERCASESENSITIVE.toString(), Messages.PluginPreferencesPage_FilterCaseSensitive,
filter));
Group analysis = createGroup(composite, Messages.PluginPreferencesPage_GroupAnalysis);
addField(new BooleanFieldEditor(Properties.Names.ADDITIONALANALYSIS.toString(), Messages.PluginPreferencesPage_AnalysisAdditional,
......
......@@ -38,4 +38,7 @@ PluginPreferencesPage_AnalysisAdditional=Activate additional checks during trace
PluginPreferencesPage_Timestamps=Timestamps
AnalysisTreeView_FilterOperations=Filter Operations
AnalysisTreeView_FilterComponents=Filter Components
AnalysisTreeView_FilterContainer=Filter Container
\ No newline at end of file
AnalysisTreeView_FilterContainer=Filter Container
PluginPreferencesPage_GroupFilter=Filter
PluginPreferencesPage_FilterRegEx=Enable Regular Expressions
PluginPreferencesPage_FilterCaseSensitive=Case Sensitive
\ No newline at end of file
......@@ -38,4 +38,7 @@ PluginPreferencesPage_AnalysisAdditional=Aktiviere weitere
PluginPreferencesPage_Timestamps=Zeitstempel
AnalysisTreeView_FilterOperations=Filter Methoden
AnalysisTreeView_FilterComponents=Filter Komponenten
AnalysisTreeView_FilterContainer=Filter Container
\ No newline at end of file
AnalysisTreeView_FilterContainer=Filter Container
PluginPreferencesPage_GroupFilter=Filter
PluginPreferencesPage_FilterRegEx=Erlaube regulre Ausdrcke (RegEx)
PluginPreferencesPage_FilterCaseSensitive=Gro-/Kleinschreibung beachten
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment